/pp data finished, change some wording, remove debug output

This commit is contained in:
Esophose 2018-10-06 13:53:31 -06:00
parent 15a1d9c74e
commit e637e7591e
14 changed files with 91 additions and 184 deletions

View file

@ -1,6 +1,5 @@
/* /*
* TODO: v5.3 * TODO: v5.3
* + Command to force set an effect/style for a player
* + Add new style 'tornado' * + Add new style 'tornado'
* + Add new style 'companion' * + Add new style 'companion'
* + Add new style 'atom' * + Add new style 'atom'

View file

@ -1,7 +1,6 @@
package com.esophose.playerparticles.command; package com.esophose.playerparticles.command;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
@ -133,7 +132,7 @@ public class AddCommandModule implements CommandModule {
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
Player p = pplayer.getPlayer(); Player p = pplayer.getPlayer();
List<String> matches = new ArrayList<String>(); List<String> matches = new ArrayList<String>();
System.out.println("Args in AddCommandModule: " + Arrays.toString(args) + " " + args.length);
if (args.length <= 1) { // Effect name if (args.length <= 1) { // Effect name
if (args.length == 0) matches = PermissionManager.getEffectsUserHasPermissionFor(p); if (args.length == 0) matches = PermissionManager.getEffectsUserHasPermissionFor(p);
else StringUtil.copyPartialMatches(args[0], PermissionManager.getEffectsUserHasPermissionFor(p), matches); else StringUtil.copyPartialMatches(args[0], PermissionManager.getEffectsUserHasPermissionFor(p), matches);

View file

@ -1,9 +1,13 @@
package com.esophose.playerparticles.command; package com.esophose.playerparticles.command;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.util.StringUtil;
import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.LangManager.Lang; import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.particles.PPlayer; import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.particles.ParticleEffect; import com.esophose.playerparticles.particles.ParticleEffect;
import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
@ -13,31 +17,38 @@ public class DataCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) { public void onCommandExecute(PPlayer pplayer, String[] args) {
if (args.length > 0) { if (args.length > 0) {
ParticleEffect effect = ParticleEffect.fromName(args[0]); ParticleEffect effect = ParticleEffect.fromName(args[0]);
if (effect == null) {
LangManager.sendMessage(pplayer, Lang.EFFECT_INVALID, args[0]);
return;
}
if ((!effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA) && !effect.hasProperty(ParticleProperty.COLORABLE)) || args.length == 0) {
if (effect.hasProperty(ParticleProperty.COLORABLE)) { if (effect.hasProperty(ParticleProperty.COLORABLE)) {
if (effect == ParticleEffect.NOTE) { if (effect == ParticleEffect.NOTE) {
LangManager.sendMessage(pplayer, Lang.DATA_USAGE_NOTE); LangManager.sendMessage(pplayer, Lang.DATA_USAGE_NOTE, effect.getName());
} else { } else {
LangManager.sendMessage(pplayer, Lang.DATA_USAGE_COLOR); LangManager.sendMessage(pplayer, Lang.DATA_USAGE_COLOR, effect.getName());
} }
} else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (effect == ParticleEffect.ITEM) { if (effect == ParticleEffect.ITEM) {
LangManager.sendMessage(pplayer, Lang.DATA_USAGE_ITEM); LangManager.sendMessage(pplayer, Lang.DATA_USAGE_ITEM, effect.getName());
} else { } else {
LangManager.sendMessage(pplayer, Lang.DATA_USAGE_BLOCK); LangManager.sendMessage(pplayer, Lang.DATA_USAGE_BLOCK, effect.getName());
} }
} else { } else {
LangManager.sendMessage(pplayer, Lang.DATA_USAGE_NONE); LangManager.sendMessage(pplayer, Lang.DATA_USAGE_NONE, effect.getName());
}
} }
} else { } else {
LangManager.sendMessage(pplayer, Lang.EFFECT_INVALID); LangManager.sendMessage(pplayer, Lang.COMMAND_DATA_NO_ARGS);
} }
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {
return null; List<String> matches = new ArrayList<String>();
if (args.length <= 1) {
if (args.length == 0) matches = PermissionManager.getEffectsUserHasPermissionFor(pplayer.getPlayer());
else StringUtil.copyPartialMatches(args[0], PermissionManager.getEffectsUserHasPermissionFor(pplayer.getPlayer()), matches);
}
return matches;
} }
public String getName() { public String getName() {

View file

@ -36,7 +36,6 @@ public class FixedCommandModule implements CommandModule {
} }
if (args.length == 0) { // General information on command if (args.length == 0) { // General information on command
LangManager.sendMessage(p, Lang.FIXED_INVALID_COMMAND);
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_CREATE); LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_CREATE);
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_REMOVE); LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_REMOVE);
LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_LIST); LangManager.sendMessage(p, Lang.COMMAND_DESCRIPTION_FIXED_LIST);

View file

@ -113,11 +113,6 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
return true; return true;
} }
// private static final String[] COMMANDS = { "help", "gui", "effect", "effects", "style", "styles", "data", "fixed", "reset", "worlds", "version" };
// private static final String[] FIXED_COMMANDS = { "create", "remove", "list", "info" };
// private static final List<String> BLOCK_MATERIALS = ParticleUtils.getAllBlockMaterials();
// private static final List<String> ITEM_MATERIALS = ParticleUtils.getAllItemMaterials();
/** /**
* Activated when a user pushes tab in chat prefixed with /pp * Activated when a user pushes tab in chat prefixed with /pp
* *
@ -131,7 +126,6 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
if (!(sender instanceof Player)) return new ArrayList<String>(); if (!(sender instanceof Player)) return new ArrayList<String>();
if (cmd.getName().equalsIgnoreCase("pp")) { if (cmd.getName().equalsIgnoreCase("pp")) {
System.out.println("Args in onTabComplete: " + Arrays.toString(args) + " " + args.length);
if (args.length <= 1) { if (args.length <= 1) {
CommandModule commandModule = findMatchingCommand(""); // Get the default command module CommandModule commandModule = findMatchingCommand(""); // Get the default command module
return commandModule.onTabComplete(DataManager.getPPlayer(((Player) sender).getUniqueId()), args); return commandModule.onTabComplete(DataManager.getPPlayer(((Player) sender).getUniqueId()), args);
@ -141,57 +135,9 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
if (commandModule != null) { if (commandModule != null) {
return commandModule.onTabComplete(DataManager.getPPlayer(((Player) sender).getUniqueId()), cmdArgs); return commandModule.onTabComplete(DataManager.getPPlayer(((Player) sender).getUniqueId()), cmdArgs);
} }
// TODO: Move to correct CommandModules
// if (args[0].equalsIgnoreCase("effect") && args.length == 2) {
// List<String> commands = PermissionManager.getEffectsUserHasPermissionFor((Player) sender);
// StringUtil.copyPartialMatches(args[1], commands, completions);
// } else if (args[0].equalsIgnoreCase("style") && args.length == 2) {
// List<String> commands = PermissionManager.getStylesUserHasPermissionFor((Player) sender);
// StringUtil.copyPartialMatches(args[1], commands, completions);
// } else if (args[0].equalsIgnoreCase("fixed") && args.length > 1) {
// if (args.length == 2) {
// List<String> commands = Arrays.asList(FIXED_COMMANDS);
// StringUtil.copyPartialMatches(args[1], commands, completions);
// } else if (args[1].equalsIgnoreCase("create")) {
// completions.add("<x> <y> <z> <effect> <style> [data]");
// } else if ((args[1].equalsIgnoreCase("remove") || args[1].equalsIgnoreCase("info")) && args.length == 3) {
// completions.add("<id>");
// }
// } else if (args[0].equalsIgnoreCase("data")) {
// PPlayer pplayer = DataManager.getPPlayer(((Player) sender).getUniqueId());
// if (pplayer == null) {
// completions.add(ChatColor.stripColor(Lang.NO_DATA_USAGE.get()));
// } else if (pplayer.getParticleEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA) && args.length == 2) {
// if (pplayer.getParticleEffect() == ParticleEffect.ITEM) {
// StringUtil.copyPartialMatches(args[1], ITEM_MATERIALS, completions);
// } else {
// StringUtil.copyPartialMatches(args[1], BLOCK_MATERIALS, completions);
// }
// } else if (pplayer.getParticleEffect().hasProperty(ParticleProperty.COLORABLE)) {
// if (pplayer.getParticleEffect() == ParticleEffect.NOTE && args.length == 2) {
// completions.add("<0-23>");
// StringUtil.copyPartialMatches(args[args.length - 1], Arrays.asList(new String[] { "rainbow" }), completions);
// } else if (pplayer.getParticleEffect() != ParticleEffect.NOTE && args.length > 1 && args.length < 5) {
// completions.add("<0-255>");
// if (args.length == 2) {
// StringUtil.copyPartialMatches(args[args.length - 1], Arrays.asList(new String[] { "rainbow" }), completions);
// }
// }
// } else if (args.length == 2) {
// completions.add(ChatColor.stripColor(Lang.NO_DATA_USAGE.get()));
// }
// }
// } else {
// List<String> commands = new ArrayList<String>(Arrays.asList(COMMANDS));
// StringUtil.copyPartialMatches(args[0], commands, completions);
} }
} }
return null; return null;
} }
// public static String[] getCommandsList() {
// return COMMANDS;
// }
} }

View file

@ -2,12 +2,8 @@ package com.esophose.playerparticles.command;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.esophose.playerparticles.manager.DataManager; import com.esophose.playerparticles.manager.DataManager;
import com.esophose.playerparticles.manager.LangManager; import com.esophose.playerparticles.manager.LangManager;
import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.manager.LangManager.Lang; import com.esophose.playerparticles.manager.LangManager.Lang;
import com.esophose.playerparticles.particles.PPlayer; import com.esophose.playerparticles.particles.PPlayer;
import com.esophose.playerparticles.particles.ParticleGroup; import com.esophose.playerparticles.particles.ParticleGroup;
@ -15,32 +11,9 @@ import com.esophose.playerparticles.particles.ParticleGroup;
public class ResetCommandModule implements CommandModule { public class ResetCommandModule implements CommandModule {
public void onCommandExecute(PPlayer pplayer, String[] args) { public void onCommandExecute(PPlayer pplayer, String[] args) {
if (args.length >= 1) { int particleCount = pplayer.getActiveParticles().size();
String altPlayerName = args[0];
if (!PermissionManager.canUseForceReset(pplayer.getPlayer())) {
LangManager.sendMessage(pplayer, Lang.EXECUTE_FAILED_NO_PERMISSION, altPlayerName);
} else {
Player targetPlayer = null;
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.getName().toLowerCase().contains(altPlayerName.toLowerCase())) {
targetPlayer = p;
break;
}
}
if (targetPlayer == null) {
LangManager.sendMessage(pplayer, Lang.EXECUTE_FAILED_NOT_FOUND, altPlayerName);
} else {
DataManager.saveParticleGroup(targetPlayer.getUniqueId(), ParticleGroup.getDefaultGroup());
LangManager.sendMessage(targetPlayer, Lang.RESET_SUCCESS);
LangManager.sendMessage(pplayer, Lang.EXECUTE_SUCCESS, targetPlayer.getName());
}
}
} else {
DataManager.saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup()); DataManager.saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup());
LangManager.sendMessage(pplayer, Lang.RESET_SUCCESS); LangManager.sendMessage(pplayer, Lang.RESET_SUCCESS, particleCount);
}
} }
public List<String> onTabComplete(PPlayer pplayer, String[] args) { public List<String> onTabComplete(PPlayer pplayer, String[] args) {

View file

@ -88,10 +88,9 @@ public class DataManager {
"WHERE g.owner_uuid = ?"; // @formatter:on "WHERE g.owner_uuid = ?"; // @formatter:on
try (PreparedStatement statement = connection.prepareStatement(groupQuery)) { try (PreparedStatement statement = connection.prepareStatement(groupQuery)) {
statement.setString(1, playerUUID.toString()); statement.setString(1, playerUUID.toString());
System.out.println("Executing particle query");
ResultSet result = statement.executeQuery(); ResultSet result = statement.executeQuery();
while (result.next()) { while (result.next()) {
System.out.println("Particle result found");
// Group properties // Group properties
String groupName = result.getString("name"); String groupName = result.getString("name");
@ -105,15 +104,6 @@ public class DataManager {
OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b")); OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b"));
ParticlePair particle = new ParticlePair(playerUUID, id, effect, style, itemMaterial, blockMaterial, color, noteColor); ParticlePair particle = new ParticlePair(playerUUID, id, effect, style, itemMaterial, blockMaterial, color, noteColor);
System.out.println("==============================");
System.out.println(result.getInt("id"));
System.out.println(result.getString("effect"));
System.out.println(result.getString("style"));
System.out.println(result.getString("item_material"));
System.out.println(result.getString("block_material"));
System.out.println(result.getInt("note"));
System.out.println(result.getInt("r") + " " + result.getInt("g") + " " + result.getInt("b"));
// Try to add particle to an existing group // Try to add particle to an existing group
boolean groupAlreadyExists = false; boolean groupAlreadyExists = false;
for (ParticleGroup group : groups) { for (ParticleGroup group : groups) {

View file

@ -20,7 +20,7 @@ public class LangManager {
/** /**
* Contains the location in the .lang file of every chat message * Contains the location in the .lang file of every chat message
*/ */
public static enum Lang { public static enum Lang { // @formatter:off
// Command Errors // Command Errors
COMMAND_ERROR_NO_EFFECTS, COMMAND_ERROR_NO_EFFECTS,
@ -59,6 +59,9 @@ public class LangManager {
// Add Command // Add Command
COMMAND_ADD_PARTICLE_APPLIED, COMMAND_ADD_PARTICLE_APPLIED,
// Data Command
COMMAND_DATA_NO_ARGS,
// Effects // Effects
EFFECT_NO_PERMISSION, EFFECT_NO_PERMISSION,
EFFECT_INVALID, EFFECT_INVALID,
@ -88,11 +91,6 @@ public class LangManager {
DISABLED_WORLDS, DISABLED_WORLDS,
DISABLED_WORLDS_NONE, DISABLED_WORLDS_NONE,
// Alternate Player Command Execution
EXECUTE_SUCCESS,
EXECUTE_FAILED_NOT_FOUND,
EXECUTE_FAILED_NO_PERMISSION,
// Reset // Reset
RESET_SUCCESS, RESET_SUCCESS,
@ -134,7 +132,7 @@ public class LangManager {
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; // @formatter:on
private String message; private String message;

View file

@ -70,16 +70,6 @@ public class PermissionManager {
return list; return list;
} }
/**
* Checks if a player has permission to execute commands for other players
*
* @param player The player to check the permission for
* @return True if the player has permission
*/
public static boolean canUseForceReset(Player player) {
return player.hasPermission("playerparticles.forcereset");
}
/** /**
* Checks if a player has permission to created fixed effects * Checks if a player has permission to created fixed effects
* *

View file

@ -22,8 +22,10 @@ public class ParticleStyleBlockBreak implements ParticleStyle, Listener {
public List<PParticle> getParticles(ParticlePair particle, Location location) { public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>(); List<PParticle> particles = new ArrayList<PParticle>();
location.add(0.5, 0.5, 0.5); // Center around the block
for (int i = 0; i < 15; i++) for (int i = 0; i < 15; i++)
particles.add(new PParticle(location.add(0.5, 0.5, 0.5), 0.5F, 0.5F, 0.5F, 0.05F)); particles.add(new PParticle(location, 0.5F, 0.5F, 0.5F, 0.05F));
return particles; return particles;
} }

View file

@ -22,8 +22,10 @@ public class ParticleStyleBlockPlace implements ParticleStyle, Listener {
public List<PParticle> getParticles(ParticlePair particle, Location location) { public List<PParticle> getParticles(ParticlePair particle, Location location) {
List<PParticle> particles = new ArrayList<PParticle>(); List<PParticle> particles = new ArrayList<PParticle>();
location.add(0.5, 0.5, 0.5); // Center around the block
for (int i = 0; i < 15; i++) for (int i = 0; i < 15; i++)
particles.add(new PParticle(location.add(0.5, 0.5, 0.5), 0.75F, 0.75F, 0.75F, 0.05F)); particles.add(new PParticle(location, 0.75F, 0.75F, 0.75F, 0.05F));
return particles; return particles;
} }

View file

@ -45,6 +45,9 @@ command-description-group-remove: '&e/pp group remove <name> - Removes all parti
# Add Command # 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!' 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>'
# Effects # Effects
effect-no-permission: '&cYou do not have permission to use the effect &b{0} &c!' 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.'
@ -56,15 +59,15 @@ style-invalid: '&cThe style &b{0} &cdoes not exist. Use &b/pp styles &cfor a lis
style-list: '&eYou can use the following styles: &b{0}' style-list: '&eYou can use the following styles: &b{0}'
# Data # Data
data-usage-none: '&eYour current effect does not use any data!' data-usage-none: '&eThe effect &b{0} &edoes not use any data!'
data-usage-block: '&eThe effect &b{0} requires &bblock &edata! &bFormat: <blockName>' data-usage-block: '&eThe effect &b{0} &erequires &bblock &edata! &bFormat: <blockName>'
data-usage-item: '&eThe effect &b{0} requires &bitem &edata! &bFormat: <itemName>' data-usage-item: '&eThe effect &b{0} &erequires &bitem &edata! &bFormat: <itemName>'
data-usage-color: '&eThe effect &b{0} requires &bcolor &edata! &bFormat: [<0-255> <0-255> <0-255>]|[<rainbow>]' data-usage-color: '&eThe effect &b{0} &erequires &bcolor &edata! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>'
data-usage-note: '&eThe effect &b{0} requires &bnote &edata! &bFormat: <0-23>/<rainbow>' data-usage-note: '&eThe effect &b{0} &erequires &bnote &edata! &bFormat: <0-23>|<rainbow>'
data-invalid-block: '&cThe &bblock &cdata you entered is invalid! &bFormat: <blockName>' data-invalid-block: '&cThe &bblock &cdata you entered is invalid! &bFormat: <blockName>'
data-invalid-item: '&cThe &bitem &cdata you entered is invalid! &bFormat: <itemName>' data-invalid-item: '&cThe &bitem &cdata you entered is invalid! &bFormat: <itemName>'
data-invalid-color: '&cThe &bcolor &cdata you entered is invalid! &bFormat: [<0-255> <0-255> <0-255>]|[<rainbow>]' data-invalid-color: '&cThe &bcolor &cdata you entered is invalid! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>'
data-invalid-note: '&cThe &bitem &cdata you entered is invalid! &bFormat: <0-23>/<rainbow>' data-invalid-note: '&cThe &bnote &cdata you entered is invalid! &bFormat: <0-23>|<rainbow>'
data-invalid-material-not-item: '&cThe &bitem &cmaterial &b{0} &cyou entered is not an item!' data-invalid-material-not-item: '&cThe &bitem &cmaterial &b{0} &cyou entered is not an item!'
data-invalid-material-not-block: '&cThe &bblock &cmaterial &b{0} &cyou entered is not a block!' data-invalid-material-not-block: '&cThe &bblock &cmaterial &b{0} &cyou entered is not a block!'
data-invalid-material-item: '&cThe &bitem &cmaterial &b{0} you entered does not exist!' data-invalid-material-item: '&cThe &bitem &cmaterial &b{0} you entered does not exist!'
@ -74,13 +77,8 @@ data-invalid-material-block: '&cThe &bblock &cmaterial &b{0} you entered does no
disabled-worlds: '&eParticles are disabled in these worlds: &b{0}' 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!'
# Alternate Player Command Execution
execute-success: '&aSuccessfully executed &b{0} &aexecuted for &b{1}'
execute-failed-not-found: '&cFailed to execute &b{0} &cfor &b{1}&c! Player not found!'
execute-failed-no-permission: '&cFailed to execute &b{0} for &b{1}&c! You do not have permission!'
# Reset # Reset
reset-success: '&aAll your active particles have been removed.' reset-success: '&aRemoved &b{0} &aactive particles.'
# Fixed Effects # Fixed Effects
fixed-create-missing-args: '&cUnable to create fixed effect, you are missing &b{0} &crequired arguments!' fixed-create-missing-args: '&cUnable to create fixed effect, you are missing &b{0} &crequired arguments!'