2018-07-06 15:30:00 +02:00
|
|
|
package com.eu.habbo.habbohotel.commands;
|
|
|
|
|
|
|
|
import com.eu.habbo.Emulator;
|
|
|
|
import com.eu.habbo.habbohotel.bots.Bot;
|
|
|
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
2018-09-12 18:45:00 +02:00
|
|
|
import com.eu.habbo.habbohotel.permissions.Permission;
|
2018-07-06 15:30:00 +02:00
|
|
|
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
|
|
|
import com.eu.habbo.habbohotel.users.Habbo;
|
2020-07-14 02:20:11 +02:00
|
|
|
import com.eu.habbo.messages.outgoing.inventory.InventoryBotsComposer;
|
2018-07-06 15:30:00 +02:00
|
|
|
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
|
|
|
|
import gnu.trove.map.hash.TIntObjectHashMap;
|
|
|
|
import gnu.trove.procedure.TObjectProcedure;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public class EmptyBotsInventoryCommand extends Command {
|
|
|
|
public EmptyBotsInventoryCommand() {
|
2018-07-06 15:30:00 +02:00
|
|
|
super("cmd_empty_bots", Emulator.getTexts().getValue("commands.keys.cmd_empty_bots").split(";"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
|
|
|
if (params.length == 1 || (params.length >= 2 && !params[1].equals(Emulator.getTexts().getValue("generic.yes")))) {
|
|
|
|
if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
|
|
|
|
if (gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) {
|
2019-03-18 02:22:00 +01:00
|
|
|
gameClient.getHabbo().alert(Emulator.getTexts().getValue("commands.succes.cmd_empty_bots.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes")));
|
2019-05-26 20:14:53 +02:00
|
|
|
} else {
|
2018-07-06 15:30:00 +02:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty_bots.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes")), RoomChatMessageBubbles.ALERT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (params.length >= 2 && params[1].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) {
|
2020-07-14 02:20:11 +02:00
|
|
|
|
|
|
|
Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo();
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (habbo != null) {
|
2018-07-06 15:30:00 +02:00
|
|
|
TIntObjectHashMap<Bot> bots = new TIntObjectHashMap<>();
|
|
|
|
bots.putAll(habbo.getInventory().getBotsComponent().getBots());
|
|
|
|
habbo.getInventory().getBotsComponent().getBots().clear();
|
2020-07-14 02:20:11 +02:00
|
|
|
bots.forEachValue(object -> {
|
|
|
|
Emulator.getGameEnvironment().getBotManager().deleteBot(object);
|
|
|
|
return true;
|
2018-07-06 15:30:00 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
habbo.getClient().sendResponse(new InventoryRefreshComposer());
|
2020-07-14 02:20:11 +02:00
|
|
|
habbo.getClient().sendResponse(new InventoryBotsComposer(habbo));
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2020-07-14 02:20:11 +02:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty_bots.cleared").replace("%username%", habbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT);
|
|
|
|
} else {
|
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_empty_bots"), RoomChatMessageBubbles.ALERT);
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|