Skip to content

Commit

Permalink
Leaves config hot modify (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Jan 10, 2024
1 parent 11c94f7 commit 45c933a
Show file tree
Hide file tree
Showing 114 changed files with 962 additions and 1,136 deletions.
1,645 changes: 845 additions & 800 deletions patches/server/0005-Leaves-Server-Config-And-Command.patch

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions patches/server/0006-Leaves-Protocol-Core.patch
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ index 192eeaffd6d51baca149c7b9eaccf53246cb3af5..00f4ee320f8a8d019cb311cee78bb384
ServerLevel worldserver = entityplayer.serverLevel();

diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index f18225bff50f87e4dab89951a9f09947639b6a27..dc4ce7bbde058560c077fe2004da64e3113ccace 100644
index 417a808d2b99a0a3f499a457c93afb9494d22fff..1e904d37a4646ebd2c3913fb6157342678c06ba9 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -463,6 +463,7 @@ public final class CraftServer implements Server {
Expand All @@ -88,8 +88,8 @@ index f18225bff50f87e4dab89951a9f09947639b6a27..dc4ce7bbde058560c077fe2004da64e3
}

public boolean getCommandBlockOverride(String command) {
@@ -1072,6 +1073,7 @@ public final class CraftServer implements Server {
top.leavesmc.leaves.LeavesConfig.registerCommands(); // Leaves - Server Command
@@ -1070,6 +1071,7 @@ public final class CraftServer implements Server {
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
+ top.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleServerReload(); // Leaves - protocol
Expand Down
40 changes: 7 additions & 33 deletions patches/server/0010-Fakeplayer-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ index dfeb3e336e06ef01f5401a362755030db942bb07..c51413bf02b3572a05f09d2f0d02493d
if (randomsource.nextInt(j) >= world.paperConfig().entities.behavior.playerInsomniaStartTicks) { // Paper
BlockPos blockposition1 = blockposition.above(20 + randomsource.nextInt(15)).east(-10 + randomsource.nextInt(21)).south(-10 + randomsource.nextInt(21));
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index dc4ce7bbde058560c077fe2004da64e3113ccace..602d913b144c6d565e09c5623859c40775a4fcca 100644
index 1e904d37a4646ebd2c3913fb6157342678c06ba9..1dc51050065af9bfc760f0a2cd7a479817888280 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -259,6 +259,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
Expand All @@ -372,7 +372,7 @@ index dc4ce7bbde058560c077fe2004da64e3113ccace..602d913b144c6d565e09c5623859c407

// Paper start - Folia region threading API
private final io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler regionizedScheduler = new io.papermc.paper.threadedregions.scheduler.FallbackRegionScheduler();
@@ -3246,4 +3248,11 @@ public final class CraftServer implements Server {
@@ -3244,4 +3246,11 @@ public final class CraftServer implements Server {
}

// Paper end
Expand Down Expand Up @@ -419,35 +419,9 @@ index 74ff54724626908a083063c54983e0adfbbf7749..7afc1618f2014df67ca42f00c09e863c
/**
* The start ID for the counter.
*/
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
index a1ca90ea40b4ccd8df290f8cc34d63d390acc87c..ae21d3e873b22849cc2f02444624d150e9e3868d 100644
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
@@ -8,6 +8,9 @@ import org.bukkit.command.Command;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import top.leavesmc.leaves.command.LeavesCommand;
+import top.leavesmc.leaves.bot.BotCommand;
+import top.leavesmc.leaves.bot.agent.Actions;
+import top.leavesmc.leaves.util.MathUtils;

import java.io.File;
import java.lang.reflect.InvocationTargetException;
@@ -70,6 +73,11 @@ public final class LeavesConfig {

commands = new HashMap<>();
commands.put("leaves", new LeavesCommand("leaves"));
+
+ if (top.leavesmc.leaves.LeavesConfig.fakeplayerSupport) {
+ commands.put("bot", new BotCommand("bot"));
+ Actions.registerAll();
+ }
}

public static void load(final YamlConfiguration config) {
diff --git a/src/main/java/top/leavesmc/leaves/bot/BotCommand.java b/src/main/java/top/leavesmc/leaves/bot/BotCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..6abc37cff54d876b598051bb23aa3a2c2e1a7baa
index 0000000000000000000000000000000000000000..6a67f2e548d5f0a5936cc7520eb8369788e9bea8
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/bot/BotCommand.java
@@ -0,0 +1,275 @@
Expand All @@ -467,7 +441,7 @@ index 0000000000000000000000000000000000000000..6abc37cff54d876b598051bb23aa3a2c
+import org.bukkit.permissions.PermissionDefault;
+import org.bukkit.plugin.PluginManager;
+import org.jetbrains.annotations.NotNull;
+import top.leavesmc.leaves.LeavesLogger;
+import top.leavesmc.leaves.LeavesConfig;
+import top.leavesmc.leaves.bot.agent.Actions;
+import top.leavesmc.leaves.bot.agent.BotAction;
+import top.leavesmc.leaves.bot.agent.actions.CraftCustomBotAction;
Expand Down Expand Up @@ -532,7 +506,7 @@ index 0000000000000000000000000000000000000000..6abc37cff54d876b598051bb23aa3a2c
+
+ @Override
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, String[] args) {
+ if (!testPermission(sender)) return true;
+ if (!testPermission(sender) || !LeavesConfig.fakeplayerSupport) return true;
+
+ if (args.length == 0) {
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
Expand Down Expand Up @@ -1194,7 +1168,7 @@ index 0000000000000000000000000000000000000000..daaece30b2a3983f1cc9ee9a851e8f37
+}
diff --git a/src/main/java/top/leavesmc/leaves/bot/ServerBot.java b/src/main/java/top/leavesmc/leaves/bot/ServerBot.java
new file mode 100644
index 0000000000000000000000000000000000000000..02ef39695d921f804c2a89ae5cf7959c0c0e2903
index 0000000000000000000000000000000000000000..7a8eb0a472933239145e79930de28deb4cb7b0d6
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/bot/ServerBot.java
@@ -0,0 +1,722 @@
Expand Down Expand Up @@ -1518,7 +1492,7 @@ index 0000000000000000000000000000000000000000..02ef39695d921f804c2a89ae5cf7959c
+ if (server.getTickCount() % 20 == 0) {
+ float health = getHealth();
+ float maxHealth = getMaxHealth();
+ float regenAmount = LeavesConfig.fakeplayerRegenAmount * 20;
+ float regenAmount = (float) (LeavesConfig.fakeplayerRegenAmount * 20);
+ float amount;
+
+ if (health < maxHealth - regenAmount) {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0018-No-chat-sign.patch
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ index 9d6db4a378036559efab91c8b7dcf2a6b0c2cce6..2c349dc502ce275a8215766933f4855f
}
}
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index fd89dfb3f2ceab015b74d7e3a061973e590cedd5..4b13af14fcbe1925f9d3104d95ebbfbc596cfb3c 100644
index 570310512c9ce5cf87f3fffe20d6d88c651aa83a..d4932ba7042b897a8561103367d0b7cf9a08234c 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -643,7 +643,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@@ -642,7 +642,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
// Paper start - fix secure profile with proxy online mode
return dedicatedserverproperties.enforceSecureProfile
&& io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()
Expand Down
20 changes: 0 additions & 20 deletions patches/server/0019-Optimize-mob-spawning.patch

This file was deleted.

20 changes: 0 additions & 20 deletions patches/server/0021-Multithreaded-Tracker.patch

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ index 200ed770b57e1a9240abf0473968d4b85cbefe3c..bf16715db2424f0b05854ae7665b4448

public static long getCoordinateKey(final ChunkPos pair) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 2bd6e02291b6ac6ff31e85f6721bb89b2efc704b..0cdfb9470c29132f75a5b3df05178626a56e4e6e 100644
index f9e9b708eecae0dfdb283899ac293ddbfb986ade..b989029d7425cf410698ff477a3622b4c629ada3 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -307,7 +307,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Move ThreadUnsafeRandom Initialization
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 62867bc387f49398ebb5d608c4f1e4e562079bd7..ddbe5ece289235cf5b9a0e9d532ab9b8f1ff200c 100644
index 90626c175b8bb496e2e1c18cc8a501d8eff44a87..eaad1404e690f1fe47a49df1447e31f068fcb0a2 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -971,7 +971,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
Expand All @@ -19,10 +19,10 @@ index 62867bc387f49398ebb5d608c4f1e4e562079bd7..ddbe5ece289235cf5b9a0e9d532ab9b8

public void tickChunk(LevelChunk chunk, int randomTickSpeed) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index c51d22285a253d4220ee967504ab9eef1403edbe..f434b1dc911ce45a4d309b892079a266f2485c90 100644
index 2f1e70a695b222dfa832b5d2c81544bc314b1aec..987c5d9c54d4fe101659c42a1113ecd5ab164a6c 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -203,6 +203,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -202,6 +202,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {

public abstract ResourceKey<LevelStem> getTypeKey();

Expand All @@ -31,7 +31,7 @@ index c51d22285a253d4220ee967504ab9eef1403edbe..f434b1dc911ce45a4d309b892079a266
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper
@@ -296,6 +298,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -294,6 +296,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Paper end - optimise collisions
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ index d6089c0d0b076d232834619bc93bc64f0be57340..c4577d7dc27bb48c95794212de4abf2e
// Paper - optimise chunk tick iteration

diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index ddbe5ece289235cf5b9a0e9d532ab9b8f1ff200c..1ed4e8b5feb4cad478ac6472b386ccb9b610a7de 100644
index eaad1404e690f1fe47a49df1447e31f068fcb0a2..e25361263cb354293d584b8f400c02065654b4b8 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -974,6 +974,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ index 37af0a508cfe56f23be806d2d4100d890ad5e7ec..89a50e07bc79cb0d5353f5a06fa037f3
}

diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 0934de77256734d3dd50ea7e16662d49c3d58242..12f5a090affed70ba041f77fd0eacbeb4a700cb9 100644
index 987c5d9c54d4fe101659c42a1113ecd5ab164a6c..33dcb0c113614c7605ba750afb80459b68d78f99 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1791,6 +1791,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1789,6 +1789,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
}

public ProfilerFiller getProfiler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Throttle goal selector during inactive ticking
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index e0cf7771488ab0065708d68b4e8550b865af0ed4..dc196d04afa8e74be1a43994212d17b430aad2ee 100644
index a7fbd329ea6d36a46c00b4476c74e426dbbfe238..f0e1318a0a7d7a409df8fc5567040de9da25b75d 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -221,11 +221,13 @@ public abstract class Mob extends LivingEntity implements Targeting {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Reduce entity allocations
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 0cdfb9470c29132f75a5b3df05178626a56e4e6e..c4fb0f8e4aa77f8c6d77ad0ca9f8d985ea6cec3e 100644
index b989029d7425cf410698ff477a3622b4c629ada3..79b2831322b8312448c89b5276af40d1efa880d2 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -439,6 +439,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Remove lambda from ticking guard
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 1ed4e8b5feb4cad478ac6472b386ccb9b610a7de..fc2f0e767e079b9c7aba131e71f11eb8a8920be2 100644
index e25361263cb354293d584b8f400c02065654b4b8..3397a9f45a82e00b71578d82b6f5505288a79820 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -908,7 +908,24 @@ public class ServerLevel extends Level implements WorldGenLevel {
Expand Down
21 changes: 0 additions & 21 deletions patches/server/0036-Async-Pathfinding.patch

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] InstantBlockUpdater Reintroduced
This patch is Powered by Carpet-TIS-Addition(https://github.com/plusls/Carpet-TIS-Addition)

diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 831a5795b08e9bb74649404d8ef767dc3f18f173..fa93fd1fbcc3b508e46a2d1df38bb2c7ca1903c2 100644
index 33dcb0c113614c7605ba750afb80459b68d78f99..e304b4977dd77bd770335accae697e7c7bc90ecc 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -70,6 +70,7 @@ import net.minecraft.world.level.lighting.LevelLightEngine;
Expand All @@ -17,7 +17,7 @@ index 831a5795b08e9bb74649404d8ef767dc3f18f173..fa93fd1fbcc3b508e46a2d1df38bb2c7
import net.minecraft.world.level.redstone.NeighborUpdater;
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
import net.minecraft.world.level.storage.LevelData;
@@ -249,7 +250,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -247,7 +248,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
this.thread = Thread.currentThread();
this.biomeManager = new BiomeManager(this, i);
this.isDebug = flag1;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ index d9038d85f8a04381a92567acf1c8922d666aa3e8..b22dd3700c913d0391c8641fca46e89e
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index 58f972832c39a27a8ccd606f9144e1c54adbf6f3..b2aae4463f2d0fc6ae03bbb9a63c5b8f08d67d43 100644
index a0d69082f5fdeee15bba0d76b940aa48cff36fa9..a8583c8a368466e9c9148b5620ec51cc1816711d 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -44,6 +44,7 @@ import org.bukkit.event.Event;
Expand Down
File renamed without changes.
Loading

0 comments on commit 45c933a

Please sign in to comment.