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

69 lines
2.5 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;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Map;
2019-05-26 20:14:53 +02:00
public class StaffOnlineCommand extends Command {
public StaffOnlineCommand() {
2018-07-06 15:30:00 +02:00
super("cmd_staffonline", Emulator.getTexts().getValue("commands.keys.cmd_staffonline").split(";"));
}
@Override
2019-05-26 20:14:53 +02:00
public boolean handle(GameClient gameClient, String[] params) throws Exception {
2018-07-06 15:30:00 +02:00
int minRank = Emulator.getConfig().getInt("commands.cmd_staffonline.min_rank");
2019-05-26 20:14:53 +02:00
if (params.length >= 2) {
try {
2018-07-06 15:30:00 +02:00
int i = Integer.valueOf(params[1]);
2019-05-26 20:14:53 +02:00
if (i < 1) {
2018-07-06 15:30:00 +02:00
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_staffonline.positive_only"), RoomChatMessageBubbles.ALERT);
return true;
2019-05-26 20:14:53 +02:00
} else {
2018-07-06 15:30:00 +02:00
minRank = i;
}
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.error.cmd_staffonline.numbers_only"), RoomChatMessageBubbles.ALERT);
return true;
}
}
2019-05-26 20:14:53 +02:00
synchronized (Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos()) {
2018-09-28 21:25:00 +02:00
ArrayList<Habbo> staffs = new ArrayList<>();
2018-07-06 15:30:00 +02:00
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) {
2018-07-06 15:30:00 +02:00
staffs.add(set.getValue());
}
}
2019-05-26 20:14:53 +02:00
staffs.sort(new Comparator<Habbo>() {
2018-07-06 15:30:00 +02:00
@Override
2019-05-26 20:14:53 +02:00
public int compare(Habbo o1, Habbo o2) {
2018-07-06 15:30:00 +02:00
return o1.getHabboInfo().getId() - o2.getHabboInfo().getId();
}
});
2019-03-18 02:22:00 +01:00
StringBuilder message = new StringBuilder(Emulator.getTexts().getValue("commands.generic.cmd_staffonline.staffs"));
message.append("\r\n");
2018-07-06 15:30:00 +02:00
2019-05-26 20:14:53 +02:00
for (Habbo habbo : staffs) {
2019-03-18 02:22:00 +01:00
message.append(habbo.getHabboInfo().getUsername());
message.append(": ");
message.append(habbo.getHabboInfo().getRank().getName());
message.append("\r");
2018-07-06 15:30:00 +02:00
}
2019-03-18 02:22:00 +01:00
gameClient.getHabbo().alert(message.toString());
2018-07-06 15:30:00 +02:00
}
return true;
}
}