Most things working, missing icons

Everything is now working as intended, the GUI is just missing icons due to the Minecraft 1.13 Material name changes
This commit is contained in:
Esophose 2018-09-07 02:56:59 -06:00
parent d127824219
commit 8b4c1fcd42
22 changed files with 448 additions and 474 deletions

View file

@ -53,7 +53,7 @@
</excludes> </excludes>
</filter> </filter>
</filters> </filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot 1.13.Dev Server\plugins\update\PlayerParticles v5.2.jar</outputFile> <outputFile>C:\Users\Esophose\Desktop\Spigot 1.13 Dev Server\plugins\update\PlayerParticles v5.2.jar</outputFile>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>

View file

@ -170,7 +170,7 @@ public class PPlayer {
* @param itemData The player's new item data * @param itemData The player's new item data
*/ */
public void setItemData(ItemData itemData) { public void setItemData(ItemData itemData) {
if (itemData == null) itemData = new ItemData(ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"), (byte)0); if (itemData == null) itemData = new ItemData(ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"));
this.particleItemData = itemData; this.particleItemData = itemData;
} }
@ -180,7 +180,7 @@ public class PPlayer {
* @param blockData The player's new block data * @param blockData The player's new block data
*/ */
public void setBlockData(BlockData blockData) { public void setBlockData(BlockData blockData) {
if (blockData == null) blockData = new BlockData(Material.STONE, (byte) 0); if (blockData == null) blockData = new BlockData(Material.STONE);
this.particleBlockData = blockData; this.particleBlockData = blockData;
} }
@ -210,11 +210,11 @@ public class PPlayer {
* @return The ParticleData the current particle effect requires * @return The ParticleData the current particle effect requires
*/ */
public ParticleData getParticleSpawnData() { public ParticleData getParticleSpawnData() {
if (this.particleEffect.hasProperty(ParticleProperty.REQUIRES_DATA)) { if (this.particleEffect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (this.particleEffect == ParticleEffect.ITEM_CRACK) { if (this.particleEffect == ParticleEffect.ITEM) {
return this.particleItemData; return this.particleItemData;
} else { } else {
return particleBlockData; return this.particleBlockData;
} }
} }
return null; return null;
@ -249,10 +249,10 @@ public class PPlayer {
* @return The particle data in a human-readable string * @return The particle data in a human-readable string
*/ */
public String getParticleDataString() { public String getParticleDataString() {
if (this.particleEffect == ParticleEffect.BLOCK_CRACK || this.particleEffect == ParticleEffect.BLOCK_DUST || this.particleEffect == ParticleEffect.FALLING_DUST) { if (this.particleEffect == ParticleEffect.BLOCK || this.particleEffect == ParticleEffect.FALLING_DUST) {
return particleBlockData.getMaterial().toString().toLowerCase() + ":" + particleBlockData.getData(); return particleBlockData.getMaterial().toString().toLowerCase();
} else if (this.particleEffect == ParticleEffect.ITEM_CRACK) { } else if (this.particleEffect == ParticleEffect.ITEM) {
return particleItemData.getMaterial().toString().toLowerCase() + ":" + particleItemData.getData(); return particleItemData.getMaterial().toString().toLowerCase();
} else if (this.particleEffect.hasProperty(ParticleProperty.COLORABLE)) { } else if (this.particleEffect.hasProperty(ParticleProperty.COLORABLE)) {
if (this.particleEffect == ParticleEffect.NOTE) { if (this.particleEffect == ParticleEffect.NOTE) {
if (this.particleNoteColorData.getValueX() * 24 == 99) { if (this.particleNoteColorData.getValueX() * 24 == 99) {
@ -280,8 +280,8 @@ public class PPlayer {
public static PPlayer getNewPPlayer(UUID playerUUID) { public static PPlayer getNewPPlayer(UUID playerUUID) {
ParticleEffect particleEffect = ParticleEffect.NONE; ParticleEffect particleEffect = ParticleEffect.NONE;
ParticleStyle particleStyle = DefaultStyles.NONE; ParticleStyle particleStyle = DefaultStyles.NONE;
ItemData particleItemData = new ItemData(ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"), (byte) 0); ItemData particleItemData = new ItemData(ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"));
BlockData particleBlockData = new BlockData(Material.STONE, (byte) 0); BlockData particleBlockData = new BlockData(Material.STONE);
OrdinaryColor particleColorData = new OrdinaryColor(0, 0, 0); OrdinaryColor particleColorData = new OrdinaryColor(0, 0, 0);
NoteColor particleNoteColorData = new NoteColor(0); NoteColor particleNoteColorData = new NoteColor(0);

View file

@ -12,18 +12,26 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter; import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import com.esophose.playerparticles.manager.MessageManager.MessageType;
import com.esophose.playerparticles.manager.PPlayerDataManager;
import com.esophose.playerparticles.manager.PermissionManager; import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.particles.ParticleEffect;
import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import com.esophose.playerparticles.util.ParticleUtils;
public class ParticleCommandCompleter implements TabCompleter { public class ParticleCommandCompleter implements TabCompleter {
private static final String[] COMMANDS = { "help", "gui", "effect", "effects", "style", "styles", "data", "fixed", "reset", "worlds", "version" }; 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 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
@ -35,20 +43,49 @@ public class ParticleCommandCompleter implements TabCompleter {
* @return A list of commands available to the sender * @return A list of commands available to the sender
*/ */
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
if (!(sender instanceof Player)) return new ArrayList<String>();
List<String> completions = new ArrayList<String>(); List<String> completions = new ArrayList<String>();
if (cmd.getName().equalsIgnoreCase("pp")) { if (cmd.getName().equalsIgnoreCase("pp")) {
if (args.length > 1) { if (args.length > 1) {
if (args[0].equalsIgnoreCase("effect")) { if (args[0].equalsIgnoreCase("effect") && args.length == 2) {
List<String> commands = PermissionManager.getEffectsUserHasPermissionFor((Player) sender); List<String> commands = PermissionManager.getEffectsUserHasPermissionFor((Player) sender);
StringUtil.copyPartialMatches(args[1], commands, completions); StringUtil.copyPartialMatches(args[1], commands, completions);
return completions; } else if (args[0].equalsIgnoreCase("style") && args.length == 2) {
} else if (args[0].equalsIgnoreCase("style")) {
List<String> commands = PermissionManager.getStylesUserHasPermissionFor((Player) sender); List<String> commands = PermissionManager.getStylesUserHasPermissionFor((Player) sender);
StringUtil.copyPartialMatches(args[1], commands, completions); StringUtil.copyPartialMatches(args[1], commands, completions);
return completions; } else if (args[0].equalsIgnoreCase("fixed") && args.length > 1) {
} else if (args[0].equalsIgnoreCase("fixed")) { if (args.length == 2) {
List<String> commands = Arrays.asList(FIXED_COMMANDS); List<String> commands = Arrays.asList(FIXED_COMMANDS);
StringUtil.copyPartialMatches(args[1], commands, completions); 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 = PPlayerDataManager.getInstance().getPPlayer(((Player) sender).getUniqueId());
if (pplayer == null && args.length == 2) {
completions.add(ChatColor.stripColor(MessageType.NO_DATA_USAGE.getMessage()));
} 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(MessageType.NO_DATA_USAGE.getMessage()));
}
} }
} else { } else {
List<String> commands = new ArrayList<String>(Arrays.asList(COMMANDS)); List<String> commands = new ArrayList<String>(Arrays.asList(COMMANDS));

View file

@ -25,7 +25,7 @@ import org.bukkit.entity.Player;
import com.esophose.playerparticles.gui.PlayerParticlesGui; import com.esophose.playerparticles.gui.PlayerParticlesGui;
import com.esophose.playerparticles.gui.PlayerParticlesGui.GuiState; import com.esophose.playerparticles.gui.PlayerParticlesGui.GuiState;
import com.esophose.playerparticles.manager.ConfigManager; import com.esophose.playerparticles.manager.PPlayerDataManager;
import com.esophose.playerparticles.manager.MessageManager; import com.esophose.playerparticles.manager.MessageManager;
import com.esophose.playerparticles.manager.MessageManager.MessageType; import com.esophose.playerparticles.manager.MessageManager.MessageType;
import com.esophose.playerparticles.manager.ParticleManager; import com.esophose.playerparticles.manager.ParticleManager;
@ -105,23 +105,36 @@ public class ParticleCommandExecutor implements CommandExecutor {
// Commands that require access to effects // Commands that require access to effects
if (PermissionManager.getEffectsUserHasPermissionFor(p).size() != 1) { if (PermissionManager.getEffectsUserHasPermissionFor(p).size() != 1) {
switch (args[0].toLowerCase()) { final String[] f_cmdArgs = cmdArgs;
case "effect": PPlayerDataManager.getInstance().getPPlayer(p.getUniqueId(), (pplayer) -> { // The PPlayer MUST be loaded before we can execute any of these commands
onEffect(p, cmdArgs); // If the player no longer has permission for their effect, remove it
break; if (!PermissionManager.hasEffectPermission(p, pplayer.getParticleEffect())) {
case "data": PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), ParticleEffect.NONE);
onData(p, cmdArgs); }
break;
case "fixed": // If the player no longer has permission for their style, default to none
onFixed(p, cmdArgs); if (!PermissionManager.hasStylePermission(p, pplayer.getParticleStyle())) {
break; PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), DefaultStyles.NONE);
case "reset": }
onReset(p, cmdArgs);
break; switch (args[0].toLowerCase()) {
case "gui": case "effect":
onGUI(p, false); onEffect(p, f_cmdArgs);
break; break;
} case "data":
onData(p, f_cmdArgs);
break;
case "fixed":
onFixed(p, f_cmdArgs);
break;
case "reset":
onReset(p, f_cmdArgs);
break;
case "gui":
onGUI(p, false);
break;
}
});
} else { } else {
MessageManager.sendMessage(p, MessageType.NO_PARTICLES); MessageManager.sendMessage(p, MessageType.NO_PARTICLES);
} }
@ -157,13 +170,13 @@ public class ParticleCommandExecutor implements CommandExecutor {
* @param p The player who used the command * @param p The player who used the command
*/ */
private void onWorlds(Player p) { private void onWorlds(Player p) {
if (ConfigManager.getInstance().getDisabledWorlds() == null || ConfigManager.getInstance().getDisabledWorlds().isEmpty()) { if (PPlayerDataManager.getInstance().getDisabledWorlds() == null || PPlayerDataManager.getInstance().getDisabledWorlds().isEmpty()) {
MessageManager.sendMessage(p, MessageType.DISABLED_WORLDS_NONE); MessageManager.sendMessage(p, MessageType.DISABLED_WORLDS_NONE);
return; return;
} }
String worlds = ""; String worlds = "";
for (String s : ConfigManager.getInstance().getDisabledWorlds()) { for (String s : PPlayerDataManager.getInstance().getDisabledWorlds()) {
worlds += s + ", "; worlds += s + ", ";
} }
if (worlds.length() > 2) worlds = worlds.substring(0, worlds.length() - 2); if (worlds.length() > 2) worlds = worlds.substring(0, worlds.length() - 2);
@ -188,13 +201,8 @@ public class ParticleCommandExecutor implements CommandExecutor {
* @param args The arguments for the command * @param args The arguments for the command
*/ */
private void onData(Player p, String[] args) { private void onData(Player p, String[] args) {
if (PermissionManager.getEffectsUserHasPermissionFor(p).size() == 1) { ParticleEffect effect = PPlayerDataManager.getInstance().getPPlayer(p.getUniqueId()).getParticleEffect();
if ((!effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA) && !effect.hasProperty(ParticleProperty.COLORABLE)) || args.length == 0) {
return;
}
ParticleEffect effect = ConfigManager.getInstance().getPPlayer(p.getUniqueId()).getParticleEffect();
if ((!effect.hasProperty(ParticleProperty.REQUIRES_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) {
MessageManager.sendMessage(p, MessageType.DATA_USAGE, "note"); MessageManager.sendMessage(p, MessageType.DATA_USAGE, "note");
@ -203,8 +211,8 @@ public class ParticleCommandExecutor implements CommandExecutor {
MessageManager.sendMessage(p, MessageType.DATA_USAGE, "color"); MessageManager.sendMessage(p, MessageType.DATA_USAGE, "color");
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.COLOR_DATA_USAGE.getMessage()); MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.COLOR_DATA_USAGE.getMessage());
} }
} else if (effect.hasProperty(ParticleProperty.REQUIRES_DATA)) { } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (effect == ParticleEffect.ITEM_CRACK) { if (effect == ParticleEffect.ITEM) {
MessageManager.sendMessage(p, MessageType.DATA_USAGE, "item"); MessageManager.sendMessage(p, MessageType.DATA_USAGE, "item");
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.ITEM_DATA_USAGE.getMessage()); MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.ITEM_DATA_USAGE.getMessage());
} else { } else {
@ -219,7 +227,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
if (effect.hasProperty(ParticleProperty.COLORABLE)) { if (effect.hasProperty(ParticleProperty.COLORABLE)) {
if (effect == ParticleEffect.NOTE) { if (effect == ParticleEffect.NOTE) {
if (args[0].equalsIgnoreCase("rainbow")) { if (args[0].equalsIgnoreCase("rainbow")) {
ConfigManager.getInstance().savePPlayer(p.getUniqueId(), new NoteColor(99)); PPlayerDataManager.getInstance().savePPlayer(p.getUniqueId(), new NoteColor(99));
MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "note"); MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "note");
return; return;
} }
@ -239,11 +247,11 @@ public class ParticleCommandExecutor implements CommandExecutor {
return; return;
} }
ConfigManager.getInstance().savePPlayer(p.getUniqueId(), new NoteColor(note)); PPlayerDataManager.getInstance().savePPlayer(p.getUniqueId(), new NoteColor(note));
MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "note"); MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "note");
} else { } else {
if (args[0].equalsIgnoreCase("rainbow")) { if (args[0].equalsIgnoreCase("rainbow")) {
ConfigManager.getInstance().savePPlayer(p.getUniqueId(), new OrdinaryColor(999, 999, 999)); PPlayerDataManager.getInstance().savePPlayer(p.getUniqueId(), new OrdinaryColor(999, 999, 999));
MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "color"); MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "color");
} else if (args.length >= 3) { } else if (args.length >= 3) {
int r = -1; int r = -1;
@ -266,18 +274,16 @@ public class ParticleCommandExecutor implements CommandExecutor {
return; return;
} }
ConfigManager.getInstance().savePPlayer(p.getUniqueId(), new OrdinaryColor(r, g, b)); PPlayerDataManager.getInstance().savePPlayer(p.getUniqueId(), new OrdinaryColor(r, g, b));
MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "color"); MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "color");
} else { } else {
MessageManager.sendMessage(p, MessageType.DATA_INVALID_ARGUMENTS, "color"); MessageManager.sendMessage(p, MessageType.DATA_INVALID_ARGUMENTS, "color");
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.COLOR_DATA_USAGE.getMessage()); MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.COLOR_DATA_USAGE.getMessage());
} }
} }
} else if (effect.hasProperty(ParticleProperty.REQUIRES_DATA)) { } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (effect == ParticleEffect.ITEM_CRACK) { if (effect == ParticleEffect.ITEM) {
Material material = null; Material material = null;
int data = -1;
try { try {
material = ParticleUtils.closestMatch(args[0]); material = ParticleUtils.closestMatch(args[0]);
if (material == null) material = Material.matchMaterial(args[0]); if (material == null) material = Material.matchMaterial(args[0]);
@ -288,32 +294,16 @@ public class ParticleCommandExecutor implements CommandExecutor {
return; return;
} }
try {
data = Integer.parseInt(args[1]);
} catch (Exception e) {
MessageManager.sendMessage(p, MessageType.DATA_INVALID_ARGUMENTS, "item");
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.ITEM_DATA_USAGE.getMessage());
return;
}
if (material.isBlock()) { if (material.isBlock()) {
MessageManager.sendMessage(p, MessageType.DATA_MATERIAL_MISMATCH, "item"); MessageManager.sendMessage(p, MessageType.DATA_MATERIAL_MISMATCH, "item");
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.ITEM_DATA_USAGE.getMessage()); MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.ITEM_DATA_USAGE.getMessage());
return; return;
} }
if (data < 0 || data > 15) { PPlayerDataManager.getInstance().savePPlayer(p.getUniqueId(), new ItemData(material));
MessageManager.sendMessage(p, MessageType.DATA_INVALID_ARGUMENTS, "item");
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.ITEM_DATA_USAGE.getMessage());
return;
}
ConfigManager.getInstance().savePPlayer(p.getUniqueId(), new ItemData(material, (byte) data));
MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "item"); MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "item");
} else { } else {
Material material = null; Material material = null;
int data = -1;
try { try {
material = ParticleUtils.closestMatch(args[0]); material = ParticleUtils.closestMatch(args[0]);
if (material == null) material = Material.matchMaterial(args[0]); if (material == null) material = Material.matchMaterial(args[0]);
@ -324,27 +314,13 @@ public class ParticleCommandExecutor implements CommandExecutor {
return; return;
} }
try {
data = Integer.parseInt(args[1]);
} catch (Exception e) {
MessageManager.sendMessage(p, MessageType.DATA_INVALID_ARGUMENTS, "block");
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.BLOCK_DATA_USAGE.getMessage());
return;
}
if (!material.isBlock()) { if (!material.isBlock()) {
MessageManager.sendMessage(p, MessageType.DATA_MATERIAL_MISMATCH, "block"); MessageManager.sendMessage(p, MessageType.DATA_MATERIAL_MISMATCH, "block");
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.BLOCK_DATA_USAGE.getMessage()); MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.BLOCK_DATA_USAGE.getMessage());
return; return;
} }
if (data < 0 || data > 15) { PPlayerDataManager.getInstance().savePPlayer(p.getUniqueId(), new BlockData(material));
MessageManager.sendMessage(p, MessageType.DATA_INVALID_ARGUMENTS, "block");
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.BLOCK_DATA_USAGE.getMessage());
return;
}
ConfigManager.getInstance().savePPlayer(p.getUniqueId(), new BlockData(material, (byte) data));
MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "block"); MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "block");
} }
} }
@ -367,14 +343,14 @@ public class ParticleCommandExecutor implements CommandExecutor {
if (altPlayer == null) { if (altPlayer == null) {
MessageManager.sendMessage(p, MessageType.FAILED_EXECUTE_NOT_FOUND, altPlayerName); MessageManager.sendMessage(p, MessageType.FAILED_EXECUTE_NOT_FOUND, altPlayerName);
} else { } else {
ConfigManager.getInstance().resetPPlayer(altPlayer.getUniqueId()); PPlayerDataManager.getInstance().resetPPlayer(altPlayer.getUniqueId());
MessageManager.sendMessage(altPlayer, MessageType.RESET); MessageManager.sendMessage(altPlayer, MessageType.RESET);
MessageManager.sendMessage(p, MessageType.EXECUTED_FOR_PLAYER, altPlayer.getName()); MessageManager.sendMessage(p, MessageType.EXECUTED_FOR_PLAYER, altPlayer.getName());
} }
} }
} else { } else {
ConfigManager.getInstance().resetPPlayer(p.getUniqueId()); PPlayerDataManager.getInstance().resetPPlayer(p.getUniqueId());
MessageManager.sendMessage(p, MessageType.RESET); MessageManager.sendMessage(p, MessageType.RESET);
} }
} }
@ -390,16 +366,16 @@ public class ParticleCommandExecutor implements CommandExecutor {
MessageManager.sendMessage(p, MessageType.INVALID_TYPE); MessageManager.sendMessage(p, MessageType.INVALID_TYPE);
return; return;
} }
String argument = args[0].replace("_", ""); String argument = args[0];
if (ParticleManager.effectFromString(argument) != null) { if (ParticleManager.effectFromString(argument) != null) {
ParticleEffect effect = ParticleManager.effectFromString(argument); ParticleEffect effect = ParticleManager.effectFromString(argument);
if (!PermissionManager.hasEffectPermission(p, effect)) { if (!PermissionManager.hasEffectPermission(p, effect)) {
MessageManager.sendMessage(p, MessageType.NO_PERMISSION, effect.getName().toLowerCase()); MessageManager.sendMessage(p, MessageType.NO_PERMISSION, effect.getName());
return; return;
} }
ConfigManager.getInstance().savePPlayer(p.getUniqueId(), effect); PPlayerDataManager.getInstance().savePPlayer(p.getUniqueId(), effect);
if (effect != ParticleEffect.NONE) { if (effect != ParticleEffect.NONE) {
MessageManager.sendMessage(p, MessageType.NOW_USING, effect.getName().toLowerCase()); MessageManager.sendMessage(p, MessageType.NOW_USING, effect.getName());
} else { } else {
MessageManager.sendMessage(p, MessageType.CLEARED_PARTICLES); MessageManager.sendMessage(p, MessageType.CLEARED_PARTICLES);
} }
@ -422,7 +398,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
String toSend = MessageType.USE.getMessage() + " "; String toSend = MessageType.USE.getMessage() + " ";
for (ParticleEffect effect : ParticleEffect.getSupportedEffects()) { for (ParticleEffect effect : ParticleEffect.getSupportedEffects()) {
if (PermissionManager.hasEffectPermission(p, effect)) { if (PermissionManager.hasEffectPermission(p, effect)) {
toSend += effect.getName().toLowerCase().replace("_", "") + ", "; toSend += effect.getName() + ", ";
continue; continue;
} }
} }
@ -449,16 +425,16 @@ public class ParticleCommandExecutor implements CommandExecutor {
MessageManager.sendMessage(p, MessageType.INVALID_TYPE_STYLE); MessageManager.sendMessage(p, MessageType.INVALID_TYPE_STYLE);
return; return;
} }
String argument = args[0].replace("_", ""); String argument = args[0];
if (ParticleStyleManager.styleFromString(argument) != null) { if (ParticleStyleManager.styleFromString(argument) != null) {
ParticleStyle style = ParticleStyleManager.styleFromString(argument); ParticleStyle style = ParticleStyleManager.styleFromString(argument);
if (!PermissionManager.hasStylePermission(p, style)) { if (!PermissionManager.hasStylePermission(p, style)) {
MessageManager.sendMessage(p, MessageType.NO_PERMISSION_STYLE, style.getName().toLowerCase()); MessageManager.sendMessage(p, MessageType.NO_PERMISSION_STYLE, style.getName());
return; return;
} }
ConfigManager.getInstance().savePPlayer(p.getUniqueId(), style); PPlayerDataManager.getInstance().savePPlayer(p.getUniqueId(), style);
if (style != DefaultStyles.NONE) { if (style != DefaultStyles.NONE) {
MessageManager.sendMessage(p, MessageType.NOW_USING_STYLE, style.getName().toLowerCase()); MessageManager.sendMessage(p, MessageType.NOW_USING_STYLE, style.getName());
} else { } else {
MessageManager.sendMessage(p, MessageType.CLEARED_STYLE); MessageManager.sendMessage(p, MessageType.CLEARED_STYLE);
} }
@ -481,7 +457,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
String toSend = MessageType.USE.getMessage() + " "; String toSend = MessageType.USE.getMessage() + " ";
for (ParticleStyle style : ParticleStyleManager.getStyles()) { for (ParticleStyle style : ParticleStyleManager.getStyles()) {
if (PermissionManager.hasStylePermission(p, style)) { if (PermissionManager.hasStylePermission(p, style)) {
toSend += style.getName().toLowerCase(); toSend += style.getName();
toSend += ", "; toSend += ", ";
} }
} }
@ -525,7 +501,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
if (cmd.equalsIgnoreCase("create")) { if (cmd.equalsIgnoreCase("create")) {
final String[] f_args = args; final String[] f_args = args;
ConfigManager.getInstance().hasPlayerReachedMaxFixedEffects(p.getUniqueId(), (reachedMax) -> { PPlayerDataManager.getInstance().hasPlayerReachedMaxFixedEffects(p.getUniqueId(), (reachedMax) -> {
if (reachedMax) { if (reachedMax) {
MessageManager.sendMessage(p, MessageType.MAX_FIXED_EFFECTS_REACHED); MessageManager.sendMessage(p, MessageType.MAX_FIXED_EFFECTS_REACHED);
return; return;
@ -564,7 +540,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
} }
double distanceFromEffect = p.getLocation().distance(new Location(p.getWorld(), xPos, yPos, zPos)); double distanceFromEffect = p.getLocation().distance(new Location(p.getWorld(), xPos, yPos, zPos));
int maxCreationDistance = ConfigManager.getInstance().getMaxFixedEffectCreationDistance(); int maxCreationDistance = PPlayerDataManager.getInstance().getMaxFixedEffectCreationDistance();
if (maxCreationDistance != 0 && distanceFromEffect > maxCreationDistance) { if (maxCreationDistance != 0 && distanceFromEffect > maxCreationDistance) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_OUT_OF_RANGE, maxCreationDistance + ""); MessageManager.sendMessage(p, MessageType.CREATE_FIXED_OUT_OF_RANGE, maxCreationDistance + "");
return; return;
@ -644,11 +620,9 @@ public class ParticleCommandExecutor implements CommandExecutor {
colorData = new OrdinaryColor(r, g, b); colorData = new OrdinaryColor(r, g, b);
} }
} }
} else if (effect.hasProperty(ParticleProperty.REQUIRES_DATA)) { } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (effect == ParticleEffect.BLOCK_CRACK || effect == ParticleEffect.BLOCK_DUST || effect == ParticleEffect.FALLING_DUST) { if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) {
Material material = null; Material material = null;
int data = -1;
try { try {
material = ParticleUtils.closestMatch(f_args[5]); material = ParticleUtils.closestMatch(f_args[5]);
if (material == null) material = Material.matchMaterial(f_args[5]); if (material == null) material = Material.matchMaterial(f_args[5]);
@ -658,23 +632,9 @@ public class ParticleCommandExecutor implements CommandExecutor {
return; return;
} }
try { blockData = new BlockData(material);
data = Integer.parseInt(f_args[6]); } else if (effect == ParticleEffect.ITEM) {
} catch (Exception e) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_DATA_ERROR, "block");
return;
}
if (data < 0 || data > 15 || !material.isBlock()) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_DATA_ERROR, "block");
return;
}
blockData = new BlockData(material, (byte) data);
} else if (effect == ParticleEffect.ITEM_CRACK) {
Material material = null; Material material = null;
int data = -1;
try { try {
material = ParticleUtils.closestMatch(f_args[5]); material = ParticleUtils.closestMatch(f_args[5]);
if (material == null) material = Material.matchMaterial(f_args[5]); if (material == null) material = Material.matchMaterial(f_args[5]);
@ -684,19 +644,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
return; return;
} }
try { itemData = new ItemData(material);
data = Integer.parseInt(f_args[6]);
} catch (Exception e) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_DATA_ERROR, "item");
return;
}
if (data < 0 || data > 15 || material.isBlock()) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_DATA_ERROR, "item");
return;
}
itemData = new ItemData(material, (byte) data);
} }
} }
} }
@ -708,14 +656,14 @@ public class ParticleCommandExecutor implements CommandExecutor {
final OrdinaryColor f_colorData = colorData; final OrdinaryColor f_colorData = colorData;
final NoteColor f_noteData = noteColorData; final NoteColor f_noteData = noteColorData;
ConfigManager.getInstance().getNextFixedEffectId(p.getUniqueId(), (nextFixedEffectId) -> { PPlayerDataManager.getInstance().getNextFixedEffectId(p.getUniqueId(), (nextFixedEffectId) -> {
FixedParticleEffect fixedEffect = new FixedParticleEffect(p.getUniqueId(), // @formatter:off FixedParticleEffect fixedEffect = new FixedParticleEffect(p.getUniqueId(), // @formatter:off
nextFixedEffectId, nextFixedEffectId,
p.getLocation().getWorld().getName(), f_xPos, f_yPos, f_zPos, p.getLocation().getWorld().getName(), f_xPos, f_yPos, f_zPos,
effect, style, f_itemData, f_blockData, f_colorData, f_noteData); // @formatter:on effect, style, f_itemData, f_blockData, f_colorData, f_noteData); // @formatter:on
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_SUCCESS); MessageManager.sendMessage(p, MessageType.CREATE_FIXED_SUCCESS);
ConfigManager.getInstance().saveFixedEffect(fixedEffect); PPlayerDataManager.getInstance().saveFixedEffect(fixedEffect);
}); });
}); });
} else if (cmd.equalsIgnoreCase("remove")) { } else if (cmd.equalsIgnoreCase("remove")) {
@ -733,7 +681,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
} }
final int f_id = id; final int f_id = id;
ConfigManager.getInstance().removeFixedEffect(p.getUniqueId(), id, (successful) -> { PPlayerDataManager.getInstance().removeFixedEffect(p.getUniqueId(), id, (successful) -> {
if (successful) { if (successful) {
MessageManager.sendMessage(p, MessageType.REMOVE_FIXED_SUCCESS, f_id + ""); MessageManager.sendMessage(p, MessageType.REMOVE_FIXED_SUCCESS, f_id + "");
} else { } else {
@ -741,7 +689,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
} }
}); });
} else if (cmd.equalsIgnoreCase("list")) { } else if (cmd.equalsIgnoreCase("list")) {
ConfigManager.getInstance().getFixedEffectIdsForPlayer(p.getUniqueId(), (ids) -> { PPlayerDataManager.getInstance().getFixedEffectIdsForPlayer(p.getUniqueId(), (ids) -> {
Collections.sort(ids); Collections.sort(ids);
if (ids.isEmpty()) { if (ids.isEmpty()) {
@ -775,7 +723,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
final int f_id = id; final int f_id = id;
ConfigManager.getInstance().getFixedEffectForPlayerById(p.getUniqueId(), id, (fixedEffect) -> { PPlayerDataManager.getInstance().getFixedEffectForPlayerById(p.getUniqueId(), id, (fixedEffect) -> {
if (fixedEffect == null) { if (fixedEffect == null) {
MessageManager.sendMessage(p, MessageType.INFO_FIXED_NONEXISTANT, f_id + ""); MessageManager.sendMessage(p, MessageType.INFO_FIXED_NONEXISTANT, f_id + "");
return; return;
@ -819,7 +767,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
fixedEffectsToRemove.add(fixedEffect); fixedEffectsToRemove.add(fixedEffect);
for (FixedParticleEffect fixedEffect : fixedEffectsToRemove) for (FixedParticleEffect fixedEffect : fixedEffectsToRemove)
ConfigManager.getInstance().removeFixedEffect(fixedEffect.getOwnerUniqueId(), fixedEffect.getId(), (successful) -> { }); PPlayerDataManager.getInstance().removeFixedEffect(fixedEffect.getOwnerUniqueId(), fixedEffect.getId(), (successful) -> { });
String clearMessage = MessageType.CLEAR_FIXED_SUCCESS.getMessage() // @formatter:off String clearMessage = MessageType.CLEAR_FIXED_SUCCESS.getMessage() // @formatter:off
.replaceAll("\\{0\\}", fixedEffectsToRemove.size() + "") .replaceAll("\\{0\\}", fixedEffectsToRemove.size() + "")
@ -859,7 +807,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
MessageManager.sendMessage(p, MessageType.GUI_BY_DEFAULT); MessageManager.sendMessage(p, MessageType.GUI_BY_DEFAULT);
} }
ConfigManager.getInstance().getPPlayer(p.getUniqueId(), (pplayer) -> { PPlayerDataManager.getInstance().getPPlayer(p.getUniqueId(), (pplayer) -> {
PlayerParticlesGui.changeState(pplayer, GuiState.DEFAULT); PlayerParticlesGui.changeState(pplayer, GuiState.DEFAULT);
}); });
} }

View file

@ -74,15 +74,27 @@ public class PlayerParticles extends JavaPlugin {
Bukkit.getPluginManager().registerEvents(new ParticleManager(), this); Bukkit.getPluginManager().registerEvents(new ParticleManager(), this);
Bukkit.getPluginManager().registerEvents(new PluginUpdateListener(), this); Bukkit.getPluginManager().registerEvents(new PluginUpdateListener(), this);
Bukkit.getPluginManager().registerEvents(new PlayerParticlesGui(), this); Bukkit.getPluginManager().registerEvents(new PlayerParticlesGui(), this);
if (getConfig().getDouble("version") < Double.parseDouble(getDescription().getVersion())) { double configVersion = getConfig().getDouble("version");
if (configVersion < Double.parseDouble(getDescription().getVersion())) {
File configFile = new File(getDataFolder(), "config.yml"); File configFile = new File(getDataFolder(), "config.yml");
if (configFile.exists()) configFile.delete(); if (configFile.exists()) configFile.delete();
saveDefaultConfig(); saveDefaultConfig();
reloadConfig(); reloadConfig();
getLogger().warning("The config.yml has been updated to v" + getDescription().getVersion() + "!"); getLogger().warning("The config.yml has been updated to v" + getDescription().getVersion() + "!");
} }
checkDatabase();
startTask(); if (configVersion < 5.2) {
checkDatabase(true); // @formatter:off
getLogger().warning("All previous player data has been purged. " +
"PlayerParticles v" + getDescription().getVersion() + " is not backwards compatible with the previous data schema. " +
"If you were using regular file storage, the new data file is called pplayerData.yml, the old file playerData.yml is still there. " +
"If you were using database storage, all data has been deleted."); // @formatter:on
} else {
checkDatabase(false);
}
checkDatabase(configVersion < 5.2);
startParticleTask();
if (shouldCheckUpdates()) { if (shouldCheckUpdates()) {
new BukkitRunnable() { new BukkitRunnable() {
@ -138,7 +150,7 @@ public class PlayerParticles extends JavaPlugin {
* Creates new tables if they don't exist * Creates new tables if they don't exist
* Sets useMySQL to true if it connects successfully, and false if it fails or isn't enabled * Sets useMySQL to true if it connects successfully, and false if it fails or isn't enabled
*/ */
private void checkDatabase() { private void checkDatabase(boolean shouldPurge) {
if (getConfig().getBoolean("database-enable")) { if (getConfig().getBoolean("database-enable")) {
mySQL = new DatabaseManager(getConfig()); mySQL = new DatabaseManager(getConfig());
@ -147,6 +159,23 @@ public class PlayerParticles extends JavaPlugin {
// Queries are purposely not run in an asynchronous task, this is on plugin startup and shouldn't affect the end users // Queries are purposely not run in an asynchronous task, this is on plugin startup and shouldn't affect the end users
mySQL.connect((connection) -> { // @formatter:off mySQL.connect((connection) -> { // @formatter:off
if (shouldPurge) { // Reset the database
try (Statement statement = connection.createStatement()) {
statement.addBatch("DROP TABLE pp_users"); // Drop tables, they will be recreated from scratch
statement.addBatch("DROP TABLE pp_fixed");
statement.addBatch("DROP TABLE pp_data_item");
statement.addBatch("DROP TABLE pp_data_block");
statement.addBatch("DROP TABLE pp_data_color");
statement.addBatch("DROP TABLE pp_data_note");
statement.executeBatch();
} catch (SQLException e) {
getLogger().info("Failed to connect to the MySQL Database! Check to see if your login information is correct!");
getLogger().info("Additional information: " + e.getMessage());
useMySQL = false;
return;
}
}
try (Statement statement = connection.createStatement(); try (Statement statement = connection.createStatement();
ResultSet res = statement.executeQuery("SHOW TABLES LIKE 'pp_users'")) { ResultSet res = statement.executeQuery("SHOW TABLES LIKE 'pp_users'")) {
@ -165,8 +194,8 @@ public class PlayerParticles extends JavaPlugin {
} else { // Database isn't created yet } else { // Database isn't created yet
mySQL.updateSQL("CREATE TABLE pp_users (player_uuid VARCHAR(36), effect VARCHAR(32), style VARCHAR(32));" + mySQL.updateSQL("CREATE TABLE pp_users (player_uuid VARCHAR(36), effect VARCHAR(32), style VARCHAR(32));" +
"CREATE TABLE pp_fixed (uuid VARCHAR(36), player_uuid VARCHAR(36), id SMALLINT, effect VARCHAR(32), style VARCHAR(32), worldName VARCHAR(50), xPos DOUBLE, yPos DOUBLE, zPos DOUBLE);" + "CREATE TABLE pp_fixed (uuid VARCHAR(36), player_uuid VARCHAR(36), id SMALLINT, effect VARCHAR(32), style VARCHAR(32), worldName VARCHAR(50), xPos DOUBLE, yPos DOUBLE, zPos DOUBLE);" +
"CREATE TABLE pp_data_item (uuid VARCHAR(36), material VARCHAR(32), data SMALLINT);" + "CREATE TABLE pp_data_item (uuid VARCHAR(36), material VARCHAR(32));" +
"CREATE TABLE pp_data_block (uuid VARCHAR(36), material VARCHAR(32), data SMALLINT);" + "CREATE TABLE pp_data_block (uuid VARCHAR(36), material VARCHAR(32));" +
"CREATE TABLE pp_data_color (uuid VARCHAR(36), r SMALLINT, g SMALLINT, b SMALLINT);" + "CREATE TABLE pp_data_color (uuid VARCHAR(36), r SMALLINT, g SMALLINT, b SMALLINT);" +
"CREATE TABLE pp_data_note (uuid VARCHAR(36), note SMALLINT);"); "CREATE TABLE pp_data_note (uuid VARCHAR(36), note SMALLINT);");
} }
@ -186,7 +215,7 @@ public class PlayerParticles extends JavaPlugin {
* Starts the task reponsible for spawning particles * Starts the task reponsible for spawning particles
* Run in the synchronous task so it starts after all plugins have loaded, including extensions * Run in the synchronous task so it starts after all plugins have loaded, including extensions
*/ */
private void startTask() { private void startParticleTask() {
final Plugin playerParticles = this; final Plugin playerParticles = this;
new BukkitRunnable() { new BukkitRunnable() {
public void run() { public void run() {

View file

@ -38,7 +38,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import com.esophose.playerparticles.PPlayer; import com.esophose.playerparticles.PPlayer;
import com.esophose.playerparticles.PlayerParticles; import com.esophose.playerparticles.PlayerParticles;
import com.esophose.playerparticles.manager.ConfigManager; import com.esophose.playerparticles.manager.PPlayerDataManager;
import com.esophose.playerparticles.manager.MessageManager.MessageType; import com.esophose.playerparticles.manager.MessageManager.MessageType;
import com.esophose.playerparticles.particles.ParticleEffect; import com.esophose.playerparticles.particles.ParticleEffect;
import com.esophose.playerparticles.particles.ParticleEffect.BlockData; import com.esophose.playerparticles.particles.ParticleEffect.BlockData;
@ -102,22 +102,22 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
static { // @formatter:off static { // @formatter:off
colorMapping = new ColorData[] { colorMapping = new ColorData[] {
new ColorData(DyeColor.RED, Material.ROSE_RED, new OrdinaryColor(255, 0, 0), ChatColor.RED + "red"), new ColorData(DyeColor.RED, ParticleUtils.closestMatch("ROSE_RED"), new OrdinaryColor(255, 0, 0), ChatColor.RED + "red"),
new ColorData(DyeColor.ORANGE, Material.ORANGE_DYE, new OrdinaryColor(255, 140, 0), ChatColor.GOLD + "orange"), new ColorData(DyeColor.ORANGE, ParticleUtils.closestMatch("ORANGE_DYE"), new OrdinaryColor(255, 140, 0), ChatColor.GOLD + "orange"),
new ColorData(DyeColor.YELLOW, Material.DANDELION_YELLOW, new OrdinaryColor(255, 255, 0), ChatColor.YELLOW + "yellow"), new ColorData(DyeColor.YELLOW, ParticleUtils.closestMatch("DANDELION_YELLOW"), new OrdinaryColor(255, 255, 0), ChatColor.YELLOW + "yellow"),
new ColorData(DyeColor.LIME, Material.LIME_DYE, new OrdinaryColor(50, 205, 50), ChatColor.GREEN + "lime green"), new ColorData(DyeColor.LIME, ParticleUtils.closestMatch("LIME_DYE"), new OrdinaryColor(50, 205, 50), ChatColor.GREEN + "lime green"),
new ColorData(DyeColor.GREEN, Material.CACTUS_GREEN, new OrdinaryColor(0, 128, 0), ChatColor.DARK_GREEN + "green"), new ColorData(DyeColor.GREEN, ParticleUtils.closestMatch("CACTUS_GREEN"), new OrdinaryColor(0, 128, 0), ChatColor.DARK_GREEN + "green"),
new ColorData(DyeColor.BLUE, Material.LAPIS_LAZULI, new OrdinaryColor(0, 0, 255), ChatColor.DARK_BLUE + "blue"), new ColorData(DyeColor.BLUE, ParticleUtils.closestMatch("LAPIZ_LAZULI"), new OrdinaryColor(0, 0, 255), ChatColor.DARK_BLUE + "blue"),
new ColorData(DyeColor.CYAN, Material.CYAN_DYE, new OrdinaryColor(0, 139, 139), ChatColor.DARK_AQUA + "cyan"), new ColorData(DyeColor.CYAN, ParticleUtils.closestMatch("CYAN_DYE"), new OrdinaryColor(0, 139, 139), ChatColor.DARK_AQUA + "cyan"),
new ColorData(DyeColor.LIGHT_BLUE, Material.LIGHT_BLUE_DYE, new OrdinaryColor(173, 216, 230), ChatColor.AQUA + "light blue"), new ColorData(DyeColor.LIGHT_BLUE, ParticleUtils.closestMatch("LIGHT_BLUE_DYE"), new OrdinaryColor(173, 216, 230), ChatColor.AQUA + "light blue"),
new ColorData(DyeColor.PURPLE, Material.PURPLE_DYE, new OrdinaryColor(138, 43, 226), ChatColor.DARK_PURPLE + "purple"), new ColorData(DyeColor.PURPLE, ParticleUtils.closestMatch("PURPLE_DYE"), new OrdinaryColor(138, 43, 226), ChatColor.DARK_PURPLE + "purple"),
new ColorData(DyeColor.MAGENTA, Material.MAGENTA_DYE, new OrdinaryColor(202, 31, 123), ChatColor.LIGHT_PURPLE + "magenta"), new ColorData(DyeColor.MAGENTA, ParticleUtils.closestMatch("MAGENTA_DYE"), new OrdinaryColor(202, 31, 123), ChatColor.LIGHT_PURPLE + "magenta"),
new ColorData(DyeColor.PINK, Material.PINK_DYE, new OrdinaryColor(255, 182, 193), ChatColor.LIGHT_PURPLE + "pink"), new ColorData(DyeColor.PINK, ParticleUtils.closestMatch("PINK_DYE"), new OrdinaryColor(255, 182, 193), ChatColor.LIGHT_PURPLE + "pink"),
new ColorData(DyeColor.BROWN, Material.COCOA_BEANS, new OrdinaryColor(139, 69, 19), ChatColor.GOLD + "brown"), new ColorData(DyeColor.BROWN, ParticleUtils.closestMatch("COCOA_BEANS"), new OrdinaryColor(139, 69, 19), ChatColor.GOLD + "brown"),
new ColorData(DyeColor.BLACK, Material.INK_SAC, new OrdinaryColor(0, 0, 0), ChatColor.DARK_GRAY + "black"), new ColorData(DyeColor.BLACK, ParticleUtils.closestMatch("INK_SAC"), new OrdinaryColor(0, 0, 0), ChatColor.DARK_GRAY + "black"),
new ColorData(DyeColor.GRAY, Material.GRAY_DYE, new OrdinaryColor(128, 128, 128), ChatColor.DARK_GRAY + "gray"), new ColorData(DyeColor.GRAY, ParticleUtils.closestMatch("GRAY_DYE"), new OrdinaryColor(128, 128, 128), ChatColor.DARK_GRAY + "gray"),
new ColorData(DyeColor.getByColor(Color.SILVER), Material.LIGHT_GRAY_DYE, new OrdinaryColor(192, 192, 192), ChatColor.GRAY + "light gray"), new ColorData(DyeColor.getByColor(Color.SILVER), ParticleUtils.closestMatch("LIGHT_GRAY_DYE"), new OrdinaryColor(192, 192, 192), ChatColor.GRAY + "light gray"),
new ColorData(DyeColor.WHITE, Material.BONE_MEAL, new OrdinaryColor(255, 255, 255), ChatColor.WHITE + "white"), new ColorData(DyeColor.WHITE, ParticleUtils.closestMatch("BONE_MEAL"), new OrdinaryColor(255, 255, 255), ChatColor.WHITE + "white"),
}; };
rainbowColors = new DyeColor[] { rainbowColors = new DyeColor[] {
@ -157,7 +157,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
ParticleUtils.closestMatchWithFallback("NETHERRACK"), ParticleUtils.closestMatchWithFallback("NETHERRACK"),
ParticleUtils.closestMatchWithFallback("SOUL_SAND"), ParticleUtils.closestMatchWithFallback("SOUL_SAND"),
ParticleUtils.closestMatchWithFallback("GLOWSTONE"), ParticleUtils.closestMatchWithFallback("GLOWSTONE"),
ParticleUtils.closestMatchWithFallback("NETHER_BRICK"), ParticleUtils.closestMatchWithFallback("NETHER_BRICKS"),
ParticleUtils.closestMatchWithFallback("END_STONE", "ENDER_STONE"), ParticleUtils.closestMatchWithFallback("END_STONE", "ENDER_STONE"),
ParticleUtils.closestMatchWithFallback("PRISMARINE") ParticleUtils.closestMatchWithFallback("PRISMARINE")
}; };
@ -213,7 +213,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
for (int i = 0; i < defaultMenuIcons.length; i++) for (int i = 0; i < defaultMenuIcons.length; i++)
if (defaultMenuIcons[i] == null) defaultMenuIcons[i] = Material.BARRIER; if (defaultMenuIcons[i] == null) defaultMenuIcons[i] = Material.BARRIER;
for (ParticleEffect effect : ParticleEffect.values()) { for (ParticleEffect effect : ParticleEffect.getSupportedEffects()) {
String effectName = effect.name(); String effectName = effect.name();
Material iconMaterial = ParticleUtils.closestMatch(config.getString("gui-icon.effect." + effectName)); Material iconMaterial = ParticleUtils.closestMatch(config.getString("gui-icon.effect." + effectName));
if (iconMaterial == null) iconMaterial = Material.BARRIER; // Missing icon or invalid? Replace it with a barrier instead to fail safety. if (iconMaterial == null) iconMaterial = Material.BARRIER; // Missing icon or invalid? Replace it with a barrier instead to fail safety.
@ -239,7 +239,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
for (Map.Entry<UUID, GuiInventory> entry : playerGuiInventories.entrySet()) { for (Map.Entry<UUID, GuiInventory> entry : playerGuiInventories.entrySet()) {
UUID playerUUID = entry.getKey(); UUID playerUUID = entry.getKey();
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(playerUUID); PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(playerUUID);
if (pplayer == null) { if (pplayer == null) {
toRemoveList.add(playerUUID); toRemoveList.add(playerUUID);
continue; continue;
@ -368,11 +368,11 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
SkullMeta currentIconMeta = (SkullMeta) currentIcon.getItemMeta(); SkullMeta currentIconMeta = (SkullMeta) currentIcon.getItemMeta();
currentIconMeta.setDisplayName(ChatColor.GREEN + player.getName()); currentIconMeta.setDisplayName(ChatColor.GREEN + player.getName());
String[] currentIconLore = new String[3]; String[] currentIconLore = new String[3];
currentIconLore[0] = ChatColor.YELLOW + "Effect: " + ChatColor.AQUA + p.getParticleEffect().getName().toLowerCase(); currentIconLore[0] = ChatColor.YELLOW + "Effect: " + ChatColor.AQUA + p.getParticleEffect().getName();
currentIconLore[1] = ChatColor.YELLOW + "Style: " + ChatColor.AQUA + p.getParticleStyle().getName(); currentIconLore[1] = ChatColor.YELLOW + "Style: " + ChatColor.AQUA + p.getParticleStyle().getName();
currentIconLore[2] = ChatColor.YELLOW + "Active Data: " + ChatColor.AQUA + p.getParticleDataString(); currentIconLore[2] = ChatColor.YELLOW + "Active Data: " + ChatColor.AQUA + p.getParticleDataString();
currentIconMeta.setLore(Arrays.asList(currentIconLore)); currentIconMeta.setLore(Arrays.asList(currentIconLore));
currentIconMeta.setOwningPlayer(Bukkit.getOfflinePlayer(player.getUniqueId())); currentIconMeta.setOwner(player.getName());
currentIcon.setItemMeta(currentIconMeta); currentIcon.setItemMeta(currentIconMeta);
ItemStack effectIcon = new ItemStack(defaultMenuIcons[0], 1); ItemStack effectIcon = new ItemStack(defaultMenuIcons[0], 1);
@ -401,7 +401,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
if (pe.hasProperty(ParticleProperty.COLORABLE)) // @formatter:off if (pe.hasProperty(ParticleProperty.COLORABLE)) // @formatter:off
if (pe == ParticleEffect.NOTE) dataType = "note " + dataType; if (pe == ParticleEffect.NOTE) dataType = "note " + dataType;
else dataType = "color " + dataType; else dataType = "color " + dataType;
else if (pe.hasProperty(ParticleProperty.REQUIRES_DATA)) if (pe == ParticleEffect.ITEM_CRACK) dataType = "item " + dataType; else if (pe.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) if (pe == ParticleEffect.ITEM) dataType = "item " + dataType;
else dataType = "block " + dataType; // @formatter:on else dataType = "block " + dataType; // @formatter:on
dataIconMeta.setLore(Arrays.asList(MessageType.GUI_ICON_SET_YOUR.getMessageReplaced(dataType))); dataIconMeta.setLore(Arrays.asList(MessageType.GUI_ICON_SET_YOUR.getMessageReplaced(dataType)));
if (p.getParticleSpawnData() == null && p.getParticleSpawnColor() == null) { if (p.getParticleSpawnData() == null && p.getParticleSpawnColor() == null) {
@ -509,8 +509,8 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
inventory.setItem(40, getItemForRainbowColorData(p.getColorData(), rainbowColors[rainbowColorsIndex])); inventory.setItem(40, getItemForRainbowColorData(p.getColorData(), rainbowColors[rainbowColorsIndex]));
} }
} else if (pe.hasProperty(ParticleProperty.REQUIRES_DATA)) { } else if (pe.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (pe == ParticleEffect.ITEM_CRACK) { // Item data if (pe == ParticleEffect.ITEM) { // Item data
Material currentItemMaterial = p.getItemData().getMaterial(); Material currentItemMaterial = p.getItemData().getMaterial();
int itemMaterialIndex = 0; int itemMaterialIndex = 0;
for (int i = 10; i <= 16; i++) { // Top row for (int i = 10; i <= 16; i++) { // Top row
@ -575,7 +575,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
if (!guiInventory.getInventory().equals(e.getClickedInventory())) return; // Clicked bottom inventory if (!guiInventory.getInventory().equals(e.getClickedInventory())) return; // Clicked bottom inventory
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(player.getUniqueId()); PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(player.getUniqueId());
if (pplayer == null) { if (pplayer == null) {
player.closeInventory(); player.closeInventory();
return; return;
@ -602,11 +602,11 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
} }
break; break;
case EFFECT: case EFFECT:
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), ParticleManager.effectFromString(name)); PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), ParticleManager.effectFromString(name));
changeState(pplayer, GuiState.DEFAULT); changeState(pplayer, GuiState.DEFAULT);
break; break;
case STYLE: case STYLE:
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), ParticleStyleManager.styleFromString(name)); PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), ParticleStyleManager.styleFromString(name));
changeState(pplayer, GuiState.DEFAULT); changeState(pplayer, GuiState.DEFAULT);
break; break;
case DATA: case DATA:
@ -614,28 +614,28 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
if (pe.hasProperty(ParticleProperty.COLORABLE)) { if (pe.hasProperty(ParticleProperty.COLORABLE)) {
if (pe == ParticleEffect.NOTE) { if (pe == ParticleEffect.NOTE) {
if (clicked.getItemMeta().getDisplayName().equals(rainbowName)) { if (clicked.getItemMeta().getDisplayName().equals(rainbowName)) {
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), new NoteColor(99)); PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), new NoteColor(99));
} else { } else {
int note = Integer.parseInt(ChatColor.stripColor(clicked.getItemMeta().getDisplayName()).substring(6)); int note = Integer.parseInt(ChatColor.stripColor(clicked.getItemMeta().getDisplayName()).substring(6));
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), new NoteColor(note)); PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), new NoteColor(note));
} }
} else { } else {
if (clicked.getItemMeta().getDisplayName().equals(rainbowName)) { if (clicked.getItemMeta().getDisplayName().equals(rainbowName)) {
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), new OrdinaryColor(999, 999, 999)); PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), new OrdinaryColor(999, 999, 999));
} else { } else {
for (int i = 0; i < colorMapping.length; i++) { for (int i = 0; i < colorMapping.length; i++) {
if (clicked.getItemMeta().getDisplayName().equals(colorMapping[i].getName())) { if (clicked.getItemMeta().getDisplayName().equals(colorMapping[i].getName())) {
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), colorMapping[i].getOrdinaryColor()); PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), colorMapping[i].getOrdinaryColor());
} }
} }
} }
} }
} else if (pe.hasProperty(ParticleProperty.REQUIRES_DATA)) { } else if (pe.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
Material clickedMaterial = clicked.getType(); // All preset materials have a data value of 0 Material clickedMaterial = clicked.getType(); // All preset materials have a data value of 0
if (pe == ParticleEffect.ITEM_CRACK) { if (pe == ParticleEffect.ITEM) {
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), new ItemData(clickedMaterial, (byte) 0)); PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), new ItemData(clickedMaterial));
} else { } else {
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), new BlockData(clickedMaterial, (byte) 0)); PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), new BlockData(clickedMaterial));
} }
} }
@ -654,11 +654,11 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
ItemStack icon = new ItemStack(effectIcons.get(effect.name()), 1); ItemStack icon = new ItemStack(effectIcons.get(effect.name()), 1);
ItemMeta iconMeta = icon.getItemMeta(); ItemMeta iconMeta = icon.getItemMeta();
iconMeta.setDisplayName(MessageType.GUI_ICON_NAME_COLOR.getMessage() + effect.getName().toLowerCase()); iconMeta.setDisplayName(MessageType.GUI_ICON_NAME_COLOR.getMessage() + effect.getName());
if (!isActive) { if (!isActive) {
iconMeta.setLore(Arrays.asList(MessageType.GUI_ICON_SETS_TO.getMessageReplaced("effect") + effect.getName().toLowerCase())); iconMeta.setLore(Arrays.asList(MessageType.GUI_ICON_SETS_TO.getMessageReplaced("effect") + effect.getName()));
} else { } else {
iconMeta.setLore(Arrays.asList(MessageType.GUI_ICON_SETS_TO.getMessageReplaced("effect") + effect.getName().toLowerCase(), MessageType.GUI_ICON_CURRENT_ACTIVE.getMessageReplaced("effect"))); iconMeta.setLore(Arrays.asList(MessageType.GUI_ICON_SETS_TO.getMessageReplaced("effect") + effect.getName(), MessageType.GUI_ICON_CURRENT_ACTIVE.getMessageReplaced("effect")));
iconMeta.addEnchant(Enchantment.ARROW_INFINITE, -1, true); iconMeta.addEnchant(Enchantment.ARROW_INFINITE, -1, true);
iconMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); iconMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
} }

View file

@ -38,12 +38,12 @@ import com.esophose.playerparticles.styles.api.ParticleStyle;
import com.esophose.playerparticles.styles.api.ParticleStyleManager; import com.esophose.playerparticles.styles.api.ParticleStyleManager;
import com.esophose.playerparticles.util.ParticleUtils; import com.esophose.playerparticles.util.ParticleUtils;
public class ConfigManager { public class PPlayerDataManager {
/** /**
* The instance of the ConfigManager used for effect data * The instance of the ConfigManager used for effect data
*/ */
private static ConfigManager instance = new ConfigManager("playerData"); private static PPlayerDataManager instance = new PPlayerDataManager("pplayerData");
/** /**
* The file the data is located in for the instance * The file the data is located in for the instance
*/ */
@ -71,14 +71,14 @@ public class ConfigManager {
/** /**
* @return The instance of the config for effects * @return The instance of the config for effects
*/ */
public static ConfigManager getInstance() { public static PPlayerDataManager getInstance() {
return instance; return instance;
} }
/** /**
* @param fileName The name of the file * @param fileName The name of the file
*/ */
private ConfigManager(String fileName) { private PPlayerDataManager(String fileName) {
if (!PlayerParticles.useMySQL) { // Don't bother creating the playerData.yml file if we aren't going to use it if (!PlayerParticles.useMySQL) { // Don't bother creating the playerData.yml file if we aren't going to use it
if (!PlayerParticles.getPlugin().getDataFolder().exists()) PlayerParticles.getPlugin().getDataFolder().mkdir(); if (!PlayerParticles.getPlugin().getDataFolder().exists()) PlayerParticles.getPlugin().getDataFolder().mkdir();
@ -165,8 +165,8 @@ public class ConfigManager {
ParticleEffect particleEffect = ParticleEffect.fromName(effectSection.getString("name")); ParticleEffect particleEffect = ParticleEffect.fromName(effectSection.getString("name"));
ParticleStyle particleStyle = ParticleStyleManager.styleFromString(styleSection.getString("name")); ParticleStyle particleStyle = ParticleStyleManager.styleFromString(styleSection.getString("name"));
ItemData particleItemData = new ItemData(Material.matchMaterial(itemDataSection.getString("material")), (byte) itemDataSection.getInt("data")); ItemData particleItemData = new ItemData(Material.matchMaterial(itemDataSection.getString("material")));
BlockData particleBlockData = new BlockData(Material.matchMaterial(blockDataSection.getString("material")), (byte) blockDataSection.getInt("data")); BlockData particleBlockData = new BlockData(Material.matchMaterial(blockDataSection.getString("material")));
OrdinaryColor particleColorData = new OrdinaryColor(colorDataSection.getInt("r"), colorDataSection.getInt("g"), colorDataSection.getInt("b")); OrdinaryColor particleColorData = new OrdinaryColor(colorDataSection.getInt("r"), colorDataSection.getInt("g"), colorDataSection.getInt("b"));
NoteColor particleNoteColorData = new NoteColor(noteColorDataSection.getInt("note")); NoteColor particleNoteColorData = new NoteColor(noteColorDataSection.getInt("note"));
@ -197,8 +197,8 @@ public class ConfigManager {
if (res.next()) { if (res.next()) {
ParticleEffect particleEffect = ParticleEffect.fromName(res.getString("u.effect")); ParticleEffect particleEffect = ParticleEffect.fromName(res.getString("u.effect"));
ParticleStyle particleStyle = ParticleStyleManager.styleFromString(res.getString("u.style")); ParticleStyle particleStyle = ParticleStyleManager.styleFromString(res.getString("u.style"));
ItemData particleItemData = new ItemData(Material.matchMaterial(res.getString("i.material")), res.getByte("i.data")); ItemData particleItemData = new ItemData(Material.matchMaterial(res.getString("i.material")));
BlockData particleBlockData = new BlockData(Material.matchMaterial(res.getString("b.material")), res.getByte("b.data")); BlockData particleBlockData = new BlockData(Material.matchMaterial(res.getString("b.material")));
OrdinaryColor particleColorData = new OrdinaryColor(res.getInt("c.r"), res.getInt("c.g"), res.getInt("c.b")); OrdinaryColor particleColorData = new OrdinaryColor(res.getInt("c.r"), res.getInt("c.g"), res.getInt("c.b"));
NoteColor particleNoteColorData = new NoteColor(res.getByte("n.note")); NoteColor particleNoteColorData = new NoteColor(res.getByte("n.note"));
@ -246,9 +246,7 @@ public class ConfigManager {
effectSection.set("name", pplayer.getParticleEffect().getName()); effectSection.set("name", pplayer.getParticleEffect().getName());
styleSection.set("name", pplayer.getParticleStyle().getName()); styleSection.set("name", pplayer.getParticleStyle().getName());
itemDataSection.set("material", pplayer.getItemData().getMaterial().name()); itemDataSection.set("material", pplayer.getItemData().getMaterial().name());
itemDataSection.set("data", pplayer.getItemData().getData());
blockDataSection.set("material", pplayer.getBlockData().getMaterial().name()); blockDataSection.set("material", pplayer.getBlockData().getMaterial().name());
blockDataSection.set("data", pplayer.getBlockData().getData());
colorDataSection.set("r", pplayer.getColorData().getRed()); colorDataSection.set("r", pplayer.getColorData().getRed());
colorDataSection.set("g", pplayer.getColorData().getGreen()); colorDataSection.set("g", pplayer.getColorData().getGreen());
colorDataSection.set("b", pplayer.getColorData().getBlue()); colorDataSection.set("b", pplayer.getColorData().getBlue());
@ -269,13 +267,11 @@ public class ConfigManager {
"); " + "); " +
"INSERT INTO pp_data_item (uuid, material, data) VALUES (" + "INSERT INTO pp_data_item (uuid, material, data) VALUES (" +
"'" + pplayer.getUniqueId().toString() + "', " + "'" + pplayer.getUniqueId().toString() + "', " +
"'" + pplayer.getItemData().getMaterial().name() + "', " + "'" + pplayer.getItemData().getMaterial().name() +
pplayer.getItemData().getData() +
"); " + "); " +
"INSERT INTO pp_data_block (uuid, material, data) VALUES (" + "INSERT INTO pp_data_block (uuid, material, data) VALUES (" +
"'" + pplayer.getUniqueId().toString() + "', " + "'" + pplayer.getUniqueId().toString() + "', " +
"'" + pplayer.getBlockData().getMaterial().name() + "', " + "'" + pplayer.getBlockData().getMaterial().name() +
pplayer.getBlockData().getData() +
"); " + "); " +
"INSERT INTO pp_data_color (uuid, r, g, b) VALUES (" + "INSERT INTO pp_data_color (uuid, r, g, b) VALUES (" +
"'" + pplayer.getUniqueId().toString() + "', " + "'" + pplayer.getUniqueId().toString() + "', " +
@ -393,12 +389,11 @@ public class ConfigManager {
if (!PlayerParticles.useMySQL) { if (!PlayerParticles.useMySQL) {
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".itemData"); ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".itemData");
section.set("material", particleItemData.getMaterial().name()); section.set("material", particleItemData.getMaterial().name());
section.set("data", particleItemData.getData());
save(); save();
} else { } else {
async(() -> { async(() -> {
try { try {
PlayerParticles.mySQL.updateSQL("UPDATE pp_data_item SET material = '" + particleItemData.getMaterial().name() + "', data = '" + particleItemData.getData() + "' WHERE uuid = '" + playerUUID + "';"); PlayerParticles.mySQL.updateSQL("UPDATE pp_data_item SET material = '" + particleItemData.getMaterial().name() + "' WHERE uuid = '" + playerUUID + "';");
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -420,12 +415,11 @@ public class ConfigManager {
if (!PlayerParticles.useMySQL) { if (!PlayerParticles.useMySQL) {
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".blockData"); ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".blockData");
section.set("material", particleBlockData.getMaterial().name()); section.set("material", particleBlockData.getMaterial().name());
section.set("data", particleBlockData.getData());
save(); save();
} else { } else {
async(() -> { async(() -> {
try { try {
PlayerParticles.mySQL.updateSQL("UPDATE pp_data_block SET material = '" + particleBlockData.getMaterial().name() + "', data = '" + particleBlockData.getData() + "' WHERE uuid = '" + playerUUID + "';"); PlayerParticles.mySQL.updateSQL("UPDATE pp_data_block SET material = '" + particleBlockData.getMaterial().name() + "' WHERE uuid = '" + playerUUID + "';");
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -507,7 +501,6 @@ public class ConfigManager {
baseSection.createSection("colorData"); baseSection.createSection("colorData");
baseSection.createSection("noteColorData"); baseSection.createSection("noteColorData");
} else { } else {
System.out.println("Tried to create a fixed effect with ID " + fixedEffect.getId() + " that already exists!");
return; return;
} }
@ -527,9 +520,7 @@ public class ConfigManager {
effectSection.set("name", fixedEffect.getParticleEffect().getName()); effectSection.set("name", fixedEffect.getParticleEffect().getName());
styleSection.set("name", fixedEffect.getParticleStyle().getName()); styleSection.set("name", fixedEffect.getParticleStyle().getName());
itemDataSection.set("material", fixedEffect.getItemData().getMaterial().name()); itemDataSection.set("material", fixedEffect.getItemData().getMaterial().name());
itemDataSection.set("data", fixedEffect.getItemData().getData());
blockDataSection.set("material", fixedEffect.getBlockData().getMaterial().name()); blockDataSection.set("material", fixedEffect.getBlockData().getMaterial().name());
blockDataSection.set("data", fixedEffect.getBlockData().getData());
colorDataSection.set("r", fixedEffect.getColorData().getRed()); colorDataSection.set("r", fixedEffect.getColorData().getRed());
colorDataSection.set("g", fixedEffect.getColorData().getGreen()); colorDataSection.set("g", fixedEffect.getColorData().getGreen());
colorDataSection.set("b", fixedEffect.getColorData().getBlue()); colorDataSection.set("b", fixedEffect.getColorData().getBlue());
@ -544,7 +535,6 @@ public class ConfigManager {
ResultSet res = statement.executeQuery("SELECT * FROM pp_fixed WHERE player_uuid = '" + fixedEffect.getOwnerUniqueId() + "' AND id = " + fixedEffect.getId())) { ResultSet res = statement.executeQuery("SELECT * FROM pp_fixed WHERE player_uuid = '" + fixedEffect.getOwnerUniqueId() + "' AND id = " + fixedEffect.getId())) {
if (res.next()) { if (res.next()) {
System.out.println("Tried to create a fixed effect with ID " + fixedEffect.getId() + " that already in the database!");
return; return;
} }
@ -563,13 +553,11 @@ public class ConfigManager {
"); " + "); " +
"INSERT INTO pp_data_item (uuid, material, data) VALUES (" + "INSERT INTO pp_data_item (uuid, material, data) VALUES (" +
"'" + fixedEffectUUID + "', " + "'" + fixedEffectUUID + "', " +
"'" + fixedEffect.getItemData().getMaterial().name() + "', " + "'" + fixedEffect.getItemData().getMaterial().name() +
fixedEffect.getItemData().getData() +
"); " + "); " +
"INSERT INTO pp_data_block (uuid, material, data) VALUES (" + "INSERT INTO pp_data_block (uuid, material, data) VALUES (" +
"'" + fixedEffectUUID + "', " + "'" + fixedEffectUUID + "', " +
"'" + fixedEffect.getBlockData().getMaterial().name() + "', " + "'" + fixedEffect.getBlockData().getMaterial().name() +
fixedEffect.getBlockData().getData() +
"); " + "); " +
"INSERT INTO pp_data_color (uuid, r, g, b) VALUES (" + "INSERT INTO pp_data_color (uuid, r, g, b) VALUES (" +
"'" + fixedEffectUUID + "', " + "'" + fixedEffectUUID + "', " +
@ -695,8 +683,8 @@ public class ConfigManager {
double zPos = section.getDouble("zPos"); double zPos = section.getDouble("zPos");
ParticleEffect particleEffect = ParticleEffect.fromName(effectSection.getString("name")); ParticleEffect particleEffect = ParticleEffect.fromName(effectSection.getString("name"));
ParticleStyle particleStyle = ParticleStyleManager.styleFromString(styleSection.getString("name")); ParticleStyle particleStyle = ParticleStyleManager.styleFromString(styleSection.getString("name"));
ItemData particleItemData = new ItemData(Material.matchMaterial(itemDataSection.getString("material")), (byte) itemDataSection.getInt("data")); ItemData particleItemData = new ItemData(Material.matchMaterial(itemDataSection.getString("material")));
BlockData particleBlockData = new BlockData(Material.matchMaterial(blockDataSection.getString("material")), (byte) blockDataSection.getInt("data")); BlockData particleBlockData = new BlockData(Material.matchMaterial(blockDataSection.getString("material")));
OrdinaryColor particleColorData = new OrdinaryColor(colorDataSection.getInt("r"), colorDataSection.getInt("g"), colorDataSection.getInt("b")); OrdinaryColor particleColorData = new OrdinaryColor(colorDataSection.getInt("r"), colorDataSection.getInt("g"), colorDataSection.getInt("b"));
NoteColor particleNoteColorData = new NoteColor(noteColorDataSection.getInt("note")); NoteColor particleNoteColorData = new NoteColor(noteColorDataSection.getInt("note"));
@ -728,8 +716,8 @@ public class ConfigManager {
double zPos = res.getDouble("f.zPos"); double zPos = res.getDouble("f.zPos");
ParticleEffect particleEffect = ParticleManager.effectFromString(res.getString("f.effect")); ParticleEffect particleEffect = ParticleManager.effectFromString(res.getString("f.effect"));
ParticleStyle particleStyle = ParticleStyleManager.styleFromString(res.getString("f.style")); ParticleStyle particleStyle = ParticleStyleManager.styleFromString(res.getString("f.style"));
ItemData particleItemData = new ItemData(Material.matchMaterial(res.getString("i.material")), res.getByte("i.data")); ItemData particleItemData = new ItemData(Material.matchMaterial(res.getString("i.material")));
BlockData particleBlockData = new BlockData(Material.matchMaterial(res.getString("b.material")), res.getByte("b.data")); BlockData particleBlockData = new BlockData(Material.matchMaterial(res.getString("b.material")));
OrdinaryColor particleColorData = new OrdinaryColor(res.getInt("c.r"), res.getInt("c.g"), res.getInt("c.b")); OrdinaryColor particleColorData = new OrdinaryColor(res.getInt("c.r"), res.getInt("c.g"), res.getInt("c.b"));
NoteColor particleNoteColorData = new NoteColor(res.getByte("n.note")); NoteColor particleNoteColorData = new NoteColor(res.getByte("n.note"));
@ -767,8 +755,8 @@ public class ConfigManager {
double zPos = section.getDouble("zPos"); double zPos = section.getDouble("zPos");
ParticleEffect particleEffect = ParticleEffect.fromName(effectSection.getString("name")); ParticleEffect particleEffect = ParticleEffect.fromName(effectSection.getString("name"));
ParticleStyle particleStyle = ParticleStyleManager.styleFromString(styleSection.getString("name")); ParticleStyle particleStyle = ParticleStyleManager.styleFromString(styleSection.getString("name"));
ItemData particleItemData = new ItemData(Material.matchMaterial(itemDataSection.getString("material")), (byte) itemDataSection.getInt("data")); ItemData particleItemData = new ItemData(Material.matchMaterial(itemDataSection.getString("material")));
BlockData particleBlockData = new BlockData(Material.matchMaterial(blockDataSection.getString("material")), (byte) blockDataSection.getInt("data")); BlockData particleBlockData = new BlockData(Material.matchMaterial(blockDataSection.getString("material")));
OrdinaryColor particleColorData = new OrdinaryColor(colorDataSection.getInt("r"), colorDataSection.getInt("g"), colorDataSection.getInt("b")); OrdinaryColor particleColorData = new OrdinaryColor(colorDataSection.getInt("r"), colorDataSection.getInt("g"), colorDataSection.getInt("b"));
NoteColor particleNoteColorData = new NoteColor(noteColorDataSection.getInt("note")); NoteColor particleNoteColorData = new NoteColor(noteColorDataSection.getInt("note"));
@ -793,8 +781,8 @@ public class ConfigManager {
double zPos = res.getDouble("f.zPos"); double zPos = res.getDouble("f.zPos");
ParticleEffect particleEffect = ParticleManager.effectFromString(res.getString("f.effect")); ParticleEffect particleEffect = ParticleManager.effectFromString(res.getString("f.effect"));
ParticleStyle particleStyle = ParticleStyleManager.styleFromString(res.getString("f.style")); ParticleStyle particleStyle = ParticleStyleManager.styleFromString(res.getString("f.style"));
ItemData particleItemData = new ItemData(Material.matchMaterial(res.getString("i.material")), res.getByte("i.data")); ItemData particleItemData = new ItemData(Material.matchMaterial(res.getString("i.material")));
BlockData particleBlockData = new BlockData(Material.matchMaterial(res.getString("b.material")), res.getByte("b.data")); BlockData particleBlockData = new BlockData(Material.matchMaterial(res.getString("b.material")));
OrdinaryColor particleColorData = new OrdinaryColor(res.getInt("c.r"), res.getInt("c.g"), res.getInt("c.b")); OrdinaryColor particleColorData = new OrdinaryColor(res.getInt("c.r"), res.getInt("c.g"), res.getInt("c.b"));
NoteColor particleNoteColorData = new NoteColor(res.getByte("n.note")); NoteColor particleNoteColorData = new NoteColor(res.getByte("n.note"));
@ -975,7 +963,6 @@ public class ConfigManager {
private void async(SyncInterface asyncCallback) { private void async(SyncInterface asyncCallback) {
new BukkitRunnable() { new BukkitRunnable() {
public void run() { public void run() {
System.out.println("Async with thread: " + Thread.currentThread().getName());
asyncCallback.execute(); asyncCallback.execute();
} }
}.runTaskAsynchronously(PlayerParticles.getPlugin()); }.runTaskAsynchronously(PlayerParticles.getPlugin());
@ -989,7 +976,6 @@ public class ConfigManager {
private void sync(SyncInterface syncCallback) { private void sync(SyncInterface syncCallback) {
new BukkitRunnable() { new BukkitRunnable() {
public void run() { public void run() {
System.out.println("Resynced with thread: " + Thread.currentThread().getName());
syncCallback.execute(); syncCallback.execute();
} }
}.runTask(PlayerParticles.getPlugin()); }.runTask(PlayerParticles.getPlugin());

View file

@ -29,7 +29,6 @@ import com.esophose.playerparticles.particles.ParticleEffect;
import com.esophose.playerparticles.particles.ParticleEffect.NoteColor; import com.esophose.playerparticles.particles.ParticleEffect.NoteColor;
import com.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; import com.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import com.esophose.playerparticles.styles.DefaultStyles;
import com.esophose.playerparticles.styles.api.PParticle; import com.esophose.playerparticles.styles.api.PParticle;
import com.esophose.playerparticles.styles.api.ParticleStyleManager; import com.esophose.playerparticles.styles.api.ParticleStyleManager;
@ -59,7 +58,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent e) { public void onPlayerJoin(PlayerJoinEvent e) {
ConfigManager.getInstance().loadPPlayer(e.getPlayer().getUniqueId()); PPlayerDataManager.getInstance().loadPPlayer(e.getPlayer().getUniqueId());
} }
/** /**
@ -69,7 +68,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
*/ */
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent e) { public void onPlayerQuit(PlayerQuitEvent e) {
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(e.getPlayer().getUniqueId()); PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(e.getPlayer().getUniqueId());
if (pplayer != null) if (pplayer != null)
particlePlayers.remove(pplayer); particlePlayers.remove(pplayer);
} }
@ -78,7 +77,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
* Adds all fixed effects from the config * Adds all fixed effects from the config
*/ */
public static void addAllFixedEffects() { public static void addAllFixedEffects() {
ConfigManager.getInstance().getAllFixedEffects((fixedEffects) -> { PPlayerDataManager.getInstance().getAllFixedEffects((fixedEffects) -> {
fixedParticleEffects.addAll(fixedEffects); fixedParticleEffects.addAll(fixedEffects);
}); });
} }
@ -122,7 +121,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
public static void refreshPPlayers() { public static void refreshPPlayers() {
particlePlayers.clear(); particlePlayers.clear();
for (Player player : Bukkit.getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
ConfigManager.getInstance().loadPPlayer(player.getUniqueId()); PPlayerDataManager.getInstance().loadPPlayer(player.getUniqueId());
} }
/** /**
@ -148,7 +147,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
*/ */
public static ParticleEffect effectFromString(String effectName) { public static ParticleEffect effectFromString(String effectName) {
for (ParticleEffect effect : ParticleEffect.getSupportedEffects()) { for (ParticleEffect effect : ParticleEffect.getSupportedEffects()) {
if (effect.getName().toLowerCase().replace("_", "").equals(effectName.toLowerCase())) return effect; if (effect.getName().equalsIgnoreCase(effectName)) return effect;
} }
return null; return null;
} }
@ -178,27 +177,15 @@ public class ParticleManager extends BukkitRunnable implements Listener {
continue; continue;
} }
// Perform permission and validity checks // Perform validity checks
boolean valid = true; boolean valid = true;
// If the player no longer has permission for the effect, remove it
if (!PermissionManager.hasEffectPermission(player, pplayer.getParticleEffect())) {
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), ParticleEffect.NONE);
valid = false;
}
// If the player no longer has permission for the style, default to none
if (!PermissionManager.hasStylePermission(player, pplayer.getParticleStyle())) {
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), DefaultStyles.NONE);
valid = false;
}
// Don't show their particles if they are in spectator mode // Don't show their particles if they are in spectator mode
if (player.getGameMode() == GameMode.SPECTATOR) { if (player.getGameMode() == GameMode.SPECTATOR) {
valid = false; valid = false;
} }
if (ConfigManager.getInstance().isWorldDisabled(player.getWorld().getName())) { if (PPlayerDataManager.getInstance().isWorldDisabled(player.getWorld().getName())) {
valid = false; valid = false;
} }
@ -235,7 +222,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
ParticleEffect effect = pplayer.getParticleEffect(); ParticleEffect effect = pplayer.getParticleEffect();
if (effect == ParticleEffect.NONE) return; if (effect == ParticleEffect.NONE) return;
for (PParticle particle : pplayer.getParticleStyle().getParticles(pplayer, location)) { for (PParticle particle : pplayer.getParticleStyle().getParticles(pplayer, location)) {
if (effect.hasProperty(ParticleProperty.REQUIRES_DATA)) { if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
effect.display(pplayer.getParticleSpawnData(), particle.getXOff(), particle.getYOff(), particle.getZOff(), particle.getSpeed(), 1, particle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE))); effect.display(pplayer.getParticleSpawnData(), particle.getXOff(), particle.getYOff(), particle.getZOff(), particle.getSpeed(), 1, particle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE)));
} else if (effect.hasProperty(ParticleProperty.COLORABLE)) { } else if (effect.hasProperty(ParticleProperty.COLORABLE)) {
effect.display(pplayer.getParticleSpawnColor(), particle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE))); effect.display(pplayer.getParticleSpawnColor(), particle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE)));
@ -256,7 +243,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
ParticleEffect effect = pplayer.getParticleEffect(); ParticleEffect effect = pplayer.getParticleEffect();
if (effect == ParticleEffect.NONE) return; if (effect == ParticleEffect.NONE) return;
for (PParticle particle : particles) { for (PParticle particle : particles) {
if (effect.hasProperty(ParticleProperty.REQUIRES_DATA)) { if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
effect.display(pplayer.getParticleSpawnData(), particle.getXOff(), particle.getYOff(), particle.getZOff(), particle.getSpeed(), 1, particle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE))); effect.display(pplayer.getParticleSpawnData(), particle.getXOff(), particle.getYOff(), particle.getZOff(), particle.getSpeed(), 1, particle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE)));
} else if (effect.hasProperty(ParticleProperty.COLORABLE)) { } else if (effect.hasProperty(ParticleProperty.COLORABLE)) {
effect.display(pplayer.getParticleSpawnColor(), particle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE))); effect.display(pplayer.getParticleSpawnColor(), particle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE)));
@ -275,7 +262,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
PPlayer fakePPlayer = new PPlayer(fixedEffect.getOwnerUniqueId(), fixedEffect.getParticleEffect(), fixedEffect.getParticleStyle(), null, null, null, null); PPlayer fakePPlayer = new PPlayer(fixedEffect.getOwnerUniqueId(), fixedEffect.getParticleEffect(), fixedEffect.getParticleStyle(), null, null, null, null);
ParticleEffect effect = fixedEffect.getParticleEffect(); ParticleEffect effect = fixedEffect.getParticleEffect();
for (PParticle particle : fixedEffect.getParticleStyle().getParticles(fakePPlayer, fixedEffect.getLocation())) { for (PParticle particle : fixedEffect.getParticleStyle().getParticles(fakePPlayer, fixedEffect.getLocation())) {
if (effect.hasProperty(ParticleProperty.REQUIRES_DATA)) { if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
effect.display(fixedEffect.getParticleSpawnData(), particle.getXOff(), particle.getYOff(), particle.getZOff(), particle.getSpeed(), 1, particle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE))); effect.display(fixedEffect.getParticleSpawnData(), particle.getXOff(), particle.getYOff(), particle.getZOff(), particle.getSpeed(), 1, particle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE)));
} else if (effect.hasProperty(ParticleProperty.COLORABLE)) { } else if (effect.hasProperty(ParticleProperty.COLORABLE)) {
effect.display(fixedEffect.getParticleSpawnColor(), particle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE))); effect.display(fixedEffect.getParticleSpawnColor(), particle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE)));

View file

@ -30,7 +30,7 @@ public class PermissionManager {
*/ */
public static boolean hasEffectPermission(Player player, ParticleEffect effect) { public static boolean hasEffectPermission(Player player, ParticleEffect effect) {
if (player.hasPermission("playerparticles.*") || player.hasPermission("playerparticles.effect.*")) return true; if (player.hasPermission("playerparticles.*") || player.hasPermission("playerparticles.effect.*")) return true;
if (player.hasPermission("playerparticles.effect." + effect.getName().toLowerCase().replace("_", ""))) return true; if (player.hasPermission("playerparticles.effect." + effect.getName())) return true;
if (effect == ParticleEffect.NONE) return true; if (effect == ParticleEffect.NONE) return true;
return false; return false;
} }
@ -45,7 +45,7 @@ public class PermissionManager {
*/ */
public static boolean hasStylePermission(Player player, ParticleStyle style) { public static boolean hasStylePermission(Player player, ParticleStyle style) {
if (player.hasPermission("playerparticles.*") || player.hasPermission("playerparticles.style.*")) return true; if (player.hasPermission("playerparticles.*") || player.hasPermission("playerparticles.style.*")) return true;
if (player.hasPermission("playerparticles.style." + style.getName().toLowerCase().replace("_", ""))) return true; if (player.hasPermission("playerparticles.style." + style.getName())) return true;
if (style == DefaultStyles.NONE) return true; if (style == DefaultStyles.NONE) return true;
return false; return false;
} }
@ -59,7 +59,7 @@ public class PermissionManager {
public static List<String> getEffectsUserHasPermissionFor(Player p) { public static List<String> getEffectsUserHasPermissionFor(Player p) {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
for (ParticleEffect pe : ParticleEffect.getSupportedEffects()) { for (ParticleEffect pe : ParticleEffect.getSupportedEffects()) {
if (hasEffectPermission(p, pe)) list.add(pe.getName().toLowerCase().replace("_", "")); if (hasEffectPermission(p, pe)) list.add(pe.getName());
} }
return list; return list;
} }
@ -73,7 +73,7 @@ public class PermissionManager {
public static List<String> getStylesUserHasPermissionFor(Player p) { public static List<String> getStylesUserHasPermissionFor(Player p) {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
for (ParticleStyle ps : ParticleStyleManager.getStyles()) { for (ParticleStyle ps : ParticleStyleManager.getStyles()) {
if (hasStylePermission(p, ps)) list.add(ps.getName().toLowerCase().replace("_", "")); if (hasStylePermission(p, ps)) list.add(ps.getName());
} }
return list; return list;
} }

View file

@ -15,7 +15,7 @@ import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import com.esophose.playerparticles.PPlayer; import com.esophose.playerparticles.PPlayer;
import com.esophose.playerparticles.manager.ConfigManager; import com.esophose.playerparticles.manager.PPlayerDataManager;
import com.esophose.playerparticles.manager.ParticleManager; import com.esophose.playerparticles.manager.ParticleManager;
import com.esophose.playerparticles.particles.ParticleEffect.BlockData; import com.esophose.playerparticles.particles.ParticleEffect.BlockData;
import com.esophose.playerparticles.particles.ParticleEffect.ItemData; import com.esophose.playerparticles.particles.ParticleEffect.ItemData;
@ -87,8 +87,8 @@ public class FixedParticleEffect {
this.particleNoteColorData = noteColorData; this.particleNoteColorData = noteColorData;
// The PPlayer must be loaded // The PPlayer must be loaded
ConfigManager.getInstance().loadPPlayer(pplayerUUID); PPlayerDataManager.getInstance().loadPPlayer(pplayerUUID);
PPlayer owner = ConfigManager.getInstance().getPPlayer(this.pplayerUUID); PPlayer owner = PPlayerDataManager.getInstance().getPPlayer(this.pplayerUUID);
// Check nulls, if any are null set them to the PPlayer's values // Check nulls, if any are null set them to the PPlayer's values
if (this.particleItemData == null) this.particleItemData = owner.getItemData(); if (this.particleItemData == null) this.particleItemData = owner.getItemData();
@ -182,10 +182,10 @@ public class FixedParticleEffect {
* @return The ParticleData the current particle effect requires * @return The ParticleData the current particle effect requires
*/ */
public ParticleData getParticleSpawnData() { public ParticleData getParticleSpawnData() {
if (this.particleEffect.hasProperty(ParticleProperty.REQUIRES_DATA)) { if (this.particleEffect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (this.particleEffect == ParticleEffect.BLOCK_CRACK || this.particleEffect == ParticleEffect.BLOCK_DUST || this.particleEffect == ParticleEffect.FALLING_DUST) { if (this.particleEffect == ParticleEffect.BLOCK || this.particleEffect == ParticleEffect.FALLING_DUST) {
return particleBlockData; return particleBlockData;
} else if (this.particleEffect == ParticleEffect.ITEM_CRACK) { } else if (this.particleEffect == ParticleEffect.ITEM) {
return this.particleItemData; return this.particleItemData;
} }
} }
@ -235,11 +235,11 @@ public class FixedParticleEffect {
return this.particleColorData.getRed() + " " + this.particleColorData.getGreen() + " " + this.particleColorData.getBlue(); return this.particleColorData.getRed() + " " + this.particleColorData.getGreen() + " " + this.particleColorData.getBlue();
} }
} }
} else if (this.particleEffect.hasProperty(ParticleProperty.REQUIRES_DATA)) { } else if (this.particleEffect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (this.particleEffect == ParticleEffect.BLOCK_CRACK || this.particleEffect == ParticleEffect.BLOCK_DUST || this.particleEffect == ParticleEffect.FALLING_DUST) { if (this.particleEffect == ParticleEffect.BLOCK || this.particleEffect == ParticleEffect.FALLING_DUST) {
return this.particleBlockData.getMaterial() + " " + this.particleBlockData.getData(); return this.particleBlockData.getMaterial().toString().toLowerCase();
} else if (this.particleEffect == ParticleEffect.ITEM_CRACK) { } else if (this.particleEffect == ParticleEffect.ITEM) {
return this.particleItemData.getMaterial() + " " + this.particleItemData.getData(); return this.particleItemData.getMaterial().toString().toLowerCase();
} }
} }

View file

@ -1,5 +1,15 @@
/**
* Copyright Esophose 2018
* While using any of the code provided by this plugin
* you must not claim it as your own. This plugin may
* be modified and installed on a server, but may not
* be distributed to any person by any means.
*/
package com.esophose.playerparticles.particles; package com.esophose.playerparticles.particles;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -8,6 +18,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Particle; import org.bukkit.Particle;
@ -15,124 +26,110 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
/**
* <b>ParticleEffect Library</b>
* <p>
* This library was created by @DarkBlade12 and allows you to display all Minecraft particle effects on a Bukkit server
* <p>
* You are welcome to use it, modify it and redistribute it under the following conditions:
* <ul>
* <li>Don't claim this class as your own
* <li>Don't remove this disclaimer
* </ul>
* <p>
* Special thanks:
* <ul>
* <li>@microgeek (original idea, names and packet parameters)
* <li>@ShadyPotato (1.8 names, ids and packet parameters)
* <li>@RingOfStorms (particle behavior)
* <li>@Cybermaxke (particle behavior)
* <li>@JamieSinn (hosting a jenkins server and documentation for ParticleEffect)
* </ul>
* <p>
* <i>It would be nice if you provide credit to me if you use this class in a published project</i>
*
* @author DarkBlade12
* @version 1.7
*/
/** /**
* Heavily modified to work with the Spigot Particle API * Heavily modified to work with the Spigot Particle API
* *
* @author (of changes) Esophose * @author Esophose
*/ */
public enum ParticleEffect { public enum ParticleEffect {
NONE("none", ""), // Custom effect type, has no Spigot Particle Enum // Ordered and named by their Minecraft 1.13 internal names
EXPLODE("explode", "EXPLOSION_NORMAL"), AMBIENT_ENTITY_EFFECT("SPELL_MOB_AMBIENT", "SPELL_MOB_AMBIENT", ParticleProperty.COLORABLE),
LARGE_EXPLODE("largeexplode", "EXPLOSION_LARGE"), ANGRY_VILLAGER("VILLAGER_ANGRY", "VILLAGER_ANGRY"),
HUGE_EXPLOSION("hugeexplosion", "EXPLOSION_HUGE"), BARRIER("BARRIER", "BARRIER"),
FIREWORKS_SPARK("fireworksSpark", "FIREWORKS_SPARK"), BLOCK("BLOCK_CRACK", "BLOCK_CRACK", ParticleProperty.REQUIRES_MATERIAL_DATA),
BUBBLE("bubble", "WATER_BUBBLE"), BUBBLE("WATER_BUBBLE", "WATER_BUBBLE"),
//SPLASH("splash", "WATER_SPLASH"), // Basically the same thing as droplet, just goes a tiny bit higher //BUBBLE_COLUMN_UP("BUBBLE_COLUMN_UP", null), // Identical to bubble
WAKE("wake", "WATER_WAKE"), BUBBLE_POP("BUBBLE_POP", null),
SUSPENDED("suspended", "SUSPENDED"), CLOUD("CLOUD", "CLOUD"),
DEPTH_SUSPEND("depthSuspend", "SUSPENDED_DEPTH"), CRIT("CRIT", "CRIT"),
CRIT("crit", "CRIT"), CURRENT_DOWN("CURRENT_DOWN", null),
MAGIC_CRIT("magicCrit", "CRIT_MAGIC"), DAMAGE_INDICATOR("DAMAGE_INDICATOR", "DAMAGE_INDICATOR"),
SMOKE("smoke", "SMOKE_NORMAL"), DOLPHIN("DOLPHIN", null),
LARGE_SMOKE("largesmoke", "SMOKE_LARGE"), DRAGON_BREATH("DRAGON_BREATH", "DRAGON_BREATH"),
SPELL("spell", "SPELL"), DRIPPING_LAVA("DRIP_LAVA", "DRIP_LAVA"),
INSTANT_SPELL("instantSpell", "SPELL_INSTANT"), DRIPPING_WATER("DRIP_WATER", "DRIP_WATER"),
MOB_SPELL("mobSpell", "SPELL_MOB", ParticleProperty.COLORABLE), DUST("REDSTONE", "REDSTONE", ParticleProperty.COLORABLE),
MOB_SPELL_AMBIENT("mobSpellAmbient", "SPELL_MOB_AMBIENT", ParticleProperty.COLORABLE), //ELDER_GUARDIAN("MOB_APPEARANCE", "MOB_APPEARANCE"), // No thank you
WITCH_MAGIC("witchMagic", "SPELL_WITCH"), ENCHANT("ENCHANTMENT_TABLE", "ENCHANTMENT_TABLE"),
DRIP_WATER("dripWater", "DRIP_WATER"), ENCHANTED_HIT("CRIT_MAGIC", "CRIT_MAGIC"),
DRIP_LAVA("dripLava", "DRIP_LAVA"), END_ROD("END_ROD", "END_ROD"),
ANGRY_VILLAGER("angryVillager", "VILLAGER_ANGRY"), ENTITY_EFFECT("SPELL_MOB", "SPELL_MOB", ParticleProperty.COLORABLE),
HAPPY_VILLAGER("happyVillager", "VILLAGER_HAPPY"), EXPLOSION("EXPLOSION_LARGE", "EXPLOSION_LARGE"),
NOTE("note", "NOTE", ParticleProperty.COLORABLE), FALLING_DUST("FALLING_DUST", "FALLING_DUST", ParticleProperty.REQUIRES_MATERIAL_DATA),
PORTAL("portal", "PORTAL"), FIREWORK("FIREWORKS_SPARK", "FIREWORKS_SPARK"),
ENCHANTMENT_TABLE("enchantmenttable", "ENCHANTMENT_TABLE"), FISHING("WATER_WAKE", "WATER_WAKE"),
FLAME("flame", "FLAME"), FLAME("FLAME", "FLAME"),
LAVA("lava", "LAVA"), FOOTSTEP(null, "FOOTSTEP"), // Removed in Minecraft 1.13 :(
FOOTSTEP("footstep", "FOOTSTEP"), HAPPY_VILLAGER("VILLAGER_HAPPY", "VILLAGER_HAPPY"),
CLOUD("cloud", "CLOUD"), HEART("HEART", "HEART"),
RED_DUST("reddust", "REDSTONE", ParticleProperty.COLORABLE), EXPLOSION_EMITTER("EXPLOSION_HUGE", "EXPLOSION_HUGE"),
SNOWBALL_POOF("snowballpoof", "SNOWBALL"), INSTANT_EFFECT("SPELL_INSTANT", "SPELL_INSTANT"),
SNOW_SHOVEL("snowshovel", "SNOW_SHOVEL"), ITEM("ITEM_CRACK", "ITEM_CRACK", ParticleProperty.REQUIRES_MATERIAL_DATA),
SLIME("slime", "SLIME"), ITEM_SLIME("SLIME", "SLIME"),
HEART("heart", "HEART"), ITEM_SNOWBALL("SNOWBALL", "SNOWBALL"),
BARRIER("barrier", "BARRIER"), LARGE_SMOKE("SMOKE_LARGE", "SMOKE_LARGE"),
ITEM_CRACK("iconcrack", "ITEM_CRACK", ParticleProperty.REQUIRES_DATA), LAVA("LAVA", "LAVA"),
BLOCK_CRACK("blockcrack", "BLOCK_CRACK", ParticleProperty.REQUIRES_DATA), MYCELIUM("TOWN_AURA", "TOWN_AURA"),
BLOCK_DUST("blockdust", "BLOCK_DUST", ParticleProperty.REQUIRES_DATA), NAUTILUS("NAUTILUS", null),
DROPLET("droplet", "WATER_DROP"), NONE("", ""), // Custom effect to represent none selected
// ITEM_TAKE("take", "ITEM_TAKE"), // Doesn't do anything NOTE("NOTE", "NOTE", ParticleProperty.COLORABLE),
// MOB_APPEARANCE("mobappearance", "MOB_APPEARANCE"), // Looks ridiculous POOF("EXPLOSION_NORMAL", "EXPLOSION_NORMAL"), // The 1.13 combination of explode and showshovel
DRAGON_BREATH("dragonbreath", "DRAGON_BREATH"), PORTAL("PORTAL", "PORTAL"),
END_ROD("endrod", "END_ROD"), RAIN("WATER_DROP", "WATER_DROP"),
DAMAGE_INDICATOR("damageindicator", "DAMAGE_INDICATOR"), SMOKE("SMOKE_NORMAL", "SMOKE_NORMAL"),
SWEEP_ATTACK("sweepattack", "SWEEP_ATTACK"), SPELL("SPELL", "SPELL"), // The Minecraft internal name for this is actually "effect", but that's the command name, so it's SPELL for the plugin instead
FALLING_DUST("fallingdust", "FALLING_DUST", ParticleProperty.REQUIRES_DATA), SPIT("SPIT", "SPIT"),
TOTEM("totem", "TOTEM"), SPLASH("WATER_SPLASH", "WATER_SPLASH"),
SPIT("spit", "SPIT"); SQUID_INK("SQUID_INK", null),
SWEEP_ATTACK("SWEEP_ATTACK", "SWEEP_ATTACK"),
TOTEM_OF_UNDYING("TOTEM", "TOTEM"),
UNDERWATER("SUSPENDED_DEPTH", "SUSPENDED_DEPTH"),
WITCH("SPELL_WITCH", "SPELL_WTICH");
private static final int PARTICLE_DISPLAY_RANGE_SQUARED = 36864; // (12 chunks * 16 blocks per chunk)^2 private static final int PARTICLE_DISPLAY_RANGE_SQUARED = 36864; // (12 chunks * 16 blocks per chunk)^2
private static final Map<String, ParticleEffect> NAME_MAP = new HashMap<String, ParticleEffect>(); private static final Map<String, ParticleEffect> NAME_MAP = new HashMap<String, ParticleEffect>();
private static final Map<Integer, ParticleEffect> ID_MAP = new HashMap<Integer, ParticleEffect>(); private static boolean VERSION_13; // This is a particle unique to Minecraft 1.13, this is a reliable way of telling what server version is running
private final String name; private static Constructor<?> DUSTOPTIONS_CONSTRUCTOR;
private final String spigotEnumName; private static Method CREATEBLOCKDATA_METHOD;
private final Particle spigotEnum; private final Particle internalEnum;
private final List<ParticleProperty> properties; private final List<ParticleProperty> properties;
// Initialize map for quick name and id lookup // Initialize map for quick name and id lookup
static { static {
for (ParticleEffect effect : values()) { for (ParticleEffect effect : values()) {
NAME_MAP.put(effect.name, effect); NAME_MAP.put(effect.getName(), effect);
}
try {
VERSION_13 = Particle.valueOf("NAUTILUS") != null;
DUSTOPTIONS_CONSTRUCTOR = Particle.REDSTONE.getDataType().getConstructor(Color.class, float.class);
CREATEBLOCKDATA_METHOD = Material.class.getMethod("createBlockData");
} catch (Exception e) {
DUSTOPTIONS_CONSTRUCTOR = null;
VERSION_13 = false;
} }
} }
/** /**
* Construct a new particle effect * Construct a new particle effect
* *
* @param name Name of this particle effect * @param enumName Name of the Particle Enum when the server version is >= 1.13
* @param spigotEnumName Name of the Spigot Particle Enum * @param enumNameLegacy Name of the Particle Enum when the server version is < 1.13
* @param properties Properties of this particle effect * @param properties Properties of this particle effect
*/ */
private ParticleEffect(String name, String spigotEnumName, ParticleProperty... properties) { private ParticleEffect(String enumName, String enumNameLegacy, ParticleProperty... properties) {
this.name = name;
this.spigotEnumName = spigotEnumName;
this.properties = Arrays.asList(properties); this.properties = Arrays.asList(properties);
Particle matchingSpigotEnum = null; Particle matchingEnum = null;
for (Particle particle : Particle.values()) { for (Particle particle : Particle.values()) {
if (particle.name().equals(spigotEnumName)) { if (particle.name().equals(enumName) || particle.name().equals(enumNameLegacy)) {
matchingSpigotEnum = particle; matchingEnum = particle;
break; break;
} }
} }
this.spigotEnum = matchingSpigotEnum; // Will be null if this server's version doesn't support this particle type
this.internalEnum = matchingEnum; // Will be null if this server's version doesn't support this particle type
} }
/** /**
@ -141,16 +138,7 @@ public enum ParticleEffect {
* @return The name * @return The name
*/ */
public String getName() { public String getName() {
return name; return this.name().toLowerCase();
}
/**
* Returns the name of this particle effect's Spigot Particle Enum
*
* @return The name of the Spigot Particle Enum this ParticleEffect represents
*/
public String getSpigotEnumName() {
return spigotEnumName;
} }
/** /**
@ -159,7 +147,7 @@ public enum ParticleEffect {
* @return The Spigot Particle Enum this ParticleEffect represents * @return The Spigot Particle Enum this ParticleEffect represents
*/ */
public Particle getSpigotEnum() { public Particle getSpigotEnum() {
return spigotEnum; return this.internalEnum;
} }
/** /**
@ -169,7 +157,7 @@ public enum ParticleEffect {
* @return Whether it has the property or not * @return Whether it has the property or not
*/ */
public boolean hasProperty(ParticleProperty property) { public boolean hasProperty(ParticleProperty property) {
return properties.contains(property); return this.properties.contains(property);
} }
/** /**
@ -179,7 +167,7 @@ public enum ParticleEffect {
* @return Whether the particle effect is supported or not * @return Whether the particle effect is supported or not
*/ */
public boolean isSupported() { public boolean isSupported() {
return this == ParticleEffect.NONE || spigotEnum != null; return this == NONE || this.internalEnum != null;
} }
/** /**
@ -210,22 +198,6 @@ public enum ParticleEffect {
return null; return null;
} }
/**
* Returns the particle effect with the given id
*
* @param id Id of the particle effect
* @return The particle effect
*/
public static ParticleEffect fromId(int id) {
for (Entry<Integer, ParticleEffect> entry : ID_MAP.entrySet()) {
if (entry.getKey() != id) {
continue;
}
return entry.getValue();
}
return null;
}
/** /**
* Determine if the data type for a particle effect is correct * Determine if the data type for a particle effect is correct
* *
@ -234,7 +206,7 @@ public enum ParticleEffect {
* @return Whether the data type is correct or not * @return Whether the data type is correct or not
*/ */
private static boolean isDataCorrect(ParticleEffect effect, ParticleData data) { private static boolean isDataCorrect(ParticleEffect effect, ParticleData data) {
return ((effect == BLOCK_CRACK || effect == BLOCK_DUST || effect == FALLING_DUST) && data instanceof BlockData) || (effect == ITEM_CRACK && data instanceof ItemData); return ((effect == BLOCK || effect == FALLING_DUST) && data instanceof BlockData) || (effect == ITEM && data instanceof ItemData);
} }
/** /**
@ -245,7 +217,7 @@ public enum ParticleEffect {
* @return Whether the color type is correct or not * @return Whether the color type is correct or not
*/ */
private static boolean isColorCorrect(ParticleEffect effect, ParticleColor color) { private static boolean isColorCorrect(ParticleEffect effect, ParticleColor color) {
return ((effect == MOB_SPELL || effect == MOB_SPELL_AMBIENT || effect == RED_DUST) && color instanceof OrdinaryColor) || (effect == NOTE && color instanceof NoteColor); return ((effect == ENTITY_EFFECT || effect == AMBIENT_ENTITY_EFFECT || effect == DUST) && color instanceof OrdinaryColor) || (effect == NOTE && color instanceof NoteColor);
} }
/** /**
@ -260,12 +232,12 @@ public enum ParticleEffect {
* @throws ParticleDataException If the particle effect requires additional data * @throws ParticleDataException If the particle effect requires additional data
*/ */
public void display(float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center) throws ParticleDataException { public void display(float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center) throws ParticleDataException {
if (hasProperty(ParticleProperty.REQUIRES_DATA)) { if (hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
throw new ParticleDataException("This particle effect requires additional data"); throw new ParticleDataException("This particle effect requires additional data");
} }
for (Player player : getPlayersInRange(center)) for (Player player : getPlayersInRange(center))
player.spawnParticle(spigotEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed); player.spawnParticle(internalEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed);
} }
/** /**
@ -283,9 +255,22 @@ public enum ParticleEffect {
throw new ParticleColorException("The particle color type is incorrect"); throw new ParticleColorException("The particle color type is incorrect");
} }
for (Player player : getPlayersInRange(center)) if (this == DUST && VERSION_13) { // DUST uses a special data object for spawning in 1.13
// Minecraft clients require that you pass Float.MIN_VALUE if the Red value is 0 OrdinaryColor dustColor = (OrdinaryColor)color;
player.spawnParticle(spigotEnum, center.getX(), center.getY(), center.getZ(), 0, this == ParticleEffect.RED_DUST && color.getValueX() == 0 ? Float.MIN_VALUE : color.getValueX(), color.getValueY(), color.getValueZ(), 1); Object dustData = null;
try { // The DustData class doesn't exist in Minecraft versions less than 1.13... so this is disgusting... but it works great
dustData = DUSTOPTIONS_CONSTRUCTOR.newInstance(Color.fromRGB(dustColor.getRed(), dustColor.getGreen(), dustColor.getBlue()), 1); // Wait, you can change the size of these now??? AWESOME! I might implement this in the future!
} catch (Exception e) { }
for (Player player : getPlayersInRange(center)) {
player.spawnParticle(internalEnum, center.getX(), center.getY(), center.getZ(), 1, 0, 0, 0, 0, dustData);
}
} else {
for (Player player : getPlayersInRange(center)) {
// Minecraft clients require that you pass a non-zero value if the Red value should be zero
player.spawnParticle(internalEnum, center.getX(), center.getY(), center.getZ(), 0, this == ParticleEffect.DUST && color.getValueX() == 0 ? Float.MIN_VALUE : color.getValueX(), color.getValueY(), color.getValueZ(), 1);
}
}
} }
/** /**
@ -303,24 +288,28 @@ public enum ParticleEffect {
* @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect
*/ */
public void display(ParticleData data, float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center) throws ParticleDataException { public void display(ParticleData data, float offsetX, float offsetY, float offsetZ, float speed, int amount, Location center) throws ParticleDataException {
if (!hasProperty(ParticleProperty.REQUIRES_DATA)) { if (!hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
throw new ParticleDataException("This particle effect does not require additional data"); throw new ParticleDataException("This particle effect does not require additional data");
} }
if (!isDataCorrect(this, data)) { if (!isDataCorrect(this, data)) {
throw new ParticleDataException("The particle data type is incorrect"); throw new ParticleDataException("The particle data type is incorrect");
} }
Object extraData; Object extraData = null;
if (spigotEnum.getDataType() == MaterialData.class) { if (internalEnum.getDataType().getTypeName().equals("org.bukkit.block.data.BlockData")) {
extraData = new MaterialData(data.getMaterial(), data.getData()); // Deprecated, but there is currently no replacement for it try { // The Material.createBlockData() method doesn't exist in Minecraft versions less than 1.13... so this is disgusting... but it works great
} else if (spigotEnum.getDataType() == ItemStack.class) { extraData = CREATEBLOCKDATA_METHOD.invoke(data.getMaterial());
extraData = new ItemStack(data.getMaterial(), data.getData()); } catch (Exception e) { }
} else if (internalEnum.getDataType() == ItemStack.class) {
extraData = new ItemStack(data.getMaterial());
} else if (internalEnum.getDataType() == MaterialData.class) {
extraData = new MaterialData(data.getMaterial()); // Deprecated, only used in versions < 1.13
} else { } else {
System.out.println(internalEnum.getDataType());
extraData = null; extraData = null;
System.out.println(spigotEnum.getDataType().getName());
} }
for (Player player : getPlayersInRange(center)) for (Player player : getPlayersInRange(center))
player.spawnParticle(spigotEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed, extraData); player.spawnParticle(internalEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed, extraData);
} }
/** /**
@ -350,9 +339,9 @@ public enum ParticleEffect {
*/ */
public static enum ParticleProperty { public static enum ParticleProperty {
/** /**
* The particle effect requires block or item data to be displayed * The particle effect requires block or item material data to be displayed
*/ */
REQUIRES_DATA, REQUIRES_MATERIAL_DATA,
/** /**
* The particle effect uses the offsets as color values * The particle effect uses the offsets as color values
*/ */
@ -361,7 +350,7 @@ public enum ParticleEffect {
/** /**
* Represents the particle data for effects like * Represents the particle data for effects like
* {@link ParticleEffect#ITEM_CRACK}, {@link ParticleEffect#BLOCK_CRACK}, * {@link ParticleEffect#ITEM}, {@link ParticleEffect#BLOCK_CRACK},
* {@link ParticleEffect#BLOCK_DUST}, and {@link ParticleEffect#FALLING_DUST} * {@link ParticleEffect#BLOCK_DUST}, and {@link ParticleEffect#FALLING_DUST}
* <p> * <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the * This class is part of the <b>ParticleEffect Library</b> and follows the
@ -372,17 +361,14 @@ public enum ParticleEffect {
*/ */
public static abstract class ParticleData { public static abstract class ParticleData {
private final Material material; private final Material material;
private final byte data;
/** /**
* Construct a new particle data * Construct a new particle data
* *
* @param material Material of the item/block * @param material Material of the item/block
* @param data Data value of the item/block
*/ */
public ParticleData(Material material, byte data) { public ParticleData(Material material) {
this.material = material; this.material = material;
this.data = data;
} }
/** /**
@ -393,15 +379,6 @@ public enum ParticleEffect {
public Material getMaterial() { public Material getMaterial() {
return material; return material;
} }
/**
* Returns the data value of this data
*
* @return The data value
*/
public byte getData() {
return data;
}
} }
/** /**
@ -418,10 +395,9 @@ public enum ParticleEffect {
* Construct a new item data * Construct a new item data
* *
* @param material Material of the item * @param material Material of the item
* @param data Data value of the item
*/ */
public ItemData(Material material, byte data) { public ItemData(Material material) {
super(material, data); super(material);
} }
} }
@ -443,8 +419,8 @@ public enum ParticleEffect {
* @param data Data value of the block * @param data Data value of the block
* @throws IllegalArgumentException If the material is not a block * @throws IllegalArgumentException If the material is not a block
*/ */
public BlockData(Material material, byte data) throws IllegalArgumentException { public BlockData(Material material) throws IllegalArgumentException {
super(material, data); super(material);
if (!material.isBlock()) { if (!material.isBlock()) {
throw new IllegalArgumentException("The material is not a block"); throw new IllegalArgumentException("The material is not a block");
} }
@ -701,7 +677,7 @@ public enum ParticleEffect {
* @since 1.7 * @since 1.7
*/ */
private static final class ParticleColorException extends RuntimeException { private static final class ParticleColorException extends RuntimeException {
private static final long serialVersionUID = 3203085387160737484L; private static final long serialVersionUID = 3203085387160737485L;
/** /**
* Construct a new particle color exception * Construct a new particle color exception

View file

@ -11,7 +11,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import com.esophose.playerparticles.PPlayer; import com.esophose.playerparticles.PPlayer;
import com.esophose.playerparticles.manager.ConfigManager; import com.esophose.playerparticles.manager.PPlayerDataManager;
import com.esophose.playerparticles.manager.ParticleManager; import com.esophose.playerparticles.manager.ParticleManager;
import com.esophose.playerparticles.manager.PermissionManager; import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.styles.api.PParticle; import com.esophose.playerparticles.styles.api.PParticle;
@ -43,7 +43,7 @@ public class ParticleStyleBlockBreak implements ParticleStyle, Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(player.getUniqueId()); PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(player.getUniqueId());
if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.BLOCKBREAK && PermissionManager.hasStylePermission(player, DefaultStyles.BLOCKBREAK)) { if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.BLOCKBREAK && PermissionManager.hasStylePermission(player, DefaultStyles.BLOCKBREAK)) {
Location loc = event.getBlock().getLocation(); Location loc = event.getBlock().getLocation();
ParticleManager.displayParticles(pplayer, DefaultStyles.BLOCKBREAK.getParticles(pplayer, loc)); ParticleManager.displayParticles(pplayer, DefaultStyles.BLOCKBREAK.getParticles(pplayer, loc));

View file

@ -9,7 +9,7 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import com.esophose.playerparticles.PPlayer; import com.esophose.playerparticles.PPlayer;
import com.esophose.playerparticles.manager.ConfigManager; import com.esophose.playerparticles.manager.PPlayerDataManager;
import com.esophose.playerparticles.manager.ParticleManager; import com.esophose.playerparticles.manager.ParticleManager;
import com.esophose.playerparticles.manager.PermissionManager; import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.styles.api.PParticle; import com.esophose.playerparticles.styles.api.PParticle;
@ -36,7 +36,7 @@ public class ParticleStyleBlockEdit implements ParticleStyle, Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(player.getUniqueId()); PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(player.getUniqueId());
if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.BLOCKEDIT && PermissionManager.hasStylePermission(player, DefaultStyles.BLOCKEDIT)) { if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.BLOCKEDIT && PermissionManager.hasStylePermission(player, DefaultStyles.BLOCKEDIT)) {
Location loc = event.getBlock().getLocation(); Location loc = event.getBlock().getLocation();
ParticleManager.displayParticles(pplayer, DefaultStyles.BLOCKBREAK.getParticles(pplayer, loc)); ParticleManager.displayParticles(pplayer, DefaultStyles.BLOCKBREAK.getParticles(pplayer, loc));
@ -46,7 +46,7 @@ public class ParticleStyleBlockEdit implements ParticleStyle, Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(player.getUniqueId()); PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(player.getUniqueId());
if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.BLOCKEDIT && PermissionManager.hasStylePermission(player, DefaultStyles.BLOCKEDIT)) { if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.BLOCKEDIT && PermissionManager.hasStylePermission(player, DefaultStyles.BLOCKEDIT)) {
Location loc = event.getBlockPlaced().getLocation(); Location loc = event.getBlockPlaced().getLocation();
ParticleManager.displayParticles(pplayer, DefaultStyles.BLOCKPLACE.getParticles(pplayer, loc)); ParticleManager.displayParticles(pplayer, DefaultStyles.BLOCKPLACE.getParticles(pplayer, loc));

View file

@ -11,7 +11,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import com.esophose.playerparticles.PPlayer; import com.esophose.playerparticles.PPlayer;
import com.esophose.playerparticles.manager.ConfigManager; import com.esophose.playerparticles.manager.PPlayerDataManager;
import com.esophose.playerparticles.manager.ParticleManager; import com.esophose.playerparticles.manager.ParticleManager;
import com.esophose.playerparticles.manager.PermissionManager; import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.styles.api.PParticle; import com.esophose.playerparticles.styles.api.PParticle;
@ -43,7 +43,7 @@ public class ParticleStyleBlockPlace implements ParticleStyle, Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(player.getUniqueId()); PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(player.getUniqueId());
if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.BLOCKPLACE && PermissionManager.hasStylePermission(player, DefaultStyles.BLOCKPLACE)) { if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.BLOCKPLACE && PermissionManager.hasStylePermission(player, DefaultStyles.BLOCKPLACE)) {
Location loc = event.getBlockPlaced().getLocation(); Location loc = event.getBlockPlaced().getLocation();
ParticleManager.displayParticles(pplayer, DefaultStyles.BLOCKPLACE.getParticles(pplayer, loc)); ParticleManager.displayParticles(pplayer, DefaultStyles.BLOCKPLACE.getParticles(pplayer, loc));

View file

@ -8,7 +8,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import com.esophose.playerparticles.PPlayer; import com.esophose.playerparticles.PPlayer;
import com.esophose.playerparticles.manager.ConfigManager; import com.esophose.playerparticles.manager.PPlayerDataManager;
import com.esophose.playerparticles.manager.ParticleManager; import com.esophose.playerparticles.manager.ParticleManager;
import com.esophose.playerparticles.manager.PermissionManager; import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.styles.api.PParticle; import com.esophose.playerparticles.styles.api.PParticle;
@ -44,7 +44,7 @@ public class ParticleStyleHurt implements ParticleStyle, Listener {
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
if (event.getEntity() instanceof Player) { if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(player.getUniqueId()); PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(player.getUniqueId());
if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.HURT && PermissionManager.hasStylePermission(player, DefaultStyles.HURT)) { if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.HURT && PermissionManager.hasStylePermission(player, DefaultStyles.HURT)) {
Location loc = player.getLocation().clone().add(0, 1, 0); Location loc = player.getLocation().clone().add(0, 1, 0);
ParticleManager.displayParticles(pplayer, DefaultStyles.HURT.getParticles(pplayer, loc)); ParticleManager.displayParticles(pplayer, DefaultStyles.HURT.getParticles(pplayer, loc));

View file

@ -7,7 +7,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import com.esophose.playerparticles.PPlayer; import com.esophose.playerparticles.PPlayer;
import com.esophose.playerparticles.manager.ConfigManager; import com.esophose.playerparticles.manager.PPlayerDataManager;
import com.esophose.playerparticles.manager.ParticleManager; import com.esophose.playerparticles.manager.ParticleManager;
import com.esophose.playerparticles.manager.PermissionManager; import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.styles.api.PParticle; import com.esophose.playerparticles.styles.api.PParticle;
@ -33,7 +33,7 @@ public class ParticleStyleMove implements ParticleStyle, Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent e) { public void onPlayerMove(PlayerMoveEvent e) {
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(e.getPlayer().getUniqueId()); PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(e.getPlayer().getUniqueId());
if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.MOVE) { if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.MOVE) {
if (PermissionManager.hasStylePermission(e.getPlayer(), DefaultStyles.MOVE)) { if (PermissionManager.hasStylePermission(e.getPlayer(), DefaultStyles.MOVE)) {
Location loc = e.getPlayer().getLocation(); Location loc = e.getPlayer().getLocation();

View file

@ -19,20 +19,20 @@ public class ParticleStyleNone implements ParticleStyle {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.CRIT)) { } else if (particleEffect.equals(ParticleEffect.CRIT)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.DEPTH_SUSPEND)) { } else if (particleEffect.equals(ParticleEffect.UNDERWATER)) {
PParticle[] particles = new PParticle[5]; PParticle[] particles = new PParticle[5];
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
particles[i] = new PParticle(location, 0.5F, 0.5F, 0.5F, 0.0F); particles[i] = new PParticle(location, 0.5F, 0.5F, 0.5F, 0.0F);
return particles; return particles;
} else if (particleEffect.equals(ParticleEffect.DRIP_LAVA)) { } else if (particleEffect.equals(ParticleEffect.DRIPPING_LAVA)) {
return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.DRIP_WATER)) { } else if (particleEffect.equals(ParticleEffect.DRIPPING_LAVA)) {
return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.ENCHANTMENT_TABLE)) { } else if (particleEffect.equals(ParticleEffect.ENCHANT)) {
return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.05F) }; return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.05F) };
} else if (particleEffect.equals(ParticleEffect.EXPLODE)) { } else if (particleEffect.equals(ParticleEffect.POOF)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.FIREWORKS_SPARK)) { } else if (particleEffect.equals(ParticleEffect.FIREWORK)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.FLAME)) { } else if (particleEffect.equals(ParticleEffect.FLAME)) {
return new PParticle[] { new PParticle(location, 0.1F, 0.1F, 0.1F, 0.05F) }; return new PParticle[] { new PParticle(location, 0.1F, 0.1F, 0.1F, 0.05F) };
@ -42,53 +42,46 @@ public class ParticleStyleNone implements ParticleStyle {
return new PParticle[] { new PParticle(location, 0.5F, 0.5F, 0.5F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.5F, 0.5F, 0.5F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.HEART)) { } else if (particleEffect.equals(ParticleEffect.HEART)) {
return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.HUGE_EXPLOSION)) { } else if (particleEffect.equals(ParticleEffect.EXPLOSION_EMITTER)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.INSTANT_SPELL)) { } else if (particleEffect.equals(ParticleEffect.INSTANT_EFFECT)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.LARGE_EXPLODE)) { } else if (particleEffect.equals(ParticleEffect.EXPLOSION)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.LARGE_SMOKE)) { } else if (particleEffect.equals(ParticleEffect.LARGE_SMOKE)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.LAVA)) { } else if (particleEffect.equals(ParticleEffect.LAVA)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.MAGIC_CRIT)) { } else if (particleEffect.equals(ParticleEffect.ENCHANTED_HIT)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.MOB_SPELL)) { } else if (particleEffect.equals(ParticleEffect.ENTITY_EFFECT)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.MOB_SPELL_AMBIENT)) { } else if (particleEffect.equals(ParticleEffect.AMBIENT_ENTITY_EFFECT)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.NOTE)) { } else if (particleEffect.equals(ParticleEffect.NOTE)) {
return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.PORTAL)) { } else if (particleEffect.equals(ParticleEffect.PORTAL)) {
return new PParticle[] { new PParticle(location, 0.5F, 0.5F, 0.5F, 0.05F) }; return new PParticle[] { new PParticle(location, 0.5F, 0.5F, 0.5F, 0.05F) };
} else if (particleEffect.equals(ParticleEffect.RED_DUST)) { } else if (particleEffect.equals(ParticleEffect.DUST)) {
return new PParticle[] { new PParticle(location, 0.5F, 0.5F, 0.5F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.5F, 0.5F, 0.5F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.SLIME)) { } else if (particleEffect.equals(ParticleEffect.ITEM_SLIME)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.SMOKE)) { } else if (particleEffect.equals(ParticleEffect.SMOKE)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.SNOW_SHOVEL)) { } else if (particleEffect.equals(ParticleEffect.ITEM_SNOWBALL)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.SNOWBALL_POOF)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.SPELL)) { } else if (particleEffect.equals(ParticleEffect.SPELL)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.SUSPENDED)) { } else if (particleEffect.equals(ParticleEffect.UNDERWATER)) {
PParticle[] particles = new PParticle[5];
for (int i = 0; i < 5; i++)
particles[i] = new PParticle(location, 0.8F, 0.8F, 0.8F, 0.0F);
return particles;
} else if (particleEffect.equals(ParticleEffect.WAKE)) {
PParticle[] particles = new PParticle[3]; PParticle[] particles = new PParticle[3];
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
particles[i] = new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F); particles[i] = new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F);
return particles; return particles;
} else if (particleEffect.equals(ParticleEffect.WITCH_MAGIC)) { } else if (particleEffect.equals(ParticleEffect.WITCH)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.BARRIER)) { } else if (particleEffect.equals(ParticleEffect.BARRIER)) {
return new PParticle[] { new PParticle(location, 1.2F, 1.2F, 1.2F, 0.0F) }; return new PParticle[] { new PParticle(location, 1.2F, 1.2F, 1.2F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.DROPLET)) { } else if (particleEffect.equals(ParticleEffect.SPLASH)) {
return new PParticle[] { new PParticle(location, 0.8F, 0.8F, 0.8F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.8F, 0.8F, 0.8F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.DRAGON_BREATH)) { } else if (particleEffect.equals(ParticleEffect.DRAGON_BREATH)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
@ -98,18 +91,16 @@ public class ParticleStyleNone implements ParticleStyle {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.SWEEP_ATTACK)) { } else if (particleEffect.equals(ParticleEffect.SWEEP_ATTACK)) {
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.BLOCK_CRACK)) { } else if (particleEffect.equals(ParticleEffect.BLOCK)) {
return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.BLOCK_DUST)) { } else if (particleEffect.equals(ParticleEffect.ITEM)) {
return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.ITEM_CRACK)) {
return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.FALLING_DUST)) { } else if (particleEffect.equals(ParticleEffect.FALLING_DUST)) {
PParticle[] particles = new PParticle[2]; PParticle[] particles = new PParticle[2];
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
particles[i] = new PParticle(location.add(0, 0.75, 0), 0.6F, 0.4F, 0.6F, 0.0F); particles[i] = new PParticle(location.add(0, 0.75, 0), 0.6F, 0.4F, 0.6F, 0.0F);
return particles; return particles;
} else if (particleEffect.equals(ParticleEffect.TOTEM)) { } else if (particleEffect.equals(ParticleEffect.TOTEM_OF_UNDYING)) {
return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) };
} else if (particleEffect.equals(ParticleEffect.SPIT)) { } else if (particleEffect.equals(ParticleEffect.SPIT)) {
return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) }; return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) };

View file

@ -13,7 +13,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import com.esophose.playerparticles.PPlayer; import com.esophose.playerparticles.PPlayer;
import com.esophose.playerparticles.manager.ConfigManager; import com.esophose.playerparticles.manager.PPlayerDataManager;
import com.esophose.playerparticles.manager.ParticleManager; import com.esophose.playerparticles.manager.ParticleManager;
import com.esophose.playerparticles.manager.PermissionManager; import com.esophose.playerparticles.manager.PermissionManager;
import com.esophose.playerparticles.styles.api.PParticle; import com.esophose.playerparticles.styles.api.PParticle;
@ -57,7 +57,7 @@ public class ParticleStyleSwords implements ParticleStyle, Listener {
if (event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity) { if (event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity) {
Player player = (Player) event.getDamager(); Player player = (Player) event.getDamager();
LivingEntity entity = (LivingEntity) event.getEntity(); LivingEntity entity = (LivingEntity) event.getEntity();
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(player.getUniqueId()); PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(player.getUniqueId());
if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.SWORDS && PermissionManager.hasStylePermission(player, DefaultStyles.SWORDS)) { if (pplayer != null && pplayer.getParticleStyle() == DefaultStyles.SWORDS && PermissionManager.hasStylePermission(player, DefaultStyles.SWORDS)) {
if (player.getInventory().getItemInMainHand() != null && SWORD_NAMES.contains(player.getInventory().getItemInMainHand().getType().name())) { if (player.getInventory().getItemInMainHand() != null && SWORD_NAMES.contains(player.getInventory().getItemInMainHand().getType().name())) {
Location loc = entity.getLocation().clone().add(0, 1, 0); Location loc = entity.getLocation().clone().add(0, 1, 0);

View file

@ -27,8 +27,8 @@ public class ParticleStyleManager {
*/ */
public static void registerStyle(ParticleStyle style) { public static void registerStyle(ParticleStyle style) {
for (ParticleStyle testAgainst : styles) { for (ParticleStyle testAgainst : styles) {
if (testAgainst.getName().replace("_", "").equalsIgnoreCase(style.getName())) { if (testAgainst.getName().equalsIgnoreCase(style.getName())) {
PlayerParticles.getPlugin().getLogger().severe("Tried to register two styles with the same (or too similar) name: " + style.getName()); PlayerParticles.getPlugin().getLogger().severe("Tried to register two styles with the same name spelling: " + style.getName());
} else if (testAgainst.equals(style)) { } else if (testAgainst.equals(style)) {
PlayerParticles.getPlugin().getLogger().severe("Tried to register the same style twice: " + style.getName()); PlayerParticles.getPlugin().getLogger().severe("Tried to register the same style twice: " + style.getName());
} }
@ -73,7 +73,7 @@ public class ParticleStyleManager {
*/ */
public static ParticleStyle styleFromString(String styleName) { public static ParticleStyle styleFromString(String styleName) {
for (ParticleStyle style : styles) for (ParticleStyle style : styles)
if (style.getName().toLowerCase().replace("_", "").equals(styleName)) return style; if (style.getName().equals(styleName)) return style;
return null; return null;
} }

View file

@ -8,6 +8,9 @@
package com.esophose.playerparticles.util; package com.esophose.playerparticles.util;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
public class ParticleUtils { public class ParticleUtils {
@ -51,6 +54,22 @@ public class ParticleUtils {
return mat; return mat;
} }
public static List<String> getAllBlockMaterials() {
List<String> materials = new ArrayList<String>();
for (Material mat : Material.values())
if (mat.isBlock())
materials.add(mat.name().toLowerCase());
return materials;
}
public static List<String> getAllItemMaterials() {
List<String> materials = new ArrayList<String>();
for (Material mat : Material.values())
if (!mat.isBlock())
materials.add(mat.name().toLowerCase());
return materials;
}
/** /**
* Gets the smallest positive integer from an array * Gets the smallest positive integer from an array
* *

View file

@ -14,7 +14,7 @@
# I don't recommend changing it # I don't recommend changing it
# NOTE: Updating to a new version of the plugin will change this number and delete your config. # NOTE: Updating to a new version of the plugin will change this number and delete your config.
# Make sure you create a backup each time before you update! # Make sure you create a backup each time before you update!
version: 5.1 version: 5.2
# Check for new versions of the plugin # Check for new versions of the plugin
# Default: true # Default: true
@ -169,13 +169,13 @@ message-color-data-usage: '&b/pp data [<0-255> <0-255> <0-255>]|[rainbow]'
# Item Data Usage # Item Data Usage
# You should not change the text here, only the coloring # You should not change the text here, only the coloring
# Default: '&b/pp data <itemName/ID> <0-15>' # Default: '&b/pp data <itemName/ID>'
message-item-data-usage: '&b/pp data <itemName> <0-15>' message-item-data-usage: '&b/pp data <itemName>'
# Block Data Usage # Block Data Usage
# You should not change the text here, only the coloring # You should not change the text here, only the coloring
# Default: '&b/pp data <blockName/ID> <0-15>' # Default: '&b/pp data <blockName/ID>'
message-block-data-usage: '&b/pp data <blockName> <0-15>' message-block-data-usage: '&b/pp data <blockName>'
# ---------------- # # ---------------- #
# Prefixes # # Prefixes #

View file

@ -1,9 +1,10 @@
name: PlayerParticles name: PlayerParticles
main: com.esophose.playerparticles.PlayerParticles main: com.esophose.playerparticles.PlayerParticles
version: 5.1 version: 5.2
api-version: 1.13
description: Make particles around players in fancy ways. description: Make particles around players in fancy ways.
author: Esophose author: Esophose
website: https://dev.bukkit.org/projects/playerparticles website: https://dev.bukkit.org/projects/playerparticles
commands: commands:
pp: pp:
description: The main PlayerParticles command. description: The main PlayerParticles command. By default, opens the GUI.