public String getState() { if (!slp.isOnline()) { Document dbo = SpleefLeague.getInstance() .getPluginDB() .getCollection("ActiveInfractions") .find(new Document("uuid", slp.getUniqueId().toString())) .first(); if (dbo != null) { Infraction inf = EntityBuilder.load(dbo, Infraction.class); if (inf.getType() == InfractionType.BAN) { return ChatColor.DARK_RED + "BANNED"; } else if (inf.getType() == InfractionType.TEMPBAN) { if (inf.getTime() + inf.getDuration() > System.currentTimeMillis()) { return ChatColor.RED + "TEMPBANNED" + ChatColor.GRAY + " (for " + TimeUtil.dateToString(new Date(inf.getTime() + inf.getDuration()), true) + ")"; } } } return ChatColor.GRAY + "OFFLINE"; } else { return ChatColor.GREEN + StringUtil.upperCaseFirst(slp.getState().toString()); } }
@Override protected void run(Player p, SLPlayer slp, Command cmd, String[] args) { p.sendMessage( ChatColor.DARK_GRAY + "[ " + ChatColor.GRAY + "============ " + ChatColor.DARK_AQUA + "Spawns" + ChatColor.GRAY + " ============" + ChatColor.DARK_GRAY + " ]"); ModifiableFinal<Integer> current = new ModifiableFinal<>(1); SpleefLeague.getInstance() .getSpawnManager() .getAll() .forEach( (SpawnManager.SpawnLocation spawnLocation) -> { ComponentBuilder componentBuilder = new ComponentBuilder("#" + current.getValue()) .color(ChatColor.RED.asBungee()) .append(" | ") .color(ChatColor.DARK_GRAY.asBungee()) .append("CLICK TO TELEPORT") .color(ChatColor.GRAY.asBungee()) .event( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/tppos " + spawnLocation.getLocation().getBlockX() + " " + spawnLocation.getLocation().getBlockY() + ' ' + spawnLocation.getLocation().getBlockZ())) .append(" | ") .color(ChatColor.DARK_GRAY.asBungee()) .append(spawnLocation.getPlayersInRadius() + " players") .color(ChatColor.GRAY.asBungee()); slp.spigot().sendMessage(componentBuilder.create()); current.setValue(current.getValue() + 1); }); p.sendMessage( ChatColor.RED + "All spawns were cached " + TimeUtil.dateToString( new Date(SpleefLeague.getInstance().getSpawnManager().getLastCached()), false) + " ago."); }
public String getSharedAccounts() { String playerUUID = slp.getUniqueId().toString(); Set<String> sharedUUIDs = new HashSet<>(); Collection<String> ips = new HashSet<>(); MongoCollection<Document> col = SpleefLeague.getInstance().getPluginDB().getCollection("PlayerConnections"); Date lastOnline = null; for (Document doc : col.find(new Document("uuid", playerUUID))) { ips.add(doc.get("ip", String.class)); if (lastOnline == null) { lastOnline = doc.get("date", Date.class); } else { Date d = doc.get("date", Date.class); if (lastOnline.before(d)) { lastOnline = d; } } } lastSeen = lastOnline != null ? TimeUtil.dateToString(lastOnline, false) + " ago" : "Unknown"; Set<Document> orQuerry = new HashSet<>(); for (String ip : ips) { orQuerry.add(new Document("ip", ip)); Thread.currentThread().getStackTrace(); } if (!orQuerry.isEmpty()) { for (Document doc : col.find(new Document("$or", orQuerry))) { String uuid = doc.get("uuid", String.class); if (!uuid.equals(playerUUID)) { sharedUUIDs.add(uuid); } } } col = SpleefLeague.getInstance().getPluginDB().getCollection("Players"); String sharedUsernames = null; for (String uuid : sharedUUIDs) { if (sharedUsernames == null) { sharedUsernames = col.find(new Document("uuid", uuid)).first().get("username", String.class); } else { sharedUsernames += ", " + col.find(new Document("uuid", uuid)).first().get("username", String.class); } } return sharedUsernames; }