2018-07-06 13:30:00 +00: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.ModToolBan;
|
|
|
|
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 21:14:53 +03:00
|
|
|
public class BanCommand extends Command {
|
|
|
|
public BanCommand() {
|
2018-07-06 13:30:00 +00:00
|
|
|
super("cmd_ban", Emulator.getTexts().getValue("commands.keys.cmd_ban").split(";"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 21:14:53 +03:00
|
|
|
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
|
|
|
if (params.length < 2) {
|
2018-07-06 13:30:00 +00:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.forgot_user"), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
if (params.length < 3) {
|
2018-07-06 13:30:00 +00:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.forgot_time"), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int banTime;
|
2019-05-26 21:14:53 +03:00
|
|
|
try {
|
2018-07-06 13:30:00 +00:00
|
|
|
banTime = Integer.valueOf(params[2]);
|
2019-05-26 21:14:53 +03:00
|
|
|
} catch (Exception e) {
|
2018-07-06 13:30:00 +00:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.invalid_time"), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
if (banTime < 600) {
|
2018-07-06 13:30:00 +00:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.time_to_short"), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
if (params[1].toLowerCase().equals(gameClient.getHabbo().getHabboInfo().getUsername().toLowerCase())) {
|
2018-07-06 13:30:00 +00:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.ban_self"), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Habbo t = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]);
|
|
|
|
|
2019-03-18 01:22:00 +00:00
|
|
|
HabboInfo target;
|
2019-05-26 21:14:53 +03:00
|
|
|
if (t != null) {
|
2018-07-06 13:30:00 +00:00
|
|
|
target = t.getHabboInfo();
|
2019-05-26 21:14:53 +03:00
|
|
|
} else {
|
2018-07-06 13:30:00 +00:00
|
|
|
target = HabboManager.getOfflineHabboInfo(params[1]);
|
|
|
|
}
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
if (target == null) {
|
2018-07-06 13:30:00 +00:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.user_offline"), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
if (target.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) {
|
2018-07-06 13:30:00 +00:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.target_rank_higher"), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-18 01:22:00 +00:00
|
|
|
StringBuilder reason = new StringBuilder();
|
2018-07-06 13:30:00 +00:00
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
if (params.length > 3) {
|
|
|
|
for (int i = 3; i < params.length; i++) {
|
2019-03-18 01:22:00 +00:00
|
|
|
reason.append(params[i]).append(" ");
|
2018-07-06 13:30:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-18 01:22:00 +00:00
|
|
|
ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().ban(target.getId(), gameClient.getHabbo(), reason.toString(), banTime, ModToolBanType.ACCOUNT, -1).get(0);
|
2018-09-28 19:25:00 +00:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_ban.ban_issued").replace("%user%", target.getUsername()).replace("%time%", ban.expireDate - Emulator.getIntUnixTimestamp() + "").replace("%reason%", ban.reason), RoomChatMessageBubbles.ALERT);
|
2018-07-06 13:30:00 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|