Fixed Effects Finished

Finished working on Fixed Particle Effects. They are now fully
functional!
This commit is contained in:
Esophose 2017-03-03 18:40:26 -07:00
parent aeaac3abbd
commit c1616638a9
10 changed files with 596 additions and 75 deletions

View file

@ -214,6 +214,37 @@ public class FixedParticleEffect {
return null;
}
/**
* Gets the particle data as a string
*
* @return A string of the current effect's data
*/
public String getParticleDataString() {
if (this.particleEffect.hasProperty(ParticleProperty.COLORABLE)) {
if (this.particleEffect == ParticleEffect.NOTE) {
if (this.particleNoteColorData.getValueX() * 24 == 99) {
return "rainbow";
} else {
return (this.particleNoteColorData.getValueX() * 24) + "";
}
} else {
if (this.particleColorData.getRed() == 999 && this.particleColorData.getGreen() == 999 && this.particleColorData.getBlue() == 999) {
return "rainbow";
} else {
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();
}
}
return "None";
}
/**
* Gets the location this effect will be displayed at
*

View file

@ -9,17 +9,22 @@
package com.esophose.playerparticles;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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.PermissionManager;
public class ParticleCommandCompleter implements TabCompleter {
private final String[] COMMANDS = { "help", "effect", "effects", "style", "styles", "worlds", "version", "fixed", "reset" };
private final String[] FIXED_COMMANDS = { "create", "remove", "list", "info" };
/**
* Activated when a user pushes tab in chat prefixed with /pp
*
@ -30,28 +35,27 @@ 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) {
List<String> completions = new ArrayList<String>();
if (cmd.getName().equalsIgnoreCase("pp")) {
if (args.length == 0) {
List<String> list = new ArrayList<String>();
list.add("help");
list.add("effect");
list.add("effects");
list.add("style");
list.add("styles");
list.add("worlds");
list.add("version");
list.add("fixed");
list.add("reset");
return list;
} else if (args.length == 1) {
if (args.length > 1) {
if (args[0].equalsIgnoreCase("effect")) {
return PermissionManager.getParticlesUserHasPermissionFor((Player) sender);
List<String> commands = PermissionManager.getParticlesUserHasPermissionFor((Player) sender);
StringUtil.copyPartialMatches(args[1], commands, completions);
return completions;
} else if (args[0].equalsIgnoreCase("style")) {
return PermissionManager.getStylesUserHasPermissionFor((Player) sender);
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 {
List<String> commands = new ArrayList<String>(Arrays.asList(COMMANDS));
StringUtil.copyPartialMatches(args[0], commands, completions);
}
}
return null;
return completions;
}
}

View file

@ -8,10 +8,14 @@
package com.esophose.playerparticles;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -446,15 +450,6 @@ public class ParticleCommandExecutor implements CommandExecutor {
MessageManager.sendCustomMessage(p, MessageType.USAGE.getMessage() + " " + MessageType.STYLE_USAGE.getMessage());
}
/*
Requires permission playerparticles.fixed
Maximum number of fixed effects defined in config.yml, default value 5
*/
/**
* Called when a player uses /pp fixed
*
@ -478,18 +473,264 @@ public class ParticleCommandExecutor implements CommandExecutor {
String cmd = args[0];
if (cmd.equalsIgnoreCase("create")) {
if (ConfigManager.getInstance().getNumberOfFixedEffectsForPlayer(p.getUniqueId()) >= PlayerParticles.getPlugin().getConfig().getInt("max-fixed-effects")) {
String[] cmdArgs = new String[args.length - 1];
for (int i = 1; i < args.length; i++) {
cmdArgs[i - 1] = args[i];
}
args = cmdArgs;
if (cmd.equalsIgnoreCase("create")) {
if (ConfigManager.getInstance().hasPlayerReachedMaxFixedEffects(p.getUniqueId())) {
MessageManager.sendMessage(p, MessageType.MAX_FIXED_EFFECTS_REACHED);
return;
}
// /pp fixed create <x> <y> <z> <effect> <style> [data] - Creates a fixed effect and assigns it an id
if (args.length < 5) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_MISSING_ARGS, (5 - args.length) + "");
return;
}
double xPos = -1, yPos = -1, zPos = -1;
try {
if (args[0].startsWith("~")) {
if (args[0].equals("~")) xPos = p.getLocation().getX();
else xPos = p.getLocation().getX() + Double.parseDouble(args[0].substring(1));
} else {
xPos = Double.parseDouble(args[0]);
}
if (args[1].startsWith("~")) {
if (args[1].equals("~")) yPos = p.getLocation().getY() + 1;
else yPos = p.getLocation().getY() + 1 + Double.parseDouble(args[1].substring(1));
} else {
yPos = Double.parseDouble(args[1]);
}
if (args[2].startsWith("~")) {
if (args[2].equals("~")) zPos = p.getLocation().getZ();
else zPos = p.getLocation().getZ() + Double.parseDouble(args[2].substring(1));
} else {
zPos = Double.parseDouble(args[2]);
}
} catch (Exception e) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_INVALID_COORDS);
return;
}
double distanceFromEffect = p.getLocation().distance(new Location(p.getWorld(), xPos, yPos, zPos));
int maxCreationDistance = ConfigManager.getInstance().getMaxFixedEffectCreationDistance();
if (maxCreationDistance != 0 && distanceFromEffect > maxCreationDistance) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_OUT_OF_RANGE, maxCreationDistance + "");
return;
}
ParticleEffect effect = ParticleManager.particleFromString(args[3]);
if (effect == null) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_INVALID_EFFECT, args[3]);
return;
} else if (!PermissionManager.hasEffectPermission(p, effect)) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_NO_PERMISSION_EFFECT, effect.getName());
return;
}
ParticleStyle style = ParticleStyleManager.styleFromString(args[4]);
if (style == null) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_INVALID_STYLE, args[4]);
return;
} else if (!PermissionManager.hasStylePermission(p, style)) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_NO_PERMISSION_STYLE, args[4]);
return;
}
if (!style.canBeFixed()) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_NON_FIXABLE_STYLE, style.getName());
return;
}
ItemData itemData = null;
BlockData blockData = null;
OrdinaryColor colorData = null;
NoteColor noteColorData = null;
if (args.length > 5) {
if (effect.hasProperty(ParticleProperty.COLORABLE)) {
if (effect == ParticleEffect.NOTE) {
if (args[5].equalsIgnoreCase("rainbow")) {
noteColorData = new NoteColor(99);
} else {
int note = -1;
try {
note = Integer.parseInt(args[5]);
} catch (Exception e) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_DATA_ERROR, "note");
return;
}
if (note < 0 || note > 23) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_DATA_ERROR, "note");
return;
}
noteColorData = new NoteColor(note);
}
} else {
if (args[5].equalsIgnoreCase("rainbow")) {
colorData = new OrdinaryColor(999, 999, 999);
} else {
int r = -1;
int g = -1;
int b = -1;
try {
r = Integer.parseInt(args[5]);
g = Integer.parseInt(args[6]);
b = Integer.parseInt(args[7]);
} catch (Exception e) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_DATA_ERROR, "colr");
return;
}
if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_DATA_ERROR, "color");
return;
}
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) {
Material material = null;
int data = -1;
try {
material = ParticlesUtils.closestMatch(args[5]);
if (material == null) material = Material.matchMaterial(args[5]);
if (material == null) throw new Exception();
} catch (Exception e) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_DATA_ERROR, "block");
return;
}
try {
data = Integer.parseInt(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) {
Material material = null;
int data = -1;
try {
material = ParticlesUtils.closestMatch(args[5]);
if (material == null) material = Material.matchMaterial(args[5]);
if (material == null) throw new Exception();
} catch (Exception e) {
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_DATA_ERROR, "item");
return;
}
try {
data = Integer.parseInt(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);
}
}
}
FixedParticleEffect fixedEffect = new FixedParticleEffect(p.getUniqueId(), // @formatter:off
ConfigManager.getInstance().getNextFixedEffectId(p.getUniqueId()),
p.getLocation().getWorld().getName(), xPos, yPos, zPos,
effect, style, itemData, blockData, colorData, noteColorData); // @formatter:on
MessageManager.sendMessage(p, MessageType.CREATE_FIXED_SUCCESS);
ConfigManager.getInstance().saveFixedEffect(fixedEffect);
} else if (cmd.equalsIgnoreCase("remove")) {
// /pp fixed remove <id> - Removes a fixed effect by its id
if (args.length < 1) {
MessageManager.sendMessage(p, MessageType.REMOVE_FIXED_NO_ARGS);
return;
}
int id = -1;
try {
id = Integer.parseInt(args[0]);
} catch (Exception e) {
MessageManager.sendMessage(p, MessageType.REMOVE_FIXED_INVALID_ARGS);
return;
}
if (ConfigManager.getInstance().removeFixedEffect(p.getUniqueId(), id)) {
MessageManager.sendMessage(p, MessageType.REMOVE_FIXED_SUCCESS, id + "");
} else {
MessageManager.sendMessage(p, MessageType.REMOVE_FIXED_NONEXISTANT, id + "");
}
} else if (cmd.equalsIgnoreCase("list")) {
// /pp fixed list - Lists the location, and id of all fixed effects
List<Integer> ids = ConfigManager.getInstance().getFixedEffectIdsForPlayer(p.getUniqueId());
Collections.sort(ids);
if (ids.isEmpty()) {
MessageManager.sendMessage(p, MessageType.LIST_FIXED_NONE);
return;
}
String msg = MessageType.LIST_FIXED_SUCCESS.getMessage();
boolean first = true;
for (int id : ids) {
if (!first) msg += ", ";
else first = false;
msg += id;
}
MessageManager.sendCustomMessage(p, msg);
} else if (cmd.equalsIgnoreCase("info")) {
// /pp fixed info <id> - Lists all information about the fixed effect with the matching id
if (args.length < 1) {
MessageManager.sendMessage(p, MessageType.INFO_FIXED_NO_ARGS);
return;
}
int id = -1;
try {
id = Integer.parseInt(args[0]);
} catch (Exception e) {
MessageManager.sendMessage(p, MessageType.INFO_FIXED_INVALID_ARGS);
return;
}
FixedParticleEffect fixedEffect = ConfigManager.getInstance().getFixedEffectForPlayerById(p.getUniqueId(), id);
if (fixedEffect == null) {
MessageManager.sendMessage(p, MessageType.INFO_FIXED_NONEXISTANT, id + "");
return;
}
DecimalFormat df = new DecimalFormat("0.##"); // Decimal formatter so the coords aren't super long
String listMessage = MessageType.INFO_FIXED_INFO.getMessage() // @formatter:off
.replaceAll("\\{0\\}", fixedEffect.getId() + "")
.replaceAll("\\{1\\}", fixedEffect.getLocation().getWorld().getName())
.replaceAll("\\{2\\}", df.format(fixedEffect.getLocation().getX()) + "")
.replaceAll("\\{3\\}", df.format(fixedEffect.getLocation().getY()) + "")
.replaceAll("\\{4\\}", df.format(fixedEffect.getLocation().getZ()) + "")
.replaceAll("\\{5\\}", fixedEffect.getParticleEffect().getName())
.replaceAll("\\{6\\}", fixedEffect.getParticleStyle().getName())
.replaceAll("\\{7\\}", fixedEffect.getParticleDataString()); // @formatter:on
MessageManager.sendCustomMessage(p, listMessage);
} else {
MessageManager.sendMessage(p, MessageType.INVALID_FIXED_COMMAND);
MessageManager.sendMessage(p, MessageType.FIXED_COMMAND_DESC_CREATE);
@ -497,9 +738,6 @@ public class ParticleCommandExecutor implements CommandExecutor {
MessageManager.sendMessage(p, MessageType.FIXED_COMMAND_DESC_LIST);
MessageManager.sendMessage(p, MessageType.FIXED_COMMAND_DESC_INFO);
}
// Test data
//ConfigManager.getInstance().saveFixedEffect(new FixedParticleEffect(p.getUniqueId(), ConfigManager.getInstance().getNextFixedEffectId(p.getUniqueId()), p.getLocation().getWorld().getName(), p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), ParticleEffect.RED_DUST, DefaultStyles.ARROWS, null, null, new OrdinaryColor(999, 999, 999), null));
}
}

View file

@ -12,6 +12,7 @@
* Fix errors printing to console resulting from offline players trying to spawn particles
* Fix arrow style particles staying after an arrow is considered dead (in rare cases this occurred)
* Fix SQL queries getting logged to console when database-enable is set to true
* Fix tab completion, it stopped working at one point and I didn't notice until now
* Added new style 'thick'
TODO:

View file

@ -47,7 +47,7 @@ import com.esophose.playerparticles.library.ReflectionUtils.PackageType;
/**
* Modified a couple things for the plugin
*
* Updated to 1.10
* Updated to 1.11
*
* @author (of changes) Esophose
*/

View file

@ -55,6 +55,16 @@ public class ConfigManager {
*/
private List<String> disabledWorlds = null;
/**
* The max number of fixed effects a player can have, defined in the config
*/
private int maxFixedEffects = -1;
/**
* The max distance a fixed effect can be created relative to the player
*/
private int maxFixedEffectCreationDistance = -1;
/**
* @return The instance of the config for effects
*/
@ -499,12 +509,12 @@ public class ConfigManager {
*
* @param playerUUID The player who owns the effect
* @param id The id of the effect to remove
* @return If the effect was removed
*/
public void deleteFixedEffect(UUID playerUUID, int id) {
public boolean removeFixedEffect(UUID playerUUID, int id) {
if (!PlayerParticles.useMySQL) {
if (!config.isConfigurationSection(playerUUID.toString() + ".fixedEffect." + id)) {
System.out.println("Tried to remove a fixed effect with ID " + id + " that doesn't exists!");
return;
return false;
}
config.set(playerUUID.toString() + ".fixedEffect." + id, null);
@ -513,8 +523,7 @@ public class ConfigManager {
} else {
try (ResultSet res = PlayerParticles.mySQL.querySQL("SELECT uuid FROM pp_fixed WHERE player_uuid = '" + playerUUID.toString() + "' AND id = " + id)) {
if (!res.next()) {
System.out.println("Tried to remove a fixed effect with ID " + id + " doesn't exist in the database!");
return;
return false;
} else { // @formatter:off
String uuid = res.getString("uuid");
PlayerParticles.mySQL.updateSQL("DELETE FROM pp_fixed WHERE uuid = '" + uuid + "';" +
@ -526,10 +535,12 @@ public class ConfigManager {
} // @formatter:on
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
return false;
}
}
ParticleManager.removeFixedEffectForPlayer(playerUUID, id);
return true;
}
/**
@ -633,27 +644,119 @@ public class ConfigManager {
}
/**
* Gets the number of fixed effects a player has created
* Gets a fixed effect for a pplayer by its id
*
* @param pplayerUUID The player to check
* @return The number of fixed effects the player has created
* @param pplayerUUID The player who owns the effect
* @param id The id for the effect to get
* @return The effect if one exists
*/
public int getNumberOfFixedEffectsForPlayer(UUID pplayerUUID) {
public FixedParticleEffect getFixedEffectForPlayerById(UUID pplayerUUID, int id) {
if (!PlayerParticles.useMySQL) {
if (config.isConfigurationSection(pplayerUUID.toString() + ".fixedEffect")) {
return config.getConfigurationSection(pplayerUUID.toString() + ".fixedEffect").getKeys(false).size();
} else return 0;
} else {
try (ResultSet res = PlayerParticles.mySQL.querySQL("SELECT COUNT(1) FROM pp_fixed WHERE player_uuid = '" + pplayerUUID.toString() + "'")) {
if (config.isConfigurationSection(pplayerUUID.toString() + ".fixedEffect." + id)) {
ConfigurationSection section = config.getConfigurationSection(pplayerUUID + ".fixedEffect." + id);
ConfigurationSection effectSection = section.getConfigurationSection("effect");
ConfigurationSection styleSection = section.getConfigurationSection("style");
ConfigurationSection itemDataSection = section.getConfigurationSection("itemData");
ConfigurationSection blockDataSection = section.getConfigurationSection("blockData");
ConfigurationSection colorDataSection = section.getConfigurationSection("colorData");
ConfigurationSection noteColorDataSection = section.getConfigurationSection("noteColorData");
String worldName = section.getString("worldName");
double xPos = section.getDouble("xPos");
double yPos = section.getDouble("yPos");
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"));
OrdinaryColor particleColorData = new OrdinaryColor(colorDataSection.getInt("r"), colorDataSection.getInt("g"), colorDataSection.getInt("b"));
NoteColor particleNoteColorData = new NoteColor(noteColorDataSection.getInt("note"));
return new FixedParticleEffect(pplayerUUID, id, worldName, xPos, yPos, zPos, particleEffect, particleStyle, particleItemData, particleBlockData, particleColorData, particleNoteColorData);
}
} else { // @formatter:off
try (ResultSet res = PlayerParticles.mySQL.querySQL("SELECT * FROM pp_fixed f " +
"JOIN pp_data_item i ON f.uuid = i.uuid " +
"JOIN pp_data_block b ON f.uuid = b.uuid " +
"JOIN pp_data_color c ON f.uuid = c.uuid " +
"JOIN pp_data_note n ON f.uuid = n.uuid " +
"WHERE f.player_uuid = '" + pplayerUUID.toString() + "' AND f.id = '" + id + "'")) { // @formatter:on
if (res.next()) {
return res.getInt(1);
} else return 0;
String worldName = res.getString("f.worldName");
double xPos = res.getDouble("f.xPos");
double yPos = res.getDouble("f.yPos");
double zPos = res.getDouble("f.zPos");
ParticleEffect particleEffect = ParticleManager.particleFromString(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"));
OrdinaryColor particleColorData = new OrdinaryColor(res.getInt("c.r"), res.getInt("c.g"), res.getInt("c.b"));
NoteColor particleNoteColorData = new NoteColor(res.getByte("n.note"));
return new FixedParticleEffect(pplayerUUID, id, worldName, xPos, yPos, zPos, particleEffect, particleStyle, particleItemData, particleBlockData, particleColorData, particleNoteColorData);
}
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
}
return 0;
return null; // No effect was found with the id specified
}
/**
* Gets a list of all fixed effect ids for a player
*
* @param pplayerUUID The player
* @return A list of all fixed effect ids for the given player
*/
public List<Integer> getFixedEffectIdsForPlayer(UUID pplayerUUID) {
List<Integer> ids = new ArrayList<Integer>();
if (!PlayerParticles.useMySQL) {
if (config.isConfigurationSection(pplayerUUID.toString() + ".fixedEffect")) {
Set<String> keys = config.getConfigurationSection(pplayerUUID.toString() + ".fixedEffect").getKeys(false);
for (String key : keys) {
ids.add(Integer.parseInt(key));
}
}
} else {
try (ResultSet res = PlayerParticles.mySQL.querySQL("SELECT id FROM pp_fixed WHERE player_uuid = '" + pplayerUUID.toString() + "'")) {
while (res.next()) {
ids.add(res.getInt(1));
}
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
}
return ids;
}
/**
* Checks if the given player has reached the max number of fixed effects
*
* @param pplayerUUID The player to check
* @return If the player can create any more fixed effects
*/
public boolean hasPlayerReachedMaxFixedEffects(UUID pplayerUUID) {
if (maxFixedEffects == -1) { // Initialize on the fly
maxFixedEffects = PlayerParticles.getPlugin().getConfig().getInt("max-fixed-effects");
}
if (!PlayerParticles.useMySQL) {
if (config.isConfigurationSection(pplayerUUID.toString() + ".fixedEffect")) {
return config.getConfigurationSection(pplayerUUID.toString() + ".fixedEffect").getKeys(false).size() >= maxFixedEffects;
} else return false;
} else {
try (ResultSet res = PlayerParticles.mySQL.querySQL("SELECT COUNT(1) FROM pp_fixed WHERE player_uuid = '" + pplayerUUID.toString() + "'")) {
if (res.next()) {
return res.getInt(1) >= maxFixedEffects;
} else return false;
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
}
return true; // Something went wrong, pretend they reached the max
}
/**
@ -686,6 +789,18 @@ public class ConfigManager {
return -1;
}
/**
* Gets the max distance a fixed effect can be created from the player
*
* @return The max distance a fixed effect can be created from the player
*/
public int getMaxFixedEffectCreationDistance() {
if (maxFixedEffectCreationDistance == -1) {
maxFixedEffectCreationDistance = PlayerParticles.getPlugin().getConfig().getInt("max-fixed-effect-creation-distance");
}
return maxFixedEffectCreationDistance;
}
/**
* Checks if a world is disabled for particles to spawn in
*

View file

@ -51,13 +51,33 @@ public class MessageManager {
BLOCK_DATA_USAGE("message-block-data-usage"),
// Fixed Effects
NO_PERMISSION_FIXED("message-no-permission-fixed"),
MAX_FIXED_EFFECTS_REACHED("message-max-fixed-effects-reached"),
INVALID_FIXED_COMMAND("message-invalid-fixed-command"),
FIXED_COMMAND_DESC_CREATE("message-fixed-command-desc-create"),
FIXED_COMMAND_DESC_REMOVE("message-fixed-command-desc-remove"),
FIXED_COMMAND_DESC_LIST("message-fixed-command-desc-list"),
FIXED_COMMAND_DESC_INFO("message-fixed-command-desc-info"),
CREATE_FIXED_MISSING_ARGS("message-create-fixed-missing-args"),
CREATE_FIXED_INVALID_COORDS("message-create-fixed-invalid-coords"),
CREATE_FIXED_OUT_OF_RANGE("message-create-fixed-out-of-range"),
CREATE_FIXED_INVALID_EFFECT("message-create-fixed-invalid-effect"),
CREATE_FIXED_NO_PERMISSION_EFFECT("message-create-fixed-no-permission-effect"),
CREATE_FIXED_INVALID_STYLE("message-create-fixed-invalid-style"),
CREATE_FIXED_NO_PERMISSION_STYLE("message-create-fixed-no-permission-style"),
CREATE_FIXED_NON_FIXABLE_STYLE("message-create-fixed-non-fixable-style"),
CREATE_FIXED_DATA_ERROR("message-create-fixed-data-error"),
CREATE_FIXED_SUCCESS("message-create-fixed-success"),
REMOVE_FIXED_NONEXISTANT("message-remove-fixed-nonexistant"),
REMOVE_FIXED_NO_ARGS("message-remove-fixed-no-args"),
REMOVE_FIXED_INVALID_ARGS("message-remove-fixed-invalid-args"),
REMOVE_FIXED_SUCCESS("message-remove-fixed-success"),
LIST_FIXED_SUCCESS("message-list-fixed-success"),
LIST_FIXED_NONE("message-list-fixed-none"),
INFO_FIXED_NONEXISTANT("message-info-fixed-nonexistant"),
INFO_FIXED_NO_ARGS("message-info-fixed-no-args"),
INFO_FIXED_INVALID_ARGS("message-info-fixed-invalid-args"),
INFO_FIXED_INFO("message-info-fixed-info"),
NO_PERMISSION_FIXED("message-no-permission-fixed"),
MAX_FIXED_EFFECTS_REACHED("message-max-fixed-effects-reached"),
INVALID_FIXED_COMMAND("message-invalid-fixed-command"),
// Prefixes
USE("message-use"),

View file

@ -13,7 +13,6 @@ import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -193,7 +192,13 @@ public class ParticleManager extends BukkitRunnable implements Listener {
valid = false;
}
if (ConfigManager.getInstance().isWorldDisabled(player.getWorld().getName()) || player.getGameMode() == GameMode.SPECTATOR) {
// Check for the string matching to maintain support for 1.7
// This was checking GameMode.SPECTATOR before and was throwing errors
if (player.getGameMode().name().equalsIgnoreCase("spectator")) {
valid = false;
}
if (ConfigManager.getInstance().isWorldDisabled(player.getWorld().getName())) {
valid = false;
}

View file

@ -25,9 +25,9 @@ public class ParticlesUtils {
public static Material closestMatch(String input) {
ArrayList<Material> matchList = new ArrayList<Material>();
for (Material material : Material.values())
if (material.name().replace("_", " ").toLowerCase().equals(input.toLowerCase()) || String.valueOf(material.getId()).equals(input))
if (material.name().replaceAll("_", " ").toLowerCase().equals(input.toLowerCase()) || String.valueOf(material.getId()).equals(input))
return material;
else if (material.name().replace("_", " ").toLowerCase().contains(input.toLowerCase()))
else if (material.name().replaceAll("_", " ").toLowerCase().contains(input.toLowerCase()))
matchList.add(material);
if (matchList.size() == 1) return matchList.get(0);

View file

@ -7,12 +7,12 @@
# Please excuse the cheesy ASCII Art
# ====================================================#
# PlayerParticles Config #
# DO NOT DELETE OR EDIT THE FIELD "version"! #
# ====================================================#
# ==================================================== #
# PlayerParticles Config #
# Welcome to the beginning #
# ==================================================== #
# Changing this value will reset your config on the next server reload/restart.
# Changing this value will reset your config on the next server reload / restart.
# I don't recommend changing it
version: 4.3
@ -38,6 +38,13 @@ disabled-worlds: []
# Default: 5
max-fixed-effects: 5
# Max fixed effect creation distance
# Determines how far away a player may create a fixed effect from themselves
# This measurement is in blocks
# Set to 0 for infinite distance
# Default: 256
max-fixed-effect-creation-distance: 256
# ================================================================ #
# MESSAGE CONFIGURATION #
# Important Notes: #
@ -147,13 +154,13 @@ message-data-material-mismatch: '&cThe material supplied is not of type &b{TYPE}
# Note Data Usage
# You should not change the text here, only the coloring
# Default: '&b/pp data <0-23>'
message-note-data-usage: '&b/pp data <0-23>'
# Default: '&b/pp data [<0-23>]|[rainbow]'
message-note-data-usage: '&b/pp data [<0-23>]|[rainbow]'
# Color Data Usage
# You should not change the text here, only the coloring
# Default: '&b/pp data <0-255> <0-255> <0-255>'
message-color-data-usage: '&b/pp data [<0-255> <0-255> <0-255>] [rainbow]'
# Default: '&b/pp data [<0-255> <0-255> <0-255>]|[rainbow]'
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
@ -205,6 +212,105 @@ message-failed-execute-no-permission: '&cFailed to execute command for &b{TYPE}&
# Fixed Effects
# ----------------- #
# -- Create -- #
# Missing Creation Arguments
# Default: '&cUnable to create fixed effect, you are missing &b{TYPE} &crequired arguments!'
message-create-fixed-missing-args: '&cUnable to create fixed effect, you are missing &b{TYPE} &crequired arguments!'
# Invalid Coordinates
# Default: '&cUnable to create fixed effect, one or more coordinates you entered is invalid!'
message-create-fixed-invalid-coords: '&cUnable to create fixed effect, one or more coordinates you entered is invalid!'
# Coords Out Of Range
# Default: '&cUnable to create fixed effect, you must be within &b{TYPE}&c blocks of your desired location!'
message-create-fixed-out-of-range: '&cUnable to create fixed effect, you must be within &b{TYPE}&c blocks of your desired location!'
# Invalid Effect
# Default: '&cUnable to create fixed effect, an effect with the name &b{TYPE} &cdoes not exist!'
message-create-fixed-invalid-effect: '&cUnable to create fixed effect, an effect with the name &b{TYPE} &cdoes not exist!'
# No Permission Effect
# Default: '&cUnable to create fixed effect, you do not have permission to use the effect &b{TYPE}&c!'
message-create-fixed-no-permission-effect: '&cUnable to create fixed effect, you do not have permission to use the effect &b{TYPE}&c!'
# Invalid Style
# Default: '&cUnable to create fixed effect, a style with the name &b{TYPE} &cdoes not exist!'
message-create-fixed-invalid-style: '&cUnable to create fixed effect, a style with the name &b{TYPE} &cdoes not exist!'
# No Permission Style
# Default: '&cUnable to create fixed effect, you do not have permission to use the style &b{TYPE}&c!'
message-create-fixed-no-permission-style: '&cUnable to create fixed effect, you do not have permission to use the style &b{TYPE}&c!'
# Style Not Fixable
# Default: '&cThe style &b{TYPE} &cprovided can not be used in fixed effects!'
message-create-fixed-non-fixable-style: '&cThe style &b{TYPE} &ccan not be used in fixed effects!'
# Data Error
# Default: '&cUnable to create fixed effect, the data provided is not correct! This effect requires &b{TYPE}&c!'
message-create-fixed-data-error: '&cUnable to create fixed effect, the data provided is not correct! This effect requires &b{TYPE}&c data!'
# Creation Success
# Default: '&aYour fixed effect has been created!'
message-create-fixed-success: '&aYour fixed effect has been created!'
# -- Remove -- #
# Could Not Remove
# Default: '&cUnable to remove, you do not have a fixed effect with the id of &b{TYPE}&c!'
message-remove-fixed-nonexistant: '&cUnable to remove, you do not have a fixed effect with the id of &b{TYPE}&c!'
# No Args Remove
# Default: '&cYou did not specify an id to remove!'
message-remove-fixed-no-args: '&cYou did not specify an id to remove!'
# Invalid Args Remove
# Default: '&cUnable to remove, the id specified must be a number!'
message-remove-fixed-invalid-args: '&cUnable to remove, the id specified must be a number!'
# Effect Removed
# Default: '&aYour fixed effect with the id &b{TYPE}&a has been removed!'
message-remove-fixed-success: '&aYour fixed effect with the id &b{TYPE}&a has been removed!'
# -- List -- #
# List Success
# Default: '&eYou have fixed effects with these ids: &b'
message-list-fixed-success: '&eYou have fixed effects with these ids: &b'
# List None
# Default: '&eYou do not have any fixed effects!'
message-list-fixed-none: '&eYou do not have any fixed effects!'
# -- Info -- #
# Could Not Get Info
# Default: '&cUnable to get info, you do not have a fixed effect with the id of &b{TYPE}&c!'
message-info-fixed-nonexistant: '&cUnable to get info, you do not have a fixed effect with the id of &b{TYPE}&c!'
# No Args Info
# Default: '&cYou did not specify an id to display info for!'
message-info-fixed-no-args: '&cYou did not specify an id to display info for!'
# Invalid Args Info
# Default: '&cUnable to get info, the id specified must be a number!'
message-info-fixed-invalid-args: '&cUnable to get info, the id specified must be a number!'
# Fixed Effect Info
# Key:
# {0} = ID
# {1} = World Name
# {2} = World X Position
# {3} = World Y Position
# {4} = World Z Position
# {5} = Effect Name
# {6} = Style Name
# {7} = Data
# Default: '&eID: &b{0} &eWorld: &b{1} &eX: &b{2} &eY: &b{3} &eZ: &b{4} &eEffect: &b{5} &eStyle: &b{6} &eData: &b{7}'
message-info-fixed-info: '&eID: &b{0} &eWorld: &b{1} &eX: &b{2} &eY: &b{3} &eZ: &b{4} &eEffect: &b{5} &eStyle: &b{6} &eData: &b{7}'
# -- Other -- #
# No Permission Fixed
# Default: '&cYou do not have permission to use fixed effects!'
message-no-permission-fixed: '&cYou do not have permission to use fixed effects!'
@ -217,6 +323,8 @@ message-max-fixed-effects-reached: '&cYou have reached the maximum allowed fixed
# Default: '&cInvalid sub-command for &b/pp fixed&c!'
message-invalid-fixed-command: '&cInvalid subcommand for &b/pp fixed&c! &eCommands: '
# -- Command Descriptions -- #
# Fixed Command Description For Create
# Default '&e/pp fixed create <x> <y> <z> <effect> <style> [data]'
message-fixed-command-desc-create: '&e/pp fixed create <x> <y> <z> <effect> <style> [data] - Creates a new fixed effect'
@ -233,7 +341,6 @@ message-fixed-command-desc-list: '&e/pp fixed list - Lists all ids of your fixed
# Default: '&e/pp fixed info <id> - Gets info on one of your fixed effects'
message-fixed-command-desc-info: '&e/pp fixed info <id> - Gets info on one of your fixed effects'
# ------------- #
# Other #
# ------------- #