geforkt von Mirrors/Paper
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9825)
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: 897a0a23 SPIGOT-5753: Back PotionType by a minecraft registry 255b2aa1 SPIGOT-7080: Add World#locateNearestBiome ff984826 Remove javadoc.io doc links CraftBukkit Changes: 71b0135cc SPIGOT-5753: Back PotionType by a minecraft registry a6bcb8489 SPIGOT-7080: Add World#locateNearestBiome ad0e57434 SPIGOT-7502: CraftMetaItem - cannot deserialize BlockStateTag b3efca57a SPIGOT-6400: Use Mockito instead of InvocationHandler 38c599f9d PR-1272: Only allow one entity in CraftItem instead of two f065271ac SPIGOT-7498: ChunkSnapshot.getBlockEmittedLight() gets 64 blocks upper in Overworld Spigot Changes: e0e223fe Remove javadoc.io doc links
Dieser Commit ist enthalten in:
Ursprung
69b2101f34
Commit
5f694a81ab
@ -330,9 +330,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- <configuration>
|
||||
- <links>
|
||||
- <link>https://guava.dev/releases/31.1-jre/api/docs/</link>
|
||||
- <link>https://javadoc.io/doc/org.yaml/snakeyaml/2.0/</link>
|
||||
- <link>https://javadoc.io/doc/org.jetbrains/annotations-java5/24.0.1/</link>
|
||||
- <link>https://javadoc.io/doc/net.md-5/bungeecord-chat/1.20-R0.1/</link>
|
||||
- </links>
|
||||
- <tags>
|
||||
- <tag>
|
||||
|
@ -196,8 +196,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/org/bukkit/potion/PotionBrewer.java
|
||||
+++ b/src/main/java/org/bukkit/potion/PotionBrewer.java
|
||||
@@ -0,0 +0,0 @@ public interface PotionBrewer {
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public Collection<PotionEffect> getEffects(@NotNull PotionType type, boolean upgraded, boolean extended);
|
||||
+
|
||||
+ // Paper start
|
||||
|
@ -21,9 +21,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ * @param biome Biome to find
|
||||
+ * @param radius radius to search
|
||||
+ * @return Location of biome or null if not found in specified radius
|
||||
+ * @deprecated use {@link #locateNearestBiome(Location, int, Biome...)}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ @Nullable
|
||||
+ Location locateNearestBiome(@NotNull Location origin, @NotNull Biome biome, int radius);
|
||||
+ default Location locateNearestBiome(@NotNull Location origin, @NotNull Biome biome, int radius) {
|
||||
+ return java.util.Optional.ofNullable(this.locateNearestBiome(origin, radius, 8, 8, biome)).map(BiomeSearchResult::getLocation).orElse(null);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Locates the nearest biome based on an origin, biome type, and radius to search
|
||||
@ -34,9 +38,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ * @param radius radius to search
|
||||
+ * @param step Search step 1 would mean checking every block, 8 would be every 8th block
|
||||
+ * @return Location of biome or null if not found in specified radius
|
||||
+ * @deprecated use {@link #locateNearestBiome(Location, int, int, int, Biome...)}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ @Nullable
|
||||
+ Location locateNearestBiome(@NotNull Location origin, @NotNull Biome biome, int radius, int step);
|
||||
+ default Location locateNearestBiome(@NotNull Location origin, @NotNull Biome biome, int radius, int step) {
|
||||
+ return java.util.Optional.ofNullable(this.locateNearestBiome(origin, radius, step, step, biome)).map(BiomeSearchResult::getLocation).orElse(null);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if the world:
|
||||
|
@ -1350,9 +1350,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -0,0 +0,0 @@ public interface UnsafeValues {
|
||||
|
||||
@Nullable
|
||||
FeatureFlag getFeatureFlag(@NotNull NamespacedKey key);
|
||||
* @return an internal potion data
|
||||
*/
|
||||
PotionType.InternalPotionData getInternalPotionData(NamespacedKey key);
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Deprecated(forRemoval = true)
|
||||
|
@ -12,21 +12,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
@@ -0,0 +0,0 @@ public class CraftItem extends CraftEntity implements Item {
|
||||
public void setWillAge(boolean willAge) {
|
||||
item.age = willAge ? 0 : NO_AGE_TIME;
|
||||
this.getHandle().age = willAge ? 0 : NO_AGE_TIME;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public int getHealth() {
|
||||
+ return item.health;
|
||||
+ return this.getHandle().health;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setHealth(int health) {
|
||||
+ if (health <= 0) {
|
||||
+ item.getItem().onDestroyed(item);
|
||||
+ item.discard();
|
||||
+ this.getHandle().getItem().onDestroyed(this.getHandle());
|
||||
+ this.getHandle().discard();
|
||||
+ } else {
|
||||
+ item.health = health;
|
||||
+ this.getHandle().health = health;
|
||||
+ }
|
||||
+ }
|
||||
// Paper End
|
||||
|
@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -0,0 +0,0 @@ dependencies {
|
||||
testImplementation("org.mockito:mockito-core:4.9.0") // Paper - switch to mockito
|
||||
implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation
|
||||
implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files
|
||||
implementation("commons-lang:commons-lang:2.6")
|
||||
+ implementation("net.fabricmc:mapping-io:0.3.0") // Paper - needed to read mappings for stacktrace deobfuscation
|
||||
|
@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // Paper end
|
||||
|
||||
LevelLightEngine lightengine = this.worldServer.getLightEngine();
|
||||
DataLayer skyLightArray = lightengine.getLayerListener(LightLayer.SKY).getDataLayerData(SectionPos.of(x, i, z));
|
||||
DataLayer skyLightArray = lightengine.getLayerListener(LightLayer.SKY).getDataLayerData(SectionPos.of(x, chunk.getSectionYFromSectionIndex(i), z)); // SPIGOT-7498: Convert section index
|
||||
@@ -0,0 +0,0 @@ public class CraftChunk implements Chunk {
|
||||
}
|
||||
|
||||
|
@ -1,44 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Sceri <scerimail@gmail.com>
|
||||
Date: Fri, 14 May 2021 19:06:51 +0500
|
||||
Subject: [PATCH] Fix CraftPotionBrewer cache
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionBrewer.java
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
public class CraftPotionBrewer implements PotionBrewer {
|
||||
- private static final Map<PotionType, Collection<PotionEffect>> cache = Maps.newHashMap();
|
||||
+ private static final Map<Integer, Collection<PotionEffect>> cache = Maps.newHashMap(); // Paper
|
||||
|
||||
@Override
|
||||
public Collection<PotionEffect> getEffects(PotionType damage, boolean upgraded, boolean extended) {
|
||||
- if (CraftPotionBrewer.cache.containsKey(damage))
|
||||
- return CraftPotionBrewer.cache.get(damage);
|
||||
+ // Paper start
|
||||
+ int key = damage.ordinal() << 2;
|
||||
+ key |= (upgraded ? 1 : 0) << 1;
|
||||
+ key |= extended ? 1 : 0;
|
||||
+
|
||||
+ if (CraftPotionBrewer.cache.containsKey(key))
|
||||
+ return CraftPotionBrewer.cache.get(key);
|
||||
+ // Paper end
|
||||
|
||||
List<MobEffectInstance> mcEffects = Potion.byName(CraftPotionUtil.fromBukkit(new PotionData(damage, extended, upgraded))).getEffects();
|
||||
|
||||
@@ -0,0 +0,0 @@ public class CraftPotionBrewer implements PotionBrewer {
|
||||
builder.add(CraftPotionUtil.toBukkit(effect));
|
||||
}
|
||||
|
||||
- CraftPotionBrewer.cache.put(damage, builder.build());
|
||||
+ CraftPotionBrewer.cache.put(key, builder.build()); // Paper
|
||||
|
||||
- return CraftPotionBrewer.cache.get(damage);
|
||||
+ return CraftPotionBrewer.cache.get(key); // Paper
|
||||
}
|
||||
|
||||
@Override
|
@ -113,24 +113,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
@@ -0,0 +0,0 @@ public class CraftItem extends CraftEntity implements Item {
|
||||
item.age = willAge ? 0 : NO_AGE_TIME;
|
||||
this.getHandle().age = willAge ? 0 : NO_AGE_TIME;
|
||||
}
|
||||
|
||||
+ @org.jetbrains.annotations.NotNull
|
||||
+ @Override
|
||||
+ public net.kyori.adventure.util.TriState getFrictionState() {
|
||||
+ return this.item.frictionState;
|
||||
+ return this.getHandle().frictionState;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setFrictionState(@org.jetbrains.annotations.NotNull net.kyori.adventure.util.TriState state) {
|
||||
+ java.util.Objects.requireNonNull(state, "state may not be null");
|
||||
+ this.item.frictionState = state;
|
||||
+ this.getHandle().frictionState = state;
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
public int getHealth() {
|
||||
return item.health;
|
||||
return this.getHandle().health;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
|
@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test
|
||||
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
|
||||
testImplementation("org.hamcrest:hamcrest:2.2")
|
||||
}
|
||||
testImplementation("org.mockito:mockito-core:5.5.0")
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
|
@ -43,15 +43,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // Paper Start
|
||||
+ @Override
|
||||
+ public boolean canMobPickup() {
|
||||
+ return item.canMobPickup;
|
||||
+ return this.getHandle().canMobPickup;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCanMobPickup(boolean canMobPickup) {
|
||||
+ item.canMobPickup = canMobPickup;
|
||||
+ this.getHandle().canMobPickup = canMobPickup;
|
||||
+ }
|
||||
+ // Paper End
|
||||
+
|
||||
@Override
|
||||
public void setOwner(UUID uuid) {
|
||||
this.item.setTarget(uuid);
|
||||
this.getHandle().setTarget(uuid);
|
||||
|
@ -8,42 +8,41 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/ma
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CraftItem extends CraftEntity implements Item {
|
||||
+
|
||||
|
||||
+ // Paper start
|
||||
+ private final static int NO_AGE_TIME = (int) Short.MIN_VALUE;
|
||||
+ private final static int NO_PICKUP_TIME = (int) Short.MAX_VALUE;
|
||||
+ // Paper end
|
||||
+
|
||||
private final ItemEntity item;
|
||||
|
||||
public CraftItem(CraftServer server, Entity entity, ItemEntity item) {
|
||||
public CraftItem(CraftServer server, ItemEntity entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class CraftItem extends CraftEntity implements Item {
|
||||
public void setCanMobPickup(boolean canMobPickup) {
|
||||
item.canMobPickup = canMobPickup;
|
||||
this.getHandle().canMobPickup = canMobPickup;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean canPlayerPickup() {
|
||||
+ return item.pickupDelay != NO_PICKUP_TIME;
|
||||
+ return this.getHandle().pickupDelay != NO_PICKUP_TIME;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCanPlayerPickup(boolean canPlayerPickup) {
|
||||
+ item.pickupDelay = canPlayerPickup ? 0 : NO_PICKUP_TIME;
|
||||
+ this.getHandle().pickupDelay = canPlayerPickup ? 0 : NO_PICKUP_TIME;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean willAge() {
|
||||
+ return item.age != NO_AGE_TIME;
|
||||
+ return this.getHandle().age != NO_AGE_TIME;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setWillAge(boolean willAge) {
|
||||
+ item.age = willAge ? 0 : NO_AGE_TIME;
|
||||
+ this.getHandle().age = willAge ? 0 : NO_AGE_TIME;
|
||||
+ }
|
||||
// Paper End
|
||||
|
||||
|
@ -14,22 +14,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public Location locateNearestBiome(Location origin, Biome biome, int radius) {
|
||||
+ return this.locateNearestBiome(origin, biome, radius, 8);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location locateNearestBiome(Location origin, Biome biome, int radius, int step) {
|
||||
+ BlockPos originPos = io.papermc.paper.util.MCUtil.toBlockPos(origin);
|
||||
+ Pair<BlockPos, Holder<net.minecraft.world.level.biome.Biome>> pair = getHandle().findClosestBiome3d(holder -> holder.is(CraftNamespacedKey.toMinecraft(biome.getKey())), originPos, radius, step, step);
|
||||
+ if (pair == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ BlockPos nearest = pair.getFirst();
|
||||
+ return new Location(this, nearest.getX(), nearest.getY(), nearest.getZ());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isUltrawarm() {
|
||||
+ return getHandle().dimensionType().ultraWarm();
|
||||
+ }
|
||||
@ -76,8 +60,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public Raid locateNearestRaid(Location location, int radius) {
|
||||
Preconditions.checkArgument(location != null, "Location cannot be null");
|
||||
public BiomeSearchResult locateNearestBiome(Location origin, int radius, Biome... biomes) {
|
||||
return this.locateNearestBiome(origin, radius, 32, 64, biomes);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftVector.java b/src/main/java/org/bukkit/craftbukkit/util/CraftVector.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftVector.java
|
||||
|
@ -7891,16 +7891,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ return "null";
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/io/papermc/paper/testing/DummyServer.java b/src/test/java/io/papermc/paper/testing/DummyServer.java
|
||||
diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/test/java/io/papermc/paper/testing/DummyServer.java
|
||||
+++ b/src/test/java/io/papermc/paper/testing/DummyServer.java
|
||||
--- a/src/test/java/org/bukkit/support/DummyServer.java
|
||||
+++ b/src/test/java/org/bukkit/support/DummyServer.java
|
||||
@@ -0,0 +0,0 @@ public final class DummyServer {
|
||||
return CraftRegistry.createRegistry(invocation.getArgument(0), org.bukkit.support.AbstractTestingBase.REGISTRY_CUSTOM);
|
||||
});
|
||||
final Thread currentThread = Thread.currentThread();
|
||||
when(instance.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread));
|
||||
|
||||
- final PluginManager pluginManager = new SimplePluginManager(dummyServer, new SimpleCommandMap(dummyServer));
|
||||
+ final PluginManager pluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(dummyServer, new SimpleCommandMap(dummyServer), null);
|
||||
when(dummyServer.getPluginManager()).thenReturn(pluginManager);
|
||||
- final org.bukkit.plugin.PluginManager pluginManager = new org.bukkit.plugin.SimplePluginManager(instance, new org.bukkit.command.SimpleCommandMap(instance));
|
||||
+ final org.bukkit.plugin.PluginManager pluginManager = new io.papermc.paper.plugin.manager.PaperPluginManagerImpl(instance, new org.bukkit.command.SimpleCommandMap(instance), null);
|
||||
when(instance.getPluginManager()).thenReturn(pluginManager);
|
||||
// paper end - testing additions
|
||||
|
||||
Bukkit.setServer(dummyServer);
|
||||
|
@ -19,9 +19,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -0,0 +0,0 @@ dependencies {
|
||||
implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
|
||||
implementation("org.ow2.asm:asm:9.5")
|
||||
implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation
|
||||
testImplementation("org.mockito:mockito-core:4.9.0") // Paper - switch to mockito
|
||||
+ implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files
|
||||
implementation("commons-lang:commons-lang:2.6")
|
||||
runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.1")
|
||||
@ -5000,8 +5000,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/test/java/org/bukkit/support/AbstractTestingBase.java
|
||||
+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java
|
||||
@@ -0,0 +0,0 @@ public abstract class AbstractTestingBase {
|
||||
BIOMES = REGISTRY_CUSTOM.registryOrThrow(Registries.BIOME);
|
||||
|
||||
DummyServer.setup();
|
||||
DummyEnchantments.setup();
|
||||
+ io.papermc.paper.configuration.GlobalConfigTestingBase.setupGlobalConfigForTest(); // Paper
|
||||
|
||||
|
@ -57,6 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
|
||||
+ testImplementation("org.hamcrest:hamcrest:2.2")
|
||||
+ testImplementation("org.mockito:mockito-core:5.5.0")
|
||||
+}
|
||||
+
|
||||
+val craftbukkitPackageVersion = "1_20_R2" // Paper
|
||||
@ -461,6 +462,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- <version>2.2</version>
|
||||
- <scope>test</scope>
|
||||
- </dependency>
|
||||
- <dependency>
|
||||
- <groupId>org.mockito</groupId>
|
||||
- <artifactId>mockito-core</artifactId>
|
||||
- <version>5.5.0</version>
|
||||
- <scope>test</scope>
|
||||
- </dependency>
|
||||
- </dependencies>
|
||||
-
|
||||
- <!-- This builds a completely 'ready to start' jar with all dependencies inside -->
|
||||
|
@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Sun, 22 Oct 2023 19:56:02 +0100
|
||||
Subject: [PATCH] Temp fix for serialisable blockdata
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
this.setCustomModelData(customModelData);
|
||||
}
|
||||
|
||||
- Map blockData = SerializableMeta.getObject(Map.class, map, BLOCK_DATA.BUKKIT, true);
|
||||
+ Object blockData = SerializableMeta.getObject(Object.class, map, BLOCK_DATA.BUKKIT, true);
|
||||
if (blockData != null) {
|
||||
this.blockData = (CompoundTag) CraftNBTTagConfigSerializer.deserialize(blockData);
|
||||
}
|
@ -8,14 +8,6 @@ diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -0,0 +0,0 @@ dependencies {
|
||||
implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
|
||||
implementation("org.ow2.asm:asm:9.5")
|
||||
implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation
|
||||
+ testImplementation("org.mockito:mockito-core:4.9.0") // Paper - switch to mockito
|
||||
implementation("commons-lang:commons-lang:2.6")
|
||||
runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.1")
|
||||
runtimeOnly("com.mysql:mysql-connector-j:8.1.0")
|
||||
@@ -0,0 +0,0 @@ tasks.compileJava {
|
||||
options.setIncremental(false)
|
||||
}
|
||||
@ -29,228 +21,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
publishing {
|
||||
publications.create<MavenPublication>("maven") {
|
||||
artifact(tasks.shadowJar)
|
||||
diff --git a/src/test/java/io/papermc/paper/testing/DummyServer.java b/src/test/java/io/papermc/paper/testing/DummyServer.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/testing/DummyServer.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.testing;
|
||||
+
|
||||
+import java.util.logging.Logger;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.Material;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.Server;
|
||||
+import org.bukkit.command.SimpleCommandMap;
|
||||
+import org.bukkit.craftbukkit.CraftRegistry;
|
||||
+import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemFactory;
|
||||
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.plugin.PluginManager;
|
||||
+import org.bukkit.plugin.SimplePluginManager;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
+import org.mockito.Mockito;
|
||||
+
|
||||
+import static org.mockito.Mockito.any;
|
||||
+import static org.mockito.Mockito.mock;
|
||||
+import static org.mockito.Mockito.when;
|
||||
+
|
||||
+public final class DummyServer {
|
||||
+
|
||||
+ @SuppressWarnings({"deprecation", "removal"})
|
||||
+ public static void setup() {
|
||||
+ //noinspection ConstantValue
|
||||
+ if (Bukkit.getServer() != null) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ final Server dummyServer = mock(Server.class, Mockito.withSettings().stubOnly());
|
||||
+
|
||||
+ final Logger logger = Logger.getLogger(DummyServer.class.getCanonicalName());
|
||||
+ when(dummyServer.getLogger()).thenReturn(logger);
|
||||
+ when(dummyServer.getName()).thenReturn(DummyServer.class.getSimpleName());
|
||||
+ when(dummyServer.getVersion()).thenReturn("Version_" + DummyServer.class.getPackage().getImplementationVersion());
|
||||
+ when(dummyServer.getBukkitVersion()).thenReturn("BukkitVersion_" + DummyServer.class.getPackage().getImplementationVersion());
|
||||
+
|
||||
+ final Thread currentThread = Thread.currentThread();
|
||||
+ when(dummyServer.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread));
|
||||
+
|
||||
+ when(dummyServer.getItemFactory()).thenReturn(CraftItemFactory.instance());
|
||||
+
|
||||
+ when(dummyServer.getUnsafe()).thenAnswer(ignored -> CraftMagicNumbers.INSTANCE); // lambda for lazy load
|
||||
+
|
||||
+ when(dummyServer.createBlockData(any(Material.class))).thenAnswer(invocation -> {
|
||||
+ return CraftBlockData.newData(invocation.getArgument(0, Material.class), null);
|
||||
+ });
|
||||
+
|
||||
+ when(dummyServer.getLootTable(any(NamespacedKey.class))).thenAnswer(invocation -> {
|
||||
+ final NamespacedKey key = invocation.getArgument(0, NamespacedKey.class);
|
||||
+ return new org.bukkit.craftbukkit.CraftLootTable(key, AbstractTestingBase.DATA_PACK.getLootData().getLootTable(CraftNamespacedKey.toMinecraft(key)));
|
||||
+ });
|
||||
+
|
||||
+ when(dummyServer.getRegistry(any())).thenAnswer(invocation -> {
|
||||
+ return CraftRegistry.createRegistry(invocation.getArgument(0), org.bukkit.support.AbstractTestingBase.REGISTRY_CUSTOM);
|
||||
+ });
|
||||
+
|
||||
+ final PluginManager pluginManager = new SimplePluginManager(dummyServer, new SimpleCommandMap(dummyServer));
|
||||
+ when(dummyServer.getPluginManager()).thenReturn(pluginManager);
|
||||
+
|
||||
+ Bukkit.setServer(dummyServer);
|
||||
+
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/test/java/org/bukkit/support/AbstractTestingBase.java
|
||||
+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java
|
||||
@@ -0,0 +0,0 @@ public abstract class AbstractTestingBase {
|
||||
LayeredRegistryAccess<RegistryLayer> layers = RegistryLayer.createRegistryAccess();
|
||||
layers = WorldLoader.loadAndReplaceLayer(resourceManager, layers, RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES);
|
||||
REGISTRY_CUSTOM = layers.compositeAccess().freeze();
|
||||
+ io.papermc.paper.testing.DummyServer.setup(); // Paper
|
||||
// Register vanilla pack
|
||||
DATA_PACK = ReloadableServerResources.loadResources(resourceManager, REGISTRY_CUSTOM, FeatureFlags.REGISTRY.allFlags(), Commands.CommandSelection.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join();
|
||||
// Bind tags
|
||||
@@ -0,0 +0,0 @@ public abstract class AbstractTestingBase {
|
||||
// Biome shortcut
|
||||
BIOMES = REGISTRY_CUSTOM.registryOrThrow(Registries.BIOME);
|
||||
|
||||
- DummyServer.setup();
|
||||
DummyEnchantments.setup();
|
||||
|
||||
CraftRegistry.setMinecraftRegistry(REGISTRY_CUSTOM);
|
||||
diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java
|
||||
deleted file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/test/java/org/bukkit/support/DummyServer.java
|
||||
+++ /dev/null
|
||||
@@ -0,0 +0,0 @@
|
||||
-package org.bukkit.support;
|
||||
-
|
||||
-import java.lang.reflect.InvocationHandler;
|
||||
-import java.lang.reflect.Method;
|
||||
-import java.lang.reflect.Proxy;
|
||||
-import java.util.HashMap;
|
||||
-import java.util.logging.Logger;
|
||||
-import org.bukkit.Bukkit;
|
||||
-import org.bukkit.Material;
|
||||
-import org.bukkit.NamespacedKey;
|
||||
-import org.bukkit.Server;
|
||||
-import org.bukkit.craftbukkit.CraftLootTable;
|
||||
-import org.bukkit.craftbukkit.CraftRegistry;
|
||||
-import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
-import org.bukkit.craftbukkit.inventory.CraftItemFactory;
|
||||
-import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
-import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
-import org.bukkit.craftbukkit.util.Versioning;
|
||||
-
|
||||
-public final class DummyServer implements InvocationHandler {
|
||||
- private static interface MethodHandler {
|
||||
- Object handle(DummyServer server, Object[] args);
|
||||
- }
|
||||
- private static final HashMap<Method, MethodHandler> methods = new HashMap<Method, MethodHandler>();
|
||||
- static {
|
||||
- try {
|
||||
- methods.put(
|
||||
- Server.class.getMethod("getItemFactory"),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return CraftItemFactory.instance();
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(
|
||||
- Server.class.getMethod("getName"),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return DummyServer.class.getName();
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(
|
||||
- Server.class.getMethod("getVersion"),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return DummyServer.class.getPackage().getImplementationVersion();
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(
|
||||
- Server.class.getMethod("getBukkitVersion"),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return Versioning.getBukkitVersion();
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(
|
||||
- Server.class.getMethod("getLogger"),
|
||||
- new MethodHandler() {
|
||||
- final Logger logger = Logger.getLogger(DummyServer.class.getCanonicalName());
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return logger;
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(
|
||||
- Server.class.getMethod("getUnsafe"),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return CraftMagicNumbers.INSTANCE;
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(
|
||||
- Server.class.getMethod("createBlockData", Material.class),
|
||||
- new MethodHandler() {
|
||||
- final Logger logger = Logger.getLogger(DummyServer.class.getCanonicalName());
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return CraftBlockData.newData((Material) args[0], null);
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(Server.class.getMethod("getLootTable", NamespacedKey.class),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- NamespacedKey key = (NamespacedKey) args[0];
|
||||
- return new CraftLootTable(key, AbstractTestingBase.DATA_PACK.getLootData().getLootTable(CraftNamespacedKey.toMinecraft(key)));
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(Server.class.getMethod("getRegistry", Class.class),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return CraftRegistry.createRegistry((Class) args[0], AbstractTestingBase.REGISTRY_CUSTOM);
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- Bukkit.setServer(Proxy.getProxyClass(Server.class.getClassLoader(), Server.class).asSubclass(Server.class).getConstructor(InvocationHandler.class).newInstance(new DummyServer()));
|
||||
- } catch (Throwable t) {
|
||||
- throw new Error(t);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- public static void setup() {}
|
||||
-
|
||||
- private DummyServer() {};
|
||||
-
|
||||
- @Override
|
||||
- public Object invoke(Object proxy, Method method, Object[] args) {
|
||||
- MethodHandler handler = DummyServer.methods.get(method);
|
||||
- if (handler != null) {
|
||||
- return handler.handle(this, args);
|
||||
- }
|
||||
- throw new UnsupportedOperationException(String.valueOf(method));
|
||||
- }
|
||||
-}
|
||||
+++ b/src/test/java/org/bukkit/support/DummyServer.java
|
||||
@@ -0,0 +0,0 @@ public final class DummyServer {
|
||||
|
||||
when(instance.getRegistry(any())).then(mock -> CraftRegistry.createRegistry(mock.getArgument(0), AbstractTestingBase.REGISTRY_CUSTOM));
|
||||
|
||||
+ // Paper start - testing additions
|
||||
+ final Thread currentThread = Thread.currentThread();
|
||||
+ when(instance.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread));
|
||||
+
|
||||
+ final org.bukkit.plugin.PluginManager pluginManager = new org.bukkit.plugin.SimplePluginManager(instance, new org.bukkit.command.SimpleCommandMap(instance));
|
||||
+ when(instance.getPluginManager()).thenReturn(pluginManager);
|
||||
+ // paper end - testing additions
|
||||
+
|
||||
Bukkit.setServer(instance);
|
||||
} catch (Throwable t) {
|
||||
throw new Error(t);
|
||||
|
@ -2067,7 +2067,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
public static byte toLegacyData(BlockState data) {
|
||||
return CraftLegacy.toLegacyData(data);
|
||||
@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
return CraftFeatureFlag.getFromNMS(namespacedKey);
|
||||
return new CraftPotionType(namespacedKey, potionRegistry);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 09b1c123ebe4fe06ced3a6277a100aa8d4f55fcc
|
||||
Subproject commit 897a0a238bc989f9ca89613f0ee413254bd1106b
|
@ -1 +1 @@
|
||||
Subproject commit 1bf30a4e9019c8a6444e1460135c6c33d72f45a2
|
||||
Subproject commit 71b0135cc7986690f2e0950dbcf679271e894245
|
@ -1 +1 @@
|
||||
Subproject commit 224dad51c7c6dbae96729d15807094bff1283ac4
|
||||
Subproject commit e0e223fe5197272feb12eba337cfbbc567316a84
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren