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.modtool.ModToolBan;
|
|
|
|
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
|
|
|
import com.eu.habbo.habbohotel.users.Habbo;
|
|
|
|
import com.eu.habbo.habbohotel.users.HabboInfo;
|
|
|
|
import com.eu.habbo.habbohotel.users.HabboManager;
|
|
|
|
import gnu.trove.iterator.TIntIntIterator;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.*;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public class UserInfoCommand extends Command {
|
|
|
|
public UserInfoCommand() {
|
2018-07-06 15:30:00 +02:00
|
|
|
super("cmd_userinfo", Emulator.getTexts().getValue("commands.keys.cmd_userinfo").split(";"));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
|
|
|
if (params.length < 2) {
|
2018-07-06 15:30:00 +02:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_userinfo.forgot_username"), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Habbo onlineHabbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]);
|
|
|
|
HabboInfo habbo = (onlineHabbo != null ? onlineHabbo.getHabboInfo() : null);
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (habbo == null) {
|
2018-07-06 15:30:00 +02:00
|
|
|
habbo = HabboManager.getOfflineHabboInfo(params[1]);
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (habbo == null) {
|
2018-07-06 15:30:00 +02:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_userinfo.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-03-18 02:22:00 +01:00
|
|
|
StringBuilder message = new StringBuilder(Emulator.getTexts().getValue("command.cmd_userinfo.userinfo") + ": " + " <b>" + habbo.getUsername() + "</b> (<b>" + habbo.getId() + "</b>)\r" +
|
2018-07-06 15:30:00 +02:00
|
|
|
Emulator.getTexts().getValue("command.cmd_userinfo.user_id") + ": " + habbo.getId() + "\r" +
|
|
|
|
Emulator.getTexts().getValue("command.cmd_userinfo.user_name") + ": " + habbo.getUsername() + "\r" +
|
|
|
|
Emulator.getTexts().getValue("command.cmd_userinfo.motto") + ": " + habbo.getMotto().replace("<", "[").replace(">", "]") + "\r" +
|
2019-03-18 02:22:00 +01:00
|
|
|
Emulator.getTexts().getValue("command.cmd_userinfo.rank") + ": " + habbo.getRank().getName() + " (" + habbo.getRank().getId() + ") \r" +
|
2018-07-06 15:30:00 +02:00
|
|
|
Emulator.getTexts().getValue("command.cmd_userinfo.online") + ": " + (onlineHabbo == null ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" +
|
2020-06-03 02:42:38 +02:00
|
|
|
((habbo.getRank().hasPermission("acc_hide_mail", true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r") +
|
2019-03-18 02:22:00 +01:00
|
|
|
((habbo.getRank().hasPermission("acc_hide_ip", true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") +
|
|
|
|
((habbo.getRank().hasPermission("acc_hide_ip", true)) || onlineHabbo == null ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getClient().getChannel().remoteAddress().toString() + "\r") +
|
|
|
|
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().achievementScore + "\r" : ""));
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(habbo.getId());
|
|
|
|
|
2019-03-18 02:22:00 +01:00
|
|
|
message.append(Emulator.getTexts().getValue("command.cmd_userinfo.total_bans")).append(": ").append(Emulator.getGameEnvironment().getModToolManager().totalBans(habbo.getId())).append("\r");
|
|
|
|
message.append(Emulator.getTexts().getValue("command.cmd_userinfo.banned")).append(": ").append(Emulator.getTexts().getValue(ban != null ? "generic.yes" : "generic.no")).append("\r\r");
|
2019-05-26 20:14:53 +02:00
|
|
|
if (ban != null) {
|
2019-03-18 02:22:00 +01:00
|
|
|
message.append("<b>").append(Emulator.getTexts().getValue("command.cmd_userinfo.ban_info")).append("</b>\r");
|
|
|
|
message.append(ban.listInfo()).append("\r");
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
|
2019-03-18 02:22:00 +01:00
|
|
|
message.append("<b>").append(Emulator.getTexts().getValue("command.cmd_userinfo.currencies")).append("</b>\r");
|
|
|
|
message.append(Emulator.getTexts().getValue("command.cmd_userinfo.credits")).append(": ").append(habbo.getCredits()).append("\r");
|
2018-07-06 15:30:00 +02:00
|
|
|
TIntIntIterator iterator = habbo.getCurrencies().iterator();
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
for (int i = habbo.getCurrencies().size(); i-- > 0; ) {
|
|
|
|
try {
|
2018-07-06 15:30:00 +02:00
|
|
|
iterator.advance();
|
2019-05-26 20:14:53 +02:00
|
|
|
} catch (Exception e) {
|
2018-07-06 15:30:00 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-03-18 02:22:00 +01:00
|
|
|
message.append(Emulator.getTexts().getValue("seasonal.name." + iterator.key())).append(": ").append(iterator.value()).append("\r");
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
2019-03-18 02:22:00 +01:00
|
|
|
message.append("\r").append(onlineHabbo != null ? "<b>" + Emulator.getTexts().getValue("command.cmd_userinfo.current_activity") + "</b>\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.room") + ": " + (onlineHabbo.getHabboInfo().getCurrentRoom() != null ? onlineHabbo.getHabboInfo().getCurrentRoom().getName() + "(" + onlineHabbo.getHabboInfo().getCurrentRoom().getId() + ")\r" : "-") : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.respect_left") + ": " + onlineHabbo.getHabboStats().respectPointsToGive + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.pet_respect_left") + ": " + onlineHabbo.getHabboStats().petRespectPointsToGive + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_trade") + ": " + ((onlineHabbo.getHabboStats().allowTrade()) ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no")) + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_follow") + ": " + ((onlineHabbo.getHabboStats().blockFollowing) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_friend_request") + ": " + ((onlineHabbo.getHabboStats().blockFriendRequests) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : "");
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
List<Map.Entry<Integer, String>> nameChanges = Emulator.getGameEnvironment().getHabboManager().getNameChanges(habbo.getId(), 3);
|
2019-05-26 20:14:53 +02:00
|
|
|
if (!nameChanges.isEmpty()) {
|
2019-03-18 02:22:00 +01:00
|
|
|
message.append("\r<b>Latest name changes:<b><br/>");
|
2019-05-26 20:14:53 +02:00
|
|
|
for (Map.Entry<Integer, String> entry : nameChanges) {
|
2019-03-18 02:22:00 +01:00
|
|
|
message.append(format.format(new Date((long) entry.getKey() * 1000L))).append(" : ").append(entry.getValue()).append("<br/>");
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (onlineHabbo != null) {
|
2019-03-18 02:22:00 +01:00
|
|
|
message.append("\r" + "<b>Other accounts (");
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
ArrayList<HabboInfo> users = Emulator.getGameEnvironment().getHabboManager().getCloneAccounts(onlineHabbo, 10);
|
2019-05-26 20:14:53 +02:00
|
|
|
users.sort(new Comparator<HabboInfo>() {
|
2018-07-06 15:30:00 +02:00
|
|
|
@Override
|
2019-05-26 20:14:53 +02:00
|
|
|
public int compare(HabboInfo o1, HabboInfo o2) {
|
2018-07-06 15:30:00 +02:00
|
|
|
return o1.getId() - o2.getId();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-03-18 02:22:00 +01:00
|
|
|
message.append(users.size()).append("):</b>\r");
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
|
2019-03-18 02:22:00 +01:00
|
|
|
message.append("<b>Username,\tID,\tDate register,\tDate last online</b>\r");
|
2018-07-06 15:30:00 +02:00
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
for (HabboInfo info : users) {
|
2019-03-18 02:22:00 +01:00
|
|
|
message.append(info.getUsername()).append(",\t").append(info.getId()).append(",\t").append(format.format(new Date((long) info.getAccountCreated() * 1000L))).append(",\t").append(format.format(new Date((long) info.getLastOnline() * 1000L))).append("\r");
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-26 20:14:53 +02:00
|
|
|
gameClient.getHabbo().alert(message.toString());
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|