From 5aeb0107d5d3cad43e1ca4c2bfe06e5df758c23e Mon Sep 17 00:00:00 2001 From: sakurawald Date: Sun, 21 Jul 2024 03:58:17 +0800 Subject: [PATCH] refactor: rename field `command_regex_2_cooldown_ms` to `regex2ms` in `command_cooldown module` + refactor: refactor: rename field `rules` to `regex` in `command_rewrite module` + refactor: extract `rows` and `tops` fields into `top` field in `top chunks module` --- fuji-fabric.wiki | 2 +- .../sakurawald/config/model/ConfigModel.java | 506 ++++++++++-------- .../CommandCooldownInitializer.java | 2 +- .../top_chunks/TopChunksInitializer.java | 6 +- .../ServerPlayNetworkHandlerMixin.java | 2 +- 5 files changed, 303 insertions(+), 215 deletions(-) diff --git a/fuji-fabric.wiki b/fuji-fabric.wiki index 741773f6b..590582ae6 160000 --- a/fuji-fabric.wiki +++ b/fuji-fabric.wiki @@ -1 +1 @@ -Subproject commit 741773f6b34c2daae78cf7c977e5d5d788b36c7a +Subproject commit 590582ae6e6d49f4cae2bc1ecd7978735424480e diff --git a/src/main/java/io/github/sakurawald/config/model/ConfigModel.java b/src/main/java/io/github/sakurawald/config/model/ConfigModel.java index 184a9deae..131b5aeec 100644 --- a/src/main/java/io/github/sakurawald/config/model/ConfigModel.java +++ b/src/main/java/io/github/sakurawald/config/model/ConfigModel.java @@ -12,11 +12,12 @@ @SuppressWarnings("ALL") @Documentation(""" Welcome to fuji-fabric 's official documentation. - This page is the `source code` used to generate the default `config.json` file. - You can press `CTRL + F` keys in your keyboard, and search any `option key` that you want to konw. + Tips: + - The `quote bar` on the left side of your browser = the strucutre nested level. You can see which level you are in. + - You can press `CTRL + F` keys in your keyboard, and search any `configuration key` that you want to konw. + - If anything is unclear, please create an issue in github. - All the text inside `@Documentation` are the documentation text, which describe the following field. """) public class ConfigModel { @@ -24,35 +25,45 @@ public class ConfigModel { public Modules modules = new Modules(); @Documentation(""" - Common options for fuji, which influce all modules. + Common options for this mod, which will influence `all modules`. """) public class Common { public Quartz quartz = new Quartz(); + public Backup backup = new Backup(); + public Language language = new Language(); @Documentation(""" - Fuji use quartz library as scheduler, all the timer are managed by quartz. - You can use quartz language to define when to trigger a job. - See: https://www.freeformatter.com/cron-expression-generator-quartz.html + Fuji use `quartz` library as scheduler, all the timer are managed by quartz. + + Quartz library use a language called `cron language` to define when to trigger a job. + See: [cron language generator](https://www.freeformatter.com/cron-expression-generator-quartz.html) """) public class Quartz { @Documentation(""" - The fuji logger level. - Options: OFF/FATAL/ERROR/WARN/INFO/DEBUG/TRACE/ALL - - Set to `OFF` to supress all the messages from fuji. - Set to `ALL` to display all the messages from fuji. + Logger level for quartz. + + Logger levels: OFF > FATAL > ERROR > WARN > INFO > DEBUG > TRACE > ALL + - Set to `OFF` to supress all the messages from fuji. + - Set to `ALL` to display all the messages from fuji. + + Note: + - It's recommended to set at least `WARN`, to avoid `console spam` """) public String logger_level = "WARN"; } - public Backup backup = new Backup(); - + @Documentation(""" + Fuji will backup the folder `config/fuji` automatically before it loads any module. + """) public class Backup { - @Documentation("How many backup should we keep?") + + @Documentation("How many `backup` should we keep?") public int max_slots = 15; @Documentation(""" - The list of `path resolver` to skip + The list of `path resolver` to skip in backup. + + Insert `head` means skip the folder `config/fuji/head`. """) public List skip = new ArrayList<>() { { @@ -61,8 +72,13 @@ public class Backup { }; } - public Language language = new Language(); - + @Documentation(""" + The default language to use. + + Fuji also supports multi-language based on player's client-side language if the server is able to do so. + You need to enable `language module` to let fuji respect client-side's language settings. + Also, if the server can't support client-side's language, it will fallback to the `deafult_language` + """) public class Language { public String default_language = "en_us"; } @@ -71,13 +87,10 @@ public class Language { @Documentation(""" A module means a standalone unit to provide a purpose. - All the module can work standalone, you can enable or disable any modules if you like. + All the module can work standalone, you can enable or disable `any module` if you like. - Some modules can work together to achive more purpose. - e.g. A module can provides some placeholders for other modules to use. - - The following fields are used to define the structure of the configuration. - Go ahead, scroll the page down, and see more... + Some modules can work together to achieve more purpose. + e.t. the `placeholder module` can provides some placeholders for `chat module`, `motd module` and other modules to use. """) public class Modules { public ResourceWorld resource_world = new ResourceWorld(); @@ -110,12 +123,21 @@ public class Modules { public CommandInteractive command_interactive = new CommandInteractive(); public Home home = new Home(); public SystemMessage system_message = new SystemMessage(); - public Sit sit = new Sit(); public CommandAlias command_alias = new CommandAlias(); public CommandRewrite command_rewrite = new CommandRewrite(); public World world = new World(); public Multiplier multiplier = new Multiplier(); + public CommandWarmup command_warmup = new CommandWarmup(); + public Disabler disabler = new Disabler(); + public AntiBuild anti_build = new AntiBuild(); + public Nickname nickname = new Nickname(); + public Color color = new Color(); + public Functional functional = new Functional(); + public Carpet carpet = new Carpet(); + public CommandToolbox command_toolbox = new CommandToolbox(); + public TabList tab_list = new TabList(); + public Kit kit = new Kit(); @Documentation(""" This module adds another 3 worlds called `resource world`: resource_overworld, resource_nether, resource_the_end . @@ -135,7 +157,7 @@ public class ResourceWorld { @Documentation(""" The seed for resource worlds: overworld, the_nether and the_end. - You don't need to input this field, since the `seed` field will randomly generated and write every time resource worlds gets reset. + You don't need to input the seed, since the `seed` field will randomly generated and write every time resource worlds gets reset. """) public long seed = 0L; @@ -159,7 +181,10 @@ public class MOTD { public boolean enable_custom_server_icon = true; @Documentation(""" - Fuji will randomly pick a motd each time the player refresh server list. + Fuji will `randomly` pick a motd each time the player refresh server list. + + Tips: + - You may need to enable `placeholder` to support some placeholders. """) public List list = new ArrayList<>() { { @@ -170,6 +195,7 @@ public class MOTD { @Documentation(""" This module provides some jobs to trigger when a player is the first time to join the server. + """) public class NewbieWelcome { public boolean enable = false; @@ -191,7 +217,6 @@ public class RandomTeleport { 1. the player runs too far. 2. the player gets damage. 3. the player is in combat. - """) public class TeleportWarmup { public boolean enable = false; @@ -203,11 +228,10 @@ public class TeleportWarmup { public double interrupt_distance = 1d; } - @Documentation(""" - This module provides a cooldown before each command the player issued. + This module provides a cooldown for command usage. - Use-case: use this module to avoid some heavy-command abuse + Use-case: use this module to avoid some heavy cost commands. """) public class CommandCooldown { public boolean enable = false; @@ -215,9 +239,11 @@ public class CommandCooldown { @Documentation(""" Use `regex language` to define issued command cooldown. - For each player, each command has its cooldown. + Note: + - For each player, each command has its cooldown. + - You may want to use some editor for `regex language`. See [regex editor](https://regexr.com/) """) - public HashMap command_regex_2_cooldown_ms = new HashMap<>() { + public HashMap regex2ms = new HashMap<>() { { this.put("rw tp (overworld|the_nether|the_end)", 120 * 1000L); this.put("chunks\\s*", 60 * 1000L); @@ -226,10 +252,16 @@ public class CommandCooldown { }; } - public CommandWarmup command_warmup = new CommandWarmup(); + @Documentation(""" + This module provides `warmup` for `command usage`. + + Note: + - `command warmup` is before `command usage`, while `command cooldown` is after `command usage`. + """) public class CommandWarmup { public boolean enable = false; + @Documentation("See `command_cooldown module`") public HashMap regex2ms = new HashMap<>() { { this.put("back", 3 * 1000); @@ -247,8 +279,14 @@ public class CommandWarmup { public class TopChunks { public boolean enable = false; - public int rows = 10; - public int columns = 10; + + public Top top = new Top(); + + @Documentation("The `top chunks` to show in `/chunks` command") + public class Top { + public int rows = 10; + public int columns = 10; + } @Documentation("For a chunk, how much the radius used to search `the nearest player` around the chunk.") public int nearest_distance = 128; @@ -263,7 +301,7 @@ public class TopChunks { @Documentation(""" The dict to define how laggy a type(entity/entity_block) should be. - For example, + For example: `this.put("entity.minecraft.zombie", 4);` means there are 15 zombies inside a chunk, then the chunk gets score 15 * 4 = 60 @@ -340,16 +378,18 @@ The dict to define how laggy a type(entity/entity_block) should be. - You can create your own `regex transformaer` to repalce the input message. - You can insert any `placeholder` like `%world:name%` in the chat message. (See more placeholders in: https://placeholders.pb4.eu/user/default-placeholders/) - You can insert player's prefix and suffix. Just insert `fuji:player_prefix` and `fuji:player_suffix`. - > Requires `luckperms` installed. See also: https://luckperms.net/wiki/Prefixes,-Suffixes-&-Meta - > After you installed `luckperms` mod, just issue `/lp group default meta setprefix [awesome]` to assign prefix. - > Don't forget to change the format of `Chat module`, and issue `/fuji reload` + Requires `luckperms` installed. See also: https://luckperms.net/wiki/Prefixes,-Suffixes-&-Meta + After you installed `luckperms` mod, just issue `/lp group default meta setprefix [awesome]` to assign prefix. + Don't forget to change the format of `Chat module`, and issue `/fuji reload` - You can insert `item`, `inv` and `ender` to display your `item in your hand`, `your inventory` and `your enderchest` - You can insert `Steve` to mention another player named `Steve`. - You can insert `pos` to show the position. - You can use `markdown language` to define simple format. - You can use `mini-message language` to define complex format. - > See: https://docs.advntr.dev/minimessage/format.html - > See: https://placeholders.pb4.eu/user/quicktext + See: https://docs.advntr.dev/minimessage/format.html + See: https://placeholders.pb4.eu/user/quicktext + - Besides the `server chat format`, each player can use `/chat format set` command to set their `per-player chat format` + Placeholder: - %fuji:item% - %fuji:inv% @@ -371,6 +411,7 @@ public class Chat { public MentionPlayer mention_player = new MentionPlayer(); public History history = new History(); public Display display = new Display(); + public Pattern pattern = new Pattern(); @Documentation(""" New joined players can see the historical chat messages. @@ -384,15 +425,18 @@ public class History { If you insert `Steve` in chat message, then the player named `Steve` will get audio mention. """) public class MentionPlayer { + @Documentation("You can query all the `sound identifier` using `/playsound ...` command.") public String sound = "entity.experience_orb.pickup"; public float volume = 100f; public float pitch = 1f; + @Documentation("The sound repeat count.") public int repeat_count = 3; + @Documentation("The interval between each repeat.") public int interval_ms = 1000; } @Documentation(""" - You can insert `item`, `inv` and `ender` in message to display something with other players. + You can insert `item`, `inv` and `ender` in message to `display` something with other players. """) public class Display { @@ -403,8 +447,11 @@ public class Display { public int expiration_duration_s = 3600; } - public Pattern pattern = new Pattern(); - + @Documentation(""" + The `regex language` list used to `rewrite` the `player chat message`. + + You can use `regex language` to transform player's chat input (only chat message, no command usage). + """) public class Pattern { public List list = new ArrayList<>() { { @@ -468,10 +515,15 @@ public class Tpa { A `work` means a project (a building, a red-stone device ...) that crafted by a player. - All `work` types: - 1. Non-production work: the project don't produce any resource (e.g. bone, string, coal). - 2. Production work: the project produce some resource. - For a production-work, fuji provides the `production sample` to count the `hopper` and `minecart-hopper` + `work` types: + - `Non-production work`: the project don't produce any resource (e.g. bone, string, coal). + - `Production work`: the project produce some resource. + For a production-work, fuji provides the `production sample` to count the `hopper` and `minecart-hopper` + + Note: + - You can use the `production counter` provided by `production work` to sample the output. + - This module works with `carpet-fabric`'s `hopper counter`. You can use both of them at the same time. + - The hopper counter provided by this module will not `destroy the item`. """) public class Works { @@ -508,7 +560,6 @@ public class WorldDownloader { public int context_cache_size = 5; } - public Disabler disabler = new Disabler(); @Documentation(""" This module provides `disabler` to disable checkers in `vaniila minecraft`. """) @@ -519,9 +570,7 @@ public class Disabler { public MoveSpeedDisabler move_speed_disabler = new MoveSpeedDisabler(); public MaxPlayerDisabler max_player_disabler = new MaxPlayerDisabler(); - @Documentation(""" - This module bypass "Kicked for spamming" - """) + @Documentation("Disable `Kicked for spamming`") public class ChatSpeedDisabler { public boolean enable = true; } @@ -531,20 +580,21 @@ public class MoveSpeedDisabler { public boolean enable = true; } - @Documentation(""" - Bypass the max players limit of the server. - """) + @Documentation("Disable the max players limit of the server.") public class MaxPlayerDisabler { public boolean enable = true; } } - @Documentation(""" This module provides `/deathlog` command. Log player's inventory when he die, so that we can restore his inventory later. + Usage: + - If you want to query the death logs for player `Steve`: `/deathlog view Steve` + - If you want to restore **the death log indexed 0 from `Steve`** for player `Steve`: `/deathlog restore Steve 0 Steve` + """) public class DeathLog { public boolean enable = false; @@ -552,6 +602,7 @@ public class DeathLog { @Documentation(""" This module provides some extra `placeholder`. + Extra placeholder: - %fuji:player_mined% - %fuji:server_mined% @@ -564,8 +615,10 @@ public class DeathLog { - %fuji:player_playtime% - %fuji:server_playtime% - You can also use [the default available placeholders](https://placeholders.pb4.eu/user/default-placeholders/) - in anywhere. (Yeah, you can use `placeholder` in the `en_us.json` language file, it works) + Tips: + - You can also use [the default available placeholders](https://placeholders.pb4.eu/user/default-placeholders/) + in anywhere. (Yeah, you can use `placeholder` in the `en_us.json` language file, it works) + """) public class Placeholder { public boolean enable = false; @@ -603,10 +656,9 @@ public class Pvp { } @Documentation(""" - for offline whitelist, this makes whitelist ONLY compare the username and ignore UUID! + for `offline-mode` whitelist, this makes whitelist `only` compare the username and `ignore` UUID! """) public class Whitelist { - public boolean enable = false; } @@ -631,7 +683,6 @@ public class Head { This module provides `/profiler` command to show server health status (including os, vm, cpu, ram, tps, mspt and gc) """) public class Profiler { - public boolean enable = false; } @@ -643,14 +694,20 @@ public class CommandSpy { @Documentation(""" This module provides scheduler for auto-run jobs, and `/schudler_trigger` command. - You can add schedule jobs by cron expression, set the random command-list to be executed. - + You can add schedule jobs by `cron expression`, set the random command-list to be executed. """) public class Scheduler { public boolean enable = false; } - @Documentation("This module provides `/fuji reload` command, so that you can reload modules in game.") + @Documentation(""" + This module provides `/fuji reload` command, so that you can reload modules in game. + + Note: + - After you `enable` or `disable` a `module`, you must `restart` the server. + The command `/fuji reload` only works for `module options`. + + """) public class Config { public boolean enable = false; } @@ -661,21 +718,15 @@ public class Config { If you enable this module in a production-environment, then nothing will happen. """) public class Test { - // disable TestModule by default public boolean enable = false; } - - - @Documentation(""" This module provides multi-language support for your players. - - Disable this module: all the players use the `default_language` - - Enable this module: will try to respect the player's client-side language, if the server-side supports its - language + Difference: + - Disable this module: all the players use the `default_language` + - Enable this module: will try to respect the player's client-side language, if the server-side supports its language Feature: - Respect the player's client-side language-setting. @@ -688,7 +739,6 @@ public class Language { public boolean enable = false; } - @Documentation(""" This module provides afk detection. @@ -696,10 +746,14 @@ public class Language { A afk player will display in `tab list`. A player can issue `/afk` command to afk manually. + + Note: + - There is no protect for a `afk player` + """) public class Afk { - public boolean enable = false; + @Documentation("The tab-name format when a player is afk") public String format = "[AFK] %player:name_visual%"; @@ -714,28 +768,25 @@ public class AfkChecker { } } - @Documentation(""" This module allows you to write commands in `sign block`. Example 1 - ``` /say hi %player:name% line 2 empty line 3 empty line 4 epmty ``` - + Example 2 - ``` prefix /say first /say the second /say hi %player:name% /say the last command ``` - + Example 3 ``` prefix /say this is @@ -743,24 +794,16 @@ public class AfkChecker { second line 4 empty ``` - + Note: - - You need to press `shift + right click` to edit an `interactive sign` - The command is executed as `the player in the console`. (Not executed as the console) + """) public class CommandInteractive { - public boolean enable = false; - } - - - - - - @Documentation(""" This module provides `/home` command. @@ -772,7 +815,6 @@ public class Home { public boolean enable = false; } - @Documentation(""" This module allows you to custom every system-message defined by mojang in `./assets/minecraft/lang/en_us.json` @@ -784,13 +826,13 @@ public class Home { - Player death message - Player command feedback - Player white-list message - - ... (and 7000+ other system messages) + - ... (and more other system messages) """) public class SystemMessage { public boolean enable = false; - @Documentation("The language keys to hijack.") + @Documentation("The language keys to modify.") public Map key2value = new HashMap<>() { { this.put("multiplayer.player.joined", "+ %s"); @@ -802,12 +844,10 @@ public class SystemMessage { } - @Documentation(""" This module provides `/sit` command, and the ability to sit by right-click any chair. """) public class Sit { - public boolean enable = false; public boolean allow_right_click_sit = true; public int max_distance_to_sit = -1; @@ -822,6 +862,9 @@ public class Sit { An alias means we redirect a command-node into another command-node. The requirement of comamnd-node is extended. + + The format is: `source command node path` and `destination command node path` + """) public class CommandAlias { public boolean enable = false; @@ -838,7 +881,7 @@ public class CommandAlias { """) public class CommandRewrite { public boolean enable = false; - public List rules = new ArrayList<>() { + public List regex = new ArrayList<>() { { this.add(new CommandRewriteEntry("home", "home tp default")); } @@ -846,54 +889,44 @@ public class CommandRewrite { } - @Documentation("This module provides `/world` command, which teleport the player to target dimension.") public class World { public boolean enable = false; - } - @Documentation(""" This module provides some `numeric multiplier`. - + Supported `numeric types`: - `damage`: damage to plaer - `experience`: experience a player gained - + Example 1 - If you want to `doubled` the damage from zombie to a player. You can set a meta by: `/lp group default meta set fuji.multiplier.damage.minecraft:zombie 2` - + Example 2 - If you want to cancel fall damage for all players. You can use `damage multiplier`. You can set a meta by: `/lp group default meta set fuji.multiplier.damage.minecraft:fall 0` - + Example 3 - If you want to `doubled` all the damages to a player. You can set a meta by: `/lp group default meta set fuji.multiplier.damage.all 2` - + Example 4 - If you want to `doubled` all the experience a player gained. You can set a meta by: `/lp group default meta set fuji.multiplier.experience.all 2` - + Example 5 - If you want to `half` all the damages to a player. You can set a meta by: `/lp group default meta set fuji.multiplier.damage.all 0.5` - + """) public class Multiplier { public boolean enable = false; } - public AntiBuild anti_build = new AntiBuild(); - @Documentation(""" This module provides anti-build purpose. @@ -913,6 +946,11 @@ public class Multiplier { Use `/lp user permission set fuji.anti_build.place_block.bypass.minecraft:tnt` to allow a player place the tnt. + + Tips: + - To query `blcok identifier`, use `/setblock ~ ~ ~ ...` command. + - To query `entity identifier`, use `/summon ...` command. + - To query `item identifier`, use `/give ...` command. """) public class AntiBuild { @@ -921,8 +959,11 @@ public class AntiBuild { public Anti anti = new Anti(); public class Anti { - public Break break_block = new Break(); + public Place place_block = new Place(); + public InteractItem interact_item = new InteractItem(); + public InteractBlock interact_block = new InteractBlock(); + public InteractEntity interact_entity = new InteractEntity(); public class Break { public Set id = new HashSet<>() { @@ -932,8 +973,6 @@ public class Break { }; } - public Place place_block = new Place(); - public class Place { public Set id = new HashSet<>() { { @@ -942,8 +981,6 @@ public class Place { }; } - public InteractItem interact_item = new InteractItem(); - public class InteractItem { public Set id = new HashSet<>() { { @@ -952,8 +989,6 @@ public class InteractItem { }; } - public InteractBlock interact_block = new InteractBlock(); - public class InteractBlock { public Set id = new HashSet<>() { { @@ -962,8 +997,6 @@ public class InteractBlock { }; } - public InteractEntity interact_entity = new InteractEntity(); - public class InteractEntity { public Set id = new HashSet<>() { { @@ -972,51 +1005,78 @@ public class InteractEntity { }; } - } } - public Nickname nickname = new Nickname(); - @Documentation(""" This module provides `/nickname` command. + + Tips: + - You can query real name using `realname module` + - To show the `nickname`, you need to use `%player:displayname%` or `%player:displayname_visual%` placeholders. + """) public class Nickname { public boolean enable = false; } - public Color color = new Color(); @Documentation(""" This module provides colorize for: sign, anvil + + Tips: + - You can use `mini-message language` to define complex message format. (See more in `chat module`) + """) public class Color { public boolean enable = false; public Sign sign = new Sign(); + public Anvil anvil = new Anvil(); + + @Documentation("Enable `color` for all sign blocks.") public class Sign { public boolean enable = true; } - public Anvil anvil = new Anvil(); + @Documentation("Enable `color` for anvil.") public class Anvil { public boolean enable = true; } } - public Functional functional = new Functional(); @Documentation(""" - This module provides commands to open `remote functional blocks` (e.g. workbench, enderchest...) + This module provides commands to open `remote functional blocks`. + + Functional blocks: + - /workbench + - /enchantment + - /grindstone + - /stonecutter + - /anvil + - /cartography + - /enderchest + - /smithing + - /loom + """) public class Functional { public boolean enable = false; public Workbench workbench = new Workbench(); + public Enchantment enchantment = new Enchantment(); + public GrindStone grindstone = new GrindStone(); + public StoneCutter stonecutter = new StoneCutter(); + public Anvil anvil = new Anvil(); + public Cartography cartography = new Cartography(); + public EnderChest enderchest = new EnderChest(); + public Smithing smithing = new Smithing(); + public Loom loom = new Loom(); + @Documentation("This module provides `/workbench` command.") public class Workbench { public boolean enable = true; } - public Enchantment enchantment = new Enchantment(); @Documentation("This module provides `/enchantment` command.") public class Enchantment { @@ -1029,52 +1089,44 @@ public class OverridePower { public boolean enable = true; @Documentation(""" - How many power providers for the opened enchant table. - For a max level of enchant table, it requires 15 power providers.""") + How many power providers for the opened enchant table. + For a max level of enchant table, it requires 15 power providers.""") public int power_provider_amount = 15; } } - public GrindStone grindstone = new GrindStone(); @Documentation("This module provides `/grindstone` command.") public class GrindStone { - public boolean enable = true; } - public StoneCutter stonecutter = new StoneCutter(); @Documentation("This module provides `/stonecutter` command.") public class StoneCutter { public boolean enable = true; } - public Anvil anvil = new Anvil(); @Documentation("This module provides `/anvil` command.") public class Anvil { public boolean enable = true; } - public Cartography cartography = new Cartography(); @Documentation("This module provides `/cartography` command.") public class Cartography { public boolean enable = true; } - public EnderChest enderchest = new EnderChest(); @Documentation("This module provides `/enderchest` command.") public class EnderChest { public boolean enable = true; } - public Smithing smithing = new Smithing(); @Documentation("This module provides `/smithing` command.") public class Smithing { public boolean enable = true; } - public Loom loom = new Loom(); @Documentation("This module provides `/loom` command.") public class Loom { public boolean enable = true; @@ -1082,7 +1134,6 @@ public class Loom { } - public Carpet carpet = new Carpet(); @Documentation(""" This module provides some purpose about `carpet-fabric` mod. """) @@ -1090,30 +1141,32 @@ public class Carpet { public boolean enable = false; public FakePlayerManager fake_player_manager = new FakePlayerManager(); + public BetterInfo better_info = new BetterInfo(); + @Documentation(""" - Enable this module requires `carpet-fabric` mod installed. - - This module provides some management for `fake-player` and `/player` command. - """) + Enable this module requires `carpet-fabric` mod installed. + + This module provides some management for `fake-player` and `/player who` command. + """) public class FakePlayerManager { public boolean enable = true; @Documentation(""" - How many fake-player can each player spawn (in different time)? - - The tuple means (day_of_week, minutes_of_the_day, max_fake_player_per_player). - The range of day_of_week is [1,7]. - The range of minutes_of_the_day is [0, 1440]. - - For example: (1, 0, 2) means if the days_of_week >= 1, and minutes_of_the_day >= 0, then the max_fake_player_per_player now is 2. - - Besides, you can add multi rules, the rules are checked from up to down. - The first rule that matches current time will be used to decide the max_fake_player_per_player. - - You can issue `/player who` to see the owner of the fake-player. - Only the owner can operates the fake-player. (Op can bypass this limit) - - """) + How many fake-player can each player spawn (in different time)? + + The tuple means (day_of_week, minutes_of_the_day, max_fake_player_per_player). + The range of day_of_week is [1,7]. + The range of minutes_of_the_day is [0, 1440]. + + For example: (1, 0, 2) means if the days_of_week >= 1, and minutes_of_the_day >= 0, then the max_fake_player_per_player now is 2. + + Besides, you can add multi rules, the rules are checked from up to down. + The first rule that matches current time will be used to decide the max_fake_player_per_player. + + You can issue `/player who` to see the owner of the fake-player. + Only the owner can operates the fake-player. (Op can bypass this limit) + + """) public ArrayList> caps_limit_rule = new ArrayList<>() { { this.add(List.of(1, 0, 2)); @@ -1121,43 +1174,41 @@ The tuple means (day_of_week, minutes_of_the_day, max_fake_player_per_player). }; @Documentation(""" - How long should we renew when a player issue command `/player renew` - - The command `/player renew` allows the player to manually renew all of his `fake-player`. - - If a fake-player don't gets renew, then it will expired and get killed. - - Use-case: to avoid some long-term alive fake-player. - """) + How long should we renew when a player issue command `/player renew` + + The command `/player renew` allows the player to manually renew all of his `fake-player`. + + If a fake-player don't gets renew, then it will expired and get killed. + + Use-case: to avoid some long-term alive fake-player. + """) public int renew_duration_ms = 1000 * 60 * 60 * 12; @Documentation(""" - The rule to transform the name of fake-player. - - Use-case: add prefix or suffix for fake-player. - """) + The rule to transform the name of fake-player. + + Use-case: add prefix or suffix for fake-player. + """) public String transform_name = "_fake_%name%"; @Documentation(""" - Should we use local skin for fake-player? - - Enable this can prevent fetching skins from mojang official server each time the fake-player is spawned. - This is mainly used in some network siatuation if your network to mojang official server is bad. - """) + Should we use local skin for fake-player? + + Enable this can prevent fetching skins from mojang official server each time the fake-player is spawned. + This is mainly used in some network siatuation if your network to mojang official server is bad. + """) public boolean use_local_random_skins_for_fake_player = true; } - public BetterInfo better_info = new BetterInfo(); @Documentation(""" - Adds nbt query and entity query for carpet command `/info`. - """) + - Add `nbt query` for `/info block` command. + - Add the command `/info entity`. + """) public class BetterInfo { public boolean enable = true; } } - - public CommandToolbox command_toolbox = new CommandToolbox(); @Documentation(""" This module provies some `simple` commands. We said a `command` is `simple` since its puporse is not big enough to be a standalone `facility`. @@ -1166,91 +1217,106 @@ public class CommandToolbox { public boolean enable = false; public Bed bed = new Bed(); + public Extinguish extinguish = new Extinguish(); + public Feed feed = new Feed(); + public Fly fly = new Fly(); + public God god = new God(); + public Hat hat = new Hat(); + public Heal heal = new Heal(); + public More more = new More(); + public Ping ping = new Ping(); + public Realname realname = new Realname(); + public Repair repair = new Repair(); + public Reply reply = new Reply(); + public Seen seen = new Seen(); + public Suicide suicide = new Suicide(); + public Top top = new Top(); + public SendMessage send_message = new SendMessage(); + public SendBroadcast send_broadcast = new SendBroadcast(); + public SendActionBar send_actionbar = new SendActionBar(); + public ForEach for_each = new ForEach(); + public Shell shell = new Shell(); + @Documentation("This module provides `/bed` command, which teleports the player to his bed.") public class Bed { - public boolean enable = true; } - public Extinguish extinguish = new Extinguish(); + @Documentation("This module provides `/extinguish` command.") public class Extinguish { public boolean enable = true; } - public Feed feed = new Feed(); + @Documentation("This module provides `/feed` command.") public class Feed { public boolean enable = true; } - public Fly fly = new Fly(); + @Documentation("This module provides `/fly` command.") public class Fly { public boolean enable = true; } - public God god = new God(); + @Documentation("This module provides `/god` command.") public class God { public boolean enable = true; } - public Hat hat = new Hat(); + @Documentation("This module provides `/hat` command.") public class Hat { public boolean enable = true; } - public Heal heal = new Heal(); + @Documentation("This module provides `/heal` command.") public class Heal { public boolean enable = true; } - public More more = new More(); @Documentation("This module provides `/more` command.") public class More { public boolean enable = true; } - public Ping ping = new Ping(); + @Documentation("This module provides `/ping` command.") public class Ping { public boolean enable = true; } - public Realname realname = new Realname(); + @Documentation("This module provides `/realname` command.") public class Realname { public boolean enable = true; } - public Repair repair = new Repair(); + @Documentation("This module provides `/repair` command.") public class Repair { public boolean enable = true; } - public Reply reply = new Reply(); @Documentation("This module provides `/reply` command, which replys the recent player who `/msg` you") public class Reply { public boolean enable = true; } - public Seen seen = new Seen(); @Documentation("This module provides `/seen` command.") public class Seen { public boolean enable = true; } - public Suicide suicide = new Suicide(); + @Documentation("This module provides `/suicide` command.") public class Suicide { public boolean enable = true; } - public Top top = new Top(); + @Documentation(""" - This module provides `/top` command. - """) + This module provides `/top` command. + """) public class Top { public boolean enable = true; } - public SendMessage send_message = new SendMessage(); @Documentation(""" This module provides `/sendmessage` command. """) @@ -1258,7 +1324,6 @@ public class SendMessage { public boolean enable = true; } - public SendBroadcast send_broadcast = new SendBroadcast(); @Documentation(""" This module provides `/sendbroadcast` command. """) @@ -1266,25 +1331,43 @@ public class SendBroadcast { public boolean enable = true; } - public SendActionBar send_actionbar = new SendActionBar(); + @Documentation(""" + This module provides `/sendactionbar` command. + """) public class SendActionBar { public boolean enable = true; } - public ForEach for_each = new ForEach(); + @Documentation(""" + This module provides `/foreach` command. + + If a command is only targeted for `single player`, you can use `foreach` to apply it for `all players` + + Example 1: `/foreach say hello %player:name%` + + """) public class ForEach { public boolean enable = true; } - public Shell shell = new Shell(); + @Documentation(""" + This module provides `/shell` command, which executes `command line` in your `host shell`. + + This module is a powerful and **`dangerous`** module, **not recommended to enable it**. + + Exmaple 1: `/shell touch %player:name%.dangerous` (Create a file using placeholder) + + Exmaple 2: `/shell emacs` (Execute a program in the host os) + + Example 3: `/shell ...` (Possible to download a virus from Internet and execute it!) + + """) public class Shell { public String enable_warning = "ENABLE THIS MODULE IS POTENTIAL TO HARM YOUR COMPUTER! YOU NEED TO CHANGE THIS FIELD INTO `CONFIRM` TO ENABLE THIS MODULE"; public boolean enable = false; } } - - public TabList tab_list = new TabList(); @Documentation(""" This module provides tab-list custom. """) @@ -1292,15 +1375,20 @@ public class TabList { public boolean enable = false; public int update_tick = 20; public Style style = new Style(); + public class Style { public String header = "TabList------%server:online%/%server:max_players%------"; public String footer = "-----------------TPS: %server:tps_colored% PING: %player:ping_colored%Memory: %server:used_ram%/%server:max_ram% MB"; } } - public Kit kit = new Kit(); + @Documentation(""" + + Command: /kit + + """) public class Kit { - public boolean enable = true; + public boolean enable = false; } } } diff --git a/src/main/java/io/github/sakurawald/module/initializer/command_cooldown/CommandCooldownInitializer.java b/src/main/java/io/github/sakurawald/module/initializer/command_cooldown/CommandCooldownInitializer.java index 0aa79a62a..74d66e846 100644 --- a/src/main/java/io/github/sakurawald/module/initializer/command_cooldown/CommandCooldownInitializer.java +++ b/src/main/java/io/github/sakurawald/module/initializer/command_cooldown/CommandCooldownInitializer.java @@ -16,7 +16,7 @@ public long calculateCommandCooldown(ServerPlayerEntity player, String commandLi // find the matched cooldown-entry HashMap commandRegex2LastExecutedTimeMS = map.computeIfAbsent(player, k -> new HashMap<>()); long leftTime = 0; - for (Map.Entry entry : Configs.configHandler.model().modules.command_cooldown.command_regex_2_cooldown_ms.entrySet()) { + for (Map.Entry entry : Configs.configHandler.model().modules.command_cooldown.regex2ms.entrySet()) { if (!commandLine.matches(entry.getKey())) continue; long commandLineLastExecutedTimeMS = commandRegex2LastExecutedTimeMS.computeIfAbsent(entry.getKey(), k -> 0L); diff --git a/src/main/java/io/github/sakurawald/module/initializer/top_chunks/TopChunksInitializer.java b/src/main/java/io/github/sakurawald/module/initializer/top_chunks/TopChunksInitializer.java index 0eca68bad..c7d517b2b 100644 --- a/src/main/java/io/github/sakurawald/module/initializer/top_chunks/TopChunksInitializer.java +++ b/src/main/java/io/github/sakurawald/module/initializer/top_chunks/TopChunksInitializer.java @@ -77,12 +77,12 @@ public void registerCommand(CommandDispatcher dispatcher, C /* send output */ ConfigModel.Modules.TopChunks topChunks = Configs.configHandler.model().modules.top_chunks; - calculateNearestPlayer(ctx.getSource(), PQ, topChunks.rows * topChunks.columns); + calculateNearestPlayer(ctx.getSource(), PQ, topChunks.top.rows * topChunks.top.columns); TextComponent.Builder textComponentBuilder = Component.text(); outer: - for (int j = 0; j < topChunks.rows; j++) { - for (int i = 0; i < topChunks.columns; i++) { + for (int j = 0; j < topChunks.top.rows; j++) { + for (int i = 0; i < topChunks.top.columns; i++) { if (PQ.isEmpty()) break outer; textComponentBuilder.append(PQ.poll().asComponent(ctx.getSource())).appendSpace(); } diff --git a/src/main/java/io/github/sakurawald/module/mixin/command_rewrite/ServerPlayNetworkHandlerMixin.java b/src/main/java/io/github/sakurawald/module/mixin/command_rewrite/ServerPlayNetworkHandlerMixin.java index 33b69bad6..e22566d98 100644 --- a/src/main/java/io/github/sakurawald/module/mixin/command_rewrite/ServerPlayNetworkHandlerMixin.java +++ b/src/main/java/io/github/sakurawald/module/mixin/command_rewrite/ServerPlayNetworkHandlerMixin.java @@ -14,7 +14,7 @@ public class ServerPlayNetworkHandlerMixin { @ModifyVariable(method = "executeCommand", at = @At(value = "HEAD"), ordinal = 0, argsOnly = true) public String $execute(String string) { - for (CommandRewriteEntry rule : Configs.configHandler.model().modules.command_rewrite.rules) { + for (CommandRewriteEntry rule : Configs.configHandler.model().modules.command_rewrite.regex) { if (string.matches(rule.from)) { return string.replaceAll(rule.from, rule.to); }