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;
|
|
|
|
import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public class SummonRankCommand extends Command {
|
|
|
|
public SummonRankCommand() {
|
2018-07-06 15:30:00 +02:00
|
|
|
super("cmd_summonrank", Emulator.getTexts().getValue("commands.keys.cmd_summonrank").split(";"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
2019-03-18 02:22:00 +01:00
|
|
|
int minRank;
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (params.length >= 2) {
|
|
|
|
try {
|
2018-07-06 15:30:00 +02:00
|
|
|
minRank = Integer.valueOf(params[1]);
|
2019-05-26 20:14:53 +02:00
|
|
|
} catch (Exception e) {
|
2018-07-06 15:30:00 +02:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.generic.cmd_summonrank.error"), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
|
|
|
|
if (set.getValue().getHabboInfo().getRank().getId() >= minRank) {
|
|
|
|
if (set.getValue() == gameClient.getHabbo())
|
2018-07-06 15:30:00 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if (set.getValue().getHabboInfo().getCurrentRoom() == gameClient.getHabbo().getHabboInfo().getCurrentRoom())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Emulator.getGameEnvironment().getRoomManager().leaveRoom(set.getValue(), set.getValue().getHabboInfo().getCurrentRoom());
|
|
|
|
set.getValue().getClient().sendResponse(new ForwardToRoomComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId()));
|
|
|
|
Emulator.getGameEnvironment().getRoomManager().enterRoom(set.getValue(), gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|