mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-02-20 15:04:31 +00:00
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:
parent
d127824219
commit
8b4c1fcd42
22 changed files with 448 additions and 474 deletions
2
pom.xml
2
pom.xml
|
@ -53,7 +53,7 @@
|
|||
</excludes>
|
||||
</filter>
|
||||
</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>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
|
@ -170,7 +170,7 @@ public class PPlayer {
|
|||
* @param itemData The player's new item data
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ public class PPlayer {
|
|||
* @param blockData The player's new block data
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -210,11 +210,11 @@ public class PPlayer {
|
|||
* @return The ParticleData the current particle effect requires
|
||||
*/
|
||||
public ParticleData getParticleSpawnData() {
|
||||
if (this.particleEffect.hasProperty(ParticleProperty.REQUIRES_DATA)) {
|
||||
if (this.particleEffect == ParticleEffect.ITEM_CRACK) {
|
||||
if (this.particleEffect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
|
||||
if (this.particleEffect == ParticleEffect.ITEM) {
|
||||
return this.particleItemData;
|
||||
} else {
|
||||
return particleBlockData;
|
||||
return this.particleBlockData;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -249,10 +249,10 @@ public class PPlayer {
|
|||
* @return The particle data in a human-readable string
|
||||
*/
|
||||
public String getParticleDataString() {
|
||||
if (this.particleEffect == ParticleEffect.BLOCK_CRACK || this.particleEffect == ParticleEffect.BLOCK_DUST || this.particleEffect == ParticleEffect.FALLING_DUST) {
|
||||
return particleBlockData.getMaterial().toString().toLowerCase() + ":" + particleBlockData.getData();
|
||||
} else if (this.particleEffect == ParticleEffect.ITEM_CRACK) {
|
||||
return particleItemData.getMaterial().toString().toLowerCase() + ":" + particleItemData.getData();
|
||||
if (this.particleEffect == ParticleEffect.BLOCK || this.particleEffect == ParticleEffect.FALLING_DUST) {
|
||||
return particleBlockData.getMaterial().toString().toLowerCase();
|
||||
} else if (this.particleEffect == ParticleEffect.ITEM) {
|
||||
return particleItemData.getMaterial().toString().toLowerCase();
|
||||
} else if (this.particleEffect.hasProperty(ParticleProperty.COLORABLE)) {
|
||||
if (this.particleEffect == ParticleEffect.NOTE) {
|
||||
if (this.particleNoteColorData.getValueX() * 24 == 99) {
|
||||
|
@ -280,8 +280,8 @@ public class PPlayer {
|
|||
public static PPlayer getNewPPlayer(UUID playerUUID) {
|
||||
ParticleEffect particleEffect = ParticleEffect.NONE;
|
||||
ParticleStyle particleStyle = DefaultStyles.NONE;
|
||||
ItemData particleItemData = new ItemData(ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"), (byte) 0);
|
||||
BlockData particleBlockData = new BlockData(Material.STONE, (byte) 0);
|
||||
ItemData particleItemData = new ItemData(ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"));
|
||||
BlockData particleBlockData = new BlockData(Material.STONE);
|
||||
OrdinaryColor particleColorData = new OrdinaryColor(0, 0, 0);
|
||||
NoteColor particleNoteColorData = new NoteColor(0);
|
||||
|
||||
|
|
|
@ -12,18 +12,26 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
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.particles.ParticleEffect;
|
||||
import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
|
||||
import com.esophose.playerparticles.util.ParticleUtils;
|
||||
|
||||
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[] 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
|
||||
|
@ -35,20 +43,49 @@ public class ParticleCommandCompleter implements TabCompleter {
|
|||
* @return A list of commands available to the sender
|
||||
*/
|
||||
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>();
|
||||
if (cmd.getName().equalsIgnoreCase("pp")) {
|
||||
if (args.length > 1) {
|
||||
if (args[0].equalsIgnoreCase("effect")) {
|
||||
if (args[0].equalsIgnoreCase("effect") && args.length == 2) {
|
||||
List<String> commands = PermissionManager.getEffectsUserHasPermissionFor((Player) sender);
|
||||
StringUtil.copyPartialMatches(args[1], commands, completions);
|
||||
return completions;
|
||||
} else if (args[0].equalsIgnoreCase("style")) {
|
||||
} else if (args[0].equalsIgnoreCase("style") && args.length == 2) {
|
||||
List<String> commands = PermissionManager.getStylesUserHasPermissionFor((Player) sender);
|
||||
StringUtil.copyPartialMatches(args[1], commands, completions);
|
||||
return completions;
|
||||
} else if (args[0].equalsIgnoreCase("fixed")) {
|
||||
List<String> commands = Arrays.asList(FIXED_COMMANDS);
|
||||
StringUtil.copyPartialMatches(args[1], commands, completions);
|
||||
} else if (args[0].equalsIgnoreCase("fixed") && args.length > 1) {
|
||||
if (args.length == 2) {
|
||||
List<String> commands = Arrays.asList(FIXED_COMMANDS);
|
||||
StringUtil.copyPartialMatches(args[1], commands, completions);
|
||||
} else if (args[1].equalsIgnoreCase("create")) {
|
||||
completions.add("<x> <y> <z> <effect> <style> [data]");
|
||||
} else if ((args[1].equalsIgnoreCase("remove") || args[1].equalsIgnoreCase("info")) && args.length == 3) {
|
||||
completions.add("<id>");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("data")) {
|
||||
PPlayer pplayer = 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 {
|
||||
List<String> commands = new ArrayList<String>(Arrays.asList(COMMANDS));
|
||||
|
@ -57,7 +94,7 @@ public class ParticleCommandCompleter implements TabCompleter {
|
|||
}
|
||||
return completions;
|
||||
}
|
||||
|
||||
|
||||
public static String[] getCommandsList() {
|
||||
return COMMANDS;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import com.esophose.playerparticles.gui.PlayerParticlesGui;
|
||||
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.MessageType;
|
||||
import com.esophose.playerparticles.manager.ParticleManager;
|
||||
|
@ -105,23 +105,36 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
|
||||
// Commands that require access to effects
|
||||
if (PermissionManager.getEffectsUserHasPermissionFor(p).size() != 1) {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "effect":
|
||||
onEffect(p, cmdArgs);
|
||||
break;
|
||||
case "data":
|
||||
onData(p, cmdArgs);
|
||||
break;
|
||||
case "fixed":
|
||||
onFixed(p, cmdArgs);
|
||||
break;
|
||||
case "reset":
|
||||
onReset(p, cmdArgs);
|
||||
break;
|
||||
case "gui":
|
||||
onGUI(p, false);
|
||||
break;
|
||||
}
|
||||
final String[] f_cmdArgs = cmdArgs;
|
||||
PPlayerDataManager.getInstance().getPPlayer(p.getUniqueId(), (pplayer) -> { // The PPlayer MUST be loaded before we can execute any of these commands
|
||||
// If the player no longer has permission for their effect, remove it
|
||||
if (!PermissionManager.hasEffectPermission(p, pplayer.getParticleEffect())) {
|
||||
PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), ParticleEffect.NONE);
|
||||
}
|
||||
|
||||
// If the player no longer has permission for their style, default to none
|
||||
if (!PermissionManager.hasStylePermission(p, pplayer.getParticleStyle())) {
|
||||
PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), DefaultStyles.NONE);
|
||||
}
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "effect":
|
||||
onEffect(p, f_cmdArgs);
|
||||
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 {
|
||||
MessageManager.sendMessage(p, MessageType.NO_PARTICLES);
|
||||
}
|
||||
|
@ -157,13 +170,13 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
* @param p The player who used the command
|
||||
*/
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
String worlds = "";
|
||||
for (String s : ConfigManager.getInstance().getDisabledWorlds()) {
|
||||
for (String s : PPlayerDataManager.getInstance().getDisabledWorlds()) {
|
||||
worlds += s + ", ";
|
||||
}
|
||||
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
|
||||
*/
|
||||
private void onData(Player p, String[] args) {
|
||||
if (PermissionManager.getEffectsUserHasPermissionFor(p).size() == 1) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ParticleEffect effect = ConfigManager.getInstance().getPPlayer(p.getUniqueId()).getParticleEffect();
|
||||
if ((!effect.hasProperty(ParticleProperty.REQUIRES_DATA) && !effect.hasProperty(ParticleProperty.COLORABLE)) || args.length == 0) {
|
||||
ParticleEffect effect = PPlayerDataManager.getInstance().getPPlayer(p.getUniqueId()).getParticleEffect();
|
||||
if ((!effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA) && !effect.hasProperty(ParticleProperty.COLORABLE)) || args.length == 0) {
|
||||
if (effect.hasProperty(ParticleProperty.COLORABLE)) {
|
||||
if (effect == ParticleEffect.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.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.COLOR_DATA_USAGE.getMessage());
|
||||
}
|
||||
} else if (effect.hasProperty(ParticleProperty.REQUIRES_DATA)) {
|
||||
if (effect == ParticleEffect.ITEM_CRACK) {
|
||||
} else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
|
||||
if (effect == ParticleEffect.ITEM) {
|
||||
MessageManager.sendMessage(p, MessageType.DATA_USAGE, "item");
|
||||
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.ITEM_DATA_USAGE.getMessage());
|
||||
} else {
|
||||
|
@ -219,7 +227,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
if (effect.hasProperty(ParticleProperty.COLORABLE)) {
|
||||
if (effect == ParticleEffect.NOTE) {
|
||||
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");
|
||||
return;
|
||||
}
|
||||
|
@ -239,11 +247,11 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
return;
|
||||
}
|
||||
|
||||
ConfigManager.getInstance().savePPlayer(p.getUniqueId(), new NoteColor(note));
|
||||
PPlayerDataManager.getInstance().savePPlayer(p.getUniqueId(), new NoteColor(note));
|
||||
MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "note");
|
||||
} else {
|
||||
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");
|
||||
} else if (args.length >= 3) {
|
||||
int r = -1;
|
||||
|
@ -266,18 +274,16 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
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");
|
||||
} else {
|
||||
MessageManager.sendMessage(p, MessageType.DATA_INVALID_ARGUMENTS, "color");
|
||||
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.COLOR_DATA_USAGE.getMessage());
|
||||
}
|
||||
}
|
||||
} else if (effect.hasProperty(ParticleProperty.REQUIRES_DATA)) {
|
||||
if (effect == ParticleEffect.ITEM_CRACK) {
|
||||
} else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
|
||||
if (effect == ParticleEffect.ITEM) {
|
||||
Material material = null;
|
||||
int data = -1;
|
||||
|
||||
try {
|
||||
material = ParticleUtils.closestMatch(args[0]);
|
||||
if (material == null) material = Material.matchMaterial(args[0]);
|
||||
|
@ -288,32 +294,16 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
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()) {
|
||||
MessageManager.sendMessage(p, MessageType.DATA_MATERIAL_MISMATCH, "item");
|
||||
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.ITEM_DATA_USAGE.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (data < 0 || data > 15) {
|
||||
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));
|
||||
PPlayerDataManager.getInstance().savePPlayer(p.getUniqueId(), new ItemData(material));
|
||||
MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "item");
|
||||
} else {
|
||||
Material material = null;
|
||||
int data = -1;
|
||||
|
||||
try {
|
||||
material = ParticleUtils.closestMatch(args[0]);
|
||||
if (material == null) material = Material.matchMaterial(args[0]);
|
||||
|
@ -324,27 +314,13 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
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()) {
|
||||
MessageManager.sendMessage(p, MessageType.DATA_MATERIAL_MISMATCH, "block");
|
||||
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.BLOCK_DATA_USAGE.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (data < 0 || data > 15) {
|
||||
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));
|
||||
PPlayerDataManager.getInstance().savePPlayer(p.getUniqueId(), new BlockData(material));
|
||||
MessageManager.sendMessage(p, MessageType.DATA_APPLIED, "block");
|
||||
}
|
||||
}
|
||||
|
@ -367,14 +343,14 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
if (altPlayer == null) {
|
||||
MessageManager.sendMessage(p, MessageType.FAILED_EXECUTE_NOT_FOUND, altPlayerName);
|
||||
} else {
|
||||
ConfigManager.getInstance().resetPPlayer(altPlayer.getUniqueId());
|
||||
PPlayerDataManager.getInstance().resetPPlayer(altPlayer.getUniqueId());
|
||||
MessageManager.sendMessage(altPlayer, MessageType.RESET);
|
||||
|
||||
MessageManager.sendMessage(p, MessageType.EXECUTED_FOR_PLAYER, altPlayer.getName());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ConfigManager.getInstance().resetPPlayer(p.getUniqueId());
|
||||
PPlayerDataManager.getInstance().resetPPlayer(p.getUniqueId());
|
||||
MessageManager.sendMessage(p, MessageType.RESET);
|
||||
}
|
||||
}
|
||||
|
@ -390,16 +366,16 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
MessageManager.sendMessage(p, MessageType.INVALID_TYPE);
|
||||
return;
|
||||
}
|
||||
String argument = args[0].replace("_", "");
|
||||
String argument = args[0];
|
||||
if (ParticleManager.effectFromString(argument) != null) {
|
||||
ParticleEffect effect = ParticleManager.effectFromString(argument);
|
||||
if (!PermissionManager.hasEffectPermission(p, effect)) {
|
||||
MessageManager.sendMessage(p, MessageType.NO_PERMISSION, effect.getName().toLowerCase());
|
||||
MessageManager.sendMessage(p, MessageType.NO_PERMISSION, effect.getName());
|
||||
return;
|
||||
}
|
||||
ConfigManager.getInstance().savePPlayer(p.getUniqueId(), effect);
|
||||
PPlayerDataManager.getInstance().savePPlayer(p.getUniqueId(), effect);
|
||||
if (effect != ParticleEffect.NONE) {
|
||||
MessageManager.sendMessage(p, MessageType.NOW_USING, effect.getName().toLowerCase());
|
||||
MessageManager.sendMessage(p, MessageType.NOW_USING, effect.getName());
|
||||
} else {
|
||||
MessageManager.sendMessage(p, MessageType.CLEARED_PARTICLES);
|
||||
}
|
||||
|
@ -422,7 +398,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
String toSend = MessageType.USE.getMessage() + " ";
|
||||
for (ParticleEffect effect : ParticleEffect.getSupportedEffects()) {
|
||||
if (PermissionManager.hasEffectPermission(p, effect)) {
|
||||
toSend += effect.getName().toLowerCase().replace("_", "") + ", ";
|
||||
toSend += effect.getName() + ", ";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -449,16 +425,16 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
MessageManager.sendMessage(p, MessageType.INVALID_TYPE_STYLE);
|
||||
return;
|
||||
}
|
||||
String argument = args[0].replace("_", "");
|
||||
String argument = args[0];
|
||||
if (ParticleStyleManager.styleFromString(argument) != null) {
|
||||
ParticleStyle style = ParticleStyleManager.styleFromString(argument);
|
||||
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;
|
||||
}
|
||||
ConfigManager.getInstance().savePPlayer(p.getUniqueId(), style);
|
||||
PPlayerDataManager.getInstance().savePPlayer(p.getUniqueId(), style);
|
||||
if (style != DefaultStyles.NONE) {
|
||||
MessageManager.sendMessage(p, MessageType.NOW_USING_STYLE, style.getName().toLowerCase());
|
||||
MessageManager.sendMessage(p, MessageType.NOW_USING_STYLE, style.getName());
|
||||
} else {
|
||||
MessageManager.sendMessage(p, MessageType.CLEARED_STYLE);
|
||||
}
|
||||
|
@ -481,7 +457,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
String toSend = MessageType.USE.getMessage() + " ";
|
||||
for (ParticleStyle style : ParticleStyleManager.getStyles()) {
|
||||
if (PermissionManager.hasStylePermission(p, style)) {
|
||||
toSend += style.getName().toLowerCase();
|
||||
toSend += style.getName();
|
||||
toSend += ", ";
|
||||
}
|
||||
}
|
||||
|
@ -525,7 +501,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
|
||||
if (cmd.equalsIgnoreCase("create")) {
|
||||
final String[] f_args = args;
|
||||
ConfigManager.getInstance().hasPlayerReachedMaxFixedEffects(p.getUniqueId(), (reachedMax) -> {
|
||||
PPlayerDataManager.getInstance().hasPlayerReachedMaxFixedEffects(p.getUniqueId(), (reachedMax) -> {
|
||||
if (reachedMax) {
|
||||
MessageManager.sendMessage(p, MessageType.MAX_FIXED_EFFECTS_REACHED);
|
||||
return;
|
||||
|
@ -564,7 +540,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
}
|
||||
|
||||
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) {
|
||||
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_OUT_OF_RANGE, maxCreationDistance + "");
|
||||
return;
|
||||
|
@ -644,11 +620,9 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
colorData = new OrdinaryColor(r, g, b);
|
||||
}
|
||||
}
|
||||
} else if (effect.hasProperty(ParticleProperty.REQUIRES_DATA)) {
|
||||
if (effect == ParticleEffect.BLOCK_CRACK || effect == ParticleEffect.BLOCK_DUST || effect == ParticleEffect.FALLING_DUST) {
|
||||
} else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
|
||||
if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) {
|
||||
Material material = null;
|
||||
int data = -1;
|
||||
|
||||
try {
|
||||
material = ParticleUtils.closestMatch(f_args[5]);
|
||||
if (material == null) material = Material.matchMaterial(f_args[5]);
|
||||
|
@ -658,23 +632,9 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
data = Integer.parseInt(f_args[6]);
|
||||
} 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) {
|
||||
blockData = new BlockData(material);
|
||||
} else if (effect == ParticleEffect.ITEM) {
|
||||
Material material = null;
|
||||
int data = -1;
|
||||
|
||||
try {
|
||||
material = ParticleUtils.closestMatch(f_args[5]);
|
||||
if (material == null) material = Material.matchMaterial(f_args[5]);
|
||||
|
@ -684,19 +644,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
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);
|
||||
itemData = new ItemData(material);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -708,14 +656,14 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
final OrdinaryColor f_colorData = colorData;
|
||||
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
|
||||
nextFixedEffectId,
|
||||
p.getLocation().getWorld().getName(), f_xPos, f_yPos, f_zPos,
|
||||
effect, style, f_itemData, f_blockData, f_colorData, f_noteData); // @formatter:on
|
||||
|
||||
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_SUCCESS);
|
||||
ConfigManager.getInstance().saveFixedEffect(fixedEffect);
|
||||
PPlayerDataManager.getInstance().saveFixedEffect(fixedEffect);
|
||||
});
|
||||
});
|
||||
} else if (cmd.equalsIgnoreCase("remove")) {
|
||||
|
@ -733,7 +681,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
}
|
||||
|
||||
final int f_id = id;
|
||||
ConfigManager.getInstance().removeFixedEffect(p.getUniqueId(), id, (successful) -> {
|
||||
PPlayerDataManager.getInstance().removeFixedEffect(p.getUniqueId(), id, (successful) -> {
|
||||
if (successful) {
|
||||
MessageManager.sendMessage(p, MessageType.REMOVE_FIXED_SUCCESS, f_id + "");
|
||||
} else {
|
||||
|
@ -741,7 +689,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
}
|
||||
});
|
||||
} else if (cmd.equalsIgnoreCase("list")) {
|
||||
ConfigManager.getInstance().getFixedEffectIdsForPlayer(p.getUniqueId(), (ids) -> {
|
||||
PPlayerDataManager.getInstance().getFixedEffectIdsForPlayer(p.getUniqueId(), (ids) -> {
|
||||
Collections.sort(ids);
|
||||
|
||||
if (ids.isEmpty()) {
|
||||
|
@ -775,7 +723,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
|
||||
|
||||
final int f_id = id;
|
||||
ConfigManager.getInstance().getFixedEffectForPlayerById(p.getUniqueId(), id, (fixedEffect) -> {
|
||||
PPlayerDataManager.getInstance().getFixedEffectForPlayerById(p.getUniqueId(), id, (fixedEffect) -> {
|
||||
if (fixedEffect == null) {
|
||||
MessageManager.sendMessage(p, MessageType.INFO_FIXED_NONEXISTANT, f_id + "");
|
||||
return;
|
||||
|
@ -819,7 +767,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
fixedEffectsToRemove.add(fixedEffect);
|
||||
|
||||
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
|
||||
.replaceAll("\\{0\\}", fixedEffectsToRemove.size() + "")
|
||||
|
@ -859,7 +807,7 @@ public class ParticleCommandExecutor implements CommandExecutor {
|
|||
MessageManager.sendMessage(p, MessageType.GUI_BY_DEFAULT);
|
||||
}
|
||||
|
||||
ConfigManager.getInstance().getPPlayer(p.getUniqueId(), (pplayer) -> {
|
||||
PPlayerDataManager.getInstance().getPPlayer(p.getUniqueId(), (pplayer) -> {
|
||||
PlayerParticlesGui.changeState(pplayer, GuiState.DEFAULT);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -74,15 +74,27 @@ public class PlayerParticles extends JavaPlugin {
|
|||
Bukkit.getPluginManager().registerEvents(new ParticleManager(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new PluginUpdateListener(), 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");
|
||||
if (configFile.exists()) configFile.delete();
|
||||
saveDefaultConfig();
|
||||
reloadConfig();
|
||||
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()) {
|
||||
new BukkitRunnable() {
|
||||
|
@ -138,7 +150,7 @@ public class PlayerParticles extends JavaPlugin {
|
|||
* 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
|
||||
*/
|
||||
private void checkDatabase() {
|
||||
private void checkDatabase(boolean shouldPurge) {
|
||||
if (getConfig().getBoolean("database-enable")) {
|
||||
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
|
||||
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();
|
||||
ResultSet res = statement.executeQuery("SHOW TABLES LIKE 'pp_users'")) {
|
||||
|
||||
|
@ -165,8 +194,8 @@ public class PlayerParticles extends JavaPlugin {
|
|||
} else { // Database isn't created yet
|
||||
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_data_item (uuid VARCHAR(36), material VARCHAR(32), data SMALLINT);" +
|
||||
"CREATE TABLE pp_data_block (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));" +
|
||||
"CREATE TABLE pp_data_color (uuid VARCHAR(36), r SMALLINT, g SMALLINT, b 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
|
||||
* 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;
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||
|
||||
import com.esophose.playerparticles.PPlayer;
|
||||
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.particles.ParticleEffect;
|
||||
import com.esophose.playerparticles.particles.ParticleEffect.BlockData;
|
||||
|
@ -102,22 +102,22 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
|||
|
||||
static { // @formatter:off
|
||||
colorMapping = new ColorData[] {
|
||||
new ColorData(DyeColor.RED, Material.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.YELLOW, Material.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.GREEN, Material.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.CYAN, Material.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.PURPLE, Material.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.PINK, Material.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.BLACK, Material.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.getByColor(Color.SILVER), Material.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.RED, ParticleUtils.closestMatch("ROSE_RED"), new OrdinaryColor(255, 0, 0), ChatColor.RED + "red"),
|
||||
new ColorData(DyeColor.ORANGE, ParticleUtils.closestMatch("ORANGE_DYE"), new OrdinaryColor(255, 140, 0), ChatColor.GOLD + "orange"),
|
||||
new ColorData(DyeColor.YELLOW, ParticleUtils.closestMatch("DANDELION_YELLOW"), new OrdinaryColor(255, 255, 0), ChatColor.YELLOW + "yellow"),
|
||||
new ColorData(DyeColor.LIME, ParticleUtils.closestMatch("LIME_DYE"), new OrdinaryColor(50, 205, 50), ChatColor.GREEN + "lime green"),
|
||||
new ColorData(DyeColor.GREEN, ParticleUtils.closestMatch("CACTUS_GREEN"), new OrdinaryColor(0, 128, 0), ChatColor.DARK_GREEN + "green"),
|
||||
new ColorData(DyeColor.BLUE, ParticleUtils.closestMatch("LAPIZ_LAZULI"), new OrdinaryColor(0, 0, 255), ChatColor.DARK_BLUE + "blue"),
|
||||
new ColorData(DyeColor.CYAN, ParticleUtils.closestMatch("CYAN_DYE"), new OrdinaryColor(0, 139, 139), ChatColor.DARK_AQUA + "cyan"),
|
||||
new ColorData(DyeColor.LIGHT_BLUE, ParticleUtils.closestMatch("LIGHT_BLUE_DYE"), new OrdinaryColor(173, 216, 230), ChatColor.AQUA + "light blue"),
|
||||
new ColorData(DyeColor.PURPLE, ParticleUtils.closestMatch("PURPLE_DYE"), new OrdinaryColor(138, 43, 226), ChatColor.DARK_PURPLE + "purple"),
|
||||
new ColorData(DyeColor.MAGENTA, ParticleUtils.closestMatch("MAGENTA_DYE"), new OrdinaryColor(202, 31, 123), ChatColor.LIGHT_PURPLE + "magenta"),
|
||||
new ColorData(DyeColor.PINK, ParticleUtils.closestMatch("PINK_DYE"), new OrdinaryColor(255, 182, 193), ChatColor.LIGHT_PURPLE + "pink"),
|
||||
new ColorData(DyeColor.BROWN, ParticleUtils.closestMatch("COCOA_BEANS"), new OrdinaryColor(139, 69, 19), ChatColor.GOLD + "brown"),
|
||||
new ColorData(DyeColor.BLACK, ParticleUtils.closestMatch("INK_SAC"), new OrdinaryColor(0, 0, 0), ChatColor.DARK_GRAY + "black"),
|
||||
new ColorData(DyeColor.GRAY, ParticleUtils.closestMatch("GRAY_DYE"), new OrdinaryColor(128, 128, 128), ChatColor.DARK_GRAY + "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, ParticleUtils.closestMatch("BONE_MEAL"), new OrdinaryColor(255, 255, 255), ChatColor.WHITE + "white"),
|
||||
};
|
||||
|
||||
rainbowColors = new DyeColor[] {
|
||||
|
@ -157,7 +157,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
|||
ParticleUtils.closestMatchWithFallback("NETHERRACK"),
|
||||
ParticleUtils.closestMatchWithFallback("SOUL_SAND"),
|
||||
ParticleUtils.closestMatchWithFallback("GLOWSTONE"),
|
||||
ParticleUtils.closestMatchWithFallback("NETHER_BRICK"),
|
||||
ParticleUtils.closestMatchWithFallback("NETHER_BRICKS"),
|
||||
ParticleUtils.closestMatchWithFallback("END_STONE", "ENDER_STONE"),
|
||||
ParticleUtils.closestMatchWithFallback("PRISMARINE")
|
||||
};
|
||||
|
@ -213,7 +213,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
|||
for (int i = 0; i < defaultMenuIcons.length; i++)
|
||||
if (defaultMenuIcons[i] == null) defaultMenuIcons[i] = Material.BARRIER;
|
||||
|
||||
for (ParticleEffect effect : ParticleEffect.values()) {
|
||||
for (ParticleEffect effect : ParticleEffect.getSupportedEffects()) {
|
||||
String effectName = effect.name();
|
||||
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.
|
||||
|
@ -239,7 +239,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
|||
|
||||
for (Map.Entry<UUID, GuiInventory> entry : playerGuiInventories.entrySet()) {
|
||||
UUID playerUUID = entry.getKey();
|
||||
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(playerUUID);
|
||||
PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(playerUUID);
|
||||
if (pplayer == null) {
|
||||
toRemoveList.add(playerUUID);
|
||||
continue;
|
||||
|
@ -368,11 +368,11 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
|||
SkullMeta currentIconMeta = (SkullMeta) currentIcon.getItemMeta();
|
||||
currentIconMeta.setDisplayName(ChatColor.GREEN + player.getName());
|
||||
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[2] = ChatColor.YELLOW + "Active Data: " + ChatColor.AQUA + p.getParticleDataString();
|
||||
currentIconMeta.setLore(Arrays.asList(currentIconLore));
|
||||
currentIconMeta.setOwningPlayer(Bukkit.getOfflinePlayer(player.getUniqueId()));
|
||||
currentIconMeta.setOwner(player.getName());
|
||||
currentIcon.setItemMeta(currentIconMeta);
|
||||
|
||||
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 == ParticleEffect.NOTE) dataType = "note " + 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
|
||||
dataIconMeta.setLore(Arrays.asList(MessageType.GUI_ICON_SET_YOUR.getMessageReplaced(dataType)));
|
||||
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]));
|
||||
}
|
||||
} else if (pe.hasProperty(ParticleProperty.REQUIRES_DATA)) {
|
||||
if (pe == ParticleEffect.ITEM_CRACK) { // Item data
|
||||
} else if (pe.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
|
||||
if (pe == ParticleEffect.ITEM) { // Item data
|
||||
Material currentItemMaterial = p.getItemData().getMaterial();
|
||||
int itemMaterialIndex = 0;
|
||||
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
|
||||
|
||||
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(player.getUniqueId());
|
||||
PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(player.getUniqueId());
|
||||
if (pplayer == null) {
|
||||
player.closeInventory();
|
||||
return;
|
||||
|
@ -602,11 +602,11 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
|||
}
|
||||
break;
|
||||
case EFFECT:
|
||||
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), ParticleManager.effectFromString(name));
|
||||
PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), ParticleManager.effectFromString(name));
|
||||
changeState(pplayer, GuiState.DEFAULT);
|
||||
break;
|
||||
case STYLE:
|
||||
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), ParticleStyleManager.styleFromString(name));
|
||||
PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), ParticleStyleManager.styleFromString(name));
|
||||
changeState(pplayer, GuiState.DEFAULT);
|
||||
break;
|
||||
case DATA:
|
||||
|
@ -614,28 +614,28 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
|
|||
if (pe.hasProperty(ParticleProperty.COLORABLE)) {
|
||||
if (pe == ParticleEffect.NOTE) {
|
||||
if (clicked.getItemMeta().getDisplayName().equals(rainbowName)) {
|
||||
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), new NoteColor(99));
|
||||
PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), new NoteColor(99));
|
||||
} else {
|
||||
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 {
|
||||
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 {
|
||||
for (int i = 0; i < colorMapping.length; i++) {
|
||||
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
|
||||
if (pe == ParticleEffect.ITEM_CRACK) {
|
||||
ConfigManager.getInstance().savePPlayer(pplayer.getUniqueId(), new ItemData(clickedMaterial, (byte) 0));
|
||||
if (pe == ParticleEffect.ITEM) {
|
||||
PPlayerDataManager.getInstance().savePPlayer(pplayer.getUniqueId(), new ItemData(clickedMaterial));
|
||||
} 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);
|
||||
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) {
|
||||
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 {
|
||||
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.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
}
|
||||
|
|
|
@ -38,12 +38,12 @@ import com.esophose.playerparticles.styles.api.ParticleStyle;
|
|||
import com.esophose.playerparticles.styles.api.ParticleStyleManager;
|
||||
import com.esophose.playerparticles.util.ParticleUtils;
|
||||
|
||||
public class ConfigManager {
|
||||
public class PPlayerDataManager {
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -71,14 +71,14 @@ public class ConfigManager {
|
|||
/**
|
||||
* @return The instance of the config for effects
|
||||
*/
|
||||
public static ConfigManager getInstance() {
|
||||
public static PPlayerDataManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.getPlugin().getDataFolder().exists()) PlayerParticles.getPlugin().getDataFolder().mkdir();
|
||||
|
||||
|
@ -165,8 +165,8 @@ public class ConfigManager {
|
|||
|
||||
ParticleEffect particleEffect = ParticleEffect.fromName(effectSection.getString("name"));
|
||||
ParticleStyle particleStyle = ParticleStyleManager.styleFromString(styleSection.getString("name"));
|
||||
ItemData particleItemData = new ItemData(Material.matchMaterial(itemDataSection.getString("material")), (byte) itemDataSection.getInt("data"));
|
||||
BlockData particleBlockData = new BlockData(Material.matchMaterial(blockDataSection.getString("material")), (byte) blockDataSection.getInt("data"));
|
||||
ItemData particleItemData = new ItemData(Material.matchMaterial(itemDataSection.getString("material")));
|
||||
BlockData particleBlockData = new BlockData(Material.matchMaterial(blockDataSection.getString("material")));
|
||||
OrdinaryColor particleColorData = new OrdinaryColor(colorDataSection.getInt("r"), colorDataSection.getInt("g"), colorDataSection.getInt("b"));
|
||||
NoteColor particleNoteColorData = new NoteColor(noteColorDataSection.getInt("note"));
|
||||
|
||||
|
@ -197,8 +197,8 @@ public class ConfigManager {
|
|||
if (res.next()) {
|
||||
ParticleEffect particleEffect = ParticleEffect.fromName(res.getString("u.effect"));
|
||||
ParticleStyle particleStyle = ParticleStyleManager.styleFromString(res.getString("u.style"));
|
||||
ItemData particleItemData = new ItemData(Material.matchMaterial(res.getString("i.material")), res.getByte("i.data"));
|
||||
BlockData particleBlockData = new BlockData(Material.matchMaterial(res.getString("b.material")), res.getByte("b.data"));
|
||||
ItemData particleItemData = new ItemData(Material.matchMaterial(res.getString("i.material")));
|
||||
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"));
|
||||
NoteColor particleNoteColorData = new NoteColor(res.getByte("n.note"));
|
||||
|
||||
|
@ -246,9 +246,7 @@ public class ConfigManager {
|
|||
effectSection.set("name", pplayer.getParticleEffect().getName());
|
||||
styleSection.set("name", pplayer.getParticleStyle().getName());
|
||||
itemDataSection.set("material", pplayer.getItemData().getMaterial().name());
|
||||
itemDataSection.set("data", pplayer.getItemData().getData());
|
||||
blockDataSection.set("material", pplayer.getBlockData().getMaterial().name());
|
||||
blockDataSection.set("data", pplayer.getBlockData().getData());
|
||||
colorDataSection.set("r", pplayer.getColorData().getRed());
|
||||
colorDataSection.set("g", pplayer.getColorData().getGreen());
|
||||
colorDataSection.set("b", pplayer.getColorData().getBlue());
|
||||
|
@ -269,13 +267,11 @@ public class ConfigManager {
|
|||
"); " +
|
||||
"INSERT INTO pp_data_item (uuid, material, data) VALUES (" +
|
||||
"'" + pplayer.getUniqueId().toString() + "', " +
|
||||
"'" + pplayer.getItemData().getMaterial().name() + "', " +
|
||||
pplayer.getItemData().getData() +
|
||||
"'" + pplayer.getItemData().getMaterial().name() +
|
||||
"); " +
|
||||
"INSERT INTO pp_data_block (uuid, material, data) VALUES (" +
|
||||
"'" + pplayer.getUniqueId().toString() + "', " +
|
||||
"'" + pplayer.getBlockData().getMaterial().name() + "', " +
|
||||
pplayer.getBlockData().getData() +
|
||||
"'" + pplayer.getBlockData().getMaterial().name() +
|
||||
"); " +
|
||||
"INSERT INTO pp_data_color (uuid, r, g, b) VALUES (" +
|
||||
"'" + pplayer.getUniqueId().toString() + "', " +
|
||||
|
@ -393,12 +389,11 @@ public class ConfigManager {
|
|||
if (!PlayerParticles.useMySQL) {
|
||||
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".itemData");
|
||||
section.set("material", particleItemData.getMaterial().name());
|
||||
section.set("data", particleItemData.getData());
|
||||
save();
|
||||
} else {
|
||||
async(() -> {
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -420,12 +415,11 @@ public class ConfigManager {
|
|||
if (!PlayerParticles.useMySQL) {
|
||||
ConfigurationSection section = playerDataYaml.getConfigurationSection(playerUUID.toString() + ".blockData");
|
||||
section.set("material", particleBlockData.getMaterial().name());
|
||||
section.set("data", particleBlockData.getData());
|
||||
save();
|
||||
} else {
|
||||
async(() -> {
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -507,7 +501,6 @@ public class ConfigManager {
|
|||
baseSection.createSection("colorData");
|
||||
baseSection.createSection("noteColorData");
|
||||
} else {
|
||||
System.out.println("Tried to create a fixed effect with ID " + fixedEffect.getId() + " that already exists!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -527,9 +520,7 @@ public class ConfigManager {
|
|||
effectSection.set("name", fixedEffect.getParticleEffect().getName());
|
||||
styleSection.set("name", fixedEffect.getParticleStyle().getName());
|
||||
itemDataSection.set("material", fixedEffect.getItemData().getMaterial().name());
|
||||
itemDataSection.set("data", fixedEffect.getItemData().getData());
|
||||
blockDataSection.set("material", fixedEffect.getBlockData().getMaterial().name());
|
||||
blockDataSection.set("data", fixedEffect.getBlockData().getData());
|
||||
colorDataSection.set("r", fixedEffect.getColorData().getRed());
|
||||
colorDataSection.set("g", fixedEffect.getColorData().getGreen());
|
||||
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())) {
|
||||
|
||||
if (res.next()) {
|
||||
System.out.println("Tried to create a fixed effect with ID " + fixedEffect.getId() + " that already in the database!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -563,13 +553,11 @@ public class ConfigManager {
|
|||
"); " +
|
||||
"INSERT INTO pp_data_item (uuid, material, data) VALUES (" +
|
||||
"'" + fixedEffectUUID + "', " +
|
||||
"'" + fixedEffect.getItemData().getMaterial().name() + "', " +
|
||||
fixedEffect.getItemData().getData() +
|
||||
"'" + fixedEffect.getItemData().getMaterial().name() +
|
||||
"); " +
|
||||
"INSERT INTO pp_data_block (uuid, material, data) VALUES (" +
|
||||
"'" + fixedEffectUUID + "', " +
|
||||
"'" + fixedEffect.getBlockData().getMaterial().name() + "', " +
|
||||
fixedEffect.getBlockData().getData() +
|
||||
"'" + fixedEffect.getBlockData().getMaterial().name() +
|
||||
"); " +
|
||||
"INSERT INTO pp_data_color (uuid, r, g, b) VALUES (" +
|
||||
"'" + fixedEffectUUID + "', " +
|
||||
|
@ -695,8 +683,8 @@ public class ConfigManager {
|
|||
double zPos = section.getDouble("zPos");
|
||||
ParticleEffect particleEffect = ParticleEffect.fromName(effectSection.getString("name"));
|
||||
ParticleStyle particleStyle = ParticleStyleManager.styleFromString(styleSection.getString("name"));
|
||||
ItemData particleItemData = new ItemData(Material.matchMaterial(itemDataSection.getString("material")), (byte) itemDataSection.getInt("data"));
|
||||
BlockData particleBlockData = new BlockData(Material.matchMaterial(blockDataSection.getString("material")), (byte) blockDataSection.getInt("data"));
|
||||
ItemData particleItemData = new ItemData(Material.matchMaterial(itemDataSection.getString("material")));
|
||||
BlockData particleBlockData = new BlockData(Material.matchMaterial(blockDataSection.getString("material")));
|
||||
OrdinaryColor particleColorData = new OrdinaryColor(colorDataSection.getInt("r"), colorDataSection.getInt("g"), colorDataSection.getInt("b"));
|
||||
NoteColor particleNoteColorData = new NoteColor(noteColorDataSection.getInt("note"));
|
||||
|
||||
|
@ -728,8 +716,8 @@ public class ConfigManager {
|
|||
double zPos = res.getDouble("f.zPos");
|
||||
ParticleEffect particleEffect = ParticleManager.effectFromString(res.getString("f.effect"));
|
||||
ParticleStyle particleStyle = ParticleStyleManager.styleFromString(res.getString("f.style"));
|
||||
ItemData particleItemData = new ItemData(Material.matchMaterial(res.getString("i.material")), res.getByte("i.data"));
|
||||
BlockData particleBlockData = new BlockData(Material.matchMaterial(res.getString("b.material")), res.getByte("b.data"));
|
||||
ItemData particleItemData = new ItemData(Material.matchMaterial(res.getString("i.material")));
|
||||
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"));
|
||||
NoteColor particleNoteColorData = new NoteColor(res.getByte("n.note"));
|
||||
|
||||
|
@ -767,8 +755,8 @@ public class ConfigManager {
|
|||
double zPos = section.getDouble("zPos");
|
||||
ParticleEffect particleEffect = ParticleEffect.fromName(effectSection.getString("name"));
|
||||
ParticleStyle particleStyle = ParticleStyleManager.styleFromString(styleSection.getString("name"));
|
||||
ItemData particleItemData = new ItemData(Material.matchMaterial(itemDataSection.getString("material")), (byte) itemDataSection.getInt("data"));
|
||||
BlockData particleBlockData = new BlockData(Material.matchMaterial(blockDataSection.getString("material")), (byte) blockDataSection.getInt("data"));
|
||||
ItemData particleItemData = new ItemData(Material.matchMaterial(itemDataSection.getString("material")));
|
||||
BlockData particleBlockData = new BlockData(Material.matchMaterial(blockDataSection.getString("material")));
|
||||
OrdinaryColor particleColorData = new OrdinaryColor(colorDataSection.getInt("r"), colorDataSection.getInt("g"), colorDataSection.getInt("b"));
|
||||
NoteColor particleNoteColorData = new NoteColor(noteColorDataSection.getInt("note"));
|
||||
|
||||
|
@ -793,8 +781,8 @@ public class ConfigManager {
|
|||
double zPos = res.getDouble("f.zPos");
|
||||
ParticleEffect particleEffect = ParticleManager.effectFromString(res.getString("f.effect"));
|
||||
ParticleStyle particleStyle = ParticleStyleManager.styleFromString(res.getString("f.style"));
|
||||
ItemData particleItemData = new ItemData(Material.matchMaterial(res.getString("i.material")), res.getByte("i.data"));
|
||||
BlockData particleBlockData = new BlockData(Material.matchMaterial(res.getString("b.material")), res.getByte("b.data"));
|
||||
ItemData particleItemData = new ItemData(Material.matchMaterial(res.getString("i.material")));
|
||||
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"));
|
||||
NoteColor particleNoteColorData = new NoteColor(res.getByte("n.note"));
|
||||
|
||||
|
@ -975,7 +963,6 @@ public class ConfigManager {
|
|||
private void async(SyncInterface asyncCallback) {
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
System.out.println("Async with thread: " + Thread.currentThread().getName());
|
||||
asyncCallback.execute();
|
||||
}
|
||||
}.runTaskAsynchronously(PlayerParticles.getPlugin());
|
||||
|
@ -989,7 +976,6 @@ public class ConfigManager {
|
|||
private void sync(SyncInterface syncCallback) {
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
System.out.println("Resynced with thread: " + Thread.currentThread().getName());
|
||||
syncCallback.execute();
|
||||
}
|
||||
}.runTask(PlayerParticles.getPlugin());
|
|
@ -29,7 +29,6 @@ import com.esophose.playerparticles.particles.ParticleEffect;
|
|||
import com.esophose.playerparticles.particles.ParticleEffect.NoteColor;
|
||||
import com.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
|
||||
import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
|
||||
import com.esophose.playerparticles.styles.DefaultStyles;
|
||||
import com.esophose.playerparticles.styles.api.PParticle;
|
||||
import com.esophose.playerparticles.styles.api.ParticleStyleManager;
|
||||
|
||||
|
@ -59,7 +58,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
|
|||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
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)
|
||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||
PPlayer pplayer = ConfigManager.getInstance().getPPlayer(e.getPlayer().getUniqueId());
|
||||
PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(e.getPlayer().getUniqueId());
|
||||
if (pplayer != null)
|
||||
particlePlayers.remove(pplayer);
|
||||
}
|
||||
|
@ -78,7 +77,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
|
|||
* Adds all fixed effects from the config
|
||||
*/
|
||||
public static void addAllFixedEffects() {
|
||||
ConfigManager.getInstance().getAllFixedEffects((fixedEffects) -> {
|
||||
PPlayerDataManager.getInstance().getAllFixedEffects((fixedEffects) -> {
|
||||
fixedParticleEffects.addAll(fixedEffects);
|
||||
});
|
||||
}
|
||||
|
@ -122,7 +121,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
|
|||
public static void refreshPPlayers() {
|
||||
particlePlayers.clear();
|
||||
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) {
|
||||
for (ParticleEffect effect : ParticleEffect.getSupportedEffects()) {
|
||||
if (effect.getName().toLowerCase().replace("_", "").equals(effectName.toLowerCase())) return effect;
|
||||
if (effect.getName().equalsIgnoreCase(effectName)) return effect;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -178,27 +177,15 @@ public class ParticleManager extends BukkitRunnable implements Listener {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Perform permission and validity checks
|
||||
// Perform validity checks
|
||||
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
|
||||
if (player.getGameMode() == GameMode.SPECTATOR) {
|
||||
valid = false;
|
||||
}
|
||||
|
||||
if (ConfigManager.getInstance().isWorldDisabled(player.getWorld().getName())) {
|
||||
if (PPlayerDataManager.getInstance().isWorldDisabled(player.getWorld().getName())) {
|
||||
valid = false;
|
||||
}
|
||||
|
||||
|
@ -235,7 +222,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
|
|||
ParticleEffect effect = pplayer.getParticleEffect();
|
||||
if (effect == ParticleEffect.NONE) return;
|
||||
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)));
|
||||
} else if (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();
|
||||
if (effect == ParticleEffect.NONE) return;
|
||||
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)));
|
||||
} else if (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);
|
||||
ParticleEffect effect = fixedEffect.getParticleEffect();
|
||||
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)));
|
||||
} else if (effect.hasProperty(ParticleProperty.COLORABLE)) {
|
||||
effect.display(fixedEffect.getParticleSpawnColor(), particle.getLocation(effect.hasProperty(ParticleProperty.COLORABLE)));
|
||||
|
|
|
@ -30,7 +30,7 @@ public class PermissionManager {
|
|||
*/
|
||||
public static boolean hasEffectPermission(Player player, ParticleEffect effect) {
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class PermissionManager {
|
|||
*/
|
||||
public static boolean hasStylePermission(Player player, ParticleStyle style) {
|
||||
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;
|
||||
return false;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public class PermissionManager {
|
|||
public static List<String> getEffectsUserHasPermissionFor(Player p) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
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;
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class PermissionManager {
|
|||
public static List<String> getStylesUserHasPermissionFor(Player p) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.bukkit.Location;
|
|||
import org.bukkit.World;
|
||||
|
||||
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.particles.ParticleEffect.BlockData;
|
||||
import com.esophose.playerparticles.particles.ParticleEffect.ItemData;
|
||||
|
@ -87,8 +87,8 @@ public class FixedParticleEffect {
|
|||
this.particleNoteColorData = noteColorData;
|
||||
|
||||
// The PPlayer must be loaded
|
||||
ConfigManager.getInstance().loadPPlayer(pplayerUUID);
|
||||
PPlayer owner = ConfigManager.getInstance().getPPlayer(this.pplayerUUID);
|
||||
PPlayerDataManager.getInstance().loadPPlayer(pplayerUUID);
|
||||
PPlayer owner = PPlayerDataManager.getInstance().getPPlayer(this.pplayerUUID);
|
||||
|
||||
// Check nulls, if any are null set them to the PPlayer's values
|
||||
if (this.particleItemData == null) this.particleItemData = owner.getItemData();
|
||||
|
@ -182,10 +182,10 @@ public class FixedParticleEffect {
|
|||
* @return The ParticleData the current particle effect requires
|
||||
*/
|
||||
public ParticleData getParticleSpawnData() {
|
||||
if (this.particleEffect.hasProperty(ParticleProperty.REQUIRES_DATA)) {
|
||||
if (this.particleEffect == ParticleEffect.BLOCK_CRACK || this.particleEffect == ParticleEffect.BLOCK_DUST || this.particleEffect == ParticleEffect.FALLING_DUST) {
|
||||
if (this.particleEffect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
|
||||
if (this.particleEffect == ParticleEffect.BLOCK || this.particleEffect == ParticleEffect.FALLING_DUST) {
|
||||
return particleBlockData;
|
||||
} else if (this.particleEffect == ParticleEffect.ITEM_CRACK) {
|
||||
} else if (this.particleEffect == ParticleEffect.ITEM) {
|
||||
return this.particleItemData;
|
||||
}
|
||||
}
|
||||
|
@ -235,11 +235,11 @@ public class FixedParticleEffect {
|
|||
return this.particleColorData.getRed() + " " + this.particleColorData.getGreen() + " " + this.particleColorData.getBlue();
|
||||
}
|
||||
}
|
||||
} else if (this.particleEffect.hasProperty(ParticleProperty.REQUIRES_DATA)) {
|
||||
if (this.particleEffect == ParticleEffect.BLOCK_CRACK || this.particleEffect == ParticleEffect.BLOCK_DUST || this.particleEffect == ParticleEffect.FALLING_DUST) {
|
||||
return this.particleBlockData.getMaterial() + " " + this.particleBlockData.getData();
|
||||
} else if (this.particleEffect == ParticleEffect.ITEM_CRACK) {
|
||||
return this.particleItemData.getMaterial() + " " + this.particleItemData.getData();
|
||||
} else if (this.particleEffect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
|
||||
if (this.particleEffect == ParticleEffect.BLOCK || this.particleEffect == ParticleEffect.FALLING_DUST) {
|
||||
return this.particleBlockData.getMaterial().toString().toLowerCase();
|
||||
} else if (this.particleEffect == ParticleEffect.ITEM) {
|
||||
return this.particleItemData.getMaterial().toString().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -8,6 +18,7 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
|
@ -15,124 +26,110 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
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
|
||||
*
|
||||
* @author (of changes) Esophose
|
||||
* @author Esophose
|
||||
*/
|
||||
public enum ParticleEffect {
|
||||
|
||||
NONE("none", ""), // Custom effect type, has no Spigot Particle Enum
|
||||
EXPLODE("explode", "EXPLOSION_NORMAL"),
|
||||
LARGE_EXPLODE("largeexplode", "EXPLOSION_LARGE"),
|
||||
HUGE_EXPLOSION("hugeexplosion", "EXPLOSION_HUGE"),
|
||||
FIREWORKS_SPARK("fireworksSpark", "FIREWORKS_SPARK"),
|
||||
BUBBLE("bubble", "WATER_BUBBLE"),
|
||||
//SPLASH("splash", "WATER_SPLASH"), // Basically the same thing as droplet, just goes a tiny bit higher
|
||||
WAKE("wake", "WATER_WAKE"),
|
||||
SUSPENDED("suspended", "SUSPENDED"),
|
||||
DEPTH_SUSPEND("depthSuspend", "SUSPENDED_DEPTH"),
|
||||
CRIT("crit", "CRIT"),
|
||||
MAGIC_CRIT("magicCrit", "CRIT_MAGIC"),
|
||||
SMOKE("smoke", "SMOKE_NORMAL"),
|
||||
LARGE_SMOKE("largesmoke", "SMOKE_LARGE"),
|
||||
SPELL("spell", "SPELL"),
|
||||
INSTANT_SPELL("instantSpell", "SPELL_INSTANT"),
|
||||
MOB_SPELL("mobSpell", "SPELL_MOB", ParticleProperty.COLORABLE),
|
||||
MOB_SPELL_AMBIENT("mobSpellAmbient", "SPELL_MOB_AMBIENT", ParticleProperty.COLORABLE),
|
||||
WITCH_MAGIC("witchMagic", "SPELL_WITCH"),
|
||||
DRIP_WATER("dripWater", "DRIP_WATER"),
|
||||
DRIP_LAVA("dripLava", "DRIP_LAVA"),
|
||||
ANGRY_VILLAGER("angryVillager", "VILLAGER_ANGRY"),
|
||||
HAPPY_VILLAGER("happyVillager", "VILLAGER_HAPPY"),
|
||||
NOTE("note", "NOTE", ParticleProperty.COLORABLE),
|
||||
PORTAL("portal", "PORTAL"),
|
||||
ENCHANTMENT_TABLE("enchantmenttable", "ENCHANTMENT_TABLE"),
|
||||
FLAME("flame", "FLAME"),
|
||||
LAVA("lava", "LAVA"),
|
||||
FOOTSTEP("footstep", "FOOTSTEP"),
|
||||
CLOUD("cloud", "CLOUD"),
|
||||
RED_DUST("reddust", "REDSTONE", ParticleProperty.COLORABLE),
|
||||
SNOWBALL_POOF("snowballpoof", "SNOWBALL"),
|
||||
SNOW_SHOVEL("snowshovel", "SNOW_SHOVEL"),
|
||||
SLIME("slime", "SLIME"),
|
||||
HEART("heart", "HEART"),
|
||||
BARRIER("barrier", "BARRIER"),
|
||||
ITEM_CRACK("iconcrack", "ITEM_CRACK", ParticleProperty.REQUIRES_DATA),
|
||||
BLOCK_CRACK("blockcrack", "BLOCK_CRACK", ParticleProperty.REQUIRES_DATA),
|
||||
BLOCK_DUST("blockdust", "BLOCK_DUST", ParticleProperty.REQUIRES_DATA),
|
||||
DROPLET("droplet", "WATER_DROP"),
|
||||
// ITEM_TAKE("take", "ITEM_TAKE"), // Doesn't do anything
|
||||
// MOB_APPEARANCE("mobappearance", "MOB_APPEARANCE"), // Looks ridiculous
|
||||
DRAGON_BREATH("dragonbreath", "DRAGON_BREATH"),
|
||||
END_ROD("endrod", "END_ROD"),
|
||||
DAMAGE_INDICATOR("damageindicator", "DAMAGE_INDICATOR"),
|
||||
SWEEP_ATTACK("sweepattack", "SWEEP_ATTACK"),
|
||||
FALLING_DUST("fallingdust", "FALLING_DUST", ParticleProperty.REQUIRES_DATA),
|
||||
TOTEM("totem", "TOTEM"),
|
||||
SPIT("spit", "SPIT");
|
||||
|
||||
// Ordered and named by their Minecraft 1.13 internal names
|
||||
AMBIENT_ENTITY_EFFECT("SPELL_MOB_AMBIENT", "SPELL_MOB_AMBIENT", ParticleProperty.COLORABLE),
|
||||
ANGRY_VILLAGER("VILLAGER_ANGRY", "VILLAGER_ANGRY"),
|
||||
BARRIER("BARRIER", "BARRIER"),
|
||||
BLOCK("BLOCK_CRACK", "BLOCK_CRACK", ParticleProperty.REQUIRES_MATERIAL_DATA),
|
||||
BUBBLE("WATER_BUBBLE", "WATER_BUBBLE"),
|
||||
//BUBBLE_COLUMN_UP("BUBBLE_COLUMN_UP", null), // Identical to bubble
|
||||
BUBBLE_POP("BUBBLE_POP", null),
|
||||
CLOUD("CLOUD", "CLOUD"),
|
||||
CRIT("CRIT", "CRIT"),
|
||||
CURRENT_DOWN("CURRENT_DOWN", null),
|
||||
DAMAGE_INDICATOR("DAMAGE_INDICATOR", "DAMAGE_INDICATOR"),
|
||||
DOLPHIN("DOLPHIN", null),
|
||||
DRAGON_BREATH("DRAGON_BREATH", "DRAGON_BREATH"),
|
||||
DRIPPING_LAVA("DRIP_LAVA", "DRIP_LAVA"),
|
||||
DRIPPING_WATER("DRIP_WATER", "DRIP_WATER"),
|
||||
DUST("REDSTONE", "REDSTONE", ParticleProperty.COLORABLE),
|
||||
//ELDER_GUARDIAN("MOB_APPEARANCE", "MOB_APPEARANCE"), // No thank you
|
||||
ENCHANT("ENCHANTMENT_TABLE", "ENCHANTMENT_TABLE"),
|
||||
ENCHANTED_HIT("CRIT_MAGIC", "CRIT_MAGIC"),
|
||||
END_ROD("END_ROD", "END_ROD"),
|
||||
ENTITY_EFFECT("SPELL_MOB", "SPELL_MOB", ParticleProperty.COLORABLE),
|
||||
EXPLOSION("EXPLOSION_LARGE", "EXPLOSION_LARGE"),
|
||||
FALLING_DUST("FALLING_DUST", "FALLING_DUST", ParticleProperty.REQUIRES_MATERIAL_DATA),
|
||||
FIREWORK("FIREWORKS_SPARK", "FIREWORKS_SPARK"),
|
||||
FISHING("WATER_WAKE", "WATER_WAKE"),
|
||||
FLAME("FLAME", "FLAME"),
|
||||
FOOTSTEP(null, "FOOTSTEP"), // Removed in Minecraft 1.13 :(
|
||||
HAPPY_VILLAGER("VILLAGER_HAPPY", "VILLAGER_HAPPY"),
|
||||
HEART("HEART", "HEART"),
|
||||
EXPLOSION_EMITTER("EXPLOSION_HUGE", "EXPLOSION_HUGE"),
|
||||
INSTANT_EFFECT("SPELL_INSTANT", "SPELL_INSTANT"),
|
||||
ITEM("ITEM_CRACK", "ITEM_CRACK", ParticleProperty.REQUIRES_MATERIAL_DATA),
|
||||
ITEM_SLIME("SLIME", "SLIME"),
|
||||
ITEM_SNOWBALL("SNOWBALL", "SNOWBALL"),
|
||||
LARGE_SMOKE("SMOKE_LARGE", "SMOKE_LARGE"),
|
||||
LAVA("LAVA", "LAVA"),
|
||||
MYCELIUM("TOWN_AURA", "TOWN_AURA"),
|
||||
NAUTILUS("NAUTILUS", null),
|
||||
NONE("", ""), // Custom effect to represent none selected
|
||||
NOTE("NOTE", "NOTE", ParticleProperty.COLORABLE),
|
||||
POOF("EXPLOSION_NORMAL", "EXPLOSION_NORMAL"), // The 1.13 combination of explode and showshovel
|
||||
PORTAL("PORTAL", "PORTAL"),
|
||||
RAIN("WATER_DROP", "WATER_DROP"),
|
||||
SMOKE("SMOKE_NORMAL", "SMOKE_NORMAL"),
|
||||
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
|
||||
SPIT("SPIT", "SPIT"),
|
||||
SPLASH("WATER_SPLASH", "WATER_SPLASH"),
|
||||
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 Map<String, ParticleEffect> NAME_MAP = new HashMap<String, ParticleEffect>();
|
||||
private static final Map<Integer, ParticleEffect> ID_MAP = new HashMap<Integer, ParticleEffect>();
|
||||
private final String name;
|
||||
private final String spigotEnumName;
|
||||
private final Particle spigotEnum;
|
||||
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 static Constructor<?> DUSTOPTIONS_CONSTRUCTOR;
|
||||
private static Method CREATEBLOCKDATA_METHOD;
|
||||
private final Particle internalEnum;
|
||||
private final List<ParticleProperty> properties;
|
||||
|
||||
// Initialize map for quick name and id lookup
|
||||
static {
|
||||
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
|
||||
*
|
||||
* @param name Name of this particle effect
|
||||
* @param spigotEnumName Name of the Spigot Particle Enum
|
||||
* @param enumName Name of the Particle Enum when the server version is >= 1.13
|
||||
* @param enumNameLegacy Name of the Particle Enum when the server version is < 1.13
|
||||
* @param properties Properties of this particle effect
|
||||
*/
|
||||
private ParticleEffect(String name, String spigotEnumName, ParticleProperty... properties) {
|
||||
this.name = name;
|
||||
this.spigotEnumName = spigotEnumName;
|
||||
private ParticleEffect(String enumName, String enumNameLegacy, ParticleProperty... properties) {
|
||||
this.properties = Arrays.asList(properties);
|
||||
|
||||
Particle matchingSpigotEnum = null;
|
||||
Particle matchingEnum = null;
|
||||
for (Particle particle : Particle.values()) {
|
||||
if (particle.name().equals(spigotEnumName)) {
|
||||
matchingSpigotEnum = particle;
|
||||
if (particle.name().equals(enumName) || particle.name().equals(enumNameLegacy)) {
|
||||
matchingEnum = particle;
|
||||
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
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,7 +147,7 @@ public enum ParticleEffect {
|
|||
* @return The Spigot Particle Enum this ParticleEffect represents
|
||||
*/
|
||||
public Particle getSpigotEnum() {
|
||||
return spigotEnum;
|
||||
return this.internalEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,7 +157,7 @@ public enum ParticleEffect {
|
|||
* @return Whether it has the property or not
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public boolean isSupported() {
|
||||
return this == ParticleEffect.NONE || spigotEnum != null;
|
||||
return this == NONE || this.internalEnum != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -210,22 +198,6 @@ public enum ParticleEffect {
|
|||
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
|
||||
*
|
||||
|
@ -234,7 +206,7 @@ public enum ParticleEffect {
|
|||
* @return Whether the data type is correct or not
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -282,10 +254,23 @@ public enum ParticleEffect {
|
|||
if (!isColorCorrect(this, color)) {
|
||||
throw new ParticleColorException("The particle color type is incorrect");
|
||||
}
|
||||
|
||||
for (Player player : getPlayersInRange(center))
|
||||
// Minecraft clients require that you pass Float.MIN_VALUE if the Red value is 0
|
||||
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);
|
||||
|
||||
if (this == DUST && VERSION_13) { // DUST uses a special data object for spawning in 1.13
|
||||
OrdinaryColor dustColor = (OrdinaryColor)color;
|
||||
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
|
||||
*/
|
||||
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");
|
||||
}
|
||||
if (!isDataCorrect(this, data)) {
|
||||
throw new ParticleDataException("The particle data type is incorrect");
|
||||
}
|
||||
Object extraData;
|
||||
if (spigotEnum.getDataType() == MaterialData.class) {
|
||||
extraData = new MaterialData(data.getMaterial(), data.getData()); // Deprecated, but there is currently no replacement for it
|
||||
} else if (spigotEnum.getDataType() == ItemStack.class) {
|
||||
extraData = new ItemStack(data.getMaterial(), data.getData());
|
||||
Object extraData = null;
|
||||
if (internalEnum.getDataType().getTypeName().equals("org.bukkit.block.data.BlockData")) {
|
||||
try { // The Material.createBlockData() method doesn't exist in Minecraft versions less than 1.13... so this is disgusting... but it works great
|
||||
extraData = CREATEBLOCKDATA_METHOD.invoke(data.getMaterial());
|
||||
} 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 {
|
||||
System.out.println(internalEnum.getDataType());
|
||||
extraData = null;
|
||||
System.out.println(spigotEnum.getDataType().getName());
|
||||
}
|
||||
|
||||
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 {
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
@ -361,7 +350,7 @@ public enum ParticleEffect {
|
|||
|
||||
/**
|
||||
* 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}
|
||||
* <p>
|
||||
* 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 {
|
||||
private final Material material;
|
||||
private final byte data;
|
||||
|
||||
/**
|
||||
* Construct a new particle data
|
||||
*
|
||||
* @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.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -393,15 +379,6 @@ public enum ParticleEffect {
|
|||
public Material getMaterial() {
|
||||
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
|
||||
*
|
||||
* @param material Material of the item
|
||||
* @param data Data value of the item
|
||||
*/
|
||||
public ItemData(Material material, byte data) {
|
||||
super(material, data);
|
||||
public ItemData(Material material) {
|
||||
super(material);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -443,8 +419,8 @@ public enum ParticleEffect {
|
|||
* @param data Data value of the block
|
||||
* @throws IllegalArgumentException If the material is not a block
|
||||
*/
|
||||
public BlockData(Material material, byte data) throws IllegalArgumentException {
|
||||
super(material, data);
|
||||
public BlockData(Material material) throws IllegalArgumentException {
|
||||
super(material);
|
||||
if (!material.isBlock()) {
|
||||
throw new IllegalArgumentException("The material is not a block");
|
||||
}
|
||||
|
@ -701,7 +677,7 @@ public enum ParticleEffect {
|
|||
* @since 1.7
|
||||
*/
|
||||
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
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
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.PermissionManager;
|
||||
import com.esophose.playerparticles.styles.api.PParticle;
|
||||
|
@ -43,7 +43,7 @@ public class ParticleStyleBlockBreak implements ParticleStyle, Listener {
|
|||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
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)) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
ParticleManager.displayParticles(pplayer, DefaultStyles.BLOCKBREAK.getParticles(pplayer, loc));
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.bukkit.event.block.BlockBreakEvent;
|
|||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
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.PermissionManager;
|
||||
import com.esophose.playerparticles.styles.api.PParticle;
|
||||
|
@ -36,7 +36,7 @@ public class ParticleStyleBlockEdit implements ParticleStyle, Listener {
|
|||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
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)) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
ParticleManager.displayParticles(pplayer, DefaultStyles.BLOCKBREAK.getParticles(pplayer, loc));
|
||||
|
@ -46,7 +46,7 @@ public class ParticleStyleBlockEdit implements ParticleStyle, Listener {
|
|||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
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)) {
|
||||
Location loc = event.getBlockPlaced().getLocation();
|
||||
ParticleManager.displayParticles(pplayer, DefaultStyles.BLOCKPLACE.getParticles(pplayer, loc));
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
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.PermissionManager;
|
||||
import com.esophose.playerparticles.styles.api.PParticle;
|
||||
|
@ -43,7 +43,7 @@ public class ParticleStyleBlockPlace implements ParticleStyle, Listener {
|
|||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
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)) {
|
||||
Location loc = event.getBlockPlaced().getLocation();
|
||||
ParticleManager.displayParticles(pplayer, DefaultStyles.BLOCKPLACE.getParticles(pplayer, loc));
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
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.PermissionManager;
|
||||
import com.esophose.playerparticles.styles.api.PParticle;
|
||||
|
@ -44,7 +44,7 @@ public class ParticleStyleHurt implements ParticleStyle, Listener {
|
|||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
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)) {
|
||||
Location loc = player.getLocation().clone().add(0, 1, 0);
|
||||
ParticleManager.displayParticles(pplayer, DefaultStyles.HURT.getParticles(pplayer, loc));
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
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.PermissionManager;
|
||||
import com.esophose.playerparticles.styles.api.PParticle;
|
||||
|
@ -33,7 +33,7 @@ public class ParticleStyleMove implements ParticleStyle, Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
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 (PermissionManager.hasStylePermission(e.getPlayer(), DefaultStyles.MOVE)) {
|
||||
Location loc = e.getPlayer().getLocation();
|
||||
|
|
|
@ -19,20 +19,20 @@ public class ParticleStyleNone implements ParticleStyle {
|
|||
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
|
||||
} else if (particleEffect.equals(ParticleEffect.CRIT)) {
|
||||
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];
|
||||
for (int i = 0; i < 5; i++)
|
||||
particles[i] = new PParticle(location, 0.5F, 0.5F, 0.5F, 0.0F);
|
||||
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) };
|
||||
} 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) };
|
||||
} 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) };
|
||||
} 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) };
|
||||
} 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) };
|
||||
} else if (particleEffect.equals(ParticleEffect.FLAME)) {
|
||||
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) };
|
||||
} else if (particleEffect.equals(ParticleEffect.HEART)) {
|
||||
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) };
|
||||
} 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) };
|
||||
} 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) };
|
||||
} else if (particleEffect.equals(ParticleEffect.LARGE_SMOKE)) {
|
||||
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
|
||||
} else if (particleEffect.equals(ParticleEffect.LAVA)) {
|
||||
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) };
|
||||
} 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) };
|
||||
} 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) };
|
||||
} else if (particleEffect.equals(ParticleEffect.NOTE)) {
|
||||
return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) };
|
||||
} else if (particleEffect.equals(ParticleEffect.PORTAL)) {
|
||||
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) };
|
||||
} 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) };
|
||||
} else if (particleEffect.equals(ParticleEffect.SMOKE)) {
|
||||
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
|
||||
} else if (particleEffect.equals(ParticleEffect.SNOW_SHOVEL)) {
|
||||
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
|
||||
} else if (particleEffect.equals(ParticleEffect.SNOWBALL_POOF)) {
|
||||
} 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.SPELL)) {
|
||||
return new PParticle[] { new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F) };
|
||||
} else if (particleEffect.equals(ParticleEffect.SUSPENDED)) {
|
||||
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)) {
|
||||
} else if (particleEffect.equals(ParticleEffect.UNDERWATER)) {
|
||||
PParticle[] particles = new PParticle[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
particles[i] = new PParticle(location, 0.4F, 0.4F, 0.4F, 0.0F);
|
||||
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) };
|
||||
} else if (particleEffect.equals(ParticleEffect.BARRIER)) {
|
||||
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) };
|
||||
} else if (particleEffect.equals(ParticleEffect.DRAGON_BREATH)) {
|
||||
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) };
|
||||
} else if (particleEffect.equals(ParticleEffect.SWEEP_ATTACK)) {
|
||||
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) };
|
||||
} else if (particleEffect.equals(ParticleEffect.BLOCK_DUST)) {
|
||||
return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) };
|
||||
} else if (particleEffect.equals(ParticleEffect.ITEM_CRACK)) {
|
||||
} 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.FALLING_DUST)) {
|
||||
PParticle[] particles = new PParticle[2];
|
||||
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);
|
||||
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) };
|
||||
} else if (particleEffect.equals(ParticleEffect.SPIT)) {
|
||||
return new PParticle[] { new PParticle(location, 0.6F, 0.6F, 0.6F, 0.0F) };
|
||||
|
|
|
@ -13,7 +13,7 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
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.PermissionManager;
|
||||
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) {
|
||||
Player player = (Player) event.getDamager();
|
||||
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 (player.getInventory().getItemInMainHand() != null && SWORD_NAMES.contains(player.getInventory().getItemInMainHand().getType().name())) {
|
||||
Location loc = entity.getLocation().clone().add(0, 1, 0);
|
||||
|
|
|
@ -27,8 +27,8 @@ public class ParticleStyleManager {
|
|||
*/
|
||||
public static void registerStyle(ParticleStyle style) {
|
||||
for (ParticleStyle testAgainst : styles) {
|
||||
if (testAgainst.getName().replace("_", "").equalsIgnoreCase(style.getName())) {
|
||||
PlayerParticles.getPlugin().getLogger().severe("Tried to register two styles with the same (or too similar) name: " + style.getName());
|
||||
if (testAgainst.getName().equalsIgnoreCase(style.getName())) {
|
||||
PlayerParticles.getPlugin().getLogger().severe("Tried to register two styles with the same name spelling: " + style.getName());
|
||||
} else if (testAgainst.equals(style)) {
|
||||
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) {
|
||||
for (ParticleStyle style : styles)
|
||||
if (style.getName().toLowerCase().replace("_", "").equals(styleName)) return style;
|
||||
if (style.getName().equals(styleName)) return style;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
package com.esophose.playerparticles.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class ParticleUtils {
|
||||
|
@ -50,6 +53,22 @@ public class ParticleUtils {
|
|||
mat = Material.BARRIER;
|
||||
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
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# I don't recommend changing it
|
||||
# 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!
|
||||
version: 5.1
|
||||
version: 5.2
|
||||
|
||||
# Check for new versions of the plugin
|
||||
# Default: true
|
||||
|
@ -169,13 +169,13 @@ message-color-data-usage: '&b/pp data [<0-255> <0-255> <0-255>]|[rainbow]'
|
|||
|
||||
# Item Data Usage
|
||||
# You should not change the text here, only the coloring
|
||||
# Default: '&b/pp data <itemName/ID> <0-15>'
|
||||
message-item-data-usage: '&b/pp data <itemName> <0-15>'
|
||||
# Default: '&b/pp data <itemName/ID>'
|
||||
message-item-data-usage: '&b/pp data <itemName>'
|
||||
|
||||
# Block Data Usage
|
||||
# You should not change the text here, only the coloring
|
||||
# Default: '&b/pp data <blockName/ID> <0-15>'
|
||||
message-block-data-usage: '&b/pp data <blockName> <0-15>'
|
||||
# Default: '&b/pp data <blockName/ID>'
|
||||
message-block-data-usage: '&b/pp data <blockName>'
|
||||
|
||||
# ---------------- #
|
||||
# Prefixes #
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
name: PlayerParticles
|
||||
main: com.esophose.playerparticles.PlayerParticles
|
||||
version: 5.1
|
||||
version: 5.2
|
||||
api-version: 1.13
|
||||
description: Make particles around players in fancy ways.
|
||||
author: Esophose
|
||||
website: https://dev.bukkit.org/projects/playerparticles
|
||||
commands:
|
||||
pp:
|
||||
description: The main PlayerParticles command.
|
||||
description: The main PlayerParticles command. By default, opens the GUI.
|
Loading…
Reference in a new issue