3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 11:00:06 +01:00

fix some more issues

Dieser Commit ist enthalten in:
Jake Potrebic 2024-04-26 11:39:20 -07:00
Ursprung cc81668863
Commit 44e68c301a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: ECE0B3C133C016C5
114 geänderte Dateien mit 183 neuen und 125 gelöschten Zeilen

Datei anzeigen

@ -115,7 +115,7 @@ index 0000000000000000000000000000000000000000..a02a02aa0c87e0f0ed9e509e4dcab015
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/MaterialTags.java b/src/main/java/com/destroystokyo/paper/MaterialTags.java diff --git a/src/main/java/com/destroystokyo/paper/MaterialTags.java b/src/main/java/com/destroystokyo/paper/MaterialTags.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..6dc176b694ff4f50ca4b665c3cf82212cf21f16f index 0000000000000000000000000000000000000000..be212b4fbeabab32a4dab6ae554768c368efaa88
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/MaterialTags.java +++ b/src/main/java/com/destroystokyo/paper/MaterialTags.java
@@ -0,0 +1,717 @@ @@ -0,0 +1,717 @@
@ -438,7 +438,7 @@ index 0000000000000000000000000000000000000000..6dc176b694ff4f50ca4b665c3cf82212
+ */ + */
+ public static final MaterialSetTag SPAWN_EGGS = new MaterialSetTag(keyFor("spawn_eggs")) + public static final MaterialSetTag SPAWN_EGGS = new MaterialSetTag(keyFor("spawn_eggs"))
+ .endsWith("_SPAWN_EGG") + .endsWith("_SPAWN_EGG")
+ .ensureSize("SPAWN_EGGS", 78).lock(); + .ensureSize("SPAWN_EGGS", 80).lock();
+ +
+ /** + /**
+ * Covers all colors of stained glass. + * Covers all colors of stained glass.

Datei anzeigen

@ -6,7 +6,7 @@ Subject: [PATCH] Add missing effects
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
diff --git a/src/main/java/org/bukkit/Effect.java b/src/main/java/org/bukkit/Effect.java diff --git a/src/main/java/org/bukkit/Effect.java b/src/main/java/org/bukkit/Effect.java
index fd9cf25f2fdef5ee3b7143f27e5f43dfe3f21a38..2d50f5e3f95e280ae5741514d5eba6440d9966ce 100644 index fd9cf25f2fdef5ee3b7143f27e5f43dfe3f21a38..326c99d91ae125b28054b5730b9576b214e4595e 100644
--- a/src/main/java/org/bukkit/Effect.java --- a/src/main/java/org/bukkit/Effect.java
+++ b/src/main/java/org/bukkit/Effect.java +++ b/src/main/java/org/bukkit/Effect.java
@@ -131,9 +131,9 @@ public enum Effect { @@ -131,9 +131,9 @@ public enum Effect {
@ -21,7 +21,17 @@ index fd9cf25f2fdef5ee3b7143f27e5f43dfe3f21a38..2d50f5e3f95e280ae5741514d5eba644
* additional info. * additional info.
*/ */
POTION_BREAK(2002, Type.VISUAL, Color.class), POTION_BREAK(2002, Type.VISUAL, Color.class),
@@ -336,21 +336,146 @@ public enum Effect { @@ -177,7 +177,9 @@ public enum Effect {
/**
* Particles displayed when a villager grows a plant, data
* is the number of particles
+ * @deprecated partially replaced by {@link #BEE_GROWTH}
*/
+ @Deprecated(forRemoval = true, since = "1.20.5") // Paper
VILLAGER_PLANT_GROW(2005, Type.VISUAL, Integer.class),
/**
* The sound/particles used by the enderdragon's breath
@@ -336,21 +338,152 @@ public enum Effect {
* block. * block.
*/ */
OXIDISED_COPPER_SCRAPE(3005, Type.VISUAL), OXIDISED_COPPER_SCRAPE(3005, Type.VISUAL),
@ -128,6 +138,11 @@ index fd9cf25f2fdef5ee3b7143f27e5f43dfe3f21a38..2d50f5e3f95e280ae5741514d5eba644
+ */ + */
+ SHOOT_WHITE_SMOKE(2010, Type.VISUAL, BlockFace.class), + SHOOT_WHITE_SMOKE(2010, Type.VISUAL, BlockFace.class),
+ +
+ /**
+ * {@link Integer} param is the number of particles
+ */
+ BEE_GROWTH(2011, Type.VISUAL, Integer.class),
+
+ PARTICLES_SCULK_CHARGE(3006, Type.VISUAL, Integer.class), + PARTICLES_SCULK_CHARGE(3006, Type.VISUAL, Integer.class),
+ +
+ PARTICLES_SCULK_SHRIEK(3007, Type.SOUND), + PARTICLES_SCULK_SHRIEK(3007, Type.SOUND),
@ -136,6 +151,7 @@ index fd9cf25f2fdef5ee3b7143f27e5f43dfe3f21a38..2d50f5e3f95e280ae5741514d5eba644
+ +
+ PARTICLES_EGG_CRACK(3009, Type.VISUAL), + PARTICLES_EGG_CRACK(3009, Type.VISUAL),
+ +
+ @Deprecated(forRemoval = true, since = "1.20.5")
+ GUST_DUST(3010, Type.VISUAL), + GUST_DUST(3010, Type.VISUAL),
+ +
+ TRIAL_SPAWNER_SPAWN(3011, Type.VISUAL), + TRIAL_SPAWNER_SPAWN(3011, Type.VISUAL),
@ -172,7 +188,7 @@ index fd9cf25f2fdef5ee3b7143f27e5f43dfe3f21a38..2d50f5e3f95e280ae5741514d5eba644
} }
/** /**
@@ -366,8 +491,10 @@ public enum Effect { @@ -366,8 +499,10 @@ public enum Effect {
/** /**
* @return The type of the effect. * @return The type of the effect.
@ -183,7 +199,7 @@ index fd9cf25f2fdef5ee3b7143f27e5f43dfe3f21a38..2d50f5e3f95e280ae5741514d5eba644
public Type getType() { public Type getType() {
return this.type; return this.type;
} }
@@ -378,8 +505,15 @@ public enum Effect { @@ -378,8 +513,15 @@ public enum Effect {
*/ */
@Nullable @Nullable
public Class<?> getData() { public Class<?> getData() {
@ -200,7 +216,7 @@ index fd9cf25f2fdef5ee3b7143f27e5f43dfe3f21a38..2d50f5e3f95e280ae5741514d5eba644
/** /**
* Gets the Effect associated with the given ID. * Gets the Effect associated with the given ID.
@@ -396,12 +530,26 @@ public enum Effect { @@ -396,12 +538,26 @@ public enum Effect {
static { static {
for (Effect effect : values()) { for (Effect effect : values()) {

Datei anzeigen

@ -5,7 +5,8 @@ Subject: [PATCH] Add methods to get translation keys
== AT == == AT ==
public org.bukkit.craftbukkit.inventory.CraftMetaFirework public org.bukkit.craftbukkit.inventory.CraftMetaFirework
public org.bukkit.craftbukkit.inventory.CraftMetaFirework getNBT(Lorg/bukkit/FireworkEffect$Type;)I public org.bukkit.craftbukkit.inventory.CraftMetaFirework power
public org.bukkit.craftbukkit.inventory.CraftMetaFirework getNBT(Lorg/bukkit/FireworkEffect$Type;)Lnet/minecraft/world/item/component/FireworkExplosion$Shape;
Co-authored-by: MeFisto94 <MeFisto94@users.noreply.github.com> Co-authored-by: MeFisto94 <MeFisto94@users.noreply.github.com>
@ -40,8 +41,21 @@ index d839a0edf31f6803e5813b28a23fa17e20916b2c..bb8a3e670924ebcce48669c5dce57e2d
// Paper end // Paper end
@Override @Override
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
index ebdb19d7ee0460d50c082b0a41b3a6a57a3534ee..b444bd26d6c3def3494d3cc0520e462408272be3 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaFirework.java
@@ -111,7 +111,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta {
return new FireworkExplosion(CraftMetaFirework.getNBT(effect.getType()), colors, fadeColors, effect.hasTrail(), effect.hasFlicker());
}
- static FireworkExplosion.Shape getNBT(Type type) {
+ public static FireworkExplosion.Shape getNBT(Type type) { // Paper - package-private -> public
switch (type) {
case BALL:
return FireworkExplosion.Shape.SMALL_BALL;
diff --git a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java diff --git a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java
index 7f8b6462d2a1bbd39a870d2543bebc135f7eb45b..dbd1dc4453bd26fb6116b62f6ccbf69e92e09fc4 100644 index 7f8b6462d2a1bbd39a870d2543bebc135f7eb45b..441e8fbd548e425ca9b0dfd69d08f7b83081888c 100644
--- a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java --- a/src/test/java/io/papermc/paper/world/TranslationKeyTest.java
+++ b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java +++ b/src/test/java/io/papermc/paper/world/TranslationKeyTest.java
@@ -1,12 +1,27 @@ @@ -1,12 +1,27 @@
@ -73,7 +87,7 @@ index 7f8b6462d2a1bbd39a870d2543bebc135f7eb45b..dbd1dc4453bd26fb6116b62f6ccbf69e
@Test @Test
public void testChatVisibilityKeys() { public void testChatVisibilityKeys() {
@@ -15,4 +30,67 @@ public class TranslationKeyTest { @@ -15,4 +30,69 @@ public class TranslationKeyTest {
Assertions.assertEquals(ChatVisiblity.valueOf(chatVisibility.name()).getKey(), chatVisibility.translationKey(), chatVisibility + "'s translation key doesn't match"); Assertions.assertEquals(ChatVisiblity.valueOf(chatVisibility.name()).getKey(), chatVisibility.translationKey(), chatVisibility + "'s translation key doesn't match");
} }
} }
@ -101,8 +115,10 @@ index 7f8b6462d2a1bbd39a870d2543bebc135f7eb45b..dbd1dc4453bd26fb6116b62f6ccbf69e
+ +
+ @Test + @Test
+ public void testFireworkEffectType() { + public void testFireworkEffectType() {
+ for (FireworkEffect.Type type : FireworkEffect.Type.values()) { + for (final FireworkEffect.Type type : FireworkEffect.Type.values()) {
+ Assertions.assertEquals(net.minecraft.world.item.FireworkRocketItem.Shape.byId(org.bukkit.craftbukkit.inventory.CraftMetaFirework.getNBT(type)).getName(), org.bukkit.FireworkEffect.Type.NAMES.key(type), "translation key mismatch for " + type); + final net.minecraft.world.item.component.FireworkExplosion.Shape nmsType = org.bukkit.craftbukkit.inventory.CraftMetaFirework.getNBT(type);
+ Assertions.assertTrue(nmsType.getName().getContents() instanceof TranslatableContents, "contents aren't translatable");
+ Assertions.assertEquals(((TranslatableContents) nmsType.getName().getContents()).getKey(), type.translationKey(), "translation key mismatch for " + type);
+ } + }
+ } + }
+ +

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Add missing default perms for commands
diff --git a/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java b/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java diff --git a/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java b/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java
index a9ea2e38e4673686c9994a58c94ad19e59fd423c..dd95b3bfe59f2bb635afe92317288efcd2986326 100644 index a9ea2e38e4673686c9994a58c94ad19e59fd423c..52649f82351ab4f675c3cc3cd6640956b0f76b91 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java --- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java +++ b/src/main/java/org/bukkit/craftbukkit/util/permissions/CommandPermissions.java
@@ -24,13 +24,74 @@ public final class CommandPermissions { @@ -24,13 +24,75 @@ public final class CommandPermissions {
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "stop", "Allows the user to stop the server", PermissionDefault.OP, commands); DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "stop", "Allows the user to stop the server", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "list", "Allows the user to list all online players", PermissionDefault.OP, commands); DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "list", "Allows the user to list all online players", PermissionDefault.OP, commands);
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "gamemode", "Allows the user to change the gamemode of another player", PermissionDefault.OP, commands); DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "gamemode", "Allows the user to change the gamemode of another player", PermissionDefault.OP, commands);
@ -75,6 +75,7 @@ index a9ea2e38e4673686c9994a58c94ad19e59fd423c..dd95b3bfe59f2bb635afe92317288efc
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "time", "Allows the user to change or query the world's game time", PermissionDefault.OP, commands); + DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "time", "Allows the user to change or query the world's game time", PermissionDefault.OP, commands);
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "tick", "Allows the user to control the tick rate of the server", PermissionDefault.OP, commands); + DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "tick", "Allows the user to control the tick rate of the server", PermissionDefault.OP, commands);
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "title", "Allows the user to manage screen titles", PermissionDefault.OP, commands); + DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "title", "Allows the user to manage screen titles", PermissionDefault.OP, commands);
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "transfer", "Allows the user to transfer to another server", PermissionDefault.OP, commands);
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "weather", "Allows the user to set the weather", PermissionDefault.OP, commands); + DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "weather", "Allows the user to set the weather", PermissionDefault.OP, commands);
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "whitelist", "Allows the user to manage the server whitelist", PermissionDefault.OP, commands); + DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "whitelist", "Allows the user to manage the server whitelist", PermissionDefault.OP, commands);
+ DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "worldborder", "Allows the user to manage the world border", PermissionDefault.OP, commands); + DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "worldborder", "Allows the user to manage the world border", PermissionDefault.OP, commands);
@ -87,7 +88,7 @@ index a9ea2e38e4673686c9994a58c94ad19e59fd423c..dd95b3bfe59f2bb635afe92317288efc
diff --git a/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java b/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java diff --git a/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java b/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..afeb4271fffb7546209f1e651214065187c88302 index 0000000000000000000000000000000000000000..ca71c688b37ce2c8b712a4f9216cf872c8edf78e
--- /dev/null --- /dev/null
+++ b/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java +++ b/src/test/java/io/papermc/paper/permissions/MinecraftCommandPermissionsTest.java
@@ -0,0 +1,82 @@ @@ -0,0 +1,82 @@
@ -132,7 +133,7 @@ index 0000000000000000000000000000000000000000..afeb4271fffb7546209f1e6512140651
+ CraftDefaultPermissions.registerCorePermissions(); + CraftDefaultPermissions.registerCorePermissions();
+ Set<String> perms = collectMinecraftCommandPerms(); + Set<String> perms = collectMinecraftCommandPerms();
+ +
+ Commands commands = new Commands(Commands.CommandSelection.DEDICATED, CommandBuildContext.configurable(AbstractTestingBase.REGISTRY_CUSTOM, FeatureFlags.VANILLA_SET)); + Commands commands = new Commands(Commands.CommandSelection.DEDICATED, CommandBuildContext.simple(AbstractTestingBase.REGISTRY_CUSTOM, FeatureFlags.VANILLA_SET));
+ RootCommandNode<CommandSourceStack> root = commands.getDispatcher().getRoot(); + RootCommandNode<CommandSourceStack> root = commands.getDispatcher().getRoot();
+ Set<String> missing = new LinkedHashSet<>(); + Set<String> missing = new LinkedHashSet<>();
+ Set<String> foundPerms = new HashSet<>(); + Set<String> foundPerms = new HashSet<>();

Datei anzeigen

@ -33,7 +33,7 @@ index c0592a85a1a0781b83232533b9ca1b30b116eb98..125ed63d8ae812284cd452b4387fd0d6
/** /**
diff --git a/src/test/java/io/papermc/paper/inventory/ItemRarityTest.java b/src/test/java/io/papermc/paper/inventory/ItemRarityTest.java diff --git a/src/test/java/io/papermc/paper/inventory/ItemRarityTest.java b/src/test/java/io/papermc/paper/inventory/ItemRarityTest.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..d310f86c57e4521ad7666d3f738f53ac83d221f2 index 0000000000000000000000000000000000000000..8086e6a754cb94ce15428ac0cdbaa43590beb9fe
--- /dev/null --- /dev/null
+++ b/src/test/java/io/papermc/paper/inventory/ItemRarityTest.java +++ b/src/test/java/io/papermc/paper/inventory/ItemRarityTest.java
@@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..d310f86c57e4521ad7666d3f738f53ac
+ @Test + @Test
+ public void testRarityFormatting() { + public void testRarityFormatting() {
+ for (Rarity nmsRarity : Rarity.values()) { + for (Rarity nmsRarity : Rarity.values()) {
+ assertEquals(nmsRarity.color, PaperAdventure.asVanilla(ItemRarity.values()[nmsRarity.ordinal()].color), "rarity formatting is mis-matched"); + assertEquals(nmsRarity.color(), PaperAdventure.asVanilla(ItemRarity.values()[nmsRarity.ordinal()].color), "rarity formatting is mis-matched");
+ } + }
+ } + }
+} +}

Datei anzeigen

@ -85,43 +85,3 @@ index bb8a3e670924ebcce48669c5dce57e2df03fad77..bb45dde0fd91796d5fd83a5fd20f5f1d
// Paper end // Paper end
@Override @Override
diff --git a/src/test/java/io/papermc/paper/entity/EntityCategoryTest.java b/src/test/java/io/papermc/paper/entity/EntityCategoryTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..4ee48ef89f0e31a7bda4b04453fca8177874f540
--- /dev/null
+++ b/src/test/java/io/papermc/paper/entity/EntityCategoryTest.java
@@ -0,0 +1,34 @@
+package io.papermc.paper.entity;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import net.minecraft.world.entity.MobType;
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.entity.EntityCategory;
+import org.junit.jupiter.api.Test;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class EntityCategoryTest {
+
+ @Test
+ public void test() throws IllegalAccessException {
+
+ Map<MobType, String> enumMonsterTypeFieldMap = Maps.newHashMap();
+ for (Field field : MobType.class.getDeclaredFields()) {
+ if (field.getType() == MobType.class) {
+ enumMonsterTypeFieldMap.put( (MobType) field.get(null), field.getName());
+ }
+ }
+
+ for (EntityCategory entityCategory : EntityCategory.values()) {
+ enumMonsterTypeFieldMap.remove(CraftLivingEntity.fromBukkitEntityCategory(entityCategory));
+ }
+ assertTrue(enumMonsterTypeFieldMap.size() == 0, MobType.class.getName() + " instance(s): " + Joiner.on(", ").join(enumMonsterTypeFieldMap.values()) + " do not have bukkit equivalents");
+ }
+}

Datei anzeigen

@ -9,19 +9,20 @@ upstream. Until then, this test and these fixes
should address all the known issues with them should address all the known issues with them
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftEffect.java b/src/main/java/org/bukkit/craftbukkit/CraftEffect.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftEffect.java b/src/main/java/org/bukkit/craftbukkit/CraftEffect.java
index 71733f918ed84b9879ac1b142ef6205c5e768a9c..7ee13c0a0cd12979c7f8cc2e403baf9300fd61c8 100644 index 71733f918ed84b9879ac1b142ef6205c5e768a9c..239bbc2f5d2010e203eda2750777e507fc5937d0 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftEffect.java --- a/src/main/java/org/bukkit/craftbukkit/CraftEffect.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftEffect.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftEffect.java
@@ -15,6 +15,8 @@ public class CraftEffect { @@ -15,6 +15,9 @@ public class CraftEffect {
public static <T> int getDataValue(Effect effect, T data) { public static <T> int getDataValue(Effect effect, T data) {
int datavalue; int datavalue;
switch (effect) { switch (effect) {
+ case PARTICLES_SCULK_CHARGE: // Paper - add missing effects + case PARTICLES_SCULK_CHARGE: // Paper - add missing effects
+ case TRIAL_SPAWNER_DETECT_PLAYER: // Paper - add missing effects + case TRIAL_SPAWNER_DETECT_PLAYER: // Paper - add missing effects
+ case BEE_GROWTH: // Paper - add missing effects
case VILLAGER_PLANT_GROW: case VILLAGER_PLANT_GROW:
datavalue = (Integer) data; datavalue = (Integer) data;
break; break;
@@ -26,6 +28,13 @@ public class CraftEffect { @@ -26,6 +29,13 @@ public class CraftEffect {
Preconditions.checkArgument(data == Material.AIR || ((Material) data).isRecord(), "Invalid record type for Material %s!", data); Preconditions.checkArgument(data == Material.AIR || ((Material) data).isRecord(), "Invalid record type for Material %s!", data);
datavalue = Item.getId(CraftItemType.bukkitToMinecraft((Material) data)); datavalue = Item.getId(CraftItemType.bukkitToMinecraft((Material) data));
break; break;
@ -35,7 +36,7 @@ index 71733f918ed84b9879ac1b142ef6205c5e768a9c..7ee13c0a0cd12979c7f8cc2e403baf93
case SMOKE: case SMOKE:
switch ((BlockFace) data) { switch ((BlockFace) data) {
case DOWN: case DOWN:
@@ -57,8 +66,15 @@ public class CraftEffect { @@ -57,8 +67,15 @@ public class CraftEffect {
} }
break; break;
case STEP_SOUND: case STEP_SOUND:
@ -79,24 +80,28 @@ index 1c264135c34117407bfbb2d230e2ea1f9ebd0671..463b24fd34f76632b590ad659676ba49
Preconditions.checkArgument(effect.getData() == null || effect == Effect.ELECTRIC_SPARK, "Wrong kind of data for the %s effect", effect); Preconditions.checkArgument(effect.getData() == null || effect == Effect.ELECTRIC_SPARK, "Wrong kind of data for the %s effect", effect);
diff --git a/src/test/java/org/bukkit/EffectTest.java b/src/test/java/org/bukkit/EffectTest.java diff --git a/src/test/java/org/bukkit/EffectTest.java b/src/test/java/org/bukkit/EffectTest.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..875eacc2e5776901ba8593d0183844db2571f71b index 0000000000000000000000000000000000000000..eaccc9a154ff2f498d765a2932b6f3edb449f4f7
--- /dev/null --- /dev/null
+++ b/src/test/java/org/bukkit/EffectTest.java +++ b/src/test/java/org/bukkit/EffectTest.java
@@ -0,0 +1,64 @@ @@ -0,0 +1,79 @@
+package org.bukkit; +package org.bukkit;
+ +
+import com.google.common.base.Joiner;
+import java.lang.reflect.Field; +import java.lang.reflect.Field;
+import java.lang.reflect.Modifier; +import java.lang.reflect.Modifier;
+import java.util.ArrayList; +import java.util.ArrayList;
+import java.util.HashMap; +import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List; +import java.util.List;
+import java.util.Map; +import java.util.Map;
+import java.util.Set;
+import net.minecraft.world.level.block.LevelEvent; +import net.minecraft.world.level.block.LevelEvent;
+import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Test;
+ +
+import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+ +
+public class EffectTest { +public class EffectTest {
+ +
@ -125,12 +130,17 @@ index 0000000000000000000000000000000000000000..875eacc2e5776901ba8593d0183844db
+ } + }
+ } + }
+ +
+ final Set<Integer> missingEvents = new HashSet<>();
+ for (final Integer event : collectNmsLevelEvents()) { + for (final Integer event : collectNmsLevelEvents()) {
+ assertNotNull(toId.get(event), "missing API Effect: " + event); + if (toId.get(event) == null) {
+ missingEvents.add(event);
+ }
+ }
+ if (!missingEvents.isEmpty()) {
+ fail("Missing API Effects:\n" + Joiner.on("\n").join(missingEvents));
+ } + }
+ } + }
+ +
+ @SuppressWarnings("deprecation")
+ @Test + @Test
+ public void checkNoExtraApi() throws ReflectiveOperationException { + public void checkNoExtraApi() throws ReflectiveOperationException {
+ Map<Integer, Effect> toId = new HashMap<>(); + Map<Integer, Effect> toId = new HashMap<>();
@ -142,8 +152,14 @@ index 0000000000000000000000000000000000000000..875eacc2e5776901ba8593d0183844db
+ } + }
+ +
+ final List<Integer> nmsEvents = collectNmsLevelEvents(); + final List<Integer> nmsEvents = collectNmsLevelEvents();
+ final Set<Effect> extraApiEffects = new HashSet<>();
+ for (final Map.Entry<Integer, Effect> entry : toId.entrySet()) { + for (final Map.Entry<Integer, Effect> entry : toId.entrySet()) {
+ assertTrue(nmsEvents.contains(entry.getKey()), "Extra API Effect: " + entry.getValue()); + if (!nmsEvents.contains(entry.getKey())) {
+ extraApiEffects.add(entry.getValue());
+ }
+ }
+ if (!extraApiEffects.isEmpty()) {
+ fail("Extra API Effects:\n" + Joiner.on("\n").join(extraApiEffects));
+ } + }
+ } + }
+} +}

Datei anzeigen

@ -1,58 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sat, 4 Nov 2023 18:39:18 -0400
Subject: [PATCH] Add MaterialTagsTest
diff --git a/src/test/java/io/papermc/paper/inventory/item/MaterialTagsTest.java b/src/test/java/io/papermc/paper/inventory/item/MaterialTagsTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..3f2734eae2053b4b8fccd7149178699e36ce8b78
--- /dev/null
+++ b/src/test/java/io/papermc/paper/inventory/item/MaterialTagsTest.java
@@ -0,0 +1,46 @@
+package io.papermc.paper.inventory.item;
+
+import com.destroystokyo.paper.MaterialTags;
+import it.unimi.dsi.fastutil.objects.ObjectArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import net.minecraft.core.registries.BuiltInRegistries;
+import net.minecraft.world.item.Item;
+import net.minecraft.world.item.enchantment.EnchantmentCategory;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.support.AbstractTestingBase;
+import org.jetbrains.annotations.NotNull;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+public class MaterialTagsTest extends AbstractTestingBase {
+
+ private final static EnchantmentCategory[] ENCHANTMENT_CATEGORIES = EnchantmentCategory.values();
+
+ @ParameterizedTest
+ @MethodSource("items")
+ public void testEnchantables(@NotNull final Item item) {
+ final List<EnchantmentCategory> enchantableCategories = new ObjectArrayList<>();
+ for (final EnchantmentCategory enchantmentCategory : ENCHANTMENT_CATEGORIES) {
+ if (enchantmentCategory.canEnchant(item)) enchantableCategories.add(enchantmentCategory);
+ }
+
+ final boolean taggedAsEnchantable = MaterialTags.ENCHANTABLE.isTagged(CraftMagicNumbers.getMaterial(item));
+ final boolean requiresTagByInternals = !enchantableCategories.isEmpty();
+ Assertions.assertEquals(
+ requiresTagByInternals,
+ taggedAsEnchantable,
+ () -> "%s matches enchantment categories [%s] but was tagged by material tags as enchantable: %s".formatted(
+ item.getDescriptionId(),
+ enchantableCategories.stream().map(Enum::name).collect(Collectors.joining(", ")),
+ taggedAsEnchantable
+ )
+ );
+ }
+
+ private static Stream<Item> items() {
+ return BuiltInRegistries.ITEM.stream();
+ }
+}

Datei anzeigen

@ -232,6 +232,44 @@ index 2de1a2f666da9db1832907e1651dbff948e37252..5c2ed3c39c8eb850f3be1e2ea5b5a7ea
} }
} }
diff --git a/src/main/java/net/minecraft/world/entity/monster/Bogged.java b/src/main/java/net/minecraft/world/entity/monster/Bogged.java
index 9c0bfddd479eef688d2509ad700371c3c860ff1a..754eb747179d9318bc5a3883e5622cc400c4e06c 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Bogged.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Bogged.java
@@ -135,6 +135,11 @@ public class Bogged extends AbstractSkeleton implements Shearable {
}
private void spawnShearedMushrooms() {
+ // Paper start - shear drops API
+ this.generateShearedMushrooms(this::spawnAtLocation);
+ }
+ private void generateShearedMushrooms(java.util.function.Consumer<ItemStack> stackConsumer) {
+ // Paper end - shear drops API
if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
LootTable lootTable = serverLevel.getServer().reloadableRegistries().getLootTable(BuiltInLootTables.BOGGED_SHEAR);
LootParams lootParams = new LootParams.Builder(serverLevel)
@@ -143,11 +148,20 @@ public class Bogged extends AbstractSkeleton implements Shearable {
.create(LootContextParamSets.SHEARING);
for (ItemStack itemStack : lootTable.getRandomItems(lootParams)) {
- this.spawnAtLocation(itemStack);
+ stackConsumer.accept(itemStack); // Paper
}
}
}
+ // Paper start - shear drops API
+ @Override
+ public java.util.List<ItemStack> generateDefaultDrops() {
+ final java.util.List<ItemStack> drops = new java.util.ArrayList<>();
+ this.generateShearedMushrooms(drops::add);
+ return drops;
+ }
+ // Paper end - shear drops API
+
@Override
public boolean readyForShearing() {
return !this.isSheared() && this.isAlive();
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 822bfebc779646dde655239ac217bad011a9eee4..444287fea080182df533198f5c659533de86c5dc 100644 index 822bfebc779646dde655239ac217bad011a9eee4..444287fea080182df533198f5c659533de86c5dc 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen