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.rooms.RoomChatMessageBubbles;
|
|
|
|
import com.eu.habbo.habbohotel.users.Habbo;
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
public class ControlCommand extends Command {
|
|
|
|
public ControlCommand() {
|
2018-07-06 13:30:00 +00:00
|
|
|
super("cmd_control", Emulator.getTexts().getValue("commands.keys.cmd_control").split(";"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 21:14:53 +03:00
|
|
|
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
|
|
|
if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
|
|
|
|
if (params.length == 2) {
|
2018-07-06 13:30:00 +00:00
|
|
|
Habbo target = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbo(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_control.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
if (target == gameClient.getHabbo()) {
|
2018-07-06 13:30:00 +00:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_control.not_self"), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
Habbo oldHabbo = (Habbo) gameClient.getHabbo().getRoomUnit().getCacheable().remove("control");
|
2018-07-06 13:30:00 +00:00
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
if (oldHabbo != null) {
|
2018-07-06 13:30:00 +00:00
|
|
|
oldHabbo.getRoomUnit().getCacheable().remove("controller");
|
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_control.stopped").replace("%user%", oldHabbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT);
|
|
|
|
}
|
|
|
|
gameClient.getHabbo().getRoomUnit().getCacheable().put("control", target);
|
|
|
|
target.getRoomUnit().getCacheable().put("controller", gameClient.getHabbo());
|
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_control.controlling").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
2019-05-26 21:14:53 +03:00
|
|
|
} else {
|
2018-07-06 13:30:00 +00:00
|
|
|
Object habbo = gameClient.getHabbo().getRoomUnit().getCacheable().get("control");
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
if (habbo != null) {
|
2018-07-06 13:30:00 +00:00
|
|
|
gameClient.getHabbo().getRoomUnit().getCacheable().remove("control");
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_control.stopped").replace("%user%", ((Habbo) habbo).getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT);
|
2018-07-06 13:30:00 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|