mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
fix(sanctions): check if sanctions are active/ignore level 0's
This commit is contained in:
parent
67f4e27904
commit
8be461354c
@ -51,7 +51,7 @@ public class ModToolSanctions {
|
|||||||
|
|
||||||
public THashMap<Integer, ArrayList<ModToolSanctionItem>> getSanctions(int habboId) {
|
public THashMap<Integer, ArrayList<ModToolSanctionItem>> getSanctions(int habboId) {
|
||||||
synchronized (this.sanctionHashmap) {
|
synchronized (this.sanctionHashmap) {
|
||||||
//this.sanctionHashmap.clear(); // TODO: unsure if needed at some point.
|
this.sanctionHashmap.clear();
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM sanctions WHERE habbo_id = ? ORDER BY id ASC")) {
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM sanctions WHERE habbo_id = ? ORDER BY id ASC")) {
|
||||||
statement.setInt(1, habboId);
|
statement.setInt(1, habboId);
|
||||||
try (ResultSet set = statement.executeQuery()) {
|
try (ResultSet set = statement.executeQuery()) {
|
||||||
@ -91,11 +91,10 @@ public class ModToolSanctions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSanction(int rowId, int sanctionLevel, int probationTimestamp) {
|
public void updateSanction(int rowId, int probationTimestamp) {
|
||||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET sanction_level = ? AND probation_timestamp = ? WHERE id = ?")) {
|
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET probation_timestamp = ? WHERE id = ?")) {
|
||||||
statement.setInt(1, sanctionLevel);
|
statement.setInt(1, probationTimestamp);
|
||||||
statement.setInt(2, probationTimestamp);
|
statement.setInt(2, rowId);
|
||||||
statement.setInt(3, rowId);
|
|
||||||
|
|
||||||
statement.execute();
|
statement.execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
@ -150,10 +150,10 @@ public class SecureLoginEvent extends MessageHandler {
|
|||||||
if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) {
|
if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) {
|
||||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||||
|
|
||||||
if (item.sanctionLevel > 0 && item.probationTimestamp > Emulator.getIntUnixTimestamp()) {
|
if (item.sanctionLevel > 0 && item.probationTimestamp != 0 && item.probationTimestamp > Emulator.getIntUnixTimestamp()) {
|
||||||
this.client.sendResponse(new ModToolSanctionInfoComposer(this.client.getHabbo()));
|
this.client.sendResponse(new ModToolSanctionInfoComposer(this.client.getHabbo()));
|
||||||
} else if (item.sanctionLevel > 0 && item.probationTimestamp <= Emulator.getIntUnixTimestamp()) {
|
} else if (item.sanctionLevel > 0 && item.probationTimestamp != 0 && item.probationTimestamp <= Emulator.getIntUnixTimestamp()) {
|
||||||
modToolSanctions.updateSanction(item.id, 0, 0);
|
modToolSanctions.updateSanction(item.id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.tradeLockedUntil > 0 && item.tradeLockedUntil <= Emulator.getIntUnixTimestamp()) {
|
if (item.tradeLockedUntil > 0 && item.tradeLockedUntil <= Emulator.getIntUnixTimestamp()) {
|
||||||
|
@ -28,7 +28,7 @@ public class ModToolSanctionInfoComposer extends MessageComposer {
|
|||||||
ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
|
ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
|
||||||
|
|
||||||
Date probationEndTime;
|
Date probationEndTime;
|
||||||
Date probationStartTime = null;
|
Date probationStartTime;
|
||||||
|
|
||||||
if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
|
if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
|
||||||
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId());
|
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId());
|
||||||
@ -37,7 +37,10 @@ public class ModToolSanctionInfoComposer extends MessageComposer {
|
|||||||
if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) {
|
if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) {
|
||||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||||
|
|
||||||
boolean prevItem = modToolSanctionItems.size() > 1;
|
ModToolSanctionItem prevItem = null;
|
||||||
|
if (modToolSanctionItems.get(modToolSanctionItems.size() - 2) != null) {
|
||||||
|
prevItem = modToolSanctionItems.get(modToolSanctionItems.size() - 2);
|
||||||
|
}
|
||||||
|
|
||||||
ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel);
|
ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel);
|
||||||
ModToolSanctionLevelItem nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel + 1);
|
ModToolSanctionLevelItem nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel + 1);
|
||||||
@ -47,50 +50,56 @@ public class ModToolSanctionInfoComposer extends MessageComposer {
|
|||||||
|
|
||||||
probationStartTime = new DateTime(probationEndTime).minusDays(modToolSanctions.getProbationDays(modToolSanctionLevelItem)).toDate();
|
probationStartTime = new DateTime(probationEndTime).minusDays(modToolSanctions.getProbationDays(modToolSanctionLevelItem)).toDate();
|
||||||
|
|
||||||
|
Date tradeLockedUntil = null;
|
||||||
|
|
||||||
|
if (item.tradeLockedUntil > 0) {
|
||||||
|
tradeLockedUntil = new Date((long) item.tradeLockedUntil * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.response.init(Outgoing.ModToolSanctionInfoComposer);
|
||||||
|
|
||||||
|
this.response.appendBoolean(prevItem != null && prevItem.probationTimestamp > 0); // has prev sanction
|
||||||
|
this.response.appendBoolean(item.probationTimestamp >= Emulator.getIntUnixTimestamp()); // is on probation
|
||||||
|
this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem)); // current sanction type
|
||||||
|
this.response.appendInt(modToolSanctions.getTimeOfSanction(modToolSanctionLevelItem)); // time of current sanction
|
||||||
|
this.response.appendInt(30); // TODO: unused?
|
||||||
|
this.response.appendString(item.reason.equals("") ? "cfh.reason.EMPTY" : item.reason); // reason
|
||||||
|
this.response.appendString(probationStartTime == null ? Emulator.getDate().toString() : probationStartTime.toString()); // probation start time
|
||||||
|
this.response.appendInt(0); // TODO: unused?
|
||||||
|
this.response.appendString(modToolSanctions.getSanctionType(nextModToolSanctionLevelItem)); // next sanction type
|
||||||
|
this.response.appendInt(modToolSanctions.getTimeOfSanction(nextModToolSanctionLevelItem)); // time to be applied in next sanction (in hours)
|
||||||
|
this.response.appendInt(30); // TODO: unused?
|
||||||
|
this.response.appendBoolean(item.isMuted); // muted
|
||||||
|
this.response.appendString(tradeLockedUntil == null ? "" : tradeLockedUntil.toString()); // trade locked until
|
||||||
|
} else {
|
||||||
|
return cleanResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
Date tradeLockedUntil = null;
|
} else {
|
||||||
|
return cleanResponse();
|
||||||
if (item.tradeLockedUntil > 0) {
|
|
||||||
tradeLockedUntil = new Date((long) item.tradeLockedUntil * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.response.init(Outgoing.ModToolSanctionInfoComposer);
|
|
||||||
|
|
||||||
this.response.appendBoolean(prevItem); // has prev sanction
|
|
||||||
this.response.appendBoolean(item.probationTimestamp >= Emulator.getIntUnixTimestamp()); // is on probation
|
|
||||||
this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem)); // current sanction type
|
|
||||||
this.response.appendInt(modToolSanctions.getTimeOfSanction(modToolSanctionLevelItem)); // time of current sanction
|
|
||||||
this.response.appendInt(30); // TODO: unused?
|
|
||||||
this.response.appendString(item.reason.equals("") ? "cfh.reason.EMPTY" : item.reason); // reason
|
|
||||||
this.response.appendString(probationStartTime == null ? Emulator.getDate().toString() : probationStartTime.toString()); // probation start time
|
|
||||||
this.response.appendInt(0); // TODO: unused?
|
|
||||||
this.response.appendString(modToolSanctions.getSanctionType(nextModToolSanctionLevelItem)); // next sanction type
|
|
||||||
this.response.appendInt(modToolSanctions.getTimeOfSanction(nextModToolSanctionLevelItem)); // time to be applied in next sanction (in hours)
|
|
||||||
this.response.appendInt(30); // TODO: unused?
|
|
||||||
this.response.appendBoolean(item.isMuted); // muted
|
|
||||||
this.response.appendString(tradeLockedUntil == null ? "" : tradeLockedUntil.toString()); // trade locked until
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.response.init(Outgoing.ModToolSanctionInfoComposer);
|
|
||||||
|
|
||||||
this.response.appendBoolean(false); // has prev sanction
|
|
||||||
this.response.appendBoolean(false); // is on probation
|
|
||||||
this.response.appendString("ALERT"); // last sanction type
|
|
||||||
this.response.appendInt(0); // time of current sanction
|
|
||||||
this.response.appendInt(30); // TODO: unused?
|
|
||||||
this.response.appendString("cfh.reason.EMPTY"); // reason
|
|
||||||
this.response.appendString(Emulator.getDate().toString()); // probation start time
|
|
||||||
this.response.appendInt(0); // TODO: unused?
|
|
||||||
this.response.appendString("ALERT"); // next sanction type
|
|
||||||
this.response.appendInt(0); // time to be applied in next sanction (in hours)
|
|
||||||
this.response.appendInt(30); // TODO: unused?
|
|
||||||
this.response.appendBoolean(false); // muted
|
|
||||||
this.response.appendString(""); // trade locked until
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.response;
|
return this.response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ServerMessage cleanResponse() {
|
||||||
|
this.response.init(Outgoing.ModToolSanctionInfoComposer);
|
||||||
|
|
||||||
|
this.response.appendBoolean(false); // has prev sanction
|
||||||
|
this.response.appendBoolean(false); // is on probation
|
||||||
|
this.response.appendString("ALERT"); // last sanction type
|
||||||
|
this.response.appendInt(0); // time of current sanction
|
||||||
|
this.response.appendInt(30); // TODO: unused?
|
||||||
|
this.response.appendString("cfh.reason.EMPTY"); // reason
|
||||||
|
this.response.appendString(Emulator.getDate().toString()); // probation start time
|
||||||
|
this.response.appendInt(0); // TODO: unused?
|
||||||
|
this.response.appendString("ALERT"); // next sanction type
|
||||||
|
this.response.appendInt(0); // time to be applied in next sanction (in hours)
|
||||||
|
this.response.appendInt(30); // TODO: unused?
|
||||||
|
this.response.appendBoolean(false); // muted
|
||||||
|
this.response.appendString(""); // trade locked until
|
||||||
|
|
||||||
|
return this.response;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user