Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/commands/IPBanCommand.java

71 lines
2.8 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.modtool.ModToolBanType;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.users.HabboManager;
2019-05-26 20:14:53 +02:00
public class IPBanCommand extends Command {
2018-07-06 15:30:00 +02:00
public final static int TEN_YEARS = 315569260;
2019-05-26 20:14:53 +02:00
public IPBanCommand() {
2018-07-06 15:30:00 +02:00
super("cmd_ip_ban", Emulator.getTexts().getValue("commands.keys.cmd_ip_ban").split(";"));
}
@Override
2019-05-26 20:14:53 +02:00
public boolean handle(GameClient gameClient, String[] params) throws Exception {
2019-03-18 02:22:00 +01:00
HabboInfo habbo;
StringBuilder reason = new StringBuilder();
2019-05-26 20:14:53 +02:00
if (params.length >= 2) {
2018-07-06 15:30:00 +02:00
Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]);
2019-05-26 20:14:53 +02:00
if (h != null) {
2018-07-06 15:30:00 +02:00
habbo = h.getHabboInfo();
2019-05-26 20:14:53 +02:00
} else {
2018-07-06 15:30:00 +02:00
habbo = HabboManager.getOfflineHabboInfo(params[1]);
}
2019-05-26 20:14:53 +02:00
} else {
2018-07-06 15:30:00 +02:00
return true;
}
2019-05-26 20:14:53 +02:00
if (params.length > 2) {
for (int i = 2; i < params.length; i++) {
2019-03-18 02:22:00 +01:00
reason.append(params[i]);
reason.append(" ");
2018-07-06 15:30:00 +02:00
}
}
int count = 0;
2019-05-26 20:14:53 +02:00
if (habbo != null) {
if (habbo == gameClient.getHabbo().getHabboInfo()) {
2018-07-06 15:30:00 +02:00
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ip_ban.ban_self"), RoomChatMessageBubbles.ALERT);
return true;
}
2019-05-26 20:14:53 +02:00
if (habbo.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) {
2018-07-06 15:30:00 +02:00
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.target_rank_higher"), RoomChatMessageBubbles.ALERT);
return true;
}
2019-03-18 02:22:00 +01:00
Emulator.getGameEnvironment().getModToolManager().ban(habbo.getId(), gameClient.getHabbo(), reason.toString(), TEN_YEARS, ModToolBanType.IP, -1);
2018-07-06 15:30:00 +02:00
count++;
2019-05-26 20:14:53 +02:00
for (Habbo h : Emulator.getGameServer().getGameClientManager().getHabbosWithIP(habbo.getIpLogin())) {
if (h != null) {
2018-07-06 15:30:00 +02:00
count++;
2019-03-18 02:22:00 +01:00
Emulator.getGameEnvironment().getModToolManager().ban(h.getHabboInfo().getId(), gameClient.getHabbo(), reason.toString(), TEN_YEARS, ModToolBanType.IP, -1);
2018-07-06 15:30:00 +02:00
}
}
2019-05-26 20:14:53 +02:00
} else {
2018-07-06 15:30:00 +02:00
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.user_offline"), RoomChatMessageBubbles.ALERT);
return true;
}
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_ip_ban").replace("%count%", count + ""), RoomChatMessageBubbles.ALERT);
return true;
}
}