mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-02-11 11:40:21 +00:00
'/pp edit' implemented, fix cmd material bug
This commit is contained in:
parent
b4455e6686
commit
4fce663167
11 changed files with 329 additions and 35 deletions
|
@ -2,7 +2,6 @@
|
||||||
* TODO: v5.3
|
* TODO: v5.3
|
||||||
* + Add new style 'tornado'
|
* + Add new style 'tornado'
|
||||||
* + Add new style 'companion'
|
* + Add new style 'companion'
|
||||||
* + Add new style 'atom'
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.esophose.playerparticles;
|
package com.esophose.playerparticles;
|
||||||
|
|
|
@ -19,7 +19,6 @@ import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
|
||||||
import com.esophose.playerparticles.particles.ParticleGroup;
|
import com.esophose.playerparticles.particles.ParticleGroup;
|
||||||
import com.esophose.playerparticles.particles.ParticlePair;
|
import com.esophose.playerparticles.particles.ParticlePair;
|
||||||
import com.esophose.playerparticles.styles.api.ParticleStyle;
|
import com.esophose.playerparticles.styles.api.ParticleStyle;
|
||||||
import com.esophose.playerparticles.styles.api.ParticleStyleManager;
|
|
||||||
import com.esophose.playerparticles.util.ParticleUtils;
|
import com.esophose.playerparticles.util.ParticleUtils;
|
||||||
|
|
||||||
public class AddCommandModule implements CommandModule {
|
public class AddCommandModule implements CommandModule {
|
||||||
|
@ -39,7 +38,7 @@ public class AddCommandModule implements CommandModule {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleStyle style = ParticleStyleManager.styleFromString(args[1]);
|
ParticleStyle style = ParticleStyle.fromName(args[1]);
|
||||||
if (style == null) {
|
if (style == null) {
|
||||||
LangManager.sendMessage(pplayer, Lang.STYLE_INVALID, args[1]);
|
LangManager.sendMessage(pplayer, Lang.STYLE_INVALID, args[1]);
|
||||||
return;
|
return;
|
||||||
|
@ -103,7 +102,7 @@ public class AddCommandModule implements CommandModule {
|
||||||
if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) {
|
if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) {
|
||||||
try {
|
try {
|
||||||
blockData = ParticleUtils.closestMatch(args[2]);
|
blockData = ParticleUtils.closestMatch(args[2]);
|
||||||
if (blockData == null) throw new Exception();
|
if (blockData == null || !blockData.isBlock()) throw new Exception();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_BLOCK);
|
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_BLOCK);
|
||||||
return;
|
return;
|
||||||
|
@ -111,7 +110,7 @@ public class AddCommandModule implements CommandModule {
|
||||||
} else if (effect == ParticleEffect.ITEM) {
|
} else if (effect == ParticleEffect.ITEM) {
|
||||||
try {
|
try {
|
||||||
itemData = ParticleUtils.closestMatch(args[2]);
|
itemData = ParticleUtils.closestMatch(args[2]);
|
||||||
if (itemData == null) throw new Exception();
|
if (itemData == null || itemData.isBlock()) throw new Exception();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_ITEM);
|
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_ITEM);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,18 +1,297 @@
|
||||||
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.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
import com.esophose.playerparticles.manager.DataManager;
|
||||||
|
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.ParticleEffect;
|
||||||
|
import com.esophose.playerparticles.particles.ParticleGroup;
|
||||||
|
import com.esophose.playerparticles.particles.ParticlePair;
|
||||||
|
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.util.ParticleUtils;
|
||||||
|
|
||||||
public class EditCommandModule implements CommandModule {
|
public class EditCommandModule implements CommandModule {
|
||||||
|
|
||||||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||||
|
if (args.length < 3) {
|
||||||
|
CommandModule.printUsage(pplayer, this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int id = -1;
|
||||||
|
try {
|
||||||
|
id = Integer.parseInt(args[0]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LangManager.sendMessage(pplayer, Lang.COMMAND_ID_INVALID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id <= 0) {
|
||||||
|
LangManager.sendMessage(pplayer, Lang.COMMAND_ID_INVALID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pplayer.getActiveParticle(id) == null) {
|
||||||
|
LangManager.sendMessage(pplayer, Lang.COMMAND_ID_UNKNOWN, id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] cmdArgs = new String[args.length - 2];
|
||||||
|
for (int i = 2; i < args.length; i++) {
|
||||||
|
cmdArgs[i - 2] = args[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args[1].toLowerCase()) {
|
||||||
|
case "effect":
|
||||||
|
editEffect(pplayer, id, cmdArgs);
|
||||||
|
break;
|
||||||
|
case "style":
|
||||||
|
editStyle(pplayer, id, cmdArgs);
|
||||||
|
break;
|
||||||
|
case "data":
|
||||||
|
editData(pplayer, id, cmdArgs);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
LangManager.sendMessage(pplayer, Lang.COMMAND_EDIT_INVALID_PROPERTY, args[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the effect subcommand
|
||||||
|
*
|
||||||
|
* @param pplayer The PPlayer executing the command
|
||||||
|
* @param id The target particle ID
|
||||||
|
* @param args The rest of the args
|
||||||
|
*/
|
||||||
|
private void editEffect(PPlayer pplayer, int id, String[] args) {
|
||||||
|
ParticleEffect effect = ParticleEffect.fromName(args[0]);
|
||||||
|
if (effect == null) {
|
||||||
|
LangManager.sendMessage(pplayer, Lang.EFFECT_INVALID, args[0]);
|
||||||
|
return;
|
||||||
|
} else if (!PermissionManager.hasEffectPermission(pplayer.getPlayer(), effect)) {
|
||||||
|
LangManager.sendMessage(pplayer, Lang.EFFECT_NO_PERMISSION, effect.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ParticleGroup group = pplayer.getActiveParticleGroup();
|
||||||
|
for (ParticlePair particle : group.getParticles()) {
|
||||||
|
if (particle.getId() == id) {
|
||||||
|
particle.setEffect(effect);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
|
||||||
|
LangManager.sendMessage(pplayer, Lang.COMMAND_EDIT_SUCCESS_EFFECT, id, effect.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the style subcommand
|
||||||
|
*
|
||||||
|
* @param pplayer The PPlayer executing the command
|
||||||
|
* @param id The target particle ID
|
||||||
|
* @param args The rest of the args
|
||||||
|
*/
|
||||||
|
private void editStyle(PPlayer pplayer, int id, String[] args) {
|
||||||
|
ParticleStyle style = ParticleStyle.fromName(args[0]);
|
||||||
|
if (style == null) {
|
||||||
|
LangManager.sendMessage(pplayer, Lang.STYLE_INVALID, args[0]);
|
||||||
|
return;
|
||||||
|
} else if (!PermissionManager.hasStylePermission(pplayer.getPlayer(), style)) {
|
||||||
|
LangManager.sendMessage(pplayer, Lang.STYLE_NO_PERMISSION, style.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ParticleGroup group = pplayer.getActiveParticleGroup();
|
||||||
|
for (ParticlePair particle : group.getParticles()) {
|
||||||
|
if (particle.getId() == id) {
|
||||||
|
particle.setStyle(style);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
|
||||||
|
LangManager.sendMessage(pplayer, Lang.COMMAND_EDIT_SUCCESS_STYLE, id, style.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the data subcommand
|
||||||
|
*
|
||||||
|
* @param pplayer The PPlayer executing the command
|
||||||
|
* @param id The target particle ID
|
||||||
|
* @param args The rest of the args
|
||||||
|
*/
|
||||||
|
private void editData(PPlayer pplayer, int id, String[] args) {
|
||||||
|
Material itemData = null;
|
||||||
|
Material blockData = null;
|
||||||
|
OrdinaryColor colorData = null;
|
||||||
|
NoteColor noteColorData = null;
|
||||||
|
|
||||||
|
ParticleEffect effect = pplayer.getActiveParticle(id).getEffect();
|
||||||
|
|
||||||
|
if (effect.hasProperty(ParticleProperty.COLORABLE)) {
|
||||||
|
if (effect == ParticleEffect.NOTE) {
|
||||||
|
if (args[0].equalsIgnoreCase("rainbow")) {
|
||||||
|
noteColorData = new NoteColor(99);
|
||||||
|
} else {
|
||||||
|
int note = -1;
|
||||||
|
try {
|
||||||
|
note = Integer.parseInt(args[0]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (note < 0 || note > 23) {
|
||||||
|
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
noteColorData = new NoteColor(note);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (args[0].equalsIgnoreCase("rainbow")) {
|
||||||
|
colorData = new OrdinaryColor(999, 999, 999);
|
||||||
|
} else {
|
||||||
|
int r = -1;
|
||||||
|
int g = -1;
|
||||||
|
int b = -1;
|
||||||
|
|
||||||
|
try {
|
||||||
|
r = Integer.parseInt(args[0]);
|
||||||
|
g = Integer.parseInt(args[1]);
|
||||||
|
b = Integer.parseInt(args[2]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_COLOR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
|
||||||
|
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_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[0]);
|
||||||
|
if (blockData == null || !blockData.isBlock()) throw new Exception();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_BLOCK);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (effect == ParticleEffect.ITEM) {
|
||||||
|
try {
|
||||||
|
itemData = ParticleUtils.closestMatch(args[0]);
|
||||||
|
if (itemData == null || itemData.isBlock()) throw new Exception();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_ITEM);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String updatedDataString = null;
|
||||||
|
ParticleGroup group = pplayer.getActiveParticleGroup();
|
||||||
|
for (ParticlePair particle : group.getParticles()) {
|
||||||
|
if (particle.getId() == id) {
|
||||||
|
if (itemData != null) particle.setItemMaterial(itemData);
|
||||||
|
if (blockData != null) particle.setBlockMaterial(blockData);
|
||||||
|
if (colorData != null) particle.setColor(colorData);
|
||||||
|
if (noteColorData != null) particle.setNoteColor(noteColorData);
|
||||||
|
updatedDataString = particle.getDataString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
|
||||||
|
LangManager.sendMessage(pplayer, Lang.COMMAND_EDIT_SUCCESS_DATA, id, updatedDataString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
|
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
|
||||||
return null;
|
Player p = pplayer.getPlayer();
|
||||||
|
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) {
|
||||||
|
matches = ids;
|
||||||
|
} else if (args.length == 1) {
|
||||||
|
StringUtil.copyPartialMatches(args[0], ids, matches);
|
||||||
|
}
|
||||||
|
|
||||||
|
int id = -1;
|
||||||
|
try {
|
||||||
|
id = Integer.parseInt(args[0]);
|
||||||
|
} catch (Exception e) { }
|
||||||
|
|
||||||
|
if (pplayer.getActiveParticle(id) != null) {
|
||||||
|
if (args.length == 2) {
|
||||||
|
List<String> possibleValues = new ArrayList<String>();
|
||||||
|
possibleValues.add("effect");
|
||||||
|
possibleValues.add("style");
|
||||||
|
possibleValues.add("data");
|
||||||
|
StringUtil.copyPartialMatches(args[1], possibleValues, matches);
|
||||||
|
} else if (args.length >= 3) {
|
||||||
|
switch (args[1].toLowerCase()) {
|
||||||
|
case "effect":
|
||||||
|
StringUtil.copyPartialMatches(args[2], PermissionManager.getEffectsUserHasPermissionFor(p), matches);
|
||||||
|
break;
|
||||||
|
case "style":
|
||||||
|
StringUtil.copyPartialMatches(args[2], PermissionManager.getStylesUserHasPermissionFor(p), matches);
|
||||||
|
break;
|
||||||
|
case "data":
|
||||||
|
ParticleEffect effect = pplayer.getActiveParticle(id).getEffect();
|
||||||
|
if (effect.hasProperty(ParticleProperty.COLORABLE)) {
|
||||||
|
List<String> possibleValues = new ArrayList<String>();
|
||||||
|
if (effect == ParticleEffect.NOTE) { // Note data
|
||||||
|
if (args.length == 3) {
|
||||||
|
possibleValues.add("<0-23>");
|
||||||
|
possibleValues.add("rainbow");
|
||||||
|
}
|
||||||
|
} else { // Color data
|
||||||
|
if (args.length <= 5 && !args[2].equalsIgnoreCase("rainbow")) {
|
||||||
|
possibleValues.add("<0-255>");
|
||||||
|
}
|
||||||
|
if (args.length <= 4 && !args[2].equalsIgnoreCase("rainbow")) {
|
||||||
|
possibleValues.add("<0-255> <0-255>");
|
||||||
|
}
|
||||||
|
if (args.length <= 3) {
|
||||||
|
possibleValues.add("<0-255> <0-255> <0-255>");
|
||||||
|
possibleValues.add("rainbow");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches);
|
||||||
|
} else if (args.length == 3 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
|
||||||
|
if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material
|
||||||
|
matches = StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllBlockMaterials(), matches);
|
||||||
|
} else if (effect == ParticleEffect.ITEM) { // Item material
|
||||||
|
matches = StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllItemMaterials(), matches);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -24,7 +303,7 @@ public class EditCommandModule implements CommandModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getArguments() {
|
public String getArguments() {
|
||||||
return "";
|
return "<id> <effect>|<style>|<data> <args>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean requiresEffects() {
|
public boolean requiresEffects() {
|
||||||
|
|
|
@ -142,7 +142,7 @@ public class FixedCommandModule implements CommandModule {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleStyle style = ParticleStyleManager.styleFromString(args[4]);
|
ParticleStyle style = ParticleStyle.fromName(args[4]);
|
||||||
if (style == null) {
|
if (style == null) {
|
||||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_STYLE_INVALID, args[4]);
|
LangManager.sendMessage(p, Lang.FIXED_CREATE_STYLE_INVALID, args[4]);
|
||||||
return;
|
return;
|
||||||
|
@ -213,7 +213,7 @@ public class FixedCommandModule implements CommandModule {
|
||||||
try {
|
try {
|
||||||
material = ParticleUtils.closestMatch(args[5]);
|
material = ParticleUtils.closestMatch(args[5]);
|
||||||
if (material == null) material = Material.matchMaterial(args[5]);
|
if (material == null) material = Material.matchMaterial(args[5]);
|
||||||
if (material == null) throw new Exception();
|
if (material == null || !material.isBlock()) throw new Exception();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_DATA_ERROR);
|
LangManager.sendMessage(p, Lang.FIXED_CREATE_DATA_ERROR);
|
||||||
return;
|
return;
|
||||||
|
@ -225,7 +225,7 @@ public class FixedCommandModule implements CommandModule {
|
||||||
try {
|
try {
|
||||||
material = ParticleUtils.closestMatch(args[5]);
|
material = ParticleUtils.closestMatch(args[5]);
|
||||||
if (material == null) material = Material.matchMaterial(args[5]);
|
if (material == null) material = Material.matchMaterial(args[5]);
|
||||||
if (material == null) throw new Exception();
|
if (material == null || material.isBlock()) throw new Exception();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_DATA_ERROR);
|
LangManager.sendMessage(p, Lang.FIXED_CREATE_DATA_ERROR);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -24,12 +24,12 @@ public class RemoveCommandModule implements CommandModule {
|
||||||
try {
|
try {
|
||||||
id = Integer.parseInt(args[0]);
|
id = Integer.parseInt(args[0]);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LangManager.sendMessage(pplayer, Lang.COMMAND_REMOVE_ARGS_INVALID);
|
LangManager.sendMessage(pplayer, Lang.COMMAND_ID_INVALID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id <= 0) {
|
if (id <= 0) {
|
||||||
LangManager.sendMessage(pplayer, Lang.COMMAND_REMOVE_ARGS_INVALID);
|
LangManager.sendMessage(pplayer, Lang.COMMAND_ID_INVALID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class RemoveCommandModule implements CommandModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!removed) {
|
if (!removed) {
|
||||||
LangManager.sendMessage(pplayer, Lang.COMMAND_REMOVE_INVALID_ID, id);
|
LangManager.sendMessage(pplayer, Lang.COMMAND_ID_UNKNOWN, id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ import com.esophose.playerparticles.util.ParticleUtils;
|
||||||
* This class provides a collection of static methods for modifying your
|
* This class provides a collection of static methods for modifying your
|
||||||
* particle/style/data through the use of a GUI
|
* particle/style/data through the use of a GUI
|
||||||
*/
|
*/
|
||||||
// TODO: This entire GUI is currently hardwired to only work with the first particle in the player's list, make it with with everything
|
// TODO: This entire GUI is currently hardwired to only work with the first particle in the player's list, make it work with everything
|
||||||
public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -540,7 +540,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
||||||
List<String> stylesUserHasPermissionFor = PermissionManager.getStylesUserHasPermissionFor(player);
|
List<String> stylesUserHasPermissionFor = PermissionManager.getStylesUserHasPermissionFor(player);
|
||||||
for (int i = 0; i < stylesUserHasPermissionFor.size(); i++) {
|
for (int i = 0; i < stylesUserHasPermissionFor.size(); i++) {
|
||||||
String s = stylesUserHasPermissionFor.get(i);
|
String s = stylesUserHasPermissionFor.get(i);
|
||||||
ParticleStyle style = ParticleStyleManager.styleFromString(s);
|
ParticleStyle style = ParticleStyle.fromName(s);
|
||||||
inventory.setItem(i, getItemForStyle(style, style == getPPlayerStyle(pplayer)));
|
inventory.setItem(i, getItemForStyle(style, style == getPPlayerStyle(pplayer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +710,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
||||||
changeState(pplayer, GuiState.DEFAULT);
|
changeState(pplayer, GuiState.DEFAULT);
|
||||||
break;
|
break;
|
||||||
case STYLE:
|
case STYLE:
|
||||||
setPPlayerStyle(pplayer, ParticleStyleManager.styleFromString(name));
|
setPPlayerStyle(pplayer, ParticleStyle.fromName(name));
|
||||||
changeState(pplayer, GuiState.DEFAULT);
|
changeState(pplayer, GuiState.DEFAULT);
|
||||||
break;
|
break;
|
||||||
case DATA:
|
case DATA:
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class DataManager {
|
||||||
// Particle properties
|
// Particle properties
|
||||||
int id = result.getInt("id");
|
int id = result.getInt("id");
|
||||||
ParticleEffect effect = ParticleEffect.fromName(result.getString("effect"));
|
ParticleEffect effect = ParticleEffect.fromName(result.getString("effect"));
|
||||||
ParticleStyle style = ParticleStyleManager.styleFromString(result.getString("style"));
|
ParticleStyle style = ParticleStyle.fromName(result.getString("style"));
|
||||||
Material itemMaterial = ParticleUtils.closestMatchWithFallback(result.getString("item_material"));
|
Material itemMaterial = ParticleUtils.closestMatchWithFallback(result.getString("item_material"));
|
||||||
Material blockMaterial = ParticleUtils.closestMatchWithFallback(result.getString("block_material"));
|
Material blockMaterial = ParticleUtils.closestMatchWithFallback(result.getString("block_material"));
|
||||||
NoteColor noteColor = new NoteColor(result.getInt("note"));
|
NoteColor noteColor = new NoteColor(result.getInt("note"));
|
||||||
|
@ -143,7 +143,7 @@ public class DataManager {
|
||||||
// Particle properties
|
// Particle properties
|
||||||
int particleId = result.getInt("p_id");
|
int particleId = result.getInt("p_id");
|
||||||
ParticleEffect effect = ParticleEffect.fromName(result.getString("effect"));
|
ParticleEffect effect = ParticleEffect.fromName(result.getString("effect"));
|
||||||
ParticleStyle style = ParticleStyleManager.styleFromString(result.getString("style"));
|
ParticleStyle style = ParticleStyle.fromName(result.getString("style"));
|
||||||
Material itemMaterial = ParticleUtils.closestMatchWithFallback(result.getString("item_material"));
|
Material itemMaterial = ParticleUtils.closestMatchWithFallback(result.getString("item_material"));
|
||||||
Material blockMaterial = ParticleUtils.closestMatchWithFallback(result.getString("block_material"));
|
Material blockMaterial = ParticleUtils.closestMatchWithFallback(result.getString("block_material"));
|
||||||
NoteColor noteColor = new NoteColor(result.getInt("note"));
|
NoteColor noteColor = new NoteColor(result.getInt("note"));
|
||||||
|
|
|
@ -58,16 +58,24 @@ public class LangManager {
|
||||||
COMMAND_DESCRIPTION_GROUP_LIST,
|
COMMAND_DESCRIPTION_GROUP_LIST,
|
||||||
COMMAND_DESCRIPTION_GROUP_INFO,
|
COMMAND_DESCRIPTION_GROUP_INFO,
|
||||||
|
|
||||||
|
// ID Lookup
|
||||||
|
COMMAND_ID_INVALID,
|
||||||
|
COMMAND_ID_UNKNOWN,
|
||||||
|
|
||||||
// Add Command
|
// Add Command
|
||||||
COMMAND_ADD_PARTICLE_APPLIED,
|
COMMAND_ADD_PARTICLE_APPLIED,
|
||||||
|
|
||||||
// Data Command
|
// Data Command
|
||||||
COMMAND_DATA_NO_ARGS,
|
COMMAND_DATA_NO_ARGS,
|
||||||
|
|
||||||
|
// Edit Command
|
||||||
|
COMMAND_EDIT_INVALID_PROPERTY,
|
||||||
|
COMMAND_EDIT_SUCCESS_EFFECT,
|
||||||
|
COMMAND_EDIT_SUCCESS_STYLE,
|
||||||
|
COMMAND_EDIT_SUCCESS_DATA,
|
||||||
|
|
||||||
// Remove Command
|
// Remove Command
|
||||||
COMMAND_REMOVE_NO_ARGS,
|
COMMAND_REMOVE_NO_ARGS,
|
||||||
COMMAND_REMOVE_ARGS_INVALID,
|
|
||||||
COMMAND_REMOVE_INVALID_ID,
|
|
||||||
COMMAND_REMOVE_SUCCESS,
|
COMMAND_REMOVE_SUCCESS,
|
||||||
|
|
||||||
// List Command
|
// List Command
|
||||||
|
|
|
@ -35,5 +35,18 @@ public interface ParticleStyle {
|
||||||
* @return If the style can be used in a FixedParticleEffect
|
* @return If the style can be used in a FixedParticleEffect
|
||||||
*/
|
*/
|
||||||
public boolean canBeFixed();
|
public boolean canBeFixed();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ParticleStyle with the name given, returns null if not found
|
||||||
|
*
|
||||||
|
* @param styleName The string of the style to search for
|
||||||
|
* @return The ParticleStyle with the name requested
|
||||||
|
*/
|
||||||
|
public static ParticleStyle fromName(String styleName) {
|
||||||
|
for (ParticleStyle style : ParticleStyleManager.getStyles())
|
||||||
|
if (style.getName().equals(styleName)) return style;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,18 +58,6 @@ public class ParticleStyleManager {
|
||||||
return styles;
|
return styles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the ParticleStyle with the name given, returns null if not found
|
|
||||||
*
|
|
||||||
* @param styleName The string of the style to search for
|
|
||||||
* @return The ParticleStyle with the name requested
|
|
||||||
*/
|
|
||||||
public static ParticleStyle styleFromString(String styleName) {
|
|
||||||
for (ParticleStyle style : styles)
|
|
||||||
if (style.getName().equals(styleName)) return style;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates all the timers for the particle styles to make the animations
|
* Updates all the timers for the particle styles to make the animations
|
||||||
*
|
*
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# Important Notes: #
|
# Important Notes: #
|
||||||
# * You can use the & symbol to color the messages #
|
# * You can use the & symbol to color the messages #
|
||||||
# * {#} Will be replaced with whatever that message requires #
|
# * {#} Will be replaced with whatever that message requires #
|
||||||
# * If you use an apostrophe character it MUST be escaped! ( \' ) #
|
# * Do NOT use the apostrophe character in any message! ( ' ) #
|
||||||
# * PLEASE MAKE YOUR OWN .lang FILE IF YOU WANT CUSTOM MESSAGES! #
|
# * PLEASE MAKE YOUR OWN .lang FILE IF YOU WANT CUSTOM MESSAGES! #
|
||||||
# * This file will be overridden almost every plugin update! #
|
# * This file will be overridden almost every plugin update! #
|
||||||
# ================================================================ #
|
# ================================================================ #
|
||||||
|
@ -44,16 +44,24 @@ command-description-group-remove: '&e/pp group remove <name> - Removes a group y
|
||||||
command-description-group-list: '&e/pp group list <name> - List all particle groups 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'
|
command-description-group-info: '&e/pp group info <name> - List the particles saved in the group'
|
||||||
|
|
||||||
|
# Command ID Lookup
|
||||||
|
command-id-invalid: '&cThe ID you entered is invalid, it must be a positive whole number!'
|
||||||
|
command-id-unknown: '&cYou do not have a particle applied with the ID &b{0}&c!'
|
||||||
|
|
||||||
# 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
|
# 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>'
|
||||||
|
|
||||||
|
# Edit Command
|
||||||
|
command-edit-invalid-property: '&cAn invalid property &b{0} &cwas provided. Valid properties: &beffect&c, &bstyle&c, &bdata'
|
||||||
|
command-edit-success-effect: '&aYour particle with an ID of &b{0} &ahas had its effect changed to &b{1}&a!'
|
||||||
|
command-edit-success-style: '&aYour particle with an ID of &b{0} &ahas had its style changed to &b{1}&a!'
|
||||||
|
command-edit-success-data: '&aYour particle with an ID of &b{0} &ahas had its data changed to &b{1}&a!'
|
||||||
|
|
||||||
# Remove Command
|
# Remove Command
|
||||||
command-remove-no-args: '&cYou did not specify an ID to remove! &b/pp remove <ID>'
|
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!'
|
command-remove-success: '&aYour particle with the ID &b{0} &ahas been removed!'
|
||||||
|
|
||||||
# List Command
|
# List Command
|
||||||
|
|
Loading…
Reference in a new issue