progress
This commit is contained in:
parent
d001eefd7e
commit
3c02c90f3e
23 changed files with 157 additions and 219 deletions
148
patches/server/0426-Add-villager-reputation-API.patch
Normal file
148
patches/server/0426-Add-villager-reputation-API.patch
Normal file
|
@ -0,0 +1,148 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Wed, 22 Apr 2020 23:29:20 +0200
|
||||
Subject: [PATCH] Add villager reputation API
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/entity/villager/ReputationConstructor.java b/src/main/java/com/destroystokyo/paper/entity/villager/ReputationConstructor.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0f10c333d88f2e1c56a6c7f22d421084adfd3789
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/entity/villager/ReputationConstructor.java
|
||||
@@ -0,0 +1,9 @@
|
||||
+package com.destroystokyo.paper.entity.villager;
|
||||
+// Must have own package due to package-level constructor.
|
||||
+
|
||||
+public final class ReputationConstructor {
|
||||
+ // Abuse the package-level constructor.
|
||||
+ public static Reputation construct(int[] values) {
|
||||
+ return new Reputation(values);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||
index 07ecb01d02f64e85d478995062a33b58c211ed7e..e316f83a7adc7bba06a6a3fdab55cc9c004cb835 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java
|
||||
@@ -29,7 +29,7 @@ import net.minecraft.util.VisibleForDebug;
|
||||
|
||||
public class GossipContainer {
|
||||
public static final int DISCARD_THRESHOLD = 2;
|
||||
- private final Map<UUID, GossipContainer.EntityGossips> gossips = Maps.newHashMap();
|
||||
+ private final Map<UUID, GossipContainer.EntityGossips> gossips = Maps.newHashMap(); public Map<UUID, GossipContainer.EntityGossips> getReputations() { return this.gossips; } // Paper - add getter for reputations
|
||||
|
||||
@VisibleForDebug
|
||||
public Map<UUID, Object2IntMap<GossipType>> getGossipEntries() {
|
||||
@@ -177,7 +177,7 @@ public class GossipContainer {
|
||||
return i > type.max ? Math.max(type.max, left) : i;
|
||||
}
|
||||
|
||||
- static class EntityGossips {
|
||||
+ public static class EntityGossips { // Paper - make public
|
||||
final Object2IntMap<GossipType> entries = new Object2IntOpenHashMap<>();
|
||||
|
||||
public int weightedValue(Predicate<GossipType> gossipTypeFilter) {
|
||||
@@ -228,6 +228,28 @@ public class GossipContainer {
|
||||
public void remove(GossipType gossipType) {
|
||||
this.entries.removeInt(gossipType);
|
||||
}
|
||||
+
|
||||
+ // Paper start - Add villager reputation API
|
||||
+ private static final com.destroystokyo.paper.entity.villager.ReputationType[] REPUTATION_TYPES = com.destroystokyo.paper.entity.villager.ReputationType.values();
|
||||
+ public com.destroystokyo.paper.entity.villager.Reputation getPaperReputation() {
|
||||
+ int[] reputation = new int[REPUTATION_TYPES.length];
|
||||
+ reputation[com.destroystokyo.paper.entity.villager.ReputationType.MAJOR_NEGATIVE.ordinal()] = entries.getOrDefault(GossipType.MAJOR_NEGATIVE, 0);
|
||||
+ reputation[com.destroystokyo.paper.entity.villager.ReputationType.MAJOR_POSITIVE.ordinal()] = entries.getOrDefault(GossipType.MAJOR_POSITIVE, 0);
|
||||
+ reputation[com.destroystokyo.paper.entity.villager.ReputationType.MINOR_NEGATIVE.ordinal()] = entries.getOrDefault(GossipType.MINOR_NEGATIVE, 0);
|
||||
+ reputation[com.destroystokyo.paper.entity.villager.ReputationType.MINOR_POSITIVE.ordinal()] = entries.getOrDefault(GossipType.MINOR_POSITIVE, 0);
|
||||
+ reputation[com.destroystokyo.paper.entity.villager.ReputationType.TRADING.ordinal()] = entries.getOrDefault(GossipType.TRADING, 0);
|
||||
+ return com.destroystokyo.paper.entity.villager.ReputationConstructor.construct(reputation);
|
||||
+ }
|
||||
+
|
||||
+ public void assignFromPaperReputation(com.destroystokyo.paper.entity.villager.Reputation rep) {
|
||||
+ int val;
|
||||
+ if ((val = rep.getReputation(com.destroystokyo.paper.entity.villager.ReputationType.MAJOR_NEGATIVE)) != 0) this.entries.put(GossipType.MAJOR_NEGATIVE, val);
|
||||
+ if ((val = rep.getReputation(com.destroystokyo.paper.entity.villager.ReputationType.MAJOR_POSITIVE)) != 0) this.entries.put(GossipType.MAJOR_POSITIVE, val);
|
||||
+ if ((val = rep.getReputation(com.destroystokyo.paper.entity.villager.ReputationType.MINOR_NEGATIVE)) != 0) this.entries.put(GossipType.MINOR_NEGATIVE, val);
|
||||
+ if ((val = rep.getReputation(com.destroystokyo.paper.entity.villager.ReputationType.MINOR_POSITIVE)) != 0) this.entries.put(GossipType.MINOR_POSITIVE, val);
|
||||
+ if ((val = rep.getReputation(com.destroystokyo.paper.entity.villager.ReputationType.TRADING)) != 0) this.entries.put(GossipType.TRADING, val);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
static class GossipEntry {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
index e99cdbb1d050288b5f1177737b242c331a989471..8508a3864fc3f8919f823d96f27061a6b3706713 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
||||
@@ -1065,6 +1065,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
||||
this.numberOfRestocksToday = 0;
|
||||
}
|
||||
|
||||
+ public GossipContainer getReputation() { return this.getGossips(); } // Paper - OBFHELPER
|
||||
public GossipContainer getGossips() {
|
||||
return this.gossips;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
|
||||
index 115f107ac100524ef0fcf8de0fc528d164c845f7..b15db2bf0a0bbe39b8067559fbf2b6bdadf56ca4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java
|
||||
@@ -16,6 +16,13 @@ import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.Villager.Profession;
|
||||
import org.bukkit.entity.Villager.Type;
|
||||
|
||||
+// Paper start
|
||||
+import com.destroystokyo.paper.entity.villager.Reputation;
|
||||
+import com.google.common.collect.Maps;
|
||||
+import java.util.Map;
|
||||
+import java.util.UUID;
|
||||
+// Paper end
|
||||
+
|
||||
public class CraftVillager extends CraftAbstractVillager implements Villager {
|
||||
|
||||
public CraftVillager(CraftServer server, net.minecraft.world.entity.npc.Villager entity) {
|
||||
@@ -125,4 +132,45 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
|
||||
public static VillagerProfession bukkitToNmsProfession(Profession bukkit) {
|
||||
return Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(bukkit.getKey()));
|
||||
}
|
||||
+
|
||||
+ // Paper start - Add villager reputation API
|
||||
+ @Override
|
||||
+ public Reputation getReputation(UUID uniqueId) {
|
||||
+ net.minecraft.world.entity.ai.gossip.GossipContainer.EntityGossips rep = getHandle().getReputation().getReputations().get(uniqueId);
|
||||
+ if (rep == null) {
|
||||
+ return new Reputation(Maps.newHashMap());
|
||||
+ }
|
||||
+
|
||||
+ return rep.getPaperReputation();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Map<UUID, Reputation> getReputations() {
|
||||
+ return getHandle().getReputation().getReputations().entrySet()
|
||||
+ .stream()
|
||||
+ .collect(java.util.stream.Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().getPaperReputation()));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setReputation(UUID uniqueId, Reputation reputation) {
|
||||
+ net.minecraft.world.entity.ai.gossip.GossipContainer.EntityGossips nmsReputation =
|
||||
+ getHandle().getReputation().getReputations().computeIfAbsent(
|
||||
+ uniqueId,
|
||||
+ key -> new net.minecraft.world.entity.ai.gossip.GossipContainer.EntityGossips()
|
||||
+ );
|
||||
+ nmsReputation.assignFromPaperReputation(reputation);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setReputations(Map<UUID, Reputation> reputations) {
|
||||
+ for (Map.Entry<UUID, Reputation> entry : reputations.entrySet()) {
|
||||
+ setReputation(entry.getKey(), entry.getValue());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void clearReputations() {
|
||||
+ getHandle().getReputation().getReputations().clear();
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
19
patches/server/0427-Fix-PotionEffect-ignores-icon-flag.patch
Normal file
19
patches/server/0427-Fix-PotionEffect-ignores-icon-flag.patch
Normal file
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: kickash32 <kickash32@gmail.com>
|
||||
Date: Fri, 8 May 2020 00:49:18 -0400
|
||||
Subject: [PATCH] Fix PotionEffect ignores icon flag
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index 76e9977f7b2f7fb50631fc56f3318d59d04b1398..a7a6757b83c94a0c0926097021015815f8f18b8e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -400,7 +400,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
|
||||
@Override
|
||||
public boolean addPotionEffect(PotionEffect effect, boolean force) {
|
||||
- this.getHandle().addEffect(new MobEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()), EntityPotionEffectEvent.Cause.PLUGIN);
|
||||
+ this.getHandle().addEffect(new MobEffectInstance(MobEffect.byId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles(), effect.hasIcon()), EntityPotionEffectEvent.Cause.PLUGIN); // Paper - Don't ignore icon
|
||||
return true;
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: virustotalop <virustotalop@gmail.com>
|
||||
Date: Thu, 16 Apr 2020 20:51:32 -0700
|
||||
Subject: [PATCH] Optimize brigadier child sorting performance
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/mojang/brigadier/tree/CommandNode.java b/src/main/java/com/mojang/brigadier/tree/CommandNode.java
|
||||
index b8d646864a24bba376661cfd87901012416c669d..aa3a1795850a419f624f14bd7c4daab0020779d0 100644
|
||||
--- a/src/main/java/com/mojang/brigadier/tree/CommandNode.java
|
||||
+++ b/src/main/java/com/mojang/brigadier/tree/CommandNode.java
|
||||
@@ -26,7 +26,7 @@ import java.util.stream.Collectors;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
|
||||
public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
|
||||
- private Map<String, CommandNode<S>> children = Maps.newLinkedHashMap();
|
||||
+ private Map<String, CommandNode<S>> children = Maps.newTreeMap(); //Paper - Switch to tree map for automatic sorting
|
||||
private Map<String, LiteralCommandNode<S>> literals = Maps.newLinkedHashMap();
|
||||
private Map<String, ArgumentCommandNode<S, ?>> arguments = Maps.newLinkedHashMap();
|
||||
private final Predicate<S> requirement;
|
||||
@@ -107,7 +107,7 @@ public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
|
||||
}
|
||||
}
|
||||
|
||||
- this.children = this.children.entrySet().stream().sorted(Map.Entry.comparingByValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
|
||||
+ // Paper - Remove manual sorting, it is no longer needed
|
||||
}
|
||||
|
||||
public void findAmbiguities(final AmbiguityConsumer<S> consumer) {
|
44
patches/server/0429-Potential-bed-API.patch
Normal file
44
patches/server/0429-Potential-bed-API.patch
Normal file
|
@ -0,0 +1,44 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: JRoy <joshroy126@gmail.com>
|
||||
Date: Sun, 10 May 2020 23:06:30 -0400
|
||||
Subject: [PATCH] Potential bed API
|
||||
|
||||
Adds a new method to fetch the location of a player's bed without generating any sync loads.
|
||||
|
||||
getPotentialBedLocation - Gets the last known location of a player's bed. This does not preform any check if the bed is still valid and does not load any chunks.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
||||
index 31b62dc1ee06b254c398cbfe157283fb199ef0fe..36ea76bfe0bd96ead82ed1ad34f25de10b7fa30e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundContainerClosePacket;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -125,6 +126,22 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
return this.getHandle().sleepCounter;
|
||||
}
|
||||
|
||||
+ // Paper start - Potential bed api
|
||||
+ @Override
|
||||
+ public Location getPotentialBedLocation() {
|
||||
+ ServerPlayer handle = (ServerPlayer) getHandle();
|
||||
+ BlockPos bed = handle.getRespawnPosition();
|
||||
+ if (bed == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ ServerLevel worldServer = handle.server.getLevel(handle.getRespawnDimension());
|
||||
+ if (worldServer == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ return new Location(worldServer.getWorld(), bed.getX(), bed.getY(), bed.getZ());
|
||||
+ }
|
||||
+ // Paper end
|
||||
@Override
|
||||
public boolean sleep(Location location, boolean force) {
|
||||
Preconditions.checkArgument(location != null, "Location cannot be null");
|
|
@ -0,0 +1,63 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 10 May 2020 22:16:17 -0400
|
||||
Subject: [PATCH] Wait for Async Tasks during shutdown
|
||||
|
||||
Server.reload() had this logic to give time for tasks to shutdown,
|
||||
however shutdown did not...
|
||||
|
||||
Adds a 5 second grace period for any async tasks to finish and warns
|
||||
if any are still running after that delay just as reload does.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index d7023cb0974f6c28a0fb8a0a6e5a6600fe30d3e3..11dbe48c8a8c29cd28d725c43505e326a6e626ff 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -945,6 +945,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// CraftBukkit start
|
||||
if (this.server != null) {
|
||||
this.server.disablePlugins();
|
||||
+ this.server.waitForAsyncTasksShutdown(); // Paper
|
||||
}
|
||||
// CraftBukkit end
|
||||
if (this.getConnection() != null) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 4d6a6583af73a25b5f2783ba56a63b8c9987c0a4..94670ec4de01341822f6affe0fa1c9774dd6131b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -937,6 +937,35 @@ public final class CraftServer implements Server {
|
||||
org.spigotmc.WatchdogThread.hasStarted = true; // Paper - Disable watchdog early timeout on reload
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public void waitForAsyncTasksShutdown() {
|
||||
+ int pollCount = 0;
|
||||
+
|
||||
+ // Wait for at most 5 seconds for plugins to close their threads
|
||||
+ while (pollCount < 10*5 && getScheduler().getActiveWorkers().size() > 0) {
|
||||
+ try {
|
||||
+ Thread.sleep(100);
|
||||
+ } catch (InterruptedException e) {}
|
||||
+ pollCount++;
|
||||
+ }
|
||||
+
|
||||
+ List<BukkitWorker> overdueWorkers = getScheduler().getActiveWorkers();
|
||||
+ for (BukkitWorker worker : overdueWorkers) {
|
||||
+ Plugin plugin = worker.getOwner();
|
||||
+ String author = "<NoAuthorGiven>";
|
||||
+ if (plugin.getDescription().getAuthors().size() > 0) {
|
||||
+ author = plugin.getDescription().getAuthors().get(0);
|
||||
+ }
|
||||
+ getLogger().log(Level.SEVERE, String.format(
|
||||
+ "Nag author: '%s' of '%s' about the following: %s",
|
||||
+ author,
|
||||
+ plugin.getDescription().getName(),
|
||||
+ "This plugin is not properly shutting down its async tasks when it is being shut down. This task may throw errors during the final shutdown logs and might not complete before process dies."
|
||||
+ ));
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public void reloadData() {
|
||||
ReloadCommand.reload(console);
|
|
@ -0,0 +1,28 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: kickash32 <kickash32@gmail.com>
|
||||
Date: Sat, 9 May 2020 02:01:48 -0400
|
||||
Subject: [PATCH] Ensure EntityRaider respects game and entity rules for
|
||||
picking up items
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
||||
index 37f4becb39d6d4c13aa0c3901ed123083518cdbf..49028fef0706a4413e446c337750f31e756e8de1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
||||
@@ -305,7 +305,7 @@ public abstract class Raider extends PatrollingMonster {
|
||||
|
||||
public class ObtainRaidLeaderBannerGoal<T extends Raider> extends Goal {
|
||||
|
||||
- private final T mob;
|
||||
+ private final T mob; private T getRaider() { return mob; } // Paper - obfhelper
|
||||
|
||||
public ObtainRaidLeaderBannerGoal(T entityraider) { // CraftBukkit - decompile error
|
||||
this.mob = entityraider;
|
||||
@@ -314,6 +314,7 @@ public abstract class Raider extends PatrollingMonster {
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
+ if (!getRaider().level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || !getRaider().canPickUpLoot()) return false; // Paper - respect game and entity rules for picking up items
|
||||
Raid raid = this.mob.getCurrentRaid();
|
||||
|
||||
if (this.mob.hasActiveRaid() && !this.mob.getCurrentRaid().isOver() && this.mob.canBeLeader() && !ItemStack.matches(this.mob.getItemBySlot(EquipmentSlot.HEAD), Raid.getLeaderBannerInstance())) {
|
|
@ -0,0 +1,173 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 13 May 2020 23:01:26 -0400
|
||||
Subject: [PATCH] Protect Bedrock and End Portal/Frames from being destroyed
|
||||
|
||||
This fixes exploits that let players destroy bedrock by Pistons, explosions
|
||||
and Mushrooom/Tree generation.
|
||||
|
||||
These blocks are designed to not be broken except by creative players/commands.
|
||||
So protect them from a multitude of methods of destroying them.
|
||||
|
||||
A config is provided if you rather let players use these exploits, and let
|
||||
them destroy the worlds End Portals and get on top of the nether easy.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
index 78271b400c79578d043b20a5389a37b1bef9a70d..5f3b0d95cc7e6a0434d78ea7305a70689c41c71c 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -416,4 +416,17 @@ public class PaperConfig {
|
||||
private static void midTickChunkTasks() {
|
||||
midTickChunkTasks = getInt("settings.chunk-tasks-per-tick", midTickChunkTasks);
|
||||
}
|
||||
+
|
||||
+ public static boolean allowBlockPermanentBreakingExploits = false;
|
||||
+ private static void allowBlockPermanentBreakingExploits() {
|
||||
+ if (config.contains("allow-perm-block-break-exploits")) {
|
||||
+ allowBlockPermanentBreakingExploits = config.getBoolean("allow-perm-block-break-exploits", false);
|
||||
+ config.set("allow-perm-block-break-exploits", null);
|
||||
+ }
|
||||
+
|
||||
+ config.set("settings.unsupported-settings.allow-permanent-block-break-exploits-readme", "This setting controls if players should be able to break bedrock, end portals and other intended to be permanent blocks.");
|
||||
+ allowBlockPermanentBreakingExploits = getBoolean("settings.unsupported-settings.allow-permanent-block-break-exploits", allowBlockPermanentBreakingExploits);
|
||||
+
|
||||
+ }
|
||||
+
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index cdf214fca3b0055efa56702470d9d2f890a8aead..a12af10e28f2d023ba6f916b5e7a53539416713f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -174,6 +174,7 @@ public class Explosion {
|
||||
for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
|
||||
BlockPos blockposition = new BlockPos(d4, d5, d6);
|
||||
BlockState iblockdata = this.level.getBlockState(blockposition);
|
||||
+ if (!iblockdata.isDestroyable()) continue; // Paper
|
||||
FluidState fluid = iblockdata.getFluidState(); // Paper
|
||||
|
||||
if (!this.level.isInWorldBounds(blockposition)) {
|
||||
@@ -332,7 +333,7 @@ public class Explosion {
|
||||
BlockState iblockdata = this.level.getBlockState(blockposition);
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
- if (!iblockdata.isAir()) {
|
||||
+ if (!iblockdata.isAir() && iblockdata.isDestroyable()) { // Paper
|
||||
BlockPos blockposition1 = blockposition.immutable();
|
||||
|
||||
this.level.getProfiler().push("explosion_blocks");
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 03271675b4997588bd8f6774856aef25cdd4fa05..581e7975c4bfcc902e262003843fe54212bc5b61 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -419,6 +419,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) {
|
||||
// CraftBukkit start - tree generation
|
||||
if (this.captureTreeGeneration) {
|
||||
+ // Paper start
|
||||
+ BlockState type = getBlockState(pos);
|
||||
+ if (!type.isDestroyable()) return false;
|
||||
+ // Paper end
|
||||
CraftBlockState blockstate = this.capturedBlockStates.get(pos);
|
||||
if (blockstate == null) {
|
||||
blockstate = CapturedBlockState.getTreeBlockState(this, pos, flags);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
index 27016f964d2f6458298a9052d031a44b3d9f5f4b..878cdfc49253e7916d038495f79fec7cce75aa50 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
@@ -91,6 +91,19 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
protected final StateDefinition<Block, BlockState> stateDefinition;
|
||||
private BlockState defaultBlockState;
|
||||
// Paper start
|
||||
+ public final boolean isDestroyable() {
|
||||
+ return com.destroystokyo.paper.PaperConfig.allowBlockPermanentBreakingExploits ||
|
||||
+ this != Blocks.BEDROCK &&
|
||||
+ this != Blocks.END_PORTAL_FRAME &&
|
||||
+ this != Blocks.END_PORTAL &&
|
||||
+ this != Blocks.END_GATEWAY &&
|
||||
+ this != Blocks.COMMAND_BLOCK &&
|
||||
+ this != Blocks.REPEATING_COMMAND_BLOCK &&
|
||||
+ this != Blocks.CHAIN_COMMAND_BLOCK &&
|
||||
+ this != Blocks.BARRIER &&
|
||||
+ this != Blocks.STRUCTURE_BLOCK &&
|
||||
+ this != Blocks.JIGSAW;
|
||||
+ }
|
||||
public co.aikar.timings.Timing timing;
|
||||
public co.aikar.timings.Timing getTiming() {
|
||||
if (timing == null) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
index c345bd7542f3ffa09719864887e1516f1182e7e3..44cc09006eac6315d167a2628857f9942eb1fc13 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
@@ -200,6 +200,12 @@ public class PistonBaseBlock extends DirectionalBlock {
|
||||
@Override
|
||||
public boolean triggerEvent(BlockState state, Level world, BlockPos pos, int type, int data) {
|
||||
Direction enumdirection = (Direction) state.getValue(PistonBaseBlock.FACING);
|
||||
+ // Paper start - prevent retracting when we're facing the wrong way (we were replaced before retraction could occur)
|
||||
+ Direction directionQueuedAs = Direction.from3DDataValue(data & 7); // Paper - copied from below
|
||||
+ if (!com.destroystokyo.paper.PaperConfig.allowBlockPermanentBreakingExploits && enumdirection != directionQueuedAs) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper end - prevent retracting when we're facing the wrong way
|
||||
|
||||
if (!world.isClientSide) {
|
||||
boolean flag = this.getNeighborSignal(world, pos, enumdirection);
|
||||
@@ -232,7 +238,7 @@ public class PistonBaseBlock extends DirectionalBlock {
|
||||
BlockState iblockdata1 = (BlockState) ((BlockState) Blocks.MOVING_PISTON.defaultBlockState().setValue(MovingPistonBlock.FACING, enumdirection)).setValue(MovingPistonBlock.TYPE, this.isSticky ? PistonType.STICKY : PistonType.DEFAULT);
|
||||
|
||||
world.setBlock(pos, iblockdata1, 20);
|
||||
- world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(pos, iblockdata1, (BlockState) this.defaultBlockState().setValue(PistonBaseBlock.FACING, Direction.from3DDataValue(data & 7)), enumdirection, false, true));
|
||||
+ world.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(pos, iblockdata1, (BlockState) this.defaultBlockState().setValue(PistonBaseBlock.FACING, Direction.from3DDataValue(data & 7)), enumdirection, false, true)); // Paper - diff on change
|
||||
world.blockUpdated(pos, iblockdata1.getBlock());
|
||||
iblockdata1.updateNeighbourShapes(world, pos, 2);
|
||||
if (this.isSticky) {
|
||||
@@ -261,7 +267,14 @@ public class PistonBaseBlock extends DirectionalBlock {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
- world.removeBlock(pos.relative(enumdirection), false);
|
||||
+ // Paper start - fix headless pistons breaking blocks
|
||||
+ BlockPos headPos = pos.relative(enumdirection);
|
||||
+ if (com.destroystokyo.paper.PaperConfig.allowBlockPermanentBreakingExploits || world.getBlockState(headPos) == Blocks.PISTON_HEAD.defaultBlockState().setValue(FACING, enumdirection)) { // double check to make sure we're not a headless piston.
|
||||
+ world.setAir(headPos, false);
|
||||
+ } else {
|
||||
+ ((ServerLevel)world).getChunkSource().blockChanged(headPos); // ... fix client desync
|
||||
+ }
|
||||
+ // Paper end - fix headless pistons breaking blocks
|
||||
}
|
||||
|
||||
world.playSound((Player) null, pos, SoundEvents.PISTON_CONTRACT, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.15F + 0.6F);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
index d99ca942f5885b4d9af054547832c05ddb5634eb..6d4ef15842c6bd230543de19dd1053a4fe6ad270 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
@@ -206,7 +206,7 @@ public abstract class BlockBehaviour {
|
||||
|
||||
@Deprecated
|
||||
public boolean canBeReplaced(BlockState state, BlockPlaceContext context) {
|
||||
- return this.material.isReplaceable() && (context.getItemInHand().isEmpty() || !context.getItemInHand().is(this.asItem()));
|
||||
+ return this.material.isReplaceable() && (context.getItemInHand().isEmpty() || !context.getItemInHand().is(this.asItem())) && (state.isDestroyable() || (context.getPlayer() != null && context.getPlayer().getAbilities().instabuild)); // Paper
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -656,7 +656,11 @@ public abstract class BlockBehaviour {
|
||||
public Block getBlock() {
|
||||
return (Block) this.owner;
|
||||
}
|
||||
-
|
||||
+ // Paper start
|
||||
+ public final boolean isDestroyable() {
|
||||
+ return getBlock().isDestroyable();
|
||||
+ }
|
||||
+ // Paper end
|
||||
public Material getMaterial() {
|
||||
return this.material;
|
||||
}
|
||||
@@ -754,7 +758,7 @@ public abstract class BlockBehaviour {
|
||||
}
|
||||
|
||||
public PushReaction getPistonPushReaction() {
|
||||
- return this.getBlock().getPistonPushReaction(this.asState());
|
||||
+ return !isDestroyable() ? PushReaction.BLOCK : this.getBlock().getPistonPushReaction(this.asState()); // Paper
|
||||
}
|
||||
|
||||
public boolean isSolidRender(BlockGetter world, BlockPos pos) {
|
|
@ -0,0 +1,50 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Mon, 27 Apr 2020 02:48:06 -0700
|
||||
Subject: [PATCH] Reduce MutableInt allocations from light engine
|
||||
|
||||
We can abuse the fact light is single threaded and share an instance
|
||||
per light engine instance
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/lighting/BlockLightEngine.java b/src/main/java/net/minecraft/world/level/lighting/BlockLightEngine.java
|
||||
index 729c4b1763a24bac3c0764bea505555a32e54f57..37d7165dfd17da03428f8dbbbf95aa8005be289c 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/lighting/BlockLightEngine.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/lighting/BlockLightEngine.java
|
||||
@@ -15,6 +15,7 @@ import org.apache.commons.lang3.mutable.MutableInt;
|
||||
public final class BlockLightEngine extends LayerLightEngine<BlockLightSectionStorage.BlockDataLayerStorageMap, BlockLightSectionStorage> {
|
||||
private static final Direction[] DIRECTIONS = Direction.values();
|
||||
private final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
|
||||
+ private final MutableInt mutableInt = new MutableInt(); // Paper
|
||||
|
||||
public BlockLightEngine(LightChunkGetter chunkProvider) {
|
||||
super(chunkProvider, LightLayer.BLOCK, new BlockLightSectionStorage(chunkProvider));
|
||||
@@ -44,7 +45,7 @@ public final class BlockLightEngine extends LayerLightEngine<BlockLightSectionSt
|
||||
if (direction == null) {
|
||||
return 15;
|
||||
} else {
|
||||
- MutableInt mutableInt = new MutableInt();
|
||||
+ //MutableInt mutableint = new MutableInt(); // Paper - share mutableint, single threaded
|
||||
BlockState blockState = this.getStateAndOpacity(targetId, mutableInt);
|
||||
if (mutableInt.getValue() >= 15) {
|
||||
return 15;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/lighting/SkyLightEngine.java b/src/main/java/net/minecraft/world/level/lighting/SkyLightEngine.java
|
||||
index 4252247acd5c71e46d90f454663a9737e22e2a61..d122475c1a9d340046c478087d3ff5bf1ff8932c 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/lighting/SkyLightEngine.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/lighting/SkyLightEngine.java
|
||||
@@ -14,6 +14,7 @@ import org.apache.commons.lang3.mutable.MutableInt;
|
||||
public final class SkyLightEngine extends LayerLightEngine<SkyLightSectionStorage.SkyDataLayerStorageMap, SkyLightSectionStorage> {
|
||||
private static final Direction[] DIRECTIONS = Direction.values();
|
||||
private static final Direction[] HORIZONTALS = new Direction[]{Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST};
|
||||
+ private final MutableInt mutableInt = new MutableInt(); // Paper
|
||||
|
||||
public SkyLightEngine(LightChunkGetter chunkProvider) {
|
||||
super(chunkProvider, LightLayer.SKY, new SkyLightSectionStorage(chunkProvider));
|
||||
@@ -25,7 +26,7 @@ public final class SkyLightEngine extends LayerLightEngine<SkyLightSectionStorag
|
||||
if (level >= 15) {
|
||||
return level;
|
||||
} else {
|
||||
- MutableInt mutableInt = new MutableInt();
|
||||
+ //MutableInt mutableint = new MutableInt(); // Paper - share mutableint, single threaded
|
||||
BlockState blockState = this.getStateAndOpacity(targetId, mutableInt);
|
||||
if (mutableInt.getValue() >= 15) {
|
||||
return 15;
|
|
@ -0,0 +1,61 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@spottedleaf.dev>
|
||||
Date: Mon, 27 Apr 2020 00:04:16 -0700
|
||||
Subject: [PATCH] Reduce allocation of Vec3D by entity tracker
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 18335e2c5c9e50a8ed31a3d2b585835bcc28bbe6..d8f99f7f5ca0e1dbbb9b760af3a4b4f9c52ef6c7 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -2102,9 +2102,14 @@ Sections go from 0..16. Now whenever a section is not empty, it can potentially
|
||||
public void updatePlayer(ServerPlayer player) {
|
||||
org.spigotmc.AsyncCatcher.catchOp("player tracker update"); // Spigot
|
||||
if (player != this.entity) {
|
||||
- Vec3 vec3d = player.position().subtract(this.entity.position()); // MC-155077, SPIGOT-5113
|
||||
+ // Paper start - remove allocation of Vec3D here
|
||||
+ //Vec3D vec3d = entityplayer.getPositionVector().d(this.tracker.getPositionVector()); // MC-155077, SPIGOT-5113
|
||||
+ double vec3d_dx = player.getX() - this.entity.getX();
|
||||
+ double vec3d_dy = player.getY() - this.entity.getY();
|
||||
+ double vec3d_dz = player.getZ() - this.entity.getZ();
|
||||
+ // Paper end - remove allocation of Vec3D here
|
||||
int i = Math.min(this.getEffectiveRange(), (ChunkMap.this.viewDistance - 1) * 16);
|
||||
- boolean flag = vec3d.x >= (double) (-i) && vec3d.x <= (double) i && vec3d.z >= (double) (-i) && vec3d.z <= (double) i && this.entity.broadcastToPlayer(player);
|
||||
+ boolean flag = vec3d_dx >= (double) (-i) && vec3d_dx <= (double) i && vec3d_dz >= (double) (-i) && vec3d_dz <= (double) i && this.entity.broadcastToPlayer(player); // Paper - remove allocation of Vec3D here
|
||||
|
||||
// CraftBukkit start - respect vanish API
|
||||
if (this.entity instanceof ServerPlayer) {
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index 6b492b72b177e3c58580561585609b176876acf1..8ea4209400489116823eced292d8cd9654a1c809 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -145,8 +145,12 @@ public class ServerEntity {
|
||||
++this.teleportDelay;
|
||||
i = Mth.floor(this.entity.getYRot() * 256.0F / 360.0F);
|
||||
j = Mth.floor(this.entity.getXRot() * 256.0F / 360.0F);
|
||||
- Vec3 vec3d = this.entity.position().subtract(ClientboundMoveEntityPacket.packetToEntity(this.xp, this.yp, this.zp));
|
||||
- boolean flag1 = vec3d.lengthSqr() >= 7.62939453125E-6D;
|
||||
+ // Paper start - reduce allocation of Vec3D here
|
||||
+ double vec3d_dx = this.entity.getX() - 2.44140625E-4D*(this.xp);
|
||||
+ double vec3d_dy = this.entity.getY() - 2.44140625E-4D*(this.yp);
|
||||
+ double vec3d_dz = this.entity.getZ() - 2.44140625E-4D*(this.zp);
|
||||
+ boolean flag1 = (vec3d_dx * vec3d_dx + vec3d_dy * vec3d_dy + vec3d_dz * vec3d_dz) >= 7.62939453125E-6D;
|
||||
+ // Paper end - reduce allocation of Vec3D here
|
||||
Packet<?> packet1 = null;
|
||||
boolean flag2 = flag1 || this.tickCount % 60 == 0;
|
||||
boolean flag3 = Math.abs(i - this.yRotp) >= 1 || Math.abs(j - this.xRotp) >= 1;
|
||||
@@ -163,9 +167,11 @@ public class ServerEntity {
|
||||
// CraftBukkit end
|
||||
|
||||
if (this.tickCount > 0 || this.entity instanceof AbstractArrow) {
|
||||
- long k = ClientboundMoveEntityPacket.entityToPacket(vec3d.x);
|
||||
- long l = ClientboundMoveEntityPacket.entityToPacket(vec3d.y);
|
||||
- long i1 = ClientboundMoveEntityPacket.entityToPacket(vec3d.z);
|
||||
+ // Paper start - remove allocation of Vec3D here
|
||||
+ long k = ClientboundMoveEntityPacket.entityToPacket(vec3d_dx);
|
||||
+ long l = ClientboundMoveEntityPacket.entityToPacket(vec3d_dy);
|
||||
+ long i1 = ClientboundMoveEntityPacket.entityToPacket(vec3d_dz);
|
||||
+ // Paper end - remove allocation of Vec3D here
|
||||
boolean flag4 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L;
|
||||
|
||||
if (!flag4 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.isOnGround()) {
|
26
patches/server/0435-Ensure-safe-gateway-teleport.patch
Normal file
26
patches/server/0435-Ensure-safe-gateway-teleport.patch
Normal file
|
@ -0,0 +1,26 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: kickash32 <kickash32@gmail.com>
|
||||
Date: Fri, 15 May 2020 01:10:03 -0400
|
||||
Subject: [PATCH] Ensure safe gateway teleport
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
||||
index 370ec4cd08a50ad0b8154db9afcaa76ec741dcb2..782becb96b6300f14deee360b653dc99c57fdc12 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
|
||||
@@ -105,7 +105,14 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity {
|
||||
List<Entity> list = world.getEntitiesOfClass(Entity.class, new AABB(pos), TheEndGatewayBlockEntity::canEntityTeleport);
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
- TheEndGatewayBlockEntity.teleportEntity(world, pos, state, (Entity) list.get(world.random.nextInt(list.size())), blockEntity);
|
||||
+ // Paper start
|
||||
+ for (Entity entity : list) {
|
||||
+ if (entity.canChangeDimensions()) {
|
||||
+ TheEndGatewayBlockEntity.teleportEntity(world, pos, state, entity, blockEntity);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
if (blockEntity.age % 2400L == 0L) {
|
|
@ -0,0 +1,61 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Sat, 16 May 2020 10:12:15 +0200
|
||||
Subject: [PATCH] Add option for console having all permissions
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
index 5f3b0d95cc7e6a0434d78ea7305a70689c41c71c..7f140333c2e62012fa572c1a061d84432426997f 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -429,4 +429,9 @@ public class PaperConfig {
|
||||
|
||||
}
|
||||
|
||||
+ public static boolean consoleHasAllPermissions = false;
|
||||
+ private static void consoleHasAllPermissions() {
|
||||
+ consoleHasAllPermissions = getBoolean("settings.console-has-all-permissions", consoleHasAllPermissions);
|
||||
+ }
|
||||
+
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java
|
||||
index a885eb537d6475eefe7d06f8312ecf0a278c5a00..4d95d4f4b354fc22c29c55bb70010282a4d3c5d9 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/command/CraftConsoleCommandSender.java
|
||||
@@ -86,5 +86,15 @@ public class CraftConsoleCommandSender extends ServerCommandSender implements Co
|
||||
public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) {
|
||||
this.sendRawMessage(org.bukkit.craftbukkit.util.CraftChatMessage.fromComponent(io.papermc.paper.adventure.PaperAdventure.asVanilla(message)));
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean hasPermission(String name) {
|
||||
+ return com.destroystokyo.paper.PaperConfig.consoleHasAllPermissions || super.hasPermission(name);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean hasPermission(org.bukkit.permissions.Permission perm) {
|
||||
+ return com.destroystokyo.paper.PaperConfig.consoleHasAllPermissions || super.hasPermission(perm);
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java
|
||||
index c2d163c078b569e3e97ee01d149c5c3e87f55513..d1ce98ca68690542c6864c189bc114f1f715b2b5 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/command/CraftRemoteConsoleCommandSender.java
|
||||
@@ -39,4 +39,16 @@ public class CraftRemoteConsoleCommandSender extends ServerCommandSender impleme
|
||||
public void setOp(boolean value) {
|
||||
throw new UnsupportedOperationException("Cannot change operator status of remote controller.");
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean hasPermission(String name) {
|
||||
+ return com.destroystokyo.paper.PaperConfig.consoleHasAllPermissions || super.hasPermission(name);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean hasPermission(org.bukkit.permissions.Permission perm) {
|
||||
+ return com.destroystokyo.paper.PaperConfig.consoleHasAllPermissions || super.hasPermission(perm);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 23 May 2020 01:31:06 -0400
|
||||
Subject: [PATCH] Fix Non Full Status Chunk NBT Memory Leak
|
||||
|
||||
Any full status chunk that was requested for any status less than full
|
||||
would hold onto their entire nbt tree and every variable in that function.
|
||||
|
||||
This was due to use of a lambda that persists on the Chunk object
|
||||
until that chunk reaches FULL status.
|
||||
|
||||
With introduction of no tick, we greatly increased the number of non
|
||||
full chunks so this was really starting to hurt.
|
||||
|
||||
We further improve it by making a copy of the nbt tag with only the memory
|
||||
it needs, so that we dont have to hold a copy to the entire compound.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
index 7c04aef3eac54981ca1e34cb87d97104c3c9685b..b4246524dd11ad1e1dc94c56eee966c5a54d9ecc 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
@@ -27,6 +27,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.LongArrayTag;
|
||||
import net.minecraft.nbt.ShortTag;
|
||||
+import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ThreadedLevelLightEngine;
|
||||
@@ -207,15 +208,9 @@ public class ChunkSerializer {
|
||||
object2 = protochunkticklist1;
|
||||
}
|
||||
|
||||
- object = new LevelChunk(world.getLevel(), pos, biomestorage, chunkconverter, (TickList) object1, (TickList) object2, k, achunksection, (chunk) -> {
|
||||
- ChunkSerializer.postLoadChunk(world, nbttagcompound1, chunk);
|
||||
- // CraftBukkit start - load chunk persistent data from nbt
|
||||
- net.minecraft.nbt.Tag persistentBase = nbttagcompound1.get("ChunkBukkitValues");
|
||||
- if (persistentBase instanceof CompoundTag) {
|
||||
- chunk.persistentDataContainer.putAll((CompoundTag) persistentBase);
|
||||
- }
|
||||
- // CraftBukkit end
|
||||
- });
|
||||
+ object = new LevelChunk(world.getLevel(), pos, biomestorage, chunkconverter, (TickList) object1, (TickList) object2, k, achunksection, // Paper start - fix massive nbt memory leak due to lambda. move lambda into a container method to not leak scope. Only clone needed NBT keys.
|
||||
+ createLoadEntitiesConsumer(new SafeNBTCopy(nbttagcompound1, "TileEntities", "Entities", "ChunkBukkitValues")) // Paper - move CB Chunk PDC into here
|
||||
+ );// Paper end
|
||||
} else {
|
||||
ProtoChunk protochunk = new ProtoChunk(pos, chunkconverter, achunksection, protochunkticklist, protochunkticklist1, world, world); // Paper - add level
|
||||
|
||||
@@ -321,6 +316,50 @@ public class ChunkSerializer {
|
||||
return new InProgressChunkHolder(protochunk1, tasksToExecuteOnMain); // Paper - Async chunk loading
|
||||
}
|
||||
}
|
||||
+ // Paper start
|
||||
+
|
||||
+ /**
|
||||
+ * This wrapper will error out if any key is accessed that wasn't copied so we can catch it easy on an update
|
||||
+ */
|
||||
+ private static class SafeNBTCopy extends CompoundTag {
|
||||
+ private final java.util.Set<String> keys = new java.util.HashSet<String>();
|
||||
+ public SafeNBTCopy(CompoundTag base, String... keys) {
|
||||
+ for (String key : keys) {
|
||||
+ this.keys.add(key);
|
||||
+ final Tag nbtBase = base.get(key);
|
||||
+ if (nbtBase != null) {
|
||||
+ this.put(key, nbtBase);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean contains(String key) {
|
||||
+ if (super.contains(key)) {
|
||||
+ return true;
|
||||
+ } else if (keys.contains(key)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ throw new IllegalStateException("Missing Key " + key + " in SafeNBTCopy");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean contains(String key, int type) {
|
||||
+ return contains(key) && super.contains(key, type);
|
||||
+ }
|
||||
+ }
|
||||
+ private static java.util.function.Consumer<LevelChunk> createLoadEntitiesConsumer(CompoundTag nbt) {
|
||||
+ return (chunk) -> {
|
||||
+ postLoadChunk(chunk.level, nbt, chunk);
|
||||
+ // CraftBukkit start - load chunk persistent data from nbt
|
||||
+ Tag persistentBase = nbt.get("ChunkBukkitValues");
|
||||
+ if (persistentBase instanceof CompoundTag) {
|
||||
+ chunk.persistentDataContainer.putAll((CompoundTag) persistentBase);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ };
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
// Paper start - async chunk save for unload
|
||||
public static final class AsyncSaveData {
|
Loading…
Add table
Add a link
Reference in a new issue