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

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