/pp remove finished

This commit is contained in:
Esophose 2018-10-07 16:33:13 -06:00
parent 7876079ca4
commit 6fb22e16c7
14 changed files with 142 additions and 94 deletions

View file

@ -12,7 +12,7 @@ public class DefaultCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
// The default command just opens the GUI, execute the GUICommandModule
ParticleCommandHandler.findMatchingCommand("gui").onCommandExecute(pplayer, args);
ParticleCommandHandler.findMatchingCommand("gui").onCommandExecute(pplayer, new String[] { "byDefault" });
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {

View file

@ -5,10 +5,9 @@ import java.util.List;
import org.bukkit.entity.Player;
import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.particles.ParticleEffect;
public class EffectsCommandModule implements CommandModule {
@ -16,18 +15,16 @@ public class EffectsCommandModule implements CommandModule {
Player p = pplayer.getPlayer();
List<String> effectList = PermissionManager.getEffectsUserHasPermissionFor(p);
if (effectList.size() == 1) {
LangManager.sendMessage(p, Lang.EFFECT_LIST, effectList.get(0));
if (effectList.isEmpty()) {
LangManager.sendMessage(p, Lang.EFFECT_LIST_EMPTY);
return;
}
String toSend = "";
for (ParticleEffect effect : ParticleEffect.getSupportedEffects()) {
if (PermissionManager.hasEffectPermission(p, effect)) {
toSend += effect.getName() + ", ";
continue;
}
for (String name : effectList) {
toSend += name + ", ";
}
if (toSend.endsWith(", ")) {
toSend = toSend.substring(0, toSend.length() - 2);
}

View file

@ -237,7 +237,7 @@ public class FixedCommandModule implements CommandModule {
return;
}
String msg = LangManager.getText(Lang.FIXED_LIST_SUCCESS);
String msg = "";
boolean first = true;
for (int id : ids) {
if (!first) msg += ", ";
@ -245,7 +245,7 @@ public class FixedCommandModule implements CommandModule {
msg += id;
}
LangManager.sendCustomMessage(p, msg);
LangManager.sendMessage(p, Lang.FIXED_LIST_SUCCESS, msg);
} else if (cmd.equalsIgnoreCase("info")) {
if (args.length < 1) {
LangManager.sendMessage(p, Lang.FIXED_INFO_NO_ARGS);

View file

@ -26,7 +26,7 @@ public class GUICommandModule implements CommandModule {
return;
}
if (PermissionManager.getEffectsUserHasPermissionFor(pplayer.getPlayer()).size() == 1) {
if (PermissionManager.getEffectsUserHasPermissionFor(pplayer.getPlayer()).isEmpty()) {
if (byDefault) {
LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_UNKNOWN);
} else {

View file

@ -8,6 +8,7 @@ import com.esophose.playerparticles.particles.PPlayer;
public class HelpCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
// TODO: Add pages, there are a lot of commands
List<CommandModule> cmds = ParticleCommandHandler.getCommands();
for (CommandModule cmd : cmds) {
CommandModule.printUsageWithDescription(pplayer, cmd);

View file

@ -1,34 +0,0 @@
package com.esophose.playerparticles.command;
import java.util.List;
import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.particles.PPlayer;
public class InfoCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
return null;
}
public String getName() {
return "info";
}
public Lang getDescription() {
return Lang.COMMAND_DESCRIPTION_INFO;
}
public String getArguments() {
return "<id>";
}
public boolean requiresEffects() {
return true;
}
}

View file

@ -2,13 +2,29 @@ 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;
import com.esophose.playerparticles.particles.ParticlePair;
public class ListCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
List<ParticlePair> particles = pplayer.getActiveParticles();
if (particles.isEmpty()) {
LangManager.sendMessage(pplayer, Lang.COMMAND_LIST_NONE);
return;
}
LangManager.sendMessage(pplayer, Lang.COMMAND_LIST_YOU_HAVE);
for (ParticlePair particle : particles) {
int id = particle.getId();
String effect = particle.getEffect().getName();
String style = particle.getStyle().getName();
String data = particle.getDataString();
LangManager.sendMessage(pplayer, Lang.COMMAND_LIST_OUTPUT, id, effect, style, data);
}
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {

View file

@ -35,7 +35,6 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
commands.add(new GroupCommandModule());
commands.add(new GUICommandModule());
commands.add(new HelpCommandModule());
commands.add(new InfoCommandModule());
commands.add(new ListCommandModule());
commands.add(new RemoveCommandModule());
commands.add(new ResetCommandModule());
@ -98,7 +97,7 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
CommandModule commandModule = findMatchingCommand(commandName);
if (commandModule != null) {
if (commandModule.requiresEffects() && PermissionManager.getEffectsUserHasPermissionFor(p).size() == 1) {
if (commandModule.requiresEffects() && PermissionManager.getEffectsUserHasPermissionFor(p).isEmpty()) {
LangManager.sendMessage(p, Lang.COMMAND_ERROR_NO_EFFECTS);
} else {
String[] cmdArgs = new String[0];

View file

@ -1,18 +1,68 @@
package com.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.util.StringUtil;
import com.esophose.playerparticles.manager.DataManager;
import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.particles.ParticleGroup;
import com.esophose.playerparticles.particles.ParticlePair;
public class RemoveCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) {
if (args.length == 0) {
LangManager.sendMessage(pplayer, Lang.COMMAND_REMOVE_NO_ARGS);
return;
}
int id = -1;
try {
id = Integer.parseInt(args[0]);
} catch (Exception ex) {
LangManager.sendMessage(pplayer, Lang.COMMAND_REMOVE_ARGS_INVALID);
return;
}
if (id <= 0) {
LangManager.sendMessage(pplayer, Lang.COMMAND_REMOVE_ARGS_INVALID);
return;
}
boolean removed = false;
ParticleGroup activeGroup = pplayer.getActiveParticleGroup();
for (ParticlePair particle : activeGroup.getParticles()) {
if (particle.getId() == id) {
activeGroup.getParticles().remove(particle);
removed = true;
break;
}
}
if (!removed) {
LangManager.sendMessage(pplayer, Lang.COMMAND_REMOVE_INVALID_ID, id);
return;
}
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
LangManager.sendMessage(pplayer, Lang.COMMAND_REMOVE_SUCCESS, id);
}
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
return null;
List<String> matches = new ArrayList<String>();
List<String> ids = new ArrayList<String>();
for (ParticlePair particles : pplayer.getActiveParticles())
ids.add(String.valueOf(particles.getId()));
if (args.length == 0) return ids;
StringUtil.copyPartialMatches(args[0], ids, matches);
return matches;
}
public String getName() {

View file

@ -5,11 +5,9 @@ import java.util.List;
import org.bukkit.entity.Player;
import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.styles.api.ParticleStyle;
import com.esophose.playerparticles.styles.api.ParticleStyleManager;
public class StylesCommandModule implements CommandModule {
@ -17,18 +15,11 @@ public class StylesCommandModule implements CommandModule {
Player p = pplayer.getPlayer();
List<String> styleNames = PermissionManager.getStylesUserHasPermissionFor(p);
if (styleNames.size() == 1) {
LangManager.sendMessage(pplayer, Lang.STYLE_LIST, styleNames.get(0));
return;
String toSend = "";
for (String name : styleNames) {
toSend += name + ", ";
}
String toSend = "";
for (ParticleStyle style : ParticleStyleManager.getStyles()) {
if (PermissionManager.hasStylePermission(p, style)) {
toSend += style.getName();
toSend += ", ";
}
}
if (toSend.endsWith(", ")) {
toSend = toSend.substring(0, toSend.length() - 2);
}

View file

@ -404,7 +404,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
public static void changeState(PPlayer pplayer, GuiState state) {
Player player = pplayer.getPlayer();
if ((state == GuiState.EFFECT && PermissionManager.getEffectsUserHasPermissionFor(player).size() == 1) || (state == GuiState.STYLE && PermissionManager.getStylesUserHasPermissionFor(player).size() == 1) || (state == GuiState.DATA && getPPlayerSpawnMaterial(pplayer) == null && getPPlayerSpawnColor(pplayer) == null)) return;
if ((state == GuiState.EFFECT && PermissionManager.getEffectsUserHasPermissionFor(player).isEmpty()) || (state == GuiState.STYLE && PermissionManager.getStylesUserHasPermissionFor(player).size() == 1) || (state == GuiState.DATA && getPPlayerSpawnMaterial(pplayer) == null && getPPlayerSpawnColor(pplayer) == null)) return;
// Update the state and create an inventory for the player if one isn't already open for them
// If they have the wrong inventory open for some reason, create a new one and open it for them
@ -470,7 +470,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
ItemMeta effectIconMeta = effectIcon.getItemMeta();
effectIconMeta.setDisplayName(ChatColor.GREEN + "Effect");
effectIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SET_YOUR, "effect")));
if (PermissionManager.getEffectsUserHasPermissionFor(player).size() == 1) { // Always has access to NONE
if (PermissionManager.getEffectsUserHasPermissionFor(player).isEmpty()) {
effectIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_NO_ACCESS_TO, "effects")));
}
effectIcon.setItemMeta(effectIconMeta);
@ -479,7 +479,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
ItemMeta styleIconMeta = styleIcon.getItemMeta();
styleIconMeta.setDisplayName(ChatColor.GREEN + "Style");
styleIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_ICON_SET_YOUR, "style")));
if (PermissionManager.getStylesUserHasPermissionFor(player).size() == 1) { // Always has access to NONE
if (PermissionManager.getStylesUserHasPermissionFor(player).size() == 1) { // Always has access to NORMAL
styleIconMeta.setLore(Arrays.asList(LangManager.getText(Lang.GUI_NO_ACCESS_TO, "styles")));
}
styleIcon.setItemMeta(styleIconMeta);

View file

@ -55,6 +55,8 @@ public class LangManager {
COMMAND_DESCRIPTION_GROUP_SAVE,
COMMAND_DESCRIPTION_GROUP_LOAD,
COMMAND_DESCRIPTION_GROUP_REMOVE,
COMMAND_DESCRIPTION_GROUP_LIST,
COMMAND_DESCRIPTION_GROUP_INFO,
// Add Command
COMMAND_ADD_PARTICLE_APPLIED,
@ -62,6 +64,17 @@ public class LangManager {
// Data Command
COMMAND_DATA_NO_ARGS,
// Remove Command
COMMAND_REMOVE_NO_ARGS,
COMMAND_REMOVE_ARGS_INVALID,
COMMAND_REMOVE_INVALID_ID,
COMMAND_REMOVE_SUCCESS,
// List Command
COMMAND_LIST_NONE,
COMMAND_LIST_YOU_HAVE,
COMMAND_LIST_OUTPUT,
// Rainbow
RAINBOW,
@ -69,6 +82,7 @@ public class LangManager {
EFFECT_NO_PERMISSION,
EFFECT_INVALID,
EFFECT_LIST,
EFFECT_LIST_EMPTY,
// Styles
STYLE_NO_PERMISSION,

View file

@ -9,56 +9,70 @@
# ================================================================ #
# Command Errors
command-error-no-effects: '&cYou must have access to effects to use this command.'
command-error-no-effects: '&cYou must have access to effects to use this command!'
command-error-unknown: '&cUnknown command, use &b/pp help &cfor a list of commands.'
# Command Descriptions
command-description-add: 'Add a particle to your active particles'
command-description-data: 'Check what type of data an effect uses'
command-description-default: 'The main command. By default, opens the GUI.'
command-description-default: 'The main command. By default, opens the GUI'
command-description-edit: 'Edit the effect, style, or data of an active particle'
command-description-effect: '&cThis command has been removed, use &b/pp help &cto find new commands'
command-description-effects: 'Display a list of effects you can use'
command-description-fixed: 'Create, edit, and remove fixed particle effects'
command-description-group: 'Save, load, and remove your particle groups'
command-description-gui: 'Display the GUI for easy editing of particles'
command-description-help: 'Displays the help menu... You have arrived.'
command-description-help: 'Displays the help menu... You have arrived'
command-description-info: 'Gets the description of one of your active particles'
command-description-list: 'Lists the ids of your active particles'
command-description-list: 'Lists the IDs of your active particles'
command-description-remove: 'Removes one of your active particles'
command-description-reset: 'Removes all your active particles'
command-description-style: '&cThis command has been removed, use &b/pp help &cto find new commands'
command-description-styles: 'Display a list of styles you can use'
command-description-version: 'Display the current version of the plugin and the author'
command-description-worlds: 'Find out what worlds particles is disabled in'
command-description-worlds: 'Find out what worlds particles are disabled in'
# Sub-Command Usage
command-description-fixed-create: '&e/pp fixed create <x> <y> <z> <effect> <style> [data] - Creates a new fixed effect'
command-description-fixed-remove: '&e/pp fixed remove <id> - Removes a fixed effect by its id'
command-description-fixed-list: '&e/pp fixed list - Lists all ids of your fixed effects'
command-description-fixed-info: '&e/pp fixed info <id> - Gets info on one of your fixed effects'
command-description-fixed-remove: '&e/pp fixed remove <ID> - Removes a fixed effect by its ID'
command-description-fixed-list: '&e/pp fixed list - Lists all IDs of your fixed effects'
command-description-fixed-info: '&e/pp fixed info <ID> - Gets info on one of your fixed effects'
command-description-fixed-clear: '&e/pp fixed clear <radius> - Clears all fixed effects of all players within the given radius'
command-description-group-save: '&e/pp group save <name> - Saves all currently applied particles under a given name'
command-description-group-load: '&e/pp group load <name> - Loads all particles saved under a given name'
command-description-group-remove: '&e/pp group remove <name> - Removes all particles saved under a given name'
command-description-group-save: '&e/pp group save <name> - Saves all active particles in a new group'
command-description-group-load: '&e/pp group load <name> - Loads all particles saved in a group'
command-description-group-remove: '&e/pp group remove <name> - Removes a group you have saved'
command-description-group-list: '&e/pp group list <name> - List all particle groups you have saved'
command-description-group-info: '&e/pp group info <name> - List the particles saved in the group'
# Add Command
command-add-particle-applied: '&aA new particle has been applied with the effect &b{0}&a, style &b{1}&a, and data &b{2}&a!'
# Data Command
command-data-no-args: '&cMissing argument for effect. Command usage: &b/pp data <effect>'
command-data-no-args: '&cMissing argument for effect! Command usage: &b/pp data <effect>'
# Remove Command
command-remove-no-args: '&cYou did not specify an ID to remove! &b/pp remove <ID>'
command-remove-args-invalid: '&cThe ID you entered is invalid, it must be a positive whole number!'
command-remove-invalid-id: '&cYou do not have a particle applied with the ID &b{0}&c!'
command-remove-success: '&aYour particle with the ID &b{0} &ahas been removed!'
# List Command
command-list-none: '&eYou do not have any active particles!'
command-list-you-have: '&eYou have the following particles applied:'
command-list-output: '&eID: &b{0} &eEffect: &b{1} &eStyle: &b{2} &eData: &b{3}'
# Rainbow
rainbow: '&cr&6a&ei&an&bb&9o&dw'
# Effects
effect-no-permission: '&cYou do not have permission to use the effect &b{0} &c!'
effect-invalid: '&cThe effect &b{0} &cdoes not exist. Use &b/pp effects &cfor a list of effects you can use.'
effect-invalid: '&cThe effect &b{0} &cdoes not exist! Use &b/pp effects &cfor a list of effects you can use.'
effect-list: '&eYou can use the following effects: &b{0}'
effect-list-empoty: '&cYou do not have permission to use any effects!'
# Styles
style-no-permission: '&cYou do not have permission to use the style &b{0} &c!'
style-invalid: '&cThe style &b{0} &cdoes not exist. Use &b/pp styles &cfor a list of styles you can use.'
style-invalid: '&cThe style &b{0} &cdoes not exist! Use &b/pp styles &cfor a list of styles you can use.'
style-list: '&eYou can use the following styles: &b{0}'
# Data
@ -78,7 +92,7 @@ data-invalid-material-block: '&cThe &bblock &cmaterial &b{0} you entered does no
# Worlds
disabled-worlds: '&eParticles are disabled in these worlds: &b{0}'
disabled-worlds-none: '&eParticles are not disabled in any worlds!'
disabled-worlds-none: '&eParticles are not disabled in any worlds.'
# Reset
reset-success: '&aRemoved &b{0} &aactive particle(s)!'
@ -94,26 +108,26 @@ fixed-create-style-no-permission: '&cUnable to create fixed effect, you do not h
fixed-create-style-non-fixable: '&cThe style &b{0} &ccan not be used in fixed effects!'
fixed-create-data-error: '&cUnable to create fixed effect, the data provided is not correct! Use &b/pp data <effect> &cto find the correct data format!'
fixed-create-success: '&aYour fixed effect has been created!'
fixed-remove-invalid: '&cUnable to remove fixed effect, you do not have a fixed effect with the id of &b{0}&c!'
fixed-remove-no-args: '&cYou did not specify an id to remove!'
fixed-remove-args-invalid: '&cUnable to remove, the id specified must be a number!'
fixed-remove-success: '&aYour fixed effect with the id &b{0} &ahas been removed!'
fixed-remove-invalid: '&cUnable to remove fixed effect, you do not have a fixed effect with the ID of &b{0}&c!'
fixed-remove-no-args: '&cYou did not specify an ID to remove!'
fixed-remove-args-invalid: '&cUnable to remove, the ID specified must be a number!'
fixed-remove-success: '&aYour fixed effect with the ID &b{0} &ahas been removed!'
fixed-list-none: '&eYou do not have any fixed effects!'
fixed-list-success: '&eYou have fixed effects with these ids: &b{0}'
fixed-info-invalid: '&cUnable to get info, you do not have a fixed effect with the id of &b{0}&c!'
fixed-info-no-args: '&cYou did not specify an id to display info for!'
fixed-info-invalid-args: '&cUnable to get info, the id specified must be a number!'
fixed-list-success: '&eYou have fixed effects with these IDs: &b{0}'
fixed-info-invalid: '&cUnable to get info, you do not have a fixed effect with the ID of &b{0}&c!'
fixed-info-no-args: '&cYou did not specify an ID to display info for!'
fixed-info-invalid-args: '&cUnable to get info, the ID specified must be a number!'
fixed-info-success: '&eID: &b{0} &eWorld: &b{1} &eX: &b{2} &eY: &b{3} &eZ: &b{4} &eEffect: &b{5} &eStyle: &b{6} &eData: &b{7}'
fixed-clear-no-permission: '&cYou do not have permission to clear nearby fixed effects!'
fixed-clear-no-args: '&cYou did not provide a radius to clear fixed effects for!'
fixed-clear-invalid-args: '&cThe radius you provided is invalid. Make sure it is a positive whole number!'
fixed-clear-invalid-args: '&cThe radius you provided is invalid, it must be a positive whole number!'
fixed-clear-success: '&aCleared &b{0} &afixed effects within &b{1} &ablocks of your location!'
fixed-no-permission: '&cYou do not have permission to use fixed effects!'
fixed-max-reached: '&cYou have reached the maximum allowed fixed effects!'
fixed-invalid-command: '&cInvalid sub-command for &b/pp fixed&c!'
# GUI
gui-disabled: '&cThe server administrator has disabled the GUI.'
gui-disabled: '&cThe server administrator has disabled the GUI!'
gui-by-default: '&eWe opened the GUI for you because you did not specify a command. View other commands with &b/pp help&e or use &b/pp gui&e to avoid this message.'
gui-back-button: '&eGo Back'
gui-icon-name-color: '&a'