From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: YatopiaMC Date: Sun, 25 Oct 2020 12:23:35 -0500 Subject: [PATCH] Yatopia-Server-Fixes diff --git a/src/main/java/de/minebench/origami/OrigamiConfig.java b/src/main/java/de/minebench/origami/OrigamiConfig.java index fe7330fabe386966c2d203a190a00a785ea21be0..537456a7427cddd6783f5b5d8ee2d655668c4c53 100644 --- a/src/main/java/de/minebench/origami/OrigamiConfig.java +++ b/src/main/java/de/minebench/origami/OrigamiConfig.java @@ -16,7 +16,7 @@ public final class OrigamiConfig { private static final Object[] EMPTY = new Object[0]; private static File configFile; - private static YamlConfiguration config; + public static YamlConfiguration config; // Yatopia private static int configVersion; public static void init(final File file) { @@ -112,6 +112,28 @@ public final class OrigamiConfig { config.addDefault("worlds.default." + path, Double.valueOf(dfl)); return config.getDouble("worlds." + worldName + "." + path, config.getDouble("worlds.default." + path, dfl)); } + + public boolean tickEmptyHoppers = false; + public int fullHopperCooldown = 128; + private void hopperOptimizations() { + tickEmptyHoppers = getBoolean("tick-empty-hoppers", tickEmptyHoppers); + fullHopperCooldown = getInt("ticks-per.full-hopper-cooldown", fullHopperCooldown); + } + + public boolean fastFeatureSearchDontLoad = false; + private void fastFeatureSearchDontLoad() { + fastFeatureSearchDontLoad = getBoolean("fast-feature-search-dont-load", false); + } + + public boolean pigmenDontTargetUnlessHit = false; + private void pigmenDontTargetUnlessHit() { + pigmenDontTargetUnlessHit = getBoolean("pigmen.dont-target-unless-hit", pigmenDontTargetUnlessHit); + } + + public boolean disableObserverClocks = false; + private void observerClock() { + disableObserverClocks = getBoolean("disable-observer-clocks", disableObserverClocks); + } } } \ No newline at end of file diff --git a/src/main/java/de/minebench/origami/OrigamiConfig.java.rej b/src/main/java/de/minebench/origami/OrigamiConfig.java.rej deleted file mode 100644 index 02f5ccf54210776770d3215afb7c8e82f750d57e..0000000000000000000000000000000000000000 --- a/src/main/java/de/minebench/origami/OrigamiConfig.java.rej +++ /dev/null @@ -1,12 +0,0 @@ -diff a/src/main/java/de/minebench/origami/OrigamiConfig.java b/src/main/java/de/minebench/origami/OrigamiConfig.java (rejected hunks) -@@ -153,6 +153,10 @@ public final class OrigamiConfig { - public int getTickRate(String type, String typeName, String entityType, int def) { - return tickRates.getOrDefault(type + "." + entityType + "." + typeName, tickRates.getOrDefault(type + "." + typeName, def)); - } -+ public boolean pigmenDontTargetUnlessHit = false; -+ private void pigmenDontTargetUnlessHit() { -+ pigmenDontTargetUnlessHit = getBoolean("pigmen.dont-target-unless-hit", pigmenDontTargetUnlessHit); -+ } - public int pigmenPortalSpawn = 2000; - public double pigmenPortalBoost = 0.0; - public boolean pigmenFarmsWaterAi = false; diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java index e811295b4d6afcd920f60e0ce5440e43300d9085..d1064bd1c76eb23ce12e4a0703ce9f2622952897 100644 --- a/src/main/java/net/minecraft/server/BaseBlockPosition.java +++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java @@ -111,6 +111,7 @@ public class BaseBlockPosition implements Comparable { return this.distanceSquared((double) baseblockposition.getX(), (double) baseblockposition.getY(), (double) baseblockposition.getZ(), false) < d0 * d0; } + public final boolean distanceSquared(IPosition pos, double dist) { return a(pos, dist); } // Yatopia - OBFHELPER public boolean a(IPosition iposition, double d0) { return this.distanceSquared(iposition.getX(), iposition.getY(), iposition.getZ(), true) < d0 * d0; } diff --git a/src/main/java/net/minecraft/server/Behavior.java b/src/main/java/net/minecraft/server/Behavior.java index fb4a5ca220c9ef0916ecd4249a0ec7d1d8024ef1..899ca7bf676ccd874e317ba7e19b733fbf444baa 100644 --- a/src/main/java/net/minecraft/server/Behavior.java +++ b/src/main/java/net/minecraft/server/Behavior.java @@ -11,6 +11,7 @@ public abstract class Behavior { private long c; private final int d; private final int e; + co.aikar.timings.Timing timing; // Origami - behavior timing public Behavior(Map, MemoryStatus> map) { this(map, 60); @@ -25,6 +26,9 @@ public abstract class Behavior { this.d = i; this.e = j; this.a = map; + // Origami start - behavior timing + timing = co.aikar.timings.WorldTimingsHandler.getBehaviorTimings(getClass().getSimpleName()); + // Origami end } public Behavior.Status a() { diff --git a/src/main/java/net/minecraft/server/Behavior.java.rej b/src/main/java/net/minecraft/server/Behavior.java.rej deleted file mode 100644 index c3d129452b4f6ff2069bc066e594b1c632ceb0d4..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/Behavior.java.rej +++ /dev/null @@ -1,19 +0,0 @@ -diff a/src/main/java/net/minecraft/server/Behavior.java b/src/main/java/net/minecraft/server/Behavior.java (rejected hunks) -@@ -15,6 +15,7 @@ public abstract class Behavior { - private final String configKey; - private static final String RATE_TYPE = "behavior"; - // Origami end -+ co.aikar.timings.Timing timing; // Origami - behavior timing - - public Behavior(Map, MemoryStatus> map) { - this(map, 60); -@@ -37,6 +38,9 @@ public abstract class Behavior { - } - this.configKey = key; - // Origami end -+ // Origami start - behavior timing -+ timing = co.aikar.timings.WorldTimingsHandler.getBehaviorTimings(key); -+ // Origami end - } - - public Behavior.Status a() { diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java index 2291135eaef64c403183724cb6e413cd7e472672..6fcc7ed7c129e6a33386d65b37cbba4a44e96f0f 100644 --- a/src/main/java/net/minecraft/server/BlockPosition.java +++ b/src/main/java/net/minecraft/server/BlockPosition.java @@ -56,6 +56,12 @@ public class BlockPosition extends BaseBlockPosition { this(baseblockposition.getX(), baseblockposition.getY(), baseblockposition.getZ()); } + // Yatopia start - helper method + public BlockPosition(Entity entity) { + this(entity.locX(), entity.locY(), entity.locZ()); + } + // Yatopia end + public static long getAdjacent(int baseX, int baseY, int baseZ, EnumDirection enumdirection) { return asLong(baseX + enumdirection.getAdjacentX(), baseY + enumdirection.getAdjacentY(), baseZ + enumdirection.getAdjacentZ()); } // Paper public static long a(long i, EnumDirection enumdirection) { return a(i, enumdirection.getAdjacentX(), enumdirection.getAdjacentY(), enumdirection.getAdjacentZ()); diff --git a/src/main/java/net/minecraft/server/CommandDispatcher.java b/src/main/java/net/minecraft/server/CommandDispatcher.java index cabce1a8ba5db56495628edd9bc796aee7a53356..9754a9eac48c50efdefdceefbb4386bf0df583dd 100644 --- a/src/main/java/net/minecraft/server/CommandDispatcher.java +++ b/src/main/java/net/minecraft/server/CommandDispatcher.java @@ -107,6 +107,7 @@ public class CommandDispatcher { CommandIdleTimeout.a(this.b); CommandStop.a(this.b); CommandWhitelist.a(this.b); + net.pl3x.purpur.command.TPSBarCommand.register(getDispatcher()); // Purpur } if (commanddispatcher_servertype.d) { @@ -337,6 +338,7 @@ public class CommandDispatcher { } + public static LiteralArgumentBuilder literal(String s) { return a(s); } // Purpur - OBFHELPER public static LiteralArgumentBuilder a(String s) { return LiteralArgumentBuilder.literal(s); } @@ -356,6 +358,7 @@ public class CommandDispatcher { }; } + public com.mojang.brigadier.CommandDispatcher getDispatcher() { return a(); } // Purpur - OBFHELPER public com.mojang.brigadier.CommandDispatcher a() { return this.b; } diff --git a/src/main/java/net/minecraft/server/CommandDispatcher.java.rej b/src/main/java/net/minecraft/server/CommandDispatcher.java.rej deleted file mode 100644 index 7c1db96ec8692728e204a7d8490d74cf53b096a5..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/CommandDispatcher.java.rej +++ /dev/null @@ -1,9 +0,0 @@ -diff a/src/main/java/net/minecraft/server/CommandDispatcher.java b/src/main/java/net/minecraft/server/CommandDispatcher.java (rejected hunks) -@@ -109,6 +109,7 @@ public class CommandDispatcher { - CommandWhitelist.a(this.b); - net.pl3x.purpur.command.DemoCommand.register(getDispatcher()); // Purpur - net.pl3x.purpur.command.PingCommand.register(getDispatcher()); // Purpur -+ net.pl3x.purpur.command.TPSBarCommand.register(getDispatcher()); // Purpur - } - - if (commanddispatcher_servertype.d) { diff --git a/src/main/java/net/minecraft/server/CommandListenerWrapper.java b/src/main/java/net/minecraft/server/CommandListenerWrapper.java index 86f1cfe454ea0a989775b49a6b88375c766ef647..da53af61d1171db3c167c6e007adf95355771653 100644 --- a/src/main/java/net/minecraft/server/CommandListenerWrapper.java +++ b/src/main/java/net/minecraft/server/CommandListenerWrapper.java @@ -189,6 +189,7 @@ public class CommandListenerWrapper implements ICompletionProvider, com.destroys } } + public EntityPlayer getPlayerOrException() throws CommandSyntaxException { return h(); } // Purpur - OBFHELPER public EntityPlayer h() throws CommandSyntaxException { if (!(this.k instanceof EntityPlayer)) { throw CommandListenerWrapper.a.create(); diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 985d0d4aea2210e908ac76fbeafc0c895372aee7..d224b1d0e224853e825486559938aed2c56c3981 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -434,7 +434,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke public void setPosition(double d0, double d1, double d2) { this.setPositionRaw(d0, d1, d2); //this.a(this.size.a(d0, d1, d2)); // Paper - move into setPositionRaw - if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit + if (valid && !dead) ((WorldServer) world).chunkCheck(this); // CraftBukkit // Purpur } protected void af() { diff --git a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java index 171e8553a339eb3c995369f274de86b824183ca6..4103f3c39e2ed7466824e8fecbb8d21b515b5f01 100644 --- a/src/main/java/net/minecraft/server/EntityVillager.java +++ b/src/main/java/net/minecraft/server/EntityVillager.java @@ -92,6 +92,13 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation return behaviorcontroller; } + // Purpur start + @Override + public boolean a(EntityHuman entityhuman) { + return world.purpurConfig.villagerCanBeLeashed && !this.isLeashed(); + } + // Purpur end + public void c(WorldServer worldserver) { BehaviorController behaviorcontroller = this.getBehaviorController(); diff --git a/src/main/java/net/minecraft/server/EntityVillager.java.rej b/src/main/java/net/minecraft/server/EntityVillager.java.rej deleted file mode 100644 index 538b2c92e050176a1ac0bb4c2315f5b22c7f8eac..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/EntityVillager.java.rej +++ /dev/null @@ -1,13 +0,0 @@ -diff a/src/main/java/net/minecraft/server/EntityVillager.java b/src/main/java/net/minecraft/server/EntityVillager.java (rejected hunks) -@@ -79,6 +79,11 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation - protected void initPathfinder() { - if (world.purpurConfig.villagerFollowEmeraldBlock) this.goalSelector.a(3, new PathfinderGoalTempt(this, 1.0D, false, TEMPT_ITEMS)); - } -+ -+ @Override -+ public boolean a(EntityHuman entityhuman) { -+ return world.purpurConfig.villagerCanBeLeashed && !this.isLeashed(); -+ } - // Purpur end - - @Override diff --git a/src/main/java/net/minecraft/server/IProjectile.java b/src/main/java/net/minecraft/server/IProjectile.java index 9f5ce64a60fe7c312399ee416b11b84213dd3bee..64c08d830c358247186cf4e5fcf2010ed43f0f02 100644 --- a/src/main/java/net/minecraft/server/IProjectile.java +++ b/src/main/java/net/minecraft/server/IProjectile.java @@ -13,6 +13,7 @@ public abstract class IProjectile extends Entity { private UUID shooter; private int c; private boolean d; + public int despawnCounter; // Purpur - moved from EntityArrow IProjectile(EntityTypes entitytypes, World world) { super(entitytypes, world); @@ -27,6 +28,19 @@ public abstract class IProjectile extends Entity { } + // Purpur start + protected final void tickDespawnCounter() { + if (this.getPurpurDespawnRate() != -1) { + ++this.despawnCounter; + if (this.despawnCounter >= this.getPurpurDespawnRate()) { + this.die(); + } + } + } + + protected abstract int getPurpurDespawnRate(); + // Purpur end + @Nullable public Entity getShooter() { // Paper start - MC-50319 - shooter might be in another world (arrows through portals) @@ -72,6 +86,12 @@ public abstract class IProjectile extends Entity { } super.tick(); + + // Purpur start + if (!(this instanceof EntityArrow)) { + this.tickDespawnCounter(); + } + // Purpur end } private boolean h() { diff --git a/src/main/java/net/minecraft/server/IProjectile.java.rej b/src/main/java/net/minecraft/server/IProjectile.java.rej deleted file mode 100644 index f9080f6f15f51ac6ce521f062010d4485fb97524..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/IProjectile.java.rej +++ /dev/null @@ -1,40 +0,0 @@ -diff a/src/main/java/net/minecraft/server/IProjectile.java b/src/main/java/net/minecraft/server/IProjectile.java (rejected hunks) -@@ -13,11 +13,25 @@ public abstract class IProjectile extends Entity { - private UUID shooter; - private int c; - private boolean d; public boolean leftOwner() { return d; } public void setLeftOwner(boolean leftOwner) { this.d = leftOwner; } // Purpur - OBFHELPER -+ public int despawnCounter; // Purpur - moved from EntityArrow - - IProjectile(EntityTypes entitytypes, World world) { - super(entitytypes, world); - } - -+ // Purpur start -+ protected final void tickDespawnCounter() { -+ if (this.getPurpurDespawnRate() != -1) { -+ ++this.despawnCounter; -+ if (this.despawnCounter >= this.getPurpurDespawnRate()) { -+ this.die(); -+ } -+ } -+ } -+ -+ protected abstract int getPurpurDespawnRate(); -+ // Purpur end -+ - public void setShooter(@Nullable Entity entity) { - if (entity != null) { - this.shooter = entity.getUniqueID(); -@@ -72,6 +86,12 @@ public abstract class IProjectile extends Entity { - } - - super.tick(); -+ -+ // Purpur start -+ if (!(this instanceof EntityArrow)) { // EntityArrow handles its own despawn counter -+ this.tickDespawnCounter(); -+ } -+ // Purpur end - } - - public boolean checkIfLeftOwner() { return this.h(); } // Purpur - OBFHELPER diff --git a/src/main/java/net/minecraft/server/StructureGenerator.java b/src/main/java/net/minecraft/server/StructureGenerator.java index a62c87bceab2c9700a7b3925f208b0ffa2b9b393..1a6c593f5f20fb3a8e87ccb70cd3de7f0dcb0327 100644 --- a/src/main/java/net/minecraft/server/StructureGenerator.java +++ b/src/main/java/net/minecraft/server/StructureGenerator.java @@ -151,6 +151,11 @@ public abstract class StructureGenerator } } // Paper end + // Origami start - seed based feature search doesn't load + if (iworldreader instanceof World && ((World) iworldreader).origamiConfig.fastFeatureSearchDontLoad) { + return chunkcoordintpair.l(); + } + // Origami end IChunkAccess ichunkaccess = iworldreader.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z, ChunkStatus.STRUCTURE_STARTS); StructureStart structurestart = structuremanager.a(SectionPosition.a(ichunkaccess.getPos(), 0), this, ichunkaccess); diff --git a/src/main/java/net/minecraft/server/StructureGenerator.java.rej b/src/main/java/net/minecraft/server/StructureGenerator.java.rej deleted file mode 100644 index dd52a8fe4fd46e57a5d1af49ba1965a483cf4fcc..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/StructureGenerator.java.rej +++ /dev/null @@ -1,13 +0,0 @@ -diff a/src/main/java/net/minecraft/server/StructureGenerator.java b/src/main/java/net/minecraft/server/StructureGenerator.java (rejected hunks) -@@ -151,6 +151,11 @@ public abstract class StructureGenerator - } - } - // Paper end -+ // Origami start - seed based feature search doesn't load -+ if (iworldreader instanceof World && ((World) iworldreader).origamiConfig.fastFeatureSearchDontLoad) { -+ return chunkcoordintpair.l(); -+ } -+ // Origami end - // Origami start - option to only find generated features to not generate new chunks - IChunkAccess ichunkaccess = iworldreader.getChunkAt(chunkcoordintpair.x, chunkcoordintpair.z, ChunkStatus.STRUCTURE_STARTS, !(iworldreader instanceof World) || !((World) iworldreader).origamiConfig.onlyFindGeneratedFeatures); - if (ichunkaccess == null) { diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 07d47ad2362c5ebfa7993262a8faed240cc21717..107d7ac761bfb7667dfab88b31712e2061a46258 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -96,6 +96,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { public final com.tuinity.tuinity.config.TuinityConfig.WorldConfig tuinityConfig; // Tuinity - Server Config public final net.pl3x.purpur.PurpurWorldConfig purpurConfig; // Purpur + public final de.minebench.origami.OrigamiConfig.WorldConfig origamiConfig; // Origami - World config public final co.aikar.timings.WorldTimingsHandler timings; // Paper public static BlockPosition lastPhysicsProblem; // Spigot @@ -157,6 +158,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(((WorldDataServer) worlddatamutable).getName(), this.spigotConfig); // Paper this.tuinityConfig = new com.tuinity.tuinity.config.TuinityConfig.WorldConfig(((WorldDataServer)worlddatamutable).getName()); // Tuinity - Server Config this.purpurConfig = new net.pl3x.purpur.PurpurWorldConfig((((WorldDataServer)worlddatamutable).getName())); // Purpur + this.origamiConfig = new de.minebench.origami.OrigamiConfig.WorldConfig(((WorldDataServer)worlddatamutable).getName()); // Origami this.chunkPacketBlockController = this.paperConfig.antiXray ? new ChunkPacketBlockControllerAntiXray(this, executor) : ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray this.generator = gen; this.world = new CraftWorld((WorldServer) this, gen, env); diff --git a/src/main/java/net/minecraft/server/World.java.rej b/src/main/java/net/minecraft/server/World.java.rej deleted file mode 100644 index 313aa8f7d47c53a6a0130994c9d61d7c073c95c6..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/World.java.rej +++ /dev/null @@ -1,18 +0,0 @@ -diff a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java (rejected hunks) -@@ -94,6 +94,8 @@ public abstract class World implements GeneratorAccess, AutoCloseable { - public final com.destroystokyo.paper.PaperWorldConfig paperConfig; // Paper - public final ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray - -+ public final de.minebench.origami.OrigamiConfig.WorldConfig origamiConfig; // Origami - World Config -+ - public final co.aikar.timings.WorldTimingsHandler timings; // Paper - public static BlockPosition lastPhysicsProblem; // Spigot - private org.spigotmc.TickLimiter entityLimiter; -@@ -124,6 +126,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { - protected World(WorldDataMutable worlddatamutable, ResourceKey resourcekey, final DimensionManager dimensionmanager, Supplier supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env, java.util.concurrent.Executor executor) { // Paper - this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((WorldDataServer) worlddatamutable).getName()); // Spigot - this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig((((WorldDataServer)worlddatamutable).getName()), this.spigotConfig); // Paper -+ this.origamiConfig = new de.minebench.origami.OrigamiConfig.WorldConfig(((WorldDataServer)worlddatamutable).getName()); // Origami - World Config - this.chunkPacketBlockController = this.paperConfig.antiXray ? new ChunkPacketBlockControllerAntiXray(this, executor) : ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray - this.generator = gen; - this.world = new CraftWorld((WorldServer) this, gen, env); diff --git a/src/main/java/net/minecraft/server/WorldNBTStorage.java b/src/main/java/net/minecraft/server/WorldNBTStorage.java index b5cf60495b85c6ae6c32ee8a1c65d80e59fdce3d..1f77b251d7e7b0f023793cbf0876fc067caa75c1 100644 --- a/src/main/java/net/minecraft/server/WorldNBTStorage.java +++ b/src/main/java/net/minecraft/server/WorldNBTStorage.java @@ -49,7 +49,8 @@ public class WorldNBTStorage { File file = new File(this.playerDir, entityhuman.getUniqueIDString() + ".dat"); // Spigot Start boolean usingWrongFile = false; - if ( org.bukkit.Bukkit.getOnlineMode() && !file.exists() ) // Paper - Check online mode first + boolean normalFile = file.exists() && file.isFile(); // Akarin - ensures normal file + if ( org.bukkit.Bukkit.getOnlineMode() && !normalFile ) // Paper - Check online mode first // Akarin - ensures normal file { file = new File( this.playerDir, java.util.UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + entityhuman.getName() ).getBytes( "UTF-8" ) ).toString() + ".dat"); if ( file.exists() ) @@ -60,7 +61,7 @@ public class WorldNBTStorage { } // Spigot End - if (file.exists() && file.isFile()) { + if (normalFile) { // Akarin - avoid double I/O operation nbttagcompound = NBTCompressedStreamTools.a(file); } // Spigot Start diff --git a/src/main/java/net/minecraft/server/WorldNBTStorage.java.rej b/src/main/java/net/minecraft/server/WorldNBTStorage.java.rej deleted file mode 100644 index 39dce006ebf2bd81a9d6c62c25eb9bd55d24199e..0000000000000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/WorldNBTStorage.java.rej +++ /dev/null @@ -1,20 +0,0 @@ -diff a/src/main/java/net/minecraft/server/WorldNBTStorage.java b/src/main/java/net/minecraft/server/WorldNBTStorage.java (rejected hunks) -@@ -165,7 +165,8 @@ public class WorldNBTStorage implements IPlayerFileData { - File file = new File(this.playerDir, entityhuman.getUniqueIDString() + ".dat"); - // Spigot Start - boolean usingWrongFile = false; -- if ( org.bukkit.Bukkit.getOnlineMode() && !file.exists() ) // Paper - Check online mode first -+ boolean normalFile = file.exists() && file.isFile(); // Akarin - ensures normal file -+ if ( org.bukkit.Bukkit.getOnlineMode() && !normalFile ) // Paper - Check online mode first // Akarin - ensures normal file - { - file = new File( this.playerDir, UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + entityhuman.getName() ).getBytes( "UTF-8" ) ).toString() + ".dat"); - if ( file.exists() ) -@@ -176,7 +177,7 @@ public class WorldNBTStorage implements IPlayerFileData { - } - // Spigot End - -- if (file.exists() && file.isFile()) { -+ if (normalFile) { // Akarin - avoid double I/O operation - nbttagcompound = NBTCompressedStreamTools.a((InputStream) (new FileInputStream(file))); - } - // Spigot Start diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java index f5c827f7427e7b743e8ec2adbcbc478735d028d4..718528409154348733166240478e9d577aa87b6e 100644 --- a/src/main/java/net/pl3x/purpur/PurpurConfig.java +++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java @@ -1,5 +1,6 @@ package net.pl3x.purpur; +import com.destroystokyo.paper.PaperConfig; import com.google.common.base.Throwables; import net.minecraft.server.MinecraftServer; import net.pl3x.purpur.command.PurpurCommand; @@ -129,11 +130,6 @@ public class PurpurConfig { return config.getString(path, config.getString(path)); } - public static String timingsUrl = "https://timings.pl3x.net"; - private static void timingsSettings() { - timingsUrl = getString("settings.timings.url", timingsUrl); - } - public static double laggingThreshold = 19.0D; private static void tickLoopSettings() { laggingThreshold = getDouble("settings.lagging-threshold", laggingThreshold); @@ -162,4 +158,35 @@ public class PurpurConfig { InventoryType.ENDER_CHEST.setDefaultSize(enderChestSixRows ? 54 : 27); enderChestPermissionRows = getBoolean("settings.blocks.ender_chest.use-permissions-for-rows", enderChestPermissionRows); } + + public static boolean dontSendUselessEntityPackets = false; + private static void dontSendUselessEntityPackets() { + dontSendUselessEntityPackets = getBoolean("settings.dont-send-useless-entity-packets", dontSendUselessEntityPackets); + } + + public static boolean allowInfinityMending = false; + private static void enchantmentSettings() { + if (version < 5) { + boolean oldValue = getBoolean("settings.enchantment.allow-infinite-and-mending-together", false); + set("settings.enchantment.allow-infinity-and-mending-together", oldValue); + set("settings.enchantment.allow-infinite-and-mending-together", null); + } + allowInfinityMending = getBoolean("settings.enchantment.allow-infinity-and-mending-together", allowInfinityMending); + } + + public static boolean useHexColorsInConsole = true; + private static void loggerSettings() { + useHexColorsInConsole = getBoolean("settings.logger.hex-color-support-in-console", useHexColorsInConsole); + } + + private static void migrateDisableProjectileSaving() { + if (PurpurConfig.version < 6) { + final boolean saveProjectilesToDisk = getBoolean("world-settings.default.gameplay-mechanics.save-projectiles-to-disk", true); + set("world-settings.default.gameplay-mechanics.save-projectiles-to-disk", null); + if (!saveProjectilesToDisk) { + PaperConfig.config.set("world-settings.default.projectile-load-save-per-chunk-limit", 0); + PaperConfig.saveConfig(); + } + } + } } diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java.rej b/src/main/java/net/pl3x/purpur/PurpurConfig.java.rej deleted file mode 100644 index ccee2c7ae135a3a532f76b44d7d3ad6db7e8c387..0000000000000000000000000000000000000000 --- a/src/main/java/net/pl3x/purpur/PurpurConfig.java.rej +++ /dev/null @@ -1,27 +0,0 @@ -diff a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java (rejected hunks) -@@ -1,6 +1,7 @@ - package net.pl3x.purpur; - - import co.aikar.timings.TimingsManager; -+import com.destroystokyo.paper.PaperConfig; - import com.google.common.base.Throwables; - import net.minecraft.server.MinecraftServer; - import net.pl3x.purpur.command.PurpurCommand; -@@ -130,6 +131,17 @@ public class PurpurConfig { - return config.getString(path, config.getString(path)); - } - -+ private static void migrateDisableProjectileSaving() { -+ if (PurpurConfig.version < 6) { -+ final boolean saveProjectilesToDisk = getBoolean("world-settings.default.gameplay-mechanics.save-projectiles-to-disk", true); -+ set("world-settings.default.gameplay-mechanics.save-projectiles-to-disk", null); -+ if (!saveProjectilesToDisk) { -+ PaperConfig.config.set("world-settings.default.projectile-load-save-per-chunk-limit", 0); -+ PaperConfig.saveConfig(); -+ } -+ } -+ } -+ - public static String afkBroadcastAway = "§e§o%s is now AFK"; - public static String afkBroadcastBack = "§e§o%s is no longer AFK"; - public static String afkTabListPrefix = "[AFK] "; diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java index 361f7857e461578e90cb71e15027dadaf794cb69..5f0491a7cd6bb7e94cc5652be24d9bc111bb8035 100644 --- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java +++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java @@ -1,7 +1,15 @@ package net.pl3x.purpur; +import com.destroystokyo.paper.PaperConfig; +import java.util.ArrayList; +import java.util.HashSet; import org.bukkit.configuration.ConfigurationSection; import java.util.List; +import java.util.Set; +import net.minecraft.server.Block; +import net.minecraft.server.IRegistry; +import net.minecraft.server.MinecraftKey; + import static net.pl3x.purpur.PurpurConfig.log; public class PurpurWorldConfig { @@ -56,4 +64,167 @@ public class PurpurWorldConfig { PurpurConfig.config.addDefault("world-settings.default." + path, def); return PurpurConfig.config.getString("world-settings." + worldName + "." + path, PurpurConfig.config.getString("world-settings.default." + path)); } + + public int villagerBrainTicks = 1; + public boolean villagerUseBrainTicksOnlyWhenLagging = true; + public boolean villagerCanBeLeashed = false; + private void villagerSettings() { + villagerBrainTicks = getInt("mobs.villager.brain-ticks", villagerBrainTicks); + villagerUseBrainTicksOnlyWhenLagging = getBoolean("mobs.villager.use-brain-ticks-only-when-lagging", villagerUseBrainTicksOnlyWhenLagging); + villagerCanBeLeashed = getBoolean("mobs.villager.can-be-leashed", villagerCanBeLeashed); + } + + public boolean villagerTraderCanBeLeashed = false; + private void villagerTraderSettings() { + villagerTraderCanBeLeashed = getBoolean("mobs.wandering_trader.can-be-leashed", villagerTraderCanBeLeashed); + } + + public boolean milkCuresBadOmen = true; + public boolean persistentTileEntityDisplayNames = false; + private void miscGameplayMechanicsSettings() { + milkCuresBadOmen = getBoolean("gameplay-mechanics.milk-cures-bad-omen", milkCuresBadOmen); + persistentTileEntityDisplayNames = getBoolean("gameplay-mechanics.persistent-tileentity-display-names-and-lore", persistentTileEntityDisplayNames); + } + + public boolean anvilAllowColors = false; + private void anvilSettings() { + anvilAllowColors = getBoolean("blocks.anvil.allow-colors", anvilAllowColors); + } + + public int cowFeedMushrooms = 0; + private void cowSettings() { + cowFeedMushrooms = getInt("mobs.cow.feed-mushrooms-for-mooshroom", cowFeedMushrooms); + } + + public boolean snowGolemDropsPumpkin = false; + public boolean snowGolemPutPumpkinBack = false; + private void snowGolemSettings() { + snowGolemDropsPumpkin = getBoolean("mobs.snow_golem.drop-pumpkin-when-sheared", snowGolemDropsPumpkin); + snowGolemPutPumpkinBack = getBoolean("mobs.snow_golem.pumpkin-can-be-added-back", snowGolemPutPumpkinBack); + } + + public boolean farmlandGetsMoistFromBelow = false; + private void farmlandSettings() { + farmlandGetsMoistFromBelow = getBoolean("blocks.farmland.gets-moist-from-below", farmlandGetsMoistFromBelow); + } + + public int entityLifeSpan = 0; + private void entitySettings() { + entityLifeSpan = getInt("gameplay-mechanics.entity-lifespan", entityLifeSpan); + } + + public boolean squidImmuneToEAR = true; + public double squidOffsetWaterCheck = 0.0D; + private void squidSettings() { + squidImmuneToEAR = getBoolean("mobs.squid.immune-to-EAR", squidImmuneToEAR); + squidOffsetWaterCheck = getDouble("mobs.squid.water-offset-check", squidOffsetWaterCheck); + } + + public Set noTickBlocks = new HashSet<>(); + private void noTickBlocks() { + getList("blocks.no-tick", new ArrayList<>()).forEach(key -> { + Block block = IRegistry.BLOCK.get(new MinecraftKey(key.toString())); + if (!block.getBlockData().isAir()) { + noTickBlocks.add(block); + } + }); + } + + public boolean dolphinDisableTreasureSearching = false; + private void dolphinSettings() { + dolphinDisableTreasureSearching = getBoolean("mobs.dolphin.disable-treasure-searching", dolphinDisableTreasureSearching); + } + + public boolean turtleEggsBreakFromExpOrbs = true; + public boolean turtleEggsBreakFromItems = true; + public boolean turtleEggsBreakFromMinecarts = true; + private void turtleEggSettings() { + turtleEggsBreakFromExpOrbs = getBoolean("blocks.turtle_egg.break-from-exp-orbs", turtleEggsBreakFromExpOrbs); + turtleEggsBreakFromItems = getBoolean("blocks.turtle_egg.break-from-items", turtleEggsBreakFromItems); + turtleEggsBreakFromMinecarts = getBoolean("blocks.turtle_egg.break-from-minecarts", turtleEggsBreakFromMinecarts); + } + + public int dragonFireballDespawnRate = -1; + public int eggDespawnRate = -1; + public int enderPearlDespawnRate = -1; + public int expBottleDespawnRate = -1; + public int fireworkDespawnRate = -1; + public int fishingHookDespawnRate = -1; + public int largeFireballDespawnRate = -1; + public int llamaSpitDespawnRate = -1; + public int potionDespawnRate = -1; + public int shulkerBulletDespawnRate = -1; + public int smallFireballDespawnRate = -1; + public int snowballDespawnRate = -1; + public int witherSkullDespawnRate = -1; + private void projectileDespawnRateSettings() { + dragonFireballDespawnRate = getInt("gameplay-mechanics.projectile-despawn-rates.dragon_fireball", dragonFireballDespawnRate); + eggDespawnRate = getInt("gameplay-mechanics.projectile-despawn-rates.egg", eggDespawnRate); + enderPearlDespawnRate = getInt("gameplay-mechanics.projectile-despawn-rates.ender_pearl", enderPearlDespawnRate); + expBottleDespawnRate = getInt("gameplay-mechanics.projectile-despawn-rates.experience_bottle", expBottleDespawnRate); + fireworkDespawnRate = getInt("gameplay-mechanics.projectile-despawn-rates.firework_rocket", fireworkDespawnRate); + fishingHookDespawnRate = getInt("gameplay-mechanics.projectile-despawn-rates.fishing_bobber", fishingHookDespawnRate); + largeFireballDespawnRate = getInt("gameplay-mechanics.projectile-despawn-rates.fireball", largeFireballDespawnRate); + llamaSpitDespawnRate = getInt("gameplay-mechanics.projectile-despawn-rates.llama_spit", llamaSpitDespawnRate); + potionDespawnRate = getInt("gameplay-mechanics.projectile-despawn-rates.potion", potionDespawnRate); + shulkerBulletDespawnRate = getInt("gameplay-mechanics.projectile-despawn-rates.shulker_bullet", shulkerBulletDespawnRate); + smallFireballDespawnRate = getInt("gameplay-mechanics.projectile-despawn-rates.small_fireball", smallFireballDespawnRate); + snowballDespawnRate = getInt("gameplay-mechanics.projectile-despawn-rates.snowball", snowballDespawnRate); + witherSkullDespawnRate = getInt("gameplay-mechanics.projectile-despawn-rates.wither_skull", witherSkullDespawnRate); + } + + public boolean infinityWorksWithNormalArrows = true; + public boolean infinityWorksWithSpectralArrows = false; + public boolean infinityWorksWithTippedArrows = false; + private void infinityArrowsSettings() { + infinityWorksWithNormalArrows = getBoolean("gameplay-mechanics.infinity-bow.normal-arrows", infinityWorksWithNormalArrows); + infinityWorksWithSpectralArrows = getBoolean("gameplay-mechanics.infinity-bow.spectral-arrows", infinityWorksWithSpectralArrows); + infinityWorksWithTippedArrows = getBoolean("gameplay-mechanics.infinity-bow.tipped-arrows", infinityWorksWithTippedArrows); + } + + public boolean signAllowColors = false; + public boolean signRightClickEdit = false; + private void signSettings() { + signAllowColors = getBoolean("blocks.sign.allow-colors", signAllowColors); + signRightClickEdit = getBoolean("blocks.sign.right-click-edit", signRightClickEdit); + } + + private void migrateDisableProjectileSaving() { + if (PurpurConfig.version < 6) { + final boolean saveProjectilesToDisk = PurpurConfig.config.getBoolean("world-settings." + worldName + ".gameplay-mechanics.save-projectiles-to-disk", true); + set("gameplay-mechanics.save-projectiles-to-disk", null); + if (!saveProjectilesToDisk) { + PaperConfig.config.set("world-settings." + worldName + ".projectile-load-save-per-chunk-limit", 0); + PaperConfig.saveConfig(); + } + } + } + + public int bambooMaxHeight = 16; + public int bambooSmallHeight = 10; + private void bambooSettings() { + bambooMaxHeight = getInt("blocks.bamboo.max-height", bambooMaxHeight); + bambooSmallHeight = getInt("blocks.bamboo.small-height", bambooSmallHeight); + } + + public double twistingVinesGrowthModifier = 0.10D; + private void twistingVinesSettings() { + twistingVinesGrowthModifier = getDouble("blocks.twisting_vines.growth-modifier", twistingVinesGrowthModifier); + } + + public double weepingVinesGrowthModifier = 0.10D; + private void weepingVinesSettings() { + weepingVinesGrowthModifier = getDouble("blocks.weeping_vines.growth-modifier", weepingVinesGrowthModifier); + } + + public int lavaSpeedNether = 10; + public int lavaSpeedNotNether = 30; + public boolean lavaInfinite = false; + public int lavaInfiniteRequiredSources = 2; + private void lavaSettings() { + lavaSpeedNether = getInt("blocks.lava.speed.nether", lavaSpeedNether); + lavaSpeedNotNether = getInt("blocks.lava.speed.not-nether", lavaSpeedNotNether); + lavaInfinite = getBoolean("blocks.lava.infinite-source", lavaInfinite); + lavaInfiniteRequiredSources = getInt("blocks.lava.infinite-required-sources", lavaInfiniteRequiredSources); + } } diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java.rej b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java.rej deleted file mode 100644 index ad57dcdf457379d3282e710874808a6cebd3c17f..0000000000000000000000000000000000000000 --- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java.rej +++ /dev/null @@ -1,26 +0,0 @@ -diff a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java (rejected hunks) -@@ -1,5 +1,6 @@ - package net.pl3x.purpur; - -+import com.destroystokyo.paper.PaperConfig; - import net.minecraft.server.Block; - import net.minecraft.server.Blocks; - import net.minecraft.server.EnumDifficulty; -@@ -84,6 +85,17 @@ public class PurpurWorldConfig { - return PurpurConfig.config.getString("world-settings." + worldName + "." + path, PurpurConfig.config.getString("world-settings.default." + path)); - } - -+ private void migrateDisableProjectileSaving() { -+ if (PurpurConfig.version < 6) { -+ final boolean saveProjectilesToDisk = PurpurConfig.config.getBoolean("world-settings." + worldName + ".gameplay-mechanics.save-projectiles-to-disk", true); -+ PurpurConfig.config.set("world-settings." + worldName + ".gameplay-mechanics.save-projectiles-to-disk", null); -+ if (!saveProjectilesToDisk) { -+ PaperConfig.config.set("world-settings." + worldName + ".projectile-load-save-per-chunk-limit", 0); -+ PaperConfig.saveConfig(); -+ } -+ } -+ } -+ - public boolean armorstandSetNameVisible = false; - public boolean armorstandFixNametags = false; - public float armorstandStepHeight = 0.0F; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 00e6b6f29e042fb48c2fc8009659c57e9a930abc..fcf2bf8962cf6bc33d4213c1101debae4afa7114 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -863,6 +863,7 @@ public final class CraftServer implements Server { com.destroystokyo.paper.PaperConfig.init((File) console.options.valueOf("paper-settings")); // Paper com.tuinity.tuinity.config.TuinityConfig.init((File) console.options.valueOf("tuinity-settings")); // Tuinity - Server Config net.pl3x.purpur.PurpurConfig.init((File) console.options.valueOf("purpur-settings")); // Purpur + de.minebench.origami.OrigamiConfig.init((File) console.options.valueOf("origami-settings")); // Origami for (WorldServer world : console.getWorlds()) { world.worldDataServer.setDifficulty(config.difficulty); world.setSpawnFlags(config.spawnMonsters, config.spawnAnimals); @@ -899,6 +900,7 @@ public final class CraftServer implements Server { world.paperConfig.init(); // Paper world.tuinityConfig.init(); // Tuinity - Server Config world.purpurConfig.init(); // Purpur + world.origamiConfig.init(); // Origami } Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper @@ -2309,6 +2311,13 @@ public final class CraftServer implements Server { } // Purpur end + // Origami start + @Override + public YamlConfiguration getOrigamiConfig() { + return de.minebench.origami.OrigamiConfig.config; + } + // Origami end + @Override public void restart() { org.spigotmc.RestartCommand.restart(); @@ -2446,4 +2455,11 @@ public final class CraftServer implements Server { return mobGoals; } // Paper end + + // Purpur start + @Override + public boolean isLagging() { + return getServer().lagging; + } + // Purpur end } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java.rej b/src/main/java/org/bukkit/craftbukkit/CraftServer.java.rej deleted file mode 100644 index b9dbdd5416862e325200e62b7d5821a73c230ec1..0000000000000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java.rej +++ /dev/null @@ -1,12 +0,0 @@ -diff a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java (rejected hunks) -@@ -2451,5 +2451,10 @@ public final class CraftServer implements Server { - public String getServerName() { - return getProperties().serverName; - } -+ -+ @Override -+ public boolean isLagging() { -+ return getServer().lagging; -+ } - // Purpur end - } diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java index 25501197b33441fa0d319082bd8d8b72110373af..dbc934b374ff1b9eb4b66d2365e89c39c951763b 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -154,6 +154,14 @@ public class Main { .describedAs("Yml file"); // Purpur end + // Origami start + acceptsAll(asList("origami", "origami-settings"), "File for origami settings") + .withRequiredArg() + .ofType(File.class) + .defaultsTo(new File("origami.yml")) + .describedAs("Yml file"); + // Origami end + // Paper start acceptsAll(asList("server-name"), "Name of the server") .withRequiredArg() diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java.rej b/src/main/java/org/bukkit/craftbukkit/Main.java.rej deleted file mode 100644 index 27a6c3279b77f24edcea24f3a01559145d2f4da1..0000000000000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/Main.java.rej +++ /dev/null @@ -1,16 +0,0 @@ -diff a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java (rejected hunks) -@@ -139,6 +139,14 @@ public class Main { - .describedAs("Yml file"); - // Paper end - -+ // Origami Start - Server Config -+ acceptsAll(asList("origami", "origami-settings"), "File for origami settings") -+ .withRequiredArg() -+ .ofType(File.class) -+ .defaultsTo(new File("origami.yml")) -+ .describedAs("Yml file"); -+ // Origami end - Server Config -+ - // Paper start - acceptsAll(asList("server-name"), "Name of the server") - .withRequiredArg()