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

61 lines
2.4 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 MachineBanCommand extends Command {
public MachineBanCommand() {
2018-07-06 15:30:00 +02:00
super("cmd_machine_ban", Emulator.getTexts().getValue("commands.keys.cmd_machine_ban").split(";"));
}
@Override
2019-05-26 20:14:53 +02:00
public boolean handle(GameClient gameClient, String[] params) throws Exception {
2018-07-06 15:30:00 +02:00
HabboInfo habbo = null;
2019-03-18 02:22:00 +01:00
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
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
}
}
2019-03-18 02:22:00 +01:00
int count;
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_machine_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
count = Emulator.getGameEnvironment().getModToolManager().ban(habbo.getId(), gameClient.getHabbo(), reason.toString(), IPBanCommand.TEN_YEARS, ModToolBanType.MACHINE, -1).size();
2018-09-28 21:25: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_machine_ban").replace("%count%", count + ""), RoomChatMessageBubbles.ALERT);
return true;
}
}