From 4e2c7340cd4c4bf4dd2e1aa1c9ab27698d46740a Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Wed, 28 Dec 2022 17:05:12 +0100 Subject: [PATCH] Fixed setjs command --- .../command/subcommands/SetJSCommand.java | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/main/java/me/lorenzo0111/rocketplaceholders/command/subcommands/SetJSCommand.java b/src/main/java/me/lorenzo0111/rocketplaceholders/command/subcommands/SetJSCommand.java index 77c42cb..6789444 100644 --- a/src/main/java/me/lorenzo0111/rocketplaceholders/command/subcommands/SetJSCommand.java +++ b/src/main/java/me/lorenzo0111/rocketplaceholders/command/subcommands/SetJSCommand.java @@ -80,35 +80,31 @@ public void perform(CommandSender sender, String[] args) { builder.append(args[i]).append(" "); } - int runner = user != null ? 2 : 1; - builder.deleteCharAt(builder.length() - 1); - for (int i = 0; i < runner; i++) { - try { - engine.bind("Player", user != null ? user : sender); - engine.bind("Server", Bukkit.getServer()); - engine.bind("Placeholder", placeholder); - String text = engine.parse(builder.toString()); - if (text != null) { - - if (user != null) { - RocketPlaceholders.getApi().getUserStorage().setText(placeholder,user.getUniqueId(),text); - } else { - try { - placeholder.saveText(text); - } catch (SaveException e) { - sender.sendMessage(ChatColor.translateAlternateColorCodes('&', this.getCommand().getPlugin().getConfig().getString("prefix") + "&r &cAn error has occurred when editing this value. Please try again later!")); - sender.sendMessage(ChatColor.translateAlternateColorCodes('&', this.getCommand().getPlugin().getConfig().getString("prefix") + "&r &cReason: " + e.getReason())); - return; - } + try { + engine.bind("Player", user != null ? user : sender); + engine.bind("Server", Bukkit.getServer()); + engine.bind("Placeholder", placeholder); + String text = engine.parse(builder.toString()); + if (text != null) { + + if (user != null) { + RocketPlaceholders.getApi().getUserStorage().setText(placeholder,user.getUniqueId(),text); + } else { + try { + placeholder.saveText(text); + } catch (SaveException e) { + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', this.getCommand().getPlugin().getConfig().getString("prefix") + "&r &cAn error has occurred when editing this value. Please try again later!")); + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', this.getCommand().getPlugin().getConfig().getString("prefix") + "&r &cReason: " + e.getReason())); + return; } - - sender.sendMessage(ChatColor.translateAlternateColorCodes('&', this.getCommand().getPlugin().getConfig().getString("prefix") + "&r &7The placeholder &e" + placeholder.getIdentifier() + "&7's text has been set to &e" + text + "&7!")); } - } catch (ScriptException e) { - sender.sendMessage(ChatColor.translateAlternateColorCodes('&', this.getCommand().getPlugin().getConfig().getString("prefix") + "&r &7Error while parsing the javascript expression!")); - this.getCommand().getPlugin().debug(e.getMessage()); + + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', this.getCommand().getPlugin().getConfig().getString("prefix") + "&r &7The placeholder &e" + placeholder.getIdentifier() + "&7's text has been set to &e" + text + "&7!")); } + } catch (ScriptException e) { + sender.sendMessage(ChatColor.translateAlternateColorCodes('&', this.getCommand().getPlugin().getConfig().getString("prefix") + "&r &7Error while parsing the javascript expression!")); + this.getCommand().getPlugin().debug(e.getMessage()); } } }