mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-12-22 22:04:57 +00:00
Add getting other player's uuids via the uuid command
This commit is contained in:
parent
4769228fab
commit
58e87575aa
2 changed files with 92 additions and 85 deletions
|
@ -1,105 +1,108 @@
|
|||
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.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.PlayerList;
|
||||
import me.StevenLawson.TotalFreedomMod.player.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.player.UUIDManager.TFM_UuidResolver;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
|
||||
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])) {
|
||||
playerMsg(sender, "Purged " + UUIDManager.purge() + " cached UUIDs.");
|
||||
return true;
|
||||
}
|
||||
@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 ("recalculate".equals(args[0]))
|
||||
{
|
||||
playerMsg(sender, "Recalculating UUIDs...");
|
||||
if ("purge".equals(args[0])) {
|
||||
playerMsg(sender, "Purged " + UUIDManager.purge() + " cached UUIDs.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Playerlist uuids
|
||||
final Set<Player> players = PlayerList.getAllPlayers();
|
||||
final List<String> names = new ArrayList<String>();
|
||||
if ("recalculate".equals(args[0])) {
|
||||
playerMsg(sender, "Recalculating UUIDs...");
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
names.add(player.getLastLoginName());
|
||||
}
|
||||
// Playerlist uuids
|
||||
final Set<Player> players = PlayerList.getAllPlayers();
|
||||
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;
|
||||
for (String name : playerUuids.keySet())
|
||||
{
|
||||
for (Player player : players)
|
||||
{
|
||||
if (!player.getLastLoginName().equalsIgnoreCase(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Map<String, UUID> playerUuids = new TFM_UuidResolver(names).call();
|
||||
|
||||
if (player.getUniqueId().equals(playerUuids.get(name)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int updated = 0;
|
||||
for (String name : playerUuids.keySet()) {
|
||||
for (Player player : players) {
|
||||
if (!player.getLastLoginName().equalsIgnoreCase(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerList.setUniqueId(player, playerUuids.get(name));
|
||||
UUIDManager.rawSetUUID(name, playerUuids.get(name));
|
||||
updated++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (player.getUniqueId().equals(playerUuids.get(name))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
playerMsg(sender, "Recalculated " + updated + " player UUIDs");
|
||||
names.clear();
|
||||
PlayerList.setUniqueId(player, playerUuids.get(name));
|
||||
UUIDManager.rawSetUUID(name, playerUuids.get(name));
|
||||
updated++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Adminlist UUIDs
|
||||
final Set<Admin> admins = AdminList.getAllAdmins();
|
||||
for (Admin admin : admins)
|
||||
{
|
||||
names.add(admin.getLastLoginName());
|
||||
}
|
||||
playerMsg(sender, "Recalculated " + updated + " player UUIDs");
|
||||
names.clear();
|
||||
|
||||
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;
|
||||
for (String name : adminUuids.keySet())
|
||||
{
|
||||
for (Admin admin : admins)
|
||||
{
|
||||
if (!admin.getLastLoginName().equalsIgnoreCase(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Map<String, UUID> adminUuids = new TFM_UuidResolver(names).call();
|
||||
|
||||
if (admin.getUniqueId().equals(adminUuids.get(name)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
updated = 0;
|
||||
for (String name : adminUuids.keySet()) {
|
||||
for (Admin admin : admins) {
|
||||
if (!admin.getLastLoginName().equalsIgnoreCase(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
AdminList.setUuid(admin, admin.getUniqueId(), adminUuids.get(name));
|
||||
UUIDManager.rawSetUUID(name, adminUuids.get(name));
|
||||
updated++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (admin.getUniqueId().equals(adminUuids.get(name))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ name: TotalFreedomMod
|
|||
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
|
||||
version: 4.3
|
||||
description: Plugin for the Total Freedom server.
|
||||
softdepend: [BukkitTelnet, WorldEdit, Essentials]
|
||||
authors: [Madgeek1450, Prozza, business-goose, Luna]
|
||||
softdepend: [ BukkitTelnet, WorldEdit, Essentials ]
|
||||
authors: [ Madgeek1450, Prozza, business-goose, Luna ]
|
||||
|
||||
commands:
|
||||
setl:
|
||||
|
@ -21,7 +21,7 @@ commands:
|
|||
jumppads:
|
||||
description: 'Manage jumppads'
|
||||
usage: '/<command> <on | off | info | sideways <on | off> | strength <strength (1-10)>>'
|
||||
aliases: [launchpads, jp]
|
||||
aliases: [ launchpads, jp ]
|
||||
qop:
|
||||
description: 'Quick Op - op someone based on a partial name.'
|
||||
usage: '/<command> <partialname>'
|
||||
|
@ -140,7 +140,7 @@ commands:
|
|||
localspawn:
|
||||
description: 'Teleport to the spawn point for the current world.'
|
||||
usage: '/<command>'
|
||||
aliases: [worldspawn, gotospawn]
|
||||
aliases: [ worldspawn, gotospawn ]
|
||||
tag:
|
||||
description: 'Sets yourself a prefix'
|
||||
usage: '/<command> <set <tag..> | off | clear <player> | clearall>'
|
||||
|
@ -182,7 +182,7 @@ commands:
|
|||
aliases: 'ov'
|
||||
uuid:
|
||||
description: 'Provides uuid tools'
|
||||
usage: '/<command> <purge | recalculate>'
|
||||
usage: '/<command> <purge | recalculate | partialName>'
|
||||
logs:
|
||||
description: 'Register your connection with the TFM logviewer.'
|
||||
usage: '/<command> [off]'
|
||||
|
@ -233,7 +233,7 @@ commands:
|
|||
blockcmd:
|
||||
description: 'Block all commands for a specific player.'
|
||||
usage: '/<command> <purge | <partialname>>'
|
||||
aliases: [blockcommands, blockcommand]
|
||||
aliases: [ blockcommands, blockcommand ]
|
||||
tfbanlist:
|
||||
description: 'Shows all banned player names. Superadmins may optionally use ''purge'' to clear the list.'
|
||||
usage: '/<command> [purge]'
|
||||
|
@ -276,7 +276,7 @@ commands:
|
|||
updatetfm:
|
||||
description: 'For developers only - update TFM.'
|
||||
usage: '/<command>'
|
||||
aliases: [tfmupdate, update, compiletfm, tfmcompile, build, buildtfm, tfmbuild]
|
||||
aliases: [ tfmupdate, update, compiletfm, tfmcompile, build, buildtfm, tfmbuild ]
|
||||
lockup:
|
||||
description: 'Block target''s minecraft input. This is evil, and I never should have wrote it.'
|
||||
usage: '/<command> <all | purge | <<partialname> on | off>>'
|
||||
|
@ -335,6 +335,10 @@ commands:
|
|||
description: 'Who am I? Who are you? What am I doing here?'
|
||||
usage: '/<command>'
|
||||
resetplayer:
|
||||
aliases: ["resetplayerdata"]
|
||||
aliases: [ "resetplayerdata" ]
|
||||
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]'
|
Loading…
Reference in a new issue