more patches (#5807)
This commit is contained in:
parent
79da8f0eca
commit
2397b86efa
29 changed files with 178 additions and 364 deletions
|
@ -3518,6 +3518,24 @@ index 65bd706ca96f5c0ec4573da9fb144fb51d2de919..3a2e8bdc215a6af604bfaad01b670a36
|
|||
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 08fb847add9f5a2c1ca6dfef31de7e711c8b9840..5b38966093fe60b298844961d015d5a9f03412a2 100644
|
||||
--- a/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java
|
||||
+++ b/src/main/java/net/minecraft/util/thread/BlockableEventLoop.java
|
||||
@@ -78,6 +78,13 @@ public abstract class BlockableEventLoop<R extends Runnable> 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 7f3d83d3d071f6b441ad119b1c93be035e911e70..89e7d02b88404ac5dce06595432ae95c9a4e5015 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||
|
|
|
@ -95,7 +95,7 @@ index 89e7d02b88404ac5dce06595432ae95c9a4e5015..3ffaeb72be8cda7a2b9398b8909db5c2
|
|||
return this.serialize;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
||||
index 33884161de688c47c90a7b86196234acc80f9434..e4601134598e509a158ceacec6099a78bbabe89d 100644
|
||||
index 33884161de688c47c90a7b86196234acc80f9434..92b042080f06fb95958ff5e824830a84f2d1f2a6 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
|
||||
@@ -20,7 +20,7 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
|
@ -107,15 +107,6 @@ index 33884161de688c47c90a7b86196234acc80f9434..e4601134598e509a158ceacec6099a78
|
|||
|
||||
public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getTileEntityTimings(this); // Spigot
|
||||
// CraftBukkit start - data containers
|
||||
@@ -28,7 +28,7 @@ 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;
|
||||
@@ -41,6 +41,26 @@ public abstract class BlockEntity {
|
||||
this.blockState = state;
|
||||
}
|
||||
|
@ -127,7 +118,7 @@ index 33884161de688c47c90a7b86196234acc80f9434..e4601134598e509a158ceacec6099a78
|
|||
+ @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;
|
||||
|
|
|
@ -9,7 +9,7 @@ Subject: [PATCH] Fix Old Sign Conversion
|
|||
This causes Igloos and such to render broken signs. We fix this by ignoring sign conversion for Defined Structures
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
||||
index d6a4a2a59f1be0cc2e373dc326287b60db5559d2..9d777fce673c8f6b3ee2d69f5a6360a8a5ad8e84 100644
|
||||
index 66ab4deedd177f507d170a61ceca4c3ebbac9adc..77645019c88d61dde28b7598d8a29b7d0c23c209 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
|
||||
@@ -30,6 +30,7 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject {
|
||||
|
@ -17,7 +17,7 @@ index d6a4a2a59f1be0cc2e373dc326287b60db5559d2..9d777fce673c8f6b3ee2d69f5a6360a8
|
|||
// 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
|
||||
|
|
|
@ -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 c82bb38b5b1c9204daef21455723d21509ad1c44..135a62fcdbd801c9997bc28c071743e8ff8c64c2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EquipmentSlot.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/EquipmentSlot.java
|
||||
@@ -20,6 +20,7 @@ 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 89913edf98d65f08f379d0d201f9963c23573478..28de49c8b5771491b168bba26e6033669c48e3c9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
|
|
|
@ -13,18 +13,9 @@ also Avoid NPE during CraftBlockEntityState load if could not get TE
|
|||
If Tile Entity was null, correct Sign to return empty lines instead of null
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
||||
index 9d777fce673c8f6b3ee2d69f5a6360a8a5ad8e84..c3706b87ad36332a837caffb58bd4575cbc0172a 100644
|
||||
index 77645019c88d61dde28b7598d8a29b7d0c23c209..8a079ee3ed243fd19b1dd7eed2de1dd33785faa1 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
|
||||
@@ -31,7 +31,7 @@ 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;
|
||||
@@ -42,6 +42,7 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject {
|
||||
this.type = type;
|
||||
this.worldPosition = pos.immutable();
|
||||
|
|
|
@ -14,7 +14,7 @@ completion, such as offline players.
|
|||
Also adds isCommand and getLocation to the sync TabCompleteEvent
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index b2bbd25e5572f59add71579b676d5a4c719be239..737296e90e3547505a012fc516a4fc39a565343e 100644
|
||||
index b2bbd25e5572f59add71579b676d5a4c719be239..205e4ef25f49edc11a408c302d9ba68a59c68a5a 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -703,10 +703,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
|
@ -39,7 +39,7 @@ index b2bbd25e5572f59add71579b676d5a4c719be239..737296e90e3547505a012fc516a4fc39
|
|||
+ com.destroystokyo.paper.event.server.AsyncTabCompleteEvent event;
|
||||
+ java.util.List<String> 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();
|
||||
|
|
|
@ -27,22 +27,25 @@ index 8203c93dcb56646df2614f2233aaf3a36f745d1c..71fb831ed3359e7986e279c987211f39
|
|||
return experienceAmount * 2;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java b/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java
|
||||
index 27cdfbeb6cb2159075b35dd4f9e9557ec0eac7c2..d2d7b303e66bbba489e2003cc130dcd53e2a9854 100644
|
||||
index 27cdfbeb6cb2159075b35dd4f9e9557ec0eac7c2..069ce59faab5184ab9da8ca3fe1cebf7449cd7fe 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/enchantment/EnchantmentHelper.java
|
||||
@@ -246,8 +246,8 @@ public class EnchantmentHelper {
|
||||
@@ -246,8 +246,11 @@ public class EnchantmentHelper {
|
||||
return getItemEnchantmentLevel(Enchantments.CHANNELING, stack) > 0;
|
||||
}
|
||||
|
||||
- @Nullable
|
||||
- public static Entry<EquipmentSlot, ItemStack> getRandomItemWith(Enchantment enchantment, LivingEntity entity) {
|
||||
+ public static @javax.annotation.Nonnull ItemStack getRandomEquippedItemWithEnchant(Enchantment enchantment, LivingEntity entityliving) { Entry<EquipmentSlot, ItemStack> 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<EquipmentSlot, ItemStack> entry = getRandomItemWith(enchantment, entityliving);
|
||||
+ return entry != null ? entry.getValue() : ItemStack.EMPTY;
|
||||
+ } // Paper - OBFHELPER
|
||||
+ @Nullable public static Entry<EquipmentSlot, ItemStack> getRandomItemWith(Enchantment enchantment, LivingEntity entity) {
|
||||
return getRandomItemWith(enchantment, entity, (stack) -> {
|
||||
return true;
|
||||
});
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index ed1c57f22adc8b96012eca426ed1e7b409e7d663..b1778f53de7974e03c7b56b0df69e31cdae8dd62 100644
|
||||
index ed1c57f22adc8b96012eca426ed1e7b409e7d663..75963a28b39f8835f1daba3d1b44655603124bf3 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -61,11 +61,14 @@ import net.minecraft.server.level.ServerPlayer;
|
||||
|
@ -80,7 +83,7 @@ index ed1c57f22adc8b96012eca426ed1e7b409e7d663..b1778f53de7974e03c7b56b0df69e31c
|
|||
+ 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);
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 19 Jan 2018 00:36:25 -0500
|
||||
Subject: [PATCH] Add setPlayerProfile API for Skulls
|
||||
|
||||
This allows you to create already filled textures on Skulls to avoid texture lookups
|
||||
which commonly cause rate limit issues with Mojang API
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
|
||||
index 1879ae835c437883f76330d6e2707460273d02db..df0ba7ed56fc635a4aa30934d1990043dbc3d8dc 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
||||
+import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
@@ -105,6 +107,20 @@ public class CraftSkull extends CraftBlockEntityState<SkullBlockEntity> implemen
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void setPlayerProfile(PlayerProfile profile) {
|
||||
+ Preconditions.checkNotNull(profile, "profile");
|
||||
+ this.profile = CraftPlayerProfile.asAuthlibCopy(profile);
|
||||
+ }
|
||||
+
|
||||
+ @javax.annotation.Nullable
|
||||
+ @Override
|
||||
+ public PlayerProfile getPlayerProfile() {
|
||||
+ return profile != null ? CraftPlayerProfile.asBukkitCopy(profile) : null;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public BlockFace getRotation() {
|
||||
BlockData blockData = getBlockData();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
index 5e345224e698bd80133dc194385c033369a60a33..33994a050826d10d69f375f65ecce2b56116cca0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
@@ -4,10 +4,8 @@ import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
-import net.minecraft.nbt.CompoundTag;
|
||||
-import net.minecraft.nbt.NbtUtils;
|
||||
-import net.minecraft.nbt.Tag;
|
||||
-import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
||||
+import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -18,6 +16,11 @@ import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
+import javax.annotation.Nullable;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.nbt.NbtUtils;
|
||||
+import net.minecraft.nbt.Tag;
|
||||
+import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||
@DelegateDeserialization(SerializableMeta.class)
|
||||
class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
|
||||
@@ -149,6 +152,19 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
return this.hasOwner() ? this.profile.getName() : null;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void setPlayerProfile(@Nullable PlayerProfile profile) {
|
||||
+ setProfile((profile == null) ? null : CraftPlayerProfile.asAuthlibCopy(profile));
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ @Override
|
||||
+ public PlayerProfile getPlayerProfile() {
|
||||
+ return profile != null ? CraftPlayerProfile.asBukkitCopy(profile) : null;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public OfflinePlayer getOwningPlayer() {
|
||||
if (this.hasOwner()) {
|
42
patches/server/0174-Fill-Profile-Property-Events.patch
Normal file
42
patches/server/0174-Fill-Profile-Property-Events.patch
Normal file
|
@ -0,0 +1,42 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 2 Jan 2018 00:31:26 -0500
|
||||
Subject: [PATCH] Fill Profile Property Events
|
||||
|
||||
Allows plugins to populate profile properties from local sources to avoid calls out to Mojang API
|
||||
to fill in textures for example.
|
||||
|
||||
If Mojang API does need to be hit, event fire so you can get the results.
|
||||
|
||||
This is useful for implementing a ProfileCache for Player Skulls
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java b/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java
|
||||
index 93d73c27340645c7502acafdc0b2cfbc1a759dd8..5c7d2ee19243d0911a3a00af3ae42078a2ccba94 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.destroystokyo.paper.profile;
|
||||
|
||||
import com.mojang.authlib.Environment;
|
||||
+import com.destroystokyo.paper.event.profile.FillProfileEvent;
|
||||
+import com.destroystokyo.paper.event.profile.PreFillProfileEvent;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
@@ -20,7 +22,15 @@ public class PaperMinecraftSessionService extends YggdrasilMinecraftSessionServi
|
||||
|
||||
@Override
|
||||
public GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) {
|
||||
- return super.fillProfileProperties(profile, requireSecure);
|
||||
+ CraftPlayerProfile playerProfile = (CraftPlayerProfile) CraftPlayerProfile.asBukkitMirror(profile);
|
||||
+ new PreFillProfileEvent(playerProfile).callEvent();
|
||||
+ profile = playerProfile.getGameProfile();
|
||||
+ if (profile.isComplete() && profile.getProperties().containsKey("textures")) {
|
||||
+ return profile;
|
||||
+ }
|
||||
+ GameProfile gameProfile = super.fillProfileProperties(profile, requireSecure);
|
||||
+ new FillProfileEvent(CraftPlayerProfile.asBukkitMirror(gameProfile)).callEvent();
|
||||
+ return gameProfile;
|
||||
}
|
||||
|
||||
@Override
|
|
@ -0,0 +1,23 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 19 Jan 2018 08:15:29 -0600
|
||||
Subject: [PATCH] PlayerAdvancementCriterionGrantEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||
index f26bdd3d6eb0ae38c1d7b50f29942fcf2207e3a1..3d82f984648605d58fae3c57f145d0da8a2ae225 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
||||
@@ -277,6 +277,12 @@ public class PlayerAdvancements {
|
||||
boolean flag1 = advancementprogress.isDone();
|
||||
|
||||
if (advancementprogress.grantProgress(criterionName)) {
|
||||
+ // Paper start
|
||||
+ if (!new com.destroystokyo.paper.event.player.PlayerAdvancementCriterionGrantEvent(this.player.getBukkitEntity(), advancement.bukkit, criterionName).callEvent()) {
|
||||
+ advancementprogress.revokeProgress(criterionName);
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.unregisterListeners(advancement);
|
||||
this.progressChanged.add(advancement);
|
||||
flag = true;
|
288
patches/server/0176-Add-ArmorStand-Item-Meta.patch
Normal file
288
patches/server/0176-Add-ArmorStand-Item-Meta.patch
Normal file
|
@ -0,0 +1,288 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Sat, 27 Jan 2018 17:04:14 -0500
|
||||
Subject: [PATCH] Add ArmorStand Item Meta
|
||||
|
||||
This is adds basic item meta for armor stands. It does not add all
|
||||
possible metadata however.
|
||||
|
||||
There are armor, hand, and equipment types, as well as position data
|
||||
that can also be added here. This initial addition should serve a
|
||||
starting point for future additions in this area.
|
||||
|
||||
Fixes GH-559
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java
|
||||
index aee796567f11c8b93ac9ec0b8cb8f3a8412b23ce..39b98305632271e7375afe6c7001f241c17e103d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmorStand.java
|
||||
@@ -9,9 +9,22 @@ import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||
import org.bukkit.craftbukkit.inventory.CraftMetaItem.ItemMetaKey;
|
||||
|
||||
@DelegateDeserialization(CraftMetaItem.SerializableMeta.class)
|
||||
-public class CraftMetaArmorStand extends CraftMetaItem {
|
||||
+public class CraftMetaArmorStand extends CraftMetaItem implements com.destroystokyo.paper.inventory.meta.ArmorStandMeta { // Paper
|
||||
|
||||
static final ItemMetaKey ENTITY_TAG = new ItemMetaKey("EntityTag", "entity-tag");
|
||||
+ // Paper start
|
||||
+ static final ItemMetaKey INVISIBLE = new ItemMetaKey("Invisible", "invisible");
|
||||
+ static final ItemMetaKey NO_BASE_PLATE = new ItemMetaKey("NoBasePlate", "no-base-plate");
|
||||
+ static final ItemMetaKey SHOW_ARMS = new ItemMetaKey("ShowArms", "show-arms");
|
||||
+ static final ItemMetaKey SMALL = new ItemMetaKey("Small", "small");
|
||||
+ static final ItemMetaKey MARKER = new ItemMetaKey("Marker", "marker");
|
||||
+
|
||||
+ private boolean invisible;
|
||||
+ private boolean noBasePlate;
|
||||
+ private boolean showArms;
|
||||
+ private boolean small;
|
||||
+ private boolean marker;
|
||||
+ // Paper end
|
||||
CompoundTag entityTag;
|
||||
|
||||
CraftMetaArmorStand(CraftMetaItem meta) {
|
||||
@@ -22,6 +35,13 @@ public class CraftMetaArmorStand extends CraftMetaItem {
|
||||
}
|
||||
|
||||
CraftMetaArmorStand armorStand = (CraftMetaArmorStand) meta;
|
||||
+ // Paper start
|
||||
+ this.invisible = armorStand.invisible;
|
||||
+ this.noBasePlate = armorStand.noBasePlate;
|
||||
+ this.showArms = armorStand.showArms;
|
||||
+ this.small = armorStand.small;
|
||||
+ this.marker = armorStand.marker;
|
||||
+ // Paper end
|
||||
this.entityTag = armorStand.entityTag;
|
||||
}
|
||||
|
||||
@@ -30,11 +50,40 @@ public class CraftMetaArmorStand extends CraftMetaItem {
|
||||
|
||||
if (tag.contains(ENTITY_TAG.NBT)) {
|
||||
this.entityTag = tag.getCompound(ENTITY_TAG.NBT);
|
||||
+
|
||||
+ // Paper start
|
||||
+ if (entityTag.contains(INVISIBLE.NBT)) {
|
||||
+ invisible = entityTag.getBoolean(INVISIBLE.NBT);
|
||||
+ }
|
||||
+
|
||||
+ if (entityTag.contains(NO_BASE_PLATE.NBT)) {
|
||||
+ noBasePlate = entityTag.getBoolean(NO_BASE_PLATE.NBT);
|
||||
+ }
|
||||
+
|
||||
+ if (entityTag.contains(SHOW_ARMS.NBT)) {
|
||||
+ showArms = entityTag.getBoolean(SHOW_ARMS.NBT);
|
||||
+ }
|
||||
+
|
||||
+ if (entityTag.contains(SMALL.NBT)) {
|
||||
+ small = entityTag.getBoolean(SMALL.NBT);
|
||||
+ }
|
||||
+
|
||||
+ if (entityTag.contains(MARKER.NBT)) {
|
||||
+ marker = entityTag.getBoolean(MARKER.NBT);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
|
||||
CraftMetaArmorStand(Map<String, Object> map) {
|
||||
super(map);
|
||||
+ // Paper start
|
||||
+ 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
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,6 +106,31 @@ public class CraftMetaArmorStand extends CraftMetaItem {
|
||||
void applyToItem(CompoundTag tag) {
|
||||
super.applyToItem(tag);
|
||||
|
||||
+ // Paper start
|
||||
+ if (!isArmorStandEmpty() && this.entityTag == null) {
|
||||
+ this.entityTag = new CompoundTag();
|
||||
+ }
|
||||
+
|
||||
+ if (isInvisible()) {
|
||||
+ this.entityTag.putBoolean(INVISIBLE.NBT, this.invisible);
|
||||
+ }
|
||||
+
|
||||
+ if (hasNoBasePlate()) {
|
||||
+ this.entityTag.putBoolean(NO_BASE_PLATE.NBT, this.noBasePlate);
|
||||
+ }
|
||||
+
|
||||
+ if (shouldShowArms()) {
|
||||
+ this.entityTag.putBoolean(SHOW_ARMS.NBT, this.showArms);
|
||||
+ }
|
||||
+
|
||||
+ if (isSmall()) {
|
||||
+ this.entityTag.putBoolean(SMALL.NBT, this.small);
|
||||
+ }
|
||||
+
|
||||
+ if (isMarker()) {
|
||||
+ this.entityTag.putBoolean(MARKER.NBT, this.marker);
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (this.entityTag != null) {
|
||||
tag.put(ENTITY_TAG.NBT, entityTag);
|
||||
}
|
||||
@@ -78,7 +152,7 @@ public class CraftMetaArmorStand extends CraftMetaItem {
|
||||
}
|
||||
|
||||
boolean isArmorStandEmpty() {
|
||||
- return !(this.entityTag != null);
|
||||
+ return !(this.isInvisible() || this.hasNoBasePlate() || this.shouldShowArms() || this.isSmall() || this.isMarker() || this.entityTag != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +163,13 @@ public class CraftMetaArmorStand extends CraftMetaItem {
|
||||
if (meta instanceof CraftMetaArmorStand) {
|
||||
CraftMetaArmorStand that = (CraftMetaArmorStand) meta;
|
||||
|
||||
- return this.entityTag != null ? that.entityTag != null && this.entityTag.equals(that.entityTag) : this.entityTag == null;
|
||||
+ // Paper start
|
||||
+ 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;
|
||||
}
|
||||
@@ -104,9 +184,14 @@ public class CraftMetaArmorStand extends CraftMetaItem {
|
||||
final int original;
|
||||
int hash = original = super.applyHash();
|
||||
|
||||
- if (this.entityTag != null) {
|
||||
- hash = 73 * hash + this.entityTag.hashCode();
|
||||
- }
|
||||
+ // Paper start
|
||||
+ 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;
|
||||
}
|
||||
@@ -115,6 +200,28 @@ public class CraftMetaArmorStand extends CraftMetaItem {
|
||||
Builder<String, Object> serialize(Builder<String, Object> builder) {
|
||||
super.serialize(builder);
|
||||
|
||||
+ // Paper start
|
||||
+ if (this.isInvisible()) {
|
||||
+ builder.put(INVISIBLE.BUKKIT, invisible);
|
||||
+ }
|
||||
+
|
||||
+ if (this.hasNoBasePlate()) {
|
||||
+ builder.put(NO_BASE_PLATE.BUKKIT, noBasePlate);
|
||||
+ }
|
||||
+
|
||||
+ if (this.shouldShowArms()) {
|
||||
+ builder.put(SHOW_ARMS.BUKKIT, showArms);
|
||||
+ }
|
||||
+
|
||||
+ if (this.isSmall()) {
|
||||
+ builder.put(SMALL.BUKKIT, small);
|
||||
+ }
|
||||
+
|
||||
+ if (this.isMarker()) {
|
||||
+ builder.put(MARKER.BUKKIT, marker);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -128,4 +235,56 @@ public class CraftMetaArmorStand extends CraftMetaItem {
|
||||
|
||||
return clone;
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean isInvisible() {
|
||||
+ return invisible;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean hasNoBasePlate() {
|
||||
+ return noBasePlate;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean shouldShowArms() {
|
||||
+ return showArms;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isSmall() {
|
||||
+ return small;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isMarker() {
|
||||
+ return marker;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setInvisible(boolean invisible) {
|
||||
+ this.invisible = invisible;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setNoBasePlate(boolean noBasePlate) {
|
||||
+ this.noBasePlate = noBasePlate;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setShowArms(boolean showArms) {
|
||||
+ this.showArms = showArms;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setSmall(boolean small) {
|
||||
+ this.small = small;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setMarker(boolean marker) {
|
||||
+ this.marker = marker;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index 45f4f8265c51a5b08db8aa7f53915c4bd0536d39..4ad6fd7e110f949f0bd859331ed6a5109ade3008 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -1442,6 +1442,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
CraftMetaCrossbow.CHARGED.NBT,
|
||||
CraftMetaCrossbow.CHARGED_PROJECTILES.NBT,
|
||||
CraftMetaSuspiciousStew.EFFECTS.NBT,
|
||||
+ // Paper start
|
||||
+ CraftMetaArmorStand.ENTITY_TAG.NBT,
|
||||
+ CraftMetaArmorStand.INVISIBLE.NBT,
|
||||
+ CraftMetaArmorStand.NO_BASE_PLATE.NBT,
|
||||
+ CraftMetaArmorStand.SHOW_ARMS.NBT,
|
||||
+ CraftMetaArmorStand.SMALL.NBT,
|
||||
+ CraftMetaArmorStand.MARKER.NBT,
|
||||
+ // Paper end
|
||||
CraftMetaCompass.LODESTONE_DIMENSION.NBT,
|
||||
CraftMetaCompass.LODESTONE_POS.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 c1fc48881dffa61f461078bea5640f8c1a1f6570..b0bb30aebdba99a8fa929ec3c56e46b59d2467c9 100644
|
||||
--- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
|
||||
+++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
|
||||
@@ -314,6 +314,7 @@ public class ItemMetaTest extends AbstractTestingBase {
|
||||
final CraftMetaArmorStand meta = (CraftMetaArmorStand) cleanStack.getItemMeta();
|
||||
meta.entityTag = new CompoundTag();
|
||||
meta.entityTag.putBoolean("Small", true);
|
||||
+ meta.setInvisible(true); // Paper
|
||||
cleanStack.setItemMeta(meta);
|
||||
return cleanStack;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Sun, 11 Feb 2018 10:43:46 +0000
|
||||
Subject: [PATCH] Extend Player Interact cancellation
|
||||
|
||||
GUIs are opened on the client, meaning that the server cannot block them from opening,
|
||||
However, it is possible to close these GUIs from the server.
|
||||
|
||||
Flower pots are also not updated on the client when interaction is cancelled, this patch
|
||||
also resolves this.
|
||||
|
||||
Update adjacent blocks of doors, double plants, pistons and beds
|
||||
when cancelling interaction.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
index 9d303a962950c7464d1d4a2a0ce3f658628cc785..a67b7c82236d448bf10c257ab0a10476372ce89c 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
|
||||
@@ -178,6 +178,11 @@ public class ServerPlayerGameMode {
|
||||
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
|
||||
+ for (Direction dir : Direction.values()) {
|
||||
+ this.player.connection.send(new ClientboundBlockUpdatePacket(level, pos.relative(dir)));
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
|
||||
// Update any tile entity data for this block
|
||||
BlockEntity tileentity = this.level.getBlockEntity(pos);
|
||||
@@ -493,7 +498,13 @@ 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 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
|
||||
enuminteractionresult = (event.useItemInHand() != Event.Result.ALLOW) ? InteractionResult.SUCCESS : InteractionResult.PASS;
|
||||
} else if (this.gameModeForPlayer == GameType.SPECTATOR) {
|
38
patches/server/0178-Tameable-getOwnerUniqueId-API.patch
Normal file
38
patches/server/0178-Tameable-getOwnerUniqueId-API.patch
Normal file
|
@ -0,0 +1,38 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 24 Feb 2018 01:14:55 -0500
|
||||
Subject: [PATCH] Tameable#getOwnerUniqueId API
|
||||
|
||||
This is faster if all you need is the UUID, as .getOwner() will cause
|
||||
an OfflinePlayer to be loaded from disk.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java
|
||||
index 27a1ca43792644fc239af81dea5510f25d3328e9..69c95644b2531c1fe1c4a6cf7fee12e997dd67f4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java
|
||||
@@ -89,6 +89,10 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac
|
||||
}
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public UUID getOwnerUniqueId() {
|
||||
+ return getOwnerUUID();
|
||||
+ }
|
||||
public UUID 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 cc90c09c26b04689e4fffa890baf0e89c38665a3..0b152d8d20924fc1ce7f5bafb050216d250f6536 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTameableAnimal.java
|
||||
@@ -17,6 +17,10 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat
|
||||
return (TamableAnimal) super.getHandle();
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public UUID getOwnerUniqueId() {
|
||||
+ return getOwnerUUID();
|
||||
+ }
|
||||
public UUID getOwnerUUID() {
|
||||
try {
|
||||
return this.getHandle().getOwnerUUID();
|
|
@ -0,0 +1,34 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MiniDigger <admin@minidigger.me>
|
||||
Date: Sat, 10 Mar 2018 00:50:24 +0100
|
||||
Subject: [PATCH] Toggleable player crits, helps mitigate hacked clients.
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index 3577100f850975020b74f077d688f59dbca78962..da4a110809eee691c1d5b072de335d75e1516eae 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -192,6 +192,11 @@ public class PaperWorldConfig {
|
||||
disableChestCatDetection = getBoolean("game-mechanics.disable-chest-cat-detection", false);
|
||||
}
|
||||
|
||||
+ public boolean disablePlayerCrits;
|
||||
+ private void disablePlayerCrits() {
|
||||
+ disablePlayerCrits = getBoolean("game-mechanics.disable-player-crits", false);
|
||||
+ }
|
||||
+
|
||||
public boolean allChunksAreSlimeChunks;
|
||||
private void allChunksAreSlimeChunks() {
|
||||
allChunksAreSlimeChunks = getBoolean("all-chunks-are-slime-chunks", false);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
index d3fe3eabf4465101760951113b23edf2ce03e57d..4e8d38a6379d3dc1b7167b27479e6a27ea19ea19 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -1191,6 +1191,7 @@ public abstract class Player extends LivingEntity {
|
||||
|
||||
boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && target instanceof LivingEntity;
|
||||
|
||||
+ flag2 = flag2 && !level.paperConfig.disablePlayerCrits; // Paper
|
||||
flag2 = flag2 && !this.isSprinting();
|
||||
if (flag2) {
|
||||
f *= 1.5F;
|
|
@ -0,0 +1,34 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 11 Mar 2018 14:13:33 -0400
|
||||
Subject: [PATCH] Disable Explicit Network Manager Flushing
|
||||
|
||||
This seems completely pointless, as packet dispatch uses .writeAndFlush.
|
||||
|
||||
Things seem to work fine without explicit flushing, but incase issues arise,
|
||||
provide a System property to re-enable it using improved logic of doing the
|
||||
flushing on the netty event loop, so it won't do the flush on the main thread.
|
||||
|
||||
Renable flushing by passing -Dpaper.explicit-flush=true
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
||||
index 1d46187969b5792c255d0bf1966b427b905cb69c..0c5c62be83223e20f216df84413b8c2438db81ff 100644
|
||||
--- a/src/main/java/net/minecraft/network/Connection.java
|
||||
+++ b/src/main/java/net/minecraft/network/Connection.java
|
||||
@@ -86,6 +86,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
// Paper start - NetworkClient implementation
|
||||
public int protocolVersion;
|
||||
public java.net.InetSocketAddress virtualHost;
|
||||
+ private static boolean enableExplicitFlush = Boolean.getBoolean("paper.explicit-flush");
|
||||
// Paper end
|
||||
|
||||
public Connection(PacketFlow side) {
|
||||
@@ -259,7 +260,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
}
|
||||
|
||||
if (this.channel != null) {
|
||||
- this.channel.flush();
|
||||
+ if (enableExplicitFlush) this.channel.eventLoop().execute(() -> this.channel.flush()); // Paper - we don't need to explicit flush here, but allow opt in incase issues are found to a better version
|
||||
}
|
||||
|
||||
if (this.tickCount++ % 20 == 0) {
|
|
@ -0,0 +1,250 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Minecrell <minecrell@minecrell.net>
|
||||
Date: Wed, 11 Oct 2017 15:56:26 +0200
|
||||
Subject: [PATCH] Implement extended PaperServerListPingEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java b/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4ecd0c5bbea55f68549c85aa27e80e2c7e6265d4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/network/PaperServerListPingEventImpl.java
|
||||
@@ -0,0 +1,31 @@
|
||||
+package com.destroystokyo.paper.network;
|
||||
+
|
||||
+import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.util.CachedServerIcon;
|
||||
+
|
||||
+import javax.annotation.Nullable;
|
||||
+
|
||||
+class PaperServerListPingEventImpl extends PaperServerListPingEvent {
|
||||
+
|
||||
+ private final MinecraftServer server;
|
||||
+
|
||||
+ PaperServerListPingEventImpl(MinecraftServer server, StatusClient client, int protocolVersion, @Nullable CachedServerIcon icon) {
|
||||
+ super(client, server.getMotd(), server.getPlayerCount(), server.getMaxPlayers(),
|
||||
+ server.getServerModName() + ' ' + server.getServerVersion(), protocolVersion, icon);
|
||||
+ this.server = server;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected final Object[] getOnlinePlayers() {
|
||||
+ return this.server.getPlayerList().players.toArray();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected final Player getBukkitPlayer(Object player) {
|
||||
+ return ((ServerPlayer) player).getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/network/PaperStatusClient.java b/src/main/java/com/destroystokyo/paper/network/PaperStatusClient.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d926ad804355ee2fdc5910b2505e8671602acdab
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/network/PaperStatusClient.java
|
||||
@@ -0,0 +1,11 @@
|
||||
+package com.destroystokyo.paper.network;
|
||||
+
|
||||
+import net.minecraft.network.Connection;
|
||||
+
|
||||
+class PaperStatusClient extends PaperNetworkClient implements StatusClient {
|
||||
+
|
||||
+ PaperStatusClient(Connection networkManager) {
|
||||
+ super(networkManager);
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java b/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4c2351b03b58511b80017b58ee9b20ab5193adc9
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/network/StandardPaperServerListPingEventImpl.java
|
||||
@@ -0,0 +1,110 @@
|
||||
+package com.destroystokyo.paper.network;
|
||||
+
|
||||
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
||||
+import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
+import com.google.common.base.MoreObjects;
|
||||
+import com.google.common.base.Strings;
|
||||
+import com.mojang.authlib.GameProfile;
|
||||
+import io.papermc.paper.adventure.AdventureComponent;
|
||||
+import java.util.List;
|
||||
+import java.util.UUID;
|
||||
+import javax.annotation.Nonnull;
|
||||
+import net.minecraft.network.Connection;
|
||||
+import net.minecraft.network.protocol.status.ClientboundStatusResponsePacket;
|
||||
+import net.minecraft.network.protocol.status.ServerStatus;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+
|
||||
+public final class StandardPaperServerListPingEventImpl extends PaperServerListPingEventImpl {
|
||||
+
|
||||
+ private static final GameProfile[] EMPTY_PROFILES = new GameProfile[0];
|
||||
+ private static final UUID FAKE_UUID = new UUID(0, 0);
|
||||
+
|
||||
+ private GameProfile[] originalSample;
|
||||
+
|
||||
+ private StandardPaperServerListPingEventImpl(MinecraftServer server, Connection networkManager, ServerStatus ping) {
|
||||
+ super(server, new PaperStatusClient(networkManager), ping.getVersion() != null ? ping.getVersion().getProtocol() : -1, server.server.getServerIcon());
|
||||
+ this.originalSample = ping.getPlayers() == null ? null : ping.getPlayers().getSample(); // GH-1473 - pre-tick race condition NPE
|
||||
+ }
|
||||
+
|
||||
+ @Nonnull
|
||||
+ @Override
|
||||
+ public List<PlayerProfile> getPlayerSample() {
|
||||
+ List<PlayerProfile> sample = super.getPlayerSample();
|
||||
+
|
||||
+ if (this.originalSample != null) {
|
||||
+ for (GameProfile profile : this.originalSample) {
|
||||
+ sample.add(CraftPlayerProfile.asBukkitCopy(profile));
|
||||
+ }
|
||||
+ this.originalSample = null;
|
||||
+ }
|
||||
+
|
||||
+ return sample;
|
||||
+ }
|
||||
+
|
||||
+ private GameProfile[] getPlayerSampleHandle() {
|
||||
+ if (this.originalSample != null) {
|
||||
+ return this.originalSample;
|
||||
+ }
|
||||
+
|
||||
+ List<PlayerProfile> entries = super.getPlayerSample();
|
||||
+ if (entries.isEmpty()) {
|
||||
+ return EMPTY_PROFILES;
|
||||
+ }
|
||||
+
|
||||
+ GameProfile[] profiles = new GameProfile[entries.size()];
|
||||
+ for (int i = 0; i < profiles.length; i++) {
|
||||
+ /*
|
||||
+ * Avoid null UUIDs/names since that will make the response invalid
|
||||
+ * on the client.
|
||||
+ * Instead, fall back to a fake/empty UUID and an empty string as name.
|
||||
+ * This can be used to create custom lines in the player list that do not
|
||||
+ * refer to a specific player.
|
||||
+ */
|
||||
+
|
||||
+ PlayerProfile profile = entries.get(i);
|
||||
+ if (profile.getId() != null && profile.getName() != null) {
|
||||
+ profiles[i] = CraftPlayerProfile.asAuthlib(profile);
|
||||
+ } else {
|
||||
+ profiles[i] = new GameProfile(MoreObjects.firstNonNull(profile.getId(), FAKE_UUID), Strings.nullToEmpty(profile.getName()));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return profiles;
|
||||
+ }
|
||||
+
|
||||
+ @SuppressWarnings("deprecation")
|
||||
+ public static void processRequest(MinecraftServer server, Connection networkManager) {
|
||||
+ StandardPaperServerListPingEventImpl event = new StandardPaperServerListPingEventImpl(server, networkManager, server.getStatus());
|
||||
+ server.server.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ // Close connection immediately if event is cancelled
|
||||
+ if (event.isCancelled()) {
|
||||
+ networkManager.disconnect(null);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // Setup response
|
||||
+ ServerStatus ping = new ServerStatus();
|
||||
+
|
||||
+ // Description
|
||||
+ ping.setDescription(new AdventureComponent(event.motd()));
|
||||
+
|
||||
+ // Players
|
||||
+ if (!event.shouldHidePlayers()) {
|
||||
+ ping.setPlayers(new ServerStatus.Players(event.getMaxPlayers(), event.getNumPlayers()));
|
||||
+ ping.getPlayers().setSample(event.getPlayerSampleHandle());
|
||||
+ }
|
||||
+
|
||||
+ // Version
|
||||
+ ping.setVersion(new ServerStatus.Version(event.getVersion(), event.getProtocolVersion()));
|
||||
+
|
||||
+ // Favicon
|
||||
+ if (event.getServerIcon() != null) {
|
||||
+ ping.setFavicon(event.getServerIcon().getData());
|
||||
+ }
|
||||
+
|
||||
+ // Send response
|
||||
+ networkManager.send(new ClientboundStatusResponsePacket(ping));
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java b/src/main/java/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java
|
||||
index 67455a5ba75c9b816213e44d6872c5ddf8e27e98..23efad80934930beadf15e65781551d4ba7ff81b 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/status/ClientboundStatusResponsePacket.java
|
||||
@@ -10,7 +10,9 @@ import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.util.LowerCaseEnumTypeAdapterFactory;
|
||||
|
||||
public class ClientboundStatusResponsePacket implements Packet<ClientStatusPacketListener> {
|
||||
- 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(io.papermc.paper.adventure.AdventureComponent.class, new io.papermc.paper.adventure.AdventureComponent.Serializer())
|
||||
+ .create();
|
||||
private final ServerStatus status;
|
||||
|
||||
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 fb4385333ef8dd4fa22275753606df3020000539..a0c436fd5e7e03a0a01e59c046e65ebdcd88021a 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -2,6 +2,9 @@ package net.minecraft.server;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
+import co.aikar.timings.Timings;
|
||||
+import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
+import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -1310,7 +1313,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
if (i - this.lastServerStatus >= 5000000000L) {
|
||||
this.lastServerStatus = i;
|
||||
this.status.setPlayers(new ServerStatus.Players(this.getMaxPlayers(), this.getPlayerCount()));
|
||||
- GameProfile[] agameprofile = new GameProfile[Math.min(this.getPlayerCount(), 12)];
|
||||
+ GameProfile[] agameprofile = new GameProfile[Math.min(this.getPlayerCount(), org.spigotmc.SpigotConfig.playerSample)]; // Paper
|
||||
int j = Mth.nextInt(this.random, 0, this.getPlayerCount() - agameprofile.length);
|
||||
|
||||
for (int k = 0; k < agameprofile.length; ++k) {
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java
|
||||
index 9baa56d6da9c24706f1dbc8851fd68ca752cab26..d65191a50349ec86fe35df4ac1070f94fbb77b4c 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerStatusPacketListenerImpl.java
|
||||
@@ -47,6 +47,8 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene
|
||||
this.connection.disconnect(ServerStatusPacketListenerImpl.DISCONNECT_REASON);
|
||||
} else {
|
||||
this.hasRequestedStatus = true;
|
||||
+ // Paper start - Replace everything
|
||||
+ /*
|
||||
// CraftBukkit start
|
||||
// this.networkManager.sendPacket(new PacketStatusOutServerInfo(this.minecraftServer.getServerPing()));
|
||||
final Object[] players = this.server.getPlayerList().players.toArray();
|
||||
@@ -142,6 +144,9 @@ public class ServerStatusPacketListenerImpl implements ServerStatusPacketListene
|
||||
ping.setVersion(new ServerStatus.Version(this.server.getServerModName() + " " + this.server.getServerVersion(), version));
|
||||
|
||||
this.connection.send(new ClientboundStatusResponsePacket(ping));
|
||||
+ */
|
||||
+ com.destroystokyo.paper.network.StandardPaperServerListPingEventImpl.processRequest(this.server, this.connection);
|
||||
+ // Paper end
|
||||
}
|
||||
// CraftBukkit end
|
||||
}
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
index e7586c325290ceb8669f9f9d430c73080a37dd05..314fa148fe783a0558ba00b068e0bf69a91577e1 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
@@ -289,7 +289,7 @@ public class SpigotConfig
|
||||
public static int playerSample;
|
||||
private static void playerSample()
|
||||
{
|
||||
- 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
|
||||
}
|
||||
|
370
patches/server/0182-Improved-Async-Task-Scheduler.patch
Normal file
370
patches/server/0182-Improved-Async-Task-Scheduler.patch
Normal file
|
@ -0,0 +1,370 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 16 Mar 2018 22:59:43 -0400
|
||||
Subject: [PATCH] Improved Async Task Scheduler
|
||||
|
||||
The Craft Scheduler still uses the primary thread for task scheduling.
|
||||
This results in the main thread still having to do work as part of the
|
||||
dispatching of async tasks.
|
||||
|
||||
If plugins make use of lots of async tasks, such as particle emitters
|
||||
that want to keep the logic off the main thread, the main thread still
|
||||
receives quite a bit of load from processing all of these queued tasks.
|
||||
|
||||
Additionally, resizing and managing the pending entries for all of
|
||||
these asynchronous tasks takes up time on the main thread too.
|
||||
|
||||
This commit replaces the implementation of the scheduler when working
|
||||
with asynchronous tasks, by forwarding calls to the new scheduler.
|
||||
|
||||
The Async Scheduler uses a single thread executor for "management" tasks.
|
||||
The Management Thread is responsible for all adding and dispatching of
|
||||
scheduled tasks.
|
||||
|
||||
The mainThreadHeartbeat will send a heartbeat task to the management thread
|
||||
with the currentTick value, so that it can find which tasks to execute.
|
||||
|
||||
Scheduling of an async tasks also dispatches a management task, ensuring
|
||||
that any Queue resizing operation occurs off of the main thread.
|
||||
|
||||
The async queue uses a complete separate PriorityQueue, ensuring that resize
|
||||
operations are decoupled from the sync tasks queue.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3c1992e212a6d6f1db4d5b807b38d71913619fc0
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncScheduler.java
|
||||
@@ -0,0 +1,122 @@
|
||||
+/*
|
||||
+ * Copyright (c) 2018 Daniel Ennis (Aikar) MIT License
|
||||
+ *
|
||||
+ * Permission is hereby granted, free of charge, to any person obtaining
|
||||
+ * a copy of this software and associated documentation files (the
|
||||
+ * "Software"), to deal in the Software without restriction, including
|
||||
+ * without limitation the rights to use, copy, modify, merge, publish,
|
||||
+ * distribute, sublicense, and/or sell copies of the Software, and to
|
||||
+ * permit persons to whom the Software is furnished to do so, subject to
|
||||
+ * the following conditions:
|
||||
+ *
|
||||
+ * The above copyright notice and this permission notice shall be
|
||||
+ * included in all copies or substantial portions of the Software.
|
||||
+ *
|
||||
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+ */
|
||||
+
|
||||
+package org.bukkit.craftbukkit.scheduler;
|
||||
+
|
||||
+import com.destroystokyo.paper.ServerSchedulerReportingWrapper;
|
||||
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
+import org.bukkit.plugin.Plugin;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Iterator;
|
||||
+import java.util.List;
|
||||
+import java.util.concurrent.Executor;
|
||||
+import java.util.concurrent.Executors;
|
||||
+import java.util.concurrent.SynchronousQueue;
|
||||
+import java.util.concurrent.ThreadPoolExecutor;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+
|
||||
+public class CraftAsyncScheduler extends CraftScheduler {
|
||||
+
|
||||
+ private final ThreadPoolExecutor executor = new ThreadPoolExecutor(
|
||||
+ 4, Integer.MAX_VALUE,30L, TimeUnit.SECONDS, new SynchronousQueue<>(),
|
||||
+ new ThreadFactoryBuilder().setNameFormat("Craft Scheduler Thread - %1$d").build());
|
||||
+ private final Executor management = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder()
|
||||
+ .setNameFormat("Craft Async Scheduler Management Thread").build());
|
||||
+ private final List<CraftTask> temp = new ArrayList<>();
|
||||
+
|
||||
+ CraftAsyncScheduler() {
|
||||
+ super(true);
|
||||
+ executor.allowCoreThreadTimeOut(true);
|
||||
+ executor.prestartAllCoreThreads();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void cancelTask(int taskId) {
|
||||
+ this.management.execute(() -> this.removeTask(taskId));
|
||||
+ }
|
||||
+
|
||||
+ private synchronized void removeTask(int taskId) {
|
||||
+ parsePending();
|
||||
+ this.pending.removeIf((task) -> {
|
||||
+ if (task.getTaskId() == taskId) {
|
||||
+ task.cancel0();
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void mainThreadHeartbeat(int currentTick) {
|
||||
+ this.currentTick = currentTick;
|
||||
+ this.management.execute(() -> this.runTasks(currentTick));
|
||||
+ }
|
||||
+
|
||||
+ private synchronized void runTasks(int currentTick) {
|
||||
+ parsePending();
|
||||
+ while (!this.pending.isEmpty() && this.pending.peek().getNextRun() <= currentTick) {
|
||||
+ CraftTask task = this.pending.remove();
|
||||
+ if (executeTask(task)) {
|
||||
+ final long period = task.getPeriod();
|
||||
+ if (period > 0) {
|
||||
+ task.setNextRun(currentTick + period);
|
||||
+ temp.add(task);
|
||||
+ }
|
||||
+ }
|
||||
+ parsePending();
|
||||
+ }
|
||||
+ this.pending.addAll(temp);
|
||||
+ temp.clear();
|
||||
+ }
|
||||
+
|
||||
+ private boolean executeTask(CraftTask task) {
|
||||
+ if (isValid(task)) {
|
||||
+ this.runners.put(task.getTaskId(), task);
|
||||
+ this.executor.execute(new ServerSchedulerReportingWrapper(task));
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public synchronized void cancelTasks(Plugin plugin) {
|
||||
+ parsePending();
|
||||
+ for (Iterator<CraftTask> iterator = this.pending.iterator(); iterator.hasNext(); ) {
|
||||
+ CraftTask task = iterator.next();
|
||||
+ if (task.getTaskId() != -1 && (plugin == null || task.getOwner().equals(plugin))) {
|
||||
+ task.cancel0();
|
||||
+ iterator.remove();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Task is not cancelled
|
||||
+ * @param runningTask
|
||||
+ * @return
|
||||
+ */
|
||||
+ static boolean isValid(CraftTask runningTask) {
|
||||
+ return runningTask.getPeriod() >= CraftTask.NO_REPEATING;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
index 6435d53dcddc1a43420f1ea66fa08e154b82586d..dd1e8b170e87bff2089f642f41dcf7442a8ccd16 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
@@ -63,7 +63,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
/**
|
||||
* Main thread logic only
|
||||
*/
|
||||
- private final PriorityQueue<CraftTask> pending = new PriorityQueue<CraftTask>(10,
|
||||
+ final PriorityQueue<CraftTask> pending = new PriorityQueue<CraftTask>(10, // Paper
|
||||
new Comparator<CraftTask>() {
|
||||
@Override
|
||||
public int compare(final CraftTask o1, final CraftTask o2) {
|
||||
@@ -80,12 +80,13 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
/**
|
||||
* These are tasks that are currently active. It's provided for 'viewing' the current state.
|
||||
*/
|
||||
- private final ConcurrentHashMap<Integer, CraftTask> runners = new ConcurrentHashMap<Integer, CraftTask>();
|
||||
+ final ConcurrentHashMap<Integer, CraftTask> runners = new ConcurrentHashMap<Integer, CraftTask>(); // Paper
|
||||
/**
|
||||
* The sync task that is currently running on the main thread.
|
||||
*/
|
||||
private volatile CraftTask currentTask = null;
|
||||
- private volatile int currentTick = -1;
|
||||
+ // Paper start - Improved Async Task Scheduler
|
||||
+ volatile int currentTick = -1;/*
|
||||
private final Executor executor = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("Craft Scheduler Thread - %d").build());
|
||||
private CraftAsyncDebugger debugHead = new CraftAsyncDebugger(-1, null, null) {
|
||||
@Override
|
||||
@@ -94,12 +95,31 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
}
|
||||
};
|
||||
private CraftAsyncDebugger debugTail = this.debugHead;
|
||||
+
|
||||
+ */ // Paper end
|
||||
private static final int RECENT_TICKS;
|
||||
|
||||
static {
|
||||
RECENT_TICKS = 30;
|
||||
}
|
||||
|
||||
+
|
||||
+ // Paper start
|
||||
+ private final CraftScheduler asyncScheduler;
|
||||
+ private final boolean isAsyncScheduler;
|
||||
+ public CraftScheduler() {
|
||||
+ this(false);
|
||||
+ }
|
||||
+
|
||||
+ public CraftScheduler(boolean isAsync) {
|
||||
+ this.isAsyncScheduler = isAsync;
|
||||
+ if (isAsync) {
|
||||
+ this.asyncScheduler = this;
|
||||
+ } else {
|
||||
+ this.asyncScheduler = new CraftAsyncScheduler();
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Plugin plugin, final Runnable task) {
|
||||
return this.scheduleSyncDelayedTask(plugin, task, 0L);
|
||||
@@ -222,7 +242,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
} else if (period < CraftTask.NO_REPEATING) {
|
||||
period = CraftTask.NO_REPEATING;
|
||||
}
|
||||
- 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
|
||||
@@ -238,6 +258,11 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
if (taskId <= 0) {
|
||||
return;
|
||||
}
|
||||
+ // Paper start
|
||||
+ if (!this.isAsyncScheduler) {
|
||||
+ this.asyncScheduler.cancelTask(taskId);
|
||||
+ }
|
||||
+ // Paper end
|
||||
CraftTask task = this.runners.get(taskId);
|
||||
if (task != null) {
|
||||
task.cancel0();
|
||||
@@ -280,6 +305,11 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
@Override
|
||||
public void cancelTasks(final Plugin plugin) {
|
||||
Validate.notNull(plugin, "Cannot cancel tasks of null plugin");
|
||||
+ // Paper start
|
||||
+ if (!this.isAsyncScheduler) {
|
||||
+ this.asyncScheduler.cancelTasks(plugin);
|
||||
+ }
|
||||
+ // Paper end
|
||||
final CraftTask task = new CraftTask(
|
||||
new Runnable() {
|
||||
@Override
|
||||
@@ -319,6 +349,13 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
|
||||
@Override
|
||||
public boolean isCurrentlyRunning(final int taskId) {
|
||||
+ // Paper start
|
||||
+ if (!this.isAsyncScheduler) {
|
||||
+ if (this.asyncScheduler.isCurrentlyRunning(taskId)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
final CraftTask task = this.runners.get(taskId);
|
||||
if (task == null) {
|
||||
return false;
|
||||
@@ -337,6 +374,11 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
if (taskId <= 0) {
|
||||
return false;
|
||||
}
|
||||
+ // Paper start
|
||||
+ if (!this.isAsyncScheduler && this.asyncScheduler.isQueued(taskId)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
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
|
||||
@@ -348,6 +390,12 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
|
||||
@Override
|
||||
public List<BukkitWorker> getActiveWorkers() {
|
||||
+ // Paper start
|
||||
+ if (!isAsyncScheduler) {
|
||||
+ //noinspection TailRecursion
|
||||
+ return this.asyncScheduler.getActiveWorkers();
|
||||
+ }
|
||||
+ // Paper end
|
||||
final ArrayList<BukkitWorker> workers = new ArrayList<BukkitWorker>();
|
||||
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
|
||||
@@ -385,6 +433,11 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
pending.add(task);
|
||||
}
|
||||
}
|
||||
+ // Paper start
|
||||
+ if (!this.isAsyncScheduler) {
|
||||
+ pending.addAll(this.asyncScheduler.getPendingTasks());
|
||||
+ }
|
||||
+ // Paper end
|
||||
return pending;
|
||||
}
|
||||
|
||||
@@ -392,6 +445,11 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
* This method is designed to never block or wait for locks; an immediate execution of all current tasks.
|
||||
*/
|
||||
public void mainThreadHeartbeat(final int currentTick) {
|
||||
+ // Paper start
|
||||
+ if (!this.isAsyncScheduler) {
|
||||
+ this.asyncScheduler.mainThreadHeartbeat(currentTick);
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.currentTick = currentTick;
|
||||
final List<CraftTask> temp = this.temp;
|
||||
this.parsePending();
|
||||
@@ -431,7 +489,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
this.parsePending();
|
||||
} else {
|
||||
//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)
|
||||
}
|
||||
@@ -450,7 +508,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
//this.debugHead = this.debugHead.getNextHead(currentTick); // Paper
|
||||
}
|
||||
|
||||
- private void addTask(final CraftTask task) {
|
||||
+ protected void addTask(final CraftTask task) {
|
||||
final AtomicReference<CraftTask> tail = this.tail;
|
||||
CraftTask tailTask = tail.get();
|
||||
while (!tail.compareAndSet(tailTask, task)) {
|
||||
@@ -459,7 +517,13 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
tailTask.setNext(task);
|
||||
}
|
||||
|
||||
- private CraftTask handle(final CraftTask task, final long delay) {
|
||||
+ protected CraftTask handle(final CraftTask task, final long delay) { // Paper
|
||||
+ // Paper start
|
||||
+ if (!this.isAsyncScheduler && !task.isSync()) {
|
||||
+ this.asyncScheduler.handle(task, delay);
|
||||
+ return task;
|
||||
+ }
|
||||
+ // Paper end
|
||||
task.setNextRun(this.currentTick + delay);
|
||||
this.addTask(task);
|
||||
return task;
|
||||
@@ -478,8 +542,8 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
return this.ids.incrementAndGet();
|
||||
}
|
||||
|
||||
- private void parsePending() {
|
||||
- MinecraftTimings.bukkitSchedulerPendingTimer.startTiming();
|
||||
+ void parsePending() { // Paper
|
||||
+ if (!this.isAsyncScheduler) MinecraftTimings.bukkitSchedulerPendingTimer.startTiming(); // Paper
|
||||
CraftTask head = this.head;
|
||||
CraftTask task = head.getNext();
|
||||
CraftTask lastTask = head;
|
||||
@@ -498,7 +562,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
task.setNext(null);
|
||||
}
|
||||
this.head = lastTask;
|
||||
- MinecraftTimings.bukkitSchedulerPendingTimer.stopTiming();
|
||||
+ if (!this.isAsyncScheduler) MinecraftTimings.bukkitSchedulerPendingTimer.stopTiming(); // Paper
|
||||
}
|
||||
|
||||
private boolean isReady(final int currentTick) {
|
|
@ -0,0 +1,45 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 18 Mar 2018 11:45:57 -0400
|
||||
Subject: [PATCH] Ability to change PlayerProfile in AsyncPreLoginEvent
|
||||
|
||||
This will allow you to change the players name or skin on login.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index 7923078a4235a6169eb94b7c0ce85e4cd51eb593..f39ccd15c037138a933eb529bec17d49349c0264 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.minecraft.server.network;
|
||||
|
||||
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
||||
+import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.exceptions.AuthenticationUnavailableException;
|
||||
import java.math.BigInteger;
|
||||
@@ -37,6 +39,7 @@ import org.apache.commons.lang3.Validate;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import io.papermc.paper.adventure.PaperAdventure; // Paper
|
||||
+import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.util.Waitable;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.PlayerPreLoginEvent;
|
||||
@@ -336,8 +339,16 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
|
||||
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);
|
||||
+ // Paper start
|
||||
+ PlayerProfile profile = Bukkit.createProfile(uniqueId, playerName);
|
||||
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId, profile);
|
||||
server.getPluginManager().callEvent(asyncEvent);
|
||||
+ profile = asyncEvent.getPlayerProfile();
|
||||
+ profile.complete();
|
||||
+ gameProfile = 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);
|
133
patches/server/0184-Player.setPlayerProfile-API.patch
Normal file
133
patches/server/0184-Player.setPlayerProfile-API.patch
Normal file
|
@ -0,0 +1,133 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 18 Mar 2018 12:29:48 -0400
|
||||
Subject: [PATCH] Player.setPlayerProfile API
|
||||
|
||||
This can be useful for changing name or skins after a player has logged in.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index f39ccd15c037138a933eb529bec17d49349c0264..1d05725374bdffad6a8ab1502ee732775345024d 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -340,12 +340,12 @@ 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(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);
|
||||
+ ServerLoginPacketListenerImpl.this.gameProfile = CraftPlayerProfile.asAuthlib(profile);
|
||||
playerName = gameProfile.getName();
|
||||
uniqueId = gameProfile.getId();
|
||||
// Paper end
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
index 4e8d38a6379d3dc1b7167b27479e6a27ea19ea19..3c0aca2b90521da83cf494d9fff953a17a57701d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -173,7 +173,7 @@ public abstract class Player extends LivingEntity {
|
||||
protected int enchantmentSeed;
|
||||
protected final float defaultFlySpeed = 0.02F;
|
||||
private int lastLevelUpTime;
|
||||
- private final GameProfile gameProfile;
|
||||
+ public GameProfile gameProfile; // Paper - private->public
|
||||
private boolean reducedDebugInfo;
|
||||
private ItemStack lastItemInMainHand;
|
||||
private final ItemCooldowns cooldowns;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 75963a28b39f8835f1daba3d1b44655603124bf3..8bf0c74ee32e8cb7c0f48bc964552811ad6ee468 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -71,6 +71,7 @@ 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.level.saveddata.maps.MapItemSavedData;
|
||||
@@ -1320,8 +1321,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
this.hiddenPlayers.put(player.getUniqueId(), hidingPlugins);
|
||||
|
||||
// Remove this player from the hidden player's EntityTrackerEntry
|
||||
- ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap;
|
||||
+ // Paper start
|
||||
ServerPlayer other = ((CraftPlayer) player).getHandle();
|
||||
+ unregisterPlayer(other);
|
||||
+ }
|
||||
+ private void unregisterPlayer(ServerPlayer other) {
|
||||
+ ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap;
|
||||
+ // Paper end
|
||||
ChunkMap.TrackedEntity entry = tracker.entityMap.get(other.getId());
|
||||
if (entry != null) {
|
||||
entry.removePlayer(this.getHandle());
|
||||
@@ -1362,8 +1368,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
this.hiddenPlayers.remove(player.getUniqueId());
|
||||
|
||||
- ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap;
|
||||
+ // Paper start
|
||||
ServerPlayer other = ((CraftPlayer) player).getHandle();
|
||||
+ registerPlayer(other);
|
||||
+ }
|
||||
+ private void registerPlayer(ServerPlayer other) {
|
||||
+ ChunkMap tracker = ((ServerLevel) entity.level).getChunkSource().chunkMap;
|
||||
+ // Paper end
|
||||
|
||||
this.getHandle().connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, other));
|
||||
|
||||
@@ -1372,6 +1383,50 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
entry.updatePlayer(this.getHandle());
|
||||
}
|
||||
}
|
||||
+ // Paper start
|
||||
+ private void reregisterPlayer(ServerPlayer player) {
|
||||
+ if (!hiddenPlayers.containsKey(player.getUUID())) {
|
||||
+ unregisterPlayer(player);
|
||||
+ registerPlayer(player);
|
||||
+ }
|
||||
+ }
|
||||
+ public void setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile profile) {
|
||||
+ ServerPlayer self = getHandle();
|
||||
+ self.gameProfile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile);
|
||||
+ if (!self.sentListPacket) {
|
||||
+ return;
|
||||
+ }
|
||||
+ List<ServerPlayer> players = server.getServer().getPlayerList().players;
|
||||
+ for (ServerPlayer player : players) {
|
||||
+ player.getBukkitEntity().reregisterPlayer(self);
|
||||
+ }
|
||||
+ refreshPlayer();
|
||||
+ }
|
||||
+ public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() {
|
||||
+ return new com.destroystokyo.paper.profile.CraftPlayerProfile(this).clone();
|
||||
+ }
|
||||
+
|
||||
+ private void refreshPlayer() {
|
||||
+ ServerPlayer handle = getHandle();
|
||||
+
|
||||
+ Location loc = getLocation();
|
||||
+
|
||||
+ ServerGamePacketListenerImpl connection = handle.connection;
|
||||
+ reregisterPlayer(handle);
|
||||
+
|
||||
+ //Respawn the player then update their position and selected slot
|
||||
+ 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(), java.util.Collections.emptySet(), 0, false));
|
||||
+ net.minecraft.server.MinecraftServer.getServer().getPlayerList().sendAllPlayerInfo(handle);
|
||||
+
|
||||
+ if (this.isOp()) {
|
||||
+ this.setOp(false);
|
||||
+ this.setOp(true);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public void removeDisconnectingPlayer(Player player) {
|
||||
this.hiddenPlayers.remove(player.getUniqueId());
|
Loading…
Add table
Add a link
Reference in a new issue