PlayerParticles v5.2 Update

Contains the remainder of updates related to PlayerParticles v5.2. See changelog.txt for details.
This commit is contained in:
Esophose 2018-09-08 02:26:21 -06:00
parent 8b4c1fcd42
commit eafd5520e1
9 changed files with 433 additions and 218 deletions

View file

@ -1,5 +1,18 @@
== UPDATING WILL DELETE YOUR CONFIG.YML ==
* Create a backup of your config.yml if you wish to import all your old settings!
=== v5.2 ===
* Added native support for Minecraft 1.13.x
* Still compatible with Minecraft 1.9 through Minecraft 1.12!
* Renamed a bunch of effects to their internal names, you will have to update your user permissions
* All saved player data on file and in the database (if enabled) will be deleted, it isn't backwards compatible with PlayerParticles v5.1 due to "the flattening"
* Permission checks are now only performed on command execution for efficiency
* Block/Item data in the GUI are now randomized
* Removed the 'data' tag from block/item data, it was removed in 1.13
* Added full tab-completion support
* Added all new 1.13 particle effects
* Alphabatized effects and styles in their respective info lists
* Fixed /pp data throwing an internal error on rare occasions
* Removed excessive console logging when database-enable is set to true
=== v5.1 ===
* Fix bug preventing the use of /pp effect, style, data, and reset from being used before a player has opened the GUI
* Empty messages in config.yml will no longer display an error to the player, they won't be printed out at all

111
pom.xml
View file

@ -31,6 +31,7 @@
<version>3.1.0</version>
<executions>
<execution>
<id>1.13</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
@ -53,7 +54,115 @@
</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 Dev Servers\1.13\plugins\update\PlayerParticles v5.2.jar</outputFile>
</configuration>
</execution>
<execution>
<id>1.12</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.12\plugins\update\PlayerParticles v5.2.jar</outputFile>
</configuration>
</execution>
<execution>
<id>1.11</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.11\plugins\update\PlayerParticles v5.2.jar</outputFile>
</configuration>
</execution>
<execution>
<id>1.10</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.10\plugins\update\PlayerParticles v5.2.jar</outputFile>
</configuration>
</execution>
<execution>
<id>1.9</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:slf4j-api</include>
<include>org.slf4j:slf4j-nop</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<outputFile>C:\Users\Esophose\Desktop\Spigot Dev Servers\1.9\plugins\update\PlayerParticles v5.2.jar</outputFile>
</configuration>
</execution>
</executions>

View file

@ -65,7 +65,7 @@ public class ParticleCommandCompleter implements TabCompleter {
}
} else if (args[0].equalsIgnoreCase("data")) {
PPlayer pplayer = PPlayerDataManager.getInstance().getPPlayer(((Player) sender).getUniqueId());
if (pplayer == null && args.length == 2) {
if (pplayer == null) {
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) {

View file

@ -76,10 +76,37 @@ public class PlayerParticles extends JavaPlugin {
Bukkit.getPluginManager().registerEvents(new PlayerParticlesGui(), this);
double configVersion = getConfig().getDouble("version");
if (configVersion < Double.parseDouble(getDescription().getVersion())) {
// Make sure database information gets carried over between config updates
boolean databaseEnable = false;
String databaseHostname = "";
int databasePort = 3306;
String databaseName = "";
String databaseUserName = "";
String databaseUserPassword = "";
File configFile = new File(getDataFolder(), "config.yml");
if (configFile.exists()) configFile.delete();
if (configFile.exists()) {
databaseEnable = getConfig().getBoolean("database-enable");
databaseHostname = getConfig().getString("database-hostname");
databasePort = getConfig().getInt("database-port");
databaseName = getConfig().getString("database-name");
databaseUserName = getConfig().getString("database-user-name");
databaseUserPassword = getConfig().getString("database-user-password");
if (databaseEnable) { // @formatter:off
getLogger().warning("== WARNING == The PlayerParticles database configuration was detected as database-enable=true. " +
"The database configuration has been loaded this time for critical schema updates, but has also been DELETED from the config.yml! " +
"This needs to be replaced or else the plugin wont connect to the database on its next load!"); // @formatter:on
}
configFile.delete();
}
saveDefaultConfig();
reloadConfig();
getConfig().set("database-enable", databaseEnable);
getConfig().set("database-hostname", databaseHostname);
getConfig().set("database-port", databasePort);
getConfig().set("database-name", databaseName);
getConfig().set("database-user-name", databaseUserName);
getConfig().set("database-user-password", databaseUserPassword);
getLogger().warning("The config.yml has been updated to v" + getDescription().getVersion() + "!");
}
@ -167,7 +194,6 @@ public class PlayerParticles extends JavaPlugin {
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());

View file

@ -18,18 +18,38 @@ public class ColorData {
this.name = name;
}
/**
* Get the DyeColor
*
* @return The DyeColor
*/
public DyeColor getDyeColor() {
return this.dyeColor;
}
/**
* Get the Material representing this color
*
* @return The Material
*/
public Material getMaterial() {
return this.material;
}
/**
* Get the OrdinaryColor representing this color
*
* @return The OrdinaryColor
*/
public OrdinaryColor getOrdinaryColor() {
return this.ordinaryColor;
}
/**
* Get the name of this color
*
* @return The name of this color
*/
public String getName() {
return this.name;
}

View file

@ -13,6 +13,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import org.bukkit.Bukkit;
@ -20,6 +21,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.SkullType;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.enchantments.Enchantment;
@ -95,10 +97,11 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
private static int rainbowColorsIndex = 0;
/**
* 28 of each block/item Materials for block/item data
* Cached material data
*/
private static Material[] blockMaterials;
private static Material[] itemMaterials;
private static final Random RANDOM = new Random();
private static List<Material> BLOCK_MATERIALS = new ArrayList<Material>();
private static List<Material> ITEM_MATERIALS = new ArrayList<Material>();
static { // @formatter:off
colorMapping = new ColorData[] {
@ -116,7 +119,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
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.getByDyeData((byte)7), 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"),
};
@ -130,68 +133,20 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
DyeColor.PURPLE
};
// All materials contain their > 1.13 name, followed by their legacy name, if applicable
blockMaterials = new Material[] {
ParticleUtils.closestMatchWithFallback("STONE"),
ParticleUtils.closestMatchWithFallback("GRASS"),
ParticleUtils.closestMatchWithFallback("TNT"),
ParticleUtils.closestMatchWithFallback("COBBLESTONE"),
ParticleUtils.closestMatchWithFallback("OAK_WOOD", "WOOD"),
ParticleUtils.closestMatchWithFallback("BEDROCK"),
ParticleUtils.closestMatchWithFallback("SAND"),
ParticleUtils.closestMatchWithFallback("OAK_LOG", "LOG"),
ParticleUtils.closestMatchWithFallback("SPONGE"),
ParticleUtils.closestMatchWithFallback("GLASS"),
ParticleUtils.closestMatchWithFallback("WHITE_WOOL", "WOOL"),
ParticleUtils.closestMatchWithFallback("IRON_BLOCK"),
ParticleUtils.closestMatchWithFallback("GOLD_BLOCK"),
ParticleUtils.closestMatchWithFallback("DIAMOND_BLOCK"),
ParticleUtils.closestMatchWithFallback("EMERALD_BLOCK"),
ParticleUtils.closestMatchWithFallback("COAL_BLOCK"),
ParticleUtils.closestMatchWithFallback("REDSTONE_BLOCK"),
ParticleUtils.closestMatchWithFallback("BOOKSHELF"),
ParticleUtils.closestMatchWithFallback("ICE"),
ParticleUtils.closestMatchWithFallback("CLAY"),
ParticleUtils.closestMatchWithFallback("PUMPKIN"),
ParticleUtils.closestMatchWithFallback("MELON", "MELON_BLOCK"),
ParticleUtils.closestMatchWithFallback("NETHERRACK"),
ParticleUtils.closestMatchWithFallback("SOUL_SAND"),
ParticleUtils.closestMatchWithFallback("GLOWSTONE"),
ParticleUtils.closestMatchWithFallback("NETHER_BRICKS"),
ParticleUtils.closestMatchWithFallback("END_STONE", "ENDER_STONE"),
ParticleUtils.closestMatchWithFallback("PRISMARINE")
};
itemMaterials = new Material[] {
ParticleUtils.closestMatchWithFallback("COAL"),
ParticleUtils.closestMatchWithFallback("IRON_INGOT"),
ParticleUtils.closestMatchWithFallback("GOLD_INGOT"),
ParticleUtils.closestMatchWithFallback("REDSTONE"),
ParticleUtils.closestMatchWithFallback("EMERALD"),
ParticleUtils.closestMatchWithFallback("QUARTZ"),
ParticleUtils.closestMatchWithFallback("BRICK", "CLAY_BRICK"),
ParticleUtils.closestMatchWithFallback("GLOWSTONE_DUST"),
ParticleUtils.closestMatchWithFallback("SUGAR_CANE"),
ParticleUtils.closestMatchWithFallback("FLINT"),
ParticleUtils.closestMatchWithFallback("POTATO", "POTATO_ITEM"),
ParticleUtils.closestMatchWithFallback("CARROT", "CARROT_ITEM"),
ParticleUtils.closestMatchWithFallback("SNOWBALL", "SNOW_BALL"),
ParticleUtils.closestMatchWithFallback("BONE"),
ParticleUtils.closestMatchWithFallback("ENDER_PEARL"),
ParticleUtils.closestMatchWithFallback("BLAZE_POWDER"),
ParticleUtils.closestMatchWithFallback("NETHER_WART", "NETHER_STALK"),
ParticleUtils.closestMatchWithFallback("FIRE_CHARGE", "FIREBALL"),
ParticleUtils.closestMatchWithFallback("CHORUS_FRUIT"),
ParticleUtils.closestMatchWithFallback("PRISMARINE_CRYSTALS"),
ParticleUtils.closestMatchWithFallback("GUNPOWDER", "SULPHUR"),
ParticleUtils.closestMatchWithFallback("APPLE"),
ParticleUtils.closestMatchWithFallback("MELON"),
ParticleUtils.closestMatchWithFallback("COOKIE"),
ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"),
ParticleUtils.closestMatchWithFallback("COMPASS"),
ParticleUtils.closestMatchWithFallback("CLOCK", "WATCH"),
ParticleUtils.closestMatchWithFallback("NAME_TAG")
};
Inventory testingInventory = Bukkit.createInventory(null, 9);
for (Material mat : Material.values()) {
// Verify an ItemStack of the material can be placed into an inventory. In 1.12 and up this can easily be checked with mat.isItem(), but that doesn't exist pre 1.12
testingInventory.clear();
testingInventory.setItem(0, new ItemStack(mat, 1));
ItemStack itemStack = testingInventory.getItem(0);
if (itemStack != null) {
if (mat.isBlock()) {
BLOCK_MATERIALS.add(mat);
} else if (!mat.isBlock()) {
ITEM_MATERIALS.add(mat);
}
}
}
} // @formatter:on
/**
@ -207,23 +162,28 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
effectIcons = new HashMap<String, Material>();
styleIcons = new HashMap<String, Material>();
defaultMenuIcons[0] = ParticleUtils.closestMatch(config.getString("gui-icon.main-menu.EFFECT"));
defaultMenuIcons[1] = ParticleUtils.closestMatch(config.getString("gui-icon.main-menu.STYLE"));
defaultMenuIcons[2] = ParticleUtils.closestMatch(config.getString("gui-icon.main-menu.DATA"));
for (int i = 0; i < defaultMenuIcons.length; i++)
if (defaultMenuIcons[i] == null) defaultMenuIcons[i] = Material.BARRIER;
defaultMenuIcons[0] = ParticleUtils.closestMatchWithFallback(config.getString("gui-icon.main-menu.EFFECT"));
defaultMenuIcons[1] = ParticleUtils.closestMatchWithFallback(config.getString("gui-icon.main-menu.STYLE"));
defaultMenuIcons[2] = ParticleUtils.closestMatchWithFallback(config.getString("gui-icon.main-menu.DATA"));
// Grab a different effect icon set based on if the Minecraft version is >= 1.13 or not
String legacy;
try {
Particle.valueOf("NAUTILUS");
legacy = "";
} catch (Exception ex) {
legacy = "-legacy";
}
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.
String effectName = effect.getName().toUpperCase();
Material iconMaterial = ParticleUtils.closestMatchWithFallback(config.getString("gui-icon.effect" + legacy + "." + effectName));
effectIcons.put(effectName, iconMaterial);
}
for (ParticleStyle style : ParticleStyleManager.getStyles()) {
String styleName = style.getName().toUpperCase();
Material iconMaterial = ParticleUtils.closestMatch(config.getString("gui-icon.style." + styleName));
if (iconMaterial == null) iconMaterial = Material.BARRIER; // Missing icon or invalid? Replace it with a barrier instead to fail safety.
Material iconMaterial = ParticleUtils.closestMatchWithFallback(config.getString("gui-icon.style" + legacy + "." + styleName));
styleIcons.put(styleName, iconMaterial);
}
@ -373,6 +333,7 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
currentIconLore[2] = ChatColor.YELLOW + "Active Data: " + ChatColor.AQUA + p.getParticleDataString();
currentIconMeta.setLore(Arrays.asList(currentIconLore));
currentIconMeta.setOwner(player.getName());
//currentIconMeta.setOwningPlayer(Bukkit.getOfflinePlayer(player.getUniqueId())); // This doesn't exist in 1.9
currentIcon.setItemMeta(currentIconMeta);
ItemStack effectIcon = new ItemStack(defaultMenuIcons[0], 1);
@ -510,43 +471,58 @@ public class PlayerParticlesGui extends BukkitRunnable implements Listener {
inventory.setItem(40, getItemForRainbowColorData(p.getColorData(), rainbowColors[rainbowColorsIndex]));
}
} else if (pe.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
List<Material> materialBag = new ArrayList<Material>();
int materialIndex = 0;
if (pe == ParticleEffect.ITEM) { // Item data
Material currentItemMaterial = p.getItemData().getMaterial();
int itemMaterialIndex = 0;
while (materialBag.size() < 28) { // Grab 28 random materials that are an item
Material randomMaterial = ITEM_MATERIALS.get(RANDOM.nextInt(ITEM_MATERIALS.size()));
if (!materialBag.contains(randomMaterial))
materialBag.add(randomMaterial);
}
for (int i = 10; i <= 16; i++) { // Top row
inventory.setItem(i, getItemForMaterialData(currentItemMaterial, "item", itemMaterials[itemMaterialIndex]));
itemMaterialIndex++;
inventory.setItem(i, getItemForMaterialData(currentItemMaterial, "item", materialBag.get(materialIndex)));
materialIndex++;
}
for (int i = 19; i <= 25; i++) { // Middle 1 row
inventory.setItem(i, getItemForMaterialData(currentItemMaterial, "item", itemMaterials[itemMaterialIndex]));
itemMaterialIndex++;
inventory.setItem(i, getItemForMaterialData(currentItemMaterial, "item", materialBag.get(materialIndex)));
materialIndex++;
}
for (int i = 28; i <= 34; i++) { // Middle 2 row
inventory.setItem(i, getItemForMaterialData(currentItemMaterial, "item", itemMaterials[itemMaterialIndex]));
itemMaterialIndex++;
inventory.setItem(i, getItemForMaterialData(currentItemMaterial, "item", materialBag.get(materialIndex)));
materialIndex++;
}
for (int i = 37; i <= 43; i++) { // Bottom row
inventory.setItem(i, getItemForMaterialData(currentItemMaterial, "item", itemMaterials[itemMaterialIndex]));
itemMaterialIndex++;
inventory.setItem(i, getItemForMaterialData(currentItemMaterial, "item", materialBag.get(materialIndex)));
materialIndex++;
}
} else { // Block data
Material currentBlockMaterial = p.getBlockData().getMaterial();
int blockMaterialIndex = 0;
while (materialBag.size() < 28) { // Grab 28 random materials that are an item
Material randomMaterial = BLOCK_MATERIALS.get(RANDOM.nextInt(BLOCK_MATERIALS.size()));
if (!materialBag.contains(randomMaterial))
materialBag.add(randomMaterial);
}
for (int i = 10; i <= 16; i++) { // Top row
inventory.setItem(i, getItemForMaterialData(currentBlockMaterial, "block", blockMaterials[blockMaterialIndex]));
blockMaterialIndex++;
inventory.setItem(i, getItemForMaterialData(currentBlockMaterial, "block", materialBag.get(materialIndex)));
materialIndex++;
}
for (int i = 19; i <= 25; i++) { // Middle 1 row
inventory.setItem(i, getItemForMaterialData(currentBlockMaterial, "block", blockMaterials[blockMaterialIndex]));
blockMaterialIndex++;
inventory.setItem(i, getItemForMaterialData(currentBlockMaterial, "block", materialBag.get(materialIndex)));
materialIndex++;
}
for (int i = 28; i <= 34; i++) { // Middle 2 row
inventory.setItem(i, getItemForMaterialData(currentBlockMaterial, "block", blockMaterials[blockMaterialIndex]));
blockMaterialIndex++;
inventory.setItem(i, getItemForMaterialData(currentBlockMaterial, "block", materialBag.get(materialIndex)));
materialIndex++;
}
for (int i = 37; i <= 43; i++) { // Bottom row
inventory.setItem(i, getItemForMaterialData(currentBlockMaterial, "block", blockMaterials[blockMaterialIndex]));
blockMaterialIndex++;
inventory.setItem(i, getItemForMaterialData(currentBlockMaterial, "block", materialBag.get(materialIndex)));
materialIndex++;
}
}
}

View file

@ -39,7 +39,7 @@ public enum ParticleEffect {
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_COLUMN_UP("BUBBLE_COLUMN_UP", null),
BUBBLE_POP("BUBBLE_POP", null),
CLOUD("CLOUD", "CLOUD"),
CRIT("CRIT", "CRIT"),
@ -56,6 +56,7 @@ public enum ParticleEffect {
END_ROD("END_ROD", "END_ROD"),
ENTITY_EFFECT("SPELL_MOB", "SPELL_MOB", ParticleProperty.COLORABLE),
EXPLOSION("EXPLOSION_LARGE", "EXPLOSION_LARGE"),
EXPLOSION_EMITTER("EXPLOSION_HUGE", "EXPLOSION_HUGE"),
FALLING_DUST("FALLING_DUST", "FALLING_DUST", ParticleProperty.REQUIRES_MATERIAL_DATA),
FIREWORK("FIREWORKS_SPARK", "FIREWORKS_SPARK"),
FISHING("WATER_WAKE", "WATER_WAKE"),
@ -63,7 +64,6 @@ public enum ParticleEffect {
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"),
@ -90,12 +90,13 @@ public enum ParticleEffect {
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 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 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
// Initialize Minecraft 1.13 related variables
static {
for (ParticleEffect effect : values()) {
NAME_MAP.put(effect.getName(), effect);
@ -103,10 +104,11 @@ public enum ParticleEffect {
try {
VERSION_13 = Particle.valueOf("NAUTILUS") != null;
DUSTOPTIONS_CONSTRUCTOR = Particle.REDSTONE.getDataType().getConstructor(Color.class, float.class);
CREATEBLOCKDATA_METHOD = Material.class.getMethod("createBlockData");
DustOptions_CONSTRUCTOR = Particle.REDSTONE.getDataType().getConstructor(Color.class, float.class);
createBlockData_METHOD = Material.class.getMethod("createBlockData");
} catch (Exception e) {
DUSTOPTIONS_CONSTRUCTOR = null;
DustOptions_CONSTRUCTOR = null;
createBlockData_METHOD = null;
VERSION_13 = false;
}
}
@ -259,7 +261,7 @@ public enum ParticleEffect {
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!
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)) {
@ -297,7 +299,7 @@ public enum ParticleEffect {
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());
extraData = createBlockData_METHOD.invoke(data.getMaterial());
} catch (Exception e) { }
} else if (internalEnum.getDataType() == ItemStack.class) {
extraData = new ItemStack(data.getMaterial());
@ -350,8 +352,7 @@ public enum ParticleEffect {
/**
* Represents the particle data for effects like
* {@link ParticleEffect#ITEM}, {@link ParticleEffect#BLOCK_CRACK},
* {@link ParticleEffect#BLOCK_DUST}, and {@link ParticleEffect#FALLING_DUST}
* {@link ParticleEffect#ITEM}, {@link ParticleEffect#BLOCK}, and {@link ParticleEffect#FALLING_DUST}
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the
* same usage conditions
@ -382,7 +383,7 @@ public enum ParticleEffect {
}
/**
* Represents the item data for the {@link ParticleEffect#ITEM_CRACK} effect
* Represents the item data for the {@link ParticleEffect#ITEM} effect
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the
* same usage conditions
@ -402,8 +403,8 @@ public enum ParticleEffect {
}
/**
* Represents the block data for the {@link ParticleEffect#BLOCK_CRACK} and
* {@link ParticleEffect#BLOCK_DUST} effects
* Represents the block data for the {@link ParticleEffect#BLOCK} and
* {@link ParticleEffect#FALLING_DUST} effects
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the
* same usage conditions
@ -416,7 +417,6 @@ public enum ParticleEffect {
* Construct a new block data
*
* @param material Material of the block
* @param data Data value of the block
* @throws IllegalArgumentException If the material is not a block
*/
public BlockData(Material material) throws IllegalArgumentException {
@ -428,8 +428,8 @@ public enum ParticleEffect {
}
/**
* Represents the color for effects like {@link ParticleEffect#MOB_SPELL},
* {@link ParticleEffect#MOB_SPELL_AMBIENT}, {@link ParticleEffect#RED_DUST}
* Represents the color for effects like {@link ParticleEffect#ENTITY_EFFECT},
* {@link ParticleEffect#AMBIENT_ENTITY_EFFECT}, {@link ParticleEffect#DUST}
* and {@link ParticleEffect#NOTE}
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the
@ -462,8 +462,8 @@ public enum ParticleEffect {
}
/**
* Represents the color for effects like {@link ParticleEffect#MOB_SPELL},
* {@link ParticleEffect#MOB_SPELL_AMBIENT} and {@link ParticleEffect#NOTE}
* Represents the color for effects like {@link ParticleEffect#ENTITY_EFFECT},
* {@link ParticleEffect#AMBIENT_ENTITY_EFFECT} and {@link ParticleEffect#NOTE}
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the
* same usage conditions

View file

@ -14,61 +14,62 @@ public class DefaultStyles {
/**
* All the styles that are available by default from this plugin
*/
public static final ParticleStyle NONE = new ParticleStyleNone();
public static final ParticleStyle BEAM = new ParticleStyleBeam();
public static final ParticleStyle HALO = new ParticleStyleHalo();
public static final ParticleStyle POINT = new ParticleStylePoint();
public static final ParticleStyle MOVE = new ParticleStyleMove();
public static final ParticleStyle SPIN = new ParticleStyleSpin();
public static final ParticleStyle QUADHELIX = new ParticleStyleQuadhelix();
public static final ParticleStyle ORBIT = new ParticleStyleOrbit();
public static final ParticleStyle FEET = new ParticleStyleFeet();
public static final ParticleStyle CUBE = new ParticleStyleCube();
public static final ParticleStyle ARROWS = new ParticleStyleArrows();
public static final ParticleStyle SPIRAL = new ParticleStyleSpiral();
public static final ParticleStyle THICK = new ParticleStyleThick();
public static final ParticleStyle WINGS = new ParticleStyleWings();
public static final ParticleStyle SPHERE = new ParticleStyleSphere();
public static final ParticleStyle SWORDS = new ParticleStyleSwords();
public static final ParticleStyle HURT = new ParticleStyleHurt();
public static final ParticleStyle BLOCKPLACE = new ParticleStyleBlockPlace();
public static final ParticleStyle BEAM = new ParticleStyleBeam();
public static final ParticleStyle BLOCKBREAK = new ParticleStyleBlockBreak();
public static final ParticleStyle BLOCKEDIT = new ParticleStyleBlockEdit();
public static final ParticleStyle BLOCKPLACE = new ParticleStyleBlockPlace();
public static final ParticleStyle CUBE = new ParticleStyleCube();
public static final ParticleStyle FEET = new ParticleStyleFeet();
public static final ParticleStyle HALO = new ParticleStyleHalo();
public static final ParticleStyle HURT = new ParticleStyleHurt();
public static final ParticleStyle MOVE = new ParticleStyleMove();
public static final ParticleStyle NONE = new ParticleStyleNone();
public static final ParticleStyle ORBIT = new ParticleStyleOrbit();
public static final ParticleStyle POINT = new ParticleStylePoint();
public static final ParticleStyle QUADHELIX = new ParticleStyleQuadhelix();
public static final ParticleStyle SPHERE = new ParticleStyleSphere();
public static final ParticleStyle SPIN = new ParticleStyleSpin();
public static final ParticleStyle SPIRAL = new ParticleStyleSpiral();
public static final ParticleStyle SWORDS = new ParticleStyleSwords();
public static final ParticleStyle THICK = new ParticleStyleThick();
public static final ParticleStyle WINGS = new ParticleStyleWings();
/**
* Registers all the default styles to the ParticleStyleManager
* Registered in alphabetical order
*/
public static void registerStyles() {
ParticleStyleManager.registerStyle(NONE);
ParticleStyleManager.registerStyle(BEAM);
ParticleStyleManager.registerStyle(HALO);
ParticleStyleManager.registerStyle(POINT);
ParticleStyleManager.registerCustomHandledStyle(MOVE);
ParticleStyleManager.registerStyle(SPIN);
ParticleStyleManager.registerStyle(QUADHELIX);
ParticleStyleManager.registerStyle(ORBIT);
ParticleStyleManager.registerStyle(FEET);
ParticleStyleManager.registerStyle(CUBE);
ParticleStyleManager.registerStyle(ARROWS);
ParticleStyleManager.registerStyle(SPIRAL);
ParticleStyleManager.registerStyle(THICK);
ParticleStyleManager.registerStyle(WINGS);
ParticleStyleManager.registerStyle(SPHERE);
ParticleStyleManager.registerCustomHandledStyle(SWORDS);
ParticleStyleManager.registerCustomHandledStyle(HURT);
ParticleStyleManager.registerCustomHandledStyle(BLOCKPLACE);
ParticleStyleManager.registerStyle(BEAM);
ParticleStyleManager.registerCustomHandledStyle(BLOCKBREAK);
ParticleStyleManager.registerCustomHandledStyle(BLOCKEDIT);
ParticleStyleManager.registerCustomHandledStyle(BLOCKPLACE);
ParticleStyleManager.registerStyle(CUBE);
ParticleStyleManager.registerStyle(FEET);
ParticleStyleManager.registerStyle(HALO);
ParticleStyleManager.registerCustomHandledStyle(HURT);
ParticleStyleManager.registerCustomHandledStyle(MOVE);
ParticleStyleManager.registerStyle(NONE);
ParticleStyleManager.registerStyle(ORBIT);
ParticleStyleManager.registerStyle(POINT);
ParticleStyleManager.registerStyle(QUADHELIX);
ParticleStyleManager.registerStyle(SPHERE);
ParticleStyleManager.registerStyle(SPIN);
ParticleStyleManager.registerStyle(SPIRAL);
ParticleStyleManager.registerCustomHandledStyle(SWORDS);
ParticleStyleManager.registerStyle(THICK);
ParticleStyleManager.registerStyle(WINGS);
PluginManager manager = Bukkit.getPluginManager();
Plugin playerParticles = PlayerParticles.getPlugin();
manager.registerEvents((Listener) MOVE, playerParticles);
manager.registerEvents((Listener) ARROWS, playerParticles);
manager.registerEvents((Listener) SWORDS, playerParticles);
manager.registerEvents((Listener) HURT, playerParticles);
manager.registerEvents((Listener) BLOCKPLACE, playerParticles);
manager.registerEvents((Listener) BLOCKBREAK, playerParticles);
manager.registerEvents((Listener) BLOCKPLACE, playerParticles);
manager.registerEvents((Listener) BLOCKEDIT, playerParticles);
manager.registerEvents((Listener) HURT, playerParticles);
manager.registerEvents((Listener) MOVE, playerParticles);
manager.registerEvents((Listener) SWORDS, playerParticles);
}
}

View file

@ -488,75 +488,145 @@ gui-icon:
EFFECT: BLAZE_POWDER
STYLE: NETHER_STAR
DATA: BOOK
effect:
NONE: THIN_GLASS
EXPLODE: SULPHUR
LARGE_EXPLODE: FIREBALL
HUGE_EXPLOSION: TNT
FIREWORKS_SPARK: FIREWORK
BUBBLE: GLASS
WAKE: BOAT
SUSPENDED: WATER_LILY
DEPTH_SUSPEND: BEDROCK
CRIT: IRON_SWORD
MAGIC_CRIT: NETHER_STALK
SMOKE: TORCH
LARGE_SMOKE: WEB
SPELL: GLASS_BOTTLE
INSTANT_SPELL: POTION
MOB_SPELL: GLOWSTONE_DUST
MOB_SPELL_AMBIENT: BEACON
WITCH_MAGIC: CAULDRON_ITEM
DRIP_WATER: WATER_BUCKET
DRIP_LAVA: LAVA_BUCKET
effect: # 1.13 and up
AMBIENT_ENTITY_EFFECT: BEACON
ANGRY_VILLAGER: IRON_DOOR
HAPPY_VILLAGER: WOOD_DOOR
NOTE: NOTE_BLOCK
PORTAL: OBSIDIAN
ENCHANTMENT_TABLE: ENCHANTMENT_TABLE
FLAME: BLAZE_POWDER
LAVA: MAGMA_CREAM
FOOTSTEP: GRASS
CLOUD: WOOL
RED_DUST: REDSTONE
SNOWBALL_POOF: SNOW_BALL
SNOW_SHOVEL: SNOW
SLIME: SLIME_BALL
HEART: RED_ROSE
BARRIER: BARRIER
ITEM_CRACK: STICK
BLOCK_CRACK: DEAD_BUSH
BLOCK_DUST: SOUL_SAND
DROPLET: LAPIS_ORE
DRAGON_BREATH: DRAGONS_BREATH
END_ROD: END_ROD
BLOCK: STONE
BUBBLE: BUBBLE_CORAL
BUBBLE_COLUMN_UP: MAGMA_BLOCK
BUBBLE_POP: BUBBLE_CORAL_FAN
CLOUD: WHITE_WOOL
CRIT: IRON_SWORD
CURRENT_DOWN: SOUL_SAND
DAMAGE_INDICATOR: BOW
SWEEP_ATTACK: GOLD_SWORD
DOLPHIN: DOLPHIN_SPAWN_EGG
DRAGON_BREATH: DRAGON_BREATH
DRIPPING_LAVA: LAVA_BUCKET
DRIPPING_WATER: WATER_BUCKET
DUST: REDSTONE
ENCHANT: ENCHANTING_TABLE
ENCHANTED_HIT: DIAMOND_SWORD
END_ROD: END_ROD
ENTITY_EFFECT: GLOWSTONE_DUST
EXPLOSION: FIRE_CHARGE
EXPLOSION_EMITTER: TNT
FALLING_DUST: SAND
TOTEM: TOTEM
SPIT: PUMPKIN_SEEDS
style:
FIREWORK: FIREWORK_ROCKET
FISHING: FISHING_ROD
FLAME: BLAZE_POWDER
HAPPY_VILLAGER: DARK_OAK_DOOR
HEART: POPPY
INSTANT_EFFECT: SPLASH_POTION
ITEM: ITEM_FRAME
ITEM_SLIME: SLIME_BALL
ITEM_SNOWBALL: SNOWBALL
LARGE_SMOKE: COBWEB
LAVA: MAGMA_CREAM
MYCELIUM: MYCELIUM
NAUTILUS: HEART_OF_THE_SEA
NONE: GLASS_PANE
NOTE: NOTE_BLOCK
POOF: FIREWORK_STAR
PORTAL: OBSIDIAN
RAIN: PUFFERFISH_BUCKET
SMOKE: TORCH
SPELL: POTION
SPIT: LLAMA_SPAWN_EGG
SPLASH: SALMON
SQUID_INK: INK_SAC
SWEEP_ATTACK: GOLDEN_SWORD
TOTEM_OF_UNDYING: TOTEM
UNDERWATER: TURTLE_HELMET
WITCH: CAULDRON
effect-legacy: # 1.9 to 1.12
AMBIENT_ENTITY_EFFECT: BEACON
ANGRY_VILLAGER: IRON_DOOR
BARRIER: BARRIER
BLOCK: STONE
BUBBLE: GLASS
CLOUD: WOOL
CRIT: IRON_SWORD
DAMAGE_INDICATOR: BOW
DRAGON_BREATH: DRAGONS_BREATH
DRIPPING_LAVA: LAVA_BUCKET
DRIPPING_WATER: WATER_BUCKET
DUST: REDSTONE
ENCHANT: ENCHANTMENT_TABLE
ENCHANTED_HIT: DIAMOND_SWORD
END_ROD: END_ROD
ENTITY_EFFECT: GLOWSTONE_DUST
EXPLOSION: FIREBALL
EXPLOSION_EMITTER: TNT
FALLING_DUST: SAND
FIREWORK: FIREWORK
FISHING: FISHING_ROD
FLAME: BLAZE_POWDER
FOOTSTEP: GRASS
HAPPY_VILLAGER: WOOD_DOOR
HEART: RED_ROSE
INSTANT_EFFECT: POTION
ITEM: ITEM_FRAME
ITEM_SLIME: SLIME_BALL
ITEM_SNOWBALL: SNOWBALL
LARGE_SMOKE: WEB
LAVA: MAGMA_CREAM
MYCELIUM: MYCEL
NONE: THIN_GLASS
BEAM: POWERED_RAIL
HALO: ENDER_PORTAL_FRAME
POINT: STONE_BUTTON
MOVE: PISTON_BASE
SPIN: BEACON
QUADHELIX: ACTIVATOR_RAIL
ORBIT: ENCHANTMENT_TABLE
FEET: GRASS
CUBE: STONE
NOTE: NOTE_BLOCK
POOF: FIREWORK_CHARGE
PORTAL: OBSIDIAN
RAIN: LAPIS_BLOCK
SMOKE: TORCH
SPELL: GLASS_BOTTLE
SPIT: PUMPKIN_SEEDS
SPLASH: FISH
SWEEP_ATTACK: GOLD_SWORD
TOTEM_OF_UNDYING: TOTEM
UNDERWATER: BOAT
WITCH: CAULDRON
style: # 1.13 and up
ARROWS: BOW
SPIRAL: HOPPER
THICK: VINE
WINGS: ELYTRA
SPHERE: SNOW_BALL
SWORDS: IRON_SWORD
HURT: CACTUS
BLOCKPLACE: WOOD
BEAM: POWERED_RAIL
BLOCKBREAK: IRON_PICKAXE
BLOCKEDIT: DISPENSER
BLOCKPLACE: OAK_PLANKS
CUBE: STONE
FEET: GRASS
HALO: ENDER_PORTAL_FRAME
HURT: CACTUS
MOVE: PISTON
NONE: GLASS_PANE
ORBIT: ENCHANTING_TABLE
POINT: STONE_BUTTON
QUADHELIX: NAUTILUS_SHELL
SPHERE: HEART_OF_THE_SEA
SPIN: BEACON
SPIRAL: HOPPER
SWORDS: IRON_SWORD
THICK: COBWEB
WINGS: ELYTRA
style-legacy: # 1.9 to 1.12
ARROWS: BOW
BEAM: POWERED_RAIL
BLOCKBREAK: IRON_PICKAXE
BLOCKEDIT: DISPENSER
BLOCKPLACE: WOOD
CUBE: STONE
FEET: GRASS
HALO: ENDER_PORTAL_FRAME
HURT: CACTUS
MOVE: PISTON_BASE
NONE: THIN_GLASS
ORBIT: ENCHANTMENT_TABLE
POINT: STONE_BUTTON
QUADHELIX: ACTIVATOR_RAIL
SPHERE: SNOW_BALL
SPIN: BEACON
SPIRAL: HOPPER
SWORDS: IRON_SWORD
THICK: VINE
WINGS: ELYTRA
# That's everything! You reached the end of the configuration.
# Enjoy the plugin!