mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-22 08:19:19 +00:00
split configs
This commit is contained in:
@@ -27,7 +27,7 @@ index 4f90ebcd86fba38dec313143e36614e992c7dbc7..959d87f4cd1efe8cf591e98c7d327280
|
|||||||
|
|
||||||
this.setPvpAllowed(properties.pvp);
|
this.setPvpAllowed(properties.pvp);
|
||||||
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
||||||
index 0fe8f4601eedfa68c38ebadc7847ba7a07ff6fb6..3856bbe579ef6df2f220c46bc69461cab026a131 100644
|
index 0fe8f4601eedfa68c38ebadc7847ba7a07ff6fb6..b4c2602ecf6b943ab022866231f74b850269af8f 100644
|
||||||
--- a/net/minecraft/world/level/Level.java
|
--- a/net/minecraft/world/level/Level.java
|
||||||
+++ b/net/minecraft/world/level/Level.java
|
+++ b/net/minecraft/world/level/Level.java
|
||||||
@@ -171,6 +171,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -171,6 +171,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
@@ -38,11 +38,18 @@ index 0fe8f4601eedfa68c38ebadc7847ba7a07ff6fb6..3856bbe579ef6df2f220c46bc69461ca
|
|||||||
public static BlockPos lastPhysicsProblem; // Spigot
|
public static BlockPos lastPhysicsProblem; // Spigot
|
||||||
private org.spigotmc.TickLimiter entityLimiter;
|
private org.spigotmc.TickLimiter entityLimiter;
|
||||||
private org.spigotmc.TickLimiter tileLimiter;
|
private org.spigotmc.TickLimiter tileLimiter;
|
||||||
@@ -898,6 +899,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -898,6 +899,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot
|
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot
|
||||||
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
|
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
|
||||||
this.purpurConfig = new org.purpurmc.purpur.PurpurWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName(), env); // Purpur - Purpur config files
|
this.purpurConfig = new org.purpurmc.purpur.PurpurWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName(), env); // Purpur - Purpur config files
|
||||||
+ this.divineConfig = new org.bxteam.divinemc.DivineWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName(), env); // DivineMC - Configuration
|
+ // DivineMC start - Configuration
|
||||||
|
+ try {
|
||||||
|
+ this.divineConfig = new org.bxteam.divinemc.DivineWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName(), env);
|
||||||
|
+ } catch (java.io.IOException e) {
|
||||||
|
+ net.minecraft.server.MinecraftServer.LOGGER.error("Failed to load DivineMC configuration for world '{}'", ((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName(), e);
|
||||||
|
+ throw new RuntimeException(e);
|
||||||
|
+ }
|
||||||
|
+ // DivineMC end - Configuration
|
||||||
this.playerBreedingCooldowns = this.getNewBreedingCooldownCache(); // Purpur - Add adjustable breeding cooldown to config
|
this.playerBreedingCooldowns = this.getNewBreedingCooldownCache(); // Purpur - Add adjustable breeding cooldown to config
|
||||||
this.generator = gen;
|
this.generator = gen;
|
||||||
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);
|
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ index 959d87f4cd1efe8cf591e98c7d32728067f7117c..697f690305db56ae5a05483aae37994d
|
|||||||
try {
|
try {
|
||||||
org.purpurmc.purpur.PurpurConfig.init((java.io.File) options.valueOf("purpur-settings"));
|
org.purpurmc.purpur.PurpurConfig.init((java.io.File) options.valueOf("purpur-settings"));
|
||||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||||
index 5d2483b2d59ae246b822d73b9996c2aa86623ab1..92f3e5d929997a974c367ec3ce02cda4acdb5183 100644
|
index fad9cf255cbb222f0bf80f5e8126fed3cf033b1f..59c24ebf12fa8a370750c265be7618eac689f2ff 100644
|
||||||
--- a/net/minecraft/server/level/ServerLevel.java
|
--- a/net/minecraft/server/level/ServerLevel.java
|
||||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||||
@@ -184,7 +184,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
@@ -184,7 +184,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||||
@@ -599,7 +599,7 @@ index 264b713e8b7c3d5f7d8e1facc90a60349f2cf414..f461b060e03edf4102290a424ab008b8
|
|||||||
serverLevel.capturedBlockStates.clear();
|
serverLevel.capturedBlockStates.clear();
|
||||||
org.bukkit.event.world.StructureGrowEvent structureEvent = null;
|
org.bukkit.event.world.StructureGrowEvent structureEvent = null;
|
||||||
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
||||||
index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a76c83e98 100644
|
index b4c2602ecf6b943ab022866231f74b850269af8f..ad80b2fe21a09f070bc5e299e18533c2ec811ca3 100644
|
||||||
--- a/net/minecraft/world/level/Level.java
|
--- a/net/minecraft/world/level/Level.java
|
||||||
+++ b/net/minecraft/world/level/Level.java
|
+++ b/net/minecraft/world/level/Level.java
|
||||||
@@ -172,6 +172,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -172,6 +172,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
@@ -610,7 +610,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a
|
|||||||
public static BlockPos lastPhysicsProblem; // Spigot
|
public static BlockPos lastPhysicsProblem; // Spigot
|
||||||
private org.spigotmc.TickLimiter entityLimiter;
|
private org.spigotmc.TickLimiter entityLimiter;
|
||||||
private org.spigotmc.TickLimiter tileLimiter;
|
private org.spigotmc.TickLimiter tileLimiter;
|
||||||
@@ -1146,6 +1147,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -1153,6 +1154,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) {
|
public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) {
|
||||||
@@ -618,7 +618,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a
|
|||||||
// CraftBukkit start - tree generation
|
// CraftBukkit start - tree generation
|
||||||
if (this.captureTreeGeneration) {
|
if (this.captureTreeGeneration) {
|
||||||
// Paper start - Protect Bedrock and End Portal/Frames from being destroyed
|
// Paper start - Protect Bedrock and End Portal/Frames from being destroyed
|
||||||
@@ -1530,7 +1532,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -1537,7 +1539,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
tickingBlockEntity.tick();
|
tickingBlockEntity.tick();
|
||||||
// Paper start - rewrite chunk system
|
// Paper start - rewrite chunk system
|
||||||
if ((++tickedEntities & 7) == 0) {
|
if ((++tickedEntities & 7) == 0) {
|
||||||
@@ -627,7 +627,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a
|
|||||||
}
|
}
|
||||||
// Paper end - rewrite chunk system
|
// Paper end - rewrite chunk system
|
||||||
}
|
}
|
||||||
@@ -1553,7 +1555,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -1560,7 +1562,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
|
entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
|
||||||
// Paper end - Prevent block entity and entity crashes
|
// Paper end - Prevent block entity and entity crashes
|
||||||
}
|
}
|
||||||
@@ -636,7 +636,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Paper start - Option to prevent armor stands from doing entity lookups
|
// Paper start - Option to prevent armor stands from doing entity lookups
|
||||||
@@ -1696,6 +1698,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -1703,6 +1705,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public BlockEntity getBlockEntity(BlockPos pos, boolean validate) {
|
public BlockEntity getBlockEntity(BlockPos pos, boolean validate) {
|
||||||
@@ -644,7 +644,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a
|
|||||||
// Paper start - Perf: Optimize capturedTileEntities lookup
|
// Paper start - Perf: Optimize capturedTileEntities lookup
|
||||||
net.minecraft.world.level.block.entity.BlockEntity blockEntity;
|
net.minecraft.world.level.block.entity.BlockEntity blockEntity;
|
||||||
if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(pos)) != null) {
|
if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(pos)) != null) {
|
||||||
@@ -1713,6 +1716,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -1720,6 +1723,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlockEntity(BlockEntity blockEntity) {
|
public void setBlockEntity(BlockEntity blockEntity) {
|
||||||
@@ -652,7 +652,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a
|
|||||||
BlockPos blockPos = blockEntity.getBlockPos();
|
BlockPos blockPos = blockEntity.getBlockPos();
|
||||||
if (!this.isOutsideBuildHeight(blockPos)) {
|
if (!this.isOutsideBuildHeight(blockPos)) {
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
@@ -1797,6 +1801,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -1804,6 +1808,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Entity> getEntities(@Nullable Entity entity, AABB boundingBox, Predicate<? super Entity> predicate) {
|
public List<Entity> getEntities(@Nullable Entity entity, AABB boundingBox, Predicate<? super Entity> predicate) {
|
||||||
@@ -660,7 +660,7 @@ index 3856bbe579ef6df2f220c46bc69461cab026a131..8f37c27bba829733fb8db5f35470092a
|
|||||||
Profiler.get().incrementCounter("getEntities");
|
Profiler.get().incrementCounter("getEntities");
|
||||||
List<Entity> list = Lists.newArrayList();
|
List<Entity> list = Lists.newArrayList();
|
||||||
|
|
||||||
@@ -2109,8 +2114,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -2116,8 +2121,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
public abstract RecipeAccess recipeAccess();
|
public abstract RecipeAccess recipeAccess();
|
||||||
|
|
||||||
public BlockPos getBlockRandomPos(int x, int y, int z, int yMask) {
|
public BlockPos getBlockRandomPos(int x, int y, int z, int yMask) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Re-Fix MC-117075
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
||||||
index 8f37c27bba829733fb8db5f35470092a76c83e98..595ebb40f47dd55127c630813813d21d8a1274cd 100644
|
index ad80b2fe21a09f070bc5e299e18533c2ec811ca3..7c80f90ccab0f90a4c76c2d195f4aaa0b12deb9a 100644
|
||||||
--- a/net/minecraft/world/level/Level.java
|
--- a/net/minecraft/world/level/Level.java
|
||||||
+++ b/net/minecraft/world/level/Level.java
|
+++ b/net/minecraft/world/level/Level.java
|
||||||
@@ -115,7 +115,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -115,7 +115,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
@@ -17,7 +17,7 @@ index 8f37c27bba829733fb8db5f35470092a76c83e98..595ebb40f47dd55127c630813813d21d
|
|||||||
protected final NeighborUpdater neighborUpdater;
|
protected final NeighborUpdater neighborUpdater;
|
||||||
private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
|
private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
|
||||||
private boolean tickingBlockEntities;
|
private boolean tickingBlockEntities;
|
||||||
@@ -1527,7 +1527,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -1534,7 +1534,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
TickingBlockEntity tickingBlockEntity = this.blockEntityTickers.get(this.tileTickPosition);
|
TickingBlockEntity tickingBlockEntity = this.blockEntityTickers.get(this.tileTickPosition);
|
||||||
// Spigot end
|
// Spigot end
|
||||||
if (tickingBlockEntity.isRemoved()) {
|
if (tickingBlockEntity.isRemoved()) {
|
||||||
@@ -26,7 +26,7 @@ index 8f37c27bba829733fb8db5f35470092a76c83e98..595ebb40f47dd55127c630813813d21d
|
|||||||
} else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) {
|
} else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) {
|
||||||
tickingBlockEntity.tick();
|
tickingBlockEntity.tick();
|
||||||
// Paper start - rewrite chunk system
|
// Paper start - rewrite chunk system
|
||||||
@@ -1539,6 +1539,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
@@ -1546,6 +1546,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||||
}
|
}
|
||||||
this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075
|
this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Configuration
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
index 6a08a42acdb2ee24b5e403b15fb825f3cb49c968..f4f2473aa844bb245156e391df9f1997bf2013f5 100644
|
index 6a08a42acdb2ee24b5e403b15fb825f3cb49c968..e51fd95bad5038ec7c1b85babf29799d443f9b8b 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
@@ -1103,6 +1103,13 @@ public final class CraftServer implements Server {
|
@@ -1103,6 +1103,13 @@ public final class CraftServer implements Server {
|
||||||
@@ -22,16 +22,22 @@ index 6a08a42acdb2ee24b5e403b15fb825f3cb49c968..f4f2473aa844bb245156e391df9f1997
|
|||||||
for (ServerLevel world : this.console.getAllLevels()) {
|
for (ServerLevel world : this.console.getAllLevels()) {
|
||||||
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
||||||
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
|
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
|
||||||
@@ -1119,6 +1126,7 @@ public final class CraftServer implements Server {
|
@@ -1119,6 +1126,13 @@ public final class CraftServer implements Server {
|
||||||
}
|
}
|
||||||
world.spigotConfig.init(); // Spigot
|
world.spigotConfig.init(); // Spigot
|
||||||
world.purpurConfig.init(); // Purpur - Purpur config files
|
world.purpurConfig.init(); // Purpur - Purpur config files
|
||||||
+ world.divineConfig.init(); // DivineMC - Configuration
|
+ // DivineMC start - Configuration
|
||||||
|
+ try {
|
||||||
|
+ world.divineConfig.init();
|
||||||
|
+ } catch (IOException e) {
|
||||||
|
+ this.logger.log(Level.WARNING, "Failed to reload DivineMC configuration for world " + world.dimension().location(), e);
|
||||||
|
+ }
|
||||||
|
+ // DivineMC end - Configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper
|
Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
index bab0d25e82f85c7b9524ae42e0bb41e6233d71cf..f367efa0afae9792f87a842dfe7ba098a3ce7f2d 100644
|
index bab0d25e82f85c7b9524ae42e0bb41e6233d71cf..f263987076d352dbf6e4bb5c57a35a4593088bae 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
@@ -183,6 +183,15 @@ public class Main {
|
@@ -183,6 +183,15 @@ public class Main {
|
||||||
@@ -43,7 +49,7 @@ index bab0d25e82f85c7b9524ae42e0bb41e6233d71cf..f367efa0afae9792f87a842dfe7ba098
|
|||||||
+ acceptsAll(asList("divinemc", "divinemc-settings"), "File for DivineMC settings")
|
+ acceptsAll(asList("divinemc", "divinemc-settings"), "File for DivineMC settings")
|
||||||
+ .withRequiredArg()
|
+ .withRequiredArg()
|
||||||
+ .ofType(File.class)
|
+ .ofType(File.class)
|
||||||
+ .defaultsTo(new File("divinemc.yml"))
|
+ .defaultsTo(new File("config", "divinemc-global.yml"))
|
||||||
+ .describedAs("Yml file");
|
+ .describedAs("Yml file");
|
||||||
+ // DivineMC end - Configuration
|
+ // DivineMC end - Configuration
|
||||||
+
|
+
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ index de8b9048c8395c05b8688bc9d984b8ad680f15b3..98bd60111797225f3be5e2a19e25d654
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
index f5072cf579af02bde4d2f822f4e4b7973f0b7a83..cdd2fa08a813c8cec11472e378a19ce0ab3157c8 100644
|
index 384ffd0d306cf01ce58864e9d2fcf7def6afca0f..12cfe2abd84f7ba63d935f91ce907bf3f52832da 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
@@ -1408,7 +1408,11 @@ public final class CraftServer implements Server {
|
@@ -1414,7 +1414,11 @@ public final class CraftServer implements Server {
|
||||||
registryAccess = levelDataAndDimensions.dimensions().dimensionsRegistryAccess();
|
registryAccess = levelDataAndDimensions.dimensions().dimensionsRegistryAccess();
|
||||||
} else {
|
} else {
|
||||||
LevelSettings levelSettings;
|
LevelSettings levelSettings;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package org.bxteam.divinemc;
|
|||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.MemoryConfiguration;
|
import org.bukkit.configuration.MemoryConfiguration;
|
||||||
import org.bxteam.divinemc.entity.pathfinding.PathfindTaskRejectPolicy;
|
import org.bxteam.divinemc.entity.pathfinding.PathfindTaskRejectPolicy;
|
||||||
@@ -14,11 +13,9 @@ import org.simpleyaml.exceptions.InvalidConfigurationException;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class DivineConfig {
|
public class DivineConfig {
|
||||||
@@ -32,6 +29,8 @@ public class DivineConfig {
|
|||||||
New builds: https://github.com/BX-Team/DivineMC/releases/latest""";
|
New builds: https://github.com/BX-Team/DivineMC/releases/latest""";
|
||||||
|
|
||||||
public static final Logger LOGGER = LogManager.getLogger(DivineConfig.class.getSimpleName());
|
public static final Logger LOGGER = LogManager.getLogger(DivineConfig.class.getSimpleName());
|
||||||
|
public static final int CONFIG_VERSION = 5;
|
||||||
|
|
||||||
private static File configFile;
|
private static File configFile;
|
||||||
public static final YamlFile config = new YamlFile();
|
public static final YamlFile config = new YamlFile();
|
||||||
private static int updates = 0;
|
private static int updates = 0;
|
||||||
@@ -66,39 +65,23 @@ public class DivineConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getString("config.version", "5");
|
getInt("config.version", CONFIG_VERSION);
|
||||||
getBoolean("config.verbose", false);
|
|
||||||
config.options().header(HEADER);
|
config.options().header(HEADER);
|
||||||
config.options().copyDefaults(true);
|
|
||||||
|
|
||||||
readConfig(configFile, config, DivineConfig.class, null);
|
for (Method method : DivineConfig.class.getDeclaredMethods()) {
|
||||||
}
|
if (Modifier.isStatic(method.getModifiers()) && Modifier.isPrivate(method.getModifiers()) && method.getParameterCount() == 0 && method.getReturnType() == Void.TYPE && !method.getName().startsWith("lambda")) {
|
||||||
|
|
||||||
public static void readConfig(Class<?> clazz, @Nullable Object instance) {
|
|
||||||
readConfig(configFile, config, clazz, instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void readConfig(File configFile, YamlFile config, Class<?> clazz, @Nullable Object instance) {
|
|
||||||
for (Method method : clazz.getDeclaredMethods()) {
|
|
||||||
if (!Modifier.isPrivate(method.getModifiers())) continue;
|
|
||||||
if (method.getParameterTypes().length != 0) continue;
|
|
||||||
if (method.getReturnType() != Void.TYPE) continue;
|
|
||||||
|
|
||||||
try {
|
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
method.invoke(instance);
|
try {
|
||||||
} catch (InvocationTargetException ex) {
|
method.invoke(null);
|
||||||
throw new RuntimeException(ex.getCause());
|
} catch (Throwable t) {
|
||||||
} catch (Exception ex) {
|
LOGGER.warn("Failed to load configuration option from " + method.getName(), t);
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
updates++;
|
||||||
|
|
||||||
config.save(configFile);
|
config.save(configFile);
|
||||||
} catch (IOException ex) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not save " + configFile, ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setComment(String key, String... comment) {
|
private static void setComment(String key, String... comment) {
|
||||||
@@ -108,11 +91,9 @@ public class DivineConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ensureDefault(String key, Object defaultValue, String... comment) {
|
private static void ensureDefault(String key, Object defaultValue, String... comment) {
|
||||||
if (!config.contains(key)) {
|
if (!config.contains(key)) config.set(key, defaultValue);
|
||||||
config.set(key, defaultValue);
|
|
||||||
if (comment.length > 0) config.setComment(key, String.join("\n", comment), CommentType.BLOCK);
|
if (comment.length > 0) config.setComment(key, String.join("\n", comment), CommentType.BLOCK);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean getBoolean(String key, boolean defaultValue, String... comment) {
|
private static boolean getBoolean(String key, boolean defaultValue, String... comment) {
|
||||||
return getBoolean(key, null, defaultValue, comment);
|
return getBoolean(key, null, defaultValue, comment);
|
||||||
|
|||||||
@@ -1,65 +1,120 @@
|
|||||||
package org.bxteam.divinemc;
|
package org.bxteam.divinemc;
|
||||||
|
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.simpleyaml.configuration.file.YamlFile;
|
import org.simpleyaml.configuration.file.YamlFile;
|
||||||
|
import org.simpleyaml.exceptions.InvalidConfigurationException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings({"unused", "DuplicatedCode"})
|
||||||
public class DivineWorldConfig {
|
public class DivineWorldConfig {
|
||||||
private final YamlFile config;
|
private static final String HEADER = """
|
||||||
|
This is the world configuration file for DivineMC.
|
||||||
|
Configuration options here apply to all worlds, unless you specify overrides inside
|
||||||
|
the world-specific config file inside each world folder.
|
||||||
|
|
||||||
|
If you need help with the configuration or have any questions related to DivineMC,
|
||||||
|
join us in our Discord server.
|
||||||
|
|
||||||
|
Discord: https://discord.gg/p7cxhw7E2M
|
||||||
|
Docs: https://bxteam.org/docs/divinemc
|
||||||
|
New builds: https://github.com/BX-Team/DivineMC/releases/latest""";
|
||||||
|
|
||||||
|
public static final Logger LOGGER = LogManager.getLogger(DivineWorldConfig.class.getSimpleName());
|
||||||
|
public static final int CONFIG_VERSION = 5;
|
||||||
|
|
||||||
|
private static final YamlFile config = new YamlFile();
|
||||||
private final String worldName;
|
private final String worldName;
|
||||||
private final World.Environment environment;
|
private final World.Environment environment;
|
||||||
|
|
||||||
public DivineWorldConfig(String worldName, World.Environment environment) {
|
public DivineWorldConfig(String worldName, World.Environment environment) throws IOException {
|
||||||
this.config = DivineConfig.config;
|
|
||||||
this.worldName = worldName;
|
this.worldName = worldName;
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() throws IOException {
|
||||||
DivineConfig.readConfig(DivineWorldConfig.class, this);
|
File configFile = new File("config", "divinemc-world.yml");
|
||||||
|
|
||||||
|
if (configFile.exists()) {
|
||||||
|
try {
|
||||||
|
config.load(configFile);
|
||||||
|
} catch (InvalidConfigurationException e) {
|
||||||
|
throw new IOException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config.getInt("config.version", CONFIG_VERSION);
|
||||||
|
config.options().header(HEADER);
|
||||||
|
|
||||||
|
for (Method method : DivineWorldConfig.class.getDeclaredMethods()) {
|
||||||
|
if (Modifier.isPrivate(method.getModifiers())) {
|
||||||
|
if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE) {
|
||||||
|
try {
|
||||||
|
method.setAccessible(true);
|
||||||
|
method.invoke(this);
|
||||||
|
} catch (InvocationTargetException ex) {
|
||||||
|
throw Throwables.propagate(ex.getCause());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOGGER.error("Error invoking {}", method.getName(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
config.save(configFile);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LOGGER.error("Could not save {}", configFile, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void set(String path, Object val) {
|
private void set(String path, Object val) {
|
||||||
this.config.addDefault("settings.world-settings.default." + path, val);
|
config.addDefault("world-settings.default." + path, val);
|
||||||
this.config.set("settings.world-settings.default." + path, val);
|
config.set("world-settings.default." + path, val);
|
||||||
if (this.config.get("settings.world-settings." + worldName + "." + path) != null) {
|
if (config.get("world-settings." + worldName + "." + path) != null) {
|
||||||
this.config.addDefault("settings.world-settings." + worldName + "." + path, val);
|
config.addDefault("world-settings." + worldName + "." + path, val);
|
||||||
this.config.set("settings.world-settings." + worldName + "." + path, val);
|
config.set("world-settings." + worldName + "." + path, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getString(String path, String def) {
|
private String getString(String path, String def) {
|
||||||
this.config.addDefault("settings.world-settings.default." + path, def);
|
config.addDefault("world-settings.default." + path, def);
|
||||||
return this.config.getString("settings.world-settings." + worldName + "." + path, this.config.getString("settings.world-settings.default." + path));
|
return config.getString("world-settings." + worldName + "." + path, config.getString("world-settings.default." + path));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getBoolean(String path, boolean def) {
|
private boolean getBoolean(String path, boolean def) {
|
||||||
this.config.addDefault("settings.world.default." + path, def);
|
config.addDefault("settings.world.default." + path, def);
|
||||||
return this.config.getBoolean("settings.world-settings." + worldName + "." + path, this.config.getBoolean("settings.world-settings.default." + path));
|
return config.getBoolean("world-settings." + worldName + "." + path, config.getBoolean("world-settings.default." + path));
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getDouble(String path, double def) {
|
private double getDouble(String path, double def) {
|
||||||
this.config.addDefault("settings.world-settings.default." + path, def);
|
config.addDefault("world-settings.default." + path, def);
|
||||||
return this.config.getDouble("settings.world-settings." + worldName + "." + path, this.config.getDouble("settings.world-settings.default." + path));
|
return config.getDouble("world-settings." + worldName + "." + path, config.getDouble("world-settings.default." + path));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getInt(String path, int def) {
|
private int getInt(String path, int def) {
|
||||||
this.config.addDefault("settings.world-settings.default." + path, def);
|
config.addDefault("world-settings.default." + path, def);
|
||||||
return this.config.getInt("settings.world-settings." + worldName + "." + path, this.config.getInt("settings.world-settings.default." + path));
|
return config.getInt("world-settings." + worldName + "." + path, config.getInt("world-settings.default." + path));
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> List<?> getList(String path, T def) {
|
private <T> List<?> getList(String path, T def) {
|
||||||
this.config.addDefault("settings.world-settings.default." + path, def);
|
config.addDefault("world-settings.default." + path, def);
|
||||||
return this.config.getList("settings.world-settings." + worldName + "." + path, this.config.getList("settings.world-settings.default." + path));
|
return config.getList("world-settings." + worldName + "." + path, config.getList("world-settings.default." + path));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> getMap(String path, Map<String, Object> def) {
|
private Map<String, Object> getMap(String path, Map<String, Object> def) {
|
||||||
final Map<String, Object> fallback = this.getMap("settings.world-settings.default." + path, def);
|
final Map<String, Object> fallback = this.getMap("world-settings.default." + path, def);
|
||||||
final Map<String, Object> value = this.getMap("settings.world-settings." + worldName + "." + path, null);
|
final Map<String, Object> value = this.getMap("world-settings." + worldName + "." + path, null);
|
||||||
return value.isEmpty() ? fallback : value;
|
return value.isEmpty() ? fallback : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,11 @@ public final class ReloadCommand extends DivineSubCommandPermission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (ServerLevel level : server.getAllLevels()) {
|
for (ServerLevel level : server.getAllLevels()) {
|
||||||
|
try {
|
||||||
level.divineConfig.init();
|
level.divineConfig.init();
|
||||||
|
} catch (IOException e) {
|
||||||
|
MinecraftServer.LOGGER.error("Failed to reload DivineMC world config for level " + level.dimension().location(), e);
|
||||||
|
}
|
||||||
level.resetBreedingCooldowns();
|
level.resetBreedingCooldowns();
|
||||||
}
|
}
|
||||||
server.server.reloadCount++;
|
server.server.reloadCount++;
|
||||||
|
|||||||
Reference in New Issue
Block a user