Skip to content

Commit 1524cba

Browse files
authored
Merge pull request #103 from CoderFrish/ver/1.21.8
Split Config File.
2 parents 1deb036 + e6d800b commit 1524cba

7 files changed

Lines changed: 77 additions & 45 deletions

File tree

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cd Traium
2020
./gradlew applyAllPatches && ./gradlew createMojmapPaperclipJar
2121
```
2222

23-
## 2 | Development API
23+
## 2 | Plugin API
2424

2525
Maven
2626

@@ -34,11 +34,20 @@ Maven
3434
</dependencies>
3535
```
3636

37-
## 3 | Bstats
37+
## 3 | 配置文件
38+
39+
服务端的配置文件位于根目录的traium_config里面
40+
```
41+
traium_config
42+
├─ traium_global.toml
43+
└─ traium_world.toml
44+
```
45+
46+
## 4 | Bstats
3847

3948
[![bStats](https://bstats.org/signatures/server-implementation/Traium.svg)](https://bstats.org/plugin/server-implementation/Traium/)
4049

41-
## 4 | 最后
50+
## 5 | 最后
4251
> [!TIP]
4352
> 你的每一个免费的 ⭐Star 就是我们每一个前进的动力!
4453

traium-server/minecraft-patches/features/0002-Purpur-Barrels-and-enderchests-six-rows.patch

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Subject: [PATCH] Purpur Barrels and enderchests six rows.
55

66

77
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
8-
index 976a8982a0b0a9ae459cf08e13d69031d4238eca..d590baf0414653fd970b62f4735a6465417deb76 100644
8+
index 976a8982a0b0a9ae459cf08e13d69031d4238eca..c208ad9a5c49fcd92f5c1d05f119e155745d55d2 100644
99
--- a/net/minecraft/server/players/PlayerList.java
1010
+++ b/net/minecraft/server/players/PlayerList.java
1111
@@ -1071,6 +1071,27 @@ public abstract class PlayerList {
@@ -14,7 +14,7 @@ index 976a8982a0b0a9ae459cf08e13d69031d4238eca..d590baf0414653fd970b62f4735a6465
1414
} // Paper - Add sendOpLevel API
1515
+
1616
+ // Traium start - Purpur Barrels and enderchests 6 rows
17-
+ if (me.coderfrish.traium.config.GlobalConfig.enableEnderChestSixRows && me.coderfrish.traium.config.GlobalConfig.enderChestPermissionRows) {
17+
+ if (me.coderfrish.traium.config.WorldConfig.enableEnderChestSixRows && me.coderfrish.traium.config.WorldConfig.enderChestPermissionRows) {
1818
+ org.bukkit.craftbukkit.entity.CraftHumanEntity bukkit = player.getBukkitEntity();
1919
+ if (bukkit.hasPermission("traium.enderchest.rows.six")) {
2020
+ player.sixRowEnderchestSlotCount = 54;
@@ -85,15 +85,15 @@ index 0fffa384f928ab84451331380968fb4650eafe26..ea2fd33356458d52c7a6de38144601f6
8585
public ChestMenu(MenuType<?> type, int containerId, Inventory playerInventory, Container container, int rows) {
8686
super(type, containerId);
8787
diff --git a/net/minecraft/world/inventory/PlayerEnderChestContainer.java b/net/minecraft/world/inventory/PlayerEnderChestContainer.java
88-
index 51148b7b95c93a9e25da70ac9275c63f1458d84c..f99ae15656dc20af88f644f8f217d4f15912794e 100644
88+
index 51148b7b95c93a9e25da70ac9275c63f1458d84c..d4bbc0ba205b585a5cc36d3ea216a7adf6a1e5ef 100644
8989
--- a/net/minecraft/world/inventory/PlayerEnderChestContainer.java
9090
+++ b/net/minecraft/world/inventory/PlayerEnderChestContainer.java
9191
@@ -26,11 +26,18 @@ public class PlayerEnderChestContainer extends SimpleContainer {
9292
}
9393

9494
public PlayerEnderChestContainer(Player owner) {
9595
- super(27);
96-
+ super(me.coderfrish.traium.config.GlobalConfig.enableEnderChestSixRows ? 54 : 27); // Traium - Purpur Barrels and enderchests 6 rows
96+
+ super(me.coderfrish.traium.config.WorldConfig.enableEnderChestSixRows ? 54 : 27); // Traium - Purpur Barrels and enderchests 6 rows
9797
this.owner = owner;
9898
// CraftBukkit end
9999
}
@@ -109,7 +109,7 @@ index 51148b7b95c93a9e25da70ac9275c63f1458d84c..f99ae15656dc20af88f644f8f217d4f1
109109
this.activeChest = enderChestBlockEntity;
110110
}
111111
diff --git a/net/minecraft/world/level/block/EnderChestBlock.java b/net/minecraft/world/level/block/EnderChestBlock.java
112-
index 5077a9ff7b78801bdc53536a37aee07b8d86ee4d..811fafa9011a98a4b7d4afe3833cf7804846c626 100644
112+
index 5077a9ff7b78801bdc53536a37aee07b8d86ee4d..9f0a4f9c21a2db3704d0dce6a5368eaab8672822 100644
113113
--- a/net/minecraft/world/level/block/EnderChestBlock.java
114114
+++ b/net/minecraft/world/level/block/EnderChestBlock.java
115115
@@ -85,8 +85,8 @@ public class EnderChestBlock extends AbstractChestBlock<EnderChestBlockEntity> i
@@ -118,7 +118,7 @@ index 5077a9ff7b78801bdc53536a37aee07b8d86ee4d..811fafa9011a98a4b7d4afe3833cf780
118118
new SimpleMenuProvider(
119119
- (containerId, playerInventory, player1) -> ChestMenu.threeRows(containerId, playerInventory, enderChestInventory), CONTAINER_TITLE
120120
- )
121-
+ (containerId, playerInventory, player1) -> me.coderfrish.traium.config.GlobalConfig.enableEnderChestSixRows ? getEnderChestSixRows(containerId, playerInventory, player, enderChestInventory) : ChestMenu.threeRows(containerId, playerInventory, enderChestInventory), CONTAINER_TITLE
121+
+ (containerId, playerInventory, player1) -> me.coderfrish.traium.config.WorldConfig.enableEnderChestSixRows ? getEnderChestSixRows(containerId, playerInventory, player, enderChestInventory) : ChestMenu.threeRows(containerId, playerInventory, enderChestInventory), CONTAINER_TITLE
122122
+ ) // Traium - Purpur Barrels and enderchests 6 rows
123123
).isPresent()) {
124124
// Paper end - Fix InventoryOpenEvent cancellation - moved up;
@@ -129,7 +129,7 @@ index 5077a9ff7b78801bdc53536a37aee07b8d86ee4d..811fafa9011a98a4b7d4afe3833cf780
129129

130130
+ // Traium start - Purupr Barrels and enderchests 6 rows
131131
+ private ChestMenu getEnderChestSixRows(int syncId, net.minecraft.world.entity.player.Inventory inventory, Player player, PlayerEnderChestContainer playerEnderChestContainer) {
132-
+ if (me.coderfrish.traium.config.GlobalConfig.enderChestPermissionRows) {
132+
+ if (me.coderfrish.traium.config.WorldConfig.enderChestPermissionRows) {
133133
+ org.bukkit.craftbukkit.entity.CraftHumanEntity bukkitPlayer = player.getBukkitEntity();
134134
+ if (bukkitPlayer.hasPermission("traium.enderchest.rows.six")) {
135135
+ player.sixRowEnderchestSlotCount = 54;
@@ -160,15 +160,15 @@ index 5077a9ff7b78801bdc53536a37aee07b8d86ee4d..811fafa9011a98a4b7d4afe3833cf780
160160
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
161161
return new EnderChestBlockEntity(pos, state);
162162
diff --git a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
163-
index d679ab599dfd0bdbdc3ab5530d7fcd1c38baf7fa..561195318bb36d531a3946c20da62b655e8e35b4 100644
163+
index d679ab599dfd0bdbdc3ab5530d7fcd1c38baf7fa..f01aad8115ff51647f294a5f9ac777a9a7cd7748 100644
164164
--- a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
165165
+++ b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
166166
@@ -56,7 +56,15 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
167167
}
168168
// CraftBukkit end
169169

170170
- private NonNullList<ItemStack> items = NonNullList.withSize(27, ItemStack.EMPTY);
171-
+ private NonNullList<ItemStack> items = NonNullList.withSize(switch (me.coderfrish.traium.config.GlobalConfig.barrelRows) {
171+
+ private NonNullList<ItemStack> items = NonNullList.withSize(switch (me.coderfrish.traium.config.WorldConfig.barrelRows) {
172172
+ case 6 -> 54;
173173
+ case 5 -> 45;
174174
+ case 4 -> 36;
@@ -185,7 +185,7 @@ index d679ab599dfd0bdbdc3ab5530d7fcd1c38baf7fa..561195318bb36d531a3946c20da62b65
185185
@Override
186186
public int getContainerSize() {
187187
- return 27;
188-
+ return switch (me.coderfrish.traium.config.GlobalConfig.barrelRows) {
188+
+ return switch (me.coderfrish.traium.config.WorldConfig.barrelRows) {
189189
+ case 6 -> 54;
190190
+ case 5 -> 45;
191191
+ case 4 -> 36;
@@ -203,7 +203,7 @@ index d679ab599dfd0bdbdc3ab5530d7fcd1c38baf7fa..561195318bb36d531a3946c20da62b65
203203
protected AbstractContainerMenu createMenu(int id, Inventory player) {
204204
- return ChestMenu.threeRows(id, player, this);
205205
+ // Traium start - Purpur Barrels and enderchests 6 rows
206-
+ return switch (me.coderfrish.traium.config.GlobalConfig.barrelRows) {
206+
+ return switch (me.coderfrish.traium.config.WorldConfig.barrelRows) {
207207
+ case 6 -> ChestMenu.sixRows(id, player, this);
208208
+ case 5 -> ChestMenu.fiveRows(id, player, this);
209209
+ case 4 -> ChestMenu.fourRows(id, player, this);

traium-server/minecraft-patches/features/0003-Luminol-Unsafe-Teleportation-Config.patch

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,45 @@ Subject: [PATCH] Luminol Unsafe Teleportation Config.
55

66

77
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
8-
index 34e31fa13e5107f13e166f694fafe58e306330ae..6fa6c8c57377fea28acce60c26d455b7560687f7 100644
8+
index 34e31fa13e5107f13e166f694fafe58e306330ae..f1ffd6688d7558e93d650184fd9fad09c79a1c21 100644
99
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
1010
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
11-
@@ -70,7 +70,7 @@ public class FallingBlockEntity extends Entity {
11+
@@ -3,6 +3,8 @@ package net.minecraft.world.entity.item;
12+
import com.mojang.logging.LogUtils;
13+
import java.util.function.Predicate;
14+
import javax.annotation.Nullable;
15+
+
16+
+import me.coderfrish.traium.config.WorldConfig;
17+
import net.minecraft.CrashReportCategory;
18+
import net.minecraft.core.BlockPos;
19+
import net.minecraft.core.Direction;
20+
@@ -70,7 +72,7 @@ public class FallingBlockEntity extends Entity {
1221
public float fallDamagePerDistance = 0.0F;
1322
@Nullable
1423
public CompoundTag blockData;
1524
- public boolean forceTickAfterTeleportToDuplicate;
16-
+ public boolean forceTickAfterTeleportToDuplicate = me.coderfrish.traium.config.GlobalConfig.enableUnsafeTeleportation;
25+
+ public boolean forceTickAfterTeleportToDuplicate = WorldConfig.enableUnsafeTeleportation;
1726
protected static final EntityDataAccessor<BlockPos> DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS);
1827
public boolean autoExpire = true; // Paper - Expand FallingBlock API
1928

20-
@@ -387,7 +387,7 @@ public class FallingBlockEntity extends Entity {
29+
@@ -387,7 +389,7 @@ public class FallingBlockEntity extends Entity {
2130
ResourceKey<Level> resourceKey1 = this.level().dimension();
2231
boolean flag = (resourceKey1 == Level.END || resourceKey == Level.END) && resourceKey1 != resourceKey;
2332
Entity entity = super.teleport(teleportTransition);
2433
- this.forceTickAfterTeleportToDuplicate = entity != null && flag && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation; // Paper
25-
+ this.forceTickAfterTeleportToDuplicate = entity != null && flag && (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation || me.coderfrish.traium.config.GlobalConfig.enableUnsafeTeleportation); // Paper
34+
+ this.forceTickAfterTeleportToDuplicate = entity != null && flag && (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation || WorldConfig.enableUnsafeTeleportation); // Paper
2635
return entity;
2736
}
2837
}
2938
diff --git a/net/minecraft/world/level/block/EndPortalBlock.java b/net/minecraft/world/level/block/EndPortalBlock.java
30-
index 6e495b2c4176d5a30ea911f8e44a22655df92ef6..af1075ec3283d95ea2c20f7dab1d25ade474db51 100644
39+
index 6e495b2c4176d5a30ea911f8e44a22655df92ef6..832838877f20b2c6ac114dc5928c229d3568a564 100644
3140
--- a/net/minecraft/world/level/block/EndPortalBlock.java
3241
+++ b/net/minecraft/world/level/block/EndPortalBlock.java
3342
@@ -69,6 +69,9 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal {
3443
if (level.paperConfig().misc.disableEndCredits) {serverPlayer.seenCredits = true; return;} // Paper - Option to disable end credits
3544
serverPlayer.showEndCredits();
3645
} else {
37-
+ if (me.coderfrish.traium.config.GlobalConfig.enableUnsafeTeleportation && !(entity instanceof net.minecraft.world.entity.player.Player)) {
46+
+ if (me.coderfrish.traium.config.WorldConfig.enableUnsafeTeleportation && !(entity instanceof net.minecraft.world.entity.player.Player)) {
3847
+ entity.endPortalLogicAsync(pos);
3948
+ }
4049
entity.setAsInsidePortal(this, pos);

traium-server/paper-patches/features/0002-Purpur-Barrels-and-enderchests-six-rows.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ Subject: [PATCH] Purpur Barrels and enderchests six rows.
55

66

77
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
8-
index 2f41a92465b9da28e026297cc3528898bb1c8412..a99c3ef198c426c7142c862172c8fc0a4dee5a1d 100644
8+
index 2f41a92465b9da28e026297cc3528898bb1c8412..59623457cc68d462698ee58561fa81de98a9ad86 100644
99
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
1010
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftContainer.java
1111
@@ -148,8 +148,18 @@ public class CraftContainer extends AbstractContainerMenu {
1212
case PLAYER:
1313
case CHEST:
1414
case ENDER_CHEST:
1515
+ // Traium - Purpur Barrels and enderchests 6 rows
16-
+ this.delegate = new ChestMenu(me.coderfrish.traium.config.GlobalConfig.enableEnderChestSixRows ? net.minecraft.world.inventory.MenuType.GENERIC_9x6 : net.minecraft.world.inventory.MenuType.GENERIC_9x3, windowId, bottom, top, top.getContainerSize() / 9);
16+
+ this.delegate = new ChestMenu(me.coderfrish.traium.config.WorldConfig.enableEnderChestSixRows ? net.minecraft.world.inventory.MenuType.GENERIC_9x6 : net.minecraft.world.inventory.MenuType.GENERIC_9x3, windowId, bottom, top, top.getContainerSize() / 9);
1717
+ break;
1818
case BARREL:
1919
- this.delegate = new ChestMenu(net.minecraft.world.inventory.MenuType.GENERIC_9x3, windowId, bottom, top, top.getContainerSize() / 9);
20-
+ this.delegate = new ChestMenu(switch (me.coderfrish.traium.config.GlobalConfig.barrelRows) {
20+
+ this.delegate = new ChestMenu(switch (me.coderfrish.traium.config.WorldConfig.barrelRows) {
2121
+ case 6 -> net.minecraft.world.inventory.MenuType.GENERIC_9x6;
2222
+ case 5 -> net.minecraft.world.inventory.MenuType.GENERIC_9x5;
2323
+ case 4 -> net.minecraft.world.inventory.MenuType.GENERIC_9x4;

traium-server/src/main/java/me/coderfrish/traium/config/GlobalConfig.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,8 @@ public GlobalConfig() {
3131
})
3232
public static String language = "en_us";
3333

34-
@ConfigField(name = "enabled", type = ConfigTypes.fixed, parent = "unsafe_teleportation", comments = {
35-
"If you want to use sand duping,please turn on this.",
36-
"Warning: This would cause some unsafe issues, you could learn more on : https://github.com/PaperMC/Folia/issues/297."
37-
})
38-
public static boolean enableUnsafeTeleportation = true;
39-
4034
@ConfigField(type = ConfigTypes.misc, parent = "server_brand_name", comments = {
4135
"Server brand name displayed to clients."
4236
}, name = "value")
4337
public static String serverBrandName = "Traium";
44-
45-
@ConfigField(type = ConfigTypes.misc, parent = "ender_chest_six_rows", comments = {
46-
"The amount of rows a barrel should have. Min: 1, Max: 6"
47-
}, name = "barrel_rows")
48-
public static int barrelRows = 3;
49-
50-
@ConfigField(name = "enabled", type = ConfigTypes.misc, parent = "ender_chest_six_rows", comments = {
51-
"When enabled, ender chests should have six rows of inventory space."
52-
})
53-
public static boolean enableEnderChestSixRows = false;
54-
55-
@ConfigField(type = ConfigTypes.misc, parent = "ender_chest_six_rows", comments = {
56-
"Use permission nodes to determine the number of rows. By default, with this setting enabled, all players have rows unless otherwise specified using permissions"
57-
}, name = "ender_chest_permission_rows")
58-
public static boolean enderChestPermissionRows = false;
5938
}

traium-server/src/main/java/me/coderfrish/traium/config/TraiumConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public static void setupTraium() {
4646

4747
public static void loadAllConfig() throws Exception {
4848
globalConfig = new GlobalConfig();
49+
new WorldConfig();
4950
}
5051

5152
public CommentedFileConfig getCurrentConfig() {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package me.coderfrish.traium.config;
2+
3+
import java.io.File;
4+
5+
import static me.coderfrish.traium.utils.Constants.CONFIG_FOLDER;
6+
7+
public class WorldConfig extends TraiumConfig{
8+
private static final File CONFIG_WORLD_FILE = new File(CONFIG_FOLDER, "traium_world.toml");
9+
10+
public WorldConfig() {
11+
super(CONFIG_WORLD_FILE);
12+
}
13+
14+
@ConfigField(name = "enabled", type = ConfigTypes.fixed, parent = "unsafe_teleportation", comments = {
15+
"If you want to use sand duping,please turn on this.",
16+
"Warning: This would cause some unsafe issues, you could learn more on : https://github.com/PaperMC/Folia/issues/297."
17+
})
18+
public static boolean enableUnsafeTeleportation = false;
19+
20+
@ConfigField(type = ConfigTypes.misc, parent = "ender_chest_six_rows", comments = {
21+
"The amount of rows a barrel should have. Min: 1, Max: 6"
22+
}, name = "barrel_rows")
23+
public static int barrelRows = 3;
24+
25+
@ConfigField(name = "enabled", type = ConfigTypes.misc, parent = "ender_chest_six_rows", comments = {
26+
"When enabled, ender chests should have six rows of inventory space."
27+
})
28+
public static boolean enableEnderChestSixRows = false;
29+
30+
@ConfigField(type = ConfigTypes.misc, parent = "ender_chest_six_rows", comments = {
31+
"Use permission nodes to determine the number of rows. By default, with this setting enabled, all players have rows unless otherwise specified using permissions"
32+
}, name = "ender_chest_permission_rows")
33+
public static boolean enderChestPermissionRows = false;
34+
}

0 commit comments

Comments
 (0)