From efee056fd54ccd8939413b4f9f3e4f41e1b59db4 Mon Sep 17 00:00:00 2001 From: Flemmli97 Date: Wed, 9 Jun 2021 14:31:15 +0200 Subject: [PATCH] readGriefprevention log --- Changelog.txt | 2 ++ .../io/github/flemmli97/flan/claim/ClaimStorage.java | 9 ++++++--- .../io/github/flemmli97/flan/commands/CommandClaim.java | 7 ++++--- .../io/github/flemmli97/flan/config/LangCommands.java | 4 ++-- .../java/io/github/flemmli97/flan/config/LangConfig.java | 4 +++- .../io/github/flemmli97/flan/player/PlayerClaimData.java | 9 ++++++--- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 6b3f149..753719b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,8 @@ Flan 1.4.1 Basically now a worldguard version - Add locking items when the player dies so other players cant pick it up. Use /flan unlockItems to allow it. +- /flan help finished: command are clickable now and give additional info on the commands +- Log the file path when /flan readGriefPrevention can't find the files Flan 1.4.0 ====================== diff --git a/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java b/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java index bc9f104..626d737 100644 --- a/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java +++ b/src/main/java/io/github/flemmli97/flan/claim/ClaimStorage.java @@ -316,11 +316,13 @@ public class ClaimStorage { } } - public static void readGriefPreventionData(MinecraftServer server, ServerCommandSource src) { + public static boolean readGriefPreventionData(MinecraftServer server, ServerCommandSource src) { Yaml yml = new Yaml(); File griefPrevention = server.getSavePath(WorldSavePath.ROOT).resolve("plugins/GriefPreventionData/ClaimData").toFile(); - if (!griefPrevention.exists()) - return; + if (!griefPrevention.exists()) { + src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.cantFindData, griefPrevention.getAbsolutePath()), Formatting.DARK_RED), false); + return false; + } Map> subClaimMap = new HashMap<>(); Map intFileMap = new HashMap<>(); @@ -401,6 +403,7 @@ public class ClaimStorage { } catch (IOException e) { e.printStackTrace(); } + return true; } private static Set complementOf(ClaimPermission... perms) { diff --git a/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java b/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java index 0dfb9af..8a6d851 100644 --- a/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java +++ b/src/main/java/io/github/flemmli97/flan/commands/CommandClaim.java @@ -436,9 +436,10 @@ public class CommandClaim { private static int readGriefPreventionData(CommandContext context) { ServerCommandSource src = context.getSource(); src.sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.readGriefpreventionData, Formatting.GOLD), true); - ClaimStorage.readGriefPreventionData(src.getMinecraftServer(), src); - PlayerClaimData.readGriefPreventionPlayerData(src.getMinecraftServer(), src); - src.sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.readGriefpreventionDataSuccess, Formatting.GOLD), true); + if (ClaimStorage.readGriefPreventionData(src.getMinecraftServer(), src)) + src.sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.readGriefpreventionClaimDataSuccess, Formatting.GOLD), true); + if (PlayerClaimData.readGriefPreventionPlayerData(src.getMinecraftServer(), src)) + src.sendFeedback(PermHelper.simpleColoredText(ConfigHandler.lang.readGriefpreventionPlayerDataSuccess, Formatting.GOLD), true); return Command.SINGLE_SUCCESS; } diff --git a/src/main/java/io/github/flemmli97/flan/config/LangCommands.java b/src/main/java/io/github/flemmli97/flan/config/LangCommands.java index b7d568a..43a9ebd 100644 --- a/src/main/java/io/github/flemmli97/flan/config/LangCommands.java +++ b/src/main/java/io/github/flemmli97/flan/config/LangCommands.java @@ -15,9 +15,9 @@ public class LangCommands { map.put("deleteAll", new String[]{"deleteAll", "Deletes all your claims (you need to double type to confirm it so no accidents)."}); map.put("deleteSubClaim", new String[]{"deleteSubClaim", "Deletes the current subclaim."}); map.put("deleteAllSubClaims", new String[]{"deleteAllSubClaims", "Deletes all subclaim of the current claim."}); - map.put("list", new String[]{"list", "Lists all claims you have. if op also gives ability to list other players claims."}); + map.put("list", new String[]{"list", "Lists all claims you have. If op also gives ability to list other players claims."}); map.put("switchMode", new String[]{"switchMode", "Switch between normal and subclaim mode."}); - map.put("group", new String[]{"group (add | remove ) | (players add | remove [overwrite])", "Adds/removes the group with that name. Also editable via the claim menu.", " adds/remove a player to the group. if overwrite then will overwrite the players current group else does nothing. Also editable via the claim menu."}); + map.put("group", new String[]{"group (add | remove ) | (players add | remove [overwrite])", "- Adds/removes the group with that name. Also editable via the claim menu.", "- Adds/remove a player to the group. If overwrite then will overwrite the players current group else does nothing. Also editable via the claim menu."}); map.put("transferClaim", new String[]{"transferClaim ", "Gives ownership of the claim to the specified player. Only works if you're the claim owner."}); map.put("addClaim", new String[]{"addClaim ", "Creates a claim with the given positions. Same as using the claim tool."}); map.put("permission", new String[]{"permission {global | (group ) | (personal )} true | false | default", " Sets global/group/personal permissions. Also editable via the claim menu (for group perm right click on the group in the menu)."}); diff --git a/src/main/java/io/github/flemmli97/flan/config/LangConfig.java b/src/main/java/io/github/flemmli97/flan/config/LangConfig.java index ab8e33f..f2b836d 100644 --- a/src/main/java/io/github/flemmli97/flan/config/LangConfig.java +++ b/src/main/java/io/github/flemmli97/flan/config/LangConfig.java @@ -71,7 +71,9 @@ public class LangConfig { public String adminDeleteAll = "Deleted all claims for following players: %s"; public String setAdminClaim = "Adminclaim of this claim now: %s"; public String readGriefpreventionData = "Reading data from GriefPrevention"; - public String readGriefpreventionDataSuccess = "Successfully read data"; + public String readGriefpreventionClaimDataSuccess = "Successfully read claim data"; + public String readGriefpreventionPlayerDataSuccess = "Successfully read player data"; + public String cantFindData = "No griefprevention data at %s"; public String errorFile = "Error reading file %s"; public String readConflict = "%1$s conflicts with existing claims. Not added to world! Conflicts:"; public String giveClaimBlocks = "Gave following players %2$d claimblocks: %1$s"; diff --git a/src/main/java/io/github/flemmli97/flan/player/PlayerClaimData.java b/src/main/java/io/github/flemmli97/flan/player/PlayerClaimData.java index 2fd2241..09d5c51 100644 --- a/src/main/java/io/github/flemmli97/flan/player/PlayerClaimData.java +++ b/src/main/java/io/github/flemmli97/flan/player/PlayerClaimData.java @@ -377,11 +377,13 @@ public class PlayerClaimData { return usedClaimsBlocks; } - public static void readGriefPreventionPlayerData(MinecraftServer server, ServerCommandSource src) { + public static boolean readGriefPreventionPlayerData(MinecraftServer server, ServerCommandSource src) { Flan.log("Reading grief prevention data"); File griefPrevention = server.getSavePath(WorldSavePath.ROOT).resolve("plugins/GriefPreventionData/PlayerData").toFile(); - if (!griefPrevention.exists()) - return; + if (!griefPrevention.exists()) { + src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.cantFindData, griefPrevention.getAbsolutePath()), Formatting.DARK_RED), false); + return false; + } for (File f : griefPrevention.listFiles()) { try { if (f.getName().contains(".")) @@ -417,5 +419,6 @@ public class PlayerClaimData { src.sendFeedback(PermHelper.simpleColoredText(String.format(ConfigHandler.lang.errorFile, f.getName(), Formatting.RED)), false); } } + return true; } } \ No newline at end of file