mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
Merge branch '156-sanctions' into 'dev'
feat(sanctions): introduce rudimentary sanction behaviour See merge request morningstar/Arcturus-Community!61
This commit is contained in:
commit
5c3e911217
@ -15,6 +15,7 @@ import com.eu.habbo.habbohotel.guilds.GuildManager;
|
||||
import com.eu.habbo.habbohotel.hotelview.HotelViewManager;
|
||||
import com.eu.habbo.habbohotel.items.ItemManager;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolManager;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
|
||||
import com.eu.habbo.habbohotel.modtool.WordFilter;
|
||||
import com.eu.habbo.habbohotel.navigation.NavigatorManager;
|
||||
import com.eu.habbo.habbohotel.permissions.PermissionsManager;
|
||||
@ -39,6 +40,7 @@ public class GameEnvironment {
|
||||
private PermissionsManager permissionsManager;
|
||||
private BotManager botManager;
|
||||
private ModToolManager modToolManager;
|
||||
private ModToolSanctions modToolSanctions;
|
||||
private PetManager petManager;
|
||||
private AchievementManager achievementManager;
|
||||
private GuideManager guideManager;
|
||||
@ -62,6 +64,7 @@ public class GameEnvironment {
|
||||
this.navigatorManager = new NavigatorManager();
|
||||
this.commandHandler = new CommandHandler();
|
||||
this.modToolManager = new ModToolManager();
|
||||
this.modToolSanctions = new ModToolSanctions();
|
||||
this.achievementManager = new AchievementManager();
|
||||
this.achievementManager.reload();
|
||||
this.guideManager = new GuideManager();
|
||||
@ -145,6 +148,10 @@ public class GameEnvironment {
|
||||
return this.modToolManager;
|
||||
}
|
||||
|
||||
public ModToolSanctions getModToolSanctions() {
|
||||
return this.modToolSanctions;
|
||||
}
|
||||
|
||||
public PetManager getPetManager() {
|
||||
return this.petManager;
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.eu.habbo.habbohotel.modtool;
|
||||
|
||||
public class ModToolSanctionItem {
|
||||
public int id;
|
||||
public int habboId;
|
||||
public int sanctionLevel;
|
||||
public int probationTimestamp;
|
||||
public boolean isMuted;
|
||||
public int muteDuration;
|
||||
public int tradeLockedUntil;
|
||||
public String reason;
|
||||
|
||||
public ModToolSanctionItem(int id, int habboId, int sanctionLevel, int probationTimestamp, boolean isMuted, int muteDuration, int tradeLockedUntil, String reason) {
|
||||
this.id = id;
|
||||
this.habboId = habboId;
|
||||
this.sanctionLevel = sanctionLevel;
|
||||
this.probationTimestamp = probationTimestamp;
|
||||
this.isMuted = isMuted;
|
||||
this.muteDuration = muteDuration;
|
||||
this.tradeLockedUntil = tradeLockedUntil;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.eu.habbo.habbohotel.modtool;
|
||||
|
||||
public class ModToolSanctionLevelItem {
|
||||
public int sanctionLevel;
|
||||
public String sanctionType;
|
||||
public int sanctionHourLength;
|
||||
public int sanctionProbationDays;
|
||||
|
||||
public ModToolSanctionLevelItem(int sanctionLevel, String sanctionType, int sanctionHourLength, int sanctionProbationDays) {
|
||||
this.sanctionLevel = sanctionLevel;
|
||||
this.sanctionType = sanctionType;
|
||||
this.sanctionHourLength = sanctionHourLength;
|
||||
this.sanctionProbationDays = sanctionProbationDays;
|
||||
}
|
||||
}
|
@ -0,0 +1,174 @@
|
||||
package com.eu.habbo.habbohotel.modtool;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.plugin.events.sanctions.SanctionEvent;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
public class ModToolSanctions {
|
||||
|
||||
private final THashMap<Integer, ArrayList<ModToolSanctionItem>> sanctionHashmap;
|
||||
private final THashMap<Integer, ModToolSanctionLevelItem> sanctionLevelsHashmap;
|
||||
|
||||
public ModToolSanctions() {
|
||||
long millis = System.currentTimeMillis();
|
||||
this.sanctionHashmap = new THashMap<>();
|
||||
this.sanctionLevelsHashmap = new THashMap<>();
|
||||
this.loadModSanctions();
|
||||
Emulator.getLogging().logStart("Sanctions Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
|
||||
|
||||
}
|
||||
|
||||
public synchronized void loadModSanctions() {
|
||||
this.sanctionHashmap.clear();
|
||||
this.sanctionLevelsHashmap.clear();
|
||||
|
||||
this.loadSanctionLevels();
|
||||
}
|
||||
|
||||
private void loadSanctionLevels() {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM sanction_levels")) {
|
||||
try (ResultSet set = statement.executeQuery()) {
|
||||
while (set.next()) {
|
||||
this.sanctionLevelsHashmap.put(set.getInt("level"), new ModToolSanctionLevelItem(set.getInt("level"), set.getString("type"), set.getInt("hour_length"), set.getInt("probation_days")));
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public ModToolSanctionLevelItem getSanctionLevelItem(int sanctionLevel) {
|
||||
return this.sanctionLevelsHashmap.get(sanctionLevel);
|
||||
}
|
||||
|
||||
public THashMap<Integer, ArrayList<ModToolSanctionItem>> getSanctions(int habboId) {
|
||||
synchronized (this.sanctionHashmap) {
|
||||
//this.sanctionHashmap.clear(); // TODO: unsure if needed at some point.
|
||||
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()) {
|
||||
while (set.next()) {
|
||||
if (this.sanctionHashmap.get(set.getInt("habbo_id")) == null) {
|
||||
this.sanctionHashmap.put(set.getInt("habbo_id"), new ArrayList<>());
|
||||
}
|
||||
|
||||
ModToolSanctionItem item = new ModToolSanctionItem(set.getInt("id"), set.getInt("habbo_id"), set.getInt("sanction_level"), set.getInt("probation_timestamp"), set.getBoolean("is_muted"), set.getInt("mute_duration"), set.getInt("trade_locked_until"), set.getString("reason"));
|
||||
|
||||
if (!this.sanctionHashmap.get(set.getInt("habbo_id")).contains(item)) {
|
||||
this.sanctionHashmap.get(set.getInt("habbo_id")).add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
|
||||
return this.sanctionHashmap;
|
||||
}
|
||||
}
|
||||
|
||||
private void insertSanction(int habboId, int sanctionLevel, int probationTimestamp, String reason, int tradeLockedUntil, boolean isMuted, int muteDuration) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO sanctions (habbo_id, sanction_level, probation_timestamp, reason, trade_locked_until, is_muted, mute_duration) VALUES (?, ?, ?, ?, ?, ?, ?)")) {
|
||||
statement.setInt(1, habboId);
|
||||
statement.setInt(2, sanctionLevel);
|
||||
statement.setInt(3, probationTimestamp);
|
||||
statement.setString(4, reason);
|
||||
statement.setInt(5, tradeLockedUntil);
|
||||
statement.setBoolean(6, isMuted);
|
||||
statement.setInt(7, muteDuration);
|
||||
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTradeLockedUntil(int rowId, int tradeLockedUntil) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET trade_locked_until = ? WHERE id = ?")) {
|
||||
statement.setInt(1, tradeLockedUntil);
|
||||
statement.setInt(2, rowId);
|
||||
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMuteDuration(int rowId, int muteDuration) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE sanctions SET muted_duration = ? WHERE id = ?")) {
|
||||
statement.setInt(1, muteDuration);
|
||||
statement.setInt(2, rowId);
|
||||
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
Emulator.getLogging().logSQLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void run(int habboId, Habbo self, int sanctionLevel, int cfhTopic, String reason, int tradeLockedUntil, boolean isMuted, int muteDuration) {
|
||||
sanctionLevel++;
|
||||
|
||||
ModToolSanctionLevelItem sanctionLevelItem = getSanctionLevelItem(sanctionLevel);
|
||||
|
||||
insertSanction(habboId, sanctionLevel, buildProbationTimestamp(sanctionLevelItem), reason, tradeLockedUntil, isMuted, muteDuration);
|
||||
|
||||
runSanctionBasedOnLevel(sanctionLevelItem, habboId, reason, cfhTopic, self, muteDuration);
|
||||
|
||||
Emulator.getPluginManager().fireEvent(new SanctionEvent(self, Emulator.getGameEnvironment().getHabboManager().getHabbo(habboId), sanctionLevel));
|
||||
}
|
||||
|
||||
private int buildProbationTimestamp(ModToolSanctionLevelItem sanctionLevelItem) {
|
||||
return Emulator.getIntUnixTimestamp() + (sanctionLevelItem.sanctionProbationDays * 24 * 60 * 60);
|
||||
}
|
||||
|
||||
public int getProbationDays(ModToolSanctionLevelItem sanctionLevelItem) {
|
||||
return sanctionLevelItem.sanctionProbationDays;
|
||||
}
|
||||
|
||||
private void runSanctionBasedOnLevel(ModToolSanctionLevelItem sanctionLevelItem, int habboId, String reason, int cfhTopic, Habbo self, int muteDuration) {
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(habboId);
|
||||
|
||||
int muteDurationSeconds = 0;
|
||||
|
||||
if (muteDuration > 0) {
|
||||
Date muteDurationDate = new Date((long) muteDuration * 1000);
|
||||
long diff = muteDurationDate.getTime() - Emulator.getDate().getTime();
|
||||
muteDurationSeconds = Math.toIntExact(diff / 1000);
|
||||
}
|
||||
|
||||
switch (sanctionLevelItem.sanctionType) {
|
||||
case "ALERT": habbo.alert(reason); break;
|
||||
case "BAN": Emulator.getGameEnvironment().getModToolManager().ban(habboId, self, reason, sanctionLevelItem.sanctionHourLength, ModToolBanType.ACCOUNT, cfhTopic); break;
|
||||
case "MUTE": habbo.mute(muteDurationSeconds == 0 ? 3600 : muteDurationSeconds); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSanctionType(ModToolSanctionLevelItem sanctionLevelItem) {
|
||||
return sanctionLevelItem.sanctionType;
|
||||
}
|
||||
|
||||
public int getTimeOfSanction(ModToolSanctionLevelItem sanctionLevelItem) {
|
||||
return sanctionLevelItem.sanctionHourLength;
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ import com.eu.habbo.messages.incoming.guides.*;
|
||||
import com.eu.habbo.messages.incoming.guilds.*;
|
||||
import com.eu.habbo.messages.incoming.guilds.forums.*;
|
||||
import com.eu.habbo.messages.incoming.handshake.*;
|
||||
import com.eu.habbo.messages.incoming.helper.MySanctionStatusEvent;
|
||||
import com.eu.habbo.messages.incoming.helper.RequestTalentTrackEvent;
|
||||
import com.eu.habbo.messages.incoming.hotelview.*;
|
||||
import com.eu.habbo.messages.incoming.inventory.RequestInventoryBadgesEvent;
|
||||
@ -561,6 +562,7 @@ public class PacketManager {
|
||||
this.registerHandler(Incoming.RequestResolutionEvent, RequestResolutionEvent.class);
|
||||
this.registerHandler(Incoming.RequestTalenTrackEvent, RequestTalentTrackEvent.class);
|
||||
this.registerHandler(Incoming.UnknownEvent1, UnknownEvent1.class);
|
||||
this.registerHandler(Incoming.MySanctionStatusEvent, MySanctionStatusEvent.class);
|
||||
}
|
||||
|
||||
void registerFloorPlanEditor() throws Exception {
|
||||
|
@ -216,6 +216,9 @@ public class Incoming {
|
||||
public static final int PostItRequestDataEvent = 3964;
|
||||
public static final int PostItSaveDataEvent = 3666;
|
||||
public static final int PostItDeleteEvent = 3336;
|
||||
|
||||
public static final int MySanctionStatusEvent = 2746;
|
||||
|
||||
public static final int MoodLightSaveSettingsEvent = 1648;
|
||||
public static final int ModToolRequestIssueChatlogEvent = 211;
|
||||
public static final int ModToolRequestRoomUserChatlogEvent = -1;
|
||||
|
@ -2,6 +2,8 @@ package com.eu.habbo.messages.incoming.handshake;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.messenger.Messenger;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
|
||||
import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
@ -25,13 +27,17 @@ import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer;
|
||||
import com.eu.habbo.messages.outgoing.modtool.CfhTopicsMessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.modtool.ModToolComposer;
|
||||
import com.eu.habbo.messages.outgoing.modtool.ModToolSanctionInfoComposer;
|
||||
import com.eu.habbo.messages.outgoing.navigator.*;
|
||||
import com.eu.habbo.messages.outgoing.unknown.BuildersClubExpiredComposer;
|
||||
import com.eu.habbo.messages.outgoing.users.*;
|
||||
import com.eu.habbo.plugin.events.emulator.SSOAuthenticationEvent;
|
||||
import com.eu.habbo.plugin.events.users.UserLoginEvent;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
@NoAuthMessage
|
||||
public class SecureLoginEvent extends MessageHandler {
|
||||
@ -135,6 +141,37 @@ public class SecureLoginEvent extends MessageHandler {
|
||||
this.client.sendResponse(new InventoryAchievementsComposer());
|
||||
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 (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.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));
|
||||
}
|
||||
}
|
||||
|
||||
Emulator.getPluginManager().fireEvent(new UserLoginEvent(habbo, this.client.getChannel().localAddress()));
|
||||
|
||||
if (Emulator.getConfig().getBoolean("hotel.welcome.alert.enabled")) {
|
||||
|
@ -0,0 +1,12 @@
|
||||
package com.eu.habbo.messages.incoming.helper;
|
||||
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.modtool.ModToolSanctionInfoComposer;
|
||||
|
||||
public class MySanctionStatusEvent extends MessageHandler {
|
||||
|
||||
@Override
|
||||
public void handle() throws Exception {
|
||||
this.client.sendResponse(new ModToolSanctionInfoComposer(this.client.getHabbo()));
|
||||
}
|
||||
}
|
@ -1,10 +1,18 @@
|
||||
package com.eu.habbo.messages.incoming.modtool;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolBanType;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ModToolSanctionAlertEvent extends MessageHandler {
|
||||
@Override
|
||||
@ -17,7 +25,23 @@ public class ModToolSanctionAlertEvent extends MessageHandler {
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.alert(message);
|
||||
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 (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) {
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
|
||||
if (item != null && item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) {
|
||||
modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0);
|
||||
}
|
||||
} else {
|
||||
modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0);
|
||||
}
|
||||
} else {
|
||||
habbo.alert(message);
|
||||
}
|
||||
} else {
|
||||
this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name"))));
|
||||
}
|
||||
|
@ -2,9 +2,16 @@ package com.eu.habbo.messages.incoming.modtool;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolBanType;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
|
||||
import com.eu.habbo.habbohotel.modtool.ScripterManager;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ModToolSanctionBanEvent extends MessageHandler {
|
||||
public static final int BAN_18_HOURS = 3;
|
||||
@ -42,7 +49,24 @@ public class ModToolSanctionBanEvent extends MessageHandler {
|
||||
duration = Emulator.getIntUnixTimestamp();
|
||||
}
|
||||
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
|
||||
Emulator.getGameEnvironment().getModToolManager().ban(userId, this.client.getHabbo(), message, duration, ModToolBanType.ACCOUNT, cfhTopic);
|
||||
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 (modToolSanctionItems != null && !modToolSanctionItemsHashMap.isEmpty()) {
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
|
||||
if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) {
|
||||
modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, false, 0);
|
||||
}
|
||||
} else {
|
||||
modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0);
|
||||
}
|
||||
} else {
|
||||
Emulator.getGameEnvironment().getModToolManager().ban(userId, this.client.getHabbo(), message, duration, ModToolBanType.ACCOUNT, cfhTopic);
|
||||
}
|
||||
|
||||
} else {
|
||||
ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.ban").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()));
|
||||
}
|
||||
|
@ -1,10 +1,20 @@
|
||||
package com.eu.habbo.messages.incoming.modtool;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolBanType;
|
||||
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.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
public class ModToolSanctionMuteEvent extends MessageHandler {
|
||||
@Override
|
||||
@ -17,9 +27,29 @@ public class ModToolSanctionMuteEvent extends MessageHandler {
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.mute(60 * 60);
|
||||
habbo.alert(message);
|
||||
this.client.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute.muted").replace("%user%", habbo.getHabboInfo().getUsername()));
|
||||
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 (modToolSanctionItems != null && !modToolSanctionItemsHashMap.isEmpty()) {
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
|
||||
if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) {
|
||||
ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel);
|
||||
|
||||
int muteDurationTimestamp = Math.toIntExact(new Date( System.currentTimeMillis() + (modToolSanctionLevelItem.sanctionHourLength * 60 * 60)).getTime() / 1000);
|
||||
|
||||
modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, 0, true, muteDurationTimestamp);
|
||||
}
|
||||
} else {
|
||||
modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, 0, false, 0);
|
||||
}
|
||||
} else {
|
||||
habbo.mute(60 * 60);
|
||||
habbo.alert(message);
|
||||
this.client.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_mute.muted").replace("%user%", habbo.getHabboInfo().getUsername()));
|
||||
}
|
||||
} else {
|
||||
this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name"))));
|
||||
}
|
||||
|
@ -1,10 +1,17 @@
|
||||
package com.eu.habbo.messages.incoming.modtool;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolSanctionItem;
|
||||
import com.eu.habbo.habbohotel.modtool.ModToolSanctions;
|
||||
import com.eu.habbo.habbohotel.permissions.Permission;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||
import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer;
|
||||
import gnu.trove.map.hash.THashMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ModToolSanctionTradeLockEvent extends MessageHandler {
|
||||
@Override
|
||||
@ -18,8 +25,24 @@ public class ModToolSanctionTradeLockEvent extends MessageHandler {
|
||||
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
|
||||
|
||||
if (habbo != null) {
|
||||
habbo.getHabboStats().setAllowTrade(false);
|
||||
habbo.alert(message);
|
||||
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 (modToolSanctionItems != null && !modToolSanctionItems.isEmpty()) {
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
|
||||
if (item.probationTimestamp > 0 && item.probationTimestamp >= Emulator.getIntUnixTimestamp()) {
|
||||
modToolSanctions.run(userId, this.client.getHabbo(), item.sanctionLevel, cfhTopic, message, duration, false, 0);
|
||||
}
|
||||
} else {
|
||||
modToolSanctions.run(userId, this.client.getHabbo(), 0, cfhTopic, message, duration, false, 0);
|
||||
}
|
||||
} else {
|
||||
habbo.getHabboStats().setAllowTrade(false);
|
||||
habbo.alert(message);
|
||||
}
|
||||
} else {
|
||||
this.client.sendResponse(new ModToolIssueHandledComposer(Emulator.getTexts().getValue("generic.user.not_found").replace("%user%", Emulator.getConfig().getValue("hotel.player.name"))));
|
||||
}
|
||||
|
@ -1,26 +1,98 @@
|
||||
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.habbohotel.users.Habbo;
|
||||
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 org.joda.time.DateTime;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
public class ModToolSanctionInfoComposer extends MessageComposer {
|
||||
|
||||
private final Habbo habbo;
|
||||
|
||||
public ModToolSanctionInfoComposer(Habbo habbo) {
|
||||
this.habbo = habbo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerMessage compose() {
|
||||
this.response.init(Outgoing.ModToolSanctionInfoComposer);
|
||||
this.response.appendBoolean(false); //Has Last Sanction.
|
||||
this.response.appendBoolean(false); //Is probabtion.
|
||||
this.response.appendString("<< Last Sanction >>");
|
||||
this.response.appendInt(0); //Value | Probation days left.
|
||||
this.response.appendInt(-1); //Unused
|
||||
this.response.appendString("<< Reason >>"); //Reason
|
||||
this.response.appendString("1/1/1970 00:00"); //Start Time
|
||||
this.response.appendInt(0); //Probation Days Left
|
||||
this.response.appendString("<< Next Sanction >>"); //Next Sanction
|
||||
this.response.appendInt(0); //Value
|
||||
this.response.appendInt(-1); //Unused
|
||||
this.response.appendBoolean(false); //Trade Locked
|
||||
this.response.appendString("1/1/1970 00:00"); //Trade Locked Untill
|
||||
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;
|
||||
long numberOfDaysProbation = 0;
|
||||
long numberOfHoursProbation = 0;
|
||||
|
||||
if (modToolSanctionItems != null && modToolSanctionItems.size() > 0) {
|
||||
ModToolSanctionItem item = modToolSanctionItems.get(modToolSanctionItems.size() - 1);
|
||||
|
||||
boolean prevItem = modToolSanctionItems.size() > 1;
|
||||
|
||||
ModToolSanctionLevelItem modToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel);
|
||||
ModToolSanctionLevelItem nextModToolSanctionLevelItem = modToolSanctions.getSanctionLevelItem(item.sanctionLevel + 1);
|
||||
|
||||
if (item.probationTimestamp > 0) {
|
||||
probationEndTime = new Date((long) item.probationTimestamp * 1000);
|
||||
long diff = probationEndTime.getTime() - Emulator.getDate().getTime();
|
||||
numberOfDaysProbation = diff / 1000 / 60 / 60 / 24;
|
||||
numberOfHoursProbation = diff / 1000 / 60 / 60;
|
||||
|
||||
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(Math.toIntExact(numberOfDaysProbation)); // probation days left
|
||||
this.response.appendInt(30); // 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(Math.toIntExact(numberOfHoursProbation)); // days of probation in hours?
|
||||
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); // 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); // probation days left
|
||||
this.response.appendInt(30); // unused?
|
||||
this.response.appendString("cfh.reason.EMPTY"); // reason
|
||||
this.response.appendString(Emulator.getDate().toString()); // probation start time
|
||||
this.response.appendInt(0); // days of probation in hours?
|
||||
this.response.appendString("ALERT"); // next sanction type
|
||||
this.response.appendInt(0); // time to be applied in next sanction (in hours)
|
||||
this.response.appendInt(30); // unused?
|
||||
this.response.appendBoolean(false); // muted
|
||||
this.response.appendString(""); // trade locked until
|
||||
|
||||
}
|
||||
|
||||
return this.response;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.eu.habbo.plugin.events.sanctions;
|
||||
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.plugin.events.support.SupportEvent;
|
||||
|
||||
public class SanctionEvent extends SupportEvent {
|
||||
public Habbo target;
|
||||
|
||||
public int sanctionLevel;
|
||||
|
||||
public SanctionEvent(Habbo moderator, Habbo target, int sanctionLevel) {
|
||||
super(moderator);
|
||||
|
||||
this.target = target;
|
||||
this.sanctionLevel = sanctionLevel;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user