config update

This commit is contained in:
Flemmli97 2020-09-02 15:36:05 +02:00
parent 0f8c813c71
commit 3c659c8d4a
4 changed files with 15 additions and 10 deletions

View File

@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx2G
loader_version=0.9.1+build.205
# Mod Properties
mod_version = 1.0.2
mod_version = 1.0.3
maven_group = com.flemmli97.flan
archives_base_name = flan

View File

@ -55,16 +55,16 @@ public class CommandClaim {
CommandManager.literal("deleteAll").executes(CommandClaim::deleteAllClaim),
CommandManager.literal("deleteSubClaim").executes(CommandClaim::deleteSubClaim),
CommandManager.literal("deleteAllSubClaims").executes(CommandClaim::deleteAllSubClaim),
CommandManager.literal("list").executes(CommandClaim::listClaims).then(CommandManager.argument("player", GameProfileArgumentType.gameProfile()).requires(src -> src.hasPermissionLevel(2)).executes(cmd->listClaims(cmd, GameProfileArgumentType.getProfileArgument(cmd, "player")))),
CommandManager.literal("list").executes(CommandClaim::listClaims).then(CommandManager.argument("player", GameProfileArgumentType.gameProfile()).requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(cmd->listClaims(cmd, GameProfileArgumentType.getProfileArgument(cmd, "player")))),
CommandManager.literal("switchMode").executes(CommandClaim::switchClaimMode),
CommandManager.literal("adminMode").requires(src -> src.hasPermissionLevel(2)).executes(CommandClaim::switchAdminMode),
CommandManager.literal("readGriefPrevention").requires(src -> src.hasPermissionLevel(2)).executes(CommandClaim::readGriefPreventionData),
CommandManager.literal("setAdminClaim").requires(src -> src.hasPermissionLevel(2)).then(CommandManager.argument("toggle", BoolArgumentType.bool()).executes(CommandClaim::toggleAdminClaim)),
CommandManager.literal("listAdminClaims").requires(src -> src.hasPermissionLevel(2)).executes(CommandClaim::listAdminClaims),
CommandManager.literal("adminDelete").requires(src -> src.hasPermissionLevel(2)).executes(CommandClaim::adminDelete)
CommandManager.literal("adminMode").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::switchAdminMode),
CommandManager.literal("readGriefPrevention").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::readGriefPreventionData),
CommandManager.literal("setAdminClaim").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).then(CommandManager.argument("toggle", BoolArgumentType.bool()).executes(CommandClaim::toggleAdminClaim)),
CommandManager.literal("listAdminClaims").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::listAdminClaims),
CommandManager.literal("adminDelete").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).executes(CommandClaim::adminDelete)
.then(CommandManager.literal("all").then(CommandManager.argument("players", GameProfileArgumentType.gameProfile())
.executes(CommandClaim::adminDeleteAll))),
CommandManager.literal("giveClaimBlocks").requires(src -> src.hasPermissionLevel(2)).then(CommandManager.argument("players", GameProfileArgumentType.gameProfile())
CommandManager.literal("giveClaimBlocks").requires(src -> src.hasPermissionLevel(ConfigHandler.config.permissionLevel)).then(CommandManager.argument("players", GameProfileArgumentType.gameProfile())
.then(CommandManager.argument("amount", IntegerArgumentType.integer()).executes(CommandClaim::giveClaimBlocks))),
addToMainCommand(CommandManager.literal("group"),
CommandManager.literal("add").then(CommandManager.argument("group", StringArgumentType.word()).executes(CommandClaim::addGroup)),
@ -220,7 +220,6 @@ public class CommandClaim {
}
private static int listClaims(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
ServerPlayerEntity player = context.getSource().getPlayer();
return listClaimsFromUUID(context, null);
}

View File

@ -31,6 +31,7 @@ public class Config {
public Item inspectionItem = Items.STICK;
public int claimDisplayTime = 1000;
public int permissionLevel = 2;
public Config(MinecraftServer server) {
File configDir = server.getSavePath(WorldSavePath.ROOT).resolve("config/claimConfigs").toFile();
@ -65,9 +66,12 @@ public class Config {
this.claimingItem = Registry.ITEM.get(new Identifier((obj.get("claimingItem").getAsString())));
this.inspectionItem = Registry.ITEM.get(new Identifier((obj.get("inspectionItem").getAsString())));
this.claimDisplayTime = obj.get("claimDisplayTime").getAsInt();
if(obj.has("permissionLevel"))
this.permissionLevel = obj.get("permissionLevel").getAsInt();
} catch (IOException e) {
e.printStackTrace();
}
this.save();
}
private void save() {
@ -83,6 +87,7 @@ public class Config {
obj.addProperty("claimingItem", Registry.ITEM.getId(this.claimingItem).toString());
obj.addProperty("inspectionItem", Registry.ITEM.getId(this.inspectionItem).toString());
obj.addProperty("claimDisplayTime", this.claimDisplayTime);
obj.addProperty("permissionLevel", this.permissionLevel);
try {
FileWriter writer = new FileWriter(this.config);
ConfigHandler.GSON.toJson(obj, writer);

View File

@ -91,13 +91,14 @@ public class LangConfig {
JsonObject obj = ConfigHandler.GSON.fromJson(reader, JsonObject.class);
reader.close();
for (Field field : this.getClass().getDeclaredFields()) {
if (field.getDeclaringClass().equals(String.class)) {
if (field.getDeclaringClass().equals(String.class) && obj.has(field.getName())) {
field.set(this, obj.get(field.getName()).getAsString());
}
}
} catch (IOException | IllegalAccessException e) {
e.printStackTrace();
}
this.save();
}
private void save() {