Add getting other player's uuids via the uuid command

This commit is contained in:
Business Goose 2022-03-31 02:14:53 +01:00
parent 4769228fab
commit 58e87575aa
No known key found for this signature in database
GPG key ID: 77DCA801362E9645
2 changed files with 92 additions and 85 deletions

View file

@ -1,105 +1,108 @@
package me.StevenLawson.TotalFreedomMod.commands; package me.StevenLawson.TotalFreedomMod.commands;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import me.StevenLawson.TotalFreedomMod.admin.Admin; import me.StevenLawson.TotalFreedomMod.admin.Admin;
import me.StevenLawson.TotalFreedomMod.admin.AdminList; import me.StevenLawson.TotalFreedomMod.admin.AdminList;
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager;
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager.TFM_UuidResolver;
import me.StevenLawson.TotalFreedomMod.player.Player; import me.StevenLawson.TotalFreedomMod.player.Player;
import me.StevenLawson.TotalFreedomMod.player.PlayerList; import me.StevenLawson.TotalFreedomMod.player.PlayerList;
import me.StevenLawson.TotalFreedomMod.player.UUIDManager; import org.bukkit.Bukkit;
import me.StevenLawson.TotalFreedomMod.player.UUIDManager.TFM_UuidResolver;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import java.util.*;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE) @CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
public class Command_uuid extends FreedomCommand { public class Command_uuid extends FreedomCommand {
@Override
public boolean run(CommandSender sender, org.bukkit.entity.Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length != 1) {
return false;
}
if ("purge".equals(args[0])) { @Override
playerMsg(sender, "Purged " + UUIDManager.purge() + " cached UUIDs."); public boolean run(CommandSender sender, org.bukkit.entity.Player sender_p, Command cmd,
return true; String commandLabel, String[] args, boolean senderIsConsole) {
} if (args.length != 1) {
return false;
}
if ("recalculate".equals(args[0])) if ("purge".equals(args[0])) {
{ playerMsg(sender, "Purged " + UUIDManager.purge() + " cached UUIDs.");
playerMsg(sender, "Recalculating UUIDs..."); return true;
}
// Playerlist uuids if ("recalculate".equals(args[0])) {
final Set<Player> players = PlayerList.getAllPlayers(); playerMsg(sender, "Recalculating UUIDs...");
final List<String> names = new ArrayList<String>();
for (Player player : players) // Playerlist uuids
{ final Set<Player> players = PlayerList.getAllPlayers();
names.add(player.getLastLoginName()); final List<String> names = new ArrayList<String>();
}
final Map<String, UUID> playerUuids = new TFM_UuidResolver(names).call(); for (Player player : players) {
names.add(player.getLastLoginName());
}
int updated = 0; final Map<String, UUID> playerUuids = new TFM_UuidResolver(names).call();
for (String name : playerUuids.keySet())
{
for (Player player : players)
{
if (!player.getLastLoginName().equalsIgnoreCase(name))
{
continue;
}
if (player.getUniqueId().equals(playerUuids.get(name))) int updated = 0;
{ for (String name : playerUuids.keySet()) {
continue; for (Player player : players) {
} if (!player.getLastLoginName().equalsIgnoreCase(name)) {
continue;
}
PlayerList.setUniqueId(player, playerUuids.get(name)); if (player.getUniqueId().equals(playerUuids.get(name))) {
UUIDManager.rawSetUUID(name, playerUuids.get(name)); continue;
updated++; }
break;
}
}
playerMsg(sender, "Recalculated " + updated + " player UUIDs"); PlayerList.setUniqueId(player, playerUuids.get(name));
names.clear(); UUIDManager.rawSetUUID(name, playerUuids.get(name));
updated++;
break;
}
}
// Adminlist UUIDs playerMsg(sender, "Recalculated " + updated + " player UUIDs");
final Set<Admin> admins = AdminList.getAllAdmins(); names.clear();
for (Admin admin : admins)
{
names.add(admin.getLastLoginName());
}
final Map<String, UUID> adminUuids = new TFM_UuidResolver(names).call(); // Adminlist UUIDs
final Set<Admin> admins = AdminList.getAllAdmins();
for (Admin admin : admins) {
names.add(admin.getLastLoginName());
}
updated = 0; final Map<String, UUID> adminUuids = new TFM_UuidResolver(names).call();
for (String name : adminUuids.keySet())
{
for (Admin admin : admins)
{
if (!admin.getLastLoginName().equalsIgnoreCase(name))
{
continue;
}
if (admin.getUniqueId().equals(adminUuids.get(name))) updated = 0;
{ for (String name : adminUuids.keySet()) {
continue; for (Admin admin : admins) {
} if (!admin.getLastLoginName().equalsIgnoreCase(name)) {
continue;
}
AdminList.setUuid(admin, admin.getUniqueId(), adminUuids.get(name)); if (admin.getUniqueId().equals(adminUuids.get(name))) {
UUIDManager.rawSetUUID(name, adminUuids.get(name)); continue;
updated++; }
break;
}
}
playerMsg(sender, "Recalculated " + updated + " admin UUIDs"); AdminList.setUuid(admin, admin.getUniqueId(), adminUuids.get(name));
UUIDManager.rawSetUUID(name, adminUuids.get(name));
updated++;
break;
}
}
return true; playerMsg(sender, "Recalculated " + updated + " admin UUIDs");
}
return false; return true;
} }
org.bukkit.entity.Player player = Bukkit.getPlayer(args[0]);
if (player != null) {
playerMsg(sender, String.format("%s's UUID is %s", player.getName(),
player.getUniqueId().toString()));
return true;
}
return false;
}
} }

View file

@ -2,8 +2,8 @@ name: TotalFreedomMod
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
version: 4.3 version: 4.3
description: Plugin for the Total Freedom server. description: Plugin for the Total Freedom server.
softdepend: [BukkitTelnet, WorldEdit, Essentials] softdepend: [ BukkitTelnet, WorldEdit, Essentials ]
authors: [Madgeek1450, Prozza, business-goose, Luna] authors: [ Madgeek1450, Prozza, business-goose, Luna ]
commands: commands:
setl: setl:
@ -21,7 +21,7 @@ commands:
jumppads: jumppads:
description: 'Manage jumppads' description: 'Manage jumppads'
usage: '/<command> <on | off | info | sideways <on | off> | strength <strength (1-10)>>' usage: '/<command> <on | off | info | sideways <on | off> | strength <strength (1-10)>>'
aliases: [launchpads, jp] aliases: [ launchpads, jp ]
qop: qop:
description: 'Quick Op - op someone based on a partial name.' description: 'Quick Op - op someone based on a partial name.'
usage: '/<command> <partialname>' usage: '/<command> <partialname>'
@ -140,7 +140,7 @@ commands:
localspawn: localspawn:
description: 'Teleport to the spawn point for the current world.' description: 'Teleport to the spawn point for the current world.'
usage: '/<command>' usage: '/<command>'
aliases: [worldspawn, gotospawn] aliases: [ worldspawn, gotospawn ]
tag: tag:
description: 'Sets yourself a prefix' description: 'Sets yourself a prefix'
usage: '/<command> <set <tag..> | off | clear <player> | clearall>' usage: '/<command> <set <tag..> | off | clear <player> | clearall>'
@ -182,7 +182,7 @@ commands:
aliases: 'ov' aliases: 'ov'
uuid: uuid:
description: 'Provides uuid tools' description: 'Provides uuid tools'
usage: '/<command> <purge | recalculate>' usage: '/<command> <purge | recalculate | partialName>'
logs: logs:
description: 'Register your connection with the TFM logviewer.' description: 'Register your connection with the TFM logviewer.'
usage: '/<command> [off]' usage: '/<command> [off]'
@ -233,7 +233,7 @@ commands:
blockcmd: blockcmd:
description: 'Block all commands for a specific player.' description: 'Block all commands for a specific player.'
usage: '/<command> <purge | <partialname>>' usage: '/<command> <purge | <partialname>>'
aliases: [blockcommands, blockcommand] aliases: [ blockcommands, blockcommand ]
tfbanlist: tfbanlist:
description: 'Shows all banned player names. Superadmins may optionally use ''purge'' to clear the list.' description: 'Shows all banned player names. Superadmins may optionally use ''purge'' to clear the list.'
usage: '/<command> [purge]' usage: '/<command> [purge]'
@ -276,7 +276,7 @@ commands:
updatetfm: updatetfm:
description: 'For developers only - update TFM.' description: 'For developers only - update TFM.'
usage: '/<command>' usage: '/<command>'
aliases: [tfmupdate, update, compiletfm, tfmcompile, build, buildtfm, tfmbuild] aliases: [ tfmupdate, update, compiletfm, tfmcompile, build, buildtfm, tfmbuild ]
lockup: lockup:
description: 'Block target''s minecraft input. This is evil, and I never should have wrote it.' description: 'Block target''s minecraft input. This is evil, and I never should have wrote it.'
usage: '/<command> <all | purge | <<partialname> on | off>>' usage: '/<command> <all | purge | <<partialname> on | off>>'
@ -335,6 +335,10 @@ commands:
description: 'Who am I? Who are you? What am I doing here?' description: 'Who am I? Who are you? What am I doing here?'
usage: '/<command>' usage: '/<command>'
resetplayer: resetplayer:
aliases: ["resetplayerdata"] aliases: [ "resetplayerdata" ]
description: 'Reset a player''s data.' description: 'Reset a player''s data.'
usage: '/command <partialName>' usage: '/<command> <partialName>'
vanish:
aliases: [ 'v', 'uv', 'unvanish' ]
description: 'Hide yourself from other players.'
usage: '/<vanish> <on/off> [-s]'