Merge branch '297-userinfosanction' into 'dev'

feat(ModToolUserInfoComposer): display last sanction + small improv.

See merge request morningstar/Arcturus-Community!79
This commit is contained in:
Harmonic 2020-01-22 10:20:31 -05:00
commit b0446cebc4
7 changed files with 93 additions and 67 deletions

View File

@ -142,33 +142,35 @@ public class SecureLoginEvent extends MessageHandler {
this.client.sendResponse(new AchievementListComposer(this.client.getHabbo())); this.client.sendResponse(new AchievementListComposer(this.client.getHabbo()));
ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId());
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId());
if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId());
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId());
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 > 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 <= Emulator.getIntUnixTimestamp()) {
modToolSanctions.updateSanction(item.id, 0, 0); modToolSanctions.updateSanction(item.id, 0, 0);
} }
if (item.tradeLockedUntil > 0 && item.tradeLockedUntil <= Emulator.getIntUnixTimestamp()) { if (item.tradeLockedUntil > 0 && item.tradeLockedUntil <= Emulator.getIntUnixTimestamp()) {
modToolSanctions.updateTradeLockedUntil(item.id, 0); modToolSanctions.updateTradeLockedUntil(item.id, 0);
habbo.getHabboStats().setAllowTrade(true); habbo.getHabboStats().setAllowTrade(true);
} else if (item.tradeLockedUntil > 0 && item.tradeLockedUntil > Emulator.getIntUnixTimestamp()) { } else if (item.tradeLockedUntil > 0 && item.tradeLockedUntil > Emulator.getIntUnixTimestamp()) {
habbo.getHabboStats().setAllowTrade(false); habbo.getHabboStats().setAllowTrade(false);
} }
if (item.isMuted && item.muteDuration <= Emulator.getIntUnixTimestamp()) { if (item.isMuted && item.muteDuration <= Emulator.getIntUnixTimestamp()) {
modToolSanctions.updateMuteDuration(item.id, 0); modToolSanctions.updateMuteDuration(item.id, 0);
habbo.unMute(); habbo.unMute();
} else if (item.isMuted && item.muteDuration > Emulator.getIntUnixTimestamp()) { } else if (item.isMuted && item.muteDuration > Emulator.getIntUnixTimestamp()) {
Date muteDuration = new Date((long) item.muteDuration * 1000); Date muteDuration = new Date((long) item.muteDuration * 1000);
long diff = muteDuration.getTime() - Emulator.getDate().getTime(); long diff = muteDuration.getTime() - Emulator.getDate().getTime();
habbo.mute(Math.toIntExact(diff)); habbo.mute(Math.toIntExact(diff));
}
} }
} }

View File

@ -26,10 +26,11 @@ public class ModToolSanctionAlertEvent extends MessageHandler {
if (habbo != null) { if (habbo != null) {
ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId());
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId());
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());
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId());
if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) { if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) {
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);

View File

@ -50,10 +50,11 @@ public class ModToolSanctionBanEvent extends MessageHandler {
} }
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) { if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId);
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(userId);
if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId);
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(userId);
if (modToolSanctionItems != null && !modToolSanctionItemsHashMap.isEmpty()) { if (modToolSanctionItems != null && !modToolSanctionItemsHashMap.isEmpty()) {
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);

View File

@ -28,10 +28,11 @@ public class ModToolSanctionMuteEvent extends MessageHandler {
if (habbo != null) { if (habbo != null) {
ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId());
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId());
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());
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId());
if (modToolSanctionItems != null && !modToolSanctionItemsHashMap.isEmpty()) { if (modToolSanctionItems != null && !modToolSanctionItemsHashMap.isEmpty()) {
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);

View File

@ -26,10 +26,11 @@ public class ModToolSanctionTradeLockEvent extends MessageHandler {
if (habbo != null) { if (habbo != null) {
ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId);
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(userId);
if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) { if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId);
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(userId);
if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) { if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) {
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);

View File

@ -26,49 +26,52 @@ public class ModToolSanctionInfoComposer extends MessageComposer {
@Override @Override
public ServerMessage compose() { public ServerMessage compose() {
ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions(); ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId());
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId());
Date probationEndTime; Date probationEndTime;
Date probationStartTime = null; Date probationStartTime = null;
if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) { if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1); THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(habbo.getHabboInfo().getId());
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(habbo.getHabboInfo().getId());
boolean prevItem = modToolSanctionItems.size() > 1; if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) {
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel); boolean prevItem = modToolSanctionItems.size() > 1;
ModToolSanctionLevelItem nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel + 1);
if (item.probationTimestamp > 0) { ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel);
probationEndTime = new Date((long) item.probationTimestamp * 1000); ModToolSanctionLevelItem nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel + 1);
probationStartTime = new DateTime(probationEndTime).minusDays(modToolSanctions.getProbationDays(modToolSanctionLevelItem)).toDate(); if (item.probationTimestamp > 0) {
probationEndTime = new Date((long) item.probationTimestamp * 1000);
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); // 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
} }
Date tradeLockedUntil = null;
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 { } else {
this.response.init(Outgoing.ModToolSanctionInfoComposer); this.response.init(Outgoing.ModToolSanctionInfoComposer);

View File

@ -1,12 +1,17 @@
package com.eu.habbo.messages.outgoing.modtool; package com.eu.habbo.messages.outgoing.modtool;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem;
import com.eu.habbo.habbohotel.modtool.ModToolSanctionLevelItem;
import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing; import com.eu.habbo.messages.outgoing.Outgoing;
import gnu.trove.map.hash.THashMap;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
public class ModToolUserInfoComposer extends MessageComposer { public class ModToolUserInfoComposer extends MessageComposer {
private final ResultSet set; private final ResultSet set;
@ -37,11 +42,23 @@ public class ModToolUserInfoComposer extends MessageComposer {
this.response.appendString(this.set.getString("mail")); this.response.appendString(this.set.getString("mail"));
this.response.appendString("Rank (" + this.set.getInt("rank_id") + "): " + this.set.getString("rank_name")); //user_class_txt this.response.appendString("Rank (" + this.set.getInt("rank_id") + "): " + this.set.getString("rank_name")); //user_class_txt
if (false) //has sanction ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
{
this.response.appendString("SOME SANCTION"); if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
this.response.appendInt(31); THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(this.set.getInt("user_id"));
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(this.set.getInt("user_id"));
if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) //has sanction
{
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel);
this.response.appendString(modToolSanctions.getSanctionType(modToolSanctionLevelItem));
this.response.appendInt(31);
}
} }
return this.response; return this.response;
} catch (SQLException e) { } catch (SQLException e) {
Emulator.getLogging().logSQLException(e); Emulator.getLogging().logSQLException(e);