mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 00:40:52 +01:00
feat(ModToolUserInfoComposer): display last sanction + small improv.
This commit is contained in:
parent
060a5a6bc6
commit
4360507fa8
@ -142,33 +142,35 @@ public class SecureLoginEvent extends MessageHandler {
|
||||
this.client.sendResponse(new AchievementListComposer(this.client.getHabbo()));
|
||||
|
||||
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) {
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) {
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
|
||||
if (item.sanctionLevel > 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);
|
||||
}
|
||||
if (item.sanctionLevel > 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);
|
||||
}
|
||||
|
||||
if (item.tradeLockedUntil > 0 && item.tradeLockedUntil <= Emulator.getIntUnixTimestamp()) {
|
||||
modToolSanctions.updateTradeLockedUntil(item.id, 0);
|
||||
habbo.getHabboStats().setAllowTrade(true);
|
||||
} else if (item.tradeLockedUntil > 0 && item.tradeLockedUntil > Emulator.getIntUnixTimestamp()) {
|
||||
habbo.getHabboStats().setAllowTrade(false);
|
||||
}
|
||||
if (item.tradeLockedUntil > 0 && item.tradeLockedUntil <= Emulator.getIntUnixTimestamp()) {
|
||||
modToolSanctions.updateTradeLockedUntil(item.id, 0);
|
||||
habbo.getHabboStats().setAllowTrade(true);
|
||||
} else if (item.tradeLockedUntil > 0 && item.tradeLockedUntil > Emulator.getIntUnixTimestamp()) {
|
||||
habbo.getHabboStats().setAllowTrade(false);
|
||||
}
|
||||
|
||||
if (item.isMuted && item.muteDuration <= Emulator.getIntUnixTimestamp()) {
|
||||
modToolSanctions.updateMuteDuration(item.id, 0);
|
||||
habbo.unMute();
|
||||
} else if (item.isMuted && item.muteDuration > Emulator.getIntUnixTimestamp()) {
|
||||
Date muteDuration = new Date((long) item.muteDuration * 1000);
|
||||
long diff = muteDuration.getTime() - Emulator.getDate().getTime();
|
||||
habbo.mute(Math.toIntExact(diff));
|
||||
if (item.isMuted && item.muteDuration <= Emulator.getIntUnixTimestamp()) {
|
||||
modToolSanctions.updateMuteDuration(item.id, 0);
|
||||
habbo.unMute();
|
||||
} else if (item.isMuted && item.muteDuration > Emulator.getIntUnixTimestamp()) {
|
||||
Date muteDuration = new Date((long) item.muteDuration * 1000);
|
||||
long diff = muteDuration.getTime() - Emulator.getDate().getTime();
|
||||
habbo.mute(Math.toIntExact(diff));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,10 +26,11 @@ public class ModToolSanctionAlertEvent extends MessageHandler {
|
||||
|
||||
if (habbo != null) {
|
||||
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.isEmpty()) {
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
|
||||
|
@ -50,10 +50,11 @@ public class ModToolSanctionBanEvent extends MessageHandler {
|
||||
}
|
||||
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
|
||||
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")) {
|
||||
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId);
|
||||
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(userId);
|
||||
|
||||
if (modToolSanctionItems != null && !modToolSanctionItemsHashMap.isEmpty()) {
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
|
||||
|
@ -28,10 +28,11 @@ public class ModToolSanctionMuteEvent extends MessageHandler {
|
||||
|
||||
if (habbo != null) {
|
||||
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 && !modToolSanctionItemsHashMap.isEmpty()) {
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
|
||||
|
@ -26,10 +26,11 @@ public class ModToolSanctionTradeLockEvent extends MessageHandler {
|
||||
|
||||
if (habbo != null) {
|
||||
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")) {
|
||||
THashMap<Integer, ArrayList<ModToolSanctionItem>> modToolSanctionItemsHashMap = Emulator.getGameEnvironment().getModToolSanctions().getSanctions(userId);
|
||||
ArrayList<ModToolSanctionItem> modToolSanctionItems = modToolSanctionItemsHashMap.get(userId);
|
||||
|
||||
if (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) {
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
|
||||
|
@ -26,49 +26,52 @@ public class ModToolSanctionInfoComposer extends MessageComposer {
|
||||
@Override
|
||||
public ServerMessage compose() {
|
||||
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 probationStartTime = null;
|
||||
|
||||
if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) {
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
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());
|
||||
|
||||
boolean prevItem = modToolSanctionItems.size() > 1;
|
||||
if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) {
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
|
||||
ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel);
|
||||
ModToolSanctionLevelItem nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel + 1);
|
||||
boolean prevItem = modToolSanctionItems.size() > 1;
|
||||
|
||||
if (item.probationTimestamp > 0) {
|
||||
probationEndTime = new Date((long) item.probationTimestamp * 1000);
|
||||
ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel);
|
||||
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 {
|
||||
this.response.init(Outgoing.ModToolSanctionInfoComposer);
|
||||
|
||||
|
@ -1,12 +1,17 @@
|
||||
package com.eu.habbo.messages.outgoing.modtool;
|
||||
|
||||
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.outgoing.MessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ModToolUserInfoComposer extends MessageComposer {
|
||||
private final ResultSet set;
|
||||
@ -37,11 +42,23 @@ public class ModToolUserInfoComposer extends MessageComposer {
|
||||
this.response.appendString(this.set.getString("mail"));
|
||||
this.response.appendString("Rank (" + this.set.getInt("rank_id") + "): " + this.set.getString("rank_name")); //user_class_txt
|
||||
|
||||
if (false) //has sanction
|
||||
{
|
||||
this.response.appendString("SOME SANCTION");
|
||||
this.response.appendInt(31);
|
||||
ModToolSanctions modToolSanctions = Emulator.getGameEnvironment().getModToolSanctions();
|
||||
|
||||
if (Emulator.getConfig().getBoolean("hotel.sanctions.enabled")) {
|
||||
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;
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
|
Loading…
Reference in New Issue
Block a user