More json stuff

This commit is contained in:
N0tMyFaultOG 2020-08-17 18:15:29 +02:00
parent 47d9895077
commit fabb9b6fd7
7 changed files with 49 additions and 23 deletions

View File

@ -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;
}

View File

@ -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 <loadedchunks | debug-players | logging | entitytypes | msg>"));
}
if (args.length > 0) {
if ("player".equalsIgnoreCase(args[0])) {
for (Map.Entry<String, Object> 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(" ");
}

View File

@ -230,7 +230,10 @@ public class DebugExec extends SubCommand {
player.sendMessage(TranslatableCaption.of("debugexec.starting_task"));
this.hybridUtils.analyzePlot(plot, new RunnableVal<PlotAnalysis>() {
@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) {

View File

@ -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("<red>Skipping settings.yml because it's empty.</red>"));
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("<red>Skipping worlds.yml because it's empty.</red>"));
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("<red>Skipping Multiverse world's.yml because Multiverse is not in use.</red>"));
player.sendMessage(TranslatableCaption.of("debugpaste.skip_multiverse"),
Template.of("file", "worlds.yml"));
}
try {

View File

@ -57,7 +57,7 @@ public class Music extends SubCommand {
private static final Collection<String> 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 = "<gold>Cancel music</gold>";
String[] lore = {"<red>Click to cancel!<reset>"};
String[] lore = {"<red>Click to remove the music!<reset>"};
inv.setItem(index, new PlotItemStack("bedrock", 1, name, lore));
// }

View File

@ -109,7 +109,7 @@ public class ComponentPresetManager {
.collect(Collectors.toList());
} else {
final List<ComponentPreset> 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, "", "<gold>D</gold><green>i</green><red>s</red><yellow>c</yellow><aqua>o</aqua><dark_green> F</dark_green><dark_aqua>l</dark_aqua><light_purple>o</light_purple><blue>o</blue><dark_red>r</dark_red>",
Arrays.asList("<gold>Spice up your plot floor</gold>"), ItemTypes.YELLOW_WOOL));
yamlConfiguration.set("presets", defaultPreset.stream().map(ComponentPreset::serialize).collect(Collectors.toList()));
try {

View File

@ -264,6 +264,7 @@
"database.failed_to_save_plots": "<prefix><red>Failed to save plots, read stacktrace for info.</red>",
"database.invalid_args": "<prefix><red>Please make sure you are using the correct arguments.</red>",
"database.failed_to_open": "<prefix><red>Failed to open connection, read stacktrace for info.</red>",
"database.skipping_duplicated_plot": "<prefix><red>Skipping duplicate plot: </red><gray><plot></gray><red> | ID: </red><gray><id></gray>",
"template.invalid_template": "<prefix><red>Invalid template file: </red><gray><value>.template</gray>",
"template.template_failed": "<prefix><red>Failed: </red><gray><value></gray>",
@ -272,7 +273,7 @@
"debugexec.starting_task": "<prefix><gold>Starting task...</gold>",
"debugexec.threshold_default": "<prefix><gray>`threshold` = The percentage of plots you want to clear (100 clears 100% of plots so no point calibrating it.</gray>",
"debugexec.invalid_threshold": "<prefix><red>Invalid threshold: </red><gray><value></gray>",
"debugexec.threshold_default_double": "<prefix><gray>$1<threshold> $2= $1The percentage of plots you want to clear as a number between 0 - 100.</gray>",
"debugexec.threshold_default_double": "<prefix><gray><gold><threshold> </gold><gray>= </gray><gold>The percentage of plots you want to clear as a number between 0 - 100.</gold>",
"debugexec.calibration_done": "<prefix><gold>Thank you for calibrating plot expiry.</gold>",
"debugexec.task_halted": "<prefix><gray>Task already halted.</gray>",
"debugexec.cancelling_task": "<prefix><red>Task cancelled.</red>",
@ -283,6 +284,7 @@
"debugexec.expiry_started": "<prefix><gold>Started plot expiry task.</gold>",
"debugexec.expiry_already_started": "<prefix><gold>Plot expiry task already started.</gold>",
"debugexec.script_list_item": "<dark_gray>[</dark_gray><gold><number></gold><dark_gray>]</dark_gray><gold> <name></gold>",
"debugexec.analyze_done": "<prefix><gold>Done. Use </gold><gray><command></gray><gold> for more information. ",
"expiry.expired_options_clicky": "<gold><num> <are_or_is> expired: </gold><click:run_command:<list_cmd>><hover:show_text:<list_cmd>><gray><plot></gray></hover></click>\n<dark_gray> - </dark_gray><click:run_command:<cmd_del>><hover:show_text:<cmd_del>><gray>Delete this (<cmd_del>)</gray></hover></click>\n<dark_gray> - </dark_gray><click:run_command:<cmd_keep_1d>><hover:show_text:<cmd_keep_1d>><gray>Remind later (<cmd_keep_1d>)</gray></hover></click>\n<dark_gray> - </dark_gray><click:run_command:<cmd_keep>><hover:show_text:<cmd_keep>><gray>Keep this (<cmd_keep>)</gray></hover></click>\n<dark_gray> - </dark_gray><click:run_command:<cmd_no_show_expir>><hover:show_text:<cmd_no_show_expir>><gray>Don't show me this (<cmd_no_show_expir>)</gray></hover></click>",
@ -317,7 +319,12 @@
"error.plot_size": "<prefix><red>Error: size <= 0.</red>",
"error.command_went_wrong": "<prefix><red>Something went wrong when executing that command.</red>",
"errors.not_implemented": "<prefix><red>Not implemented.</red>",
"errors.stacktrace_begin": "<red>=== Begin of stacktrace ===</red>",
"errors.stacktrace_end": "<red>=== End of stacktrace ===</red>",
"debugpaste.latest_log": "<red><file> is larger than <size>. Please reboot the server and submit a new paste.",
"debugpaste.empty_file": "<red>Skipping <file> because it's empty.",
"debugpaste.skip_multiverse": "<red>Skipping Multiverse <file> because it's not in use.",
"debugpaste.debug_report_created": "<prefix><gold>Uploaded a full debug to: </gold><gray><click:open_url:<url>><url></click></gray>",
"debugpaste.creation_failed": "<prefix><red>Failed to create the debugpaste: </red><gray><value></gray>",
@ -351,6 +358,8 @@
"need.need_block": "<prefix><red>You've got to specify a block.</red>",
"near.plot_near": "<prefix><gold>Players: <gray><list></gray></gold>",
"scripts.script_list": "<dark_gray><strikethrough>--------- <reset><gold>SCRIPTS </gold><dark_gray><strikethrough>---------</dark_gray><reset>",
"info.none": "<gray>None</gray>",
"info.now": "<gray>Now</gray>",
@ -521,7 +530,7 @@
"flag.flag_partially_removed": "<prefix><dark_aqua>Successfully removed flag value(s).</dark_aqua>",
"flag.flag_added": "<prefix><dark_aqua>The flag has been added successfully.</dark_aqua>",
"flag.flag_list_see_info": "<prefix><gray>Click to view information about the flag.</gray>",
"flag.flag_parse_error": "<red>Failed to parse flag </red><gray><flag_name><red>, value </red><gray><flag_value></gray><red>: <error></red>",
"flag.flag_parse_error": "<red>Failed to parse flag </red><gray><flag_name></gray><red>, value </red><gray><flag_value></gray><red>Error: <error></red>",
"flag.flag_info_header": "<dark_gray><strikethrough>---------<reset> <gold>PlotSquared Flags </gold><dark_gray><strikethrough>---------<reset>",
"flag.flag_info_footer": "<dark_gray><strikethrough>---------<reset> <gold>PlotSquared Flags </gold><dark_gray><strikethrough>---------<reset>",
"flag.flag_list_categories": "<gold><category>: </gold>",