geforkt von Mirrors/Paper
Add UUID support to CraftProfileBanList
Dieser Commit ist enthalten in:
Ursprung
3fe3746012
Commit
7554e08e45
@ -5,6 +5,7 @@ import com.mojang.authlib.GameProfile;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import net.minecraft.server.GameProfileBanEntry;
|
import net.minecraft.server.GameProfileBanEntry;
|
||||||
import net.minecraft.server.GameProfileBanList;
|
import net.minecraft.server.GameProfileBanList;
|
||||||
@ -25,7 +26,7 @@ public class CraftProfileBanList implements org.bukkit.BanList {
|
|||||||
public org.bukkit.BanEntry getBanEntry(String target) {
|
public org.bukkit.BanEntry getBanEntry(String target) {
|
||||||
Validate.notNull(target, "Target cannot be null");
|
Validate.notNull(target, "Target cannot be null");
|
||||||
|
|
||||||
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(target);
|
GameProfile profile = getProfile(target);
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -42,7 +43,7 @@ public class CraftProfileBanList implements org.bukkit.BanList {
|
|||||||
public org.bukkit.BanEntry addBan(String target, String reason, Date expires, String source) {
|
public org.bukkit.BanEntry addBan(String target, String reason, Date expires, String source) {
|
||||||
Validate.notNull(target, "Ban target cannot be null");
|
Validate.notNull(target, "Ban target cannot be null");
|
||||||
|
|
||||||
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(target);
|
GameProfile profile = getProfile(target);
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -78,7 +79,7 @@ public class CraftProfileBanList implements org.bukkit.BanList {
|
|||||||
public boolean isBanned(String target) {
|
public boolean isBanned(String target) {
|
||||||
Validate.notNull(target, "Target cannot be null");
|
Validate.notNull(target, "Target cannot be null");
|
||||||
|
|
||||||
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(target);
|
GameProfile profile = getProfile(target);
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -90,7 +91,19 @@ public class CraftProfileBanList implements org.bukkit.BanList {
|
|||||||
public void pardon(String target) {
|
public void pardon(String target) {
|
||||||
Validate.notNull(target, "Target cannot be null");
|
Validate.notNull(target, "Target cannot be null");
|
||||||
|
|
||||||
GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(target);
|
GameProfile profile = getProfile(target);
|
||||||
list.remove(profile);
|
list.remove(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private GameProfile getProfile(String target) {
|
||||||
|
UUID uuid = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
uuid = UUID.fromString(target);
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
return (uuid != null) ? MinecraftServer.getServer().getUserCache().a(uuid) : MinecraftServer.getServer().getUserCache().getProfile(target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren