From fabb9b6fd734bd271075941ed99eb460285a4214 Mon Sep 17 00:00:00 2001 From: N0tMyFaultOG Date: Mon, 17 Aug 2020 18:15:29 +0200 Subject: [PATCH] More json stuff --- .../core/command/DatabaseCommand.java | 14 +++++++++----- .../java/com/plotsquared/core/command/Debug.java | 8 ++++++-- .../com/plotsquared/core/command/DebugExec.java | 13 ++++++++----- .../com/plotsquared/core/command/DebugPaste.java | 16 +++++++++++----- .../java/com/plotsquared/core/command/Music.java | 4 ++-- .../core/components/ComponentPresetManager.java | 2 +- Core/src/main/resources/lang/messages_en.json | 15 ++++++++++++--- 7 files changed, 49 insertions(+), 23 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java index 5c146a456..bb874aa6c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/DatabaseCommand.java @@ -177,7 +177,11 @@ public class DatabaseCommand extends SubCommand { continue; } } - player.sendMessage(StaticCaption.of("Skipping duplicate plot: " + plot + " | id=" + plot.temp)); + player.sendMessage( + TranslatableCaption.of("database.skipping_duplicated_plot"), + Template.of("plot", String.valueOf(plot)), + Template.of("id", String.valueOf(plot.temp)) + ); continue; } plot.setArea(pa); @@ -224,17 +228,17 @@ public class DatabaseCommand extends SubCommand { return true; } catch (ClassNotFoundException | SQLException e) { player.sendMessage(TranslatableCaption.of("database.failed_to_save_plots")); - player.sendMessage(StaticCaption.of(("=== Begin of stacktrace. ==="))); + player.sendMessage(TranslatableCaption.of(("errors.stacktrace_begin"))); e.printStackTrace(); - player.sendMessage(StaticCaption.of(("=== End of stacktrace. ==="))); + player.sendMessage(TranslatableCaption.of(("errors.stacktrace_end"))); player.sendMessage(TranslatableCaption.of("database.invalid_args")); return false; } } catch (ClassNotFoundException | SQLException e) { player.sendMessage(TranslatableCaption.of("database.failed_to_open")); - player.sendMessage(StaticCaption.of(("=== Begin of stacktrace. ==="))); + player.sendMessage(TranslatableCaption.of(("errors.stacktrace_begin"))); e.printStackTrace(); - player.sendMessage(StaticCaption.of(("=== End of stacktrace. ==="))); + player.sendMessage(TranslatableCaption.of(("errors.stacktrace_end"))); player.sendMessage(TranslatableCaption.of("database.invalid_args")); return false; } diff --git a/Core/src/main/java/com/plotsquared/core/command/Debug.java b/Core/src/main/java/com/plotsquared/core/command/Debug.java index 27762c7cd..2e2b01678 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Debug.java +++ b/Core/src/main/java/com/plotsquared/core/command/Debug.java @@ -72,6 +72,10 @@ public class Debug extends SubCommand { } @Override public boolean onCommand(PlotPlayer player, String[] args) { + if (args.length == 0 ) { + player.sendMessage(StaticCaption.of("commandconfig.command_syntax"), + Template.of("value", "/plot debug ")); + } if (args.length > 0) { if ("player".equalsIgnoreCase(args[0])) { for (Map.Entry meta : player.getMeta().entrySet()) { @@ -83,7 +87,7 @@ public class Debug extends SubCommand { final long start = System.currentTimeMillis(); player.sendMessage(TranslatableCaption.of("debug.fetching_loaded_chunks")); TaskManager.runTaskAsync(() -> player.sendMessage(StaticCaption - .of("Loaded chunks: " + this.worldUtil.getChunkChunks(player.getLocation().getWorldName()).size() + "(" + (System.currentTimeMillis() + .of("Loaded chunks: " + this.worldUtil.getChunkChunks(player.getLocation().getWorldName()).size() + " (" + (System.currentTimeMillis() - start) + "ms) using thread: " + Thread.currentThread().getName()))); return true; } @@ -117,7 +121,7 @@ public class Debug extends SubCommand { player.sendMessage(TranslatableCaption.of("debug.entity_categories")); EntityCategory.REGISTRY.forEach(category -> { final StringBuilder builder = - new StringBuilder("§7- §6").append(category.getId()).append("§7: §6"); + new StringBuilder(" §7- §6").append(category.getId()).append("§7: §6"); for (final EntityType entityType : category.getAll()) { builder.append(entityType.getId()).append(" "); } diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java index 86bd99a05..9920d3fab 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugExec.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugExec.java @@ -230,7 +230,10 @@ public class DebugExec extends SubCommand { player.sendMessage(TranslatableCaption.of("debugexec.starting_task")); this.hybridUtils.analyzePlot(plot, new RunnableVal() { @Override public void run(PlotAnalysis value) { - player.sendMessage(StaticCaption.of("&6Done: &7Use &6/plot debugexec analyze &7for more information.")); + player.sendMessage( + TranslatableCaption.of("debugexec.analyze_done"), + Template.of("command", "/plot debugexec analyze") + ); } }); return true; @@ -335,7 +338,7 @@ public class DebugExec extends SubCommand { case "he": case "?": case "help": - player.sendMessage(StaticCaption.of("Possible sub commands: /plot debugexec <" + StringMan.join(allowed_params, "|") + ">")); + player.sendMessage(StaticCaption.of("Possible sub commands: /plot debugexec <" + StringMan.join(allowed_params, " | ") + ">")); return false; case "addcmd": try { @@ -422,7 +425,7 @@ public class DebugExec extends SubCommand { message.set(StaticCaption.of(MINI_MESSAGE.serialize(MINI_MESSAGE .parse(TranslatableCaption.of("debugexec.script_list_item").getComponent(player), numTemplate, nameTemplate)))); } - }, "/plot debugexec list-scripts", StaticCaption.of("List of scripts")); + }, "/plot debugexec list-scripts", TranslatableCaption.of("scripts.script_list")); return true; case "all": if (args.length < 3) { @@ -458,12 +461,12 @@ public class DebugExec extends SubCommand { } catch (ScriptException e) { e.printStackTrace(); } - logger.info("[P2] > {}ms -> {}", System.currentTimeMillis() - start, result); + logger.info("[P2] {}ms -> {}", System.currentTimeMillis() - start, result); }); } else { long start = System.currentTimeMillis(); Object result = this.engine.eval(script, this.scope); - logger.info("[P2] > {}ms -> {}", System.currentTimeMillis() - start, result); + logger.info("[P2] {}ms -> {}", System.currentTimeMillis() - start, result); } return true; } catch (ScriptException e) { diff --git a/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java b/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java index c9e70c174..5f3dc7b8d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java +++ b/Core/src/main/java/com/plotsquared/core/command/DebugPaste.java @@ -146,25 +146,30 @@ public class DebugPaste extends SubCommand { final File logFile = new File(PlotSquared.platform().getDirectory(), "../../logs/latest.log"); if (Files.size(logFile.toPath()) > 14_000_000) { - throw new IOException("Too big..."); + throw new IOException("The latest.log is larger than 14MB. Please reboot your server and submit a new paste."); } incendoPaster .addFile(new IncendoPaster.PasteFile("latest.log", readFile(logFile))); } catch (IOException ignored) { - player.sendMessage(StaticCaption.of("&clatest.log is too big to be pasted, please reboot your server and submit a new paste.")); + player.sendMessage( + TranslatableCaption.of("debugpaste.latest_log"), + Template.of("file", "latest.log"), + Template.of("size", "14MB")); } try { incendoPaster.addFile(new IncendoPaster.PasteFile("settings.yml", readFile(this.configFile))); } catch (final IllegalArgumentException ignored) { - player.sendMessage(StaticCaption.of("Skipping settings.yml because it's empty.")); + player.sendMessage(TranslatableCaption.of("debugpaste.empty_file"), + Template.of("file", "settings.yml")); } try { incendoPaster.addFile(new IncendoPaster.PasteFile("worlds.yml", readFile(this.worldfile))); } catch (final IllegalArgumentException ignored) { - player.sendMessage(StaticCaption.of("Skipping worlds.yml because it's empty.")); + player.sendMessage(TranslatableCaption.of("debugpaste.empty_file"), + Template.of("file", "worlds.yml")); } try { @@ -173,7 +178,8 @@ public class DebugPaste extends SubCommand { incendoPaster.addFile(new IncendoPaster.PasteFile("MultiverseCore/worlds.yml", readFile(MultiverseWorlds))); } catch (final IOException ignored) { - player.sendMessage(StaticCaption.of("Skipping Multiverse world's.yml because Multiverse is not in use.")); + player.sendMessage(TranslatableCaption.of("debugpaste.skip_multiverse"), + Template.of("file", "worlds.yml")); } try { diff --git a/Core/src/main/java/com/plotsquared/core/command/Music.java b/Core/src/main/java/com/plotsquared/core/command/Music.java index bd73c2282..ba6bb84ca 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Music.java +++ b/Core/src/main/java/com/plotsquared/core/command/Music.java @@ -57,7 +57,7 @@ public class Music extends SubCommand { private static final Collection DISCS = Arrays .asList("music_disc_13", "music_disc_cat", "music_disc_blocks", "music_disc_chirp", "music_disc_far", "music_disc_mall", "music_disc_mellohi", "music_disc_stal", - "music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait"); + "music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait", "music_disc_pigstep"); private final InventoryUtil inventoryUtil; @@ -124,7 +124,7 @@ public class Music extends SubCommand { // Always add the cancel button // if (player.getMeta("music") != null) { String name = "Cancel music"; - String[] lore = {"Click to cancel!"}; + String[] lore = {"Click to remove the music!"}; inv.setItem(index, new PlotItemStack("bedrock", 1, name, lore)); // } diff --git a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java index d6ee38901..ba4460daa 100644 --- a/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java +++ b/Core/src/main/java/com/plotsquared/core/components/ComponentPresetManager.java @@ -109,7 +109,7 @@ public class ComponentPresetManager { .collect(Collectors.toList()); } else { final List defaultPreset = Collections.singletonList( - new ComponentPreset(ClassicPlotManagerComponent.FLOOR, "##wool", 0, "", "&6D&ai&cs&ec&bo &2F&3l&do&9o&4r", + new ComponentPreset(ClassicPlotManagerComponent.FLOOR, "##wool", 0, "", "Disco Floor", Arrays.asList("Spice up your plot floor"), ItemTypes.YELLOW_WOOL)); yamlConfiguration.set("presets", defaultPreset.stream().map(ComponentPreset::serialize).collect(Collectors.toList())); try { diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index cfbae26d0..83e470293 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -264,6 +264,7 @@ "database.failed_to_save_plots": "Failed to save plots, read stacktrace for info.", "database.invalid_args": "Please make sure you are using the correct arguments.", "database.failed_to_open": "Failed to open connection, read stacktrace for info.", + "database.skipping_duplicated_plot": "Skipping duplicate plot: | ID: ", "template.invalid_template": "Invalid template file: .template", "template.template_failed": "Failed: ", @@ -272,7 +273,7 @@ "debugexec.starting_task": "Starting task...", "debugexec.threshold_default": "`threshold` = The percentage of plots you want to clear (100 clears 100% of plots so no point calibrating it.", "debugexec.invalid_threshold": "Invalid threshold: ", - "debugexec.threshold_default_double": "$1 $2= $1The percentage of plots you want to clear as a number between 0 - 100.", + "debugexec.threshold_default_double": " = The percentage of plots you want to clear as a number between 0 - 100.", "debugexec.calibration_done": "Thank you for calibrating plot expiry.", "debugexec.task_halted": "Task already halted.", "debugexec.cancelling_task": "Task cancelled.", @@ -283,6 +284,7 @@ "debugexec.expiry_started": "Started plot expiry task.", "debugexec.expiry_already_started": "Plot expiry task already started.", "debugexec.script_list_item": "[] ", + "debugexec.analyze_done": "Done. Use for more information. ", "expiry.expired_options_clicky": " expired: >>\n - >>Delete this ()\n - >>Remind later ()\n - >>Keep this ()\n - >>Don't show me this ()", @@ -317,7 +319,12 @@ "error.plot_size": "Error: size <= 0.", "error.command_went_wrong": "Something went wrong when executing that command.", "errors.not_implemented": "Not implemented.", - + "errors.stacktrace_begin": "=== Begin of stacktrace ===", + "errors.stacktrace_end": "=== End of stacktrace ===", + + "debugpaste.latest_log": " is larger than . Please reboot the server and submit a new paste.", + "debugpaste.empty_file": "Skipping because it's empty.", + "debugpaste.skip_multiverse": "Skipping Multiverse because it's not in use.", "debugpaste.debug_report_created": "Uploaded a full debug to: >", "debugpaste.creation_failed": "Failed to create the debugpaste: ", @@ -351,6 +358,8 @@ "need.need_block": "You've got to specify a block.", "near.plot_near": "Players: ", + + "scripts.script_list": "--------- SCRIPTS ---------", "info.none": "None", "info.now": "Now", @@ -521,7 +530,7 @@ "flag.flag_partially_removed": "Successfully removed flag value(s).", "flag.flag_added": "The flag has been added successfully.", "flag.flag_list_see_info": "Click to view information about the flag.", - "flag.flag_parse_error": "Failed to parse flag , value : ", + "flag.flag_parse_error": "Failed to parse flag , value Error: ", "flag.flag_info_header": "--------- PlotSquared Flags ---------", "flag.flag_info_footer": "--------- PlotSquared Flags ---------", "flag.flag_list_categories": ": ",