diff --git a/build-data/spigot-server-patches/re-add-asm-dependency.patch b/build-data/spigot-server-patches/re-add-asm-dependency.patch new file mode 100644 index 0000000000..48858e55f6 --- /dev/null +++ b/build-data/spigot-server-patches/re-add-asm-dependency.patch @@ -0,0 +1,29 @@ +--- /dev/null 2024-01-13 10:03:30.400485704 -0800 ++++ CraftBukkit-Patches/9999-re-add-asm-dependency.patch 2024-01-13 21:41:27.650692678 -0800 +@@ -0,0 +0,0 @@ ++From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 ++From: Jake Potrebic ++Date: Sat, 13 Jan 2024 21:41:02 -0800 ++Subject: [PATCH] re add asm dependency ++ ++ ++diff --git a/pom.xml b/pom.xml ++index 266853a682..d18fdadf92 100644 ++--- a/pom.xml +++++ b/pom.xml ++@@ -0,0 +0,0 @@ ++ 2.19.0 ++ compile ++ +++ +++ org.ow2.asm +++ asm +++ 9.5 +++ compile +++ ++ ++ org.ow2.asm ++ asm-commons ++-- ++2.43.0 ++ diff --git a/build.gradle.kts b/build.gradle.kts index f3b72af683..ed586bbaf9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -93,6 +93,8 @@ paperweight { mappingsPatch = layout.projectDirectory.file("build-data/mappings-patch.tiny") reobfMappingsPatch = layout.projectDirectory.file("build-data/reobf-mappings-patch.tiny") + spigotServerPatchPatchesDir = layout.projectDirectory.dir("build-data/spigot-server-patches") + reobfPackagesToFix.addAll( "co.aikar.timings", "com.destroystokyo.paper", diff --git a/patches/api/Add-ItemStack-Recipe-API-helper-methods.patch b/patches/api/Add-ItemStack-Recipe-API-helper-methods.patch index d777c95b43..521b3e099d 100644 --- a/patches/api/Add-ItemStack-Recipe-API-helper-methods.patch +++ b/patches/api/Add-ItemStack-Recipe-API-helper-methods.patch @@ -14,8 +14,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/inventory/RecipeChoice.java @@ -0,0 +0,0 @@ public interface RecipeChoice extends Predicate, Cloneable { /** - * Represents a choice that will be valid only one of the stacks is exactly - * matched (aside from stack size). + * Represents a choice that will be valid only if one of the stacks is + * exactly matched (aside from stack size). - *
- * Only valid for shaped recipes */ diff --git a/patches/api/Add-enchantWithLevels-API.patch b/patches/api/Add-enchantWithLevels-API.patch index 778f6fb684..b512d8bcf0 100644 --- a/patches/api/Add-enchantWithLevels-API.patch +++ b/patches/api/Add-enchantWithLevels-API.patch @@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public interface ItemFactory { * @param level the level to use, which is the level in the enchantment table * @param allowTreasures allows treasure enchants, e.g. mending, if true. - * @return the modified ItemStack, or a copy if the ItemStack cannot be enchanted directly + * @return a new ItemStack containing the result of the Enchantment + * @deprecated use {@link #enchantWithLevels(ItemStack, int, boolean, java.util.Random)}. This method's implementation is poorly + * designed and was originally broken. */ @@ -23,9 +23,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** @@ -0,0 +0,0 @@ public interface ItemFactory { + * @param level the level to use, which is the level in the enchantment table * @param allowTreasures allow the treasure enchants, e.g. mending, if true. - * @return the modified ItemStack, or a copy if the ItemStack cannot be - * enchanted directly + * @return a new ItemStack containing the result of the Enchantment + * @deprecated use {@link #enchantWithLevels(ItemStack, int, boolean, java.util.Random)}. This method's implementation is poorly + * designed and was originally broken. */ @@ -35,9 +35,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** @@ -0,0 +0,0 @@ public interface ItemFactory { + * @param level the level to use, which is the level in the enchantment table * @param allowTreasures allow treasure enchantments, e.g. mending, if true. - * @return the modified ItemStack, or a copy if the ItemStack cannot be - * enchanted directly + * @return a new ItemStack containing the result of the Enchantment + * @deprecated use {@link #enchantWithLevels(ItemStack, int, boolean, java.util.Random)}. This method's implementation is poorly + * designed and was originally broken. */ diff --git a/patches/api/Fix-Spigot-annotation-mistakes.patch b/patches/api/Fix-Spigot-annotation-mistakes.patch index 4a617a67bc..6fb24a1274 100644 --- a/patches/api/Fix-Spigot-annotation-mistakes.patch +++ b/patches/api/Fix-Spigot-annotation-mistakes.patch @@ -623,30 +623,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** @@ -0,0 +0,0 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient - * @param loc The location to strike lightning - * @param isSilent Whether this strike makes no sound - * @return The lightning entity. -+ * @deprecated The lightning strike sound has been moved into the client and -+ * this doesn't prevent the sound being played. Use the regular (non spigot) methods instead -+ * for a consistent behavior. - */ - @NotNull -+ @Deprecated // Paper - public LightningStrike strikeLightning(@NotNull Location loc, boolean isSilent) { - throw new UnsupportedOperationException("Not supported yet."); - } -@@ -0,0 +0,0 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient - * @param loc The location to strike lightning - * @param isSilent Whether this strike makes no sound - * @return The lightning entity. -+ * @deprecated The lightning strike sound has been moved into the client and -+ * this doesn't prevent the sound being played. Use the regular (non spigot) methods instead -+ * for a consistent behavior. - */ - @NotNull -+ @Deprecated // Paper - public LightningStrike strikeLightningEffect(@NotNull Location loc, boolean isSilent) { - throw new UnsupportedOperationException("Not supported yet."); } } @@ -815,17 +791,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Deprecated // Paper public class Spigot extends Entity.Spigot { -- /* -+ /** - * Returns whether the strike is silent. - * - * @return whether the strike is silent. -+ * @deprecated The lightning strike sound has been moved into the client and -+ * this can't predict if the sound will be played or not accurately. - */ -+ @Deprecated // Paper - public boolean isSilent() { - throw new UnsupportedOperationException("Not supported yet."); + /** +@@ -0,0 +0,0 @@ public interface LightningStrike extends Entity { } } diff --git a/patches/api/Support-cancellation-supression-of-EntityDismount-Ve.patch b/patches/api/Support-cancellation-supression-of-EntityDismount-Ve.patch index ef12284ed5..963b45765d 100644 --- a/patches/api/Support-cancellation-supression-of-EntityDismount-Ve.patch +++ b/patches/api/Support-cancellation-supression-of-EntityDismount-Ve.patch @@ -20,6 +20,48 @@ this is going to be the best soultion all around. Improvements/suggestions welcome! +diff --git a/src/main/java/org/bukkit/event/entity/EntityDismountEvent.java b/src/main/java/org/bukkit/event/entity/EntityDismountEvent.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/event/entity/EntityDismountEvent.java ++++ b/src/main/java/org/bukkit/event/entity/EntityDismountEvent.java +@@ -0,0 +0,0 @@ public class EntityDismountEvent extends EntityEvent implements Cancellable { + private static final HandlerList handlers = new HandlerList(); + private boolean cancelled; + private final Entity dismounted; ++ private final boolean isCancellable; // Paper + + public EntityDismountEvent(@NotNull Entity what, @NotNull Entity dismounted) { ++ // Paper start ++ this(what, dismounted, true); ++ } ++ ++ public EntityDismountEvent(@NotNull Entity what, @NotNull Entity dismounted, boolean isCancellable) { ++ // Paper end + super(what); + this.dismounted = dismounted; ++ this.isCancellable = isCancellable; // Paper + } + + /** +@@ -0,0 +0,0 @@ public class EntityDismountEvent extends EntityEvent implements Cancellable { + + @Override + public void setCancelled(boolean cancel) { ++ // Paper start ++ if (cancel && !this.isCancellable) { ++ return; ++ } + this.cancelled = cancel; + } + ++ public boolean isCancellable() { ++ return this.isCancellable; ++ // Paper end ++ } ++ + @NotNull + @Override + public HandlerList getHandlers() { diff --git a/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java b/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java diff --git a/patches/server/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch b/patches/server/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch index 4673d64b2e..accf277ca4 100644 --- a/patches/server/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch +++ b/patches/server/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch @@ -10,20 +10,20 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - java.util.UUID uniqueId = gameprofile.getId(); - final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; + java.util.UUID uniqueId = gameprofile.getId(); + final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; -- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId); -+ // Paper start -+ com.destroystokyo.paper.profile.PlayerProfile profile = org.bukkit.Bukkit.createProfile(uniqueId, playerName); -+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile); - server.getPluginManager().callEvent(asyncEvent); -+ profile = asyncEvent.getPlayerProfile(); -+ profile.complete(); -+ gameprofile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile); -+ playerName = gameprofile.getName(); -+ uniqueId = gameprofile.getId(); -+ // Paper end +- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId); ++ // Paper start ++ com.destroystokyo.paper.profile.PlayerProfile profile = org.bukkit.Bukkit.createProfile(uniqueId, playerName); ++ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile); + server.getPluginManager().callEvent(asyncEvent); ++ profile = asyncEvent.getPlayerProfile(); ++ profile.complete(); ++ gameprofile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile); ++ playerName = gameprofile.getName(); ++ uniqueId = gameprofile.getId(); ++ // Paper end - if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) { - final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address, uniqueId); + if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) { + final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address, uniqueId); diff --git a/patches/server/Add-ItemFactory-getSpawnEgg-API.patch b/patches/server/Add-ItemFactory-getSpawnEgg-API.patch index 16dd2dd9bd..7c2a37e7c7 100644 --- a/patches/server/Add-ItemFactory-getSpawnEgg-API.patch +++ b/patches/server/Add-ItemFactory-getSpawnEgg-API.patch @@ -32,11 +32,10 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java -@@ -0,0 +0,0 @@ public class Commodore - return; +@@ -0,0 +0,0 @@ public class Commodore { } // Paper end -+ + + // Paper start - ItemFactory#getSpawnEgg (paper had original method that returned ItemStack, upstream added identical but returned Material) + if (owner.equals("org/bukkit/inventory/ItemFactory") && name.equals("getSpawnEgg") && desc.equals("(Lorg/bukkit/entity/EntityType;)Lorg/bukkit/inventory/ItemStack;")) { + super.visitInsn(Opcodes.SWAP); // has 1 param, this moves the owner instance to the top for the checkcast @@ -46,6 +45,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return; + } + // Paper end - ItemFactory#getSpawnEgg - if ( modern ) - { - if ( owner.equals( "org/bukkit/Material" ) ) + if (modern) { + if (owner.equals("org/bukkit/Material") || (instantiatedMethodType != null && instantiatedMethodType.getDescriptor().startsWith("(Lorg/bukkit/Material;)"))) { + switch (name) { diff --git a/patches/server/Add-Velocity-IP-Forwarding-Support.patch b/patches/server/Add-Velocity-IP-Forwarding-Support.patch index 290268ffc0..1a2e200bba 100644 --- a/patches/server/Add-Velocity-IP-Forwarding-Support.patch +++ b/patches/server/Add-Velocity-IP-Forwarding-Support.patch @@ -148,22 +148,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return; + } + // Paper end - // Spigot start - // Paper start - Cache authenticator threads - authenticatorPool.execute(new Runnable() { + // CraftBukkit start + // Paper start - Cache authenticator threads + authenticatorPool.execute(new Runnable() { @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - public class LoginHandler { - public void fireEvents(GameProfile gameprofile) throws Exception { -+ // Paper start - Velocity support -+ if (ServerLoginPacketListenerImpl.this.velocityLoginMessageId == -1 && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) { -+ disconnect("This server requires you to connect with Velocity."); -+ return; -+ } -+ // Paper end - String playerName = gameprofile.getName(); - java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(); - java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.channel.remoteAddress()).getAddress(); // Paper + // CraftBukkit start + private void callPlayerPreLoginEvents(GameProfile gameprofile) throws Exception { ++ // Paper start - Velocity support ++ if (ServerLoginPacketListenerImpl.this.velocityLoginMessageId == -1 && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) { ++ disconnect("This server requires you to connect with Velocity."); ++ return; ++ } ++ // Paper end + String playerName = gameprofile.getName(); + java.net.InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress(); + java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) this.connection.channel.remoteAddress()).getAddress(); // Paper @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @Override @@ -202,7 +202,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Proceed with login + authenticatorPool.execute(() -> { + try { -+ new LoginHandler().fireEvents(this.authenticatedProfile); ++ this.callPlayerPreLoginEvents(this.authenticatedProfile); + } catch (Exception ex) { + disconnect("Failed to verify username!"); + server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + this.authenticatedProfile.getName(), ex); diff --git a/patches/server/Add-missing-team-sidebar-display-slots.patch b/patches/server/Add-missing-team-sidebar-display-slots.patch index fc42310d39..42ee1dce16 100644 --- a/patches/server/Add-missing-team-sidebar-display-slots.patch +++ b/patches/server/Add-missing-team-sidebar-display-slots.patch @@ -55,10 +55,11 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java -@@ -0,0 +0,0 @@ public class Commodore - desc = getOriginalOrRewrite( desc ); +@@ -0,0 +0,0 @@ public class Commodore { + desc = getOriginalOrRewrite(desc); } // Paper end ++ + // Paper start - DisplaySlot + if (owner.equals("org/bukkit/scoreboard/DisplaySlot")) { + if (name.startsWith("SIDEBAR_") && !name.startsWith("SIDEBAR_TEAM_")) { @@ -67,9 +68,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + // Paper end - DisplaySlot - - if ( owner.equals( "org/bukkit/block/Biome" ) ) - { + if (owner.equals("org/bukkit/block/Biome")) { + switch (name) { + case "NETHER": diff --git a/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java b/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 diff --git a/patches/server/Add-more-advancement-API.patch b/patches/server/Add-more-advancement-API.patch index a611b65d21..5ee1886c32 100644 --- a/patches/server/Add-more-advancement-API.patch +++ b/patches/server/Add-more-advancement-API.patch @@ -167,15 +167,15 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java -@@ -0,0 +0,0 @@ public class Commodore - ) ); +@@ -0,0 +0,0 @@ public class Commodore { + ); // Paper start - Plugin rewrites + private static final String CB_PACKAGE = org.bukkit.Bukkit.getServer().getClass().getPackageName().replace('.', '/'); private static final Map SEARCH_AND_REMOVE = initReplacementsMap(); - private static Map initReplacementsMap() - { -@@ -0,0 +0,0 @@ public class Commodore + private static Map initReplacementsMap() { + Map getAndRemove = new HashMap<>(); +@@ -0,0 +0,0 @@ public class Commodore { super.visitMethodInsn(opcode, owner, name, "()Lcom/destroystokyo/paper/profile/PlayerProfile;", itf); return; } @@ -185,8 +185,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return; + } // Paper end - if ( modern ) - { + + if (modern) { diff --git a/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java b/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 diff --git a/patches/server/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch b/patches/server/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch index 5343f54e96..fc510095e6 100644 --- a/patches/server/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch +++ b/patches/server/Add-raw-address-to-AsyncPlayerPreLoginEvent.patch @@ -9,17 +9,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - public void fireEvents(GameProfile gameprofile) throws Exception { - String playerName = gameprofile.getName(); - java.net.InetAddress address = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.getRemoteAddress()).getAddress(); -+ java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) ServerLoginPacketListenerImpl.this.connection.channel.remoteAddress()).getAddress(); // Paper - java.util.UUID uniqueId = gameprofile.getId(); - final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; + private void callPlayerPreLoginEvents(GameProfile gameprofile) throws Exception { + String playerName = gameprofile.getName(); + java.net.InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress(); ++ java.net.InetAddress rawAddress = ((java.net.InetSocketAddress) this.connection.channel.remoteAddress()).getAddress(); // Paper + java.util.UUID uniqueId = gameprofile.getId(); + final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; - // Paper start - com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(gameprofile); -- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile); -+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile); // Paper - add rawAddress - server.getPluginManager().callEvent(asyncEvent); - profile = asyncEvent.getPlayerProfile(); - profile.complete(true); // Paper - setPlayerProfileAPI + // Paper start + com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(gameprofile); +- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile); ++ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile); // Paper - add rawAddress + server.getPluginManager().callEvent(asyncEvent); + profile = asyncEvent.getPlayerProfile(); + profile.complete(true); // Paper - setPlayerProfileAPI diff --git a/patches/server/Add-setting-for-proxy-online-mode-status.patch b/patches/server/Add-setting-for-proxy-online-mode-status.patch index 2d697bb5fd..e830cdc57c 100644 --- a/patches/server/Add-setting-for-proxy-online-mode-status.patch +++ b/patches/server/Add-setting-for-proxy-online-mode-status.patch @@ -47,11 +47,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - // Spigot Start + if (result == null) { GameProfile profile = null; // Only fetch an online UUID in online mode -- if ( this.getOnlineMode() || org.spigotmc.SpigotConfig.bungee ) -+ if ( this.getOnlineMode() || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() ) // Paper - Handle via setting - { +- if (this.getOnlineMode() || org.spigotmc.SpigotConfig.bungee) { // Spigot: bungee = online mode, for now. ++ if (this.getOnlineMode() || io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()) { // Paper - Handle via setting + // This is potentially blocking :( profile = this.console.getProfileCache().get(name).orElse(null); } diff --git a/patches/server/Add-support-for-Proxy-Protocol.patch b/patches/server/Add-support-for-Proxy-Protocol.patch index cd6815ff5e..d685fe5980 100644 --- a/patches/server/Add-support-for-Proxy-Protocol.patch +++ b/patches/server/Add-support-for-Proxy-Protocol.patch @@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Paper - Add support for proxy protocol // Paper end 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") diff --git a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java b/src/main/java/net/minecraft/server/network/ServerConnectionListener.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerConnectionListener.java diff --git a/patches/server/Added-getHostname-to-AsyncPlayerPreLoginEvent.patch b/patches/server/Added-getHostname-to-AsyncPlayerPreLoginEvent.patch index 7255630649..aa793bf469 100644 --- a/patches/server/Added-getHostname-to-AsyncPlayerPreLoginEvent.patch +++ b/patches/server/Added-getHostname-to-AsyncPlayerPreLoginEvent.patch @@ -10,10 +10,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - // Paper start - com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(gameprofile); -- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile); // Paper - add rawAddress -+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile, ServerLoginPacketListenerImpl.this.connection.hostname); // Paper - add rawAddress & hostname - server.getPluginManager().callEvent(asyncEvent); - profile = asyncEvent.getPlayerProfile(); - profile.complete(true); // Paper - setPlayerProfileAPI + // Paper start + com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(gameprofile); +- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile); // Paper - add rawAddress ++ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, rawAddress, uniqueId, profile, ServerLoginPacketListenerImpl.this.connection.hostname); // Paper - add rawAddress & hostname + server.getPluginManager().callEvent(asyncEvent); + profile = asyncEvent.getPlayerProfile(); + profile.complete(true); // Paper - setPlayerProfileAPI diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 60ebb16527..2f96f79cd5 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -3012,29 +3012,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) { - final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address, uniqueId); - if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED) { -- event.disallow(asyncEvent.getResult(), asyncEvent.getKickMessage()); -+ event.disallow(asyncEvent.getResult(), asyncEvent.kickMessage()); // Paper - Adventure - } - Waitable waitable = new Waitable() { - @Override + if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) { + final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address, uniqueId); + if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED) { +- event.disallow(asyncEvent.getResult(), asyncEvent.getKickMessage()); ++ event.disallow(asyncEvent.getResult(), asyncEvent.kickMessage()); // Paper - Adventure + } + Waitable waitable = new Waitable() { + @Override @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - ServerLoginPacketListenerImpl.this.server.processQueue.add(waitable); - if (waitable.get() != PlayerPreLoginEvent.Result.ALLOWED) { -- ServerLoginPacketListenerImpl.this.disconnect(event.getKickMessage()); -+ ServerLoginPacketListenerImpl.this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.kickMessage())); // Paper - Adventure - return; - } - } else { - if (asyncEvent.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) { -- ServerLoginPacketListenerImpl.this.disconnect(asyncEvent.getKickMessage()); -+ ServerLoginPacketListenerImpl.this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(asyncEvent.kickMessage())); // Paper - Adventure - return; - } - } + ServerLoginPacketListenerImpl.this.server.processQueue.add(waitable); + if (waitable.get() != PlayerPreLoginEvent.Result.ALLOWED) { +- this.disconnect(event.getKickMessage()); ++ this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.kickMessage())); // Paper - Adventure + return; + } + } else { + if (asyncEvent.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) { +- this.disconnect(asyncEvent.getKickMessage()); ++ this.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(asyncEvent.kickMessage())); // Paper - Adventure + return; + } + } diff --git a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java @@ -4818,8 +4818,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory { - EnchantmentHelper.enchantItem(source, craft.handle, level, allowTreasures); - return craft; + CraftItemStack craft = (CraftItemStack) itemStack; + return CraftItemStack.asCraftMirror(EnchantmentHelper.enchantItem(source, craft.handle, level, allowTreasures)); } + + // Paper start - Adventure diff --git a/patches/server/Bandaid-fix-for-Effect.patch b/patches/server/Bandaid-fix-for-Effect.patch index fa069f5e26..848008729a 100644 --- a/patches/server/Bandaid-fix-for-Effect.patch +++ b/patches/server/Bandaid-fix-for-Effect.patch @@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 break; @@ -0,0 +0,0 @@ public class CraftEffect { Preconditions.checkArgument(data == Material.AIR || ((Material) data).isRecord(), "Invalid record type for Material %s!", data); - datavalue = Item.getId(CraftMagicNumbers.getItem((Material) data)); + datavalue = Item.getId(CraftItemType.bukkitToMinecraft((Material) data)); break; + // Paper start - handle shoot white smoke event + case SHOOT_WHITE_SMOKE: @@ -49,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 case STEP_SOUND: + if (data instanceof Material) { // Paper - support BlockData Preconditions.checkArgument(((Material) data).isBlock(), "Material %s is not a block!", data); - datavalue = Block.getId(CraftMagicNumbers.getBlock((Material) data).defaultBlockState()); + datavalue = Block.getId(CraftBlockType.bukkitToMinecraft((Material) data).defaultBlockState()); + // Paper start - support BlockData + break; + } diff --git a/patches/server/Build-system-changes.patch b/patches/server/Build-system-changes.patch index d72905ce9f..0ca0d65796 100644 --- a/patches/server/Build-system-changes.patch +++ b/patches/server/Build-system-changes.patch @@ -20,11 +20,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - exclude(group = "org.apache.logging.log4j", module = "log4j-api") - } + 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 + implementation("org.ow2.asm:asm-commons:9.5") implementation("commons-lang:commons-lang:2.6") runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.1") - runtimeOnly("com.mysql:mysql-connector-j:8.2.0") @@ -0,0 +0,0 @@ tasks.jar { val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim() val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\"" diff --git a/patches/server/Cache-block-data-strings.patch b/patches/server/Cache-block-data-strings.patch index 8459ad575a..97bf9cb46a 100644 --- a/patches/server/Cache-block-data-strings.patch +++ b/patches/server/Cache-block-data-strings.patch @@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - cache block data strings + if (material != null) { -+ Block block = CraftMagicNumbers.getBlock(material); ++ Block block = CraftBlockType.bukkitToMinecraft(material); + if (block != null) { + net.minecraft.resources.ResourceLocation key = BuiltInRegistries.BLOCK.getKey(block); + data = data == null ? key.toString() : key + data; @@ -67,5 +67,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private static CraftBlockData createNewData(Material material, String data) { + // Paper end - cache block data strings net.minecraft.world.level.block.state.BlockState blockData; - Block block = CraftMagicNumbers.getBlock(material); + Block block = CraftBlockType.bukkitToMinecraft(material); Map, Comparable> parsed = null; diff --git a/patches/server/Cache-user-authenticator-threads.patch b/patches/server/Cache-user-authenticator-threads.patch index b04e8189e4..1e95f302ba 100644 --- a/patches/server/Cache-user-authenticator-threads.patch +++ b/patches/server/Cache-user-authenticator-threads.patch @@ -19,22 +19,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, this.connection.send(new ClientboundHelloPacket("", this.server.getKeyPair().getPublic().getEncoded(), this.challenge)); } else { - // Spigot start -- new Thread("User Authenticator #" + ServerLoginPacketListenerImpl.UNIQUE_THREAD_ID.incrementAndGet()) { -- -+ // Paper start - Cache authenticator threads -+ authenticatorPool.execute(new Runnable() { + // CraftBukkit start +- Thread thread = new Thread("User Authenticator #" + ServerLoginPacketListenerImpl.UNIQUE_THREAD_ID.incrementAndGet()) { ++ // Paper start - Cache authenticator threads ++ authenticatorPool.execute(new Runnable() { + @Override public void run() { - try { @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, ServerLoginPacketListenerImpl.this.server.server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + ServerLoginPacketListenerImpl.this.requestedUsername, ex); } } -- }.start(); -+ }); -+ // Paper end - // Spigot end +- }; +- +- thread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(ServerLoginPacketListenerImpl.LOGGER)); +- thread.start(); ++ }); ++ // Paper end + // CraftBukkit end } @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, @@ -59,4 +61,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end } - // Spigot start + // CraftBukkit start diff --git a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch index e9ea5a91d5..ae50f7c08b 100644 --- a/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch +++ b/patches/server/Deobfuscate-stacktraces-in-log-messages-crash-report.patch @@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +0,0 @@ dependencies { - implementation("org.ow2.asm:asm-commons:9.5") // Paper - ASM event executor generation + implementation("org.ow2.asm:asm-commons:9.5") 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.5.0") // Paper - needed to read mappings for stacktrace deobfuscation diff --git a/patches/server/Fix-CME-in-CraftPersistentDataTypeRegistry.patch b/patches/server/Fix-CME-in-CraftPersistentDataTypeRegistry.patch index 3418a7258f..dccef0b633 100644 --- a/patches/server/Fix-CME-in-CraftPersistentDataTypeRegistry.patch +++ b/patches/server/Fix-CME-in-CraftPersistentDataTypeRegistry.patch @@ -16,4 +16,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private final Map adapters = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - Replace HashMap with ConcurrentHashMap to avoid CME /** - * Creates a suitable adapter instance for the primitive class type + * Creates a suitable adapter instance for the primitive class type. diff --git a/patches/server/Fix-falling-block-spawn-methods.patch b/patches/server/Fix-falling-block-spawn-methods.patch index 1f7f96b6c9..2810fe66ca 100644 --- a/patches/server/Fix-falling-block-spawn-methods.patch +++ b/patches/server/Fix-falling-block-spawn-methods.patch @@ -18,9 +18,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Preconditions.checkArgument(material != null, "Material cannot be null"); Preconditions.checkArgument(material.isBlock(), "Material.%s must be a block", material); -- FallingBlockEntity entity = FallingBlockEntity.fall(this.world, BlockPos.containing(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState(), SpawnReason.CUSTOM); +- FallingBlockEntity entity = FallingBlockEntity.fall(this.world, BlockPos.containing(location.getX(), location.getY(), location.getZ()), CraftBlockType.bukkitToMinecraft(material).defaultBlockState(), SpawnReason.CUSTOM); + // Paper start - restore API behavior for spawning falling blocks -+ FallingBlockEntity entity = new FallingBlockEntity(this.world, location.getX(), location.getY(), location.getZ(), CraftMagicNumbers.getBlock(material).defaultBlockState()); // Paper ++ FallingBlockEntity entity = new FallingBlockEntity(this.world, location.getX(), location.getY(), location.getZ(), CraftBlockType.bukkitToMinecraft(material).defaultBlockState()); // Paper + entity.time = 1; + + this.world.addFreshEntity(entity, SpawnReason.CUSTOM); diff --git a/patches/server/Fix-scoreboard-entries.patch b/patches/server/Fix-scoreboard-entries.patch deleted file mode 100644 index 17e8239bac..0000000000 --- a/patches/server/Fix-scoreboard-entries.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jake Potrebic -Date: Sat, 16 Dec 2023 13:06:20 -0800 -Subject: [PATCH] Fix scoreboard entries - -1.20.3/4 introduced ScoreHolder which broke a lot of existing -logic that just assumed score entries were strings. - -diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java -+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java -@@ -0,0 +0,0 @@ final class CraftScore implements Score { - public int getScore() { - Scoreboard board = this.objective.checkState().board; - -- if (board.getTrackedPlayers().contains(this.entry)) { // Lazy -+ // if (board.getTrackedPlayers().contains(this.entry)) { // Lazy // Paper - just use the null check - ReadOnlyScoreInfo score = board.getPlayerScoreInfo(this.entry, this.objective.getHandle()); - if (score != null) { // Lazy - return score.value(); - } -- } -+ // } // Paper - just use the null check above - - return 0; // Lazy - } -@@ -0,0 +0,0 @@ final class CraftScore implements Score { - public boolean isScoreSet() { - Scoreboard board = this.objective.checkState().board; - -- return board.getTrackedPlayers().contains(this.entry) && board.getPlayerScoreInfo(this.entry, this.objective.getHandle()) != null; -+ return /*board.getTrackedPlayers().contains(this.entry) && */board.getPlayerScoreInfo(this.entry, this.objective.getHandle()) != null; // Paper - just check if the player score info exists - } - - @Override diff --git a/patches/server/Fix-strikeLightningEffect-powers-lightning-rods-and-.patch b/patches/server/Fix-strikeLightningEffect-powers-lightning-rods-and-.patch index fbf582675c..59fdd66ffa 100644 --- a/patches/server/Fix-strikeLightningEffect-powers-lightning-rods-and-.patch +++ b/patches/server/Fix-strikeLightningEffect-powers-lightning-rods-and-.patch @@ -13,7 +13,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private ServerPlayer cause; private final Set hitEntities = Sets.newHashSet(); private int blocksSetOnFire; -- public boolean isSilent = false; // Spigot + public boolean isEffect; // Paper - Properly handle lightning effects api public LightningBolt(EntityType type, Level world) { @@ -22,8 +21,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void tick() { super.tick(); -- if (!this.isSilent && this.life == 2) { // Spigot -+ if (!this.isEffect && this.life == 2) { // Spigot // Paper - Properly handle lightning effects api +- if (this.life == 2) { ++ if (!this.isEffect && this.life == 2) { // Paper - Properly handle lightning effects api if (this.level().isClientSide()) { this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), SoundEvents.LIGHTNING_BOLT_THUNDER, SoundSource.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F, false); this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), SoundEvents.LIGHTNING_BOLT_IMPACT, SoundSource.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F, false); @@ -58,24 +57,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.world.strikeLightning(lightning, LightningStrikeEvent.Cause.CUSTOM); return (LightningStrike) lightning.getBukkitEntity(); } -@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { - { - LightningBolt lightning = EntityType.LIGHTNING_BOLT.create( CraftWorld.this.world ); - lightning.moveTo( loc.getX(), loc.getY(), loc.getZ() ); -- lightning.isSilent = isSilent; - CraftWorld.this.world.strikeLightning( lightning, LightningStrikeEvent.Cause.CUSTOM ); - return (LightningStrike) lightning.getBukkitEntity(); - } -@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World { - { - LightningBolt lightning = EntityType.LIGHTNING_BOLT.create( CraftWorld.this.world ); - lightning.moveTo( loc.getX(), loc.getY(), loc.getZ() ); -- lightning.visualOnly = true; -- lightning.isSilent = isSilent; -+ lightning.isEffect = true; // Paper - Properly handle lightning effects api - CraftWorld.this.world.strikeLightning( lightning, LightningStrikeEvent.Cause.CUSTOM ); - return (LightningStrike) lightning.getBukkitEntity(); - } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLightningStrike.java @@ -89,12 +70,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public int getFlashes() { -@@ -0,0 +0,0 @@ public class CraftLightningStrike extends CraftEntity implements LightningStrike - @Override - public boolean isSilent() - { -- return CraftLightningStrike.this.getHandle().isSilent; -+ return false; // Paper - Properly handle lightning effects api; the concept of isSilent doesn't exist as sound is controlled by the client - } - }; - diff --git a/patches/server/Fix-upstreams-block-state-factories.patch b/patches/server/Fix-upstreams-block-state-factories.patch index 07258513a4..ae78d743b2 100644 --- a/patches/server/Fix-upstreams-block-state-factories.patch +++ b/patches/server/Fix-upstreams-block-state-factories.patch @@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - return new CraftBlockEntityState<>(world, tileEntity); - } + // Paper - revert upstream's revert of the block state changes. Block entities that have already had the block type set to AIR are still valid, upstream decided to ignore them - Preconditions.checkState(tileEntity == null, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock())); + Preconditions.checkState(tileEntity == null, "Unexpected BlockState for %s", CraftBlockType.minecraftToBukkit(blockData.getBlock())); return new CraftBlockState(world, blockPosition, blockData); } }; @@ -367,7 +367,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + BlockStateFactory factory = new BlockEntityStateFactory<>(blockStateType, blockStateConstructor, blockEntityType::create); + for (net.minecraft.world.level.block.Block block : blockEntityType.validBlocks) { -+ CraftBlockStates.register(CraftMagicNumbers.getMaterial(block), factory); ++ CraftBlockStates.register(CraftBlockType.minecraftToBukkit(block), factory); } + CraftBlockStates.register(blockEntityType, factory); + // Paper end @@ -423,8 +423,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.BlockEntityType; import org.bukkit.Material; - import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.support.AbstractTestingBase; + import org.junit.jupiter.api.Test; @@ -0,0 +0,0 @@ public class BlockStateTest extends AbstractTestingBase { } } diff --git a/patches/server/Fixes-and-additions-to-the-SpawnReason-API.patch b/patches/server/Fixes-and-additions-to-the-SpawnReason-API.patch index 563f963f29..3c97d8a742 100644 --- a/patches/server/Fixes-and-additions-to-the-SpawnReason-API.patch +++ b/patches/server/Fixes-and-additions-to-the-SpawnReason-API.patch @@ -33,29 +33,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } else areaEffectCloud.discard(); // Paper this.discard(); } -diff --git a/src/main/java/net/minecraft/world/level/block/CarvedPumpkinBlock.java b/src/main/java/net/minecraft/world/level/block/CarvedPumpkinBlock.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/CarvedPumpkinBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/CarvedPumpkinBlock.java -@@ -0,0 +0,0 @@ public class CarvedPumpkinBlock extends HorizontalDirectionalBlock { - // clearPatternBlocks(world, shapedetector_shapedetectorcollection); // CraftBukkit - moved down - entity.moveTo((double) pos.getX() + 0.5D, (double) pos.getY() + 0.05D, (double) pos.getZ() + 0.5D, 0.0F, 0.0F); - // CraftBukkit start -- if (!world.addFreshEntity(entity, SpawnReason.BUILD_IRONGOLEM)) { -+ // Paper start - correct spawn reason -+ final SpawnReason spawnReason; -+ if (entity.getType() == EntityType.SNOW_GOLEM) { -+ spawnReason = SpawnReason.BUILD_SNOWMAN; -+ } else if (entity.getType() == EntityType.IRON_GOLEM) { -+ spawnReason = SpawnReason.BUILD_IRONGOLEM; -+ } else { -+ spawnReason = SpawnReason.DEFAULT; -+ } -+ if (!world.addFreshEntity(entity, spawnReason)) { -+ // Paper end - return; - } - CarvedPumpkinBlock.clearPatternBlocks(world, patternResult); // CraftBukkit - from above diff --git a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java diff --git a/patches/server/Hook-into-CB-plugin-rewrites.patch b/patches/server/Hook-into-CB-plugin-rewrites.patch index e79482f356..10ba210053 100644 --- a/patches/server/Hook-into-CB-plugin-rewrites.patch +++ b/patches/server/Hook-into-CB-plugin-rewrites.patch @@ -18,10 +18,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import java.util.HashMap; import java.util.HashSet; import java.util.List; -+import java.util.Map; - import java.util.Set; - import java.util.jar.JarEntry; + import java.util.Map; +@@ -0,0 +0,0 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; + import java.util.jar.JarOutputStream; + import java.util.zip.ZipEntry; ++import javax.annotation.Nonnull; + import joptsimple.OptionParser; + import joptsimple.OptionSet; + import joptsimple.OptionSpec; @@ -0,0 +0,0 @@ import org.bukkit.plugin.AuthorNagException; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; @@ -32,30 +37,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; - -+import javax.annotation.Nonnull; -+ - /** - * This file is imported from Commodore. - * -@@ -0,0 +0,0 @@ public class Commodore - "org/bukkit/inventory/ItemStack (I)V setTypeId" - ) ); +@@ -0,0 +0,0 @@ public class Commodore { + "org/spigotmc/event/entity/EntityDismountEvent", "org/bukkit/event/entity/EntityDismountEvent" + ); + // Paper start - Plugin rewrites + private static final Map SEARCH_AND_REMOVE = initReplacementsMap(); -+ private static Map initReplacementsMap() -+ { ++ private static Map initReplacementsMap() { + Map getAndRemove = new HashMap<>(); + // Be wary of maven shade's relocations + + final java.util.jar.Manifest manifest = io.papermc.paper.util.JarManifests.manifest(Commodore.class); -+ if ( Boolean.getBoolean( "debug.rewriteForIde" ) && manifest != null) ++ if (Boolean.getBoolean( "debug.rewriteForIde") && manifest != null) + { + // unversion incoming calls for pre-relocate debug work + final String NMS_REVISION_PACKAGE = "v" + manifest.getMainAttributes().getValue("CraftBukkit-Package-Version") + "/"; + -+ getAndRemove.put( "org/bukkit/".concat( "craftbukkit/" + NMS_REVISION_PACKAGE ), NMS_REVISION_PACKAGE ); ++ getAndRemove.put("org/bukkit/".concat("craftbukkit/" + NMS_REVISION_PACKAGE), NMS_REVISION_PACKAGE); + } + + return getAndRemove; @@ -75,22 +73,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + return rewrite != null ? rewrite : original; + } -+ // Paper end ++ // Paper end - Plugin rewrites + - public static void main(String[] args) - { + public static void main(String[] args) { OptionParser parser = new OptionParser(); -@@ -0,0 +0,0 @@ public class Commodore + OptionSpec inputFlag = parser.acceptsAll(Arrays.asList("i", "input")).withRequiredArg().ofType(File.class).required(); +@@ -0,0 +0,0 @@ public class Commodore { + ClassWriter cw = new ClassWriter(cr, 0); - cr.accept( new ClassVisitor( Opcodes.ASM9, cw ) - { + cr.accept(new ClassRemapper(new ClassVisitor(Opcodes.ASM9, cw) { ++ + // Paper start - Rewrite plugins + @Override + public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) + { -+ desc = getOriginalOrRewrite( desc ); ++ desc = getOriginalOrRewrite(desc); + if ( signature != null ) { -+ signature = getOriginalOrRewrite( signature ); ++ signature = getOriginalOrRewrite(signature); + } + + return super.visitField( access, name, desc, signature, value) ; @@ -98,77 +97,70 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end + @Override - public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) - { - return new MethodVisitor( this.api, super.visitMethod( access, name, desc, signature, exceptions ) ) - { + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + return new MethodVisitor(this.api, super.visitMethod(access, name, desc, signature, exceptions)) { + + // Paper start - Plugin rewrites + @Override -+ public void visitTypeInsn(int opcode, String type) -+ { -+ type = getOriginalOrRewrite( type ); ++ public void visitTypeInsn(int opcode, String type) { ++ type = getOriginalOrRewrite(type); + -+ super.visitTypeInsn( opcode, type ); ++ super.visitTypeInsn(opcode, type); + } + + @Override + public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) { -+ for ( int i = 0; i < local.length; i++ ) ++ for (int i = 0; i < local.length; i++) + { -+ if ( !( local[i] instanceof String ) ) { continue; } ++ if (!(local[i] instanceof String)) { continue; } + -+ local[i] = getOriginalOrRewrite( (String) local[i] ); ++ local[i] = getOriginalOrRewrite((String) local[i]); + } + -+ for ( int i = 0; i < stack.length; i++ ) ++ for (int i = 0; i < stack.length; i++) + { -+ if ( !( stack[i] instanceof String ) ) { continue; } ++ if (!(stack[i] instanceof String)) { continue; } + -+ stack[i] = getOriginalOrRewrite( (String) stack[i] ); ++ stack[i] = getOriginalOrRewrite((String) stack[i]); + } + -+ super.visitFrame( type, nLocal, local, nStack, stack ); ++ super.visitFrame(type, nLocal, local, nStack, stack); + } + + @Override -+ public void visitLocalVariable(String name, String descriptor, String signature, Label start, Label end, int index) -+ { -+ descriptor = getOriginalOrRewrite( descriptor ); ++ public void visitLocalVariable(String name, String descriptor, String signature, Label start, Label end, int index) { ++ descriptor = getOriginalOrRewrite(descriptor); + -+ super.visitLocalVariable( name, descriptor, signature, start, end, index ); ++ super.visitLocalVariable(name, descriptor, signature, start, end, index); + } + // Paper end - ++ @Override - public void visitFieldInsn(int opcode, String owner, String name, String desc) - { + public void visitFieldInsn(int opcode, String owner, String name, String desc) { + // Paper start - Rewrite plugins -+ owner = getOriginalOrRewrite( owner ); -+ if ( desc != null ) -+ { -+ desc = getOriginalOrRewrite( desc ); ++ owner = getOriginalOrRewrite(owner); ++ if (desc != null) { ++ desc = getOriginalOrRewrite(desc); + } + // Paper end -+ - if ( owner.equals( "org/bukkit/block/Biome" ) ) - { - switch ( name ) -@@ -0,0 +0,0 @@ public class Commodore + if (owner.equals("org/bukkit/block/Biome")) { + switch (name) { + case "NETHER": +@@ -0,0 +0,0 @@ public class Commodore { } // Paper start - Rewrite plugins -+ owner = getOriginalOrRewrite( owner) ; -+ if (desc != null) -+ { ++ owner = getOriginalOrRewrite(owner) ; ++ if (desc != null) { + desc = getOriginalOrRewrite(desc); + } if ((owner.equals("org/bukkit/OfflinePlayer") || owner.equals("org/bukkit/entity/Player")) && name.equals("getPlayerProfile") && desc.equals("()Lorg/bukkit/profile/PlayerProfile;")) { super.visitMethodInsn(opcode, owner, name, "()Lcom/destroystokyo/paper/profile/PlayerProfile;", itf); return; -@@ -0,0 +0,0 @@ public class Commodore +@@ -0,0 +0,0 @@ public class Commodore { + @Override - public void visitLdcInsn(Object value) - { + public void visitLdcInsn(Object value) { + // Paper start + if (value instanceof Type type) { + if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { @@ -176,20 +168,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + // Paper end - if ( value instanceof String && ( (String) value ).equals( "com.mysql.jdbc.Driver" ) ) - { - super.visitLdcInsn( "com.mysql.cj.jdbc.Driver" ); -@@ -0,0 +0,0 @@ public class Commodore + if (value instanceof String && ((String) value).equals("com.mysql.jdbc.Driver")) { + super.visitLdcInsn("com.mysql.cj.jdbc.Driver"); + return; +@@ -0,0 +0,0 @@ public class Commodore { + @Override - public void visitInvokeDynamicInsn( String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments ) - { + public void visitInvokeDynamicInsn(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) { + // Paper start - Rewrite plugins -+ name = getOriginalOrRewrite( name ); -+ if ( descriptor != null ) -+ { -+ descriptor = getOriginalOrRewrite( descriptor ); ++ name = getOriginalOrRewrite(name); ++ if (descriptor != null) { ++ descriptor = getOriginalOrRewrite(descriptor); + } ++ final String fName = name; ++ final String fDescriptor = descriptor; + // Paper end - Rewrite plugins - if ( bootstrapMethodHandle.getOwner().equals( "java/lang/invoke/LambdaMetafactory" ) - && bootstrapMethodHandle.getName().equals( "metafactory" ) && bootstrapMethodArguments.length == 3 ) - { + if (bootstrapMethodHandle.getOwner().equals("java/lang/invoke/LambdaMetafactory") + && bootstrapMethodHandle.getName().equals("metafactory") && bootstrapMethodArguments.length == 3) { + Type samMethodType = (Type) bootstrapMethodArguments[0]; +@@ -0,0 +0,0 @@ public class Commodore { + methodArgs.add(new Handle(newOpcode, newOwner, newName, newDescription, newItf)); + methodArgs.add(newInstantiated); + +- super.visitInvokeDynamicInsn(name, descriptor, bootstrapMethodHandle, methodArgs.toArray(Object[]::new)); ++ super.visitInvokeDynamicInsn(fName, fDescriptor, bootstrapMethodHandle, methodArgs.toArray(Object[]::new)); // Paper - use final local vars + }, implMethod.getTag(), implMethod.getOwner(), implMethod.getName(), implMethod.getDesc(), implMethod.isInterface(), samMethodType, instantiatedMethodType); + return; + } diff --git a/patches/server/Implement-enchantWithLevels-API.patch b/patches/server/Implement-enchantWithLevels-API.patch index 9b55b45df5..5e3984d3ac 100644 --- a/patches/server/Implement-enchantWithLevels-API.patch +++ b/patches/server/Implement-enchantWithLevels-API.patch @@ -8,16 +8,6 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.jav index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -@@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory { - } - - CraftItemStack craft = (CraftItemStack) itemStack; -- EnchantmentHelper.enchantItem(source, craft.handle, level, allowTreasures); -- return craft; -+ return EnchantmentHelper.enchantItem(source, craft.handle, level, allowTreasures).asBukkitCopy(); // Paper - fix broken implementation - } - - // Paper start - Adventure @@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory { return eggItem == null ? null : new net.minecraft.world.item.ItemStack(eggItem).asBukkitMirror(); } diff --git a/patches/server/Improved-Watchdog-Support.patch b/patches/server/Improved-Watchdog-Support.patch index 3421c2b3b7..cc02b17d1f 100644 --- a/patches/server/Improved-Watchdog-Support.patch +++ b/patches/server/Improved-Watchdog-Support.patch @@ -180,8 +180,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end MinecraftServer.LOGGER.error("Encountered an unexpected exception", throwable); - // Spigot Start - if ( throwable.getCause() != null ) + CrashReport crashreport = MinecraftServer.constructOrExtractCrashReport(throwable); + @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop getInfiniburn() { -+ return com.google.common.collect.Sets.newHashSet(com.google.common.collect.Iterators.transform(net.minecraft.core.registries.BuiltInRegistries.BLOCK.getTagOrEmpty(this.getHandle().dimensionType().infiniburn()).iterator(), blockHolder -> CraftMagicNumbers.getMaterial(blockHolder.value()))); ++ return com.google.common.collect.Sets.newHashSet(com.google.common.collect.Iterators.transform(net.minecraft.core.registries.BuiltInRegistries.BLOCK.getTagOrEmpty(this.getHandle().dimensionType().infiniburn()).iterator(), blockHolder -> CraftBlockType.minecraftToBukkit(blockHolder.value()))); + } + + @Override diff --git a/patches/server/Optimise-getType-calls.patch b/patches/server/Optimise-getType-calls.patch index da67e1165f..feb050bdd5 100644 --- a/patches/server/Optimise-getType-calls.patch +++ b/patches/server/Optimise-getType-calls.patch @@ -18,9 +18,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + public final org.bukkit.Material getBukkitMaterial() { + if (this.cachedMaterial == null) { -+ this.cachedMaterial = org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(this.getBlock()); ++ this.cachedMaterial = org.bukkit.craftbukkit.block.CraftBlockType.minecraftToBukkit(this.getBlock()); + } -+ + return this.cachedMaterial; + } + // Paper end - optimise getType calls @@ -35,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public Material getBlockType(int x, int y, int z) { this.validateChunkCoordinates(x, y, z); -- return CraftMagicNumbers.getMaterial(this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z).getBlock()); +- return CraftBlockType.minecraftToBukkit(this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z).getBlock()); + return this.blockids[this.getSectionIndex(y)].get(x, y & 0xF, z).getBukkitMaterial(); // Paper - optimise getType calls } @@ -48,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public Material getType() { -- return CraftMagicNumbers.getMaterial(this.world.getBlockState(this.position).getBlock()); +- return CraftBlockType.minecraftToBukkit(this.world.getBlockState(this.position).getBlock()); + return this.world.getBlockState(this.position).getBukkitMaterial(); // Paper - optimise getType calls } @@ -61,7 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public Material getType() { -- return CraftMagicNumbers.getMaterial(this.data.getBlock()); +- return CraftBlockType.minecraftToBukkit(this.data.getBlock()); + return this.data.getBukkitMaterial(); // Paper - optimise getType calls } @@ -74,7 +73,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public Material getMaterial() { -- return CraftMagicNumbers.getMaterial(this.state.getBlock()); +- return CraftBlockType.minecraftToBukkit(this.state.getBlock()); + return this.state.getBukkitMaterial(); // Paper - optimise getType calls } @@ -87,7 +86,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public Material getType(int x, int y, int z) { -- return CraftMagicNumbers.getMaterial(this.getTypeId(x, y, z).getBlock()); +- return CraftBlockType.minecraftToBukkit(this.getTypeId(x, y, z).getBlock()); + return this.getTypeId(x, y, z).getBukkitMaterial(); // Paper - optimise getType calls } diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch index fe8b658f43..d1e04c28ba 100644 --- a/patches/server/Paper-config-files.patch +++ b/patches/server/Paper-config-files.patch @@ -19,9 +19,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +0,0 @@ dependencies { + implementation("jline:jline:2.12.1") 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 + implementation("org.ow2.asm:asm-commons:9.5") + 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") diff --git a/patches/server/Player.setPlayerProfile-API.patch b/patches/server/Player.setPlayerProfile-API.patch index 486c7781ff..82ef6ac90a 100644 --- a/patches/server/Player.setPlayerProfile-API.patch +++ b/patches/server/Player.setPlayerProfile-API.patch @@ -26,19 +26,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; + final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; - // Paper start -- com.destroystokyo.paper.profile.PlayerProfile profile = org.bukkit.Bukkit.createProfile(uniqueId, playerName); -+ com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(gameprofile); - AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile); - server.getPluginManager().callEvent(asyncEvent); - profile = asyncEvent.getPlayerProfile(); -- profile.complete(); -+ profile.complete(true); // Paper - setPlayerProfileAPI - gameprofile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile); - playerName = gameprofile.getName(); - uniqueId = gameprofile.getId(); + // Paper start +- com.destroystokyo.paper.profile.PlayerProfile profile = org.bukkit.Bukkit.createProfile(uniqueId, playerName); ++ com.destroystokyo.paper.profile.PlayerProfile profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitMirror(gameprofile); + AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile); + server.getPluginManager().callEvent(asyncEvent); + profile = asyncEvent.getPlayerProfile(); +- profile.complete(); ++ profile.complete(true); // Paper - setPlayerProfileAPI + gameprofile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile); + playerName = gameprofile.getName(); + uniqueId = gameprofile.getId(); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java @@ -223,7 +223,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java -@@ -0,0 +0,0 @@ public class Commodore +@@ -0,0 +0,0 @@ public class Commodore { return; } @@ -233,6 +233,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return; + } + // Paper end - if ( modern ) - { - if ( owner.equals( "org/bukkit/Material" ) ) ++ + if (modern) { + if (owner.equals("org/bukkit/Material") || (instantiatedMethodType != null && instantiatedMethodType.getDescriptor().startsWith("(Lorg/bukkit/Material;)"))) { + switch (name) { diff --git a/patches/server/RangedEntity-API.patch b/patches/server/RangedEntity-API.patch index ae0f75e54c..e8bf4519f0 100644 --- a/patches/server/RangedEntity-API.patch +++ b/patches/server/RangedEntity-API.patch @@ -99,7 +99,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java -@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers; +@@ -0,0 +0,0 @@ import org.bukkit.craftbukkit.inventory.CraftItemType; import org.bukkit.entity.Piglin; import org.bukkit.inventory.Inventory; diff --git a/patches/server/Restore-vanilla-entity-drops-behavior.patch b/patches/server/Restore-vanilla-entity-drops-behavior.patch index 2f1f3b5c7e..f64df4f3f4 100644 --- a/patches/server/Restore-vanilla-entity-drops-behavior.patch +++ b/patches/server/Restore-vanilla-entity-drops-behavior.patch @@ -184,7 +184,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, List drops, Runnable lootCheck) { + private static java.util.function.Function FROM_FUNCTION = stack -> { + if (stack == null) return null; -+ return new Entity.DefaultDrop(CraftMagicNumbers.getItem(stack.getType()), stack, null); ++ return new Entity.DefaultDrop(CraftItemType.bukkitToMinecraft(stack.getType()), stack, null); + }; + public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, List drops, Runnable lootCheck) { // Paper // Paper end diff --git a/patches/server/Setup-Gradle-project.patch b/patches/server/Setup-Gradle-project.patch index a27bc142ef..9421a57b44 100644 --- a/patches/server/Setup-Gradle-project.patch +++ b/patches/server/Setup-Gradle-project.patch @@ -46,7 +46,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") { + exclude(group = "org.apache.logging.log4j", module = "log4j-api") + } -+ implementation("org.ow2.asm:asm:9.5") ++ implementation("org.ow2.asm:asm-commons:9.5") + implementation("commons-lang:commons-lang:2.6") + runtimeOnly("org.xerial:sqlite-jdbc:3.42.0.1") + runtimeOnly("com.mysql:mysql-connector-j:8.2.0") @@ -244,6 +244,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - 9.5 - compile -
+- +- org.ow2.asm +- asm-commons +- 9.5 +- compile +- - - - com.github.oshi diff --git a/patches/server/Shoulder-Entities-Release-API.patch b/patches/server/Shoulder-Entities-Release-API.patch index bbd31af1de..755ee1c640 100644 --- a/patches/server/Shoulder-Entities-Release-API.patch +++ b/patches/server/Shoulder-Entities-Release-API.patch @@ -63,7 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -0,0 +0,0 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { - this.getHandle().getCooldowns().addCooldown(CraftMagicNumbers.getItem(material), ticks); + this.getHandle().getCooldowns().addCooldown(CraftItemType.bukkitToMinecraft(material), ticks); } + // Paper start diff --git a/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch b/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch index e3c5784d93..f1f0f36990 100644 --- a/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch +++ b/patches/server/Use-TerminalConsoleAppender-for-console-improvements.patch @@ -58,8 +58,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + alsoShade(log4jPlugins.output) + // Paper end 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 + implementation("org.ow2.asm:asm-commons:9.5") + implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files @@ -0,0 +0,0 @@ relocation { } diff --git a/patches/server/fix-item-meta-for-tadpole-buckets.patch b/patches/server/fix-item-meta-for-tadpole-buckets.patch index 160d162f68..5d005cd47f 100644 --- a/patches/server/fix-item-meta-for-tadpole-buckets.patch +++ b/patches/server/fix-item-meta-for-tadpole-buckets.patch @@ -58,11 +58,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void testEntityTagMeta() { + for (final Item item : BuiltInRegistries.ITEM) { + if (item instanceof net.minecraft.world.item.HangingEntityItem || item instanceof net.minecraft.world.item.MobBucketItem) { -+ ItemStack stack = new ItemStack(CraftMagicNumbers.getMaterial(item)); ++ ItemStack stack = new ItemStack(CraftItemType.minecraftToBukkit(item)); + assertTrue(ENTITY_TAG_METAS.contains(stack.getItemMeta().getClass()), "missing entity tag meta handling for " + item); + stack = CraftItemStack.asNewCraftStack(net.minecraft.world.item.Items.STONE); + stack.editMeta(meta -> meta.displayName(net.kyori.adventure.text.Component.text("hello"))); -+ stack.setType(CraftMagicNumbers.getMaterial(item)); ++ stack.setType(CraftItemType.minecraftToBukkit(item)); + assertTrue(ENTITY_TAG_METAS.contains(stack.getItemMeta().getClass()), "missing entity tag meta handling for " + item); + } + } diff --git a/patches/server/force-entity-dismount-during-teleportation.patch b/patches/server/force-entity-dismount-during-teleportation.patch index 7954c7d31b..4ac98f78c8 100644 --- a/patches/server/force-entity-dismount-during-teleportation.patch +++ b/patches/server/force-entity-dismount-during-teleportation.patch @@ -63,11 +63,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Suppress during worldgen if (this.valid) { @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S + } } - // CraftBukkit end - // Spigot start -- org.spigotmc.event.entity.EntityDismountEvent event = new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity()); -+ org.spigotmc.event.entity.EntityDismountEvent event = new org.spigotmc.event.entity.EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity(), !suppressCancellation); // Paper + +- EntityDismountEvent event = new EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity()); ++ EntityDismountEvent event = new EntityDismountEvent(entity.getBukkitEntity(), this.getBukkitEntity(), !suppressCancellation); // Paper // Suppress during worldgen if (this.valid) { Bukkit.getPluginManager().callEvent(event); diff --git a/work/Bukkit b/work/Bukkit index 0c7aedbcea..63c208dd3f 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 0c7aedbceabcf05dde0a483001acd3d957e06c03 +Subproject commit 63c208dd3f16a0874b5e21348c35ce9e5c829d03 diff --git a/work/CraftBukkit b/work/CraftBukkit index 53ebb05e39..771182f70c 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 53ebb05e3951a1a05e4efb8a739d9bf31d21385e +Subproject commit 771182f70cd789f3d220cfef80876845a48ebec5 diff --git a/work/Spigot b/work/Spigot index e7ce55a3b9..864e4acc0d 160000 --- a/work/Spigot +++ b/work/Spigot @@ -1 +1 @@ -Subproject commit e7ce55a3b93404a86c248a3d749e5219adda4ca0 +Subproject commit 864e4acc0db6ad9899f269740823a23d082d18d0