Make UUID command work in-game and lower permission level to SUPER and remove the useless functionality it had before 😎

This commit is contained in:
Business Goose 2022-03-31 02:27:16 +01:00
parent 2e79eecdf8
commit b264a9ede4
No known key found for this signature in database
GPG key ID: 77DCA801362E9645
2 changed files with 7 additions and 87 deletions

View file

@ -1,21 +1,10 @@
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 org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
public class Command_uuid extends FreedomCommand {
@Override
@ -25,84 +14,15 @@ public class Command_uuid extends FreedomCommand {
return false;
}
if ("purge".equals(args[0])) {
playerMsg(sender, "Purged " + UUIDManager.purge() + " cached UUIDs.");
return true;
}
if ("recalculate".equals(args[0])) {
playerMsg(sender, "Recalculating UUIDs...");
// Playerlist uuids
final Set<Player> players = PlayerList.getAllPlayers();
final List<String> names = new ArrayList<String>();
for (Player player : players) {
names.add(player.getLastLoginName());
}
final Map<String, UUID> playerUuids = new TFM_UuidResolver(names).call();
int updated = 0;
for (String name : playerUuids.keySet()) {
for (Player player : players) {
if (!player.getLastLoginName().equalsIgnoreCase(name)) {
continue;
}
if (player.getUniqueId().equals(playerUuids.get(name))) {
continue;
}
PlayerList.setUniqueId(player, playerUuids.get(name));
UUIDManager.rawSetUUID(name, playerUuids.get(name));
updated++;
break;
}
}
playerMsg(sender, "Recalculated " + updated + " player UUIDs");
names.clear();
// Adminlist UUIDs
final Set<Admin> admins = AdminList.getAllAdmins();
for (Admin admin : admins) {
names.add(admin.getLastLoginName());
}
final Map<String, UUID> adminUuids = new TFM_UuidResolver(names).call();
updated = 0;
for (String name : adminUuids.keySet()) {
for (Admin admin : admins) {
if (!admin.getLastLoginName().equalsIgnoreCase(name)) {
continue;
}
if (admin.getUniqueId().equals(adminUuids.get(name))) {
continue;
}
AdminList.setUuid(admin, admin.getUniqueId(), adminUuids.get(name));
UUIDManager.rawSetUUID(name, adminUuids.get(name));
updated++;
break;
}
}
playerMsg(sender, "Recalculated " + updated + " admin UUIDs");
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(),
playerMsg(sender, String.format("%s's UUID is %s.", player.getName(),
player.getUniqueId().toString()));
return true;
}
return false;
} else {
playerMsg(sender, "Player not found, bozo.");
return true;
}
}
}

View file

@ -181,8 +181,8 @@ commands:
usage: 'access'
aliases: 'ov'
uuid:
description: 'Provides uuid tools'
usage: '/<command> <purge | recalculate | partialName>'
description: 'Calculate yourself or someone else''s UUID'
usage: '/<command> <partialName>'
logs:
description: 'Register your connection with the TFM logviewer.'
usage: '/<command> [off]'