Skip to content

Commit 6711155

Browse files
committed
feature/4: Added command permission level configs
1 parent 55d24e1 commit 6711155

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

src/main/java/com/blukzen/createlab/CreateLabConfig.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ public class CreateLabConfig {
99
public static final ForgeConfigSpec COMMON_SPEC;
1010

1111
public static ForgeConfigSpec.ConfigValue<List<? extends String>> labPortalFrameBlocks;
12+
public static ForgeConfigSpec.IntValue tpCommandPermissionLevel;
13+
public static ForgeConfigSpec.IntValue debugCommandPermissionLevel;
14+
public static ForgeConfigSpec.IntValue saveCommandPermissionLevel;
1215

1316
static {
1417
ForgeConfigSpec.Builder configBuilder = new ForgeConfigSpec.Builder();
@@ -18,5 +21,17 @@ public class CreateLabConfig {
1821

1922
private static void setupConfig(ForgeConfigSpec.Builder builder) {
2023
labPortalFrameBlocks = builder.comment("Blocks that can be used as a lab portal frame").defineList("lab_portal_frame_blocks", Arrays.asList("minecraft:smooth_quartz", "minecraft:quartz_block"), entry -> true);
24+
25+
builder.push("Command Permission Levels");
26+
{
27+
builder.comment("0 = All, 1 = OPs, 3 = Disabled");
28+
tpCommandPermissionLevel = builder.defineInRange("tp_permission_level", 0, 0, 2);
29+
debugCommandPermissionLevel = builder.defineInRange("debug_permission_level", 0, 0, 2);
30+
saveCommandPermissionLevel = builder.defineInRange("save_permission_level", 0, 0, 2);
31+
}
32+
builder.pop();
33+
34+
35+
2136
}
2237
}

src/main/java/com/blukzen/createlab/commands/CommandDebug.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.blukzen.createlab.commands;
22

3+
import com.blukzen.createlab.CreateLabConfig;
34
import com.blukzen.createlab.util.GUIUtil;
45
import com.mojang.brigadier.Command;
56
import com.mojang.brigadier.CommandDispatcher;
@@ -24,7 +25,7 @@ public class CommandDebug implements Command<CommandSource>, SuggestionProvider<
2425

2526
public static ArgumentBuilder<CommandSource, ?> register(CommandDispatcher<CommandSource> dispatcher) {
2627
return Commands.literal("debug")
27-
.requires(cs -> cs.hasPermission(0))
28+
.requires(cs -> cs.hasPermission(CreateLabConfig.debugCommandPermissionLevel.get()))
2829
.executes(CMD)
2930
.then(
3031
RequiredArgumentBuilder.<CommandSource, String>argument("args", StringArgumentType.greedyString())

src/main/java/com/blukzen/createlab/commands/CommandSaveInventory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.blukzen.createlab.commands;
22

3+
import com.blukzen.createlab.CreateLabConfig;
34
import com.blukzen.createlab.data.LaboratoryCapability;
45
import com.mojang.brigadier.Command;
56
import com.mojang.brigadier.CommandDispatcher;
@@ -15,7 +16,7 @@ public class CommandSaveInventory implements Command<CommandSource> {
1516

1617
public static ArgumentBuilder<CommandSource, ?> register(CommandDispatcher<CommandSource> dispatcher) {
1718
return Commands.literal("save")
18-
.requires(cs -> cs.hasPermission(0))
19+
.requires(cs -> cs.hasPermission(CreateLabConfig.saveCommandPermissionLevel.get()))
1920
.executes(CMD);
2021
}
2122

src/main/java/com/blukzen/createlab/commands/CommandTeleport.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.blukzen.createlab.commands;
22

3+
import com.blukzen.createlab.CreateLabConfig;
34
import com.blukzen.createlab.data.LaboratoryCapability;
45
import com.blukzen.createlab.dimension.LabDimensions;
56
import com.blukzen.createlab.util.TeleportationTools;
@@ -22,7 +23,7 @@ public class CommandTeleport implements Command<CommandSource> {
2223

2324
public static ArgumentBuilder<CommandSource, ?> register(CommandDispatcher<CommandSource> dispatcher) {
2425
return Commands.literal("tp")
25-
.requires(cs -> cs.hasPermission(0))
26+
.requires(cs -> cs.hasPermission(CreateLabConfig.tpCommandPermissionLevel.get()))
2627
.executes(CMD);
2728
}
2829

0 commit comments

Comments
 (0)