Select targets via UUID (#1)

Adds the ability to control players via UUID instead of just their username
This commit is contained in:
Business Goose 2020-12-12 17:08:54 +00:00 committed by GitHub
parent ca385ad7c3
commit fa9104e9af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,7 @@
package pw.kaboom.icontrolu.commands;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -21,8 +23,10 @@ public final class CommandIcu implements CommandExecutor {
if (args.length == 1) {
controller.sendMessage(ChatColor.RED + "Usage: /" + label + " control <player>");
} else {
final Player target = Bukkit.getPlayer(args[1]);
Player target = Bukkit.getPlayer(args[1]);
if (target == null && args[1].matches("([a-f0-9]{8}(-[a-f0-9]{4}){4}[a-f0-9]{8})")) {
target = Bukkit.getPlayer(UUID.fromString(args[1]));
}
if (target != null) {
if (target == controller) {
controller.sendMessage("You are already controlling yourself");