Plazma Configurations
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Fri, 13 Dec 2024 13:54:22 +0900
|
||||
Subject: [PATCH] Minor code optimizations
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 1a808fc381c0c3ea1fc49bbffebddf2c550e817a..55f15f26b56b97a561054b0660ba4965bb008b36 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -1698,7 +1698,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
@Override
|
||||
public List<Entity> getEntities(@Nullable Entity except, AABB box, Predicate<? super Entity> predicate) {
|
||||
Profiler.get().incrementCounter("getEntities");
|
||||
- List<Entity> list = Lists.newArrayList();
|
||||
+ //List<Entity> list = Lists.newArrayList(); // Plazma - minor optimizations
|
||||
|
||||
// Paper start - rewrite chunk system
|
||||
final List<Entity> ret = new java.util.ArrayList<>();
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,146 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Sun, 5 Nov 2023 10:47:05 +0900
|
||||
Subject: [PATCH] Setup basic configuration sections
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
index b638690d5cd2360444e6c525f97f634d8e1dc60e..e89534b6e2b91483d7eddfcb3441e9addf9bccc7 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java
|
||||
@@ -6,6 +6,7 @@ import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
||||
import net.minecraft.Util;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
+import org.spongepowered.configurate.objectmapping.meta.PostProcess;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,4 +28,61 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
@Setting(Configuration.VERSION_FIELD)
|
||||
int version = VERSION;
|
||||
|
||||
+ public Messages messages;
|
||||
+ public class Messages extends ConfigurationPart {
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public Command command;
|
||||
+ public class Command extends ConfigurationPart {
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public Player player;
|
||||
+ public class Player extends ConfigurationPart {
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ @Setting("world-generation")
|
||||
+ public WorldGeneration worldgen;
|
||||
+ public class WorldGeneration extends ConfigurationPart {
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public Entity entity;
|
||||
+ public class Entity extends ConfigurationPart {
|
||||
+
|
||||
+
|
||||
+ @PostProcess
|
||||
+ public void post() {
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public World world;
|
||||
+ public class World extends ConfigurationPart {
|
||||
+
|
||||
+
|
||||
+ @PostProcess
|
||||
+ public void post() {
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public Structure structure;
|
||||
+ public class Structure extends ConfigurationPart {
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public Miscellaneous misc;
|
||||
+ public class Miscellaneous extends ConfigurationPart {
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
}
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/RemovedConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/RemovedConfigurations.java
|
||||
index 25c0f5d28107b45677aa7b19bc0d5238512d9826..ac0f038de0ce5cf6df0b730af69d3229c3119eff 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/RemovedConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/RemovedConfigurations.java
|
||||
@@ -2,9 +2,12 @@ package org.plazmamc.plazma.configurations;
|
||||
|
||||
import org.spongepowered.configurate.NodePath;
|
||||
|
||||
+import static org.spongepowered.configurate.NodePath.path;
|
||||
+
|
||||
interface RemovedConfigurations {
|
||||
|
||||
NodePath[] WORLD_PATHS = {
|
||||
+ path("structure", "nether-portal")
|
||||
};
|
||||
|
||||
NodePath[] GLOBAL_PATHS = {
|
||||
diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
index f2d3d51cb4b8fc7a5fd6db1a63289fff6d32a1ea..c222d58520b655b54b8975ec226a4ba948691cd4 100644
|
||||
--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
+++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java
|
||||
@@ -19,4 +19,44 @@ public class WorldConfigurations extends ConfigurationPart {
|
||||
@Setting(Configuration.VERSION_FIELD)
|
||||
int version = VERSION;
|
||||
|
||||
+ public Miscellaneous misc;
|
||||
+ public class Miscellaneous extends ConfigurationPart {
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public Entity entity;
|
||||
+ public class Entity extends ConfigurationPart {
|
||||
+
|
||||
+ public Phantom phantom;
|
||||
+ public class Phantom extends ConfigurationPart {
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public Structure structure;
|
||||
+ public class Structure extends ConfigurationPart {
|
||||
+
|
||||
+ public NetherPortal netherPortal;
|
||||
+ public class NetherPortal extends ConfigurationPart {
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public Block block;
|
||||
+ public class Block extends ConfigurationPart {
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public Item item;
|
||||
+ public class Item extends ConfigurationPart {
|
||||
+
|
||||
+
|
||||
+ }
|
||||
+
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: AlphaKR93 <dev@alpha93.kr>
|
||||
Date: Sun, 5 Nov 2023 10:26:26 +0900
|
||||
Subject: [PATCH] Add more metrics
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
index b58f4eb26ce6bd6696b3289b5f199ab8f0ff28b6..6ab720b65dec49092addbaf967c77682bd304096 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
@@ -635,38 +635,59 @@ public class Metrics {
|
||||
return map;
|
||||
}));
|
||||
|
||||
- metrics.addCustomChart(new Metrics.DrilldownPie("legacy_plugins", () -> {
|
||||
- Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
+ // Plazma start - Add more metrics information
|
||||
+ metrics.addCustomChart(new DrilldownPie("datapacks", () -> {
|
||||
+ int datapacks = Bukkit.getDatapackManager().getEnabledPacks().size();
|
||||
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(datapacks), 1);
|
||||
+
|
||||
+ if (datapacks == 0) return Collections.singletonMap("0", entry);
|
||||
+ else if (datapacks <= 5) return Collections.singletonMap("1-5", entry);
|
||||
+ else if (datapacks <= 10) return Collections.singletonMap("6-10", entry);
|
||||
+ else if (datapacks <= 25) return Collections.singletonMap("11-25", entry);
|
||||
+ else if (datapacks <= 50) return Collections.singletonMap("26-50", entry);
|
||||
+ else if (datapacks <= 100) return Collections.singletonMap("51+", entry);
|
||||
+ else return Collections.singletonMap("101+ \uD83D\uDE2E", entry);
|
||||
+ }));
|
||||
|
||||
- // count legacy plugins
|
||||
- int legacy = 0;
|
||||
- for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
- if (CraftMagicNumbers.isLegacy(plugin.getDescription())) {
|
||||
- legacy++;
|
||||
- }
|
||||
- }
|
||||
+ metrics.addCustomChart(new DrilldownPie("plugins", () -> {
|
||||
+ int pluginCount = Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(Plugin::isEnabled).toList().size();
|
||||
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(pluginCount), 1);
|
||||
+
|
||||
+ if (pluginCount == 0) return Collections.singletonMap("0", entry);
|
||||
+ else if (pluginCount <= 5) return Collections.singletonMap("1-5", entry);
|
||||
+ else if (pluginCount <= 10) return Collections.singletonMap("6-10", entry);
|
||||
+ else if (pluginCount <= 25) return Collections.singletonMap("11-25", entry);
|
||||
+ else if (pluginCount <= 50) return Collections.singletonMap("26-50", entry);
|
||||
+ else if (pluginCount <= 100) return Collections.singletonMap("51-100", entry);
|
||||
+ else return Collections.singletonMap("101+ \uD83D\uDE2E", entry);
|
||||
+ }));
|
||||
|
||||
- // insert real value as lower dimension
|
||||
- Map<String, Integer> entry = new HashMap<>();
|
||||
- entry.put(String.valueOf(legacy), 1);
|
||||
-
|
||||
- // create buckets as higher dimension
|
||||
- if (legacy == 0) {
|
||||
- map.put("0 \uD83D\uDE0E", entry); // :sunglasses:
|
||||
- } else if (legacy <= 5) {
|
||||
- map.put("1-5", entry);
|
||||
- } else if (legacy <= 10) {
|
||||
- map.put("6-10", entry);
|
||||
- } else if (legacy <= 25) {
|
||||
- map.put("11-25", entry);
|
||||
- } else if (legacy <= 50) {
|
||||
- map.put("26-50", entry);
|
||||
- } else {
|
||||
- map.put("50+ \uD83D\uDE2D", entry); // :cry:
|
||||
- }
|
||||
+ metrics.addCustomChart(new DrilldownPie("disabled_plugins", () -> {
|
||||
+ int disabled = Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(it -> !it.isEnabled()).toList().size();
|
||||
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(disabled), 1);
|
||||
+
|
||||
+ if (disabled == 0) return Collections.singletonMap("0 \uD83D\uDE0E", entry); // :sunglasses:
|
||||
+ else if (disabled <= 5) return Collections.singletonMap("1-5", entry);
|
||||
+ else if (disabled <= 10) return Collections.singletonMap("6-10", entry);
|
||||
+ else if (disabled <= 25) return Collections.singletonMap("11-25", entry);
|
||||
+ else if (disabled <= 50) return Collections.singletonMap("26-50", entry);
|
||||
+ else if (disabled <= 100) return Collections.singletonMap("51-100 \uD83D\uDE2D", entry); // :cry:
|
||||
+ else return Collections.singletonMap("101+ \uD83D\uDC80", entry); // :skull:
|
||||
+ }));
|
||||
|
||||
- return map;
|
||||
+ metrics.addCustomChart(new Metrics.DrilldownPie("legacy_plugins", () -> {
|
||||
+ int legacy = (int) Arrays.stream(Bukkit.getPluginManager().getPlugins()).filter(p -> CraftMagicNumbers.isLegacy(p.getDescription())).count(); // Plazma
|
||||
+ Map<String, Integer> entry = Collections.singletonMap(String.valueOf(legacy), 1);
|
||||
+
|
||||
+ if (legacy == 0) return Collections.singletonMap("0 \uD83D\uDE0E", entry); // :sunglasses:
|
||||
+ else if (legacy <= 5) return Collections.singletonMap("1-5", entry);
|
||||
+ else if (legacy <= 10) return Collections.singletonMap("6-10", entry);
|
||||
+ else if (legacy <= 25) return Collections.singletonMap("11-25", entry);
|
||||
+ else if (legacy <= 50) return Collections.singletonMap("26-50", entry);
|
||||
+ else if (legacy <= 100) return Collections.singletonMap("51-100 \uD83D\uDE2D", entry); // :cry:
|
||||
+ else return Collections.singletonMap("101+ \uD83D\uDC80", entry); // :skull:
|
||||
}));
|
||||
+ // Plazma end - Add more metrics information
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1777,7 +_,7 @@
|
||||
|
||||
profilerFiller.pop();
|
||||
profilerFiller.pop();
|
||||
- serverLevel.explosionDensityCache.clear(); // Paper - Optimize explosions
|
||||
+ serverLevel.clearExplosionDensityCache(); // Paper - Optimize explosions // Plazma - package-private
|
||||
}
|
||||
this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
||||
|
||||
@@ -1,6 +1,37 @@
|
||||
--- a/net/minecraft/world/level/Level.java
|
||||
+++ b/net/minecraft/world/level/Level.java
|
||||
@@ -171,6 +_,7 @@
|
||||
@@ -108,13 +_,6 @@
|
||||
public static final ResourceKey<Level> OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld"));
|
||||
public static final ResourceKey<Level> NETHER = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("the_nether"));
|
||||
public static final ResourceKey<Level> END = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("the_end"));
|
||||
- public static final int MAX_LEVEL_SIZE = 30000000;
|
||||
- public static final int LONG_PARTICLE_CLIP_RANGE = 512;
|
||||
- public static final int SHORT_PARTICLE_CLIP_RANGE = 32;
|
||||
- public static final int MAX_BRIGHTNESS = 15;
|
||||
- public static final int TICKS_PER_DAY = 24000;
|
||||
- public static final int MAX_ENTITY_SPAWN_Y = 20000000;
|
||||
- public static final int MIN_ENTITY_SPAWN_Y = -20000000;
|
||||
public final List<TickingBlockEntity> blockEntityTickers = Lists.newArrayList(); // Paper - public
|
||||
protected final NeighborUpdater neighborUpdater;
|
||||
private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
|
||||
@@ -123,7 +_,7 @@
|
||||
private final boolean isDebug;
|
||||
private int skyDarken;
|
||||
protected int randValue = RandomSource.create().nextInt();
|
||||
- protected final int addend = 1013904223;
|
||||
+ //protected final int addend = 1013904223;
|
||||
protected float oRainLevel;
|
||||
public float rainLevel;
|
||||
protected float oThunderLevel;
|
||||
@@ -152,6 +_,7 @@
|
||||
public boolean isBlockPlaceCancelled = false; // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent
|
||||
public Map<BlockPos, org.bukkit.craftbukkit.block.CraftBlockState> capturedBlockStates = new java.util.LinkedHashMap<>(); // Paper
|
||||
public Map<BlockPos, BlockEntity> capturedTileEntities = new java.util.LinkedHashMap<>(); // Paper - Retain block place order when capturing blockstates
|
||||
+ @Nullable // Plazma - Null safety
|
||||
public List<net.minecraft.world.entity.item.ItemEntity> captureDrops;
|
||||
public final it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<SpawnCategory> ticksPerSpawnCategory = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>();
|
||||
// Paper start
|
||||
@@ -171,11 +_,13 @@
|
||||
|
||||
public final io.papermc.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
|
||||
public final org.purpurmc.purpur.PurpurWorldConfig purpurConfig; // Purpur - Purpur config files
|
||||
@@ -8,3 +39,571 @@
|
||||
public static BlockPos lastPhysicsProblem; // Spigot
|
||||
private org.spigotmc.TickLimiter entityLimiter;
|
||||
private org.spigotmc.TickLimiter tileLimiter;
|
||||
- private int tileTickPosition;
|
||||
- public final Map<ServerExplosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
|
||||
+ //private int tileTickPosition;
|
||||
+ final Map<ServerExplosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); public final void clearExplosionDensityCache() { this.explosionDensityCache.clear(); } // Paper - Optimize explosions // Plazma - public -> package-private
|
||||
+ @Nullable // Plazma - Null safety
|
||||
public java.util.ArrayDeque<net.minecraft.world.level.block.RedstoneTorchBlock.Toggle> redstoneUpdateInfos; // Paper - Faster redstone torch rapid clock removal; Move from Map in BlockRedstoneTorch to here
|
||||
|
||||
// Purpur start - Add adjustable breeding cooldown to config
|
||||
@@ -197,21 +_,12 @@
|
||||
this.playerBreedingCooldowns.put(new BreedingCooldownPair(player, animalType), new Object());
|
||||
}
|
||||
|
||||
- private static final class BreedingCooldownPair {
|
||||
- private final java.util.UUID playerUUID;
|
||||
- private final Class<? extends net.minecraft.world.entity.animal.Animal> animalType;
|
||||
-
|
||||
- public BreedingCooldownPair(java.util.UUID playerUUID, Class<? extends net.minecraft.world.entity.animal.Animal> animalType) {
|
||||
- this.playerUUID = playerUUID;
|
||||
- this.animalType = animalType;
|
||||
- }
|
||||
-
|
||||
+ private record BreedingCooldownPair(java.util.UUID playerUUID, Class<? extends net.minecraft.world.entity.animal.Animal> animalType) { // Plazma - Use record instead
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
- if (o == null || getClass() != o.getClass()) return false;
|
||||
- BreedingCooldownPair that = (BreedingCooldownPair) o;
|
||||
- return playerUUID.equals(that.playerUUID) && animalType.equals(that.animalType);
|
||||
+ if (!(o instanceof BreedingCooldownPair(java.util.UUID uuid, Class<? extends net.minecraft.world.entity.animal.Animal> type))) return false; // Plazma - Use record instead
|
||||
+ return playerUUID.equals(uuid) && animalType.equals(type); // Plazma - Use record instead
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -219,7 +_,6 @@
|
||||
return java.util.Objects.hash(playerUUID, animalType);
|
||||
}
|
||||
}
|
||||
- // Purpur end - Add adjustable breeding cooldown to config
|
||||
|
||||
public CraftWorld getWorld() {
|
||||
return this.world;
|
||||
@@ -228,12 +_,14 @@
|
||||
public CraftServer getCraftServer() {
|
||||
return (CraftServer) Bukkit.getServer();
|
||||
}
|
||||
+
|
||||
// Paper start - Use getChunkIfLoadedImmediately
|
||||
@Override
|
||||
public boolean hasChunk(int chunkX, int chunkZ) {
|
||||
return this.getChunkIfLoaded(chunkX, chunkZ) != null;
|
||||
}
|
||||
// Paper end - Use getChunkIfLoadedImmediately
|
||||
+
|
||||
// Paper start - per world ticks per spawn
|
||||
private int getTicksPerSpawn(SpawnCategory spawnCategory) {
|
||||
final int perWorld = this.paperConfig().entities.spawning.ticksPerSpawn.getInt(CraftSpawnCategory.toNMS(spawnCategory));
|
||||
@@ -248,12 +_,13 @@
|
||||
public abstract ResourceKey<LevelStem> getTypeKey();
|
||||
|
||||
// Paper start - rewrite chunk system
|
||||
+ @Nullable // Plazma - Null safety
|
||||
private ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup entityLookup;
|
||||
private final ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkData> chunkData = new ca.spottedleaf.concurrentutil.map.ConcurrentLong2ReferenceChainedHashTable<>();
|
||||
|
||||
@Override
|
||||
public final ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup moonrise$getEntityLookup() {
|
||||
- return this.entityLookup;
|
||||
+ return java.util.Objects.requireNonNull(this.entityLookup, "Entity lookup not initialised"); // Plazma - Null safety
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -366,7 +_,7 @@
|
||||
*/
|
||||
@Override
|
||||
public ChunkAccess getChunk(final int x, final int z, final ChunkStatus status) {
|
||||
- return ((Level)(Object)this).getChunk(x, z, status, true);
|
||||
+ return this.getChunk(x, z, status, true); // Plazma - Remove unnecessary type casting
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -990,7 +_,7 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
- voxelshape = voxelshape.move((double) position.getX(), (double) position.getY(), (double) position.getZ());
|
||||
+ voxelshape = voxelshape.move(position.getX(), position.getY(), position.getZ()); // Plazma - Remove unnecessary type casting
|
||||
if (voxelshape.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
@@ -1160,130 +_,110 @@
|
||||
return true;
|
||||
}
|
||||
// CraftBukkit end
|
||||
+
|
||||
+ // Plazma start - Improve code quality
|
||||
if (this.isOutsideBuildHeight(pos)) {
|
||||
return false;
|
||||
- } else if (!this.isClientSide && this.isDebug()) {
|
||||
+ }
|
||||
+
|
||||
+ if (!this.isClientSide && this.isDebug()) {
|
||||
return false;
|
||||
- } else {
|
||||
- LevelChunk chunkAt = this.getChunkAt(pos);
|
||||
- Block block = state.getBlock();
|
||||
- // CraftBukkit start - capture blockstates
|
||||
- boolean captured = false;
|
||||
- if (this.captureBlockStates && !this.capturedBlockStates.containsKey(pos)) {
|
||||
- CraftBlockState blockstate = (CraftBlockState) world.getBlockAt(pos.getX(), pos.getY(), pos.getZ()).getState(); // Paper - use CB getState to get a suitable snapshot
|
||||
- blockstate.setFlag(flags); // Paper - set flag
|
||||
- this.capturedBlockStates.put(pos.immutable(), blockstate);
|
||||
- captured = true;
|
||||
+ }
|
||||
+
|
||||
+ LevelChunk chunkAt = this.getChunkAt(pos);
|
||||
+ // CraftBukkit start - capture blockstates
|
||||
+ boolean captured = false;
|
||||
+ if (this.captureBlockStates && !this.capturedBlockStates.containsKey(pos)) {
|
||||
+ CraftBlockState blockstate = (CraftBlockState) world.getBlockAt(pos.getX(), pos.getY(), pos.getZ()).getState(); // Paper - use CB getState to get a suitable snapshot
|
||||
+ blockstate.setFlag(flags); // Paper - set flag
|
||||
+ this.capturedBlockStates.put(pos.immutable(), blockstate);
|
||||
+ captured = true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ BlockState blockState = chunkAt.setBlockState(pos, state, (flags & 64) != 0, (flags & 1024) == 0); // CraftBukkit custom NO_PLACE flag
|
||||
+ this.chunkPacketBlockController.onBlockChange(this, pos, state, blockState, flags, recursionLeft); // Paper - Anti-Xray
|
||||
+
|
||||
+ if (blockState == null) {
|
||||
+ // CraftBukkit start - remove blockstate if failed (or the same)
|
||||
+ if (this.captureBlockStates && captured) {
|
||||
+ this.capturedBlockStates.remove(pos);
|
||||
}
|
||||
// CraftBukkit end
|
||||
-
|
||||
- BlockState blockState = chunkAt.setBlockState(pos, state, (flags & 64) != 0, (flags & 1024) == 0); // CraftBukkit custom NO_PLACE flag
|
||||
- this.chunkPacketBlockController.onBlockChange(this, pos, state, blockState, flags, recursionLeft); // Paper - Anti-Xray
|
||||
-
|
||||
- if (blockState == null) {
|
||||
- // CraftBukkit start - remove blockstate if failed (or the same)
|
||||
- if (this.captureBlockStates && captured) {
|
||||
- this.capturedBlockStates.remove(pos);
|
||||
- }
|
||||
- // CraftBukkit end
|
||||
- return false;
|
||||
- } else {
|
||||
- BlockState blockState1 = this.getBlockState(pos);
|
||||
- /*
|
||||
- if (blockState1 == state) {
|
||||
- if (blockState != blockState1) {
|
||||
- this.setBlocksDirty(pos, blockState, blockState1);
|
||||
- }
|
||||
-
|
||||
- if ((flags & 2) != 0
|
||||
- && (!this.isClientSide || (flags & 4) == 0)
|
||||
- && (this.isClientSide || chunkAt.getFullStatus() != null && chunkAt.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING))) {
|
||||
- this.sendBlockUpdated(pos, blockState, state, flags);
|
||||
- }
|
||||
-
|
||||
- if ((flags & 1) != 0) {
|
||||
- this.blockUpdated(pos, blockState.getBlock());
|
||||
- if (!this.isClientSide && state.hasAnalogOutputSignal()) {
|
||||
- this.updateNeighbourForOutputSignal(pos, block);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if ((flags & 16) == 0 && recursionLeft > 0) {
|
||||
- int i = flags & -34;
|
||||
- blockState.updateIndirectNeighbourShapes(this, pos, i, recursionLeft - 1);
|
||||
- state.updateNeighbourShapes(this, pos, i, recursionLeft - 1);
|
||||
- state.updateIndirectNeighbourShapes(this, pos, i, recursionLeft - 1);
|
||||
- }
|
||||
-
|
||||
- this.onBlockStateChange(pos, blockState, blockState1);
|
||||
- }
|
||||
- */
|
||||
-
|
||||
- // CraftBukkit start
|
||||
- if (!this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates
|
||||
- // Modularize client and physic updates
|
||||
- // Spigot start
|
||||
- try {
|
||||
- this.notifyAndUpdatePhysics(pos, chunkAt, blockState, state, blockState1, flags, recursionLeft);
|
||||
- } catch (StackOverflowError ex) {
|
||||
- Level.lastPhysicsProblem = new BlockPos(pos);
|
||||
- }
|
||||
- // Spigot end
|
||||
- }
|
||||
- // CraftBukkit end
|
||||
-
|
||||
+ return false;
|
||||
+ } else {
|
||||
+ BlockState blockState1 = this.getBlockState(pos);
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ if (this.captureBlockStates) { // Don't notify clients or update physics while capturing blockstates
|
||||
return true;
|
||||
}
|
||||
+
|
||||
+ // Modularize client and physic updates
|
||||
+ // Spigot start
|
||||
+ try {
|
||||
+ this.notifyAndUpdatePhysics(pos, chunkAt, blockState, state, blockState1, flags, recursionLeft);
|
||||
+ } catch (StackOverflowError ex) {
|
||||
+ Level.lastPhysicsProblem = new BlockPos(pos);
|
||||
+ }
|
||||
+ // Spigot end
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ return true;
|
||||
}
|
||||
+ // Plazma end - Improve code quality
|
||||
}
|
||||
|
||||
// CraftBukkit start - Split off from above in order to directly send client and physic updates
|
||||
- public void notifyAndUpdatePhysics(BlockPos blockposition, LevelChunk chunk, BlockState oldBlock, BlockState newBlock, BlockState actualBlock, int i, int j) {
|
||||
- BlockState iblockdata = newBlock;
|
||||
- BlockState iblockdata1 = oldBlock;
|
||||
- BlockState iblockdata2 = actualBlock;
|
||||
- if (iblockdata2 == iblockdata) {
|
||||
- if (iblockdata1 != iblockdata2) {
|
||||
- this.setBlocksDirty(blockposition, iblockdata1, iblockdata2);
|
||||
- }
|
||||
-
|
||||
- if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(FullChunkStatus.FULL)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement // Paper - rewrite chunk system - change from ticking to full
|
||||
- this.sendBlockUpdated(blockposition, iblockdata1, iblockdata, i);
|
||||
- }
|
||||
-
|
||||
- if ((i & 1) != 0) {
|
||||
- this.blockUpdated(blockposition, iblockdata1.getBlock());
|
||||
- if (!this.isClientSide && iblockdata.hasAnalogOutputSignal()) {
|
||||
- this.updateNeighbourForOutputSignal(blockposition, newBlock.getBlock());
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if ((i & 16) == 0 && j > 0) {
|
||||
- int k = i & -34;
|
||||
-
|
||||
- // CraftBukkit start
|
||||
- iblockdata1.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); // Don't call an event for the old block to limit event spam
|
||||
- CraftWorld world = ((ServerLevel) this).getWorld();
|
||||
- boolean cancelledUpdates = false; // Paper - Fix block place logic
|
||||
- if (world != null && ((ServerLevel)this).hasPhysicsEvent) { // Paper - BlockPhysicsEvent
|
||||
- BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata));
|
||||
- this.getCraftServer().getPluginManager().callEvent(event);
|
||||
-
|
||||
- cancelledUpdates = event.isCancelled(); // Paper - Fix block place logic
|
||||
- }
|
||||
- // CraftBukkit end
|
||||
- if (!cancelledUpdates) { // Paper - Fix block place logic
|
||||
- iblockdata.updateNeighbourShapes(this, blockposition, k, j - 1);
|
||||
- iblockdata.updateIndirectNeighbourShapes(this, blockposition, k, j - 1);
|
||||
- } // Paper - Fix block place logic
|
||||
- }
|
||||
-
|
||||
- // CraftBukkit start - SPIGOT-5710
|
||||
- if (!this.preventPoiUpdated) {
|
||||
- this.onBlockStateChange(blockposition, iblockdata1, iblockdata2);
|
||||
+ public void notifyAndUpdatePhysics(BlockPos blockPos, LevelChunk chunk, BlockState oldBlock, BlockState newBlock, BlockState actualBlock, int i, int j) {
|
||||
+ // Plazma start - Improve code quality
|
||||
+ if (actualBlock != newBlock) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (oldBlock != actualBlock) {
|
||||
+ this.setBlocksDirty(blockPos, oldBlock, actualBlock);
|
||||
+ }
|
||||
+
|
||||
+ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(FullChunkStatus.FULL)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement // Paper - rewrite chunk system - change from ticking to full
|
||||
+ this.sendBlockUpdated(blockPos, oldBlock, newBlock, i);
|
||||
+ }
|
||||
+
|
||||
+ if ((i & 1) != 0) {
|
||||
+ this.blockUpdated(blockPos, oldBlock.getBlock());
|
||||
+ if (!this.isClientSide && newBlock.hasAnalogOutputSignal()) {
|
||||
+ this.updateNeighbourForOutputSignal(blockPos, newBlock.getBlock());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if ((i & 16) == 0 && j > 0) {
|
||||
+ int k = i & -34;
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ oldBlock.updateIndirectNeighbourShapes(this, blockPos, k, j - 1); // Don't call an event for the old block to limit event spam
|
||||
+ boolean cancelledUpdates = false; // Paper - Fix block place logic
|
||||
+
|
||||
+ final CraftWorld world = this.getWorld(); // Plazma - Remove unnecessary type casting
|
||||
+ if (world != null && ((ServerLevel)this).hasPhysicsEvent) { // Paper - BlockPhysicsEvent
|
||||
+ BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockPos.getX(), blockPos.getY(), blockPos.getZ()), CraftBlockData.fromData(newBlock));
|
||||
+ this.getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ cancelledUpdates = event.isCancelled(); // Paper - Fix block place logic
|
||||
}
|
||||
// CraftBukkit end
|
||||
- }
|
||||
+
|
||||
+ if (!cancelledUpdates) { // Paper - Fix block place logic
|
||||
+ newBlock.updateNeighbourShapes(this, blockPos, k, j - 1);
|
||||
+ newBlock.updateIndirectNeighbourShapes(this, blockPos, k, j - 1);
|
||||
+ } // Paper - Fix block place logic
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - SPIGOT-5710
|
||||
+ if (!this.preventPoiUpdated) {
|
||||
+ this.onBlockStateChange(blockPos, oldBlock, actualBlock);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ // Plazma end - Improve code quality
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -1518,21 +_,19 @@
|
||||
int tickedEntities = 0; // Paper - rewrite chunk system
|
||||
var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<TickingBlockEntity>(); // Paper - Fix MC-117075; use removeAll
|
||||
toRemove.add(null); // Paper - Fix MC-117075
|
||||
- for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters
|
||||
- this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0;
|
||||
- TickingBlockEntity tickingBlockEntity = this.blockEntityTickers.get(this.tileTickPosition);
|
||||
- // Spigot end
|
||||
+ // Plazma start - Improve code quality
|
||||
+ for (TickingBlockEntity tickingBlockEntity : this.blockEntityTickers) { // Paper - Disable tick limiters
|
||||
if (tickingBlockEntity.isRemoved()) {
|
||||
toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll
|
||||
- } else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) {
|
||||
- tickingBlockEntity.tick();
|
||||
- // Paper start - rewrite chunk system
|
||||
- if ((++tickedEntities & 7) == 0) {
|
||||
- ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)(Level)(Object)this).moonrise$midTickTasks();
|
||||
- }
|
||||
- // Paper end - rewrite chunk system
|
||||
+ continue;
|
||||
}
|
||||
+
|
||||
+ if (!runsNormally || this.shouldTickBlocksAt(tickingBlockEntity.getPos())) continue;
|
||||
+
|
||||
+ tickingBlockEntity.tick();
|
||||
+ if ((++tickedEntities & 7) == 0) this.moonrise$midTickTasks(); // Paper - rewrite chunk system
|
||||
}
|
||||
+ // Plazma end - Improve code quality
|
||||
this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075
|
||||
|
||||
this.tickingBlockEntities = false;
|
||||
@@ -1561,11 +_,11 @@
|
||||
return false;
|
||||
// Paper start - optimise collisions
|
||||
final int flags = entity == null ? (ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_ONLY) : ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_ONLY;
|
||||
- if (ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisionsForBlocksOrWorldBorder((Level)(Object)this, entity, box, null, null, flags, null)) {
|
||||
+ if (ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisionsForBlocksOrWorldBorder(this, entity, box, null, null, flags, null)) { // Plazma - Remove unnecessary type casting
|
||||
return false;
|
||||
}
|
||||
|
||||
- return !ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getEntityHardCollisions((Level)(Object)this, entity, box, null, flags, null);
|
||||
+ return !ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getEntityHardCollisions(this, entity, box, null, flags, null); // Plazma - Remove unnecessary type casting
|
||||
// Paper end - optimise collisions
|
||||
}
|
||||
// Paper end - Option to prevent armor stands from doing entity lookups
|
||||
@@ -1750,7 +_,7 @@
|
||||
public void updateSkyBrightness() {
|
||||
double d = 1.0 - this.getRainLevel(1.0F) * 5.0F / 16.0;
|
||||
double d1 = 1.0 - this.getThunderLevel(1.0F) * 5.0F / 16.0;
|
||||
- double d2 = 0.5 + 2.0 * Mth.clamp((double)Mth.cos(this.getTimeOfDay(1.0F) * (float) (Math.PI * 2)), -0.25, 0.25);
|
||||
+ double d2 = 0.5 + 2.0 * Mth.clamp(Mth.cos(this.getTimeOfDay(1.0F) * (float) (Math.PI * 2)), -0.25, 0.25); // Plazma - Remove unnecessary type casting
|
||||
this.skyDarken = (int)((1.0 - d2 * d * d1) * 11.0);
|
||||
}
|
||||
|
||||
@@ -1774,12 +_,13 @@
|
||||
}
|
||||
|
||||
protected void prepareWeather() {
|
||||
- if (this.levelData.isRaining()) {
|
||||
- this.rainLevel = 1.0F;
|
||||
- if (this.levelData.isThundering()) {
|
||||
- this.thunderLevel = 1.0F;
|
||||
- }
|
||||
- }
|
||||
+ // Plazma start - Improve code quality
|
||||
+ if (!this.levelData.isRaining()) return;
|
||||
+ this.rainLevel = 1F;
|
||||
+
|
||||
+ if (!this.levelData.isThundering()) return;
|
||||
+ this.thunderLevel = 1F;
|
||||
+ // Plazma end - Improve code quality
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1796,15 +_,11 @@
|
||||
@Override
|
||||
public List<Entity> getEntities(@Nullable Entity entity, AABB boundingBox, Predicate<? super Entity> predicate) {
|
||||
Profiler.get().incrementCounter("getEntities");
|
||||
- List<Entity> list = Lists.newArrayList();
|
||||
|
||||
// Paper start - rewrite chunk system
|
||||
final List<Entity> ret = new java.util.ArrayList<>();
|
||||
-
|
||||
- ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(entity, boundingBox, ret, predicate);
|
||||
-
|
||||
- ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities((Level)(Object)this, entity, boundingBox, predicate, ret);
|
||||
-
|
||||
+ this.moonrise$getEntityLookup().getEntities(entity, boundingBox, ret, predicate); // Plazma - Remove unnecessary type casting
|
||||
+ ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities(this, entity, boundingBox, predicate, ret); // Plazma - Remove unnecessary type casting
|
||||
return ret;
|
||||
// Paper end - rewrite chunk system
|
||||
}
|
||||
@@ -1821,78 +_,68 @@
|
||||
}
|
||||
|
||||
// Paper start - rewrite chunk system
|
||||
- public <T extends Entity> void getEntities(final EntityTypeTest<Entity, T> entityTypeTest,
|
||||
- final AABB boundingBox, final Predicate<? super T> predicate,
|
||||
- final List<? super T> into, final int maxCount) {
|
||||
+ public <T extends Entity> void getEntities(
|
||||
+ // Plazma start - Improve code quality
|
||||
+ final @Nullable EntityTypeTest<Entity, T> entityTypeTest,
|
||||
+ final AABB boundingBox,
|
||||
+ final @Nullable Predicate<? super T> predicate,
|
||||
+ final @Nullable List<? super T> into,
|
||||
+ final int maxCount
|
||||
+ ) {
|
||||
Profiler.get().incrementCounter("getEntities");
|
||||
|
||||
if (entityTypeTest instanceof net.minecraft.world.entity.EntityType<T> byType) {
|
||||
if (maxCount != Integer.MAX_VALUE) {
|
||||
- ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(byType, boundingBox, into, predicate, maxCount);
|
||||
- ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities((Level)(Object)this, entityTypeTest, boundingBox, predicate, into, maxCount);
|
||||
- return;
|
||||
+ this.moonrise$getEntityLookup().getEntities(byType, boundingBox, into, predicate, maxCount);
|
||||
} else {
|
||||
- ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(byType, boundingBox, into, predicate);
|
||||
- ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities((Level)(Object)this, entityTypeTest, boundingBox, predicate, into, maxCount);
|
||||
- return;
|
||||
+ this.moonrise$getEntityLookup().getEntities(byType, boundingBox, into, predicate);
|
||||
}
|
||||
+ ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities(this, entityTypeTest, boundingBox, predicate, into, maxCount);
|
||||
+ return;
|
||||
}
|
||||
|
||||
if (entityTypeTest == null) {
|
||||
if (maxCount != Integer.MAX_VALUE) {
|
||||
- ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities((Entity)null, boundingBox, (List)into, (Predicate)predicate, maxCount);
|
||||
- ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities((Level)(Object)this, entityTypeTest, boundingBox, predicate, into, maxCount);
|
||||
- return;
|
||||
+ this.moonrise$getEntityLookup().getEntities(null, boundingBox, into, predicate, maxCount);
|
||||
} else {
|
||||
- ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities((Entity)null, boundingBox, (List)into, (Predicate)predicate);
|
||||
- ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities((Level)(Object)this, entityTypeTest, boundingBox, predicate, into, maxCount);
|
||||
- return;
|
||||
+ this.moonrise$getEntityLookup().getEntities(null, boundingBox, into, predicate);
|
||||
}
|
||||
+ ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities(this, null, boundingBox, predicate, into, maxCount);
|
||||
+ return;
|
||||
}
|
||||
|
||||
final Class<? extends Entity> base = entityTypeTest.getBaseClass();
|
||||
|
||||
final Predicate<? super T> modifiedPredicate;
|
||||
if (predicate == null) {
|
||||
- modifiedPredicate = (final T obj) -> {
|
||||
- return entityTypeTest.tryCast(obj) != null;
|
||||
- };
|
||||
+ modifiedPredicate = (obj) -> entityTypeTest.tryCast(obj) != null;
|
||||
} else {
|
||||
- modifiedPredicate = (final Entity obj) -> {
|
||||
+ modifiedPredicate = (obj) -> {
|
||||
final T casted = entityTypeTest.tryCast(obj);
|
||||
- if (casted == null) {
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- return predicate.test(casted);
|
||||
+ return casted != null && predicate.test(casted);
|
||||
};
|
||||
}
|
||||
|
||||
- if (base == null || base == Entity.class) {
|
||||
+ if (base == Entity.class) {
|
||||
if (maxCount != Integer.MAX_VALUE) {
|
||||
- ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities((Entity)null, boundingBox, (List)into, (Predicate)modifiedPredicate, maxCount);
|
||||
- ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities((Level)(Object)this, entityTypeTest, boundingBox, predicate, into, maxCount);
|
||||
- return;
|
||||
+ this.moonrise$getEntityLookup().getEntities(null, boundingBox, into, modifiedPredicate, maxCount);
|
||||
} else {
|
||||
- ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities((Entity)null, boundingBox, (List)into, (Predicate)modifiedPredicate);
|
||||
- ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities((Level)(Object)this, entityTypeTest, boundingBox, predicate, into, maxCount);
|
||||
- return;
|
||||
+ this.moonrise$getEntityLookup().getEntities(null, boundingBox, into, modifiedPredicate);
|
||||
}
|
||||
} else {
|
||||
if (maxCount != Integer.MAX_VALUE) {
|
||||
- ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(base, null, boundingBox, (List)into, (Predicate)modifiedPredicate, maxCount);
|
||||
- ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities((Level)(Object)this, entityTypeTest, boundingBox, predicate, into, maxCount);
|
||||
- return;
|
||||
+ this.moonrise$getEntityLookup().getEntities(base, null, boundingBox, (List) into, (Predicate) modifiedPredicate, maxCount);
|
||||
} else {
|
||||
- ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(base, null, boundingBox, (List)into, (Predicate)modifiedPredicate);
|
||||
- ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities((Level)(Object)this, entityTypeTest, boundingBox, predicate, into, maxCount);
|
||||
- return;
|
||||
+ this.moonrise$getEntityLookup().getEntities(base, null, boundingBox, (List) into, (Predicate) modifiedPredicate);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ ca.spottedleaf.moonrise.common.PlatformHooks.get().addToGetEntities(this, entityTypeTest, boundingBox, predicate, into, maxCount);
|
||||
+ // Plazma end - Improve code quality
|
||||
}
|
||||
|
||||
public org.bukkit.entity.Entity[] getChunkEntities(int chunkX, int chunkZ) {
|
||||
- ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices slices = ((ServerLevel)this).moonrise$getEntityLookup().getChunk(chunkX, chunkZ);
|
||||
+ ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices slices = this.moonrise$getEntityLookup().getChunk(chunkX, chunkZ); // Plazma - Remove unnecessary type casting
|
||||
if (slices == null) {
|
||||
return new org.bukkit.entity.Entity[0];
|
||||
}
|
||||
@@ -1900,7 +_,7 @@
|
||||
List<org.bukkit.entity.Entity> ret = new java.util.ArrayList<>();
|
||||
for (Entity entity : slices.getAllEntities()) {
|
||||
org.bukkit.entity.Entity bukkit = entity.getBukkitEntity();
|
||||
- if (bukkit != null && bukkit.isValid()) {
|
||||
+ if (bukkit.isValid()) { // Plazma - Not nullable
|
||||
ret.add(bukkit);
|
||||
}
|
||||
}
|
||||
@@ -2032,18 +_,20 @@
|
||||
public void updateNeighbourForOutputSignal(BlockPos pos, Block block) {
|
||||
for (Direction direction : Direction.Plane.HORIZONTAL) {
|
||||
BlockPos blockPos = pos.relative(direction);
|
||||
- if (this.hasChunkAt(blockPos)) {
|
||||
- BlockState blockState = this.getBlockState(blockPos);
|
||||
- if (blockState.is(Blocks.COMPARATOR)) {
|
||||
- this.neighborChanged(blockState, blockPos, block, null, false);
|
||||
- } else if (blockState.isRedstoneConductor(this, blockPos)) {
|
||||
- blockPos = blockPos.relative(direction);
|
||||
- blockState = this.getBlockState(blockPos);
|
||||
- if (blockState.is(Blocks.COMPARATOR)) {
|
||||
- this.neighborChanged(blockState, blockPos, block, null, false);
|
||||
- }
|
||||
+ // Plazma start - Improve code quality
|
||||
+ if (!this.hasChunkAt(blockPos)) continue;
|
||||
+
|
||||
+ BlockState state = this.getBlockState(blockPos);
|
||||
+ if (state.is(Blocks.COMPARATOR)) {
|
||||
+ this.neighborChanged(state, blockPos, block, null, false);
|
||||
+ } else if (state.isRedstoneConductor(this, blockPos)) {
|
||||
+ blockPos = blockPos.relative(direction);
|
||||
+ state = this.getBlockState(blockPos);
|
||||
+ if (state.is(Blocks.COMPARATOR)) {
|
||||
+ this.neighborChanged(state, blockPos, block, null, false);
|
||||
}
|
||||
}
|
||||
+ // Plazma end - Improve code quality
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2145,16 +_,7 @@
|
||||
|
||||
public abstract FuelValues fuelValues();
|
||||
|
||||
- // Paper start - optimize redstone (Alternate Current)
|
||||
- public alternate.current.wire.WireHandler getWireHandler() {
|
||||
- // This method is overridden in ServerLevel.
|
||||
- // Since Paper is a server platform there is no risk
|
||||
- // of this implementation being called. It is here
|
||||
- // only so this method can be called without casting
|
||||
- // an instance of Level to ServerLevel.
|
||||
- return null;
|
||||
- }
|
||||
- // Paper end - optimize redstone (Alternate Current)
|
||||
+ public abstract alternate.current.wire.WireHandler getWireHandler(); // Paper - optimize redstone (Alternate Current) // Plazma - Use abstract instead
|
||||
|
||||
public static enum ExplosionInteraction implements StringRepresentable {
|
||||
NONE("none"),
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/world/level/ServerExplosion.java
|
||||
+++ b/net/minecraft/world/level/ServerExplosion.java
|
||||
@@ -791,10 +_,10 @@
|
||||
return this.getSeenFraction(vec3d, entity, this.directMappedBlockCache, this.mutablePos); // Paper - collision optimisations
|
||||
}
|
||||
CacheKey key = new CacheKey(this, entity.getBoundingBox());
|
||||
- Float blockDensity = this.level.explosionDensityCache.get(key);
|
||||
+ Float blockDensity = ((Level) this.level).explosionDensityCache.get(key); // Plazma - package-private
|
||||
if (blockDensity == null) {
|
||||
blockDensity = this.getSeenFraction(vec3d, entity, this.directMappedBlockCache, this.mutablePos); // Paper - collision optimisations
|
||||
- this.level.explosionDensityCache.put(key, blockDensity);
|
||||
+ ((Level) this.level).explosionDensityCache.put(key, blockDensity); // Plazma - package-private
|
||||
}
|
||||
|
||||
return blockDensity;
|
||||
@@ -1,5 +1,31 @@
|
||||
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
@@ -41,7 +_,7 @@
|
||||
public static final int B_STATS_VERSION = 1;
|
||||
|
||||
// The url to which the data is sent
|
||||
- private static final String URL = "https://bStats.org/submitData/server-implementation";
|
||||
+ private static final java.net.URL URL; // Plazma
|
||||
|
||||
// Should failed requests be logged?
|
||||
private static boolean logFailedRequests = false;
|
||||
@@ -58,6 +_,16 @@
|
||||
// A list with all custom charts
|
||||
private final List<CustomChart> charts = new ArrayList<>();
|
||||
|
||||
+ // Plazma start - Create a URL instance only once
|
||||
+ static {
|
||||
+ try {
|
||||
+ URL = java.net.URI.create("https://bStats.org/submitData/server-implementation").toURL();
|
||||
+ } catch (final IOException e) {
|
||||
+ throw new IllegalStateException(e);
|
||||
+ }
|
||||
+ }
|
||||
+ // Plazma end - Create a URL instance only once
|
||||
+
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
@@ -109,7 +_,7 @@
|
||||
}
|
||||
|
||||
@@ -18,12 +44,20 @@
|
||||
*
|
||||
* @return The server specific data.
|
||||
*/
|
||||
@@ -186,7 +_,7 @@
|
||||
@@ -180,13 +_,13 @@
|
||||
* Sends the data to the bStats server.
|
||||
*
|
||||
* @param data The data to send.
|
||||
- * @throws Exception If the request failed.
|
||||
+ * @throws IOException If the request failed.
|
||||
*/
|
||||
- private static void sendData(JSONObject data) throws Exception {
|
||||
+ private static void sendData(final JSONObject data) throws IOException { // Plazma
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("Data cannot be null!");
|
||||
}
|
||||
- HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
|
||||
+ HttpsURLConnection connection = (HttpsURLConnection) new java.net.URI(URL).toURL().openConnection(); // Plazma - Use modern method
|
||||
+ HttpsURLConnection connection = (HttpsURLConnection) URL.openConnection(); // Plazma - Use modern method
|
||||
|
||||
// Compress the data to save bandwidth
|
||||
byte[] compressedData = compress(data.toString());
|
||||
@@ -59,42 +93,293 @@
|
||||
*/
|
||||
public static class SingleLineChart extends CustomChart {
|
||||
|
||||
@@ -576,12 +_,14 @@
|
||||
config.addDefault("logFailedRequests", false);
|
||||
@@ -559,116 +_,182 @@
|
||||
|
||||
// Inform the server owners about bStats
|
||||
}
|
||||
|
||||
- public static class PaperMetrics {
|
||||
- public static void startMetrics() {
|
||||
+ // Plazma start - PaperMetrics
|
||||
+ public static final class PaperMetrics {
|
||||
+ @org.jspecify.annotations.Nullable
|
||||
+ private static Metrics loadMetrics(final io.papermc.paper.ServerBuildInfo build) {
|
||||
// Get the config file
|
||||
- File configFile = new File(new File((File) MinecraftServer.getServer().options.valueOf("plugins"), "bStats"), "config.yml");
|
||||
- YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
+ final File configFile = new File(new File((File) MinecraftServer.getServer().options.valueOf("plugins"), "bStats"), "config.yml");
|
||||
+ final YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
// Check if the config file exists
|
||||
- if (!config.isSet("serverUuid")) {
|
||||
-
|
||||
- // Add default values
|
||||
- config.addDefault("enabled", true);
|
||||
- // Every server gets it's unique random id.
|
||||
- config.addDefault("serverUuid", UUID.randomUUID().toString());
|
||||
- // Should failed request be logged?
|
||||
- config.addDefault("logFailedRequests", false);
|
||||
-
|
||||
- // Inform the server owners about bStats
|
||||
- config.options().header(
|
||||
- "bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
|
||||
- "To honor their work, you should not disable it.\n" +
|
||||
- "This has nearly no effect on the server performance!\n" +
|
||||
- "Check out https://bStats.org/ to learn more :)"
|
||||
- ).copyDefaults(true);
|
||||
+ // Plazma start - Use modern method
|
||||
- try {
|
||||
- config.save(configFile);
|
||||
- } catch (IOException ignored) {
|
||||
- }
|
||||
- }
|
||||
- // Load the data
|
||||
- String serverUUID = config.getString("serverUuid");
|
||||
- boolean logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
- // Only start Metrics, if it's enabled in the config
|
||||
- if (config.getBoolean("enabled", true)) {
|
||||
- Metrics metrics = new Metrics("Purpur", serverUUID, logFailedRequests, Bukkit.getLogger()); // Pufferfish // Purpur - Purpur config files
|
||||
-
|
||||
- metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
|
||||
- String minecraftVersion = Bukkit.getVersion();
|
||||
- minecraftVersion = minecraftVersion.substring(minecraftVersion.indexOf("MC: ") + 4, minecraftVersion.length() - 1);
|
||||
- return minecraftVersion;
|
||||
- }));
|
||||
-
|
||||
- metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size()));
|
||||
- metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() ? "bungee" : "offline"))); // Purpur - Purpur config files
|
||||
- metrics.addCustomChart(new Metrics.SimplePie("purpur_version", () -> (org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() != null) ? org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() : "unknown")); // Purpur - Purpur config files
|
||||
-
|
||||
- metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
||||
- Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
- String javaVersion = System.getProperty("java.version");
|
||||
- Map<String, Integer> entry = new HashMap<>();
|
||||
- entry.put(javaVersion, 1);
|
||||
-
|
||||
- // http://openjdk.java.net/jeps/223
|
||||
- // Java decided to change their versioning scheme and in doing so modified the java.version system
|
||||
- // property to return $major[.$minor][.$secuity][-ea], as opposed to 1.$major.0_$identifier
|
||||
- // we can handle pre-9 by checking if the "major" is equal to "1", otherwise, 9+
|
||||
- String majorVersion = javaVersion.split("\\.")[0];
|
||||
- String release;
|
||||
-
|
||||
- int indexOf = javaVersion.lastIndexOf('.');
|
||||
-
|
||||
- if (majorVersion.equals("1")) {
|
||||
- release = "Java " + javaVersion.substring(0, indexOf);
|
||||
- } else {
|
||||
- // of course, it really wouldn't be all that simple if they didn't add a quirk, now would it
|
||||
- // valid strings for the major may potentially include values such as -ea to deannotate a pre release
|
||||
- Matcher versionMatcher = Pattern.compile("\\d+").matcher(majorVersion);
|
||||
- if (versionMatcher.find()) {
|
||||
- majorVersion = versionMatcher.group(0);
|
||||
- }
|
||||
- release = "Java " + majorVersion;
|
||||
- }
|
||||
- map.put(release, entry);
|
||||
-
|
||||
- return map;
|
||||
- }));
|
||||
-
|
||||
- metrics.addCustomChart(new Metrics.DrilldownPie("legacy_plugins", () -> {
|
||||
- Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
-
|
||||
- // count legacy plugins
|
||||
- int legacy = 0;
|
||||
- for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
- if (CraftMagicNumbers.isLegacy(plugin.getDescription())) {
|
||||
- legacy++;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- // insert real value as lower dimension
|
||||
- Map<String, Integer> entry = new HashMap<>();
|
||||
- entry.put(String.valueOf(legacy), 1);
|
||||
-
|
||||
- // create buckets as higher dimension
|
||||
- if (legacy == 0) {
|
||||
- map.put("0 \uD83D\uDE0E", entry); // :sunglasses:
|
||||
- } else if (legacy <= 5) {
|
||||
- map.put("1-5", entry);
|
||||
- } else if (legacy <= 10) {
|
||||
- map.put("6-10", entry);
|
||||
- } else if (legacy <= 25) {
|
||||
- map.put("11-25", entry);
|
||||
- } else if (legacy <= 50) {
|
||||
- map.put("26-50", entry);
|
||||
- } else {
|
||||
- map.put("50+ \uD83D\uDE2D", entry); // :cry:
|
||||
- }
|
||||
-
|
||||
- return map;
|
||||
- }));
|
||||
- }
|
||||
-
|
||||
+ if (config.isSet("enabled")) {
|
||||
+ // Return null if it's disabled in the config
|
||||
+ if (!config.getBoolean("enabled", true)) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ // Load the data
|
||||
+ final String serverUUID = config.getString("serverUuid");
|
||||
+ final boolean logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
+
|
||||
+ return new Metrics(build.brandName(), serverUUID, logFailedRequests, Bukkit.getLogger());
|
||||
+ }
|
||||
+
|
||||
+ // Add default values
|
||||
+ config.addDefault("enabled", true);
|
||||
+
|
||||
+ // Every server gets it's unique random id.
|
||||
+ final String serverUUID = UUID.randomUUID().toString();
|
||||
+ config.addDefault("serverUuid", serverUUID);
|
||||
+
|
||||
+ // Should a failed request be logged?
|
||||
+ final boolean logFailedRequests = false;
|
||||
+ config.addDefault("logFailedRequests", logFailedRequests);
|
||||
+
|
||||
+ // Inform the server owners about bStats
|
||||
+ config.options().setHeader(List.of(
|
||||
+ "bStats collects some data for plugin authors like how many servers are using their plugins.",
|
||||
+ "To honor their work, you should not disable it.",
|
||||
+ "This has nearly no effect on the server performance!",
|
||||
+ "Check out https://bStats.org/ to learn more :)"
|
||||
+ )).copyDefaults(true);
|
||||
+ // Plazma end - Use modern method
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException ignored) {
|
||||
@@ -592,7 +_,7 @@
|
||||
boolean logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
// Only start Metrics, if it's enabled in the config
|
||||
if (config.getBoolean("enabled", true)) {
|
||||
- Metrics metrics = new Metrics("Purpur", serverUUID, logFailedRequests, Bukkit.getLogger()); // Pufferfish // Purpur - Purpur config files
|
||||
+ Metrics metrics = new Metrics("Plazma", serverUUID, logFailedRequests, Bukkit.getLogger()); // Pufferfish // Purpur - Purpur config files // Plazma - Rebrand
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
|
||||
String minecraftVersion = Bukkit.getVersion();
|
||||
@@ -602,7 +_,7 @@
|
||||
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() ? "bungee" : "offline"))); // Purpur - Purpur config files
|
||||
- metrics.addCustomChart(new Metrics.SimplePie("purpur_version", () -> (org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() != null) ? org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() : "unknown")); // Purpur - Purpur config files
|
||||
+ metrics.addCustomChart(new Metrics.SimplePie("plazma_version", () -> (org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() != null) ? org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() : "unknown")); // Purpur - Purpur config files // Plazma - Rebrand
|
||||
|
||||
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
||||
Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
+
|
||||
+ try { config.save(configFile); } catch (IOException ignored) {}
|
||||
+ return new Metrics(build.brandName(), serverUUID, logFailedRequests, Bukkit.getLogger());
|
||||
+ }
|
||||
+
|
||||
+ private static DrilldownPie cachedDrilldownPie(final String chartId, final Callable<Map<String, Map<String, Integer>>> callable) {
|
||||
+ try {
|
||||
+ final Map<String, Map<String, Integer>> data = callable.call();
|
||||
+ return new Metrics.DrilldownPie(chartId, () -> data);
|
||||
+ } catch (final Throwable t) {
|
||||
+ if (logFailedRequests) {
|
||||
+ logger.log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
|
||||
+ }
|
||||
+ return new Metrics.DrilldownPie(chartId, () -> null);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void startMetrics() {
|
||||
+ final io.papermc.paper.ServerBuildInfo build = io.papermc.paper.ServerBuildInfo.buildInfo();
|
||||
+
|
||||
+ // Load metrics from config
|
||||
+ final Metrics metrics = loadMetrics(build);
|
||||
+ if (metrics == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ final String minecraftVersion = build.minecraftVersionId();
|
||||
+ metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> minecraftVersion));
|
||||
+
|
||||
+ final String implementationVersion = (org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() != null) ? org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion() : "unknown";
|
||||
+ metrics.addCustomChart(new Metrics.SimplePie("plazma_version", () -> implementationVersion));
|
||||
+
|
||||
+ final String authenticationMode = Bukkit.getOnlineMode() ? "online" : (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() ? "bungee" : "offline");
|
||||
+ metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> authenticationMode));
|
||||
+
|
||||
+ metrics.addCustomChart(new Metrics.SingleLineChart("total_players", () -> Bukkit.getOfflinePlayers().length));
|
||||
+ metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size()));
|
||||
+
|
||||
+ metrics.addCustomChart(cachedDrilldownPie("java_version", () -> {
|
||||
+ String javaVersion = System.getProperty("java.version");
|
||||
+
|
||||
+ // http://openjdk.java.net/jeps/223
|
||||
+ // Java decided to change their versioning scheme and in doing so modified the java.version system
|
||||
+ // property to return $major[.$minor][.$secuity][-ea], as opposed to 1.$major.0_$identifier
|
||||
+ // we can handle pre-9 by checking if the "major" is equal to "1", otherwise, 9+
|
||||
+ String majorVersion = javaVersion.split("\\.")[0];
|
||||
+ String release;
|
||||
+
|
||||
+ if (majorVersion.equals("1")) {
|
||||
+ release = "Java " + javaVersion.substring(0, javaVersion.lastIndexOf('.'));
|
||||
+ } else {
|
||||
+ // of course, it really wouldn't be all that simple if they didn't add a quirk, now would it
|
||||
+ // valid strings for the major may potentially include values such as -ea to deannotate a pre release
|
||||
+ Matcher versionMatcher = Pattern.compile("\\d+").matcher(majorVersion);
|
||||
+ if (versionMatcher.find()) {
|
||||
+ majorVersion = versionMatcher.group(0);
|
||||
+ }
|
||||
+ release = "Java " + majorVersion;
|
||||
+ }
|
||||
+
|
||||
+ return Map.of(release, Map.of(javaVersion, 1));
|
||||
+ }));
|
||||
+
|
||||
+ metrics.addCustomChart(new Metrics.DrilldownPie("datapacks", () -> {
|
||||
+ // count datapacks; since datapacks can be reloaded, we must always count the number again.
|
||||
+ final int count = Bukkit.getDatapackManager().getEnabledPacks().size();
|
||||
+
|
||||
+ // create buckets as higher dimension
|
||||
+ final String key;
|
||||
+ if (count == 0) key = "0";
|
||||
+ else if (count <= 5) key = "1-5";
|
||||
+ else if (count <= 10) key = "6-10";
|
||||
+ else if (count <= 25) key = "11-25";
|
||||
+ else if (count <= 50) key = "26-50";
|
||||
+ else if (count <= 100) key = "51-100";
|
||||
+ else key = "101+ \uD83D\uDE2E"; // :open_mouth:
|
||||
+
|
||||
+ return Map.of(key, Map.of(String.valueOf(count), 1));
|
||||
+ }));
|
||||
+
|
||||
+ final java.util.stream.Stream<Plugin> plugins = Arrays.stream(Bukkit.getPluginManager().getPlugins());
|
||||
+
|
||||
+ // Total plugins count
|
||||
+ metrics.addCustomChart(cachedDrilldownPie("plugins", () -> {
|
||||
+ // count plugins
|
||||
+ final long count = Bukkit.getPluginManager().getPlugins().length;
|
||||
+
|
||||
+ // create buckets as higher dimension
|
||||
+ final String key;
|
||||
+ if (count == 0) key = "0";
|
||||
+ else if (count <= 5) key = "1-5";
|
||||
+ else if (count <= 10) key = "6-10";
|
||||
+ else if (count <= 25) key = "11-25";
|
||||
+ else if (count <= 50) key = "26-50";
|
||||
+ else if (count <= 100) key = "51-100";
|
||||
+ else key = "101+ \uD83D\uDE2E"; // :open_mouth:
|
||||
+
|
||||
+ return Map.of(key, Map.of(String.valueOf(count), 1));
|
||||
+ }));
|
||||
+
|
||||
+ // Disabled plugins
|
||||
+ metrics.addCustomChart(cachedDrilldownPie("disabled_plugins", () -> {
|
||||
+ // count disabled plugins
|
||||
+ final long count = plugins.filter(plugin -> !plugin.isEnabled()).count();
|
||||
+
|
||||
+ // create buckets as higher dimension
|
||||
+ final String key;
|
||||
+ if (count == 0) key = "0 \uD83D\uDE0E"; // :sunglasses:
|
||||
+ else if (count <= 5) key = "1-5";
|
||||
+ else if (count <= 10) key = "6-10";
|
||||
+ else if (count <= 25) key = "11-25";
|
||||
+ else if (count <= 50) key = "26-50";
|
||||
+ else if (count <= 100) key = "51-100";
|
||||
+ else key = "101+ \uD83D\uDC80"; // :skull:
|
||||
+
|
||||
+ return Map.of(key, Map.of(String.valueOf(count), 1));
|
||||
+ }));
|
||||
+
|
||||
+ // Legacy plugins
|
||||
+ metrics.addCustomChart(cachedDrilldownPie("legacy_plugins", () -> {
|
||||
+ // count legacy plugins
|
||||
+ final long count = plugins.filter(plugin -> plugin.getPluginMeta().getAPIVersion() == null).count();
|
||||
+
|
||||
+ // create buckets as higher dimension
|
||||
+ final String key;
|
||||
+ if (count == 0) key = "0 \uD83D\uDE0E"; // :sunglasses:
|
||||
+ else if (count <= 5) key = "1-5";
|
||||
+ else if (count <= 10) key = "6-10";
|
||||
+ else if (count <= 25) key = "11-25";
|
||||
+ else if (count <= 50) key = "26-50";
|
||||
+ else if (count <= 100) key = "51-100";
|
||||
+ else key = "101+ \uD83D\uDE2D"; // :cry:
|
||||
+
|
||||
+ return Map.of(key, Map.of(String.valueOf(count), 1));
|
||||
+ }));
|
||||
}
|
||||
}
|
||||
+ // Plazma end - PaperMetrics
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.plazmamc.plazma;
|
||||
|
||||
import static java.lang.Boolean.getBoolean;
|
||||
|
||||
public interface Options {
|
||||
|
||||
boolean OPTIMIZE = !getBoolean("Plazma.disableConfigOptimization");
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.plazmamc.plazma.configurations;
|
||||
|
||||
import io.papermc.paper.configuration.ConfigurationPart;
|
||||
import io.papermc.paper.configuration.Configurations;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class GlobalConfiguration extends ConfigurationPart {
|
||||
|
||||
static GlobalConfiguration INSTANCE;
|
||||
static final int VERSION = 2;
|
||||
|
||||
@Contract(pure = true)
|
||||
public static @NonNull GlobalConfiguration get() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Setting(Configurations.VERSION_FIELD)
|
||||
int version = VERSION;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package org.plazmamc.plazma.configurations;
|
||||
|
||||
import io.papermc.paper.configuration.Configurations;
|
||||
import io.papermc.paper.configuration.serializer.ComponentSerializer;
|
||||
import io.papermc.paper.configuration.serializer.EnumValueSerializer;
|
||||
import io.papermc.paper.configuration.serializer.ResourceLocationSerializer;
|
||||
import io.papermc.paper.configuration.serializer.collections.MapSerializer;
|
||||
import joptsimple.OptionSet;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
import org.spongepowered.configurate.ConfigurationOptions;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class PlazmaConfigurations extends Configurations<GlobalConfiguration, WorldConfiguration> {
|
||||
|
||||
private PlazmaConfigurations(final Path configDir) {
|
||||
super(
|
||||
configDir,
|
||||
|
||||
GlobalConfiguration.class,
|
||||
// TODO: yaml (convert)
|
||||
"plazma-global.yml",
|
||||
"""
|
||||
This is the global configuration file for Plazma.
|
||||
|
||||
As you can see, there's a lot to configure. Some options may
|
||||
impact gameplay, so use with caution, and make sure you know
|
||||
what each option does before configuring.
|
||||
|
||||
A description of the options can be found on the official docs,
|
||||
If you need help with the configuration or have any questions
|
||||
related to Plazma, join us in our Discord for Plazma, or create
|
||||
discussions on our GitHub repository.
|
||||
|
||||
World configurations can be set in the plazma-world-defaults.yml
|
||||
|
||||
Docs: https://docs.plazmamc.org/
|
||||
GitHub: https://github.com/PlazmaMC/Plazma
|
||||
Support: https://plazmamc.org/discord
|
||||
""",
|
||||
GlobalConfiguration.VERSION,
|
||||
|
||||
WorldConfiguration.class,
|
||||
// TODO: plazma-world-defaults.yml -> plazma-world.yaml (convert)
|
||||
"plazma-world-defaults.yml",
|
||||
"""
|
||||
This is the default world configuration file for Plazma.
|
||||
|
||||
As you can see, there's a lot to configure. Some options may
|
||||
impact gameplay, so use with caution, and make sure you know
|
||||
what each option does before configuring.
|
||||
|
||||
A description of the options can be found on the official docs,
|
||||
If you need help with the configuration or have any questions
|
||||
related to Plazma, join us in our Discord for Plazma, or create
|
||||
discussions on our GitHub repository.
|
||||
|
||||
World-specific settings can be set in the plazma-world.yml file
|
||||
within each world folder, and the same settings apply to all
|
||||
worlds unless they are overwritten through the world-specific
|
||||
settings file.
|
||||
|
||||
Docs: https://docs.plazmamc.org/
|
||||
GitHub: https://github.com/PlazmaMC/Plazma
|
||||
Support: https://plazmamc.org/discord
|
||||
""",
|
||||
// TODO: yaml (convert)
|
||||
"plazma-world.yml",
|
||||
(map) -> String.format("""
|
||||
This is world-specific Plazma configuration file for the world %s (%s).
|
||||
|
||||
This file may start empty, but can be filled with options to
|
||||
override world default configuration. Some options may impact
|
||||
gameplay, so use with caution, and make sure you know what each
|
||||
option does before configuring.
|
||||
|
||||
A description of the options can be found on the official docs,
|
||||
If you need help with the configuration or have any questions
|
||||
related to Plazma, join us in our Discord for Plazma, or create
|
||||
discussions on our GitHub repository.
|
||||
|
||||
Docs: https://docs.plazmamc.org/
|
||||
GitHub: https://github.com/PlazmaMC/Plazma
|
||||
Support: https://plazmamc.org/discord
|
||||
""", map.require(WORLD_NAME), map.require(WORLD_KEY)),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GlobalConfiguration globalConfigInstance() {
|
||||
return GlobalConfiguration.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WorldConfiguration worldConfigInstance(final @NonNull ServerLevel level) {
|
||||
return level.plazmaConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConfigurationOptions defaultOptions(final ConfigurationOptions options) {
|
||||
return options.serializers(builder -> builder
|
||||
.register(MapSerializer.TYPE, new MapSerializer(false))
|
||||
.register(new EnumValueSerializer())
|
||||
.register(new ComponentSerializer())
|
||||
.register(ResourceLocationSerializer.INSTANCE)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConfigurationOptions defaultGlobalOptions(final ConfigurationOptions options, final RegistryAccess registryAccess) {
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setGlobalConfigInstance(final GlobalConfiguration instance) {
|
||||
if (GlobalConfiguration.INSTANCE != null) {
|
||||
throw new IllegalStateException("Global configuration is already initialized");
|
||||
}
|
||||
GlobalConfiguration.INSTANCE = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected WorldConfiguration createWorldConfigInstance(final ContextMap contextMap) {
|
||||
return new WorldConfiguration(contextMap.require(WORLD_KEY));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConfigurationOptions defaultWorldOptions(final ConfigurationOptions options, final ContextMap contextMap) {
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ContextMap createWorldContextMap(final ServerLevel level) {
|
||||
return ContextMap.builder()
|
||||
.put(WORLD_DIRECTORY, level.levelStorageAccess.levelDirectory.path())
|
||||
.put(WORLD_NAME, level.serverLevelData.getLevelName())
|
||||
.put(WORLD_KEY, level.dimension().location())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static PlazmaConfigurations create(final OptionSet optionSet) {
|
||||
return new PlazmaConfigurations(((File) optionSet.valueOf("paper-settings-directory")).toPath());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.plazmamc.plazma.configurations;
|
||||
|
||||
import io.papermc.paper.configuration.ConfigurationPart;
|
||||
import io.papermc.paper.configuration.Configurations;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
|
||||
@SuppressWarnings({"unused", "FieldCanBeLocal"})
|
||||
public final class WorldConfiguration extends ConfigurationPart {
|
||||
|
||||
static final int VERSION = 2;
|
||||
|
||||
private transient final ResourceLocation worldKey;
|
||||
public WorldConfiguration(final ResourceLocation worldKey) {
|
||||
this.worldKey = worldKey;
|
||||
}
|
||||
|
||||
@Setting(Configurations.VERSION_FIELD)
|
||||
int version = VERSION;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user