Compare commits

..

1 Commits

Author SHA1 Message Date
MrHua269
a7899ce2a0 Fix off region thrown egg new entity creating
should set pos before so that we could correctly modify the entity's other attribute on-region without triggering the async catchers
2025-06-05 21:12:44 +08:00
89 changed files with 298 additions and 508 deletions

View File

@@ -19,8 +19,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 22
distribution: 'zulu'
java-version: '22'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
@@ -28,16 +28,17 @@ jobs:
- name: Configure Git User Details
run: git config --global user.email "ci@luminolmc.com" && git config --global user.name "LuminolMC CI"
- name: Apply All Patches
- name: Apply Patches
run: ./gradlew applyAllPatches
- name: CreateMojmapPaperclipJar
- name: CreateJar
run: ./gradlew createMojmapPaperclipJar
- name: Publish to repo
if: github.event_name != 'pull_request'
continue-on-error: true
run: ./gradlew generateDevelopmentBundle publish -PpublishDevBundle=true
run: |
./gradlew generateDevelopmentBundle publish -PpublishDevBundle=true
env:
PRIVATE_MAVEN_REPO_PASSWORD: ${{ secrets.PRIVATE_MAVEN_REPO_PASSWORD }}
PRIVATE_MAVEN_REPO_USERNAME: ${{ secrets.PRIVATE_MAVEN_REPO_USERNAME }}
@@ -45,8 +46,8 @@ jobs:
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.project_id_b }} CI Artifacts
path: luminol-server/build/libs/*-paperclip-*-mojmap.jar
name: "${{ env.project_id_b }} CI Artifacts"
path: "luminol-server/build/libs/*-paperclip-*-mojmap.jar"
- name: SetENV
if: github.event_name != 'pull_request'
@@ -63,8 +64,9 @@ jobs:
This release is automatically compiled by GitHub Actions
### Commit Message
${{ env.commit_msg }}
artifacts: ${{ env.jar_dir }}
artifacts: |
${{ env.jar_dir }}
generateReleaseNotes: true
prerelease: ${{ env.pre }}
prerelease: false
makeLatest: ${{ env.make_latest }}
token: ${{ secrets.GITHUB_TOKEN }}
token: "${{ secrets.GITHUB_TOKEN }}"

View File

@@ -2,7 +2,7 @@ group = me.earthme.luminol
version=1.21.5-R0.1-SNAPSHOT
mcVersion=1.21.5
foliaRef=6c77040ff6ad3401687b1fc49f9d0e8e2e09de87
foliaRef=da0d7cd1beb8eb7b84a5210dcefa6ffb4cce7415
org.gradle.configuration-cache=true
org.gradle.caching=true

View File

@@ -54,7 +54,7 @@
dependencies {
- implementation(project(":folia-api"))
+ implementation(project(":luminol-api")) // Luminol
+ implementation("com.electronwill.night-config:toml:3.8.2") // Luminol - Night config
+ implementation("com.electronwill.night-config:toml:3.6.6") // Luminol - Night config
+ // Abomination start
+ implementation("com.github.luben:zstd-jni:1.5.4-1")
+ implementation("org.lz4:lz4-java:1.8.0")

View File

@@ -1,56 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
Date: Wed, 4 Jun 2025 12:51:07 +0800
Subject: [PATCH] Leaves: Configurable collision behavior
Co-authored by: Fortern <blueten.ki@gmail.com>
As part of: Leaves (https://github.com/LeavesMC/Leaves/blob/c5f18b7864206cea4411211b51787f10affbcb9c/leaves-server/minecraft-patches/features/0111-Configurable-collision-behavior.patch)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index e1bf7bc3cca63101b3c0550b5b4c0d28d0f3776e..d753d550b1df88ad9f2315ec3fc8f342be183c6d 100644
--- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -101,6 +101,14 @@ public final class CollisionUtil {
(box1.minZ - box2.maxZ) < -COLLISION_EPSILON && (box1.maxZ - box2.minZ) > COLLISION_EPSILON;
}
+ // Leaves start - Configurable collision behavior
+ public static boolean voxelShapeIntersectVanilla(final AABB box1, final AABB box2) {
+ return box1.minX < box2.maxX && box1.maxX > box2.minX &&
+ box1.minY < box2.maxY && box1.maxY > box2.minY &&
+ box1.minZ < box2.maxZ && box1.maxZ > box2.minZ;
+ }
+ // Leaves end - Configurable collision behavior
+
// assume !isEmpty(target) && abs(source_move) >= COLLISION_EPSILON
public static double collideX(final AABB target, final AABB source, final double source_move) {
if ((source.minY - target.maxY) < -COLLISION_EPSILON && (source.maxY - target.minY) > COLLISION_EPSILON &&
@@ -2025,7 +2033,7 @@ public final class CollisionUtil {
AABB singleAABB = ((CollisionVoxelShape)blockCollision).moonrise$getSingleAABBRepresentation();
if (singleAABB != null) {
singleAABB = singleAABB.move((double)blockX, (double)blockY, (double)blockZ);
- if (!voxelShapeIntersect(aabb, singleAABB)) {
+ if (shouldSkip(aabb, blockCollision, singleAABB)) { // Leaves - Configurable collision behavior
continue;
}
@@ -2078,6 +2086,18 @@ public final class CollisionUtil {
return ret;
}
+ // Leaves start - Configurable collision behavior
+ private static boolean shouldSkip(AABB aabb, VoxelShape blockCollision, AABB singleAABB) {
+ boolean isBlockShape = blockCollision == Shapes.block();
+ return switch (me.earthme.luminol.config.modules.misc.CollisionBehaviorConfig.behaviorMode) {
+ case "VANILLA" -> !voxelShapeIntersectVanilla(aabb, singleAABB);
+ case "PAPER" -> !voxelShapeIntersect(aabb, singleAABB);
+ default -> isBlockShape && !voxelShapeIntersectVanilla(aabb, singleAABB) || !isBlockShape && !voxelShapeIntersect(aabb, singleAABB);
+ // All other value as BLOCK_SHAPE_VANILLA to process
+ };
+ }
+ // Leaves end - Configurable collision behavior
+
public static boolean getEntityHardCollisions(final Level world, final Entity entity, AABB aabb,
final List<AABB> into, final int collisionFlags, final Predicate<Entity> predicate) {
final boolean checkOnly = (collisionFlags & COLLISION_FLAG_CHECK_ONLY) != 0;

View File

@@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrHua269 <wangxyper@163.com>
Date: Sat, 8 Feb 2025 14:25:16 +0800
Subject: [PATCH] Leaves: Fix Incorrect Collision Behavior for Block Shape
Co-authored by: Fortern <blueten.ki@gmail.com>
As part of: Leaves (https://github.com/LeavesMC/Leaves/blob/f553c53e4230aa032e54a69b6479f1959ed24a60/leaves-server/minecraft-patches/features/0110-Fix-Incorrect-Collision-Behavior-for-Block-Shape.patch)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index e1bf7bc3cca63101b3c0550b5b4c0d28d0f3776e..ea01087967dd9ff32b23661079e97ea468d31163 100644
--- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -101,6 +101,14 @@ public final class CollisionUtil {
(box1.minZ - box2.maxZ) < -COLLISION_EPSILON && (box1.maxZ - box2.minZ) > COLLISION_EPSILON;
}
+ // Leaves start
+ public static boolean voxelShapeIntersectVanilla(final net.minecraft.world.phys.AABB box1, final net.minecraft.world.phys.AABB box2) {
+ return box1.minX < box2.maxX && box1.maxX > box2.minX &&
+ box1.minY < box2.maxY && box1.maxY > box2.minY &&
+ box1.minZ < box2.maxZ && box1.maxZ > box2.minZ;
+ }
+ // Leaves end
+
// assume !isEmpty(target) && abs(source_move) >= COLLISION_EPSILON
public static double collideX(final AABB target, final AABB source, final double source_move) {
if ((source.minY - target.maxY) < -COLLISION_EPSILON && (source.maxY - target.minY) > COLLISION_EPSILON &&
@@ -2025,7 +2033,10 @@ public final class CollisionUtil {
AABB singleAABB = ((CollisionVoxelShape)blockCollision).moonrise$getSingleAABBRepresentation();
if (singleAABB != null) {
singleAABB = singleAABB.move((double)blockX, (double)blockY, (double)blockZ);
- if (!voxelShapeIntersect(aabb, singleAABB)) {
+ // Leaves start - Fix incorrect collision behavior for block shape
+ boolean isBlockShape = blockCollision == net.minecraft.world.phys.shapes.Shapes.block();
+ if (isBlockShape && !voxelShapeIntersectVanilla(aabb, singleAABB) || !isBlockShape && !voxelShapeIntersect(aabb, singleAABB)) {
+ // Leaves end - Fix incorrect collision behavior for block shape
continue;
}

View File

@@ -8,7 +8,7 @@ As part of: Leaves (https://github.com/LeavesMC/Leaves/blob/f553c53e4230aa032e54
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index bcc0c3cfa5be4daeec6e95a1b63a6cd38890f04d..e83c6a81e318a05580f5c811cb2543a83435f04c 100644
index 5564bba66959a2a280f700f6c6a05d292faced88..4492f3ab470c0bf735b6fdc69115c1ebbcd727ef 100644
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -1285,7 +1285,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc

View File

@@ -1,22 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
Date: Wed, 4 Jun 2025 12:54:22 +0800
Subject: [PATCH] Leaves: Fix chunk reload detector
Co-authored by: Fortern <blueten.ki@gmail.com>
As part of: Leaves (https://github.com/LeavesMC/Leaves/blob/c5f18b7864206cea4411211b51787f10affbcb9c/leaves-server/minecraft-patches/features/0123-Fix-chunk-reload-detector.patch)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
index b118e91f1e0b5a8b8c0b2a4a32faabc5a34a5954..663bd286426537daf97ae09dc7e076a9ec6d4c9c 100644
--- a/net/minecraft/server/level/ServerEntity.java
+++ b/net/minecraft/server/level/ServerEntity.java
@@ -376,7 +376,7 @@ public class ServerEntity {
if (!list.isEmpty()) {
consumer.accept(new ClientboundSetEquipmentPacket(this.entity.getId(), list, true)); // Paper - data sanitization
}
- ((LivingEntity) this.entity).detectEquipmentUpdates(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
+ if (this.entity.totalEntityAge == 0) ((LivingEntity) this.entity).detectEquipmentUpdates(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending // Leaves - fix chunk reload detector (#492)
}
if (!this.entity.getPassengers().isEmpty()) {

View File

@@ -8,7 +8,7 @@ As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish/blob/04bc249
Licensed under: GPL-3.0 (https://github.com/pufferfish-gg/Pufferfish/blob/04bc249f9eee6157338b6884113b6fa3192bf59b/PATCH-LICENSE)
diff --git a/net/minecraft/world/entity/monster/EnderMan.java b/net/minecraft/world/entity/monster/EnderMan.java
index 5ae08be75ca01924fc78bdd8d6bb6747ddc21aea..6e0b6304205210cc60293329fe30bd6c99cd263a 100644
index ab7f7846d3fc0252c6f71277b3e67d7a785a96b5..0f496f0e1c63bc3d8b17a8f0cb065138cb079334 100644
--- a/net/minecraft/world/entity/monster/EnderMan.java
+++ b/net/minecraft/world/entity/monster/EnderMan.java
@@ -300,11 +300,18 @@ public class EnderMan extends Monster implements NeutralMob {

View File

@@ -8,7 +8,7 @@ Co-authored by: MrPowerGamerBR <git@mrpowergamerbr.com>
As part of: SparklyPaper (https://github.com/SparklyPower/SparklyPaper/blob/a69d3690472c9967772ffd4d4bd1f41403b7ea6f/sparklypaper-server/minecraft-patches/features/0002-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch)
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
index 663bd286426537daf97ae09dc7e076a9ec6d4c9c..8739b4e806878cf3a4af9ad1aef7f2a55880d503 100644
index b118e91f1e0b5a8b8c0b2a4a32faabc5a34a5954..8c232ae73a8c6500723994af3a28b36814cccae0 100644
--- a/net/minecraft/server/level/ServerEntity.java
+++ b/net/minecraft/server/level/ServerEntity.java
@@ -205,6 +205,8 @@ public class ServerEntity {

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Correct player respawn place
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index e83c6a81e318a05580f5c811cb2543a83435f04c..2f2726ed97658732751032b21752840702da233e 100644
index 4492f3ab470c0bf735b6fdc69115c1ebbcd727ef..8b9c823deed1844fa69d1456a91ac65487b8ae69 100644
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -492,8 +492,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc

View File

@@ -5,6 +5,19 @@ Subject: [PATCH] Fix mispatched entity custom spawning logic
we should use local players as each tickregion will only foreach their own player entities so that we won't come across async accessing world data
diff --git a/net/minecraft/world/entity/npc/CatSpawner.java b/net/minecraft/world/entity/npc/CatSpawner.java
index f5d27988605d48cdf314f28ba332f33f0a314266..39b506dad0601b2d75acb14989f2758132155d1b 100644
--- a/net/minecraft/world/entity/npc/CatSpawner.java
+++ b/net/minecraft/world/entity/npc/CatSpawner.java
@@ -27,7 +27,7 @@ public class CatSpawner implements CustomSpawner {
worldData.catSpawnerNextTick--; // Folia - region threading
if (worldData.catSpawnerNextTick <= 0) { // Folia - region threading
worldData.catSpawnerNextTick = 1200; // Folia - region threading
- Player randomPlayer = level.getRandomPlayer();
+ Player randomPlayer = level.getRandomLocalPlayer(); // Luminol - Fix mispatched entity custom spawning logic - Use local players for only the players in current tickregion
if (randomPlayer != null) {
RandomSource randomSource = level.random;
int i = (8 + randomSource.nextInt(24)) * (randomSource.nextBoolean() ? -1 : 1);
diff --git a/net/minecraft/world/level/levelgen/PhantomSpawner.java b/net/minecraft/world/level/levelgen/PhantomSpawner.java
index a7f56126a26e1fca86c39d8d656b648f5d6bb4ca..4626ee9f4410d8fd683db17b49ef79ab67eeda5f 100644
--- a/net/minecraft/world/level/levelgen/PhantomSpawner.java

View File

@@ -6,10 +6,10 @@ Subject: [PATCH] Fix off region thrown egg new entity creating
should set pos before so that we could correctly modify the entity's other attribute on-region without triggering the async catchers
diff --git a/net/minecraft/world/entity/projectile/ThrownEgg.java b/net/minecraft/world/entity/projectile/ThrownEgg.java
index 73ec34b43f3fb2aa3edc3f1cb48a923d1fa32036..5760ae39e8c452b8291353ed59ce7f8ef4d43dc1 100644
index 73ec34b43f3fb2aa3edc3f1cb48a923d1fa32036..5d2f80c4dd8cb6726b0f42891d4ddbc85bf153a7 100644
--- a/net/minecraft/world/entity/projectile/ThrownEgg.java
+++ b/net/minecraft/world/entity/projectile/ThrownEgg.java
@@ -97,12 +97,13 @@ public class ThrownEgg extends ThrowableItemProjectile {
@@ -97,17 +97,18 @@ public class ThrownEgg extends ThrowableItemProjectile {
for (int i1 = 0; i1 < i; i1++) {
net.minecraft.world.entity.Entity chicken = newEntityType.create(this.level(), net.minecraft.world.entity.EntitySpawnReason.TRIGGERED); // CraftBukkit
if (chicken != null) {
@@ -24,3 +24,10 @@ index 73ec34b43f3fb2aa3edc3f1cb48a923d1fa32036..5760ae39e8c452b8291353ed59ce7f8e
// CraftBukkit start
if (chicken instanceof Chicken realChicken) {
Optional.ofNullable(this.getItem().get(DataComponents.CHICKEN_VARIANT))
- .flatMap(eitherHolder -> eitherHolder.unwrap(this.registryAccess()))
- .ifPresent(realChicken::setVariant);
+ .flatMap(eitherHolder -> eitherHolder.unwrap(this.registryAccess()))
+ .ifPresent(realChicken::setVariant);
}
// CraftBukkit end
if (!chicken.fudgePositionAfterSizeChange(ZERO_SIZED_DIMENSIONS)) {

View File

@@ -1,6 +1,6 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/commands/LuminolConfigCommand.java
@@ -1,0 +_,121 @@
@@ -1,0 +_,70 @@
+package me.earthme.luminol.commands;
+
+import me.earthme.luminol.config.LuminolConfig;
@@ -16,106 +16,55 @@
+import java.util.List;
+
+public class LuminolConfigCommand extends Command {
+ public LuminolConfigCommand() {
+ public LuminolConfigCommand(){
+ super("luminolconfig");
+ this.setPermission("luminol.commands.luminolconfig");
+ this.setDescription("Manage config file");
+ this.setUsage("/luminolconfig");
+ }
+
+ public void wrongUse(CommandSender sender) {
+ sender.sendMessage(
+ Component
+ .text("Wrong use!")
+ .color(TextColor.color(255, 0, 0))
+ );
+ }
+
+ @Override
+ public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args, @Nullable Location location) throws IllegalArgumentException {
+ final List<String> result = new ArrayList<>();
+
+ if (args.length == 1) {
+ result.add("query");
+ result.add("set");
+ result.add("reset");
+ if (args.length == 1){
+ result.add("reload");
+ } else if (args.length == 2 && (args[0].equals("query") || args[0].equals("set") || args[0].equals("reset"))) {
+ result.addAll(LuminolConfig.completeConfigPath(args[1]));
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
+ if (!this.testPermission(sender)) {
+ if (!this.testPermission(sender)){
+ sender.sendMessage(Component
+ .text("No permission to execute this command!")
+ .color(TextColor.color(255, 0, 0))
+ .color(TextColor.color(255,0,0))
+ );
+ }
+
+ if (args.length < 1) {
+ wrongUse(sender);
+ if (args.length < 1){
+ sender.sendMessage(
+ Component
+ .text("Wrong use!\n")
+ .color(TextColor.color(255,0,0))
+ );
+ return true;
+ }
+
+ switch (args[0]) {
+ switch (args[0]){
+ case "reload" -> {
+ LuminolConfig.reloadAsync().thenAccept(nullValue -> sender.sendMessage(
+ Component
+ .text("Reloaded config file!")
+ .color(TextColor.color(0, 255, 0))
+ .color(TextColor.color(0,255,0))
+ ));
+ }
+ case "set" -> {
+ if (args.length == 2 || args.length > 3) {
+ wrongUse(sender);
+ return true;
+ } else if (LuminolConfig.setConfig(args[1], args[2])) {
+ LuminolConfig.reloadAsync().thenAccept(nullValue -> sender.sendMessage(
+ Component
+ .text("Set Config " + args[1] + " to " + args[2] + " successfully!")
+ .color(TextColor.color(0, 255, 0))
+ ));
+ } else {
+ sender.sendMessage(
+ Component
+ .text("Failed to set config " + args[1] + " to " + args[2] + "!")
+ .color(TextColor.color(255, 0, 0))
+ );
+ }
+ }
+ case "reset" -> {
+ if (args.length != 2) {
+ wrongUse(sender);
+ return true;
+ } else {
+ LuminolConfig.resetConfig(args[1]);
+ LuminolConfig.reloadAsync().thenAccept(nullValue -> sender.sendMessage(
+ Component
+ .text("Reset Config " + args[1] + " to " + LuminolConfig.getConfig(args[1]) + " successfully!")
+ .color(TextColor.color(0, 255, 0))
+ ));
+ }
+ }
+ case "query" -> {
+ if (args.length != 2) {
+ wrongUse(sender);
+ return true;
+ } else {
+ sender.sendMessage(
+ Component
+ .text("Config " + args[1] + " is " + LuminolConfig.getConfig(args[1]) + "!")
+ .color(TextColor.color(0, 255, 0))
+ );
+ }
+ }
+
+ default -> sender.sendMessage(
+ Component
+ .text("Unknown action!")
+ .color(TextColor.color(255, 0, 0))
+ .text("Unknown action!\n")
+ .color(TextColor.color(255,0,0))
+ );
+ }
+

View File

@@ -22,28 +22,28 @@
+
+ @Override
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
+ if (!testPermission(sender)) {
+ if (!testPermission(sender)){
+ return true;
+ }
+
+ if (!MembarConfig.memoryBarEnabled) {
+ sender.sendMessage(Component.text("Membar was already disabled!").color(TextColor.color(255, 0, 0)));
+ if (!MembarConfig.memoryBarEnabled){
+ sender.sendMessage(Component.text("Membar was already disabled!").color(TextColor.color(255,0,0)));
+ return true;
+ }
+
+ if (!(sender instanceof Player player)) {
+ sender.sendMessage(Component.text("Only player can use this command!").color(TextColor.color(255, 0, 0)));
+ if (!(sender instanceof Player player)){
+ sender.sendMessage(Component.text("Only player can use this command!").color(TextColor.color(255,0,0)));
+ return true;
+ }
+
+ if (GlobalServerMemoryBar.isPlayerVisible(player)) {
+ player.sendMessage(Component.text("Disabled mem bar").color(TextColor.color(0, 255, 0)));
+ GlobalServerMemoryBar.setVisibilityForPlayer(player, false);
+ player.sendMessage(Component.text("Disabled mem bar").color(TextColor.color(0,255,0)));
+ GlobalServerMemoryBar.setVisibilityForPlayer(player,false);
+ return true;
+ }
+
+ player.sendMessage(Component.text("Enabled mem bar").color(TextColor.color(0, 255, 0)));
+ GlobalServerMemoryBar.setVisibilityForPlayer(player, true);
+ player.sendMessage(Component.text("Enabled mem bar").color(TextColor.color(0,255,0)));
+ GlobalServerMemoryBar.setVisibilityForPlayer(player,true);
+
+ return true;
+ }

View File

@@ -1,12 +1,15 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/commands/TpsBarCommand.java
@@ -1,0 +_,47 @@
@@ -1,0 +_,50 @@
+package me.earthme.luminol.commands;
+
+import me.earthme.luminol.config.modules.misc.TpsBarConfig;
+import me.earthme.luminol.functions.GlobalServerTpsBar;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.TextColor;
+import net.kyori.adventure.util.RGBLike;
+import org.bukkit.ChatColor;
+import org.bukkit.Color;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
@@ -22,28 +25,28 @@
+
+ @Override
+ public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
+ if (!testPermission(sender)) {
+ if (!testPermission(sender)){
+ return true;
+ }
+
+ if (!TpsBarConfig.tpsbarEnabled) {
+ sender.sendMessage(Component.text("Tpsbar was already disabled!").color(TextColor.color(255, 0, 0)));
+ if (!TpsBarConfig.tpsbarEnabled){
+ sender.sendMessage(Component.text("Tpsbar was already disabled!").color(TextColor.color(255,0,0)));
+ return true;
+ }
+
+ if (!(sender instanceof Player player)) {
+ sender.sendMessage(Component.text("Only player can use this command!").color(TextColor.color(255, 0, 0)));
+ if (!(sender instanceof Player player)){
+ sender.sendMessage(Component.text("Only player can use this command!").color(TextColor.color(255,0,0)));
+ return true;
+ }
+
+ if (GlobalServerTpsBar.isPlayerVisible(player)) {
+ player.sendMessage(Component.text("Disabled tps bar").color(TextColor.color(0, 255, 0)));
+ GlobalServerTpsBar.setVisibilityForPlayer(player, false);
+ player.sendMessage(Component.text("Disabled tps bar").color(TextColor.color(0,255,0)));
+ GlobalServerTpsBar.setVisibilityForPlayer(player,false);
+ return true;
+ }
+
+ player.sendMessage(Component.text("Enabled tps bar").color(TextColor.color(0, 255, 0)));
+ GlobalServerTpsBar.setVisibilityForPlayer(player, true);
+ player.sendMessage(Component.text("Enabled tps bar").color(TextColor.color(0,255,0)));
+ GlobalServerTpsBar.setVisibilityForPlayer(player,true);
+
+ return true;
+ }

View File

@@ -1,7 +1,7 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/flags/ConfigInfo.java
+++ b/src/main/java/me/earthme/luminol/config/ConfigInfo.java
@@ -1,0 +_,11 @@
+package me.earthme.luminol.config.flags;
+package me.earthme.luminol.config;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;

View File

@@ -1,7 +1,7 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/flags/DoNotLoad.java
+++ b/src/main/java/me/earthme/luminol/config/DoNotLoad.java
@@ -1,0 +_,8 @@
+package me.earthme.luminol.config.flags;
+package me.earthme.luminol.config;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;

View File

@@ -1,7 +1,7 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/flags/HotReloadUnsupported.java
+++ b/src/main/java/me/earthme/luminol/config/HotReloadUnsupported.java
@@ -1,0 +_,8 @@
+package me.earthme.luminol.config.flags;
+package me.earthme.luminol.config;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;

View File

@@ -1,6 +1,6 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/IConfigModule.java
@@ -1,0 +_,23 @@
@@ -1,0 +_,22 @@
+package me.earthme.luminol.config;
+
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
@@ -12,12 +12,11 @@
+
+ String getBaseName();
+
+ default void onLoaded(CommentedFileConfig configInstance) {
+ }
+ default void onLoaded(CommentedFileConfig configInstance) {}
+
+ default <T> T get(String keyName, T defaultValue, @NotNull CommentedFileConfig config) {
+ if (!config.contains(keyName)) {
+ config.set(keyName, defaultValue);
+ default <T> T get(String keyName, T defaultValue, @NotNull CommentedFileConfig config){
+ if (!config.contains(keyName)){
+ config.set(keyName,defaultValue);
+ return defaultValue;
+ }
+

View File

@@ -1,16 +1,12 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/LuminolConfig.java
@@ -1,0 +_,378 @@
@@ -1,0 +_,275 @@
+package me.earthme.luminol.config;
+
+import com.electronwill.nightconfig.core.UnmodifiableConfig;
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
+import io.papermc.paper.threadedregions.RegionizedServer;
+import me.earthme.luminol.commands.LuminolConfigCommand;
+import me.earthme.luminol.config.flags.ConfigInfo;
+import me.earthme.luminol.config.flags.DoNotLoad;
+import me.earthme.luminol.config.flags.HotReloadUnsupported;
+import me.earthme.luminol.config.flags.TransformedConfig;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.bukkit.Bukkit;
@@ -36,14 +32,12 @@
+ private static final File baseConfigFolder = new File("luminol_config");
+ private static final File baseConfigFile = new File(baseConfigFolder, "luminol_global_config.toml");
+ private static final Set<IConfigModule> allInstanced = new HashSet<>();
+ private static final Map<String, Object> stagedConfigMap = new HashMap<>();
+ private static final Map<String, Object> defaultvalueMap = new HashMap<>();
+ public static boolean alreadyInit = false;
+ public static boolean alreadyInited = false;
+ private static CommentedFileConfig configFileInstance;
+
+ public static void setupLatch() {
+ Bukkit.getCommandMap().register("luminolconfig", "luminol", new LuminolConfigCommand());
+ alreadyInit = true;
+ alreadyInited = true;
+ }
+
+ public static void reload() {
@@ -86,7 +80,7 @@
+ baseConfigFile.createNewFile();
+ }
+
+ configFileInstance = CommentedFileConfig.of(baseConfigFile);
+ configFileInstance = CommentedFileConfig.ofConcurrent(baseConfigFile);
+
+ configFileInstance.load();
+
@@ -98,7 +92,7 @@
+ throw new RuntimeException(e);
+ }
+
+ saveConfigs();
+ configFileInstance.save();
+ }
+
+ private static void loadAllModules() throws IllegalAccessException {
@@ -123,7 +117,7 @@
+ for (Field field : fields) {
+ int modifiers = field.getModifiers();
+ if (Modifier.isStatic(modifiers) && !Modifier.isFinal(modifiers)) {
+ boolean skipLoad = field.getAnnotation(DoNotLoad.class) != null || (alreadyInit && field.getAnnotation(HotReloadUnsupported.class) != null);
+ boolean skipLoad = field.getAnnotation(DoNotLoad.class) != null || (alreadyInited && field.getAnnotation(HotReloadUnsupported.class) != null);
+ ConfigInfo configInfo = field.getAnnotation(ConfigInfo.class);
+
+ if (skipLoad || configInfo == null) {
@@ -134,7 +128,6 @@
+
+ field.setAccessible(true);
+ final Object currentValue = field.get(null);
+ if (!alreadyInit) defaultvalueMap.put(fullConfigKeyName, currentValue);
+ boolean removed = fullConfigKeyName.equals("removed.removed_config.removed");
+
+ if (!configFileInstance.contains(fullConfigKeyName) || removed) {
@@ -182,21 +175,7 @@
+ continue;
+ }
+
+ Object actuallyValue;
+ if (stagedConfigMap.containsKey(fullConfigKeyName)) {
+ actuallyValue = stagedConfigMap.get(fullConfigKeyName);
+ if (actuallyValue == null) actuallyValue = defaultvalueMap.get(fullConfigKeyName);
+ stagedConfigMap.remove(fullConfigKeyName);
+ } else {
+ actuallyValue = configFileInstance.get(fullConfigKeyName);
+ }
+ try {
+ actuallyValue = tryTransform(field.get(null).getClass(), actuallyValue);
+ configFileInstance.set(fullConfigKeyName, actuallyValue);
+ } catch (IllegalFormatConversionException e) {
+ resetConfig(fullConfigKeyName);
+ logger.error("Failed to transform config {}, reset to default!", fullConfigKeyName);
+ }
+ final Object actuallyValue = configFileInstance.get(fullConfigKeyName);
+ field.set(null, actuallyValue);
+ }
+ }
@@ -218,88 +197,6 @@
+ }
+ }
+
+ public static boolean setConfig(String[] keys, Object value) {
+ return setConfig(String.join(".", keys), value);
+ }
+
+ public static boolean setConfig(String key, Object value) {
+ if (configFileInstance.contains(key) && configFileInstance.get(key) != null) {
+ stagedConfigMap.put(key, value);
+ return true;
+ }
+ return false;
+ }
+
+ private static Object tryTransform(Class<?> targetType, Object value) {
+ if (!targetType.isAssignableFrom(value.getClass())) {
+ try {
+ if (targetType == Integer.class) {
+ value = Integer.parseInt(value.toString());
+ } else if (targetType == Double.class) {
+ value = Double.parseDouble(value.toString());
+ } else if (targetType == Boolean.class) {
+ value = Boolean.parseBoolean(value.toString());
+ } else if (targetType == Long.class) {
+ value = Long.parseLong(value.toString());
+ } else if (targetType == Float.class) {
+ value = Float.parseFloat(value.toString());
+ } else if (targetType == String.class) {
+ value = value.toString();
+ }
+ } catch (Exception e) {
+ logger.error("Failed to transform value {}!", value);
+ throw new IllegalFormatConversionException((char) 0, targetType);
+ }
+ }
+ return value;
+ }
+
+ public static void saveConfigs() {
+ configFileInstance.save();
+ }
+
+ public static void resetConfig(String[] keys) {
+ resetConfig(String.join(".", keys));
+ }
+
+ public static void resetConfig(String key) {
+ stagedConfigMap.put(key, null);
+ }
+
+ public static String getConfig(String[] keys) {
+ return getConfig(String.join(".", keys));
+ }
+
+ public static String getConfig(String key) {
+ return configFileInstance.get(key).toString();
+ }
+
+ public static List<String> completeConfigPath(String partialPath) {
+ List<String> allPaths = getAllConfigPaths(partialPath);
+ List<String> result = new ArrayList<>();
+
+ for (String path : allPaths) {
+ String remaining = path.substring(partialPath.length());
+ if (remaining.isEmpty()) continue;
+
+ int dotIndex = remaining.indexOf('.');
+ String suggestion = (dotIndex == -1)
+ ? path
+ : partialPath + remaining.substring(0, dotIndex);
+
+ if (!result.contains(suggestion)) {
+ result.add(suggestion);
+ }
+ }
+ return result;
+ }
+
+ private static List<String> getAllConfigPaths(String currentPath) {
+ return defaultvalueMap.keySet().stream()
+ .filter(k -> k.startsWith(currentPath))
+ .toList();
+ }
+
+ public static @NotNull Set<Class<?>> getClasses(String pack) {
+ Set<Class<?>> classes = new LinkedHashSet<>();
+ String packageDirName = pack.replace('.', '/');

View File

@@ -1,9 +1,7 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/flags/TransformedConfig.java
@@ -1,0 +_,26 @@
+package me.earthme.luminol.config.flags;
+
+import me.earthme.luminol.config.DefaultTransformLogic;
+++ b/src/main/java/me/earthme/luminol/config/TransformedConfig.java
@@ -1,0 +_,24 @@
+package me.earthme.luminol.config;
+
+import java.lang.annotation.Repeatable;
+import java.lang.annotation.Retention;

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.experiment;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class CommandBlockConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enable")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.experiment;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class CommandDataConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enable")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,22 @@
+package me.earthme.luminol.config.modules.experiment;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class CommandTickConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled", comments =

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.experiment;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class DisableAsyncCatcherConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.experiment;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class DisableEntityCatchConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled")

View File

@@ -3,10 +3,10 @@
@@ -1,0 +_,24 @@
+package me.earthme.luminol.config.modules.experiment;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+import me.earthme.luminol.config.flags.TransformedConfig;
+import me.earthme.luminol.config.TransformedConfig;
+
+public class EntityDamageSourceTraceConfig implements IConfigModule {
+ @TransformedConfig(name = "enabled", category = {"experiment", "entity-damage-source-trace"})

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,28 @@
+package me.earthme.luminol.config.modules.experiment;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class RayTrackingEntityTrackerConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,28 @@
+package me.earthme.luminol.config.modules.fixes;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class FoliaEntityMovingFixConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled", comments =

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,25 @@
+package me.earthme.luminol.config.modules.fixes;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class FoliaPOIAccessOffRegionFixConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled", comments =

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,22 @@
+package me.earthme.luminol.config.modules.fixes;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class ForceCleanupEntityBrainMemoryConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled_for_entity", comments = "When enabled, the entity's brain will clean the memory which is typed of entity and not belong to current tickregion")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,22 @@
+package me.earthme.luminol.config.modules.fixes;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class UnsafeTeleportationConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled", comments = "Allow non player entities enter end portals if enabled.\n" +

View File

@@ -3,12 +3,12 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.fixes;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class VanillaRandomSourceConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enable_for_player_entity", comments = "Related with RNG cracks")
+ @ConfigInfo(baseName = "enable_for_player_entity",comments = "Related with RNG cracks")
+ public static boolean useLegacyRandomSourceForPlayers = false;
+
+ @Override

View File

@@ -1,28 +0,0 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/CollisionBehaviorConfig.java
@@ -1,0 +_,25 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class CollisionBehaviorConfig implements IConfigModule {
+ @ConfigInfo(baseName = "mode", comments =
+ """
+ Available Value:
+ VANILLA
+ BLOCK_SHAPE_VANILLA
+ PAPER""")
+ public static String behaviorMode = "BLOCK_SHAPE_VANILLA";
+
+ @Override
+ public EnumConfigCategory getCategory() {
+ return EnumConfigCategory.MISC;
+ }
+
+ @Override
+ public String getBaseName() {
+ return "collision_behavior";
+ }
+}

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,27 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class ContainerExpansionConfig implements IConfigModule {
+ @ConfigInfo(baseName = "barrel_rows", comments =

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,23 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class DisableEndCrystalCheckConfig implements IConfigModule {
+ @ConfigInfo(baseName = "disable_end_crystal_check", comments =

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,22 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class DisableHeightmapWarnConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled", comments =

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class DisableMovedWronglyThreshold implements IConfigModule {
+ @ConfigInfo(baseName = "enabled")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class FoliaWatchogConfig implements IConfigModule {
+ @ConfigInfo(baseName = "tick_region_time_out_ms")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class InorderChatConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled")

View File

@@ -5,10 +5,10 @@
+
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
+import me.earthme.luminol.commands.MembarCommand;
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.DoNotLoad;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+import me.earthme.luminol.config.flags.DoNotLoad;
+import me.earthme.luminol.functions.GlobalServerMemoryBar;
+import org.bukkit.Bukkit;
+
@@ -20,7 +20,7 @@
+ @ConfigInfo(baseName = "format")
+ public static String memBarFormat = "<gray>Memory usage <yellow>:</yellow> <used>MB<yellow>/</yellow><available>MB";
+ @ConfigInfo(baseName = "memory_color_list")
+ public static List<String> memColors = List.of("GREEN", "YELLOW", "RED", "PURPLE");
+ public static List<String> memColors = List.of("GREEN","YELLOW","RED","PURPLE");
+ @ConfigInfo(baseName = "update_interval_ticks")
+ public static int updateInterval = 15;
+
@@ -38,15 +38,15 @@
+ }
+
+ @Override
+ public void onLoaded(CommentedFileConfig configInstance) {
+ if (memoryBarEnabled) {
+ public void onLoaded(CommentedFileConfig configInstance){
+ if (memoryBarEnabled){
+ GlobalServerMemoryBar.init();
+ } else {
+ }else{
+ GlobalServerMemoryBar.cancelBarUpdateTask();
+ }
+
+ if (!inited) {
+ Bukkit.getCommandMap().register("membar", "luminol", new MembarCommand("membar"));
+ if (!inited){
+ Bukkit.getCommandMap().register("membar","luminol",new MembarCommand("membar"));
+ inited = true;
+ }
+ }

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class OfflineModeWarningConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,21 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class PublickeyVerifyConfig implements IConfigModule {
+

View File

@@ -3,10 +3,10 @@
@@ -1,0 +_,61 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+import me.earthme.luminol.config.flags.TransformedConfig;
+import me.earthme.luminol.config.TransformedConfig;
+
+public class RaidChangesConfig implements IConfigModule {
+ @TransformedConfig(name = "allow-bad-omen-trigger-raid", category = {"misc", "revert-raid-changes"})

View File

@@ -5,10 +5,10 @@
+
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
+import me.earthme.luminol.commands.RegionBarCommand;
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.DoNotLoad;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+import me.earthme.luminol.config.flags.DoNotLoad;
+import me.earthme.luminol.functions.GlobalServerRegionBar;
+import org.bukkit.Bukkit;
+

View File

@@ -1,15 +1,11 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java
@@ -1,0 +_,63 @@
@@ -1,0 +_,59 @@
+package me.earthme.luminol.config.modules.misc;
+
+import abomination.LinearRegionFile;
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+import me.earthme.luminol.config.flags.DoNotLoad;
+import me.earthme.luminol.config.flags.HotReloadUnsupported;
+import me.earthme.luminol.config.*;
+import me.earthme.luminol.utils.EnumRegionFormat;
+import net.minecraft.server.MinecraftServer;
+

View File

@@ -3,14 +3,14 @@
@@ -1,0 +_,22 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class SecureSeedConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled", comments = """
+ Once you enable secure seed, all ores and structures are generated with 1024-bit seed
+ instead of using 64-bit seed in vanilla, made seed cracker become impossible.""")
+ Once you enable secure seed, all ores and structures are generated with 1024-bit seed
+ instead of using 64-bit seed in vanilla, made seed cracker become impossible.""")
+ public static boolean enabled = false;
+
+ @Override

View File

@@ -4,9 +4,9 @@
+package me.earthme.luminol.config.modules.misc;
+
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+import org.apache.logging.log4j.Level;
+
+public class SentryConfig implements IConfigModule {

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,23 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class ServerModNameConfig implements IConfigModule {
+ @ConfigInfo(baseName = "name")

View File

@@ -1,14 +1,11 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/modules/misc/TpsBarConfig.java
@@ -1,0 +_,54 @@
@@ -1,0 +_,51 @@
+package me.earthme.luminol.config.modules.misc;
+
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
+import me.earthme.luminol.commands.TpsBarCommand;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+import me.earthme.luminol.config.flags.DoNotLoad;
+import me.earthme.luminol.config.*;
+import me.earthme.luminol.functions.GlobalServerTpsBar;
+import org.bukkit.Bukkit;
+
@@ -20,11 +17,11 @@
+ @ConfigInfo(baseName = "format")
+ public static String tpsBarFormat = "<gray>TPS<yellow>:</yellow> <tps> MSPT<yellow>:</yellow> <mspt> Ping<yellow>:</yellow> <ping>ms ChunkHot<yellow>:</yellow> <chunkhot>";
+ @ConfigInfo(baseName = "tps_color_list")
+ public static List<String> tpsColors = List.of("GREEN", "YELLOW", "RED", "PURPLE");
+ public static List<String> tpsColors = List.of("GREEN","YELLOW","RED","PURPLE");
+ @ConfigInfo(baseName = "ping_color_list")
+ public static List<String> pingColors = List.of("GREEN", "YELLOW", "RED", "PURPLE");
+ public static List<String> pingColors = List.of("GREEN","YELLOW","RED","PURPLE");
+ @ConfigInfo(baseName = "chunkhot_color_list")
+ public static List<String> chunkHotColors = List.of("GREEN", "YELLOW", "RED", "PURPLE");
+ public static List<String> chunkHotColors = List.of("GREEN","YELLOW","RED","PURPLE");
+ @ConfigInfo(baseName = "update_interval_ticks")
+ public static int updateInterval = 15;
+
@@ -42,15 +39,15 @@
+ }
+
+ @Override
+ public void onLoaded(CommentedFileConfig configInstance) {
+ if (tpsbarEnabled) {
+ public void onLoaded(CommentedFileConfig configInstance){
+ if (tpsbarEnabled){
+ GlobalServerTpsBar.init();
+ } else {
+ }else{
+ GlobalServerTpsBar.cancelBarUpdateTask();
+ }
+
+ if (!inited) {
+ Bukkit.getCommandMap().register("tpsbar", "luminol", new TpsBarCommand("tpsbar"));
+ if (!inited){
+ Bukkit.getCommandMap().register("tpsbar","luminol",new TpsBarCommand("tpsbar"));
+ inited = true;
+ }
+ }

View File

@@ -3,10 +3,10 @@
@@ -1,0 +_,29 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+import me.earthme.luminol.config.flags.TransformedConfig;
+import me.earthme.luminol.config.TransformedConfig;
+
+public class TripwireBehaviorConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.misc;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class UsernameCheckConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.optimizations;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class EntityGoalSelectorInactiveTickConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.optimizations;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class GaleVariableEntityWakeupConfig implements IConfigModule {
+ @ConfigInfo(baseName = "entity_wakeup_duration_ratio_standard_deviation")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,24 @@
+package me.earthme.luminol.config.modules.optimizations;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class LobotomizeVillageConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,22 @@
+package me.earthme.luminol.config.modules.optimizations;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class PetalReduceSensorWorkConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,22 @@
+package me.earthme.luminol.config.modules.optimizations;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class ProjectileChunkReduceConfig implements IConfigModule {
+ @ConfigInfo(baseName = "max-loads-per-tick")

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.optimizations;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class PurpurAlternativeKeepaliveConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled")

View File

@@ -6,10 +6,10 @@
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
+import com.mojang.logging.LogUtils;
+import gg.pufferfish.pufferfish.simd.SIMDDetection;
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.DoNotLoad;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+import me.earthme.luminol.config.flags.DoNotLoad;
+import org.slf4j.Logger;
+
+public class SIMDConfig implements IConfigModule {
@@ -30,7 +30,7 @@
+
+ @Override
+ public void onLoaded(CommentedFileConfig configInstance) {
+ if (!enabled) {
+ if (!enabled){
+ return;
+ }
+

View File

@@ -3,9 +3,9 @@
@@ -1,0 +_,20 @@
+package me.earthme.luminol.config.modules.optimizations;
+
+import me.earthme.luminol.config.ConfigInfo;
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+
+public class SuffocationOptimizationConfig implements IConfigModule {
+ @ConfigInfo(baseName = "enabled")

View File

@@ -1,13 +1,9 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/modules/removed/RemovedConfig.java
@@ -1,0 +_,26 @@
@@ -1,0 +_,22 @@
+package me.earthme.luminol.config.modules.removed;
+
+import me.earthme.luminol.config.EnumConfigCategory;
+import me.earthme.luminol.config.IConfigModule;
+import me.earthme.luminol.config.flags.ConfigInfo;
+import me.earthme.luminol.config.flags.DoNotLoad;
+import me.earthme.luminol.config.flags.TransformedConfig;
+import me.earthme.luminol.config.*;
+
+public class RemovedConfig implements IConfigModule {
+ @TransformedConfig(name = "example", category = {"removed", "example"}, transform = false)

View File

@@ -26,24 +26,24 @@
+ protected static final NullPlugin NULL_PLUGIN = new NullPlugin();
+ protected static final Map<UUID, BossBar> uuid2Bossbars = Maps.newConcurrentMap();
+ protected static final Map<UUID, ScheduledTask> scheduledTasks = new HashMap<>();
+ private static final Logger logger = LogUtils.getLogger();
+ protected static volatile ScheduledTask scannerTask = null;
+ private static final Logger logger = LogUtils.getLogger();
+
+ public static void init() {
+ public static void init(){
+ cancelBarUpdateTask();
+
+ scannerTask = Bukkit.getGlobalRegionScheduler().runAtFixedRate(NULL_PLUGIN, unused -> {
+ try {
+ update();
+ } catch (Exception e) {
+ }catch (Exception e){
+ logger.error(e.getLocalizedMessage());
+ }
+ }, 1, MembarConfig.updateInterval);
+ }
+
+
+ public static void cancelBarUpdateTask() {
+ if (scannerTask == null || scannerTask.isCancelled()) {
+ public static void cancelBarUpdateTask(){
+ if (scannerTask == null || scannerTask.isCancelled()){
+ return;
+ }
+
@@ -56,20 +56,20 @@
+ }
+ }
+
+ public static boolean isPlayerVisible(Player player) {
+ public static boolean isPlayerVisible(Player player){
+ return ((CraftPlayer) player).getHandle().isMemBarVisible;
+ }
+
+ public static void setVisibilityForPlayer(Player target, boolean canSee) {
+ public static void setVisibilityForPlayer(Player target,boolean canSee){
+ ((CraftPlayer) target).getHandle().isMemBarVisible = canSee;
+ }
+
+ private static void update() {
+ private static void update(){
+ doUpdate();
+ cleanUp();
+ }
+
+ private static void cleanUp() {
+ private static void cleanUp(){
+ final List<UUID> toCleanUp = new ArrayList<>();
+
+ for (Map.Entry<UUID, ScheduledTask> toCheck : scheduledTasks.entrySet()) {
@@ -83,7 +83,7 @@
+ }
+ }
+
+ private static void doUpdate() {
+ private static void doUpdate(){
+ for (Player player : Bukkit.getOnlinePlayers()) {
+ scheduledTasks.computeIfAbsent(player.getUniqueId(), unused -> createBossBarForPlayer(player));
+ }
@@ -110,7 +110,7 @@
+
+ BossBar targetBossbar = uuid2Bossbars.computeIfAbsent(
+ playerUUID,
+ (unused1) -> BossBar.bossBar(Component.text(""), 0.0F, BossBar.Color.valueOf(MembarConfig.memColors.get(3)), BossBar.Overlay.NOTCHED_20)
+ (unused1) -> BossBar.bossBar(Component.text(""),0.0F, BossBar.Color.valueOf(MembarConfig.memColors.get(3)), BossBar.Overlay.NOTCHED_20)
+ );
+
+ apiPlayer.showBossBar(targetBossbar);
@@ -125,47 +125,47 @@
+ }, 1, MembarConfig.updateInterval);
+ }
+
+ private static void updateMembar(@NotNull BossBar bar, long used, long xmx) {
+ private static void updateMembar(@NotNull BossBar bar, long used, long xmx){
+ double percent = Math.max(Math.min((float) used / xmx, 1.0F), 0.0F);
+ bar.name(MiniMessage.miniMessage().deserialize(
+ MembarConfig.memBarFormat,
+ Placeholder.component("used", getMemoryComponent(used, xmx)),
+ Placeholder.component("available", getMaxMemComponent(xmx))
+ Placeholder.component("used", getMemoryComponent(used,xmx)),
+ Placeholder.component("available",getMaxMemComponent(xmx))
+ ));
+ bar.color(barColorFromMemory(percent));
+ bar.progress((float) percent);
+ }
+
+ private static @NotNull Component getMaxMemComponent(double max) {
+ private static @NotNull Component getMaxMemComponent(double max){
+ final BossBar.Color colorBukkit = BossBar.Color.GREEN;
+ final String colorString = colorBukkit.name();
+
+ final String content = "<%s><text></%s>";
+ final String replaced = String.format(content, colorString, colorString);
+ final String replaced = String.format(content,colorString,colorString);
+
+ return MiniMessage.miniMessage().deserialize(replaced, Placeholder.parsed("text", String.format("%.2f", max / (1024 * 1024))));
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", max / (1024 * 1024))));
+ }
+
+ private static @NotNull Component getMemoryComponent(long used, long max) {
+ private static @NotNull Component getMemoryComponent(long used,long max){
+ final BossBar.Color colorBukkit = barColorFromMemory(Math.max(Math.min((float) used / max, 1.0F), 0.0F));
+ final String colorString = colorBukkit.name();
+
+ final String content = "<%s><text></%s>";
+ final String replaced = String.format(content, colorString, colorString);
+ final String replaced = String.format(content,colorString,colorString);
+
+ return MiniMessage.miniMessage().deserialize(replaced, Placeholder.parsed("text", String.format("%.2f", (double) used / (1024 * 1024))));
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", (double)used / (1024 * 1024))));
+ }
+
+ private static BossBar.Color barColorFromMemory(double memPercent) {
+ if (memPercent == -1) {
+ private static BossBar.Color barColorFromMemory(double memPercent){
+ if (memPercent == -1){
+ return BossBar.Color.valueOf(MembarConfig.memColors.get(3));
+ }
+
+ if (memPercent <= 50) {
+ if (memPercent <= 50){
+ return BossBar.Color.valueOf(MembarConfig.memColors.getFirst());
+ }
+
+ if (memPercent <= 70) {
+ if (memPercent <= 70){
+ return BossBar.Color.valueOf(MembarConfig.memColors.get(1));
+ }
+

View File

@@ -1,14 +1,11 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerRegionBar.java
@@ -1,0 +_,185 @@
@@ -1,0 +_,184 @@
+package me.earthme.luminol.functions;
+
+import com.google.common.collect.Maps;
+import com.mojang.logging.LogUtils;
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
+import io.papermc.paper.threadedregions.TickData;
+import io.papermc.paper.threadedregions.TickRegionScheduler;
+import io.papermc.paper.threadedregions.TickRegions;
+import io.papermc.paper.threadedregions.*;
+import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
+import me.earthme.luminol.config.modules.misc.RegionBarConfig;
+import me.earthme.luminol.utils.NullPlugin;
@@ -29,9 +26,11 @@
+ protected static final NullPlugin NULL_PLUGIN = new NullPlugin();
+ protected static final Map<UUID, BossBar> uuid2Bossbars = Maps.newConcurrentMap();
+ protected static final Map<UUID, ScheduledTask> scheduledTasks = new HashMap<>();
+ private static final Logger logger = LogUtils.getLogger();
+ private static final ThreadLocal<DecimalFormat> ONE_DECIMAL_PLACES = ThreadLocal.withInitial(() -> new DecimalFormat("#,##0.0"));
+
+ protected static volatile ScheduledTask scannerTask = null;
+ private static final Logger logger = LogUtils.getLogger();
+
+ private static final ThreadLocal<DecimalFormat> ONE_DECIMAL_PLACES = ThreadLocal.withInitial(() -> new DecimalFormat("#,##0.0"));
+
+ public static void init() {
+ cancelBarUpdateTask();

View File

@@ -1,6 +1,6 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
@@ -1,0 +_,240 @@
@@ -1,0 +_,241 @@
+package me.earthme.luminol.functions;
+
+import com.google.common.collect.Maps;
@@ -28,24 +28,25 @@
+ protected static final NullPlugin NULL_PLUGIN = new NullPlugin();
+ protected static final Map<UUID, BossBar> uuid2Bossbars = Maps.newConcurrentMap();
+ protected static final Map<UUID, ScheduledTask> scheduledTasks = new HashMap<>();
+ private static final Logger logger = LogUtils.getLogger();
+ protected static volatile ScheduledTask scannerTask = null;
+
+ public static void init() {
+ protected static volatile ScheduledTask scannerTask = null;
+ private static final Logger logger = LogUtils.getLogger();
+
+ public static void init(){
+ cancelBarUpdateTask();
+
+ scannerTask = Bukkit.getGlobalRegionScheduler().runAtFixedRate(NULL_PLUGIN, unused -> {
+ try {
+ update();
+ cleanUp();
+ } catch (Exception e) {
+ }catch (Exception e){
+ logger.error(e.getLocalizedMessage());
+ }
+ }, 1, TpsBarConfig.updateInterval);
+ }
+
+ public static void cancelBarUpdateTask() {
+ if (scannerTask == null || scannerTask.isCancelled()) {
+ public static void cancelBarUpdateTask(){
+ if (scannerTask == null || scannerTask.isCancelled()){
+ return;
+ }
+
@@ -58,15 +59,15 @@
+ }
+ }
+
+ public static boolean isPlayerVisible(Player player) {
+ public static boolean isPlayerVisible(Player player){
+ return ((CraftPlayer) player).getHandle().isTpsBarVisible;
+ }
+
+ public static void setVisibilityForPlayer(Player target, boolean canSee) {
+ public static void setVisibilityForPlayer(Player target,boolean canSee){
+ ((CraftPlayer) target).getHandle().isTpsBarVisible = canSee;
+ }
+
+ private static void update() {
+ private static void update(){
+ for (Player player : Bukkit.getOnlinePlayers()) {
+ scheduledTasks.computeIfAbsent(player.getUniqueId(), unused -> createBossBarForPlayer(player));
+ }
@@ -105,12 +106,12 @@
+
+ BossBar targetBossbar = uuid2Bossbars.computeIfAbsent(
+ playerUUID,
+ unused -> BossBar.bossBar(Component.text(""), 0.0F, BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3)), BossBar.Overlay.NOTCHED_20)
+ unused -> BossBar.bossBar(Component.text(""),0.0F, BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3)), BossBar.Overlay.NOTCHED_20)
+ );
+
+ apiPlayer.showBossBar(targetBossbar);
+
+ if (reportData != null) {
+ if (reportData != null){
+ final TickData.SegmentData tpsData = reportData.tpsData().segmentAll();
+ final double mspt = reportData.timePerTickData().segmentAll().average() / 1.0E6;
+
@@ -125,116 +126,116 @@
+ }, 1, TpsBarConfig.updateInterval);
+ }
+
+ private static void updateTpsBar(double tps, double mspt, @NotNull BossBar bar, @NotNull Player player) {
+ private static void updateTpsBar(double tps, double mspt, @NotNull BossBar bar, @NotNull Player player){
+ bar.name(MiniMessage.miniMessage().deserialize(
+ TpsBarConfig.tpsBarFormat,
+ Placeholder.component("tps", getTpsComponent(tps)),
+ Placeholder.component("mspt", getMsptComponent(mspt)),
+ Placeholder.component("ping", getPingComponent(player.getPing())),
+ Placeholder.component("chunkhot", getChunkHotComponent(player.getNearbyChunkHot()))
+ Placeholder.component("tps",getTpsComponent(tps)),
+ Placeholder.component("mspt",getMsptComponent(mspt)),
+ Placeholder.component("ping",getPingComponent(player.getPing())),
+ Placeholder.component("chunkhot",getChunkHotComponent(player.getNearbyChunkHot()))
+ ));
+ bar.color(barColorFromTps(tps));
+ bar.progress((float) Math.min((float) 1, Math.max(mspt / 50, 0)));
+ bar.progress((float) Math.min((float)1,Math.max(mspt / 50,0)));
+ }
+
+ private static @NotNull Component getPingComponent(int ping) {
+ private static @NotNull Component getPingComponent(int ping){
+ final BossBar.Color colorBukkit = barColorFromPing(ping);
+ final String colorString = colorBukkit.name();
+
+ final String content = "<%s><text></%s>";
+ final String replaced = String.format(content, colorString, colorString);
+ final String replaced = String.format(content,colorString,colorString);
+
+ return MiniMessage.miniMessage().deserialize(replaced, Placeholder.parsed("text", String.valueOf(ping)));
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.valueOf(ping)));
+ }
+
+ private static BossBar.Color barColorFromPing(int ping) {
+ if (ping == -1) {
+ private static BossBar.Color barColorFromPing(int ping){
+ if (ping == -1){
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(3));
+ }
+
+ if (ping <= 80) {
+ if (ping <= 80){
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(0));
+ }
+
+ if (ping <= 160) {
+ if (ping <= 160){
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(1));
+ }
+
+ return BossBar.Color.valueOf(TpsBarConfig.pingColors.get(2));
+ }
+
+ private static @NotNull Component getMsptComponent(double mspt) {
+ private static @NotNull Component getMsptComponent(double mspt){
+ final BossBar.Color colorBukkit = barColorFromMspt(mspt);
+ final String colorString = colorBukkit.name();
+
+ final String content = "<%s><text></%s>";
+ final String replaced = String.format(content, colorString, colorString);
+ final String replaced = String.format(content,colorString,colorString);
+
+ return MiniMessage.miniMessage().deserialize(replaced, Placeholder.parsed("text", String.format("%.2f", mspt)));
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", mspt)));
+ }
+
+ private static @NotNull Component getChunkHotComponent(long chunkHot) {
+ private static @NotNull Component getChunkHotComponent(long chunkHot){
+ final BossBar.Color colorBukkit = barColorFromChunkHot(chunkHot);
+ final String colorString = colorBukkit.name();
+
+ final String content = "<%s><text></%s>";
+ final String replaced = String.format(content, colorString, colorString);
+ final String replaced = String.format(content,colorString,colorString);
+
+ return MiniMessage.miniMessage().deserialize(replaced, Placeholder.parsed("text", String.valueOf(chunkHot)));
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.valueOf(chunkHot)));
+ }
+
+ private static BossBar.Color barColorFromChunkHot(long chunkHot) {
+ if (chunkHot == -1) {
+ private static BossBar.Color barColorFromChunkHot(long chunkHot){
+ if (chunkHot == -1){
+ return BossBar.Color.valueOf(TpsBarConfig.chunkHotColors.get(3));
+ }
+
+ if (chunkHot <= 300000L) {
+ if (chunkHot <= 300000L){
+ return BossBar.Color.valueOf(TpsBarConfig.chunkHotColors.get(0));
+ }
+
+ if (chunkHot <= 500000L) {
+ if (chunkHot <= 500000L){
+ return BossBar.Color.valueOf(TpsBarConfig.chunkHotColors.get(1));
+ }
+
+ return BossBar.Color.valueOf(TpsBarConfig.chunkHotColors.get(2));
+ }
+
+ private static BossBar.Color barColorFromMspt(double mspt) {
+ if (mspt == -1) {
+ private static BossBar.Color barColorFromMspt(double mspt){
+ if (mspt == -1){
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3));
+ }
+
+ if (mspt <= 25) {
+ if (mspt <= 25){
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(0));
+ }
+
+ if (mspt <= 50) {
+ if (mspt <= 50){
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(1));
+ }
+
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(2));
+ }
+
+ private static @NotNull Component getTpsComponent(double tps) {
+ private static @NotNull Component getTpsComponent(double tps){
+ final BossBar.Color colorBukkit = barColorFromTps(tps);
+ final String colorString = colorBukkit.name();
+
+ final String content = "<%s><text></%s>";
+ final String replaced = String.format(content, colorString, colorString);
+ final String replaced = String.format(content,colorString,colorString);
+
+ return MiniMessage.miniMessage().deserialize(replaced, Placeholder.parsed("text", String.format("%.2f", tps)));
+ return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", tps)));
+ }
+
+ private static BossBar.Color barColorFromTps(double tps) {
+ if (tps == -1) {
+ private static BossBar.Color barColorFromTps(double tps){
+ if (tps == -1){
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3));
+ }
+
+ if (tps >= 18) {
+ if (tps >= 18){
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(0));
+ }
+
+ if (tps >= 15) {
+ if (tps >= 15){
+ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(1));
+ }
+

View File

@@ -9,8 +9,8 @@
+import org.jetbrains.annotations.Nullable;
+
+public enum EnumRegionFormat {
+ MCA("mca", "mca", (info) -> new RegionFile(info.info(), info.filePath(), info.folder(), info.sync())),
+ LINEAR_V2("linear_v2", "linear", (info) -> new LinearRegionFile(info.info(), info.filePath(), info.folder(), info.sync(), RegionFormatConfig.linearCompressionLevel));
+ MCA("mca", "mca" , (info) -> new RegionFile(info.info(), info.filePath(), info.folder(), info.sync())),
+ LINEAR_V2("linear_v2", "linear" ,(info) -> new LinearRegionFile(info.info(), info.filePath(), info.folder(), info.sync(), RegionFormatConfig.linearCompressionLevel));
+
+ private final String name;
+ private final String argument;

View File

@@ -3,26 +3,27 @@
@@ -1,0 +_,152 @@
+package me.earthme.luminol.utils;
+
+import io.papermc.paper.plugin.configuration.PluginMeta;
+import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager;
+import org.bukkit.Server;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.generator.BiomeProvider;
+import org.bukkit.generator.ChunkGenerator;
+import org.bukkit.plugin.PluginBase;
+import org.bukkit.plugin.PluginDescriptionFile;
+import org.bukkit.plugin.PluginLoader;
+import org.bukkit.plugin.PluginLogger;
+import org.bukkit.plugin.*;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.List;
+import java.util.logging.Logger;
+
+public class NullPlugin extends PluginBase {
+ private final String pluginName;
+public class NullPlugin extends PluginBase {
+ private boolean enabled = true;
+
+ private final String pluginName;
+ private PluginDescriptionFile pdf;
+
+ public NullPlugin() {
@@ -30,6 +31,10 @@
+ pdf = new PluginDescriptionFile(pluginName, "1.0", "nms");
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ @Override
+ public File getDataFolder() {
+ throw new UnsupportedOperationException("Not supported.");
@@ -39,18 +44,17 @@
+ public PluginDescriptionFile getDescription() {
+ return pdf;
+ }
+
+ // Paper start
+ @Override
+ public io.papermc.paper.plugin.configuration.PluginMeta getPluginMeta() {
+ return pdf;
+ }
+ // Paper end
+
+ @Override
+ public FileConfiguration getConfig() {
+ throw new UnsupportedOperationException("Not supported.");
+ }
+ // Paper end
+
+ @Override
+ public InputStream getResource(String filename) {
@@ -97,10 +101,6 @@
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ @Override
+ public void onDisable() {
+ throw new UnsupportedOperationException("Not supported.");

View File

@@ -1,11 +1,10 @@
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/utils/RegionCreatorInfo.java
@@ -1,0 +_,8 @@
@@ -1,0 +_,7 @@
+package me.earthme.luminol.utils;
+
+import net.minecraft.world.level.chunk.storage.RegionStorageInfo;
+
+import java.nio.file.Path;
+
+public record RegionCreatorInfo(RegionStorageInfo info, Path filePath, Path folder, boolean sync) {
+}
+public record RegionCreatorInfo (RegionStorageInfo info, Path filePath, Path folder, boolean sync) {}