diff --git a/src/com/esophose/playerparticles/command/AddCommandModule.java b/src/com/esophose/playerparticles/command/AddCommandModule.java index 2794838..b967d53 100644 --- a/src/com/esophose/playerparticles/command/AddCommandModule.java +++ b/src/com/esophose/playerparticles/command/AddCommandModule.java @@ -2,13 +2,120 @@ package com.esophose.playerparticles.command; import java.util.List; +import org.bukkit.Material; + +import com.esophose.playerparticles.manager.LangManager; +import com.esophose.playerparticles.manager.ParticleManager; +import com.esophose.playerparticles.manager.PermissionManager; import com.esophose.playerparticles.manager.LangManager.Lang; import com.esophose.playerparticles.particles.PPlayer; +import com.esophose.playerparticles.particles.ParticleEffect; +import com.esophose.playerparticles.particles.ParticleEffect.NoteColor; +import com.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; +import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; +import com.esophose.playerparticles.styles.api.ParticleStyle; +import com.esophose.playerparticles.styles.api.ParticleStyleManager; +import com.esophose.playerparticles.util.ParticleUtils; public class AddCommandModule implements CommandModule { public void onCommandExecute(PPlayer pplayer, String[] args) { + if (args.length < 2) { + CommandModule.printUsage(pplayer, this); + return; + } + + ParticleEffect effect = ParticleManager.effectFromString(args[0]); + if (effect == null) { + LangManager.sendMessage(pplayer, Lang.INVALID_EFFECT, args[0]); + return; + } else if (!PermissionManager.hasEffectPermission(pplayer.getPlayer(), effect)) { + LangManager.sendMessage(pplayer, Lang.NO_PERMISSION, effect.getName()); + return; + } + ParticleStyle style = ParticleStyleManager.styleFromString(args[1]); + if (style == null) { + LangManager.sendMessage(pplayer, Lang.CREATE_FIXED_INVALID_STYLE, args[1]); + return; + } else if (!PermissionManager.hasStylePermission(pplayer.getPlayer(), style)) { + LangManager.sendMessage(pplayer, Lang.CREATE_FIXED_NO_PERMISSION_STYLE, args[1]); + return; + } + + Material itemData = null; + Material blockData = null; + OrdinaryColor colorData = null; + NoteColor noteColorData = null; + + if (args.length > 2) { + if (effect.hasProperty(ParticleProperty.COLORABLE)) { + if (effect == ParticleEffect.NOTE) { + if (args[2].equalsIgnoreCase("rainbow")) { + noteColorData = new NoteColor(99); + } else { + int note = -1; + try { + note = Integer.parseInt(args[2]); + } catch (Exception e) { + LangManager.sendMessage(pplayer, Lang.CREATE_FIXED_DATA_ERROR, "note"); + return; + } + + if (note < 0 || note > 23) { + LangManager.sendMessage(pplayer, Lang.CREATE_FIXED_DATA_ERROR, "note"); + return; + } + + noteColorData = new NoteColor(note); + } + } else { + if (args[2].equalsIgnoreCase("rainbow")) { + colorData = new OrdinaryColor(999, 999, 999); + } else { + int r = -1; + int g = -1; + int b = -1; + + try { + r = Integer.parseInt(args[2]); + g = Integer.parseInt(args[3]); + b = Integer.parseInt(args[4]); + } catch (Exception e) { + LangManager.sendMessage(pplayer, Lang.CREATE_FIXED_DATA_ERROR, "color"); + return; + } + + if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) { + LangManager.sendMessage(pplayer, Lang.CREATE_FIXED_DATA_ERROR, "color"); + return; + } + + colorData = new OrdinaryColor(r, g, b); + } + } + } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { + if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { + try { + blockData = ParticleUtils.closestMatch(args[2]); + if (blockData == null) throw new Exception(); + } catch (Exception e) { + LangManager.sendMessage(pplayer, Lang.CREATE_FIXED_DATA_ERROR, "block"); + return; + } + } else if (effect == ParticleEffect.ITEM) { + try { + itemData = ParticleUtils.closestMatch(args[2]); + if (itemData == null) throw new Exception(); + } catch (Exception e) { + LangManager.sendMessage(pplayer, Lang.CREATE_FIXED_DATA_ERROR, "item"); + return; + } + } + } + + // TODO: Update active group and save + } } public List onTabComplete(PPlayer pplayer, String[] args) { @@ -19,8 +126,8 @@ public class AddCommandModule implements CommandModule { return "add"; } - public String getDescription() { - return Lang.ADD_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.ADD_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/CommandModule.java b/src/com/esophose/playerparticles/command/CommandModule.java index 2587e05..5670173 100644 --- a/src/com/esophose/playerparticles/command/CommandModule.java +++ b/src/com/esophose/playerparticles/command/CommandModule.java @@ -2,6 +2,8 @@ package com.esophose.playerparticles.command; import java.util.List; +import com.esophose.playerparticles.manager.LangManager; +import com.esophose.playerparticles.manager.LangManager.Lang; import com.esophose.playerparticles.particles.PPlayer; public interface CommandModule { @@ -30,11 +32,11 @@ public interface CommandModule { public String getName(); /** - * Gets the description of this command + * Gets the Lang description of this command * * @return The description of this command */ - public String getDescription(); + public Lang getDescription(); /** * Gets any arguments this command has @@ -49,5 +51,29 @@ public interface CommandModule { * @return If the player must have effects to use this command */ public boolean requiresEffects(); + + /** + * Displays a command's usage to the player + * + * @param pplayer The PPlayer to display the command usage to + * @param command The command to display usage for + */ + public static void printUsage(PPlayer pplayer, CommandModule command) { + LangManager.sendMessage(pplayer, Lang.COMMAND_MISSING_ARGS); + LangManager.sendCustomMessage(pplayer, String.format("/{0} {1}", command.getName(), command.getArguments())); + } + + /** + * Displays a command's sub-command usage to the player + * + * @param pplayer The PPlayer to display the command usage to + * @param command The command to display usage for + * @param subCommandName The name of the command's sub-command to display usage for + * @param subCommandArgs The sub-command's arguments + */ + public static void printSubcommandUsage(PPlayer pplayer, CommandModule command, String subCommandName, String subCommandArgs) { + LangManager.sendMessage(pplayer, Lang.COMMAND_MISSING_ARGS); + LangManager.sendCustomMessage(pplayer, String.format("/{0} {1} {2}", command.getName(), subCommandName, subCommandArgs)); + } } diff --git a/src/com/esophose/playerparticles/command/DataCommandModule.java b/src/com/esophose/playerparticles/command/DataCommandModule.java index a2a5809..1875aa2 100644 --- a/src/com/esophose/playerparticles/command/DataCommandModule.java +++ b/src/com/esophose/playerparticles/command/DataCommandModule.java @@ -18,25 +18,25 @@ public class DataCommandModule implements CommandModule { if (effect.hasProperty(ParticleProperty.COLORABLE)) { if (effect == ParticleEffect.NOTE) { LangManager.sendMessage(pplayer, Lang.DATA_USAGE, "note"); - LangManager.sendCustomMessage(pplayer, Lang.USAGE.get() + " " + Lang.NOTE_DATA_USAGE.get()); + LangManager.sendCustomMessage(pplayer, LangManager.getText(Lang.USAGE) + " " + LangManager.getText(Lang.NOTE_DATA_USAGE)); } else { LangManager.sendMessage(pplayer, Lang.DATA_USAGE, "color"); - LangManager.sendCustomMessage(pplayer, Lang.USAGE.get() + " " + Lang.COLOR_DATA_USAGE.get()); + LangManager.sendCustomMessage(pplayer, LangManager.getText(Lang.USAGE) + " " + LangManager.getText(Lang.COLOR_DATA_USAGE)); } } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { if (effect == ParticleEffect.ITEM) { LangManager.sendMessage(pplayer, Lang.DATA_USAGE, "item"); - LangManager.sendCustomMessage(pplayer, Lang.USAGE.get() + " " + Lang.ITEM_DATA_USAGE.get()); + LangManager.sendCustomMessage(pplayer, LangManager.getText(Lang.USAGE) + " " + LangManager.getText(Lang.ITEM_DATA_USAGE)); } else { LangManager.sendMessage(pplayer, Lang.DATA_USAGE, "block"); - LangManager.sendCustomMessage(pplayer, Lang.USAGE.get() + " " + Lang.BLOCK_DATA_USAGE.get()); + LangManager.sendCustomMessage(pplayer, LangManager.getText(Lang.USAGE) + " " + LangManager.getText(Lang.BLOCK_DATA_USAGE)); } } else { LangManager.sendMessage(pplayer, Lang.NO_DATA_USAGE); } } } else { - LangManager.sendMessage(pplayer, Lang.INVALID_TYPE); + LangManager.sendMessage(pplayer, Lang.INVALID_EFFECT); } } @@ -48,8 +48,8 @@ public class DataCommandModule implements CommandModule { return "data"; } - public String getDescription() { - return Lang.DATA_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.DATA_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/DefaultCommandModule.java b/src/com/esophose/playerparticles/command/DefaultCommandModule.java index b5bac3c..dfeee6a 100644 --- a/src/com/esophose/playerparticles/command/DefaultCommandModule.java +++ b/src/com/esophose/playerparticles/command/DefaultCommandModule.java @@ -20,8 +20,8 @@ public class DefaultCommandModule implements CommandModule { return ""; } - public String getDescription() { - return Lang.DEFAULT_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.DEFAULT_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/EditCommandModule.java b/src/com/esophose/playerparticles/command/EditCommandModule.java index 495500e..015230f 100644 --- a/src/com/esophose/playerparticles/command/EditCommandModule.java +++ b/src/com/esophose/playerparticles/command/EditCommandModule.java @@ -19,8 +19,8 @@ public class EditCommandModule implements CommandModule { return "edit"; } - public String getDescription() { - return Lang.EDIT_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.EDIT_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/EffectCommandModule.java b/src/com/esophose/playerparticles/command/EffectCommandModule.java index b21db6e..8a197a9 100644 --- a/src/com/esophose/playerparticles/command/EffectCommandModule.java +++ b/src/com/esophose/playerparticles/command/EffectCommandModule.java @@ -20,8 +20,8 @@ public class EffectCommandModule implements CommandModule { return "effect"; } - public String getDescription() { - return Lang.EFFECT_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.EFFECT_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/EffectsCommandModule.java b/src/com/esophose/playerparticles/command/EffectsCommandModule.java index deda84d..e3ab542 100644 --- a/src/com/esophose/playerparticles/command/EffectsCommandModule.java +++ b/src/com/esophose/playerparticles/command/EffectsCommandModule.java @@ -20,7 +20,7 @@ public class EffectsCommandModule implements CommandModule { return; } - String toSend = Lang.USE.get() + " "; + String toSend = LangManager.getText(Lang.USE) + " "; for (ParticleEffect effect : ParticleEffect.getSupportedEffects()) { if (PermissionManager.hasEffectPermission(p, effect)) { toSend += effect.getName() + ", "; @@ -32,7 +32,7 @@ public class EffectsCommandModule implements CommandModule { } LangManager.sendCustomMessage(p, toSend); - LangManager.sendCustomMessage(p, Lang.USAGE.get() + " " + Lang.PARTICLE_USAGE.get()); + LangManager.sendCustomMessage(p, LangManager.getText(Lang.USAGE) + " " + LangManager.getText(Lang.PARTICLE_USAGE)); } public List onTabComplete(PPlayer pplayer, String[] args) { @@ -43,8 +43,8 @@ public class EffectsCommandModule implements CommandModule { return "effects"; } - public String getDescription() { - return Lang.EFFECTS_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.EFFECTS_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/FixedCommandModule.java b/src/com/esophose/playerparticles/command/FixedCommandModule.java index 83bd341..89eed38 100644 --- a/src/com/esophose/playerparticles/command/FixedCommandModule.java +++ b/src/com/esophose/playerparticles/command/FixedCommandModule.java @@ -237,7 +237,7 @@ public class FixedCommandModule implements CommandModule { return; } - String msg = Lang.LIST_FIXED_SUCCESS.get(); + String msg = LangManager.getText(Lang.LIST_FIXED_SUCCESS); boolean first = true; for (int id : ids) { if (!first) msg += ", "; @@ -269,7 +269,7 @@ public class FixedCommandModule implements CommandModule { ParticlePair particle = fixedEffect.getParticlePair(); DecimalFormat df = new DecimalFormat("0.##"); // Decimal formatter so the coords aren't super long - String listMessage = Lang.INFO_FIXED_INFO.get() // @formatter:off + String listMessage = LangManager.getText(Lang.INFO_FIXED_INFO) // @formatter:off .replaceAll("\\{0\\}", fixedEffect.getId() + "") .replaceAll("\\{1\\}", fixedEffect.getLocation().getWorld().getName()) .replaceAll("\\{2\\}", df.format(fixedEffect.getLocation().getX()) + "") @@ -307,7 +307,7 @@ public class FixedCommandModule implements CommandModule { for (FixedParticleEffect fixedEffect : fixedEffectsToRemove) DataManager.removeFixedEffect(fixedEffect.getOwnerUniqueId(), fixedEffect.getId()); - String clearMessage = Lang.CLEAR_FIXED_SUCCESS.get() // @formatter:off + String clearMessage = LangManager.getText(Lang.CLEAR_FIXED_SUCCESS) // @formatter:off .replaceAll("\\{0\\}", fixedEffectsToRemove.size() + "").replaceAll("\\{1\\}", radius + ""); // @formatter:on LangManager.sendCustomMessage(pplayer, clearMessage); return; @@ -329,8 +329,8 @@ public class FixedCommandModule implements CommandModule { return "fixed"; } - public String getDescription() { - return Lang.FIXED_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.FIXED_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/GUICommandModule.java b/src/com/esophose/playerparticles/command/GUICommandModule.java index e3a1849..3865096 100644 --- a/src/com/esophose/playerparticles/command/GUICommandModule.java +++ b/src/com/esophose/playerparticles/command/GUICommandModule.java @@ -50,8 +50,8 @@ public class GUICommandModule implements CommandModule { return "gui"; } - public String getDescription() { - return Lang.GUI_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.GUI_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/GroupCommandModule.java b/src/com/esophose/playerparticles/command/GroupCommandModule.java index fcb008a..bcd9561 100644 --- a/src/com/esophose/playerparticles/command/GroupCommandModule.java +++ b/src/com/esophose/playerparticles/command/GroupCommandModule.java @@ -19,8 +19,8 @@ public class GroupCommandModule implements CommandModule { return "group"; } - public String getDescription() { - return Lang.GROUP_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.GROUP_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/HelpCommandModule.java b/src/com/esophose/playerparticles/command/HelpCommandModule.java index e3c6494..a24cf1f 100644 --- a/src/com/esophose/playerparticles/command/HelpCommandModule.java +++ b/src/com/esophose/playerparticles/command/HelpCommandModule.java @@ -21,8 +21,8 @@ public class HelpCommandModule implements CommandModule { return "help"; } - public String getDescription() { - return Lang.HELP_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.HELP_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/InfoCommandModule.java b/src/com/esophose/playerparticles/command/InfoCommandModule.java index 4995e31..40671a4 100644 --- a/src/com/esophose/playerparticles/command/InfoCommandModule.java +++ b/src/com/esophose/playerparticles/command/InfoCommandModule.java @@ -19,8 +19,8 @@ public class InfoCommandModule implements CommandModule { return "info"; } - public String getDescription() { - return Lang.INFO_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.INFO_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/ListCommandModule.java b/src/com/esophose/playerparticles/command/ListCommandModule.java index b6008ef..a0a94f0 100644 --- a/src/com/esophose/playerparticles/command/ListCommandModule.java +++ b/src/com/esophose/playerparticles/command/ListCommandModule.java @@ -19,8 +19,8 @@ public class ListCommandModule implements CommandModule { return "list"; } - public String getDescription() { - return Lang.LIST_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.LIST_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/RemoveCommandModule.java b/src/com/esophose/playerparticles/command/RemoveCommandModule.java index 6a84879..ece3fd5 100644 --- a/src/com/esophose/playerparticles/command/RemoveCommandModule.java +++ b/src/com/esophose/playerparticles/command/RemoveCommandModule.java @@ -19,8 +19,8 @@ public class RemoveCommandModule implements CommandModule { return "remove"; } - public String getDescription() { - return Lang.REMOVE_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.REMOVE_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/ResetCommandModule.java b/src/com/esophose/playerparticles/command/ResetCommandModule.java index 8f862f3..a69bd9b 100644 --- a/src/com/esophose/playerparticles/command/ResetCommandModule.java +++ b/src/com/esophose/playerparticles/command/ResetCommandModule.java @@ -51,8 +51,8 @@ public class ResetCommandModule implements CommandModule { return "reset"; } - public String getDescription() { - return Lang.RESET_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.RESET_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/StyleCommandModule.java b/src/com/esophose/playerparticles/command/StyleCommandModule.java index ff07ec4..6b4e80a 100644 --- a/src/com/esophose/playerparticles/command/StyleCommandModule.java +++ b/src/com/esophose/playerparticles/command/StyleCommandModule.java @@ -20,8 +20,8 @@ public class StyleCommandModule implements CommandModule { return "style"; } - public String getDescription() { - return Lang.STYLE_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.STYLE_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/StylesCommandModule.java b/src/com/esophose/playerparticles/command/StylesCommandModule.java index 906e956..47fdec7 100644 --- a/src/com/esophose/playerparticles/command/StylesCommandModule.java +++ b/src/com/esophose/playerparticles/command/StylesCommandModule.java @@ -21,7 +21,7 @@ public class StylesCommandModule implements CommandModule { return; } - String toSend = Lang.USE.get() + " "; + String toSend = LangManager.getText(Lang.USE) + " "; for (ParticleStyle style : ParticleStyleManager.getStyles()) { if (PermissionManager.hasStylePermission(p, style)) { toSend += style.getName(); @@ -33,7 +33,7 @@ public class StylesCommandModule implements CommandModule { } LangManager.sendCustomMessage(p, toSend); - LangManager.sendCustomMessage(p, Lang.USAGE.get() + " " + Lang.STYLE_USAGE.get()); + LangManager.sendCustomMessage(p, LangManager.getText(Lang.USAGE) + " " + LangManager.getText(Lang.STYLE_USAGE)); } public List onTabComplete(PPlayer pplayer, String[] args) { @@ -44,8 +44,8 @@ public class StylesCommandModule implements CommandModule { return "styles"; } - public String getDescription() { - return Lang.STYLES_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.STYLES_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/VersionCommandModule.java b/src/com/esophose/playerparticles/command/VersionCommandModule.java index 1fdfd18..77b5f9b 100644 --- a/src/com/esophose/playerparticles/command/VersionCommandModule.java +++ b/src/com/esophose/playerparticles/command/VersionCommandModule.java @@ -24,8 +24,8 @@ public class VersionCommandModule implements CommandModule { return "version"; } - public String getDescription() { - return Lang.VERSION_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.VERSION_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/command/WorldsCommandModule.java b/src/com/esophose/playerparticles/command/WorldsCommandModule.java index 4520033..ea0e065 100644 --- a/src/com/esophose/playerparticles/command/WorldsCommandModule.java +++ b/src/com/esophose/playerparticles/command/WorldsCommandModule.java @@ -21,7 +21,7 @@ public class WorldsCommandModule implements CommandModule { } if (worlds.length() > 2) worlds = worlds.substring(0, worlds.length() - 2); - LangManager.sendCustomMessage(pplayer, Lang.DISABLED_WORLDS.get() + " " + worlds); + LangManager.sendCustomMessage(pplayer, LangManager.getText(Lang.DISABLED_WORLDS) + " " + worlds); } public List onTabComplete(PPlayer pplayer, String[] args) { @@ -32,8 +32,8 @@ public class WorldsCommandModule implements CommandModule { return "worlds"; } - public String getDescription() { - return Lang.WORLDS_COMMAND_DESCRIPTION.get(); + public Lang getDescription() { + return Lang.WORLDS_COMMAND_DESCRIPTION; } public String getArguments() { diff --git a/src/com/esophose/playerparticles/gui/PlayerParticlesGui.java b/src/com/esophose/playerparticles/gui/PlayerParticlesGui.java index 4872403..18c7a57 100644 --- a/src/com/esophose/playerparticles/gui/PlayerParticlesGui.java +++ b/src/com/esophose/playerparticles/gui/PlayerParticlesGui.java @@ -31,6 +31,7 @@ import org.bukkit.scheduler.BukkitRunnable; import com.esophose.playerparticles.PlayerParticles; import com.esophose.playerparticles.manager.DataManager; +import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.LangManager.Lang; import com.esophose.playerparticles.manager.ParticleManager; import com.esophose.playerparticles.manager.PermissionManager; @@ -470,18 +471,18 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener { ItemStack effectIcon = new ItemStack(defaultMenuIcons[0], 1); ItemMeta effectIconMeta = effectIcon.getItemMeta(); effectIconMeta.setDisplayName(ChatColor.GREEN + "Effect"); - effectIconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SET_YOUR.getMessageReplaced("effect"))); + effectIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SET_YOUR, "effect"))); if (PermissionManager.getEffectsUserHasPermissionFor(player).size() == 1) { // Always has access to NONE - effectIconMeta.setLore(Arrays.asList(Lang.GUI_NO_ACCESS_TO.getMessageReplaced("effects"))); + effectIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_NO_ACCESS_TO, "effects"))); } effectIcon.setItemMeta(effectIconMeta); ItemStack styleIcon = new ItemStack(defaultMenuIcons[1], 1); ItemMeta styleIconMeta = styleIcon.getItemMeta(); styleIconMeta.setDisplayName(ChatColor.GREEN + "Style"); - styleIconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SET_YOUR.getMessageReplaced("style"))); + styleIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SET_YOUR, "style"))); if (PermissionManager.getStylesUserHasPermissionFor(player).size() == 1) { // Always has access to NONE - styleIconMeta.setLore(Arrays.asList(Lang.GUI_NO_ACCESS_TO.getMessageReplaced("styles"))); + styleIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_NO_ACCESS_TO, "styles"))); } styleIcon.setItemMeta(styleIconMeta); @@ -495,9 +496,9 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener { else dataType = "color " + dataType; else if (pe.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) if (pe == ParticleEffect.ITEM) dataType = "item " + dataType; else dataType = "block " + dataType; // @formatter:on - dataIconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SET_YOUR.getMessageReplaced(dataType))); + dataIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SET_YOUR, dataType))); if (getPPlayerSpawnMaterial(pplayer) == null && getPPlayerSpawnColor(pplayer) == null) { - dataIconMeta.setLore(Arrays.asList(Lang.GUI_NO_DATA.get())); + dataIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_NO_DATA))); } dataIcon.setItemMeta(dataIconMeta); @@ -690,7 +691,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener { if (clicked == null || clicked.getType() == Material.AIR) return; // Clicked on an empty slot, do nothing // Check back button. This is common for most menus - if (clicked.getItemMeta().getDisplayName().equals(Lang.GUI_BACK_BUTTON.get())) { + if (clicked.getItemMeta().getDisplayName().equals(LangManager.getText(Lang.GUI_BACK_BUTTON))) { changeState(pplayer, GuiState.DEFAULT); return; } @@ -759,11 +760,11 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener { ItemStack icon = new ItemStack(effectIcons.get(effect.name()), 1); ItemMeta iconMeta = icon.getItemMeta(); - iconMeta.setDisplayName(Lang.GUI_ICON_NAME_COLOR.get() + effect.getName()); + iconMeta.setDisplayName(LangManager.getText(Lang.GUI_ICON_NAME_COLOR) + effect.getName()); if (!isActive) { - iconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced("effect") + effect.getName())); + iconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, "effect") + effect.getName())); } else { - iconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced("effect") + effect.getName(), Lang.GUI_ICON_CURRENT_ACTIVE.getMessageReplaced("effect"))); + iconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, "effect") + effect.getName(), LangManager.getText(Lang.GUI_ICON_CURRENT_ACTIVE, "effect"))); iconMeta.addEnchant(Enchantment.ARROW_INFINITE, -1, true); iconMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); } @@ -782,11 +783,11 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener { ItemStack icon = new ItemStack(styleIcons.get(style.getName().toUpperCase()), 1); ItemMeta iconMeta = icon.getItemMeta(); - iconMeta.setDisplayName(Lang.GUI_ICON_NAME_COLOR.get() + style.getName()); + iconMeta.setDisplayName(LangManager.getText(Lang.GUI_ICON_NAME_COLOR) + style.getName()); if (!isActive) { - iconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced("style") + style.getName())); + iconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, "style") + style.getName())); } else { - iconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced("style") + style.getName(), Lang.GUI_ICON_CURRENT_ACTIVE.getMessageReplaced("style"))); + iconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, "style") + style.getName(), LangManager.getText(Lang.GUI_ICON_CURRENT_ACTIVE, "style"))); iconMeta.addEnchant(Enchantment.ARROW_INFINITE, -1, true); iconMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); } @@ -807,11 +808,11 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener { ItemStack materialIcon = new ItemStack(material, 1); ItemMeta materialIconMeta = materialIcon.getItemMeta(); - materialIconMeta.setDisplayName(Lang.GUI_ICON_NAME_COLOR.get() + material.name().toLowerCase()); + materialIconMeta.setDisplayName(LangManager.getText(Lang.GUI_ICON_NAME_COLOR) + material.name().toLowerCase()); if (currentMaterial != material) { - materialIconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced(dataType + " data") + material.name().toLowerCase())); + materialIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, dataType + " data") + material.name().toLowerCase())); } else { - materialIconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced(dataType + " data") + material.name().toLowerCase(), Lang.GUI_ICON_CURRENT_ACTIVE.getMessageReplaced(dataType + " data"))); + materialIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, dataType + " data") + material.name().toLowerCase(), LangManager.getText(Lang.GUI_ICON_CURRENT_ACTIVE, dataType + " data"))); materialIconMeta.addEnchant(Enchantment.ARROW_INFINITE, -1, true); materialIconMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); } @@ -841,9 +842,9 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener { colorIconMeta.setDisplayName(colorData.getName()); if (!currentColor.equals(colorData.getOrdinaryColor())) { - colorIconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced("color data") + formattedDisplayColor)); + colorIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, "color data") + formattedDisplayColor)); } else { - colorIconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced("color data") + formattedDisplayColor, Lang.GUI_ICON_CURRENT_ACTIVE.getMessageReplaced("color data"))); + colorIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, "color data") + formattedDisplayColor, LangManager.getText(Lang.GUI_ICON_CURRENT_ACTIVE, "color data"))); colorIconMeta.addEnchant(Enchantment.ARROW_INFINITE, -1, true); colorIconMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); } @@ -863,11 +864,11 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener { ItemStack noteIcon = new ItemStack(Material.NOTE_BLOCK, noteIndex + 1); ItemMeta noteIconMeta = noteIcon.getItemMeta(); - noteIconMeta.setDisplayName(Lang.GUI_ICON_NAME_COLOR.get() + "note #" + noteIndex); + noteIconMeta.setDisplayName(LangManager.getText(Lang.GUI_ICON_NAME_COLOR) + "note #" + noteIndex); if (currentNote.getValueX() * 24 != noteIndex) { - noteIconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced("note data") + "note #" + noteIndex)); + noteIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, "note data") + "note #" + noteIndex)); } else { - noteIconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced("note data") + "note #" + noteIndex, Lang.GUI_ICON_CURRENT_ACTIVE.getMessageReplaced("note data"))); + noteIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, "note data") + "note #" + noteIndex, LangManager.getText(Lang.GUI_ICON_CURRENT_ACTIVE, "note data"))); noteIconMeta.addEnchant(Enchantment.ARROW_INFINITE, -1, true); noteIconMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); } @@ -893,11 +894,11 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener { rainbowIconMeta.setDisplayName(rainbowName); if (currentColor.getRed() == 999 && currentColor.getGreen() == 999 && currentColor.getBlue() == 999) { - rainbowIconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced("color data") + rainbowName, Lang.GUI_ICON_CURRENT_ACTIVE.getMessageReplaced("color data"))); + rainbowIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, "color data") + rainbowName, LangManager.getText(Lang.GUI_ICON_CURRENT_ACTIVE, "color data"))); rainbowIconMeta.addEnchant(Enchantment.ARROW_INFINITE, -1, true); rainbowIconMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); } else { - rainbowIconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced("color data") + rainbowName)); + rainbowIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, "color data") + rainbowName)); } rainbowIcon.setItemMeta(rainbowIconMeta); @@ -921,11 +922,11 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener { rainbowIconMeta.setDisplayName(rainbowName); if (currentColor.getValueX() * 24 == 99) { - rainbowIconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced("note data") + rainbowName, Lang.GUI_ICON_CURRENT_ACTIVE.getMessageReplaced("note data"))); + rainbowIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, "note data") + rainbowName, LangManager.getText(Lang.GUI_ICON_CURRENT_ACTIVE, "note data"))); rainbowIconMeta.addEnchant(Enchantment.ARROW_INFINITE, -1, true); rainbowIconMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); } else { - rainbowIconMeta.setLore(Arrays.asList(Lang.GUI_ICON_SETS_TO.getMessageReplaced("note data") + rainbowName)); + rainbowIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SETS_TO, "note data") + rainbowName)); } rainbowIcon.setItemMeta(rainbowIconMeta); @@ -940,7 +941,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener { private static ItemStack getItemForBack() { ItemStack icon = new ItemStack(Material.ARROW, 1); ItemMeta iconMeta = icon.getItemMeta(); - iconMeta.setDisplayName(Lang.GUI_BACK_BUTTON.get()); + iconMeta.setDisplayName(LangManager.getText(Lang.GUI_BACK_BUTTON)); icon.setItemMeta(iconMeta); return icon; diff --git a/src/com/esophose/playerparticles/manager/LangManager.java b/src/com/esophose/playerparticles/manager/LangManager.java index 0bf1593..5cb9550 100644 --- a/src/com/esophose/playerparticles/manager/LangManager.java +++ b/src/com/esophose/playerparticles/manager/LangManager.java @@ -42,99 +42,100 @@ public class LangManager { WORLDS_COMMAND_DESCRIPTION("worlds-command-description"), COMMAND_REMOVED("command-removed"), + COMMAND_MISSING_ARGS("command-missing-args"), // Particles - NO_PERMISSION("message-no-permission"), - NO_PARTICLES("message-no-particles"), - NOW_USING("message-now-using"), - CLEARED_PARTICLES("message-cleared-particles"), - INVALID_TYPE("message-invalid-type"), - PARTICLE_USAGE("message-particle-usage"), + NO_PERMISSION("no-permission"), + NO_PARTICLES("no-particles"), + NOW_USING("now-using"), + CLEARED_PARTICLES("cleared-particles"), + INVALID_EFFECT("invalid-effect"), + PARTICLE_USAGE("particle-usage"), // Styles - NO_PERMISSION_STYLE("message-no-permission-style"), - NO_STYLES("message-no-styles"), - NOW_USING_STYLE("message-now-using-style"), - CLEARED_STYLE("message-cleared-style"), - INVALID_TYPE_STYLE("message-invalid-type-style"), - STYLE_USAGE("message-style-usage"), + NO_PERMISSION_STYLE("no-permission-style"), + NO_STYLES("no-styles"), + NOW_USING_STYLE("now-using-style"), + CLEARED_STYLE("cleared-style"), + INVALID_TYPE_STYLE("invalid-type-style"), + STYLE_USAGE("style-usage"), // Data - DATA_USAGE("message-data-usage"), - NO_DATA_USAGE("message-no-data-usage"), - DATA_APPLIED("message-data-applied"), - DATA_INVALID_ARGUMENTS("message-data-invalid-arguments"), - DATA_MATERIAL_UNKNOWN("message-data-material-unknown"), - DATA_MATERIAL_MISMATCH("message-data-material-mismatch"), - NOTE_DATA_USAGE("message-note-data-usage"), - COLOR_DATA_USAGE("message-color-data-usage"), - ITEM_DATA_USAGE("message-item-data-usage"), - BLOCK_DATA_USAGE("message-block-data-usage"), + DATA_USAGE("data-usage"), + NO_DATA_USAGE("no-data-usage"), + DATA_APPLIED("data-applied"), + DATA_INVALID_ARGUMENTS("data-invalid-arguments"), + DATA_MATERIAL_UNKNOWN("data-material-unknown"), + DATA_MATERIAL_MISMATCH("data-material-mismatch"), + NOTE_DATA_USAGE("note-data-usage"), + COLOR_DATA_USAGE("color-data-usage"), + ITEM_DATA_USAGE("item-data-usage"), + BLOCK_DATA_USAGE("block-data-usage"), // Fixed Effects - FIXED_COMMAND_DESC_CREATE("message-fixed-command-desc-create"), - FIXED_COMMAND_DESC_REMOVE("message-fixed-command-desc-remove"), - FIXED_COMMAND_DESC_LIST("message-fixed-command-desc-list"), - FIXED_COMMAND_DESC_INFO("message-fixed-command-desc-info"), - FIXED_COMMAND_DESC_CLEAR("message-fixed-command-desc-clear"), - CREATE_FIXED_MISSING_ARGS("message-create-fixed-missing-args"), - CREATE_FIXED_INVALID_COORDS("message-create-fixed-invalid-coords"), - CREATE_FIXED_OUT_OF_RANGE("message-create-fixed-out-of-range"), - CREATE_FIXED_INVALID_EFFECT("message-create-fixed-invalid-effect"), - CREATE_FIXED_NO_PERMISSION_EFFECT("message-create-fixed-no-permission-effect"), - CREATE_FIXED_INVALID_STYLE("message-create-fixed-invalid-style"), - CREATE_FIXED_NO_PERMISSION_STYLE("message-create-fixed-no-permission-style"), - CREATE_FIXED_NON_FIXABLE_STYLE("message-create-fixed-non-fixable-style"), - CREATE_FIXED_DATA_ERROR("message-create-fixed-data-error"), - CREATE_FIXED_SUCCESS("message-create-fixed-success"), - REMOVE_FIXED_NONEXISTANT("message-remove-fixed-nonexistant"), - REMOVE_FIXED_NO_ARGS("message-remove-fixed-no-args"), - REMOVE_FIXED_INVALID_ARGS("message-remove-fixed-invalid-args"), - REMOVE_FIXED_SUCCESS("message-remove-fixed-success"), - LIST_FIXED_SUCCESS("message-list-fixed-success"), - LIST_FIXED_NONE("message-list-fixed-none"), - INFO_FIXED_NONEXISTANT("message-info-fixed-nonexistant"), - INFO_FIXED_NO_ARGS("message-info-fixed-no-args"), - INFO_FIXED_INVALID_ARGS("message-info-fixed-invalid-args"), - INFO_FIXED_INFO("message-info-fixed-info"), - CLEAR_FIXED_NO_PERMISSION("message-clear-no-permission"), - CLEAR_FIXED_NO_ARGS("message-clear-no-args"), - CLEAR_FIXED_INVALID_ARGS("message-clear-invalid-args"), - CLEAR_FIXED_SUCCESS("message-clear-success"), - NO_PERMISSION_FIXED("message-no-permission-fixed"), - MAX_FIXED_EFFECTS_REACHED("message-max-fixed-effects-reached"), - INVALID_FIXED_COMMAND("message-invalid-fixed-command"), + FIXED_COMMAND_DESC_CREATE("fixed-command-desc-create"), + FIXED_COMMAND_DESC_REMOVE("fixed-command-desc-remove"), + FIXED_COMMAND_DESC_LIST("fixed-command-desc-list"), + FIXED_COMMAND_DESC_INFO("fixed-command-desc-info"), + FIXED_COMMAND_DESC_CLEAR("fixed-command-desc-clear"), + CREATE_FIXED_MISSING_ARGS("create-fixed-missing-args"), + CREATE_FIXED_INVALID_COORDS("create-fixed-invalid-coords"), + CREATE_FIXED_OUT_OF_RANGE("create-fixed-out-of-range"), + CREATE_FIXED_INVALID_EFFECT("create-fixed-invalid-effect"), + CREATE_FIXED_NO_PERMISSION_EFFECT("create-fixed-no-permission-effect"), + CREATE_FIXED_INVALID_STYLE("create-fixed-invalid-style"), + CREATE_FIXED_NO_PERMISSION_STYLE("create-fixed-no-permission-style"), + CREATE_FIXED_NON_FIXABLE_STYLE("create-fixed-non-fixable-style"), + CREATE_FIXED_DATA_ERROR("create-fixed-data-error"), + CREATE_FIXED_SUCCESS("create-fixed-success"), + REMOVE_FIXED_NONEXISTANT("remove-fixed-nonexistant"), + REMOVE_FIXED_NO_ARGS("remove-fixed-no-args"), + REMOVE_FIXED_INVALID_ARGS("remove-fixed-invalid-args"), + REMOVE_FIXED_SUCCESS("remove-fixed-success"), + LIST_FIXED_SUCCESS("list-fixed-success"), + LIST_FIXED_NONE("list-fixed-none"), + INFO_FIXED_NONEXISTANT("info-fixed-nonexistant"), + INFO_FIXED_NO_ARGS("info-fixed-no-args"), + INFO_FIXED_INVALID_ARGS("info-fixed-invalid-args"), + INFO_FIXED_INFO("info-fixed-info"), + CLEAR_FIXED_NO_PERMISSION("clear-no-permission"), + CLEAR_FIXED_NO_ARGS("clear-no-args"), + CLEAR_FIXED_INVALID_ARGS("clear-invalid-args"), + CLEAR_FIXED_SUCCESS("clear-success"), + NO_PERMISSION_FIXED("no-permission-fixed"), + MAX_FIXED_EFFECTS_REACHED("max-fixed-effects-reached"), + INVALID_FIXED_COMMAND("invalid-fixed-command"), // GUI - GUI_DISABLED("message-gui-disabled"), - GUI_BY_DEFAULT("message-gui-by-default"), - GUI_BACK_BUTTON("message-gui-back-button"), - GUI_ICON_NAME_COLOR("message-gui-icon-name-color"), - GUI_ICON_CURRENT_ACTIVE("message-gui-icon-current-active"), - GUI_ICON_SETS_TO("message-gui-icon-sets-to"), - GUI_ICON_SET_YOUR("message-gui-icon-set-your"), - GUI_NO_ACCESS_TO("message-gui-no-access-to"), - GUI_NO_DATA("message-gui-no-data"), + GUI_DISABLED("gui-disabled"), + GUI_BY_DEFAULT("gui-by-default"), + GUI_BACK_BUTTON("gui-back-button"), + GUI_ICON_NAME_COLOR("gui-icon-name-color"), + GUI_ICON_CURRENT_ACTIVE("gui-icon-current-active"), + GUI_ICON_SETS_TO("gui-icon-sets-to"), + GUI_ICON_SET_YOUR("gui-icon-set-your"), + GUI_NO_ACCESS_TO("gui-no-access-to"), + GUI_NO_DATA("gui-no-data"), // Prefixes - USE("message-use"), - USAGE("message-usage"), - RESET("message-reset"), + USE("use"), + USAGE("usage"), + RESET("reset"), // Other - INVALID_ARGUMENTS("message-invalid-arguments"), - AVAILABLE_COMMANDS("message-available-commands"), - DISABLED_WORLDS_NONE("message-disabled-worlds-none"), - DISABLED_WORLDS("message-disabled-worlds"), - COMMAND_USAGE("message-command-usage"), - EXECUTED_FOR_PLAYER("message-executed-for-player"), - FAILED_EXECUTE_NOT_FOUND("message-failed-execute-not-found"), - FAILED_EXECUTE_NO_PERMISSION("message-failed-execute-no-permission"); + INVALID_ARGUMENTS("invalid-arguments"), + AVAILABLE_COMMANDS("available-commands"), + DISABLED_WORLDS_NONE("disabled-worlds-none"), + DISABLED_WORLDS("disabled-worlds"), + COMMAND_USAGE("command-usage"), + EXECUTED_FOR_PLAYER("executed-for-player"), + FAILED_EXECUTE_NOT_FOUND("failed-execute-not-found"), + FAILED_EXECUTE_NO_PERMISSION("failed-execute-no-permission"); private String fileLocation; private String message; - Lang(String fileLocation) { + private Lang(String fileLocation) { this.fileLocation = fileLocation; } @@ -143,7 +144,7 @@ public class LangManager { * * @param langFile The lang file to pull the message from */ - protected void setMessage(YamlConfiguration langFile) { + private void setMessage(YamlConfiguration langFile) { String langMessage = langFile.getString(this.fileLocation); if (langMessage == null) { langMessage = "&cMissing message in " + langFileName + ": " + this.fileLocation + ". Contact a server administrator."; @@ -157,19 +158,9 @@ public class LangManager { * * @return The message */ - public String get(String... replacements) { + private String get(String... replacements) { return String.format(this.message, (Object[]) replacements); } - - /** - * Gets the message this enum represents and replace {TYPE} with a replacement value - * - * @param replacement The text to replace {TYPE} with - * @return The message with {TYPE} replaced with the replacement value - */ - public String getMessageReplaced(String replacement) { - return this.message.replaceAll("\\{TYPE\\}", replacement); - } } /** @@ -193,8 +184,8 @@ public class LangManager { public static void setup() { FileConfiguration config = PlayerParticles.getPlugin().getConfig(); messagesEnabled = config.getBoolean("messages-enabled"); - prefixEnabled = config.getBoolean("use-message-prefix"); - messagePrefix = parseColors(config.getString("message-prefix")); + prefixEnabled = config.getBoolean("use-prefix"); + messagePrefix = parseColors(config.getString("prefix")); YamlConfiguration lang = configureLangFile(config); if (lang == null) { @@ -240,6 +231,16 @@ public class LangManager { return YamlConfiguration.loadConfiguration(targetLangFile); } + + /** + * Gets a formatted and replaced message + * + * @param messageType The message type to get + * @param replacements The replacements fot the message + */ + public static String getText(Lang messageType, String... replacements) { + return messageType.get(replacements); + } /** * Sends a message to the given player @@ -247,10 +248,11 @@ public class LangManager { * @param player The player to send the message to * @param messageType The message to send to the player */ - public static void sendMessage(Player player, Lang messageType) { + public static void sendMessage(Player player, Lang messageType, String... replacements) { if (!messagesEnabled) return; + + String message = messageType.get(replacements); - String message = messageType.get(); if (message.length() == 0) return; if (prefixEnabled) { @@ -268,39 +270,8 @@ public class LangManager { * @param pplayer The player to send the message to * @param messageType The message to send to the player */ - public static void sendMessage(PPlayer pplayer, Lang messageType) { - sendMessage(pplayer.getPlayer(), messageType); - } - - /** - * Sends a message to the given player and allows for replacing {TYPE} - * - * @param player The player to send the message to - * @param messageType The message to send to the player - * @param typeReplacement What {TYPE} should be replaced with - */ - public static void sendMessage(Player player, Lang messageType, String typeReplacement) { - if (!messagesEnabled) return; - - String message = messageType.getMessageReplaced(typeReplacement); - if (message.trim().length() == 0) return; - - if (prefixEnabled) { - message = messagePrefix + " " + message; - } - - player.sendMessage(message); - } - - /** - * Sends a message to the given PPlayer and allows for replacing {TYPE} - * - * @param pplayer The player to send the message to - * @param messageType The message to send to the player - * @param typeReplacement What {TYPE} should be replaced with - */ - public static void sendMessage(PPlayer pplayer, Lang messageType, String typeReplacement) { - sendMessage(pplayer.getPlayer(), messageType, typeReplacement); + public static void sendMessage(PPlayer pplayer, Lang messageType, String... replacements) { + sendMessage(pplayer, messageType, replacements); } /** diff --git a/src/lang/en_US.lang b/src/lang/en_US.lang index 8fd756c..78a8557 100644 --- a/src/lang/en_US.lang +++ b/src/lang/en_US.lang @@ -2,8 +2,8 @@ # en_US.lang MESSAGE CONFIGURATION # # Important Notes: # # * You can use the & symbol to color the messages # -# * {TYPE} Will be replaced with whatever that message requires # -# * You cannot use the apostrophe character! ( ' ) # +# * {#} Will be replaced with whatever that message requires # +# * If you use an apostrophe character it MUST be escaped! ( \' ) # # * PLEASE MAKE YOUR OWN .lang FILE IF YOU WANT CUSTOM MESSAGES! # # * This file will be overridden almost every plugin update! # # ================================================================ # @@ -14,28 +14,28 @@ # No Particle Permission # Default: '&cYou do not have permission to use &b{TYPE} &cparticles!' -message-no-permission: '&cYou do not have permission to use &b{TYPE} &cparticles!' +no-permission: '&cYou do not have permission to use &b{TYPE} &cparticles!' # /pp list No Particles # Default: '&cYou do not have permission to use any particles!' -message-no-particles: '&cYou do not have permission to use any particles!' +no-particles: '&cYou do not have permission to use any particles!' # Now Using Particles # Default: '&aNow using &b{TYPE} &aparticles!' -message-now-using: '&aNow using &b{TYPE} &aparticles!' +now-using: '&aNow using &b{TYPE} &aparticles!' # Cleared Particles # Default: '&aYour particles have been cleared!' -message-cleared-particles: '&aYour particles have been cleared!' +cleared-particles: '&aYour particles have been cleared!' -# Invalid Particle Type -# Default: '&cInvalid particle type! &b/pp effects' -message-invalid-type: '&cInvalid particle type! &b/pp effects &c| &b/pp effect ' +# Invalid Effect Type +# Default: '&cThe effect type {TYPE} does not exist. Use &b/pp effects&c for a list of effects you can use.' +invalid-effect: '&cThe effect type {TYPE} does not exist. Use &b/pp effects&c for a list of effects you can use.' # Particle Command Usage # You should not change the text here, only the coloring # Default: '&b/pp effect ' -message-particle-usage: '&b/pp effect ' +particle-usage: '&b/pp effect ' # -------------- # # Styles # @@ -43,28 +43,28 @@ message-particle-usage: '&b/pp effect ' # No Style Permission # Default: '&cYou do not have permission to use the style type &b{TYPE}&c!' -message-no-permission-style: '&cYou do not have permission to use the style type &b{TYPE}&c!' +no-permission-style: '&cYou do not have permission to use the style type &b{TYPE}&c!' # /pp styles No Styles # Default: '&cYou do not have permission to use any styles!' -message-no-styles: '&cYou do not have permission to use any styles!' +no-styles: '&cYou do not have permission to use any styles!' # Now Using Style # Default: '&aNow using the style type &b{TYPE}&a!' -message-now-using-style: '&aNow using the style type &b{TYPE}&a!' +now-using-style: '&aNow using the style type &b{TYPE}&a!' # Cleared Style # Default: '&aYour style has been cleared!' -message-cleared-style: '&aYour style has been cleared!' +cleared-style: '&aYour style has been cleared!' # Invalid Style Type # Default: '&cInvalid style type! &b/pp styles &c| &b/pp style ' -message-invalid-type-style: '&cInvalid style type! &b/pp styles &c| &b/pp style ' +invalid-type-style: '&cInvalid style type! &b/pp styles &c| &b/pp style ' # Style Command Usage # You should not change the text here, only the coloring # Default: '&b/pp style ' -message-style-usage: '&b/pp style ' +style-usage: '&b/pp style ' # ------------ # # Data # @@ -72,47 +72,47 @@ message-style-usage: '&b/pp style ' # Data Usage # Default: '&eYour current effect requires &b{TYPE} &edata!' -message-data-usage: '&eYour current effect requires &b{TYPE} &edata!' +data-usage: '&eYour current effect requires &b{TYPE} &edata!' # No Data Required # Default: '&eYour current effect does not use any data!' -message-no-data-usage: '&eYour current effect does not use any data!' +no-data-usage: '&eYour current effect does not use any data!' # Data Applied # Default: '&aYour &b{TYPE} &adata has been applied!' -message-data-applied: '&aYour &b{TYPE} &adata has been applied!' +data-applied: '&aYour &b{TYPE} &adata has been applied!' # Invalid Data Arguments # Default: '&cInvalid &b{TYPE} &cdata arguments!' -message-data-invalid-arguments: '&cInvalid &b{TYPE} &cdata arguments!' +data-invalid-arguments: '&cInvalid &b{TYPE} &cdata arguments!' # Unknown Material # Default: '&cThe {TYPE} name you supplied is invalid!' -message-data-material-unknown: '&cThe &b{TYPE} &cname you supplied is invalid!' +data-material-unknown: '&cThe &b{TYPE} &cname you supplied is invalid!' # Mismatched Material # Default: '&cThe material supplied is not of type &b{TYPE}&c!' -message-data-material-mismatch: '&cThe material supplied is not of type &b{TYPE}&c!' +data-material-mismatch: '&cThe material supplied is not of type &b{TYPE}&c!' # Note Data Usage # You should not change the text here, only the coloring # Default: '&b/pp data [<0-23>]|[rainbow]' -message-note-data-usage: '&b/pp data [<0-23>]|[rainbow]' +note-data-usage: '&b/pp data [<0-23>]|[rainbow]' # Color Data Usage # You should not change the text here, only the coloring # Default: '&b/pp data [<0-255> <0-255> <0-255>]|[rainbow]' -message-color-data-usage: '&b/pp data [<0-255> <0-255> <0-255>]|[rainbow]' +color-data-usage: '&b/pp data [<0-255> <0-255> <0-255>]|[rainbow]' # Item Data Usage # You should not change the text here, only the coloring # Default: '&b/pp data ' -message-item-data-usage: '&b/pp data ' +item-data-usage: '&b/pp data ' # Block Data Usage # You should not change the text here, only the coloring # Default: '&b/pp data ' -message-block-data-usage: '&b/pp data ' +block-data-usage: '&b/pp data ' # ---------------- # # Prefixes # @@ -120,19 +120,19 @@ message-block-data-usage: '&b/pp data ' # You Can Use Particles # Default: '&eYou can use:' -message-use: '&eYou can use:&b' +use: '&eYou can use:&b' # Usage # Default: '&eUsage:' -message-usage: '&eUsage:' +usage: '&eUsage:' # Available Commands # Default: '&eAvailable commands: &beffect, effects, style, styles, data, fixed, reset, gui, worlds, version, help' -message-available-commands: '&eAvailable commands: &beffect, effects, style, styles, data, fixed, reset, gui, worlds, version, help' +available-commands: '&eAvailable commands: &beffect, effects, style, styles, data, fixed, reset, gui, worlds, version, help' # Disabled Worlds # Default: '&eParticles are disabled in these worlds:&b' -message-disabled-worlds: '&eParticles are disabled in these worlds:&b' +disabled-worlds: '&eParticles are disabled in these worlds:&b' # ------------------ # # Alt. Execution @@ -140,15 +140,15 @@ message-disabled-worlds: '&eParticles are disabled in these worlds:&b' # Executed For Player # Default: '&aCommand executed for &b{TYPE}' -message-executed-for-player: '&aCommand executed for &b{TYPE}' +executed-for-player: '&aCommand executed for &b{TYPE}' # Failed Execute Not Found # Default: '&cFailed to execute command for &b{TYPE}&c! Player not found!' -message-failed-execute-not-found: '&cFailed to execute command for &b{TYPE}&c! Player not found!' +failed-execute-not-found: '&cFailed to execute command for &b{TYPE}&c! Player not found!' # Failed Execute No Permission # Default: '&cFailed to execute command for &b{TYPE}&c! You do not have permission!' -message-failed-execute-no-permission: '&cFailed to execute command for &b{TYPE}&c! You do not have permission!' +failed-execute-no-permission: '&cFailed to execute command for &b{TYPE}&c! You do not have permission!' # ----------------- # # Fixed Effects @@ -158,85 +158,85 @@ message-failed-execute-no-permission: '&cFailed to execute command for &b{TYPE}& # Missing Creation Arguments # Default: '&cUnable to create fixed effect, you are missing &b{TYPE} &crequired arguments!' -message-create-fixed-missing-args: '&cUnable to create fixed effect, you are missing &b{TYPE} &crequired arguments!' +create-fixed-missing-args: '&cUnable to create fixed effect, you are missing &b{TYPE} &crequired arguments!' # Invalid Coordinates # Default: '&cUnable to create fixed effect, one or more coordinates you entered is invalid!' -message-create-fixed-invalid-coords: '&cUnable to create fixed effect, one or more coordinates you entered is invalid!' +create-fixed-invalid-coords: '&cUnable to create fixed effect, one or more coordinates you entered is invalid!' # Coords Out Of Range # Default: '&cUnable to create fixed effect, you must be within &b{TYPE}&c blocks of your desired location!' -message-create-fixed-out-of-range: '&cUnable to create fixed effect, you must be within &b{TYPE}&c blocks of your desired location!' +create-fixed-out-of-range: '&cUnable to create fixed effect, you must be within &b{TYPE}&c blocks of your desired location!' # Invalid Effect # Default: '&cUnable to create fixed effect, an effect with the name &b{TYPE} &cdoes not exist!' -message-create-fixed-invalid-effect: '&cUnable to create fixed effect, an effect with the name &b{TYPE} &cdoes not exist!' +create-fixed-invalid-effect: '&cUnable to create fixed effect, an effect with the name &b{TYPE} &cdoes not exist!' # No Permission Effect # Default: '&cUnable to create fixed effect, you do not have permission to use the effect &b{TYPE}&c!' -message-create-fixed-no-permission-effect: '&cUnable to create fixed effect, you do not have permission to use the effect &b{TYPE}&c!' +create-fixed-no-permission-effect: '&cUnable to create fixed effect, you do not have permission to use the effect &b{TYPE}&c!' # Invalid Style # Default: '&cUnable to create fixed effect, a style with the name &b{TYPE} &cdoes not exist!' -message-create-fixed-invalid-style: '&cUnable to create fixed effect, a style with the name &b{TYPE} &cdoes not exist!' +create-fixed-invalid-style: '&cUnable to create fixed effect, a style with the name &b{TYPE} &cdoes not exist!' # No Permission Style # Default: '&cUnable to create fixed effect, you do not have permission to use the style &b{TYPE}&c!' -message-create-fixed-no-permission-style: '&cUnable to create fixed effect, you do not have permission to use the style &b{TYPE}&c!' +create-fixed-no-permission-style: '&cUnable to create fixed effect, you do not have permission to use the style &b{TYPE}&c!' # Style Not Fixable # Default: '&cThe style &b{TYPE} &cprovided can not be used in fixed effects!' -message-create-fixed-non-fixable-style: '&cThe style &b{TYPE} &ccan not be used in fixed effects!' +create-fixed-non-fixable-style: '&cThe style &b{TYPE} &ccan not be used in fixed effects!' # Data Error # Default: '&cUnable to create fixed effect, the data provided is not correct! This effect requires &b{TYPE}&c!' -message-create-fixed-data-error: '&cUnable to create fixed effect, the data provided is not correct! This effect requires &b{TYPE}&c data!' +create-fixed-data-error: '&cUnable to create fixed effect, the data provided is not correct! This effect requires &b{TYPE}&c data!' # Creation Success # Default: '&aYour fixed effect has been created!' -message-create-fixed-success: '&aYour fixed effect has been created!' +create-fixed-success: '&aYour fixed effect has been created!' # -- Remove -- # # Could Not Remove # Default: '&cUnable to remove, you do not have a fixed effect with the id of &b{TYPE}&c!' -message-remove-fixed-nonexistant: '&cUnable to remove, you do not have a fixed effect with the id of &b{TYPE}&c!' +remove-fixed-nonexistant: '&cUnable to remove, you do not have a fixed effect with the id of &b{TYPE}&c!' # No Args Remove # Default: '&cYou did not specify an id to remove!' -message-remove-fixed-no-args: '&cYou did not specify an id to remove!' +remove-fixed-no-args: '&cYou did not specify an id to remove!' # Invalid Args Remove # Default: '&cUnable to remove, the id specified must be a number!' -message-remove-fixed-invalid-args: '&cUnable to remove, the id specified must be a number!' +remove-fixed-invalid-args: '&cUnable to remove, the id specified must be a number!' # Effect Removed # Default: '&aYour fixed effect with the id &b{TYPE}&a has been removed!' -message-remove-fixed-success: '&aYour fixed effect with the id &b{TYPE}&a has been removed!' +remove-fixed-success: '&aYour fixed effect with the id &b{TYPE}&a has been removed!' # -- List -- # # List Success # Default: '&eYou have fixed effects with these ids: &b' -message-list-fixed-success: '&eYou have fixed effects with these ids: &b' +list-fixed-success: '&eYou have fixed effects with these ids: &b' # List None # Default: '&eYou do not have any fixed effects!' -message-list-fixed-none: '&eYou do not have any fixed effects!' +list-fixed-none: '&eYou do not have any fixed effects!' # -- Info -- # # Could Not Get Info # Default: '&cUnable to get info, you do not have a fixed effect with the id of &b{TYPE}&c!' -message-info-fixed-nonexistant: '&cUnable to get info, you do not have a fixed effect with the id of &b{TYPE}&c!' +info-fixed-nonexistant: '&cUnable to get info, you do not have a fixed effect with the id of &b{TYPE}&c!' # No Args Info # Default: '&cYou did not specify an id to display info for!' -message-info-fixed-no-args: '&cYou did not specify an id to display info for!' +info-fixed-no-args: '&cYou did not specify an id to display info for!' # Invalid Args Info # Default: '&cUnable to get info, the id specified must be a number!' -message-info-fixed-invalid-args: '&cUnable to get info, the id specified must be a number!' +info-fixed-invalid-args: '&cUnable to get info, the id specified must be a number!' # Fixed Effect Info # Key: @@ -249,64 +249,64 @@ message-info-fixed-invalid-args: '&cUnable to get info, the id specified must be # {6} = Style Name # {7} = Data # Default: '&eID: &b{0} &eWorld: &b{1} &eX: &b{2} &eY: &b{3} &eZ: &b{4} &eEffect: &b{5} &eStyle: &b{6} &eData: &b{7}' -message-info-fixed-info: '&eID: &b{0} &eWorld: &b{1} &eX: &b{2} &eY: &b{3} &eZ: &b{4} &eEffect: &b{5} &eStyle: &b{6} &eData: &b{7}' +info-fixed-info: '&eID: &b{0} &eWorld: &b{1} &eX: &b{2} &eY: &b{3} &eZ: &b{4} &eEffect: &b{5} &eStyle: &b{6} &eData: &b{7}' # -- Clear -- # # No Permission Clear # Default: '&cYou do not have permission to clear fixed effects of other players!' -message-clear-no-permission: '&cYou do not have permission to clear fixed effects of other players!' +clear-no-permission: '&cYou do not have permission to clear fixed effects of other players!' # No Arguments Clear # Default: '&cYou did not provide a radius to clear fixed effects for!' -message-clear-no-args: '&cYou did not provide a radius to clear fixed effects for!' +clear-no-args: '&cYou did not provide a radius to clear fixed effects for!' # Invalid Arguments Clear # Default: '&cThe radius you provided is invalid. Make sure it is a positive whole number!' -message-clear-invalid-args: '&cThe radius you provided is invalid. Make sure it is a positive whole number!' +clear-invalid-args: '&cThe radius you provided is invalid. Make sure it is a positive whole number!' # Successfully Cleared # Key: # {0} = Number of effects cleared # {1} = The provided radius # Default: '&aCleared &b{0} &afixed effects within &b{1} &ablocks of your location!' -message-clear-success: '&aCleared &b{0} &afixed effects within &b{1} &ablocks of your location!' +clear-success: '&aCleared &b{0} &afixed effects within &b{1} &ablocks of your location!' # -- Other -- # # No Permission Fixed # Default: '&cYou do not have permission to use fixed effects!' -message-no-permission-fixed: '&cYou do not have permission to use fixed effects!' +no-permission-fixed: '&cYou do not have permission to use fixed effects!' # Reached Max Allowed # Default: '&cYou have reached the maximum allowed fixed effects!' -message-max-fixed-effects-reached: '&cYou have reached the maximum allowed fixed effects!' +max-fixed-effects-reached: '&cYou have reached the maximum allowed fixed effects!' # Invalid Fixed Command # Default: '&cInvalid sub-command for &b/pp fixed&c!' -message-invalid-fixed-command: '&cInvalid subcommand for &b/pp fixed&c! &eCommands: ' +invalid-fixed-command: '&cInvalid subcommand for &b/pp fixed&c! &eCommands: ' # -- Command Descriptions -- # # Fixed Command Description For Create # Default '&e/pp fixed create