mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2026-01-04 15:41:40 +00:00
Backport Refactor Improve Purpur AFK system
This commit is contained in:
@@ -47,7 +47,7 @@ subprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl)
|
||||
maven("https://ci.pluginwiki.us/plugin/repository/everything/") // Leaf Config - ConfigurationMaster-API
|
||||
maven("https://repo.bsdevelopment.org/releases/") // Leaf - Leaf config - ConfigurationMaster-API
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ Add per world config
|
||||
Add config reload
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index c3790a8ebeeaaa395449e30ab69f1abfa9637034..a56ff254fb752030600fdf1d4ce62ff7ec14765d 100644
|
||||
index c3790a8ebeeaaa395449e30ab69f1abfa9637034..062b8e4acd90c588676b6db56cffe277c90338c2 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -14,6 +14,13 @@ val alsoShade: Configuration by configurations.creating
|
||||
@@ -20,7 +20,7 @@ index c3790a8ebeeaaa395449e30ab69f1abfa9637034..a56ff254fb752030600fdf1d4ce62ff7
|
||||
implementation(project(":leaf-api")) // Gale start - project setup - Depend on own API // Leaf
|
||||
+
|
||||
+ // Leaf start - Leaf Config
|
||||
+ implementation("com.github.thatsmusic99:ConfigurationMaster-API:v2.0.0-rc.2") {
|
||||
+ implementation("com.github.thatsmusic99:ConfigurationMaster-API:v2.0.0-rc.3") {
|
||||
+ exclude(group = "org.yaml", module = "snakeyaml")
|
||||
+ }
|
||||
+ // Leaf end - Leaf Config
|
||||
@@ -29,14 +29,19 @@ index c3790a8ebeeaaa395449e30ab69f1abfa9637034..a56ff254fb752030600fdf1d4ce62ff7
|
||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
||||
index 278adb48400ca9d4fd37bff040b37d4a8dd47282..759b22fc6f949829cef757232357368ef80d0d34 100644
|
||||
index 278adb48400ca9d4fd37bff040b37d4a8dd47282..543c673a4b1607a8a7fe71f8554ccc4625db6fe9 100644
|
||||
--- a/src/main/java/net/minecraft/server/Main.java
|
||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
||||
@@ -124,6 +124,7 @@ public class Main {
|
||||
@@ -120,10 +120,12 @@ public class Main {
|
||||
JvmProfiler.INSTANCE.start(Environment.SERVER);
|
||||
}
|
||||
|
||||
+ org.dreeam.leaf.config.LeafConfig.loadConfig(); // Leaf
|
||||
io.papermc.paper.plugin.PluginInitializerManager.load(optionset); // Paper
|
||||
Bootstrap.bootStrap();
|
||||
Bootstrap.validate();
|
||||
Util.startTimerHackThread();
|
||||
+ org.dreeam.leaf.config.LeafConfig.loadConfig(); // Leaf
|
||||
+ org.dreeam.leaf.config.ConfigModules.loadAfterBootstrap(); // Leaf - Leaf config - post load
|
||||
Path path1 = Paths.get("server.properties");
|
||||
DedicatedServerSettings dedicatedserversettings = new DedicatedServerSettings(optionset); // CraftBukkit - CLI argument support
|
||||
|
||||
@@ -56,10 +61,10 @@ index 4efbd656c57672b84c5d90f987bd57c67fc0c550..05f805c7e7a6ff6d40b9f86aaac5362a
|
||||
long tickSection = Util.getNanos();
|
||||
diff --git a/src/main/java/org/dreeam/leaf/config/ConfigModules.java b/src/main/java/org/dreeam/leaf/config/ConfigModules.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..475da1247655dd07ab59273ab5794b04b20e05ed
|
||||
index 0000000000000000000000000000000000000000..a4f2e6a2d0ac0d1a4d346af7bd82276105ff0a79
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/config/ConfigModules.java
|
||||
@@ -0,0 +1,57 @@
|
||||
@@ -0,0 +1,71 @@
|
||||
+package org.dreeam.leaf.config;
|
||||
+
|
||||
+import org.dreeam.leaf.config.annotations.Experimental;
|
||||
@@ -75,7 +80,8 @@ index 0000000000000000000000000000000000000000..475da1247655dd07ab59273ab5794b04
|
||||
+
|
||||
+public abstract class ConfigModules extends LeafConfig {
|
||||
+
|
||||
+ private static final Set<ConfigModules> modules = new HashSet<>();
|
||||
+ private static final Set<ConfigModules> MODULES = new HashSet<>();
|
||||
+
|
||||
+ public LeafGlobalConfig config;
|
||||
+
|
||||
+ public ConfigModules() {
|
||||
@@ -88,7 +94,7 @@ index 0000000000000000000000000000000000000000..475da1247655dd07ab59273ab5794b04
|
||||
+ ConfigModules module = (ConfigModules) clazz.getConstructor().newInstance();
|
||||
+ module.onLoaded();
|
||||
+
|
||||
+ modules.add(module);
|
||||
+ MODULES.add(module);
|
||||
+ for (Field field : getAnnotatedStaticFields(clazz, Experimental.class)) {
|
||||
+ Object obj = field.get(null);
|
||||
+ if (!(obj instanceof Boolean)) continue;
|
||||
@@ -104,6 +110,12 @@ index 0000000000000000000000000000000000000000..475da1247655dd07ab59273ab5794b04
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void loadAfterBootstrap() {
|
||||
+ for (ConfigModules module : MODULES) {
|
||||
+ module.onPostLoaded();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static List<Field> getAnnotatedStaticFields(Class<?> clazz, Class<? extends Annotation> annotation) {
|
||||
+ List<Field> fields = new ArrayList<>();
|
||||
+ for (Field field : clazz.getDeclaredFields()) {
|
||||
@@ -115,7 +127,14 @@ index 0000000000000000000000000000000000000000..475da1247655dd07ab59273ab5794b04
|
||||
+ return fields;
|
||||
+ }
|
||||
+
|
||||
+ public static void clearModules() {
|
||||
+ MODULES.clear();
|
||||
+ }
|
||||
+
|
||||
+ public abstract void onLoaded();
|
||||
+
|
||||
+ public void onPostLoaded() {
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/dreeam/leaf/config/EnumConfigCategory.java b/src/main/java/org/dreeam/leaf/config/EnumConfigCategory.java
|
||||
new file mode 100644
|
||||
@@ -151,10 +170,10 @@ index 0000000000000000000000000000000000000000..7d99f0711c6b4f298dd296c26c11dd9d
|
||||
+}
|
||||
diff --git a/src/main/java/org/dreeam/leaf/config/LeafConfig.java b/src/main/java/org/dreeam/leaf/config/LeafConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..fdbdf3f6a5071ce629d2881e861075dbeef11b42
|
||||
index 0000000000000000000000000000000000000000..94143d1129a571d6a44e835211779e93c1ffc0bd
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/config/LeafConfig.java
|
||||
@@ -0,0 +1,269 @@
|
||||
@@ -0,0 +1,270 @@
|
||||
+package org.dreeam.leaf.config;
|
||||
+
|
||||
+import io.papermc.paper.configuration.GlobalConfiguration;
|
||||
@@ -210,6 +229,7 @@ index 0000000000000000000000000000000000000000..fdbdf3f6a5071ce629d2881e861075db
|
||||
+ LOGGER.info("Reloading config...");
|
||||
+
|
||||
+ loadConfig(false);
|
||||
+ ConfigModules.loadAfterBootstrap();
|
||||
+
|
||||
+ LOGGER.info("Successfully reloaded config in {}ms.", (System.nanoTime() - begin) / 1_000_000);
|
||||
+ } catch (Exception e) {
|
||||
|
||||
@@ -196,7 +196,7 @@ index 0000000000000000000000000000000000000000..1fc08518f9cc2b6840b5074f181aefc6
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/dreeam/leaf/config/LeafConfig.java b/src/main/java/org/dreeam/leaf/config/LeafConfig.java
|
||||
index fdbdf3f6a5071ce629d2881e861075dbeef11b42..41b24849b6601cdf89ee6cb4125a7127e716c5ee 100644
|
||||
index 94143d1129a571d6a44e835211779e93c1ffc0bd..031750162e576b2c99cdf87fac059cac310c28b1 100644
|
||||
--- a/src/main/java/org/dreeam/leaf/config/LeafConfig.java
|
||||
+++ b/src/main/java/org/dreeam/leaf/config/LeafConfig.java
|
||||
@@ -1,6 +1,7 @@
|
||||
@@ -207,7 +207,7 @@ index fdbdf3f6a5071ce629d2881e861075dbeef11b42..41b24849b6601cdf89ee6cb4125a7127
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -211,6 +212,7 @@ public class LeafConfig {
|
||||
@@ -212,6 +213,7 @@ public class LeafConfig {
|
||||
|
||||
private static String[] buildSparkHiddenPaths() {
|
||||
return new String[]{
|
||||
|
||||
@@ -69,7 +69,7 @@ index cb61462d4691a055a4b25f7b953609d8a154fdfe..b2d8a858d8767bd6ca52e0b8db847579
|
||||
private String descriptionId;
|
||||
@Nullable
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 06c57db4e6c76945cba514fc27828ff96fcd2c10..df932757d6a2f6812a1be16a3a71c4c4c75768b5 100644
|
||||
index 361000909cedb7ae8bfe326e87be750b6916aa62..465642d06ce366f63c6152e05390b61ddab4148f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -237,10 +237,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
|
||||
@@ -295,10 +295,10 @@ index ba49442ed0b7c05c50dbc2a640f5759e391902f2..c96d612f0b3efc96f3f60f35449811ca
|
||||
}
|
||||
diff --git a/src/main/java/org/dreeam/leaf/config/modules/opt/DynamicActivationofBrain.java b/src/main/java/org/dreeam/leaf/config/modules/opt/DynamicActivationofBrain.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7e1e06ff65d1e186e6ec41917945d3d90fe72008
|
||||
index 0000000000000000000000000000000000000000..a92c5557bbfc2c8c2e2b916dad5649ed0a98c9d1
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/config/modules/opt/DynamicActivationofBrain.java
|
||||
@@ -0,0 +1,81 @@
|
||||
@@ -0,0 +1,84 @@
|
||||
+package org.dreeam.leaf.config.modules.opt;
|
||||
+
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
@@ -360,7 +360,10 @@ index 0000000000000000000000000000000000000000..7e1e06ff65d1e186e6ec41917945d3d9
|
||||
+ "不会被 DAB 影响的实体列表"));
|
||||
+
|
||||
+ startDistanceSquared = startDistance * startDistance;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onPostLoaded() {
|
||||
+ for (EntityType<?> entityType : BuiltInRegistries.ENTITY_TYPE) {
|
||||
+ entityType.dabEnabled = true; // reset all, before setting the ones to true
|
||||
+ }
|
||||
|
||||
@@ -37,10 +37,10 @@ index b2d8a858d8767bd6ca52e0b8db84757986c6ed61..f9440014ab2fe753c16b9383f5fffbb8
|
||||
@Nullable
|
||||
diff --git a/src/main/java/org/dreeam/leaf/config/modules/opt/EntityTTL.java b/src/main/java/org/dreeam/leaf/config/modules/opt/EntityTTL.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..79875406800536e753de92d7e9e6613f0f563a55
|
||||
index 0000000000000000000000000000000000000000..29c130d5ca08efb7149460d930e0141a248d94e8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/config/modules/opt/EntityTTL.java
|
||||
@@ -0,0 +1,59 @@
|
||||
@@ -0,0 +1,62 @@
|
||||
+package org.dreeam.leaf.config.modules.opt;
|
||||
+
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
@@ -59,14 +59,17 @@ index 0000000000000000000000000000000000000000..79875406800536e753de92d7e9e6613f
|
||||
+ @Override
|
||||
+ public void onLoaded() {
|
||||
+ config.addCommentRegionBased(getBasePath(), """
|
||||
+ These values define a entity's maximum lifespan. If an
|
||||
+ entity is in this list and it has survived for longer than
|
||||
+ that number of ticks, then it will be removed. Setting a value to
|
||||
+ -1 disables this feature.""",
|
||||
+ These values define a entity's maximum lifespan. If an
|
||||
+ entity is in this list and it has survived for longer than
|
||||
+ that number of ticks, then it will be removed. Setting a value to
|
||||
+ -1 disables this feature.""",
|
||||
+ """
|
||||
+ 这些值定义了实体的最大生命周期.
|
||||
+ 如果实体存活时间超过指定的 tick 将被移除, 设置为 -1 可禁用此功能.""");
|
||||
+ 这些值定义了实体的最大生命周期.
|
||||
+ 如果实体存活时间超过指定的 tick 将被移除, 设置为 -1 可禁用此功能.""");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onPostLoaded() {
|
||||
+ for (EntityType<?> entityType : BuiltInRegistries.ENTITY_TYPE) {
|
||||
+ if (isFilteredEntity(entityType)) {
|
||||
+ continue;
|
||||
|
||||
@@ -31,7 +31,7 @@ Make-pufferfish-config-relocatable.patch
|
||||
MC-121706-Fix-mobs-not-looking-up-and-down-when-stra.patch
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index a56ff254fb752030600fdf1d4ce62ff7ec14765d..d1bcbd39120480b2e1e402040d20b8567019a4b0 100644
|
||||
index 062b8e4acd90c588676b6db56cffe277c90338c2..148c2cd116e1dd794f73cc1ed5fe18f320517a82 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -54,6 +54,12 @@ dependencies {
|
||||
@@ -587,7 +587,7 @@ index 76ef195a5074006b009acd9cc1744667c6aecbb9..659577549e132754281df76a7a1bfd88
|
||||
public ClientboundSetTimePacket(long time, long timeOfDay, boolean doDaylightCycle) {
|
||||
this.gameTime = time;
|
||||
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
||||
index 759b22fc6f949829cef757232357368ef80d0d34..94e6f298b12f86f923bb58b88caec6f3c3b37aa6 100644
|
||||
index 543c673a4b1607a8a7fe71f8554ccc4625db6fe9..46de97de75979e5d27b6e0006503891bcb425baf 100644
|
||||
--- a/src/main/java/net/minecraft/server/Main.java
|
||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
||||
@@ -120,6 +120,12 @@ public class Main {
|
||||
@@ -600,9 +600,9 @@ index 759b22fc6f949829cef757232357368ef80d0d34..94e6f298b12f86f923bb58b88caec6f3
|
||||
+ org.purpurmc.purpur.PurpurConfig.registerMinecraftDebugCommands = purpurConfiguration.getBoolean("settings.register-minecraft-debug-commands");
|
||||
+ // Purpur end - load config files early
|
||||
+
|
||||
org.dreeam.leaf.config.LeafConfig.loadConfig(); // Leaf
|
||||
io.papermc.paper.plugin.PluginInitializerManager.load(optionset); // Paper
|
||||
Bootstrap.bootStrap();
|
||||
Bootstrap.validate();
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 654c381c210d9e353df8f7bca0cd7a434d997a8f..2bdc050df0333dbd611d1eb2714aa2a00116a2be 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
|
||||
@@ -7,19 +7,19 @@ AFK command & command cooldown
|
||||
AFK title message
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
||||
index 7b27575ee14ea30c104be2a231d378f69f7bd347..91eea05a68d0ace8678fc5071e67cedb18a4386b 100644
|
||||
index 7b27575ee14ea30c104be2a231d378f69f7bd347..5d3c521449dd6072297eea611e52a6752a65135e 100644
|
||||
--- a/src/main/java/net/minecraft/commands/Commands.java
|
||||
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
||||
@@ -248,6 +248,7 @@ public class Commands {
|
||||
StopCommand.register(this.dispatcher);
|
||||
TransferCommand.register(this.dispatcher);
|
||||
WhitelistCommand.register(this.dispatcher);
|
||||
+ org.purpurmc.purpur.command.AFKCommand.register(this.dispatcher); // Leaf - Improve Purpur AFK system
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.AfkCommand.enabled) org.purpurmc.purpur.command.AFKCommand.register(this.dispatcher); // Leaf - Improve Purpur AFK system
|
||||
org.purpurmc.purpur.command.CreditsCommand.register(this.dispatcher); // Purpur
|
||||
org.purpurmc.purpur.command.DemoCommand.register(this.dispatcher); // Purpur
|
||||
org.purpurmc.purpur.command.PingCommand.register(this.dispatcher); // Purpur
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 7c6bda95b8b08cc70182f19cf0b991f78d28c235..79df52237b7a5822e0cbaff015ccd193a8195980 100644
|
||||
index e36358d0217a181b101c7dfbb3ea265fd15597c1..374f1fce66c53c5d367724c4eee27f99ff7881db 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -2414,6 +2414,10 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
|
||||
@@ -57,7 +57,7 @@ index 7c6bda95b8b08cc70182f19cf0b991f78d28c235..79df52237b7a5822e0cbaff015ccd193
|
||||
} else {
|
||||
getBukkitEntity().setPlayerListName(prefix + scoreboardName + suffix, true);
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 39428db6c83527c085f4dcb012b4da297840bca6..81834489ee488be58b70dae0336645e4147d8dae 100644
|
||||
index 39428db6c83527c085f4dcb012b4da297840bca6..03fe04aa054b6190b0d77aa9c8c77893c63d477f 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2271,6 +2271,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
@@ -74,7 +74,7 @@ index 39428db6c83527c085f4dcb012b4da297840bca6..81834489ee488be58b70dae0336645e4
|
||||
}
|
||||
|
||||
+ // Leaf start - Improve Purpur AFK system
|
||||
+ if (command.equals("afk")) {
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.AfkCommand.enabled && command.equals("afk")) {
|
||||
+ this.player.commandAfkStatus = this.player.isAfk();
|
||||
+ this.player.isCommandAfk = true;
|
||||
+
|
||||
@@ -113,7 +113,7 @@ index 39428db6c83527c085f4dcb012b4da297840bca6..81834489ee488be58b70dae0336645e4
|
||||
} // Paper - Add missing SpigotConfig logCommands check
|
||||
|
||||
+ // Leaf start - Improve Purpur AFK system
|
||||
+ if (command.equals("/afk")) {
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.AfkCommand.enabled && command.equals("/afk")) {
|
||||
+ this.player.commandAfkStatus = this.player.isAfk();
|
||||
+ this.player.isCommandAfk = true;
|
||||
+
|
||||
@@ -142,17 +142,46 @@ index 39428db6c83527c085f4dcb012b4da297840bca6..81834489ee488be58b70dae0336645e4
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
command = event.getMessage().substring(1);
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index bc7dd0ceea8bb304fb4370084bf19f29c1df0828..3ac1446ed791e06e2bbf226b925890ac4d1a16de 100644
|
||||
index 8d8f552acd4d2e846e1fd0bc19574d93c372fc2b..f307305760546d83007aacab2a2eaadede83dc53 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -756,6 +756,7 @@ public abstract class PlayerList {
|
||||
org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(entityplayer); // Leaves - protocol
|
||||
// Paper end - Fix kick event leave message not being sent
|
||||
org.purpurmc.purpur.task.BossBarTask.removeFromAll(entityplayer.getBukkitEntity()); // Purpur
|
||||
+ net.minecraft.server.network.ServerGamePacketListenerImpl.afkCooldown.remove(entityplayer.getBukkitEntity().getUniqueId()); // Leaf - Improve Purpur AFK system
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.AfkCommand.enabled) net.minecraft.server.network.ServerGamePacketListenerImpl.afkCooldown.remove(entityplayer.getBukkitEntity().getUniqueId()); // Leaf - Improve Purpur AFK system
|
||||
ServerLevel worldserver = entityplayer.serverLevel();
|
||||
|
||||
entityplayer.awardStat(Stats.LEAVE_GAME);
|
||||
diff --git a/src/main/java/org/dreeam/leaf/config/modules/gameplay/AfkCommand.java b/src/main/java/org/dreeam/leaf/config/modules/gameplay/AfkCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1ac66384e2ccb9f21eefdbad4a681c6611a094fd
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/config/modules/gameplay/AfkCommand.java
|
||||
@@ -0,0 +1,23 @@
|
||||
+package org.dreeam.leaf.config.modules.gameplay;
|
||||
+
|
||||
+import org.dreeam.leaf.config.ConfigModules;
|
||||
+import org.dreeam.leaf.config.EnumConfigCategory;
|
||||
+
|
||||
+public class AfkCommand extends ConfigModules {
|
||||
+
|
||||
+ public String getBasePath() {
|
||||
+ return EnumConfigCategory.GAMEPLAY.getBaseKeyName() + ".afk-command";
|
||||
+ }
|
||||
+
|
||||
+ public static boolean enabled = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded() {
|
||||
+ enabled = config.getBoolean(getBasePath() + ".enabled", enabled, config.pickStringRegionBased("""
|
||||
+ The AFK command based on Minecraft built-in idle-timeout mechanism
|
||||
+ Rest of AFK settings are in the Purpur config""",
|
||||
+ """
|
||||
+ 基于原版 idle-timeout 系统的 AFK 指令
|
||||
+ 剩余配置项在 Purpur 配置里"""));
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
index 654e838d9a77e0dd8fe9fb1d4804785ad0f463c8..5b9b9830eadf133e5ee822d6d6a0d649e08a53ed 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
|
||||
@@ -65,7 +65,7 @@ index 573c380e123473e35c0b72c44b32c8d6ba8e61c6..feacc41ecf7f4028e0a1cce5d2012ced
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index fd7ad7866d9f16c62850d37c98d1736cd54242e4..82b885a6037afa35da76997d9eab6fe3390df5c2 100644
|
||||
index 9bcf2824a23c93442cb18a969fc3a45d3fd9d7b8..413d9c372f08ccdad0910c13cde004539b54f67b 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2958,7 +2958,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
@@ -132,10 +132,10 @@ index ecfa807e78c16a24099d40becd0c7916f239aed1..f1b4adeeb4dad5178a5e52870f420bea
|
||||
this.synchronizer.sendCarriedChange(this, this.remoteCarried);
|
||||
diff --git a/src/main/java/org/dreeam/leaf/config/modules/misc/HiddenItemComponents.java b/src/main/java/org/dreeam/leaf/config/modules/misc/HiddenItemComponents.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f89b21cbe62d66afd61c7a61d3a126a5dfda373e
|
||||
index 0000000000000000000000000000000000000000..30ea12be6a795bb9cfd904e3011894cdf5bde83f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/config/modules/misc/HiddenItemComponents.java
|
||||
@@ -0,0 +1,51 @@
|
||||
@@ -0,0 +1,54 @@
|
||||
+package org.dreeam.leaf.config.modules.misc;
|
||||
+
|
||||
+import net.minecraft.core.component.DataComponentType;
|
||||
@@ -154,28 +154,32 @@ index 0000000000000000000000000000000000000000..f89b21cbe62d66afd61c7a61d3a126a5
|
||||
+ return EnumConfigCategory.MISC.getBaseKeyName();
|
||||
+ }
|
||||
+
|
||||
+ public static List<String> hiddenTypeStrings = new ArrayList<>();
|
||||
+ public static List<DataComponentType<?>> hiddenItemComponentTypes = List.of();
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded() {
|
||||
+ List<String> list = config.getList(getBasePath() + ".hidden-item-components", new ArrayList<>(), config.pickStringRegionBased("""
|
||||
+ Controls whether specified component information is sent to clients.
|
||||
+ This may break resource packs and mods that rely on this information.
|
||||
+ It needs a component type list, incorrect things will not work.
|
||||
+ You can fill it with ["custom_data"] to hide components of CUSTOM_DATA.
|
||||
+ Also, it can avoid some frequent client animations.
|
||||
+ NOTICE: You must know what you're filling in and how it works! It will handle all itemStacks!""",
|
||||
+ hiddenTypeStrings = config.getList(getBasePath() + ".hidden-item-components", new ArrayList<>(), config.pickStringRegionBased("""
|
||||
+ Controls whether specified component information is sent to clients.
|
||||
+ This may break resource packs and mods that rely on this information.
|
||||
+ It needs a component type list, incorrect things will not work.
|
||||
+ You can fill it with ["custom_data"] to hide components of CUSTOM_DATA.
|
||||
+ Also, it can avoid some frequent client animations.
|
||||
+ NOTICE: You must know what you're filling in and how it works! It will handle all itemStacks!""",
|
||||
+ """
|
||||
+ 控制哪些物品组件信息会被发送至客户端.
|
||||
+ 可能会导致依赖物品组件的资源包/模组无法正常工作.
|
||||
+ 该配置项接受一个物品组件列表, 格式不正确将不会启用.
|
||||
+ 可以填入 ["custom_data"] 来隐藏自定义数据物品组件 CUSTOM_DATA.
|
||||
+ 也可以避免一些客户端动画效果.
|
||||
+ 注意: 你必须知道你填进去的是什么, 有什么用, 该项配置会处理所有的ItemStack!"""));
|
||||
+ 控制哪些物品组件信息会被发送至客户端.
|
||||
+ 可能会导致依赖物品组件的资源包/模组无法正常工作.
|
||||
+ 该配置项接受一个物品组件列表, 格式不正确将不会启用.
|
||||
+ 可以填入 ["custom_data"] 来隐藏自定义数据物品组件 CUSTOM_DATA.
|
||||
+ 也可以避免一些客户端动画效果.
|
||||
+ 注意: 你必须知道你填进去的是什么, 有什么用, 该项配置会处理所有的ItemStack!"""));
|
||||
+ }
|
||||
+
|
||||
+ List<DataComponentType<?>> types = new ArrayList<>(list.size());
|
||||
+ @Override
|
||||
+ public void onPostLoaded() {
|
||||
+ List<DataComponentType<?>> types = new ArrayList<>(hiddenTypeStrings.size());
|
||||
+
|
||||
+ for (String id : list) {
|
||||
+ for (String id : hiddenTypeStrings) {
|
||||
+ // Find and check
|
||||
+ DataComponentType<?> type = BuiltInRegistries.DATA_COMPONENT_TYPE.get(ResourceLocation.parse(id));
|
||||
+ if (type != null) {
|
||||
@@ -185,7 +189,6 @@ index 0000000000000000000000000000000000000000..f89b21cbe62d66afd61c7a61d3a126a5
|
||||
+
|
||||
+ hiddenItemComponentTypes = types;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/dreeam/leaf/util/item/ItemStackObfuscator.java b/src/main/java/org/dreeam/leaf/util/item/ItemStackObfuscator.java
|
||||
new file mode 100644
|
||||
|
||||
Reference in New Issue
Block a user