From 3aae52d6f52641402110702392dd6a5f293633a0 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sat, 12 Jun 2021 09:56:13 -0700 Subject: [PATCH] more patches (#5807) --- ...e-PlayerProfile-in-AsyncPreLoginEven.patch | 0 .../Add-ArmorStand-Item-Meta.patch | 0 ...dd-extended-PaperServerListPingEvent.patch | 0 .../Add-setPlayerProfile-API-for-Skulls.patch | 0 .../Fill-Profile-Property-Events.patch | 0 .../Optimize-Hoppers.patch | 0 .../Player.setPlayerProfile-API.patch | 0 ...PlayerAdvancementCriterionGrantEvent.patch | 0 .../Tameable-getOwnerUniqueId-API.patch | 0 ...sted-Ice-from-loading-holding-chunks.patch | 31 ---- ...-get-a-BlockState-without-a-snapshot.patch | 9 -- .../Ability-to-apply-mending-to-XP-API.patch | 7 +- ...e-PlayerProfile-in-AsyncPreLoginEven.patch | 2 +- .../Add-ArmorStand-Item-Meta.patch | 84 +++++----- ...-MinecraftKey-Information-to-Objects.patch | 11 +- .../server/Add-PlayerArmorChangeEvent.patch | 12 -- .../Add-setPlayerProfile-API-for-Skulls.patch | 25 +-- patches/server/AsyncTabCompleteEvent.patch | 2 +- ...le-Explicit-Network-Manager-Flushing.patch | 0 .../Extend-Player-Interact-cancellation.patch | 26 +-- .../Fill-Profile-Property-Events.patch | 0 patches/server/Fix-Old-Sign-Conversion.patch | 2 +- ...nt-extended-PaperServerListPingEvent.patch | 148 ++---------------- .../Improved-Async-Task-Scheduler.patch | 32 ++-- patches/server/MC-Utils.patch | 18 +++ .../Player.setPlayerProfile-API.patch | 39 ++--- ...PlayerAdvancementCriterionGrantEvent.patch | 4 +- .../Tameable-getOwnerUniqueId-API.patch | 6 +- ...r-crits-helps-mitigate-hacked-client.patch | 0 29 files changed, 120 insertions(+), 338 deletions(-) rename patches/{api-unmapped => api}/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch (100%) rename patches/{api-unmapped => api}/Add-ArmorStand-Item-Meta.patch (100%) rename patches/{api-unmapped => api}/Add-extended-PaperServerListPingEvent.patch (100%) rename patches/{api-unmapped => api}/Add-setPlayerProfile-API-for-Skulls.patch (100%) rename patches/{api-unmapped => api}/Fill-Profile-Property-Events.patch (100%) rename patches/{api-unmapped => api}/Optimize-Hoppers.patch (100%) rename patches/{api-unmapped => api}/Player.setPlayerProfile-API.patch (100%) rename patches/{api-unmapped => api}/PlayerAdvancementCriterionGrantEvent.patch (100%) rename patches/{api-unmapped => api}/Tameable-getOwnerUniqueId-API.patch (100%) delete mode 100644 patches/server-remapped/Prevent-Frosted-Ice-from-loading-holding-chunks.patch rename patches/{server-remapped => server}/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch (96%) rename patches/{server-remapped => server}/Add-ArmorStand-Item-Meta.patch (78%) rename patches/{server-remapped => server}/Add-setPlayerProfile-API-for-Skulls.patch (75%) rename patches/{server-remapped => server}/Disable-Explicit-Network-Manager-Flushing.patch (100%) rename patches/{server-remapped => server}/Extend-Player-Interact-cancellation.patch (65%) rename patches/{server-remapped => server}/Fill-Profile-Property-Events.patch (100%) rename patches/{server-remapped => server}/Implement-extended-PaperServerListPingEvent.patch (60%) rename patches/{server-remapped => server}/Improved-Async-Task-Scheduler.patch (92%) rename patches/{server-remapped => server}/Player.setPlayerProfile-API.patch (79%) rename patches/{server-remapped => server}/PlayerAdvancementCriterionGrantEvent.patch (89%) rename patches/{server-remapped => server}/Tameable-getOwnerUniqueId-API.patch (92%) rename patches/{server-remapped => server}/Toggleable-player-crits-helps-mitigate-hacked-client.patch (100%) diff --git a/patches/api-unmapped/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch b/patches/api/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch similarity index 100% rename from patches/api-unmapped/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch rename to patches/api/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch diff --git a/patches/api-unmapped/Add-ArmorStand-Item-Meta.patch b/patches/api/Add-ArmorStand-Item-Meta.patch similarity index 100% rename from patches/api-unmapped/Add-ArmorStand-Item-Meta.patch rename to patches/api/Add-ArmorStand-Item-Meta.patch diff --git a/patches/api-unmapped/Add-extended-PaperServerListPingEvent.patch b/patches/api/Add-extended-PaperServerListPingEvent.patch similarity index 100% rename from patches/api-unmapped/Add-extended-PaperServerListPingEvent.patch rename to patches/api/Add-extended-PaperServerListPingEvent.patch diff --git a/patches/api-unmapped/Add-setPlayerProfile-API-for-Skulls.patch b/patches/api/Add-setPlayerProfile-API-for-Skulls.patch similarity index 100% rename from patches/api-unmapped/Add-setPlayerProfile-API-for-Skulls.patch rename to patches/api/Add-setPlayerProfile-API-for-Skulls.patch diff --git a/patches/api-unmapped/Fill-Profile-Property-Events.patch b/patches/api/Fill-Profile-Property-Events.patch similarity index 100% rename from patches/api-unmapped/Fill-Profile-Property-Events.patch rename to patches/api/Fill-Profile-Property-Events.patch diff --git a/patches/api-unmapped/Optimize-Hoppers.patch b/patches/api/Optimize-Hoppers.patch similarity index 100% rename from patches/api-unmapped/Optimize-Hoppers.patch rename to patches/api/Optimize-Hoppers.patch diff --git a/patches/api-unmapped/Player.setPlayerProfile-API.patch b/patches/api/Player.setPlayerProfile-API.patch similarity index 100% rename from patches/api-unmapped/Player.setPlayerProfile-API.patch rename to patches/api/Player.setPlayerProfile-API.patch diff --git a/patches/api-unmapped/PlayerAdvancementCriterionGrantEvent.patch b/patches/api/PlayerAdvancementCriterionGrantEvent.patch similarity index 100% rename from patches/api-unmapped/PlayerAdvancementCriterionGrantEvent.patch rename to patches/api/PlayerAdvancementCriterionGrantEvent.patch diff --git a/patches/api-unmapped/Tameable-getOwnerUniqueId-API.patch b/patches/api/Tameable-getOwnerUniqueId-API.patch similarity index 100% rename from patches/api-unmapped/Tameable-getOwnerUniqueId-API.patch rename to patches/api/Tameable-getOwnerUniqueId-API.patch diff --git a/patches/server-remapped/Prevent-Frosted-Ice-from-loading-holding-chunks.patch b/patches/server-remapped/Prevent-Frosted-Ice-from-loading-holding-chunks.patch deleted file mode 100644 index 3de51f126d..0000000000 --- a/patches/server-remapped/Prevent-Frosted-Ice-from-loading-holding-chunks.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Aikar -Date: Sat, 10 Mar 2018 16:33:15 -0500 -Subject: [PATCH] Prevent Frosted Ice from loading/holding chunks - - -diff --git a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java -@@ -0,0 +0,0 @@ public class FrostedIceBlock extends IceBlock { - Direction enumdirection = aenumdirection[j]; - - blockposition_mutableblockposition.setWithOffset((Vec3i) pos, enumdirection); -- BlockState iblockdata1 = world.getBlockState(blockposition_mutableblockposition); -+ BlockState iblockdata1 = world.getTypeIfLoaded(blockposition_mutableblockposition); // Paper -+ if (iblockdata1 == null) { continue; } // Paper - - if (iblockdata1.is((Block) this) && !this.slightlyMelt(iblockdata1, (Level) world, blockposition_mutableblockposition)) { - world.getBlockTicks().scheduleTick(blockposition_mutableblockposition, this, Mth.nextInt(random, world.paperConfig.frostedIceDelayMin, world.paperConfig.frostedIceDelayMax)); // Paper - use configurable min/max delay -@@ -0,0 +0,0 @@ public class FrostedIceBlock extends IceBlock { - Direction enumdirection = aenumdirection[l]; - - blockposition_mutableblockposition.setWithOffset((Vec3i) pos, enumdirection); -- if (world.getBlockState(blockposition_mutableblockposition).is((Block) this)) { -+ // Paper start -+ BlockState type = world.getTypeIfLoaded(blockposition_mutableblockposition); -+ if (type != null && type.is((Block) this)) { // Paper end - ++j; - if (j >= maxNeighbors) { - return false; diff --git a/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch b/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch index 643f2ca937..52a62cf0cc 100644 --- a/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch +++ b/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch @@ -16,15 +16,6 @@ diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -0,0 +0,0 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject { - // CraftBukkit end - private static final Logger LOGGER = LogManager.getLogger(); - public boolean isLoadingStructure = false; // Paper -- private final BlockEntityType type; public BlockEntityType getTileEntityType() { return type; } // Paper - OBFHELPER -+ private final BlockEntityType type; - @Nullable - protected Level level; - protected final BlockPos worldPosition; @@ -0,0 +0,0 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject { this.type = type; this.worldPosition = pos.immutable(); diff --git a/patches/server/Ability-to-apply-mending-to-XP-API.patch b/patches/server/Ability-to-apply-mending-to-XP-API.patch index da854181f0..a28e8ae045 100644 --- a/patches/server/Ability-to-apply-mending-to-XP-API.patch +++ b/patches/server/Ability-to-apply-mending-to-XP-API.patch @@ -36,7 +36,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - @Nullable - public static Entry getRandomItemWith(Enchantment enchantment, LivingEntity entity) { -+ public static @javax.annotation.Nonnull ItemStack getRandomEquippedItemWithEnchant(Enchantment enchantment, LivingEntity entityliving) { Entry entry = getRandomItemWith(enchantment, entityliving); return entry != null ? entry.getValue() : ItemStack.NULL_ITEM; } // Paper - OBFHELPER ++ public static @javax.annotation.Nonnull ItemStack getRandomEquippedItemWithEnchant(Enchantment enchantment, LivingEntity entityliving) { ++ Entry entry = getRandomItemWith(enchantment, entityliving); ++ return entry != null ? entry.getValue() : ItemStack.EMPTY; ++ } // Paper - OBFHELPER + @Nullable public static Entry getRandomItemWith(Enchantment enchantment, LivingEntity entity) { return getRandomItemWith(enchantment, entity, (stack) -> { return true; @@ -80,7 +83,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + int i = Math.min(orb.xpToDur(amount), itemstack.getDamageValue()); + org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(handle, orb, itemstack, i); + i = event.getRepairAmount(); -+ orb.removed = true; ++ orb.discard(); + if (!event.isCancelled()) { + amount -= orb.durToXp(i); + itemstack.setDamageValue(itemstack.getDamageValue() - i); diff --git a/patches/server-remapped/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch b/patches/server/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch similarity index 96% rename from patches/server-remapped/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch rename to patches/server/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch index a366562b52..ec80f5732d 100644 --- a/patches/server-remapped/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch +++ b/patches/server/Ability-to-change-PlayerProfile-in-AsyncPreLoginEven.patch @@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import org.bukkit.event.player.AsyncPlayerPreLoginEvent; import org.bukkit.event.player.PlayerPreLoginEvent; @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener - java.util.UUID uniqueId = gameProfile.getId(); + java.util.UUID uniqueId = ServerLoginPacketListenerImpl.this.gameProfile.getId(); final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; - AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId); diff --git a/patches/server-remapped/Add-ArmorStand-Item-Meta.patch b/patches/server/Add-ArmorStand-Item-Meta.patch similarity index 78% rename from patches/server-remapped/Add-ArmorStand-Item-Meta.patch rename to patches/server/Add-ArmorStand-Item-Meta.patch index 1f79a81135..5c99375f83 100644 --- a/patches/server-remapped/Add-ArmorStand-Item-Meta.patch +++ b/patches/server/Add-ArmorStand-Item-Meta.patch @@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class CraftMetaArmorStand extends CraftMetaItem { if (tag.contains(ENTITY_TAG.NBT)) { - entityTag = tag.getCompound(ENTITY_TAG.NBT); + this.entityTag = tag.getCompound(ENTITY_TAG.NBT); + + // Paper start + if (entityTag.contains(INVISIBLE.NBT)) { @@ -85,19 +85,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 CraftMetaArmorStand(Map map) { super(map); -+ + // Paper start -+ boolean invis = SerializableMeta.getBoolean(map, INVISIBLE.BUKKIT); -+ boolean noBase = SerializableMeta.getBoolean(map, NO_BASE_PLATE.BUKKIT); -+ boolean showArms = SerializableMeta.getBoolean(map, SHOW_ARMS.BUKKIT); -+ boolean small = SerializableMeta.getBoolean(map, SMALL.BUKKIT); -+ boolean marker = SerializableMeta.getBoolean(map, MARKER.BUKKIT); -+ -+ this.invisible = invis; -+ this.noBasePlate = noBase; -+ this.showArms = showArms; -+ this.small = small; -+ this.marker = marker; ++ this.invisible = SerializableMeta.getBoolean(map, INVISIBLE.BUKKIT); ++ this.noBasePlate = SerializableMeta.getBoolean(map, NO_BASE_PLATE.BUKKIT); ++ this.showArms = SerializableMeta.getBoolean(map, SHOW_ARMS.BUKKIT); ++ this.small = SerializableMeta.getBoolean(map, SMALL.BUKKIT); ++ this.marker = SerializableMeta.getBoolean(map, MARKER.BUKKIT); + // Paper end } @@ -107,40 +100,39 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 super.applyToItem(tag); + // Paper start -+ if (!isArmorStandEmpty() && entityTag == null) { -+ entityTag = new CompoundTag(); ++ if (!isArmorStandEmpty() && this.entityTag == null) { ++ this.entityTag = new CompoundTag(); + } + + if (isInvisible()) { -+ entityTag.putBoolean(INVISIBLE.NBT, invisible); ++ this.entityTag.putBoolean(INVISIBLE.NBT, this.invisible); + } + + if (hasNoBasePlate()) { -+ entityTag.putBoolean(NO_BASE_PLATE.NBT, noBasePlate); ++ this.entityTag.putBoolean(NO_BASE_PLATE.NBT, this.noBasePlate); + } + + if (shouldShowArms()) { -+ entityTag.putBoolean(SHOW_ARMS.NBT, showArms); ++ this.entityTag.putBoolean(SHOW_ARMS.NBT, this.showArms); + } + + if (isSmall()) { -+ entityTag.putBoolean(SMALL.NBT, small); ++ this.entityTag.putBoolean(SMALL.NBT, this.small); + } + + if (isMarker()) { -+ entityTag.putBoolean(MARKER.NBT, marker); ++ this.entityTag.putBoolean(MARKER.NBT, this.marker); + } + // Paper end -+ - if (entityTag != null) { + if (this.entityTag != null) { tag.put(ENTITY_TAG.NBT, entityTag); } @@ -0,0 +0,0 @@ public class CraftMetaArmorStand extends CraftMetaItem { } boolean isArmorStandEmpty() { -- return !(entityTag != null); -+ return !(isInvisible() || hasNoBasePlate() || shouldShowArms() || isSmall() || isMarker() || entityTag != null); +- return !(this.entityTag != null); ++ return !(this.isInvisible() || this.hasNoBasePlate() || this.shouldShowArms() || this.isSmall() || this.isMarker() || this.entityTag != null); } @Override @@ -148,13 +140,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (meta instanceof CraftMetaArmorStand) { CraftMetaArmorStand that = (CraftMetaArmorStand) meta; -- return entityTag != null ? that.entityTag != null && this.entityTag.equals(that.entityTag) : entityTag == null; +- return this.entityTag != null ? that.entityTag != null && this.entityTag.equals(that.entityTag) : this.entityTag == null; + // Paper start -+ return invisible == that.invisible && -+ noBasePlate == that.noBasePlate && -+ showArms == that.showArms && -+ small == that.small && -+ marker == that.marker; ++ return this.invisible == that.invisible && ++ this.noBasePlate == that.noBasePlate && ++ this.showArms == that.showArms && ++ this.small == that.small && ++ this.marker == that.marker; + // Paper end } return true; @@ -163,16 +155,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 final int original; int hash = original = super.applyHash(); -- if (entityTag != null) { -- hash = 73 * hash + entityTag.hashCode(); +- if (this.entityTag != null) { +- hash = 73 * hash + this.entityTag.hashCode(); - } + // Paper start -+ hash += entityTag != null ? 73 * hash + entityTag.hashCode() : 0; -+ hash += isInvisible() ? 61 * hash + 1231 : 0; -+ hash += hasNoBasePlate() ? 61 * hash + 1231 : 0; -+ hash += shouldShowArms() ? 61 * hash + 1231 : 0; -+ hash += isSmall() ? 61 * hash + 1231 : 0; -+ hash += isMarker() ? 61 * hash + 1231 : 0; ++ hash += this.entityTag != null ? 73 * hash + this.entityTag.hashCode() : 0; ++ hash += this.isInvisible() ? 61 * hash + 1231 : 0; ++ hash += this.hasNoBasePlate() ? 61 * hash + 1231 : 0; ++ hash += this.shouldShowArms() ? 61 * hash + 1231 : 0; ++ hash += this.isSmall() ? 61 * hash + 1231 : 0; ++ hash += this.isMarker() ? 61 * hash + 1231 : 0; + // Paper end return original != hash ? CraftMetaArmorStand.class.hashCode() ^ hash : hash; @@ -182,23 +174,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 super.serialize(builder); + // Paper start -+ if (isInvisible()) { ++ if (this.isInvisible()) { + builder.put(INVISIBLE.BUKKIT, invisible); + } + -+ if (hasNoBasePlate()) { ++ if (this.hasNoBasePlate()) { + builder.put(NO_BASE_PLATE.BUKKIT, noBasePlate); + } + -+ if (shouldShowArms()) { ++ if (this.shouldShowArms()) { + builder.put(SHOW_ARMS.BUKKIT, showArms); + } + -+ if (isSmall()) { ++ if (this.isSmall()) { + builder.put(SMALL.BUKKIT, small); + } + -+ if (isMarker()) { ++ if (this.isMarker()) { + builder.put(MARKER.BUKKIT, marker); + } + // Paper end @@ -281,15 +273,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end CraftMetaCompass.LODESTONE_DIMENSION.NBT, CraftMetaCompass.LODESTONE_POS.NBT, - CraftMetaCompass.LODESTONE_TRACKED.NBT + CraftMetaCompass.LODESTONE_TRACKED.NBT, diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java @@ -0,0 +0,0 @@ public class ItemMetaTest extends AbstractTestingBase { final CraftMetaArmorStand meta = (CraftMetaArmorStand) cleanStack.getItemMeta(); - meta.entityTag = new NBTTagCompound(); - meta.entityTag.setBoolean("Small", true); + meta.entityTag = new CompoundTag(); + meta.entityTag.putBoolean("Small", true); + meta.setInvisible(true); // Paper cleanStack.setItemMeta(meta); return cleanStack; diff --git a/patches/server/Add-MinecraftKey-Information-to-Objects.patch b/patches/server/Add-MinecraftKey-Information-to-Objects.patch index 489a50d49e..9f6623aeb2 100644 --- a/patches/server/Add-MinecraftKey-Information-to-Objects.patch +++ b/patches/server/Add-MinecraftKey-Information-to-Objects.patch @@ -107,15 +107,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot // CraftBukkit start - data containers -@@ -0,0 +0,0 @@ public abstract class BlockEntity { - public CraftPersistentDataContainer persistentDataContainer; - // CraftBukkit end - private static final Logger LOGGER = LogManager.getLogger(); -- private final BlockEntityType type; -+ private final BlockEntityType type; public BlockEntityType getTileEntityType() { return type; } // Paper - OBFHELPER - @Nullable - protected Level level; - protected final BlockPos worldPosition; @@ -0,0 +0,0 @@ public abstract class BlockEntity { this.blockState = state; } @@ -127,7 +118,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public ResourceLocation getMinecraftKey() { + if (tileEntityKey == null) { -+ tileEntityKey = BlockEntityType.getKey(this.getTileEntityType()); ++ tileEntityKey = BlockEntityType.getKey(this.type); + tileEntityKeyString = tileEntityKey != null ? tileEntityKey.toString() : null; + } + return tileEntityKey; diff --git a/patches/server/Add-PlayerArmorChangeEvent.patch b/patches/server/Add-PlayerArmorChangeEvent.patch index a1b36c7ae6..c8ce4adc8d 100644 --- a/patches/server/Add-PlayerArmorChangeEvent.patch +++ b/patches/server/Add-PlayerArmorChangeEvent.patch @@ -4,18 +4,6 @@ Date: Fri, 10 Nov 2017 23:46:34 -0500 Subject: [PATCH] Add PlayerArmorChangeEvent -diff --git a/src/main/java/net/minecraft/world/entity/EquipmentSlot.java b/src/main/java/net/minecraft/world/entity/EquipmentSlot.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/EquipmentSlot.java -+++ b/src/main/java/net/minecraft/world/entity/EquipmentSlot.java -@@ -0,0 +0,0 @@ public enum EquipmentSlot { - this.name = name; - } - -+ public EquipmentSlot.Type getType() { return this.getType(); } // Paper - OBFHELPER - public EquipmentSlot.Type getType() { - return this.type; - } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/patches/server-remapped/Add-setPlayerProfile-API-for-Skulls.patch b/patches/server/Add-setPlayerProfile-API-for-Skulls.patch similarity index 75% rename from patches/server-remapped/Add-setPlayerProfile-API-for-Skulls.patch rename to patches/server/Add-setPlayerProfile-API-for-Skulls.patch index 8e18775bb3..f0fbc0242a 100644 --- a/patches/server-remapped/Add-setPlayerProfile-API-for-Skulls.patch +++ b/patches/server/Add-setPlayerProfile-API-for-Skulls.patch @@ -18,14 +18,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import com.google.common.base.Preconditions; import com.mojang.authlib.GameProfile; import net.minecraft.server.MinecraftServer; -@@ -0,0 +0,0 @@ import org.bukkit.block.data.BlockData; - import org.bukkit.block.data.Directional; - import org.bukkit.block.data.Rotatable; - import org.bukkit.craftbukkit.entity.CraftPlayer; -+import javax.annotation.Nullable; - - public class CraftSkull extends CraftBlockEntityState implements Skull { - @@ -0,0 +0,0 @@ public class CraftSkull extends CraftBlockEntityState implemen } } @@ -37,7 +29,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.profile = CraftPlayerProfile.asAuthlibCopy(profile); + } + -+ @Nullable ++ @javax.annotation.Nullable + @Override + public PlayerProfile getPlayerProfile() { + return profile != null ? CraftPlayerProfile.asBukkitCopy(profile) : null; @@ -77,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 class CraftMetaSkull extends CraftMetaItem implements SkullMeta { @@ -0,0 +0,0 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { - return hasOwner() ? profile.getName() : null; + return this.hasOwner() ? this.profile.getName() : null; } + // Paper start @@ -95,15 +87,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override public OfflinePlayer getOwningPlayer() { - if (hasOwner()) { -@@ -0,0 +0,0 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta { - } else { - // Paper start - Use Online Players Skull - GameProfile newProfile = null; -- net.minecraft.server.EntityPlayer player = net.minecraft.server.MinecraftServer.getServer().getPlayerList().getPlayerByName(name); -- if (player != null) newProfile = player.getProfile(); -+ net.minecraft.server.level.ServerPlayer player = net.minecraft.server.MinecraftServer.getServer().getPlayerList().getPlayerByName(name); -+ if (player != null) newProfile = player.getGameProfile(); - if (newProfile == null) newProfile = new GameProfile(null, name); - setProfile(newProfile); - // Paper end + if (this.hasOwner()) { diff --git a/patches/server/AsyncTabCompleteEvent.patch b/patches/server/AsyncTabCompleteEvent.patch index ffd98a8862..d6f8071a7c 100644 --- a/patches/server/AsyncTabCompleteEvent.patch +++ b/patches/server/AsyncTabCompleteEvent.patch @@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + com.destroystokyo.paper.event.server.AsyncTabCompleteEvent event; + java.util.List completions = new java.util.ArrayList<>(); + String buffer = packet.getCommand(); -+ event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getPlayer(), completions, ++ event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getCraftPlayer(), completions, + buffer, true, null); + event.callEvent(); + completions = event.isCancelled() ? com.google.common.collect.ImmutableList.of() : event.getCompletions(); diff --git a/patches/server-remapped/Disable-Explicit-Network-Manager-Flushing.patch b/patches/server/Disable-Explicit-Network-Manager-Flushing.patch similarity index 100% rename from patches/server-remapped/Disable-Explicit-Network-Manager-Flushing.patch rename to patches/server/Disable-Explicit-Network-Manager-Flushing.patch diff --git a/patches/server-remapped/Extend-Player-Interact-cancellation.patch b/patches/server/Extend-Player-Interact-cancellation.patch similarity index 65% rename from patches/server-remapped/Extend-Player-Interact-cancellation.patch rename to patches/server/Extend-Player-Interact-cancellation.patch index a7375df31e..87ca42f446 100644 --- a/patches/server-remapped/Extend-Player-Interact-cancellation.patch +++ b/patches/server/Extend-Player-Interact-cancellation.patch @@ -16,16 +16,8 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -0,0 +0,0 @@ import net.minecraft.core.BlockPos; - import net.minecraft.core.Direction; - import net.minecraft.network.protocol.game.ClientboundBlockBreakAckPacket; - import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; -+import net.minecraft.network.protocol.game.ClientboundContainerClosePacket; - import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket; - import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; - import net.minecraft.server.MinecraftServer; @@ -0,0 +0,0 @@ public class ServerPlayerGameMode { - PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, pos, direction, this.player.inventory.getSelected(), InteractionHand.MAIN_HAND); + PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, pos, direction, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); if (event.isCancelled()) { // Let the client know the block still exists + // Paper start - brute force neighbor blocks for any attached blocks @@ -37,22 +29,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Update any tile entity data for this block BlockEntity tileentity = this.level.getBlockEntity(pos); @@ -0,0 +0,0 @@ public class ServerPlayerGameMode { - interactItemStack = stack.copy(); - - if (event.useInteractedBlock() == Event.Result.DENY) { -+ - // If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door. - if (iblockdata.getBlock() instanceof DoorBlock) { - boolean bottom = iblockdata.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER; -@@ -0,0 +0,0 @@ public class ServerPlayerGameMode { // send a correcting update to the client for the block above as well, this because of replaceable blocks (such as grass, sea grass etc) player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above())); + // Paper start - extend Player Interact cancellation // TODO: consider merging this into the extracted method -+ } else if (iblockdata.getBlock() instanceof StructureBlock) { -+ player.connection.send(new ClientboundContainerClosePacket()); -+ } else if (iblockdata.getBlock() instanceof CommandBlock) { -+ player.connection.send(new ClientboundContainerClosePacket()); ++ } else if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.StructureBlock) { ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerClosePacket(this.player.containerMenu.containerId)); ++ } else if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.CommandBlock) { ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerClosePacket(this.player.containerMenu.containerId)); } + // Paper end - extend Player Interact cancellation player.getBukkitEntity().updateInventory(); // SPIGOT-2867 diff --git a/patches/server-remapped/Fill-Profile-Property-Events.patch b/patches/server/Fill-Profile-Property-Events.patch similarity index 100% rename from patches/server-remapped/Fill-Profile-Property-Events.patch rename to patches/server/Fill-Profile-Property-Events.patch diff --git a/patches/server/Fix-Old-Sign-Conversion.patch b/patches/server/Fix-Old-Sign-Conversion.patch index 6e699bf64f..522623fbbe 100644 --- a/patches/server/Fix-Old-Sign-Conversion.patch +++ b/patches/server/Fix-Old-Sign-Conversion.patch @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit end private static final Logger LOGGER = LogManager.getLogger(); + public boolean isLoadingStructure = false; // Paper - private final BlockEntityType type; public BlockEntityType getTileEntityType() { return type; } // Paper - OBFHELPER + private final BlockEntityType type; @Nullable protected Level level; diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java diff --git a/patches/server-remapped/Implement-extended-PaperServerListPingEvent.patch b/patches/server/Implement-extended-PaperServerListPingEvent.patch similarity index 60% rename from patches/server-remapped/Implement-extended-PaperServerListPingEvent.patch rename to patches/server/Implement-extended-PaperServerListPingEvent.patch index a9edf179a3..186357a88a 100644 --- a/patches/server-remapped/Implement-extended-PaperServerListPingEvent.patch +++ b/patches/server/Implement-extended-PaperServerListPingEvent.patch @@ -178,50 +178,17 @@ diff --git a/src/main/java/net/minecraft/network/protocol/status/ClientboundStat index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java +++ b/src/main/java/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java -@@ -0,0 +0,0 @@ package net.minecraft.network.protocol.status; - - import com.google.gson.Gson; - import com.google.gson.GsonBuilder; -+import io.papermc.paper.adventure.AdventureComponent; // Paper - import java.io.IOException; - import net.minecraft.network.FriendlyByteBuf; - import net.minecraft.network.chat.Component; -@@ -0,0 +0,0 @@ import net.minecraft.util.LowerCaseEnumTypeAdapterFactory; +@@ -0,0 +0,0 @@ import net.minecraft.util.GsonHelper; + import net.minecraft.util.LowerCaseEnumTypeAdapterFactory; public class ClientboundStatusResponsePacket implements Packet { - - private static final Gson GSON = (new GsonBuilder()).registerTypeAdapter(ServerStatus.Version.class, new ServerStatus.Version.Serializer()).registerTypeAdapter(ServerStatus.Players.class, new ServerStatus.Players.Serializer()).registerTypeAdapter(ServerStatus.class, new ServerStatus.Serializer()).registerTypeHierarchyAdapter(Component.class, new Component.Serializer()).registerTypeHierarchyAdapter(Style.class, new Style.Serializer()).registerTypeAdapterFactory(new LowerCaseEnumTypeAdapterFactory()).create(); + private static final Gson GSON = (new GsonBuilder()).registerTypeAdapter(ServerStatus.Version.class, new ServerStatus.Version.Serializer()).registerTypeAdapter(ServerStatus.Players.class, new ServerStatus.Players.Serializer()).registerTypeAdapter(ServerStatus.class, new ServerStatus.Serializer()).registerTypeHierarchyAdapter(Component.class, new Component.Serializer()).registerTypeHierarchyAdapter(Style.class, new Style.Serializer()).registerTypeAdapterFactory(new LowerCaseEnumTypeAdapterFactory()) -+ .registerTypeAdapter(AdventureComponent.class, new AdventureComponent.Serializer()) ++ .registerTypeAdapter(io.papermc.paper.adventure.AdventureComponent.class, new io.papermc.paper.adventure.AdventureComponent.Serializer()) + .create(); - private ServerStatus status; + private final ServerStatus status; - public ClientboundStatusResponsePacket() {} -diff --git a/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java b/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java -+++ b/src/main/java/net/minecraft/network/protocol/status/ServerStatus.java -@@ -0,0 +0,0 @@ public class ServerStatus { - this.description = description; - } - -+ public Players getPlayers() { return getPlayers(); } // Paper - OBFHELPER - public ServerStatus.Players getPlayers() { - return this.players; - } -@@ -0,0 +0,0 @@ public class ServerStatus { - return this.numPlayers; - } - -+ public GameProfile[] getSample() { return getSample(); } // Paper - OBFHELPER - public GameProfile[] getSample() { - return this.sample; - } - -+ public void setSample(GameProfile[] sample) { setSample(sample); } // Paper - OBFHELPER - public void setSample(GameProfile[] sample) { - this.sample = sample; - } + public ClientboundStatusResponsePacket(ServerStatus metadata) { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java @@ -249,24 +216,6 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerStatusPacketListen index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java -@@ -0,0 +0,0 @@ - package net.minecraft.server.network; - - import net.minecraft.server.MinecraftServer; --import net.minecraft.server.level.ServerPlayer; -+ - // CraftBukkit start - import com.mojang.authlib.GameProfile; - import java.net.InetSocketAddress; -@@ -0,0 +0,0 @@ import net.minecraft.network.Connection; - import net.minecraft.network.chat.Component; - import net.minecraft.network.chat.TranslatableComponent; - import net.minecraft.network.protocol.status.ClientboundPongResponsePacket; --import net.minecraft.network.protocol.status.ClientboundStatusResponsePacket; --import net.minecraft.network.protocol.status.ServerStatus; - import net.minecraft.network.protocol.status.ServerStatusPacketListener; - import net.minecraft.network.protocol.status.ServerboundPingRequestPacket; - import net.minecraft.network.protocol.status.ServerboundStatusRequestPacket; @@ -0,0 +0,0 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene this.connection.disconnect(ServerStatusPacketListenerImpl.DISCONNECT_REASON); } else { @@ -275,88 +224,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /* // CraftBukkit start // this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing())); -- final Object[] players = server.getPlayerList().players.toArray(); -+ final Object[] players = minecraftServer.getPlayerList().players.toArray(); - class ServerListPingEvent extends org.bukkit.event.server.ServerListPingEvent { - -- CraftIconCache icon = server.server.getServerIcon(); -+ CraftIconCache icon = minecraftServer.server.getServerIcon(); - - ServerListPingEvent() { -- super(((InetSocketAddress) connection.getRemoteAddress()).getAddress(), server.server.motd(), server.getPlayerList().getMaxPlayers()); // Paper - Adventure -+ super(((InetSocketAddress) networkManager.getSocketAddress()).getAddress(), minecraftServer.server.motd(), minecraftServer.getPlayerList().getMaxPlayers()); // Paper - Adventure - } - - @Override + final Object[] players = this.server.getPlayerList().players.toArray(); @@ -0,0 +0,0 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene - return new Iterator() { - int i; - int ret = Integer.MIN_VALUE; -- ServerPlayer player; -+ EntityPlayer player; + ping.setVersion(new ServerStatus.Version(this.server.getServerModName() + " " + this.server.getServerVersion(), version)); - @Override - public boolean hasNext() { -@@ -0,0 +0,0 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene - } - final Object[] currentPlayers = players; - for (int length = currentPlayers.length, i = this.i; i < length; i++) { -- final ServerPlayer player = (ServerPlayer) currentPlayers[i]; -+ final EntityPlayer player = (EntityPlayer) currentPlayers[i]; - if (player != null) { - this.i = i + 1; - this.player = player; -@@ -0,0 +0,0 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene - if (!hasNext()) { - throw new java.util.NoSuchElementException(); - } -- final ServerPlayer player = this.player; -+ final EntityPlayer player = this.player; - this.player = null; - this.ret = this.i - 1; - return player.getBukkitEntity(); -@@ -0,0 +0,0 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene - } - - ServerListPingEvent event = new ServerListPingEvent(); -- this.server.server.getPluginManager().callEvent(event); -+ this.minecraftServer.server.getPluginManager().callEvent(event); - - java.util.List profiles = new java.util.ArrayList(players.length); - for (Object player : players) { - if (player != null) { -- profiles.add(((ServerPlayer) player).getGameProfile()); -+ profiles.add(((EntityPlayer) player).getProfile()); - } - } - -- ServerStatus.Players playerSample = new ServerStatus.Players(event.getMaxPlayers(), profiles.size()); -+ ServerPing.ServerPingPlayerSample playerSample = new ServerPing.ServerPingPlayerSample(event.getMaxPlayers(), profiles.size()); - // Spigot Start - if ( !profiles.isEmpty() ) - { -@@ -0,0 +0,0 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene - profiles = profiles.subList( 0, Math.min( profiles.size(), org.spigotmc.SpigotConfig.playerSample ) ); // Cap the sample to n (or less) displayed players, ie: Vanilla behaviour - } - // Spigot End -- playerSample.setSample(profiles.toArray(new GameProfile[profiles.size()])); -+ playerSample.a(profiles.toArray(new GameProfile[profiles.size()])); - -- ServerStatus ping = new ServerStatus(); -+ ServerPing ping = new ServerPing(); - ping.setFavicon(event.icon.value); -- ping.setDescription(CraftChatMessage.fromString(event.getMotd(), true)[0]); -- ping.setPlayers(playerSample); -- int version = SharedConstants.getCurrentVersion().getProtocolVersion(); -- ping.setVersion(new ServerStatus.Version(server.getServerModName() + " " + server.getServerVersion(), version)); -- -- this.connection.send(new ClientboundStatusResponsePacket(ping)); -+ ping.setMOTD(CraftChatMessage.fromString(event.getMotd(), true)[0]); -+ ping.setPlayerSample(playerSample); -+ int version = SharedConstants.getGameVersion().getProtocolVersion(); -+ ping.setServerInfo(new ServerPing.ServerData(minecraftServer.getServerModName() + " " + minecraftServer.getVersion(), version)); -+ -+ this.networkManager.sendPacket(new PacketStatusOutServerInfo(ping)); + this.connection.send(new ClientboundStatusResponsePacket(ping)); + */ + com.destroystokyo.paper.network.StandardPaperServerListPingEventImpl.processRequest(this.server, this.connection); + // Paper end @@ -371,8 +243,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static int playerSample; private static void playerSample() { -- playerSample = getInt( "settings.sample-count", 12 ); -+ playerSample = Math.max( getInt( "settings.sample-count", 12 ), 0 ); // Paper - Avoid negative counts +- SpigotConfig.playerSample = SpigotConfig.getInt( "settings.sample-count", 12 ); ++ SpigotConfig.playerSample = Math.max( SpigotConfig.getInt( "settings.sample-count", 12 ), 0 ); // Paper - Avoid negative counts Bukkit.getLogger().log( Level.INFO, "Server Ping Player Sample Count: {0}", playerSample ); // Paper - Use logger } diff --git a/patches/server-remapped/Improved-Async-Task-Scheduler.patch b/patches/server/Improved-Async-Task-Scheduler.patch similarity index 92% rename from patches/server-remapped/Improved-Async-Task-Scheduler.patch rename to patches/server/Improved-Async-Task-Scheduler.patch index b05b55f2ee..2abe157c16 100644 --- a/patches/server-remapped/Improved-Async-Task-Scheduler.patch +++ b/patches/server/Improved-Async-Task-Scheduler.patch @@ -190,7 +190,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class CraftScheduler implements BukkitScheduler { } }; - private CraftAsyncDebugger debugTail = debugHead; + private CraftAsyncDebugger debugTail = this.debugHead; + + */ // Paper end private static final int RECENT_TICKS; @@ -223,8 +223,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } else if (period < CraftTask.NO_REPEATING) { period = CraftTask.NO_REPEATING; } -- return handle(new CraftAsyncTask(runners, plugin, runnable, nextId(), period), delay); -+ return handle(new CraftAsyncTask(this.asyncScheduler.runners, plugin, runnable, nextId(), period), delay); // Paper +- return this.handle(new CraftAsyncTask(this.runners, plugin, runnable, this.nextId(), period), delay); ++ return this.handle(new CraftAsyncTask(this.asyncScheduler.runners, plugin, runnable, this.nextId(), period), delay); // Paper } @Override @@ -237,7 +237,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + this.asyncScheduler.cancelTask(taskId); + } + // Paper end - CraftTask task = runners.get(taskId); + CraftTask task = this.runners.get(taskId); if (task != null) { task.cancel0(); @@ -0,0 +0,0 @@ public class CraftScheduler implements BukkitScheduler { @@ -257,13 +257,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public boolean isCurrentlyRunning(final int taskId) { + // Paper start -+ if (!isAsyncScheduler) { ++ if (!this.isAsyncScheduler) { + if (this.asyncScheduler.isCurrentlyRunning(taskId)) { + return true; + } + } + // Paper end - final CraftTask task = runners.get(taskId); + final CraftTask task = this.runners.get(taskId); if (task == null) { return false; @@ -0,0 +0,0 @@ public class CraftScheduler implements BukkitScheduler { @@ -275,7 +275,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return true; + } + // Paper end - for (CraftTask task = head.getNext(); task != null; task = task.getNext()) { + for (CraftTask task = this.head.getNext(); task != null; task = task.getNext()) { if (task.getTaskId() == taskId) { return task.getPeriod() >= CraftTask.NO_REPEATING; // The task will run @@ -0,0 +0,0 @@ public class CraftScheduler implements BukkitScheduler { @@ -289,7 +289,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end final ArrayList workers = new ArrayList(); - for (final CraftTask taskObj : runners.values()) { + for (final CraftTask taskObj : this.runners.values()) { // Iterator will be a best-effort (may fail to grab very new values) if called from an async thread @@ -0,0 +0,0 @@ public class CraftScheduler implements BukkitScheduler { pending.add(task); @@ -314,18 +314,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end this.currentTick = currentTick; final List temp = this.temp; - parsePending(); + this.parsePending(); @@ -0,0 +0,0 @@ public class CraftScheduler implements BukkitScheduler { - parsePending(); + this.parsePending(); } else { - //debugTail = debugTail.setNext(new CraftAsyncDebugger(currentTick + RECENT_TICKS, task.getOwner(), task.getTaskClass())); // Paper -- executor.execute(new ServerSchedulerReportingWrapper(task)); // Paper + //this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass())); // Paper +- this.executor.execute(new ServerSchedulerReportingWrapper(task)); // Paper + task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Paper"); // Paper // We don't need to parse pending // (async tasks must live with race-conditions if they attempt to cancel between these few lines of code) } @@ -0,0 +0,0 @@ public class CraftScheduler implements BukkitScheduler { - //debugHead = debugHead.getNextHead(currentTick); // Paper + //this.debugHead = this.debugHead.getNextHead(currentTick); // Paper } - private void addTask(final CraftTask task) { @@ -345,11 +345,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return task; + } + // Paper end - task.setNextRun(currentTick + delay); - addTask(task); + task.setNextRun(this.currentTick + delay); + this.addTask(task); return task; @@ -0,0 +0,0 @@ public class CraftScheduler implements BukkitScheduler { - return ids.incrementAndGet(); + return this.ids.incrementAndGet(); } - private void parsePending() { diff --git a/patches/server/MC-Utils.patch b/patches/server/MC-Utils.patch index 0becc49e8b..c4561bf821 100644 --- a/patches/server/MC-Utils.patch +++ b/patches/server/MC-Utils.patch @@ -3518,6 +3518,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public long[] getRaw() { return this.data; } +diff --git a/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java b/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java ++++ b/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java +@@ -0,0 +0,0 @@ public abstract class BlockableEventLoop implements Profiler + } + + } ++ // Paper start ++ public void scheduleOnMain(Runnable r0) { ++ // postToMainThread does not work the same as older versions of mc ++ // This method is actually used to create a TickTask, which can then be posted onto main ++ this.tell(this.wrapRunnable(r0)); ++ } ++ // Paper end + + @Override + public void tell(R runnable) { diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java diff --git a/patches/server-remapped/Player.setPlayerProfile-API.patch b/patches/server/Player.setPlayerProfile-API.patch similarity index 79% rename from patches/server-remapped/Player.setPlayerProfile-API.patch rename to patches/server/Player.setPlayerProfile-API.patch index 3bd7b9e114..1e431d6fcf 100644 --- a/patches/server-remapped/Player.setPlayerProfile-API.patch +++ b/patches/server/Player.setPlayerProfile-API.patch @@ -9,28 +9,19 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListene index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- 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 final Connection connection; - private ServerLoginPacketListenerImpl.State state; - private int tick; -- private GameProfile gameProfile; -+ private GameProfile gameProfile; private void setGameProfile(final GameProfile profile) { this.gameProfile = profile; } private GameProfile getGameProfile() { return this.gameProfile; } // Paper - OBFHELPER - private final String serverId; - private SecretKey secretKey; - private ServerPlayer delayedAcceptPlayer; @@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener final org.bukkit.craftbukkit.CraftServer server = ServerLoginPacketListenerImpl.this.server.server; // Paper start - PlayerProfile profile = Bukkit.createProfile(uniqueId, playerName); -+ PlayerProfile profile = CraftPlayerProfile.asBukkitMirror(getGameProfile()); ++ PlayerProfile profile = CraftPlayerProfile.asBukkitMirror(ServerLoginPacketListenerImpl.this.gameProfile); AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile); server.getPluginManager().callEvent(asyncEvent); profile = asyncEvent.getPlayerProfile(); - profile.complete(); - gameProfile = CraftPlayerProfile.asAuthlibCopy(profile); + profile.complete(true); -+ setGameProfile(CraftPlayerProfile.asAuthlib(profile)); ++ ServerLoginPacketListenerImpl.this.gameProfile = CraftPlayerProfile.asAuthlib(profile); playerName = gameProfile.getName(); uniqueId = gameProfile.getId(); // Paper end @@ -43,24 +34,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 protected final float defaultFlySpeed = 0.02F; private int lastLevelUpTime; - private final GameProfile gameProfile; -+ private GameProfile gameProfile; public final void setProfile(final GameProfile profile) { this.gameProfile = profile; } // Paper - OBFHELPER ++ public GameProfile gameProfile; // Paper - private->public + private boolean reducedDebugInfo; private ItemStack lastItemInMainHand; private final ItemCooldowns cooldowns; - @Nullable diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -0,0 +0,0 @@ import net.minecraft.world.inventory.AbstractContainerMenu; - import net.minecraft.world.item.enchantment.EnchantmentHelper; +@@ -0,0 +0,0 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.GameType; + import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.block.entity.SignBlockEntity; import net.minecraft.world.level.saveddata.maps.MapDecoration; - import net.minecraft.world.phys.Vec3; + import net.minecraft.world.level.saveddata.maps.MapItemSavedData; @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - hiddenPlayers.put(player.getUniqueId(), hidingPlugins); + this.hiddenPlayers.put(player.getUniqueId(), hidingPlugins); // Remove this player from the hidden player's EntityTrackerEntry - ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap; @@ -73,10 +64,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end ChunkMap.TrackedEntity entry = tracker.entityMap.get(other.getId()); if (entry != null) { - entry.removePlayer(getHandle()); + entry.removePlayer(this.getHandle()); @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } - hiddenPlayers.remove(player.getUniqueId()); + this.hiddenPlayers.remove(player.getUniqueId()); - ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap; + // Paper start @@ -87,10 +78,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap; + // Paper end - getHandle().connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, other)); + this.getHandle().connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, other)); @@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - entry.updatePlayer(getHandle()); + entry.updatePlayer(this.getHandle()); } } + // Paper start @@ -102,7 +93,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + public void setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile profile) { + ServerPlayer self = getHandle(); -+ self.setProfile(com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile)); ++ self.gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile); + if (!self.sentListPacket) { + return; + } @@ -128,7 +119,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + ServerLevel worldserver = handle.getLevel(); + connection.send(new net.minecraft.network.protocol.game.ClientboundRespawnPacket(worldserver.dimensionType(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), handle.gameMode.getGameModeForPlayer(), handle.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true)); + handle.onUpdateAbilities(); -+ connection.send(new net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), new HashSet<>(), 0)); ++ connection.send(new net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), java.util.Collections.emptySet(), 0, false)); + net.minecraft.server.MinecraftServer.getServer().getPlayerList().sendAllPlayerInfo(handle); + + if (this.isOp()) { @@ -139,4 +130,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper end public void removeDisconnectingPlayer(Player player) { - hiddenPlayers.remove(player.getUniqueId()); + this.hiddenPlayers.remove(player.getUniqueId()); diff --git a/patches/server-remapped/PlayerAdvancementCriterionGrantEvent.patch b/patches/server/PlayerAdvancementCriterionGrantEvent.patch similarity index 89% rename from patches/server-remapped/PlayerAdvancementCriterionGrantEvent.patch rename to patches/server/PlayerAdvancementCriterionGrantEvent.patch index 01830fc67b..d9eebfe3e0 100644 --- a/patches/server-remapped/PlayerAdvancementCriterionGrantEvent.patch +++ b/patches/server/PlayerAdvancementCriterionGrantEvent.patch @@ -11,10 +11,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class PlayerAdvancements { boolean flag1 = advancementprogress.isDone(); - if (advancementprogress.a(criterionName)) { + if (advancementprogress.grantProgress(criterionName)) { + // Paper start + if (!new com.destroystokyo.paper.event.player.PlayerAdvancementCriterionGrantEvent(this.player.getBukkitEntity(), advancement.bukkit, criterionName).callEvent()) { -+ advancementprogress.b(criterionName); ++ advancementprogress.revokeProgress(criterionName); + return false; + } + // Paper end diff --git a/patches/server-remapped/Tameable-getOwnerUniqueId-API.patch b/patches/server/Tameable-getOwnerUniqueId-API.patch similarity index 92% rename from patches/server-remapped/Tameable-getOwnerUniqueId-API.patch rename to patches/server/Tameable-getOwnerUniqueId-API.patch index d44c4df9d5..012589c671 100644 --- a/patches/server-remapped/Tameable-getOwnerUniqueId-API.patch +++ b/patches/server/Tameable-getOwnerUniqueId-API.patch @@ -14,11 +14,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } } ++ @Override + public UUID getOwnerUniqueId() { + return getOwnerUUID(); + } public UUID getOwnerUUID() { - return getHandle().getOwnerUUID(); + return this.getHandle().getOwnerUUID(); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -28,9 +29,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return (TamableAnimal) super.getHandle(); } ++ @Override + public UUID getOwnerUniqueId() { + return getOwnerUUID(); + } public UUID getOwnerUUID() { try { - return getHandle().getOwnerUUID(); + return this.getHandle().getOwnerUUID(); diff --git a/patches/server-remapped/Toggleable-player-crits-helps-mitigate-hacked-client.patch b/patches/server/Toggleable-player-crits-helps-mitigate-hacked-client.patch similarity index 100% rename from patches/server-remapped/Toggleable-player-crits-helps-mitigate-hacked-client.patch rename to patches/server/Toggleable-player-crits-helps-mitigate-hacked-client.patch