diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java index 237837d763..1328c175ec 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -90,14 +90,22 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } public boolean isBanned() { - return server.getBanList(BanList.Type.UUID).isBanned(getUniqueId().toString()); + if (getName() == null) { + return false; + } + + return server.getBanList(BanList.Type.NAME).isBanned(getName()); } public void setBanned(boolean value) { + if (getName() == null) { + return; + } + if (value) { - server.getBanList(BanList.Type.UUID).addBan(getUniqueId().toString(), null, null, null); + server.getBanList(BanList.Type.NAME).addBan(getName(), null, null, null); } else { - server.getBanList(BanList.Type.UUID).pardon(getUniqueId().toString()); + server.getBanList(BanList.Type.NAME).pardon(getName()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftProfileBanEntry.java b/src/main/java/org/bukkit/craftbukkit/CraftProfileBanEntry.java index c4491970d8..7ec0006887 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftProfileBanEntry.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftProfileBanEntry.java @@ -27,7 +27,7 @@ public final class CraftProfileBanEntry implements org.bukkit.BanEntry { @Override public String getTarget() { - return this.profile.getId().toString(); + return this.profile.getName(); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/CraftProfileBanList.java b/src/main/java/org/bukkit/craftbukkit/CraftProfileBanList.java index 5679a03657..2043359003 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftProfileBanList.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftProfileBanList.java @@ -3,7 +3,6 @@ package org.bukkit.craftbukkit; import java.io.IOException; import java.util.Date; import java.util.Set; -import java.util.UUID; import net.minecraft.server.GameProfileBanEntry; import net.minecraft.server.GameProfileBanList; @@ -27,8 +26,10 @@ public class CraftProfileBanList implements org.bukkit.BanList { public org.bukkit.BanEntry getBanEntry(String target) { Validate.notNull(target, "Target cannot be null"); - UUID id = UUID.fromString(target); - GameProfile profile = new GameProfile(id, null); + GameProfile profile = MinecraftServer.getServer().getUserCache().a(target); + if (profile == null) { + return null; + } GameProfileBanEntry entry = (GameProfileBanEntry) list.get(profile); if (entry == null) { @@ -42,8 +43,10 @@ public class CraftProfileBanList implements org.bukkit.BanList { public org.bukkit.BanEntry addBan(String target, String reason, Date expires, String source) { Validate.notNull(target, "Ban target cannot be null"); - UUID id = UUID.fromString(target); - GameProfile profile = new GameProfile(id, null); + GameProfile profile = MinecraftServer.getServer().getUserCache().a(target); + if (profile == null) { + return null; + } GameProfileBanEntry entry = new GameProfileBanEntry(profile, new Date(), StringUtils.isBlank(source) ? null : source, expires, @@ -75,8 +78,10 @@ public class CraftProfileBanList implements org.bukkit.BanList { public boolean isBanned(String target) { Validate.notNull(target, "Target cannot be null"); - UUID id = UUID.fromString(target); - GameProfile profile = new GameProfile(id, null); + GameProfile profile = MinecraftServer.getServer().getUserCache().a(target); + if (profile == null) { + return false; + } return list.isBanned(profile); } @@ -85,9 +90,7 @@ public class CraftProfileBanList implements org.bukkit.BanList { public void pardon(String target) { Validate.notNull(target, "Target cannot be null"); - UUID id = UUID.fromString(target); - GameProfile profile = new GameProfile(id, null); - + GameProfile profile = MinecraftServer.getServer().getUserCache().a(target); list.remove(profile); } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index e33576d96e..111abb829b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1356,8 +1356,6 @@ public final class CraftServer implements Server { case IP: return new CraftIpBanList(playerList.getIPBans()); case NAME: - return null; - case UUID: default: return new CraftProfileBanList(playerList.getProfileBans()); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 220967baa2..7c427fa38b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -738,15 +738,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public boolean isBanned() { - return server.getBanList(BanList.Type.UUID).isBanned(getUniqueId().toString()); + return server.getBanList(BanList.Type.NAME).isBanned(getName()); } @Override public void setBanned(boolean value) { if (value) { - server.getBanList(BanList.Type.UUID).addBan(getUniqueId().toString(), null, null, null); + server.getBanList(BanList.Type.NAME).addBan(getName(), null, null, null); } else { - server.getBanList(BanList.Type.UUID).pardon(getUniqueId().toString()); + server.getBanList(BanList.Type.NAME).pardon(getName()); } }