Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-19 04:50:06 +01:00
Make bans pretend to use names like before 1.7.8.
Bans require a name and UUID but our API only allows for a single string identifier for a ban entry. Until this is sorted out go back to the old name based setup since we can always get a UUID given a name.
Dieser Commit ist enthalten in:
Ursprung
a8d5c1224f
Commit
3e911dba54
@ -90,14 +90,22 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBanned() {
|
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) {
|
public void setBanned(boolean value) {
|
||||||
|
if (getName() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (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 {
|
} else {
|
||||||
server.getBanList(BanList.Type.UUID).pardon(getUniqueId().toString());
|
server.getBanList(BanList.Type.NAME).pardon(getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ public final class CraftProfileBanEntry implements org.bukkit.BanEntry {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTarget() {
|
public String getTarget() {
|
||||||
return this.profile.getId().toString();
|
return this.profile.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,7 +3,6 @@ package org.bukkit.craftbukkit;
|
|||||||
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 net.minecraft.server.GameProfileBanEntry;
|
import net.minecraft.server.GameProfileBanEntry;
|
||||||
import net.minecraft.server.GameProfileBanList;
|
import net.minecraft.server.GameProfileBanList;
|
||||||
@ -27,8 +26,10 @@ 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");
|
||||||
|
|
||||||
UUID id = UUID.fromString(target);
|
GameProfile profile = MinecraftServer.getServer().getUserCache().a(target);
|
||||||
GameProfile profile = new GameProfile(id, null);
|
if (profile == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
GameProfileBanEntry entry = (GameProfileBanEntry) list.get(profile);
|
GameProfileBanEntry entry = (GameProfileBanEntry) list.get(profile);
|
||||||
if (entry == null) {
|
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) {
|
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");
|
||||||
|
|
||||||
UUID id = UUID.fromString(target);
|
GameProfile profile = MinecraftServer.getServer().getUserCache().a(target);
|
||||||
GameProfile profile = new GameProfile(id, null);
|
if (profile == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
GameProfileBanEntry entry = new GameProfileBanEntry(profile, new Date(),
|
GameProfileBanEntry entry = new GameProfileBanEntry(profile, new Date(),
|
||||||
StringUtils.isBlank(source) ? null : source, expires,
|
StringUtils.isBlank(source) ? null : source, expires,
|
||||||
@ -75,8 +78,10 @@ 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");
|
||||||
|
|
||||||
UUID id = UUID.fromString(target);
|
GameProfile profile = MinecraftServer.getServer().getUserCache().a(target);
|
||||||
GameProfile profile = new GameProfile(id, null);
|
if (profile == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return list.isBanned(profile);
|
return list.isBanned(profile);
|
||||||
}
|
}
|
||||||
@ -85,9 +90,7 @@ 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");
|
||||||
|
|
||||||
UUID id = UUID.fromString(target);
|
GameProfile profile = MinecraftServer.getServer().getUserCache().a(target);
|
||||||
GameProfile profile = new GameProfile(id, null);
|
|
||||||
|
|
||||||
list.remove(profile);
|
list.remove(profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1356,8 +1356,6 @@ public final class CraftServer implements Server {
|
|||||||
case IP:
|
case IP:
|
||||||
return new CraftIpBanList(playerList.getIPBans());
|
return new CraftIpBanList(playerList.getIPBans());
|
||||||
case NAME:
|
case NAME:
|
||||||
return null;
|
|
||||||
case UUID:
|
|
||||||
default:
|
default:
|
||||||
return new CraftProfileBanList(playerList.getProfileBans());
|
return new CraftProfileBanList(playerList.getProfileBans());
|
||||||
}
|
}
|
||||||
|
@ -738,15 +738,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBanned() {
|
public boolean isBanned() {
|
||||||
return server.getBanList(BanList.Type.UUID).isBanned(getUniqueId().toString());
|
return server.getBanList(BanList.Type.NAME).isBanned(getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBanned(boolean value) {
|
public void setBanned(boolean value) {
|
||||||
if (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 {
|
} else {
|
||||||
server.getBanList(BanList.Type.UUID).pardon(getUniqueId().toString());
|
server.getBanList(BanList.Type.NAME).pardon(getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren