3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/patches/server/0861-Fix-BanList-API.patch
Jake Potrebic ac554ad46d
Updated Upstream (Bukkit/CraftBukkit) (#10691)
Updated Upstream (Bukkit/CraftBukkit)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
fa99e752 PR-1007: Add ItemMeta#getAsComponentString()
94a91782 Fix copy-pasted BlockType.Typed documentation
9b34ac8c Largely restore deprecated PotionData API
51a6449b PR-1008: Deprecate ITEMS_TOOLS, removed in 1.20.5
702d15fe Fix Javadoc reference
42f6cdf4 PR-919: Add internal ItemType and BlockType, delegate Material methods to them
237bb37b SPIGOT-1166, SPIGOT-7647: Expose Damager BlockState in EntityDamageByBlockEvent
035ea146 SPIGOT-6993: Allow #setVelocity to change the speed of a fireball and add a note to #setDirection about it
8c7880fb PR-1004: Improve field rename handling and centralize conversion between bukkit and string more
87c90e93 SPIGOT-7650: Add DamageSource for EntityDeathEvent and PlayerDeathEvent

CraftBukkit Changes:
4af0f22e8 SPIGOT-7664: Item meta should prevail over block states
c2ccc46ec SPIGOT-7666: Fix access to llama and horse special slot
124ac66d7 SPIGOT-7665: Fix ThrownPotion#getEffects() implementation only bringing custom effects
66f1f439a Restore null page behaviour of signed books even though not strictly allowed by API
6118e5398 Fix regression listening to minecraft:brand custom payloads
c1a26b366 Fix unnecessary and potential not thread-safe chat visibility check
12360a7ec Remove unused imports
147b098b4 PR-1397: Add ItemMeta#getAsComponentString()
428aefe0e Largely restore deprecated PotionData API
afe5b5ee9 PR-1275: Add internal ItemType and BlockType, delegate Material methods to them
8afeafa7d SPIGOT-1166, SPIGOT-7647: Expose Damager BlockState in EntityDamageByBlockEvent
4e7d749d4 SPIGOT-6993: Allow #setVelocity to change the speed of a fireball and add a note to #setDirection about it
441880757 Support both entity_data and bucket_entity_data on axolotl/fish buckets
0e22fdd1e Fix custom direct BlockState being not correctly set in DamageSource
f2182ed47 SPIGOT-7659: TropicalFishBucketMeta should use BUCKET_ENTITY_DATA
2a6207fe1 PR-1393: Improve field rename handling and centralize conversion between bukkit and string more
c024a5039 SPIGOT-7650: Add DamageSource for EntityDeathEvent and PlayerDeathEvent
741b84480 PR-1390: Improve internal handling of damage sources
0364df4e1 SPIGOT-7657: Error when loading angry entities
2024-05-11 23:48:37 +02:00

352 Zeilen
19 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 4 Jul 2023 11:27:10 -0700
Subject: [PATCH] Fix BanList API
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
index 8caee0181f256e2ffd4e880274859eaf5f81ae96..4d654c4f0b6210a9841427789ba70ce5d1d308be 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
@@ -115,17 +115,17 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
}
@Override
- public BanEntry<PlayerProfile> ban(String reason, Date expires, String source) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> ban(String reason, Date expires, String source) { // Paper - fix ban list API
return ((ProfileBanList) this.server.getBanList(BanList.Type.PROFILE)).addBan(this.getPlayerProfile(), reason, expires, source);
}
@Override
- public BanEntry<PlayerProfile> ban(String reason, Instant expires, String source) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> ban(String reason, Instant expires, String source) { // Paper - fix ban list API
return ((ProfileBanList) this.server.getBanList(BanList.Type.PROFILE)).addBan(this.getPlayerProfile(), reason, expires, source);
}
@Override
- public BanEntry<PlayerProfile> ban(String reason, Duration duration, String source) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> ban(String reason, Duration duration, String source) { // Paper - fix ban list API
return ((ProfileBanList) this.server.getBanList(BanList.Type.PROFILE)).addBan(this.getPlayerProfile(), reason, duration, source);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/ban/CraftProfileBanEntry.java b/src/main/java/org/bukkit/craftbukkit/ban/CraftProfileBanEntry.java
index 13e5e44b069121e51b9486c445902937f1d6c6d8..4a37c8172b42b10472bb90c9310c7ae3eeaa3481 100644
--- a/src/main/java/org/bukkit/craftbukkit/ban/CraftProfileBanEntry.java
+++ b/src/main/java/org/bukkit/craftbukkit/ban/CraftProfileBanEntry.java
@@ -9,7 +9,7 @@ import org.bukkit.BanEntry;
import org.bukkit.craftbukkit.profile.CraftPlayerProfile;
import org.bukkit.profile.PlayerProfile;
-public final class CraftProfileBanEntry implements BanEntry<PlayerProfile> {
+public final class CraftProfileBanEntry implements BanEntry<com.destroystokyo.paper.profile.PlayerProfile> { // Paper
private static final Date minorDate = Date.from(Instant.parse("1899-12-31T04:00:00Z"));
private final UserBanList list;
private final GameProfile profile;
@@ -33,8 +33,8 @@ public final class CraftProfileBanEntry implements BanEntry<PlayerProfile> {
}
@Override
- public PlayerProfile getBanTarget() {
- return new CraftPlayerProfile(this.profile);
+ public com.destroystokyo.paper.profile.PlayerProfile getBanTarget() { // Paper
+ return new com.destroystokyo.paper.profile.CraftPlayerProfile(this.profile); // Paper
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/ban/CraftProfileBanList.java b/src/main/java/org/bukkit/craftbukkit/ban/CraftProfileBanList.java
index 172202accf4448a933fcf1ff820316c7910dd7f7..50ee7656580d386db473c054f5c5ec57bb2b1424 100644
--- a/src/main/java/org/bukkit/craftbukkit/ban/CraftProfileBanList.java
+++ b/src/main/java/org/bukkit/craftbukkit/ban/CraftProfileBanList.java
@@ -24,42 +24,80 @@ public class CraftProfileBanList implements ProfileBanList {
}
@Override
- public BanEntry<PlayerProfile> getBanEntry(String target) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> getBanEntry(String target) { // Paper
Preconditions.checkArgument(target != null, "Target cannot be null");
return this.getBanEntry(CraftProfileBanList.getProfile(target));
}
@Override
- public BanEntry<PlayerProfile> getBanEntry(PlayerProfile target) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> getBanEntry(PlayerProfile target) { // Paper
Preconditions.checkArgument(target != null, "Target cannot be null");
- return this.getBanEntry(((CraftPlayerProfile) target).buildGameProfile());
+ return this.getBanEntry(((com.destroystokyo.paper.profile.SharedPlayerProfile) target).buildGameProfile()); // Paper
+ }
+ // Paper start - fix ban list API
+ @Override
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> getBanEntry(final com.destroystokyo.paper.profile.PlayerProfile target) {
+ Preconditions.checkArgument(target != null, "target cannot be null");
+
+ return this.getBanEntry(((com.destroystokyo.paper.profile.SharedPlayerProfile) target).buildGameProfile());
+ }
+
+ @Override
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> addBan(final com.destroystokyo.paper.profile.PlayerProfile target, final String reason, final Date expires, final String source) {
+ Preconditions.checkArgument(target != null, "PlayerProfile cannot be null");
+ Preconditions.checkArgument(target.getId() != null, "The PlayerProfile UUID cannot be null");
+
+ return this.addBan(((com.destroystokyo.paper.profile.SharedPlayerProfile) target).buildGameProfile(), reason, expires, source);
+ }
+
+ @Override
+ public boolean isBanned(final com.destroystokyo.paper.profile.PlayerProfile target) {
+ return this.isBanned((com.destroystokyo.paper.profile.SharedPlayerProfile) target);
+ }
+
+ @Override
+ public void pardon(final com.destroystokyo.paper.profile.PlayerProfile target) {
+ this.pardon((com.destroystokyo.paper.profile.SharedPlayerProfile) target);
}
@Override
- public BanEntry<PlayerProfile> addBan(String target, String reason, Date expires, String source) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> addBan(final com.destroystokyo.paper.profile.PlayerProfile target, final String reason, final Instant expires, final String source) {
+ Date date = expires != null ? Date.from(expires) : null;
+ return this.addBan(target, reason, date, source);
+ }
+
+ @Override
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> addBan(final com.destroystokyo.paper.profile.PlayerProfile target, final String reason, final Duration duration, final String source) {
+ Instant instant = duration != null ? Instant.now().plus(duration) : null;
+ return this.addBan(target, reason, instant, source);
+ }
+ // Paper end - fix ban list API
+
+ @Override
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> addBan(String target, String reason, Date expires, String source) { // Paper - fix ban list API
Preconditions.checkArgument(target != null, "Ban target cannot be null");
return this.addBan(CraftProfileBanList.getProfileByName(target), reason, expires, source);
}
@Override
- public BanEntry<PlayerProfile> addBan(PlayerProfile target, String reason, Date expires, String source) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> addBan(PlayerProfile target, String reason, Date expires, String source) { // Paper - fix ban list API
Preconditions.checkArgument(target != null, "PlayerProfile cannot be null");
Preconditions.checkArgument(target.getUniqueId() != null, "The PlayerProfile UUID cannot be null");
- return this.addBan(((CraftPlayerProfile) target).buildGameProfile(), reason, expires, source);
+ return this.addBan(((com.destroystokyo.paper.profile.SharedPlayerProfile) target).buildGameProfile(), reason, expires, source); // Paper
}
@Override
- public BanEntry<PlayerProfile> addBan(PlayerProfile target, String reason, Instant expires, String source) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> addBan(PlayerProfile target, String reason, Instant expires, String source) { // Paper - fix ban list API
Date date = expires != null ? Date.from(expires) : null;
return this.addBan(target, reason, date, source);
}
@Override
- public BanEntry<PlayerProfile> addBan(PlayerProfile target, String reason, Duration duration, String source) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> addBan(PlayerProfile target, String reason, Duration duration, String source) { // Paper - fix ban list API
Instant instant = duration != null ? Instant.now().plus(duration) : null;
return this.addBan(target, reason, instant, source);
}
@@ -76,8 +114,8 @@ public class CraftProfileBanList implements ProfileBanList {
}
@Override
- public Set<BanEntry<PlayerProfile>> getEntries() {
- ImmutableSet.Builder<BanEntry<PlayerProfile>> builder = ImmutableSet.builder();
+ public Set<BanEntry<com.destroystokyo.paper.profile.PlayerProfile>> getEntries() { // Paper
+ ImmutableSet.Builder<BanEntry<com.destroystokyo.paper.profile.PlayerProfile>> builder = ImmutableSet.builder(); // Paper
for (UserBanListEntry entry : this.list.getEntries()) {
GameProfile profile = entry.getUser();
builder.add(new CraftProfileBanEntry(profile, entry, this.list));
@@ -88,9 +126,14 @@ public class CraftProfileBanList implements ProfileBanList {
@Override
public boolean isBanned(PlayerProfile target) {
+ // Paper start
+ return this.isBanned((com.destroystokyo.paper.profile.SharedPlayerProfile) target);
+ }
+ private boolean isBanned(com.destroystokyo.paper.profile.SharedPlayerProfile target) {
+ // Paper end
Preconditions.checkArgument(target != null, "Target cannot be null");
- return this.isBanned(((CraftPlayerProfile) target).buildGameProfile());
+ return this.isBanned(target.buildGameProfile()); // Paper
}
@Override
@@ -102,9 +145,14 @@ public class CraftProfileBanList implements ProfileBanList {
@Override
public void pardon(PlayerProfile target) {
+ // Paper start
+ this.pardon((com.destroystokyo.paper.profile.SharedPlayerProfile) target);
+ }
+ private void pardon(com.destroystokyo.paper.profile.SharedPlayerProfile target) {
+ // Paper end
Preconditions.checkArgument(target != null, "Target cannot be null");
- this.pardon(((CraftPlayerProfile) target).buildGameProfile());
+ this.pardon(target.buildGameProfile()); // Paper
}
@Override
@@ -114,7 +162,7 @@ public class CraftProfileBanList implements ProfileBanList {
this.pardon(CraftProfileBanList.getProfile(target));
}
- public BanEntry<PlayerProfile> getBanEntry(GameProfile profile) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> getBanEntry(GameProfile profile) { // Paper
if (profile == null) {
return null;
}
@@ -127,7 +175,7 @@ public class CraftProfileBanList implements ProfileBanList {
return new CraftProfileBanEntry(profile, entry, this.list);
}
- public BanEntry<PlayerProfile> addBan(GameProfile profile, String reason, Date expires, String source) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> addBan(GameProfile profile, String reason, Date expires, String source) { // Paper
if (profile == null) {
return null;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 7522a31d618e90d5109f3067e07748f9a07482a5..7dfad8abaf5db2ca5ea942a0ce92c3313a132205 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1733,23 +1733,23 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
@Override
- public BanEntry<PlayerProfile> ban(String reason, Date expires, String source) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> ban(String reason, Date expires, String source) { // Paper - fix ban list API
return this.ban(reason, expires, source, true);
}
@Override
- public BanEntry<PlayerProfile> ban(String reason, Instant expires, String source) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> ban(String reason, Instant expires, String source) { // Paper - fix ban list API
return this.ban(reason, expires != null ? Date.from(expires) : null, source);
}
@Override
- public BanEntry<PlayerProfile> ban(String reason, Duration duration, String source) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> ban(String reason, Duration duration, String source) { // Paper - fix ban list API
return this.ban(reason, duration != null ? Instant.now().plus(duration) : null, source);
}
@Override
- public BanEntry<PlayerProfile> ban(String reason, Date expires, String source, boolean kickPlayer) {
- BanEntry<PlayerProfile> banEntry = ((ProfileBanList) this.server.getBanList(BanList.Type.PROFILE)).addBan(this.getPlayerProfile(), reason, expires, source);
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> ban(String reason, Date expires, String source, boolean kickPlayer) { // Paper - fix ban list API
+ BanEntry<com.destroystokyo.paper.profile.PlayerProfile> banEntry = ((ProfileBanList) this.server.getBanList(BanList.Type.PROFILE)).addBan(this.getPlayerProfile(), reason, expires, source); // Paper - fix ban list API
if (kickPlayer) {
this.kickPlayer(reason);
}
@@ -1757,12 +1757,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
@Override
- public BanEntry<PlayerProfile> ban(String reason, Instant instant, String source, boolean kickPlayer) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> ban(String reason, Instant instant, String source, boolean kickPlayer) { // Paper - fix ban list API
return this.ban(reason, instant != null ? Date.from(instant) : null, source, kickPlayer);
}
@Override
- public BanEntry<PlayerProfile> ban(String reason, Duration duration, String source, boolean kickPlayer) {
+ public BanEntry<com.destroystokyo.paper.profile.PlayerProfile> ban(String reason, Duration duration, String source, boolean kickPlayer) { // Paper - fix ban list API
return this.ban(reason, duration != null ? Instant.now().plus(duration) : null, source, kickPlayer);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
index d2c121cc610b6c635e2de5059b147f5ee35096bd..3e725dd3aca80a062917e3fd214c554b52dddde5 100644
--- a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
+++ b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
@@ -28,7 +28,7 @@ import org.bukkit.profile.PlayerProfile;
import org.bukkit.profile.PlayerTextures;
@SerializableAs("PlayerProfile")
-public final class CraftPlayerProfile implements PlayerProfile, com.destroystokyo.paper.profile.SharedPlayerProfile { // Paper
+public final class CraftPlayerProfile implements PlayerProfile, com.destroystokyo.paper.profile.SharedPlayerProfile, com.destroystokyo.paper.profile.PlayerProfile { // Paper
@Nonnull
public static GameProfile validateSkullProfile(@Nonnull GameProfile gameProfile) {
@@ -135,7 +135,7 @@ public final class CraftPlayerProfile implements PlayerProfile, com.destroystoky
}
@Override
- public CompletableFuture<PlayerProfile> update() {
+ public CompletableFuture update() { // Paper - have to remove generic to avoid clashing between bukkit.PlayerProfile and paper.PlayerProfile
return CompletableFuture.supplyAsync(this::getUpdatedProfile, Util.PROFILE_EXECUTOR); // Paper - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
}
@@ -289,4 +289,71 @@ public final class CraftPlayerProfile implements PlayerProfile, com.destroystoky
// Paper - diff on change
return profile;
}
+
+ // Paper start - This must implement our PlayerProfile so generic casts succeed from cb.CraftPlayerProfile to paper.PlayerProfile
+ // The methods don't actually have to be implemented, because the profile should immediately be cast to SharedPlayerProfile
+ @Override
+ public String setName(final String name) {
+ throw new UnsupportedOperationException("Do not cast to com.destroystokyo.paper.profile.PlayerProfile");
+ }
+
+ @Override
+ public UUID getId() {
+ throw new UnsupportedOperationException("Do not cast to com.destroystokyo.paper.profile.PlayerProfile");
+ }
+
+ @Override
+ public UUID setId(final UUID uuid) {
+ throw new UnsupportedOperationException("Do not cast to com.destroystokyo.paper.profile.PlayerProfile");
+ }
+
+ @Override
+ public java.util.Set<com.destroystokyo.paper.profile.ProfileProperty> getProperties() {
+ throw new UnsupportedOperationException("Do not cast to com.destroystokyo.paper.profile.PlayerProfile");
+ }
+
+ @Override
+ public boolean hasProperty(final String property) {
+ throw new UnsupportedOperationException("Do not cast to com.destroystokyo.paper.profile.PlayerProfile");
+ }
+
+ @Override
+ public void setProperty(final com.destroystokyo.paper.profile.ProfileProperty property) {
+ throw new UnsupportedOperationException("Do not cast to com.destroystokyo.paper.profile.PlayerProfile");
+ }
+
+ @Override
+ public void setProperties(final java.util.Collection<com.destroystokyo.paper.profile.ProfileProperty> properties) {
+ throw new UnsupportedOperationException("Do not cast to com.destroystokyo.paper.profile.PlayerProfile");
+ }
+
+ @Override
+ public void clearProperties() {
+ throw new UnsupportedOperationException("Do not cast to com.destroystokyo.paper.profile.PlayerProfile");
+ }
+
+ @Override
+ public boolean completeFromCache() {
+ throw new UnsupportedOperationException("Do not cast to com.destroystokyo.paper.profile.PlayerProfile");
+ }
+
+ @Override
+ public boolean completeFromCache(final boolean onlineMode) {
+ throw new UnsupportedOperationException("Do not cast to com.destroystokyo.paper.profile.PlayerProfile");
+ }
+
+ @Override
+ public boolean completeFromCache(final boolean lookupUUID, final boolean onlineMode) {
+ throw new UnsupportedOperationException("Do not cast to com.destroystokyo.paper.profile.PlayerProfile");
+ }
+
+ @Override
+ public boolean complete(final boolean textures) {
+ throw new UnsupportedOperationException("Do not cast to com.destroystokyo.paper.profile.PlayerProfile");
+ }
+
+ @Override
+ public boolean complete(final boolean textures, final boolean onlineMode) {
+ throw new UnsupportedOperationException("Do not cast to com.destroystokyo.paper.profile.PlayerProfile");
+ }
}