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

57 lines
2.2 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;
2022-03-24 01:24:23 +01:00
import com.eu.habbo.habbohotel.rooms.Room;
2018-07-06 15:30:00 +02:00
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 {
2022-03-24 01:31:45 +01:00
minRank = Integer.parseInt(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;
2022-03-24 01:24:23 +01:00
Room room = set.getValue().getHabboInfo().getCurrentRoom();
if (room != null) {
Emulator.getGameEnvironment().getRoomManager().logExit(set.getValue());
room.removeHabbo(set.getValue(), true);
set.getValue().getHabboInfo().setCurrentRoom(null);
}
2018-07-06 15:30:00 +02:00
Emulator.getGameEnvironment().getRoomManager().enterRoom(set.getValue(), gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true);
2022-03-24 01:24:23 +01:00
set.getValue().getClient().sendResponse(new ForwardToRoomComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId()));
2018-07-06 15:30:00 +02:00
}
}
}
return true;
}
}