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) {
|
||||
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")) {
|
||||
statement.setInt(1, habboId);
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
@ -91,11 +91,10 @@ public class ModToolSanctions {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSanction(int rowId, int sanctionLevel, int probationTimestamp) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET sanction_level = ? AND probation_timestamp = ? WHERE id = ?")) {
|
||||
statement.setInt(1, sanctionLevel);
|
||||
statement.setInt(2, probationTimestamp);
|
||||
statement.setInt(3, rowId);
|
||||
public void updateSanction(int rowId, int probationTimestamp) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET probation_timestamp = ? WHERE id = ?")) {
|
||||
statement.setInt(1, probationTimestamp);
|
||||
statement.setInt(2, rowId);
|
||||
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
|
@ -150,10 +150,10 @@ public class SecureLoginEvent extends MessageHandler {
|
||||
if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) {
|
||||
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()));
|
||||
} else if (item.sanctionLevel > 0 && item.probationTimestamp <= Emulator.getIntUnixTimestamp()) {
|
||||
modToolSanctions.updateSanction(item.id, 0, 0);
|
||||
} else if (item.sanctionLevel > 0 && item.probationTimestamp != 0 && item.probationTimestamp <= Emulator.getIntUnixTimestamp()) {
|
||||
modToolSanctions.updateSanction(item.id, 0);
|
||||
}
|
||||
|
||||
if (item.tradeLockedUntil > 0 && item.tradeLockedUntil <= Emulator.getIntUnixTimestamp()) {
|
||||
|
@ -28,7 +28,7 @@ public class ModToolSanctionInfoComposer extends MessageComposer {
|
||||
ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
|
||||
|
||||
Date probationEndTime;
|
||||
Date probationStartTime = null;
|
||||
Date probationStartTime;
|
||||
|
||||
if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
|
||||
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) {
|
||||
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 nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel + 1);
|
||||
@ -47,8 +50,6 @@ public class ModToolSanctionInfoComposer extends MessageComposer {
|
||||
|
||||
probationStartTime = new DateTime(probationEndTime).minusDays(modToolSanctions.getProbationDays(modToolSanctionLevelItem)).toDate();
|
||||
|
||||
}
|
||||
|
||||
Date tradeLockedUntil = null;
|
||||
|
||||
if (item.tradeLockedUntil > 0) {
|
||||
@ -57,7 +58,7 @@ public class ModToolSanctionInfoComposer extends MessageComposer {
|
||||
|
||||
this.response.init(Outgoing.ModToolSanctionInfoComposer);
|
||||
|
||||
this.response.appendBoolean(prevItem); // has prev sanction
|
||||
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
|
||||
@ -70,9 +71,19 @@ public class ModToolSanctionInfoComposer extends MessageComposer {
|
||||
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();
|
||||
}
|
||||
|
||||
} else {
|
||||
return cleanResponse();
|
||||
}
|
||||
}
|
||||
|
||||
return this.response;
|
||||
}
|
||||
|
||||
private ServerMessage cleanResponse() {
|
||||
this.response.init(Outgoing.ModToolSanctionInfoComposer);
|
||||
|
||||
this.response.appendBoolean(false); // has prev sanction
|
||||
@ -89,8 +100,6 @@ public class ModToolSanctionInfoComposer extends MessageComposer {
|
||||
this.response.appendBoolean(false); // muted
|
||||
this.response.appendString(""); // trade locked until
|
||||
|
||||
}
|
||||
|
||||
return this.response;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user