43 lines
1.9 KiB
Java
Raw Normal View History

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 DisconnectCommand extends Command {
public DisconnectCommand() {
2018-07-06 13:30:00 +00:00
super("cmd_disconnect", Emulator.getTexts().getValue("commands.keys.cmd_disconnect").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_disconnect.forgot_username"), 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_disconnect.disconnect_self"), RoomChatMessageBubbles.ALERT);
return true;
}
Habbo target = Emulator.getGameEnvironment().getHabboManager().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_disconnect.user_offline"), RoomChatMessageBubbles.ALERT);
return true;
}
2019-05-26 21:14:53 +03:00
if (target.getHabboInfo().getRank().getId() > gameClient.getHabbo().getHabboInfo().getRank().getId()) {
2018-07-06 13:30:00 +00:00
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_disconnect.higher_rank"), RoomChatMessageBubbles.ALERT);
return true;
}
target.getClient().getChannel().close();
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_disconnect.disconnected").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
return true;
}
}