diff --git a/paper-api/pom.xml b/paper-api/pom.xml
index a14b55e12c..ec3d67d1ca 100644
--- a/paper-api/pom.xml
+++ b/paper-api/pom.xml
@@ -2,7 +2,7 @@
+ * Names are no longer unique past a single game session. For persistent storage + * it is recommended that you use {@link #getUniqueId()} instead. * - * @deprecated Use {@link #getUniqueId()} as player names are no longer - * guaranteed to be unique - * @return Player name + * @return Player name or null if we have not seen a name for this player yet */ - @Deprecated public String getName(); /** diff --git a/paper-api/src/main/java/org/bukkit/Server.java b/paper-api/src/main/java/org/bukkit/Server.java index d2cb51754a..22dc74a284 100644 --- a/paper-api/src/main/java/org/bukkit/Server.java +++ b/paper-api/src/main/java/org/bukkit/Server.java @@ -558,13 +558,17 @@ public interface Server extends PluginMessageRecipient { * Gets the player by the given name, regardless if they are offline or * online. *
+ * This method may involve a blocking web request to get the UUID for the + * given name. + *
* This will return an object even if the player does not exist. To this * method, all players will exist. * - * @deprecated Use {@link #getOfflinePlayer(UUID)} as player names are no - * longer guaranteed to be unique + * @deprecated Persistent storage of users should be by UUID as names are no longer + * unique past a single session. * @param name the name the player to retrieve * @return an offline player + * @see #getOfflinePlayer(java.util.UUID) */ @Deprecated public OfflinePlayer getOfflinePlayer(String name); @@ -611,6 +615,9 @@ public interface Server extends PluginMessageRecipient { /** * Gets a ban list for the supplied type. + *
+ * Bans by name are no longer supported and this method will return + * null when trying to request them. The replacement is bans by UUID. * * @param type the type of list to fetch, cannot be null * @return a ban list of the specified type diff --git a/paper-api/src/main/java/org/bukkit/block/Skull.java b/paper-api/src/main/java/org/bukkit/block/Skull.java index 974aea203e..e0f9fd3c3c 100644 --- a/paper-api/src/main/java/org/bukkit/block/Skull.java +++ b/paper-api/src/main/java/org/bukkit/block/Skull.java @@ -1,7 +1,10 @@ package org.bukkit.block; +import org.bukkit.OfflinePlayer; import org.bukkit.SkullType; +import java.util.UUID; + /** * Represents a Skull */ @@ -17,18 +20,43 @@ public interface Skull extends BlockState { /** * Gets the owner of the skull * - * @return the owner of the skull + * @return the owner of the skull or null if the profile does not have a name + * @deprecated Skulls no longer store player names, they store profiles + * @see #getPlayer() */ + @Deprecated public String getOwner(); /** - * Sets the owner of the skull + * Does nothing * * @param name the new owner of the skull * @return true if the owner was successfully set + * @deprecated Skulls no longer store player names, they store profiles + * @see #setPlayer(org.bukkit.OfflinePlayer) */ + @Deprecated public boolean setOwner(String name); + /** + * Gets the owner of the skull, if one exists + * + * @return the owner of the skull or null if this skull does not have an owner + */ + public OfflinePlayer getPlayer(); + + /** + * Sets the owner of the skull to this player + *
+ * If the owner does not contain all the needed data for the skull a call to + * {@link #update()} may potentially involve a blocking web request to acquire + * the missing data. + * + * @param player the new owner of the skull + * @return true if the owner was successfully set + */ + public boolean setPlayer(OfflinePlayer player); + /** * Gets the rotation of the skull in the world * diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/BanCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/BanCommand.java index df891b8088..5ae95dae5c 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/BanCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/BanCommand.java @@ -29,10 +29,17 @@ public class BanCommand extends VanillaCommand { return false; } - String reason = args.length > 0 ? StringUtils.join(args, ' ', 1, args.length) : null; - Bukkit.getBanList(BanList.Type.NAME).addBan(args[0], reason, null, sender.getName()); - Player player = Bukkit.getPlayer(args[0]); + String uuid; + if (player != null) { + uuid = player.getUniqueId().toString(); + } else { + uuid = sender.getServer().getOfflinePlayer(args[0]).getUniqueId().toString(); + } + + String reason = args.length > 0 ? StringUtils.join(args, ' ', 1, args.length) : null; + Bukkit.getBanList(BanList.Type.UUID).addBan(uuid, reason, null, sender.getName()); + if (player != null) { player.kickPlayer("Banned by admin."); } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/BanListCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/BanListCommand.java index 262a237199..5f3a6f23cf 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/BanListCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/BanListCommand.java @@ -2,12 +2,14 @@ package org.bukkit.command.defaults; import java.util.ArrayList; import java.util.List; +import java.util.UUID; import org.apache.commons.lang.Validate; import org.bukkit.BanEntry; import org.bukkit.BanList; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; import org.bukkit.util.StringUtil; @@ -27,7 +29,7 @@ public class BanListCommand extends VanillaCommand { public boolean execute(CommandSender sender, String currentAlias, String[] args) { if (!testPermission(sender)) return true; - BanList.Type banType = BanList.Type.NAME; + BanList.Type banType = BanList.Type.UUID; if (args.length > 0) { if (args[0].equalsIgnoreCase("ips")) { banType = BanList.Type.IP; @@ -48,6 +50,19 @@ public class BanListCommand extends VanillaCommand { message.append(", "); } } + + String output = banlist[x].getTarget(); + if (banType == BanList.Type.UUID) { + try { + OfflinePlayer player = sender.getServer().getOfflinePlayer(UUID.fromString(output)); + if (player.getName() != null) { + output = player.getName(); + } + } catch (IllegalArgumentException ex) { + // We seem to have an invalid UUID, what do? + } + } + message.append(banlist[x].getTarget()); } diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/PardonCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/PardonCommand.java index 82c7a95466..97c65c5e8e 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/PardonCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/PardonCommand.java @@ -30,7 +30,8 @@ public class PardonCommand extends VanillaCommand { return false; } - Bukkit.getBanList(BanList.Type.NAME).pardon(args[0]); + String uuid = sender.getServer().getOfflinePlayer(args[0]).getUniqueId().toString(); + Bukkit.getBanList(BanList.Type.UUID).pardon(uuid); Command.broadcastCommandMessage(sender, "Pardoned " + args[0]); return true; } diff --git a/paper-api/src/main/java/org/bukkit/entity/AnimalTamer.java b/paper-api/src/main/java/org/bukkit/entity/AnimalTamer.java index a80d31aab2..5f74f0d85b 100644 --- a/paper-api/src/main/java/org/bukkit/entity/AnimalTamer.java +++ b/paper-api/src/main/java/org/bukkit/entity/AnimalTamer.java @@ -1,11 +1,20 @@ package org.bukkit.entity; +import java.util.UUID; + public interface AnimalTamer { /** * This is the name of the specified AnimalTamer. * - * @return The name to reference on tamed animals + * @return The name to reference on tamed animals or null if a name cannot be obtained */ public String getName(); + + /** + * This is the UUID of the specified AnimalTamer. + * + * @return The UUID to reference on tamed animals + */ + public UUID getUniqueId(); }