This commit is contained in:
parent
80a175e5eb
commit
1876f11fc2
|
|
@ -23,6 +23,10 @@ public final class Config {
|
||||||
.comment("Enable detailed API logging")
|
.comment("Enable detailed API logging")
|
||||||
.define("enableLogging", true);
|
.define("enableLogging", true);
|
||||||
|
|
||||||
|
private static final ModConfigSpec.BooleanValue ENABLE_WHITELIST = BUILDER
|
||||||
|
.comment("Enable/disable whitelist functionality")
|
||||||
|
.define("enableWhitelist", true);
|
||||||
|
|
||||||
static final ModConfigSpec SPEC = BUILDER.build();
|
static final ModConfigSpec SPEC = BUILDER.build();
|
||||||
|
|
||||||
// кэш значений
|
// кэш значений
|
||||||
|
|
@ -30,6 +34,7 @@ public final class Config {
|
||||||
public static String apiKey;
|
public static String apiKey;
|
||||||
public static int requestTimeout;
|
public static int requestTimeout;
|
||||||
public static boolean enableLogging;
|
public static boolean enableLogging;
|
||||||
|
public static boolean enableWhitelist;
|
||||||
|
|
||||||
private Config() {}
|
private Config() {}
|
||||||
|
|
||||||
|
|
@ -41,5 +46,6 @@ public final class Config {
|
||||||
apiKey = API_KEY.get();
|
apiKey = API_KEY.get();
|
||||||
requestTimeout = REQUEST_TIMEOUT.get();
|
requestTimeout = REQUEST_TIMEOUT.get();
|
||||||
enableLogging = ENABLE_LOGGING.get();
|
enableLogging = ENABLE_LOGGING.get();
|
||||||
|
enableWhitelist = ENABLE_WHITELIST.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,12 @@ public class WhitelistCommands {
|
||||||
apiClient = new WhitelistApiClient();
|
apiClient = new WhitelistApiClient();
|
||||||
|
|
||||||
dispatcher.register(Commands.literal("whitelist")
|
dispatcher.register(Commands.literal("whitelist")
|
||||||
|
.then(Commands.literal("on")
|
||||||
|
.executes(WhitelistCommands::enableWhitelist))
|
||||||
|
.then(Commands.literal("off")
|
||||||
|
.executes(WhitelistCommands::disableWhitelist))
|
||||||
|
.then(Commands.literal("status")
|
||||||
|
.executes(WhitelistCommands::whitelistStatus))
|
||||||
.then(Commands.literal("add")
|
.then(Commands.literal("add")
|
||||||
.then(Commands.argument("player", StringArgumentType.string())
|
.then(Commands.argument("player", StringArgumentType.string())
|
||||||
.executes(WhitelistCommands::addPlayer)
|
.executes(WhitelistCommands::addPlayer)
|
||||||
|
|
@ -38,6 +44,31 @@ public class WhitelistCommands {
|
||||||
.executes(WhitelistCommands::countPlayers)));
|
.executes(WhitelistCommands::countPlayers)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isWhitelistEnabled() {
|
||||||
|
return Config.enableWhitelist;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int enableWhitelist(CommandContext<CommandSourceStack> context) {
|
||||||
|
Config.enableWhitelist = true;
|
||||||
|
context.getSource().sendSuccess(() ->
|
||||||
|
Component.literal("Whitelist enabled"), true);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int disableWhitelist(CommandContext<CommandSourceStack> context) {
|
||||||
|
Config.enableWhitelist = false;
|
||||||
|
context.getSource().sendSuccess(() ->
|
||||||
|
Component.literal("Whitelist disabled"), true);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int whitelistStatus(CommandContext<CommandSourceStack> context) {
|
||||||
|
String status = isWhitelistEnabled() ? "enabled" : "disabled";
|
||||||
|
context.getSource().sendSuccess(() ->
|
||||||
|
Component.literal("Whitelist is " + status), true);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
private static int addPlayer(CommandContext<CommandSourceStack> context) {
|
private static int addPlayer(CommandContext<CommandSourceStack> context) {
|
||||||
return addPlayerWithReason(context);
|
return addPlayerWithReason(context);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
{
|
{
|
||||||
"itemGroup.whitelist": "Example Mod Tab",
|
"itemGroup.whitelist": "Whitelist Mod Tab",
|
||||||
"block.whitelist.example_block": "Example Block",
|
"block.whitelist.example_block": "Example Block",
|
||||||
"item.whitelist.example_item": "Example Item"
|
"item.whitelist.example_item": "Example Item",
|
||||||
|
"commands.whitelist.enabled": "Whitelist enabled",
|
||||||
|
"commands.whitelist.disabled": "Whitelist disabled",
|
||||||
|
"commands.whitelist.status": "Whitelist is %s",
|
||||||
|
"commands.whitelist.disabled_message": "Whitelist is disabled. Use '/whitelist on' to enable it."
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"itemGroup.whitelist": "Вкладка мода Whitelist",
|
||||||
|
"block.whitelist.example_block": "Пример блока",
|
||||||
|
"item.whitelist.example_item": "Пример предмета",
|
||||||
|
"commands.whitelist.enabled": "Whitelist включен",
|
||||||
|
"commands.whitelist.disabled": "Whitelist отключен",
|
||||||
|
"commands.whitelist.status": "Whitelist %s",
|
||||||
|
"commands.whitelist.disabled_message": "Whitelist отключен. Используйте '/whitelist on' для включения."
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue