From 126cab926ac23825a2817012da61b8eadaca2380 Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Thu, 10 Apr 2014 20:06:14 -0500 Subject: Update Bukkit for Minecraft 1.7.8 --- src/main/java/org/bukkit/BanList.java | 4 +++ src/main/java/org/bukkit/OfflinePlayer.java | 8 +++--- src/main/java/org/bukkit/Server.java | 11 ++++++-- src/main/java/org/bukkit/block/Skull.java | 32 ++++++++++++++++++++-- .../org/bukkit/command/defaults/BanCommand.java | 11 ++++++-- .../bukkit/command/defaults/BanListCommand.java | 17 +++++++++++- .../org/bukkit/command/defaults/PardonCommand.java | 3 +- src/main/java/org/bukkit/entity/AnimalTamer.java | 11 +++++++- 8 files changed, 84 insertions(+), 13 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/bukkit/BanList.java b/src/main/java/org/bukkit/BanList.java index c21b858e..541bc773 100644 --- a/src/main/java/org/bukkit/BanList.java +++ b/src/main/java/org/bukkit/BanList.java @@ -20,6 +20,10 @@ public interface BanList { * Banned player IP addresses */ IP, + /** + * Banned player UUID + */ + UUID, ; } diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java index cbf87462..e98706a6 100644 --- a/src/main/java/org/bukkit/OfflinePlayer.java +++ b/src/main/java/org/bukkit/OfflinePlayer.java @@ -19,12 +19,12 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio /** * Returns the name of this player + *

+ * 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/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index d2cb5175..22dc74a2 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/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/src/main/java/org/bukkit/block/Skull.java b/src/main/java/org/bukkit/block/Skull.java index 974aea20..e0f9fd3c 100644 --- a/src/main/java/org/bukkit/block/Skull.java +++ b/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/src/main/java/org/bukkit/command/defaults/BanCommand.java b/src/main/java/org/bukkit/command/defaults/BanCommand.java index df891b80..5ae95dae 100644 --- a/src/main/java/org/bukkit/command/defaults/BanCommand.java +++ b/src/main/java/org/bukkit/command/defaults/BanCommand.java @@ -29,10 +29,17 @@ public class BanCommand extends VanillaCommand { return false; } + 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.NAME).addBan(args[0], reason, null, sender.getName()); + Bukkit.getBanList(BanList.Type.UUID).addBan(uuid, reason, null, sender.getName()); - Player player = Bukkit.getPlayer(args[0]); if (player != null) { player.kickPlayer("Banned by admin."); } diff --git a/src/main/java/org/bukkit/command/defaults/BanListCommand.java b/src/main/java/org/bukkit/command/defaults/BanListCommand.java index 262a2371..5f3a6f23 100644 --- a/src/main/java/org/bukkit/command/defaults/BanListCommand.java +++ b/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/src/main/java/org/bukkit/command/defaults/PardonCommand.java b/src/main/java/org/bukkit/command/defaults/PardonCommand.java index 82c7a954..97c65c5e 100644 --- a/src/main/java/org/bukkit/command/defaults/PardonCommand.java +++ b/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/src/main/java/org/bukkit/entity/AnimalTamer.java b/src/main/java/org/bukkit/entity/AnimalTamer.java index a80d31aa..5f74f0d8 100644 --- a/src/main/java/org/bukkit/entity/AnimalTamer.java +++ b/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(); } -- cgit v1.2.3