diff --git a/Particles/Wrapper/build.gradle b/Particles/Wrapper/build.gradle new file mode 100644 index 0000000..f83674e --- /dev/null +++ b/Particles/Wrapper/build.gradle @@ -0,0 +1,3 @@ +dependencies { + shadow 'org.spigotmc:spigot:1.15.2-R0.1-SNAPSHOT' +} diff --git a/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/nms/wrapper/ParticleHandler.java b/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/nms/wrapper/ParticleHandler.java new file mode 100644 index 0000000..8632c91 --- /dev/null +++ b/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/nms/wrapper/ParticleHandler.java @@ -0,0 +1,19 @@ +package dev.esophose.playerparticles.nms.wrapper; + +import dev.esophose.playerparticles.particles.ParticleEffect; +import dev.esophose.playerparticles.particles.version.VersionMapping; +import java.util.Collection; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public abstract class ParticleHandler { + + protected VersionMapping versionMapping; + + public ParticleHandler(VersionMapping versionMapping) { + this.versionMapping = versionMapping; + } + + public abstract void spawnParticle(ParticleEffect particleEffect, Collection players, Location location, int count, float offsetX, float offsetY, float offsetZ, float extra, Object data); + +} diff --git a/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/ParticleEffect.java b/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/ParticleEffect.java new file mode 100644 index 0000000..e7ec6a8 --- /dev/null +++ b/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/ParticleEffect.java @@ -0,0 +1,103 @@ +package dev.esophose.playerparticles.particles; + +import java.util.Arrays; +import java.util.List; + +public enum ParticleEffect { + + AMBIENT_ENTITY_EFFECT(ParticleProperty.REQUIRES_COLOR_DATA), + ANGRY_VILLAGER, + ASH, + BARRIER, + BLOCK(ParticleProperty.REQUIRES_BLOCK_DATA), + BUBBLE, + BUBBLE_COLUMN_UP, + BUBBLE_POP, + CAMPFIRE_COSY_SMOKE, + CAMPFIRE_SIGNAL_SMOKE, + CLOUD, + COMPOSTER, + CRIMSON_SPORE, + CRIT, + CURRENT_DOWN, + DAMAGE_INDICATOR, + DOLPHIN, + DRAGON_BREATH, + DRIPPING_HONEY, + DRIPPING_LAVA, + DRIPPING_OBSIDIAN_TEAR, + DRIPPING_WATER, + DUST(ParticleProperty.REQUIRES_COLOR_DATA), + ELDER_GUARDIAN, + ENCHANT, + ENCHANTED_HIT, + END_ROD, + ENTITY_EFFECT(ParticleProperty.REQUIRES_COLOR_DATA), + EXPLOSION, + EXPLOSION_EMITTER, + FALLING_DUST(ParticleProperty.REQUIRES_BLOCK_DATA), + FALLING_HONEY, + FALLING_LAVA, + FALLING_NECTAR, + FALLING_OBSIDIAN_TEAR, + FALLING_WATER, + FIREWORK, + FISHING, + FLAME, + FLASH, + FOOTSTEP, + HAPPY_VILLAGER, + HEART, + INSTANT_EFFECT, + ITEM(ParticleProperty.REQUIRES_ITEM_DATA), + ITEM_SLIME, + ITEM_SNOWBALL, + LANDING_HONEY, + LANDING_LAVA, + LANDING_OBSIDIAN_TEAR, + LARGE_SMOKE, + LAVA, + MYCELIUM, + NAUTILUS, + NOTE(ParticleProperty.REQUIRES_COLOR_DATA), + POOF, + PORTAL, + RAIN, + SMOKE, + SNEEZE, + SOUL, + SOUL_FIRE_FLAME, + 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, + SPLASH, + SQUID_INK, + SWEEP_ATTACK, + TOTEM_OF_UNDYING, + UNDERWATER, + WARPED_SPORE, + WITCH; + + private List properties; + + ParticleEffect(ParticleProperty... properties) { + this.properties = Arrays.asList(properties); + } + + /** + * Determine if this particle effect has a specific property + * + * @param property The property to check + * @return Whether it has the property or not + */ + public boolean hasProperty(ParticleProperty property) { + return this.properties.contains(property); + } + + /** + * @return true if this ParticleEffect has properties, otherwise false + */ + public boolean hasProperties() { + return !this.properties.isEmpty(); + } + +} diff --git a/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/ParticleProperty.java b/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/ParticleProperty.java new file mode 100644 index 0000000..8b2bc42 --- /dev/null +++ b/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/ParticleProperty.java @@ -0,0 +1,12 @@ +package dev.esophose.playerparticles.particles; + +/** + * Represents a property of a particle effect + */ +public enum ParticleProperty { + + REQUIRES_BLOCK_DATA, + REQUIRES_ITEM_DATA, + REQUIRES_COLOR_DATA + +} diff --git a/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/version/VersionMapping.java b/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/version/VersionMapping.java new file mode 100644 index 0000000..82ee388 --- /dev/null +++ b/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/version/VersionMapping.java @@ -0,0 +1,43 @@ +package dev.esophose.playerparticles.particles.version; + +import dev.esophose.playerparticles.particles.ParticleEffect; +import java.util.HashMap; +import java.util.Map; + +@SuppressWarnings("StaticInitializerReferencesSubClass") +public abstract class VersionMapping { + + public static final VersionMapping _16 = new VersionMapping16(); + public static final VersionMapping _15 = new VersionMapping15(); + + private final Map particleEffectNameMapping; + + public VersionMapping() { + this.particleEffectNameMapping = new HashMap<>(); + } + + public abstract Map getParticleEffectIdMapping(); + + public Map getParticleEffectNameMapping() { + if (this.particleEffectNameMapping.isEmpty()) + this.getParticleEffectIdMapping().forEach((key, value) -> this.particleEffectNameMapping.put(value, key)); + return this.particleEffectNameMapping; + } + + public static VersionMapping getVersionMapping(int version) { + switch (version) { + case 16: + return _16; + case 15: + return _15; + } + + return new VersionMapping() { + @Override + public Map getParticleEffectIdMapping() { + return new HashMap<>(); + } + }; + } + +} diff --git a/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/version/VersionMapping15.java b/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/version/VersionMapping15.java new file mode 100644 index 0000000..d8c0e66 --- /dev/null +++ b/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/version/VersionMapping15.java @@ -0,0 +1,83 @@ +package dev.esophose.playerparticles.particles.version; + +import dev.esophose.playerparticles.particles.ParticleEffect; +import java.util.HashMap; +import java.util.Map; + +public class VersionMapping15 extends VersionMapping { + + private final Map particleEffectNameMapping; + + public VersionMapping15() { + this.particleEffectNameMapping = new HashMap() {{ + this.put(0, ParticleEffect.AMBIENT_ENTITY_EFFECT); + this.put(1, ParticleEffect.ANGRY_VILLAGER); + this.put(2, ParticleEffect.BARRIER); + this.put(3, ParticleEffect.BLOCK); + this.put(4, ParticleEffect.BUBBLE); + this.put(5, ParticleEffect.CLOUD); + this.put(6, ParticleEffect.CRIT); + this.put(7, ParticleEffect.DAMAGE_INDICATOR); + this.put(8, ParticleEffect.DRAGON_BREATH); + this.put(9, ParticleEffect.DRIPPING_LAVA); + this.put(10, ParticleEffect.FALLING_LAVA); + this.put(11, ParticleEffect.LANDING_LAVA); + this.put(12, ParticleEffect.DRIPPING_WATER); + this.put(13, ParticleEffect.FALLING_WATER); + this.put(14, ParticleEffect.DUST); + this.put(15, ParticleEffect.SPELL); + this.put(16, ParticleEffect.ELDER_GUARDIAN); + this.put(17, ParticleEffect.ENCHANTED_HIT); + this.put(18, ParticleEffect.ENCHANT); + this.put(19, ParticleEffect.END_ROD); + this.put(20, ParticleEffect.ENTITY_EFFECT); + this.put(21, ParticleEffect.EXPLOSION_EMITTER); + this.put(22, ParticleEffect.EXPLOSION); + this.put(23, ParticleEffect.FALLING_DUST); + this.put(24, ParticleEffect.FIREWORK); + this.put(25, ParticleEffect.FISHING); + this.put(26, ParticleEffect.FLAME); + this.put(27, ParticleEffect.FLASH); + this.put(28, ParticleEffect.HAPPY_VILLAGER); + this.put(29, ParticleEffect.COMPOSTER); + this.put(30, ParticleEffect.HEART); + this.put(31, ParticleEffect.INSTANT_EFFECT); + this.put(32, ParticleEffect.ITEM); + this.put(33, ParticleEffect.ITEM_SLIME); + this.put(34, ParticleEffect.ITEM_SNOWBALL); + this.put(35, ParticleEffect.LARGE_SMOKE); + this.put(36, ParticleEffect.LAVA); + this.put(37, ParticleEffect.MYCELIUM); + this.put(38, ParticleEffect.NOTE); + this.put(39, ParticleEffect.POOF); + this.put(40, ParticleEffect.PORTAL); + this.put(41, ParticleEffect.RAIN); + this.put(42, ParticleEffect.SMOKE); + this.put(43, ParticleEffect.SNEEZE); + this.put(44, ParticleEffect.SPIT); + this.put(45, ParticleEffect.SQUID_INK); + this.put(46, ParticleEffect.SWEEP_ATTACK); + this.put(47, ParticleEffect.TOTEM_OF_UNDYING); + this.put(48, ParticleEffect.UNDERWATER); + this.put(49, ParticleEffect.SPLASH); + this.put(50, ParticleEffect.WITCH); + this.put(51, ParticleEffect.BUBBLE_POP); + this.put(52, ParticleEffect.CURRENT_DOWN); + this.put(53, ParticleEffect.BUBBLE_COLUMN_UP); + this.put(54, ParticleEffect.NAUTILUS); + this.put(55, ParticleEffect.DOLPHIN); + this.put(56, ParticleEffect.CAMPFIRE_COSY_SMOKE); + this.put(57, ParticleEffect.CAMPFIRE_SIGNAL_SMOKE); + this.put(58, ParticleEffect.DRIPPING_HONEY); + this.put(59, ParticleEffect.FALLING_HONEY); + this.put(60, ParticleEffect.LANDING_HONEY); + this.put(61, ParticleEffect.FALLING_NECTAR); + }}; + } + + @Override + public Map getParticleEffectIdMapping() { + return this.particleEffectNameMapping; + } + +} diff --git a/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/version/VersionMapping16.java b/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/version/VersionMapping16.java new file mode 100644 index 0000000..c270733 --- /dev/null +++ b/Particles/Wrapper/src/main/java/dev/esophose/playerparticles/particles/version/VersionMapping16.java @@ -0,0 +1,91 @@ +package dev.esophose.playerparticles.particles.version; + +import dev.esophose.playerparticles.particles.ParticleEffect; +import java.util.HashMap; +import java.util.Map; + +public class VersionMapping16 extends VersionMapping { + + private final Map particleEffectNameMapping; + + public VersionMapping16() { + this.particleEffectNameMapping = new HashMap() {{ + this.put(0, ParticleEffect.AMBIENT_ENTITY_EFFECT); + this.put(1, ParticleEffect.ANGRY_VILLAGER); + this.put(2, ParticleEffect.BARRIER); + this.put(3, ParticleEffect.BLOCK); + this.put(4, ParticleEffect.BUBBLE); + this.put(5, ParticleEffect.CLOUD); + this.put(6, ParticleEffect.CRIT); + this.put(7, ParticleEffect.DAMAGE_INDICATOR); + this.put(8, ParticleEffect.DRAGON_BREATH); + this.put(9, ParticleEffect.DRIPPING_LAVA); + this.put(10, ParticleEffect.FALLING_LAVA); + this.put(11, ParticleEffect.LANDING_LAVA); + this.put(12, ParticleEffect.DRIPPING_WATER); + this.put(13, ParticleEffect.FALLING_WATER); + this.put(14, ParticleEffect.DUST); + this.put(15, ParticleEffect.SPELL); + this.put(16, ParticleEffect.ELDER_GUARDIAN); + this.put(17, ParticleEffect.ENCHANTED_HIT); + this.put(18, ParticleEffect.ENCHANT); + this.put(19, ParticleEffect.END_ROD); + this.put(20, ParticleEffect.ENTITY_EFFECT); + this.put(21, ParticleEffect.EXPLOSION_EMITTER); + this.put(22, ParticleEffect.EXPLOSION); + this.put(23, ParticleEffect.FALLING_DUST); + this.put(24, ParticleEffect.FIREWORK); + this.put(25, ParticleEffect.FISHING); + this.put(26, ParticleEffect.FLAME); + this.put(27, ParticleEffect.SOUL_FIRE_FLAME); + this.put(28, ParticleEffect.SOUL); + this.put(29, ParticleEffect.FLASH); + this.put(30, ParticleEffect.HAPPY_VILLAGER); + this.put(31, ParticleEffect.COMPOSTER); + this.put(32, ParticleEffect.HEART); + this.put(33, ParticleEffect.INSTANT_EFFECT); + this.put(34, ParticleEffect.ITEM); + this.put(35, ParticleEffect.ITEM_SLIME); + this.put(36, ParticleEffect.ITEM_SNOWBALL); + this.put(37, ParticleEffect.LARGE_SMOKE); + this.put(38, ParticleEffect.LAVA); + this.put(39, ParticleEffect.MYCELIUM); + this.put(40, ParticleEffect.NOTE); + this.put(41, ParticleEffect.POOF); + this.put(42, ParticleEffect.PORTAL); + this.put(43, ParticleEffect.RAIN); + this.put(44, ParticleEffect.SMOKE); + this.put(45, ParticleEffect.SNEEZE); + this.put(46, ParticleEffect.SPIT); + this.put(47, ParticleEffect.SQUID_INK); + this.put(48, ParticleEffect.SWEEP_ATTACK); + this.put(49, ParticleEffect.TOTEM_OF_UNDYING); + this.put(50, ParticleEffect.UNDERWATER); + this.put(51, ParticleEffect.SPLASH); + this.put(52, ParticleEffect.WITCH); + this.put(53, ParticleEffect.BUBBLE_POP); + this.put(54, ParticleEffect.CURRENT_DOWN); + this.put(55, ParticleEffect.BUBBLE_COLUMN_UP); + this.put(56, ParticleEffect.NAUTILUS); + this.put(57, ParticleEffect.DOLPHIN); + this.put(58, ParticleEffect.CAMPFIRE_COSY_SMOKE); + this.put(59, ParticleEffect.CAMPFIRE_SIGNAL_SMOKE); + this.put(60, ParticleEffect.DRIPPING_HONEY); + this.put(61, ParticleEffect.FALLING_HONEY); + this.put(62, ParticleEffect.LANDING_HONEY); + this.put(63, ParticleEffect.FALLING_NECTAR); + this.put(64, ParticleEffect.ASH); + this.put(65, ParticleEffect.CRIMSON_SPORE); + this.put(66, ParticleEffect.WARPED_SPORE); + this.put(67, ParticleEffect.DRIPPING_OBSIDIAN_TEAR); + this.put(68, ParticleEffect.FALLING_OBSIDIAN_TEAR); + this.put(69, ParticleEffect.LANDING_OBSIDIAN_TEAR); + }}; + } + + @Override + public Map getParticleEffectIdMapping() { + return this.particleEffectNameMapping; + } + +} diff --git a/Particles/v1_15_R1/build.gradle b/Particles/v1_15_R1/build.gradle new file mode 100644 index 0000000..2eb2d2e --- /dev/null +++ b/Particles/v1_15_R1/build.gradle @@ -0,0 +1,5 @@ +dependencies { + implementation project(':NMS-Wrapper') + shadow 'org.spigotmc:spigot:1.15.2-R0.1-SNAPSHOT' + shadow 'com.comphenix.protocol:ProtocolLib:4.5.0' +} diff --git a/Particles/v1_15_R1/src/main/java/dev/esophose/playerparticles/nms/v1_15_R1/ModifiedPacketPlayOutWorldParticles.java b/Particles/v1_15_R1/src/main/java/dev/esophose/playerparticles/nms/v1_15_R1/ModifiedPacketPlayOutWorldParticles.java new file mode 100644 index 0000000..563f424 --- /dev/null +++ b/Particles/v1_15_R1/src/main/java/dev/esophose/playerparticles/nms/v1_15_R1/ModifiedPacketPlayOutWorldParticles.java @@ -0,0 +1,52 @@ +package dev.esophose.playerparticles.nms.v1_15_R1; + +import net.minecraft.server.v1_15_R1.PacketDataSerializer; +import net.minecraft.server.v1_15_R1.PacketPlayOutWorldParticles; +import net.minecraft.server.v1_15_R1.ParticleParam; + +class ModifiedPacketPlayOutWorldParticles extends PacketPlayOutWorldParticles { + + private int particleId; + private double x; + private double y; + private double z; + private float offsetX; + private float offsetY; + private float offsetZ; + private float extra; + private int count; + private boolean longDistance; + private ParticleParam particleParam; + + public ModifiedPacketPlayOutWorldParticles(int particleId, T particalParam, boolean longDistance, double x, double y, double z, float offsetX, float offsetY, float offsetZ, float extra, int count) { + this.particleId = particleId; + this.particleParam = particalParam; + this.longDistance = longDistance; + this.x = x; + this.y = y; + this.z = z; + this.offsetX = offsetX; + this.offsetY = offsetY; + this.offsetZ = offsetZ; + this.extra = extra; + this.count = count; + } + + @Override + public void b(PacketDataSerializer var0) { + var0.writeInt(this.particleId); + var0.writeBoolean(this.longDistance); + var0.writeDouble(this.x); + var0.writeDouble(this.y); + var0.writeDouble(this.z); + var0.writeFloat(this.offsetX); + var0.writeFloat(this.offsetY); + var0.writeFloat(this.offsetZ); + var0.writeFloat(this.extra); + var0.writeInt(this.count); + + if (this.particleParam != null) + this.particleParam.a(var0); + } + +} diff --git a/Particles/v1_15_R1/src/main/java/dev/esophose/playerparticles/nms/v1_15_R1/ParticleHandlerImpl.java b/Particles/v1_15_R1/src/main/java/dev/esophose/playerparticles/nms/v1_15_R1/ParticleHandlerImpl.java new file mode 100644 index 0000000..651aa0b --- /dev/null +++ b/Particles/v1_15_R1/src/main/java/dev/esophose/playerparticles/nms/v1_15_R1/ParticleHandlerImpl.java @@ -0,0 +1,85 @@ +package dev.esophose.playerparticles.nms.v1_15_R1; + +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.ProtocolManager; +import dev.esophose.playerparticles.nms.wrapper.ParticleHandler; +import dev.esophose.playerparticles.particles.ParticleEffect; +import dev.esophose.playerparticles.particles.version.VersionMapping; +import io.netty.buffer.Unpooled; +import java.io.IOException; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import net.minecraft.server.v1_15_R1.IRegistry; +import net.minecraft.server.v1_15_R1.PacketDataSerializer; +import net.minecraft.server.v1_15_R1.PacketPlayOutWorldParticles; +import net.minecraft.server.v1_15_R1.Particle; +import net.minecraft.server.v1_15_R1.ParticleParam; +import net.minecraft.server.v1_15_R1.ParticleParamBlock; +import net.minecraft.server.v1_15_R1.ParticleParamItem; +import net.minecraft.server.v1_15_R1.ParticleParamRedstone; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Particle.DustOptions; +import org.bukkit.block.Block; +import org.bukkit.block.data.BlockData; +import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData; +import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_15_R1.util.CraftMagicNumbers; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.MaterialData; +import org.bukkit.util.Vector; + +@SuppressWarnings("deprecation") +public class ParticleHandlerImpl extends ParticleHandler { + + public ParticleHandlerImpl(VersionMapping versionMapping) { + super(versionMapping); + } + + @Override + public void spawnParticle(ParticleEffect particleEffect, Collection players, Location location, int count, float offsetX, float offsetY, float offsetZ, float extra, Object data) { + int particleId = this.versionMapping.getParticleEffectNameMapping().get(particleEffect); + Particle nms = IRegistry.PARTICLE_TYPE.fromId(particleId); + + ParticleParam particleParam = null; + if (data instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data; + particleParam = new ParticleParamItem(nms, CraftItemStack.asNMSCopy(itemStack)); + } else if (data instanceof MaterialData) { + MaterialData materialData = (MaterialData) data; + particleParam = new ParticleParamBlock(nms, CraftMagicNumbers.getBlock(materialData)); + } else if (data instanceof BlockData) { + BlockData blockData = (BlockData) data; + particleParam = new ParticleParamBlock(nms, ((CraftBlockData) blockData).getState()); + } else if (data instanceof DustOptions) { + DustOptions dustOptions = (DustOptions) data; + Color color = dustOptions.getColor(); + particleParam = new ParticleParamRedstone((float) color.getRed() / 255.0F, (float) color.getGreen() / 255.0F, (float) color.getBlue() / 255.0F, dustOptions.getSize()); + } + + PacketPlayOutWorldParticles packetplayoutworldparticles = new ModifiedPacketPlayOutWorldParticles(particleId, particleParam, true, location.getX(), location.getY(), location.getZ(), offsetX, offsetY, offsetZ, extra, count); + + PacketDataSerializer dataSerializer = new PacketDataSerializer(Unpooled.buffer()); + try { + packetplayoutworldparticles.b(dataSerializer); + } catch (IOException e) { + e.printStackTrace(); + } + + ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); + + byte[] bytes = new byte[dataSerializer.readableBytes()]; + dataSerializer.readBytes(bytes); + + try { + for (Player player : players) { + protocolManager.sendWirePacket(player, 0x24, bytes); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + +} diff --git a/Plugin/build.gradle b/Plugin/build.gradle new file mode 100644 index 0000000..0319143 --- /dev/null +++ b/Plugin/build.gradle @@ -0,0 +1,73 @@ +import org.apache.tools.ant.filters.ReplaceTokens + +plugins { + id 'maven-publish' +} + +compileJava { + options.compilerArgs += ['-parameters'] + options.fork = true + options.forkOptions.executable = 'javac' + options.encoding = 'UTF-8' +} + +dependencies { + // Other modules + implementation project(':NMS-Wrapper') + + // Referenced dependencies + shadow 'org.spigotmc:spigot:1.15.2-R0.1-SNAPSHOT' + shadow 'org.jetbrains:annotations:16.0.2' + shadow 'me.clip:placeholderapi:2.10.4' + shadow 'org.xerial:sqlite-jdbc:3.23.1' + shadow 'com.comphenix.protocol:ProtocolLib:4.5.0' + + // Dependencies that will be shaded into the jar + implementation 'org.slf4j:slf4j-api:1.7.25' + implementation 'org.slf4j:slf4j-nop:1.7.25' + implementation 'com.zaxxer:HikariCP:3.2.0' +} + +processResources { + from (sourceSets.main.resources.srcDirs) { + include '**/*.yml' + filter ReplaceTokens, tokens: ["version": project.property("version")] + } +} + +publishing { + publications { + shadow(MavenPublication) { publication -> + project.shadow.component(publication) + } + mavenJava(MavenPublication) { + artifactId = 'playerparticles' + from components.java + versionMapping { + usage('java-api') { + fromResolutionOf('runtimeClasspath') + } + usage('java-runtime') { + fromResolutionResult() + } + } + pom { + name = 'playerparticles' + } + } + } + repositories { + if (project.hasProperty('mavenUsername') && project.hasProperty('mavenPassword')) { + maven { + credentials { + username project.mavenUsername + password project.mavenPassword + } + + def releasesRepoUrl = 'https://repo.codemc.org/repository/maven-releases/' + def snapshotsRepoUrl = 'https://repo.codemc.org/repository/maven-snapshots/' + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + } + } + } +} diff --git a/src/main/java/dev/esophose/playerparticles/PlayerParticles.java b/Plugin/src/main/java/dev/esophose/playerparticles/PlayerParticles.java similarity index 57% rename from src/main/java/dev/esophose/playerparticles/PlayerParticles.java rename to Plugin/src/main/java/dev/esophose/playerparticles/PlayerParticles.java index 502fd7f..09a64c2 100644 --- a/src/main/java/dev/esophose/playerparticles/PlayerParticles.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/PlayerParticles.java @@ -6,6 +6,11 @@ package dev.esophose.playerparticles; +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.ProtocolManager; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.wrappers.EnumWrappers.TitleAction; import dev.esophose.playerparticles.gui.hook.PlayerChatHook; import dev.esophose.playerparticles.hook.ParticlePlaceholderExpansion; import dev.esophose.playerparticles.hook.PlaceholderAPIHook; @@ -24,12 +29,20 @@ import dev.esophose.playerparticles.manager.PluginUpdateManager; import dev.esophose.playerparticles.particles.listener.PPlayerCombatListener; import dev.esophose.playerparticles.particles.listener.PPlayerMovementListener; import dev.esophose.playerparticles.util.Metrics; +import io.netty.buffer.Unpooled; +import java.awt.Color; import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.Map; +import net.minecraft.server.v1_15_R1.PacketDataSerializer; +import net.minecraft.server.v1_15_R1.PacketPlayOutTitle; import org.bukkit.Bukkit; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitRunnable; /** * @author Esophose @@ -69,9 +82,76 @@ public class PlayerParticles extends JavaPlugin { if (PlaceholderAPIHook.enabled()) new ParticlePlaceholderExpansion(this).register(); + ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); + new BukkitRunnable() { + private LinkedList queue = new LinkedList<>(); + private String message = "Snapshot 20w17a Chat Hex Code Colors!"; + + @Override + public void run() { + if (queue.size() >= message.length()) + queue.poll(); + + Color color = getRainbowColor(); + String hex = String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue()); + queue.add(hex); + + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("["); + boolean isFirst = true; + for (int i = 0; i < queue.size(); i++) { + if (!isFirst) + stringBuilder.append(","); + isFirst = false; + + stringBuilder.append("{"); + stringBuilder.append("\"color\":\"").append(queue.get(i)).append("\","); + stringBuilder.append("\"text\":\"").append(message.charAt(i)).append("\""); + stringBuilder.append("}"); + } + stringBuilder.append("]"); + + PacketContainer timePacket = protocolManager.createPacket(PacketType.fromClass(PacketPlayOutTitle.class)); + timePacket.getTitleActions().write(0, TitleAction.TIMES); + timePacket.getIntegers().write(0, 0).write(1, 20).write(2, 0); + + PacketDataSerializer dataSerializer = new PacketDataSerializer(Unpooled.buffer()); + try { + PacketPlayOutTitle titlePacket = new PacketPlayOutTitle() { + @Override + public void b(PacketDataSerializer var0) { + var0.a(EnumTitleAction.TITLE); + var0.a(stringBuilder.toString()); + } + }; + titlePacket.b(dataSerializer); + } catch (IOException e) { + e.printStackTrace(); + } + + byte[] bytes = new byte[dataSerializer.readableBytes()]; + dataSerializer.readBytes(bytes); + + Bukkit.getOnlinePlayers().forEach(x -> { + try { + protocolManager.sendServerPacket(x, timePacket); + protocolManager.sendWirePacket(x, 0x50, bytes); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + }); + } + }.runTaskTimer(this, 0, 1); + PlayerChatHook.setup(); } + private float hue = 0; + private Color getRainbowColor() { + this.hue = (this.hue + 4) % 362; + return Color.getHSBColor(this.hue / 360F, 1.0F, 1.0F); + } + @Override public void onDisable() { this.managers.values().forEach(Manager::disable); diff --git a/src/main/java/dev/esophose/playerparticles/api/PlayerParticlesAPI.java b/Plugin/src/main/java/dev/esophose/playerparticles/api/PlayerParticlesAPI.java similarity index 99% rename from src/main/java/dev/esophose/playerparticles/api/PlayerParticlesAPI.java rename to Plugin/src/main/java/dev/esophose/playerparticles/api/PlayerParticlesAPI.java index ca87977..a7d6db8 100644 --- a/src/main/java/dev/esophose/playerparticles/api/PlayerParticlesAPI.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/api/PlayerParticlesAPI.java @@ -1,6 +1,5 @@ package dev.esophose.playerparticles.api; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.DataManager; import dev.esophose.playerparticles.manager.GuiManager; import dev.esophose.playerparticles.manager.ParticleManager; @@ -9,11 +8,12 @@ import dev.esophose.playerparticles.particles.ConsolePPlayer; import dev.esophose.playerparticles.particles.FixedParticleEffect; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; -import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor; -import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.particles.color.NoteColor; +import dev.esophose.playerparticles.particles.color.OrdinaryColor; import dev.esophose.playerparticles.styles.ParticleStyle; +import dev.esophose.playerparticles.PlayerParticles; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; diff --git a/src/main/java/dev/esophose/playerparticles/command/AddCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/AddCommandModule.java similarity index 79% rename from src/main/java/dev/esophose/playerparticles/command/AddCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/AddCommandModule.java index 66eecb5..c10fcde 100644 --- a/src/main/java/dev/esophose/playerparticles/command/AddCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/AddCommandModule.java @@ -1,17 +1,18 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.manager.LocaleManager; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.manager.ParticleStyleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; -import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor; -import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; -import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; +import dev.esophose.playerparticles.particles.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.api.PlayerParticlesAPI; +import dev.esophose.playerparticles.particles.color.NoteColor; +import dev.esophose.playerparticles.particles.color.OrdinaryColor; import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.StringPlaceholders; @@ -20,7 +21,6 @@ import dev.esophose.playerparticles.util.inputparser.parsable.ParsableOrdinaryCo import java.util.ArrayList; import java.util.List; import org.bukkit.Material; -import org.bukkit.entity.Player; import org.bukkit.util.StringUtil; public class AddCommandModule implements CommandModule { @@ -31,6 +31,7 @@ public class AddCommandModule implements CommandModule { return; } + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); @@ -47,7 +48,7 @@ public class AddCommandModule implements CommandModule { localeManager.sendMessage(pplayer, "effect-invalid", StringPlaceholders.single("effect", args[0])); return; } else if (!permissionManager.hasEffectPermission(pplayer, effect)) { - localeManager.sendMessage(pplayer, "effect-no-permission", StringPlaceholders.single("effect", effect.getName())); + localeManager.sendMessage(pplayer, "effect-no-permission", StringPlaceholders.single("effect", particleManager.getEffectSettings(effect).getName())); return; } @@ -66,7 +67,7 @@ public class AddCommandModule implements CommandModule { NoteColor noteColorData = null; if (args.length > 2) { - if (effect.hasProperty(ParticleProperty.COLORABLE)) { + if (effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { if (effect == ParticleEffect.NOTE) { noteColorData = inputParser.next(NoteColor.class); if (noteColorData == null) { @@ -80,19 +81,17 @@ public class AddCommandModule implements CommandModule { return; } } - } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { - blockData = inputParser.next(Material.class); - if (blockData == null || !blockData.isBlock()) { - localeManager.sendMessage(pplayer, "data-invalid-block"); - return; - } - } else if (effect == ParticleEffect.ITEM) { - itemData = inputParser.next(Material.class); - if (itemData == null || itemData.isBlock()) { - localeManager.sendMessage(pplayer, "data-invalid-item"); - return; - } + } else if (effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA)) { + blockData = inputParser.next(Material.class); + if (blockData == null || !blockData.isBlock()) { + localeManager.sendMessage(pplayer, "data-invalid-block"); + return; + } + } else if (effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA)) { + itemData = inputParser.next(Material.class); + if (itemData == null || itemData.isBlock()) { + localeManager.sendMessage(pplayer, "data-invalid-item"); + return; } } } @@ -102,7 +101,7 @@ public class AddCommandModule implements CommandModule { group.getParticles().put(newParticle.getId(), newParticle); PlayerParticlesAPI.getInstance().savePlayerParticleGroup(pplayer.getPlayer(), group); - StringPlaceholders addParticlePlaceholders = StringPlaceholders.builder("effect", newParticle.getEffect().getName()) + StringPlaceholders addParticlePlaceholders = StringPlaceholders.builder("effect", particleManager.getEffectSettings(newParticle.getEffect()).getName()) .addPlaceholder("style", newParticle.getStyle().getName()) .addPlaceholder("data", newParticle.getDataString()).build(); localeManager.sendMessage(pplayer, "add-particle-applied", addParticlePlaceholders); @@ -113,8 +112,8 @@ public class AddCommandModule implements CommandModule { } public List onTabComplete(PPlayer pplayer, String[] args) { - Player p = pplayer.getPlayer(); List matches = new ArrayList<>(); + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class); if (args.length <= 1) { // Effect name @@ -123,9 +122,9 @@ public class AddCommandModule implements CommandModule { } else if (args.length == 2) { // Style name StringUtil.copyPartialMatches(args[1], permissionManager.getStyleNamesUserHasPermissionFor(pplayer), matches); } else { // Data - ParticleEffect effect = ParticleEffect.fromName(args[0]); + ParticleEffect effect = particleManager.getEffectFromName(args[0]); if (effect != null) { - if (effect.hasProperty(ParticleProperty.COLORABLE)) { + if (effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { List possibleValues = new ArrayList<>(); if (effect == ParticleEffect.NOTE) { // Note data if (args.length == 3) { @@ -145,12 +144,10 @@ public class AddCommandModule implements CommandModule { } } StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches); - } else if (args.length == 3 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material - StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllBlockMaterials(), matches); - } else if (effect == ParticleEffect.ITEM) { // Item material - StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllItemMaterials(), matches); - } + } else if (args.length == 3 && effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA)) { + StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllBlockMaterials(), matches); + } else if (args.length == 3 && effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA)) { + StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllItemMaterials(), matches); } } } diff --git a/src/main/java/dev/esophose/playerparticles/command/CommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/CommandModule.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/command/CommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/CommandModule.java index 0081ec6..a0facc4 100644 --- a/src/main/java/dev/esophose/playerparticles/command/CommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/CommandModule.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.particles.PPlayer; +import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.util.StringPlaceholders; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/command/CommandModuleSecondary.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/CommandModuleSecondary.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/command/CommandModuleSecondary.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/CommandModuleSecondary.java diff --git a/src/main/java/dev/esophose/playerparticles/command/DataCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/DataCommandModule.java similarity index 70% rename from src/main/java/dev/esophose/playerparticles/command/DataCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/DataCommandModule.java index 10d5a55..bb1cf64 100644 --- a/src/main/java/dev/esophose/playerparticles/command/DataCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/DataCommandModule.java @@ -2,10 +2,11 @@ package dev.esophose.playerparticles.command; import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.LocaleManager; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; -import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; +import dev.esophose.playerparticles.particles.ParticleProperty; import dev.esophose.playerparticles.util.StringPlaceholders; import java.util.ArrayList; import java.util.List; @@ -14,29 +15,29 @@ import org.bukkit.util.StringUtil; public class DataCommandModule implements CommandModule { public void onCommandExecute(PPlayer pplayer, String[] args) { + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); if (args.length > 0) { - ParticleEffect effect = ParticleEffect.fromName(args[0]); + ParticleEffect effect = particleManager.getEffectFromName(args[0]); if (effect == null) { localeManager.sendMessage(pplayer, "effect-invalid", StringPlaceholders.single("effect", args[0])); return; } - if (effect.hasProperty(ParticleProperty.COLORABLE)) { + String effectName = particleManager.getEffectSettings(effect).getName(); + if (effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { if (effect == ParticleEffect.NOTE) { - localeManager.sendMessage(pplayer, "data-usage-note", StringPlaceholders.single("effect", effect.getName())); + localeManager.sendMessage(pplayer, "data-usage-note", StringPlaceholders.single("effect", effectName)); } else { - localeManager.sendMessage(pplayer, "data-usage-color", StringPlaceholders.single("effect", effect.getName())); - } - } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - if (effect == ParticleEffect.ITEM) { - localeManager.sendMessage(pplayer, "data-usage-item", StringPlaceholders.single("effect", effect.getName())); - } else { - localeManager.sendMessage(pplayer, "data-usage-block", StringPlaceholders.single("effect", effect.getName())); + localeManager.sendMessage(pplayer, "data-usage-color", StringPlaceholders.single("effect", effectName)); } + } else if (effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA)) { + localeManager.sendMessage(pplayer, "data-usage-block", StringPlaceholders.single("effect", effectName)); + } else if (effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA)) { + localeManager.sendMessage(pplayer, "data-usage-item", StringPlaceholders.single("effect", effectName)); } else { - localeManager.sendMessage(pplayer, "data-usage-none", StringPlaceholders.single("effect", effect.getName())); + localeManager.sendMessage(pplayer, "data-usage-none", StringPlaceholders.single("effect", effectName)); } } else { localeManager.sendMessage(pplayer, "data-no-args"); diff --git a/src/main/java/dev/esophose/playerparticles/command/DefaultCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/DefaultCommandModule.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/command/DefaultCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/DefaultCommandModule.java index dd2fc98..622ace2 100644 --- a/src/main/java/dev/esophose/playerparticles/command/DefaultCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/DefaultCommandModule.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.CommandManager; import dev.esophose.playerparticles.particles.PPlayer; +import dev.esophose.playerparticles.PlayerParticles; import java.util.ArrayList; import java.util.List; import org.bukkit.util.StringUtil; diff --git a/src/main/java/dev/esophose/playerparticles/command/EditCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/EditCommandModule.java similarity index 87% rename from src/main/java/dev/esophose/playerparticles/command/EditCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/EditCommandModule.java index 953d98a..faebdc4 100644 --- a/src/main/java/dev/esophose/playerparticles/command/EditCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/EditCommandModule.java @@ -1,16 +1,17 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.manager.LocaleManager; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; -import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor; -import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; -import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.api.PlayerParticlesAPI; +import dev.esophose.playerparticles.particles.ParticleProperty; +import dev.esophose.playerparticles.particles.color.NoteColor; +import dev.esophose.playerparticles.particles.color.OrdinaryColor; import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.StringPlaceholders; @@ -77,6 +78,7 @@ public class EditCommandModule implements CommandModule { * @param args The rest of the args */ private void editEffect(PPlayer pplayer, int id, String[] args) { + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); InputParser inputParser = new InputParser(pplayer, args); @@ -85,7 +87,7 @@ public class EditCommandModule implements CommandModule { localeManager.sendMessage(pplayer, "effect-invalid", StringPlaceholders.single("effect", args[0])); return; } else if (!PlayerParticles.getInstance().getManager(PermissionManager.class).hasEffectPermission(pplayer, effect)) { - localeManager.sendMessage(pplayer, "effect-no-permission", StringPlaceholders.single("effect", effect.getName())); + localeManager.sendMessage(pplayer, "effect-no-permission", StringPlaceholders.single("effect", particleManager.getEffectSettings(effect).getName())); return; } @@ -98,7 +100,7 @@ public class EditCommandModule implements CommandModule { } PlayerParticlesAPI.getInstance().savePlayerParticleGroup(pplayer.getPlayer(), group); - localeManager.sendMessage(pplayer, "edit-success-effect", StringPlaceholders.builder("id", id).addPlaceholder("effect", effect.getName()).build()); + localeManager.sendMessage(pplayer, "edit-success-effect", StringPlaceholders.builder("id", id).addPlaceholder("effect", particleManager.getEffectSettings(effect).getName()).build()); } /** @@ -151,7 +153,7 @@ public class EditCommandModule implements CommandModule { ParticleEffect effect = pplayer.getActiveParticle(id).getEffect(); InputParser inputParser = new InputParser(pplayer, args); - if (effect.hasProperty(ParticleProperty.COLORABLE)) { + if (effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { if (effect == ParticleEffect.NOTE) { noteColorData = inputParser.next(NoteColor.class); if (noteColorData == null) { @@ -165,19 +167,17 @@ public class EditCommandModule implements CommandModule { return; } } - } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { - blockData = inputParser.next(Material.class); - if (blockData == null || !blockData.isBlock()) { - localeManager.sendMessage(pplayer, "data-invalid-block"); - return; - } - } else if (effect == ParticleEffect.ITEM) { - itemData = inputParser.next(Material.class); - if (itemData == null || itemData.isBlock()) { - localeManager.sendMessage(pplayer, "data-invalid-item"); - return; - } + } else if (effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA)) { + blockData = inputParser.next(Material.class); + if (blockData == null || !blockData.isBlock()) { + localeManager.sendMessage(pplayer, "data-invalid-block"); + return; + } + } else if (effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA)) { + itemData = inputParser.next(Material.class); + if (itemData == null || itemData.isBlock()) { + localeManager.sendMessage(pplayer, "data-invalid-item"); + return; } } @@ -237,7 +237,7 @@ public class EditCommandModule implements CommandModule { break; case "data": ParticleEffect effect = pplayer.getActiveParticle(id).getEffect(); - if (effect.hasProperty(ParticleProperty.COLORABLE)) { + if (effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { List possibleValues = new ArrayList<>(); if (effect == ParticleEffect.NOTE) { // Note data if (args.length == 3) { @@ -257,12 +257,10 @@ public class EditCommandModule implements CommandModule { } } StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches); - } else if (args.length == 3 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material - StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllBlockMaterials(), matches); - } else if (effect == ParticleEffect.ITEM) { // Item material - StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllItemMaterials(), matches); - } + } else if (args.length == 3 && effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA)) { + StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllBlockMaterials(), matches); + } else if (args.length == 3 && effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA)) { + StringUtil.copyPartialMatches(args[2], ParticleUtils.getAllItemMaterials(), matches); } break; } diff --git a/src/main/java/dev/esophose/playerparticles/command/EffectsCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/EffectsCommandModule.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/command/EffectsCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/EffectsCommandModule.java index 1a06195..24dd971 100644 --- a/src/main/java/dev/esophose/playerparticles/command/EffectsCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/EffectsCommandModule.java @@ -1,9 +1,9 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; +import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.util.StringPlaceholders; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/command/FixedCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/FixedCommandModule.java similarity index 92% rename from src/main/java/dev/esophose/playerparticles/command/FixedCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/FixedCommandModule.java index 4a190a0..a035d1b 100644 --- a/src/main/java/dev/esophose/playerparticles/command/FixedCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/FixedCommandModule.java @@ -1,16 +1,17 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.manager.LocaleManager; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.FixedParticleEffect; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; -import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor; -import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; -import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.api.PlayerParticlesAPI; +import dev.esophose.playerparticles.particles.ParticleProperty; +import dev.esophose.playerparticles.particles.color.NoteColor; +import dev.esophose.playerparticles.particles.color.OrdinaryColor; import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.StringPlaceholders; @@ -108,6 +109,7 @@ public class FixedCommandModule implements CommandModule { * @param args The command arguments */ private void handleCreate(PPlayer pplayer, String[] args) { + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class); Player player = pplayer.getPlayer(); @@ -171,7 +173,7 @@ public class FixedCommandModule implements CommandModule { localeManager.sendMessage(pplayer, "fixed-create-effect-invalid", StringPlaceholders.single("effect", args[3])); return; } else if (!permissionManager.hasEffectPermission(pplayer, effect)) { - localeManager.sendMessage(pplayer, "fixed-create-effect-no-permission", StringPlaceholders.single("effect", effect.getName())); + localeManager.sendMessage(pplayer, "fixed-create-effect-no-permission", StringPlaceholders.single("effect", particleManager.getEffectSettings(effect).getName())); return; } @@ -194,8 +196,8 @@ public class FixedCommandModule implements CommandModule { OrdinaryColor colorData = null; NoteColor noteColorData = null; - if (inputParser.hasNext() && (effect.hasProperty(ParticleProperty.COLORABLE) || effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA))) { - if (effect.hasProperty(ParticleProperty.COLORABLE)) { + if (inputParser.hasNext() && (effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA) || effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA) || effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA))) { + if (effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { if (effect == ParticleEffect.NOTE) { noteColorData = inputParser.next(NoteColor.class); if (noteColorData == null) { @@ -209,19 +211,17 @@ public class FixedCommandModule implements CommandModule { return; } } - } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { - blockData = inputParser.next(Material.class); - if (blockData == null || !blockData.isBlock()) { - localeManager.sendMessage(pplayer, "fixed-create-data-error"); - return; - } - } else if (effect == ParticleEffect.ITEM) { - itemData = inputParser.next(Material.class); - if (itemData == null || itemData.isBlock()) { - localeManager.sendMessage(pplayer, "fixed-create-data-error"); - return; - } + } else if (effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA)) { + blockData = inputParser.next(Material.class); + if (blockData == null || !blockData.isBlock()) { + localeManager.sendMessage(pplayer, "fixed-create-data-error"); + return; + } + } else if (effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA)) { + itemData = inputParser.next(Material.class); + if (itemData == null || itemData.isBlock()) { + localeManager.sendMessage(pplayer, "fixed-create-data-error"); + return; } } } @@ -238,6 +238,7 @@ public class FixedCommandModule implements CommandModule { * @param args The command arguments */ private void handleEdit(PPlayer pplayer, String[] args) { + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class); Player player = pplayer.getPlayer(); @@ -291,7 +292,7 @@ public class FixedCommandModule implements CommandModule { localeManager.sendMessage(pplayer, "fixed-edit-effect-invalid", StringPlaceholders.single("effect", args[2])); return; } else if (!permissionManager.hasEffectPermission(pplayer, effect)) { - localeManager.sendMessage(pplayer, "fixed-edit-effect-no-permission", StringPlaceholders.single("effect", effect.getName())); + localeManager.sendMessage(pplayer, "fixed-edit-effect-no-permission", StringPlaceholders.single("effect", particleManager.getEffectSettings(effect).getName())); return; } @@ -320,7 +321,7 @@ public class FixedCommandModule implements CommandModule { NoteColor noteColorData = null; ParticleEffect effect = fixedEffect.getParticlePair().getEffect(); - if (effect.hasProperty(ParticleProperty.COLORABLE)) { + if (effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { if (effect == ParticleEffect.NOTE) { noteColorData = inputParser.next(NoteColor.class); if (noteColorData == null) { @@ -334,19 +335,17 @@ public class FixedCommandModule implements CommandModule { return; } } - } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { - blockData = inputParser.next(Material.class); - if (blockData == null || !blockData.isBlock()) { - localeManager.sendMessage(pplayer, "fixed-edit-data-error"); - return; - } - } else if (effect == ParticleEffect.ITEM) { - itemData = inputParser.next(Material.class); - if (itemData == null || itemData.isBlock()) { - localeManager.sendMessage(pplayer, "fixed-edit-data-error"); - return; - } + } else if (effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA)) { + blockData = inputParser.next(Material.class); + if (blockData == null || !blockData.isBlock()) { + localeManager.sendMessage(pplayer, "fixed-edit-data-error"); + return; + } + } else if (effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA)) { + itemData = inputParser.next(Material.class); + if (itemData == null || itemData.isBlock()) { + localeManager.sendMessage(pplayer, "fixed-edit-data-error"); + return; } } else { localeManager.sendMessage(pplayer, "fixed-edit-data-none"); @@ -434,6 +433,7 @@ public class FixedCommandModule implements CommandModule { * @param args The command arguments */ private void handleInfo(PPlayer pplayer, String[] args) { + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); if (args.length < 1) { @@ -463,7 +463,7 @@ public class FixedCommandModule implements CommandModule { .addPlaceholder("x", df.format(fixedEffect.getLocation().getX())) .addPlaceholder("y", df.format(fixedEffect.getLocation().getY())) .addPlaceholder("z", df.format(fixedEffect.getLocation().getZ())) - .addPlaceholder("effect", particle.getEffect().getName()) + .addPlaceholder("effect", particleManager.getEffectSettings(particle.getEffect()).getName()) .addPlaceholder("style", particle.getStyle().getName()) .addPlaceholder("data", particle.getDataString()) .build(); @@ -556,6 +556,7 @@ public class FixedCommandModule implements CommandModule { } public List onTabComplete(PPlayer pplayer, String[] args) { + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); PermissionManager permissionManager = PlayerParticles.getInstance().getManager(PermissionManager.class); List matches = new ArrayList<>(); Player player = pplayer.getPlayer(); @@ -623,9 +624,9 @@ public class FixedCommandModule implements CommandModule { } else if (args.length == 6) { StringUtil.copyPartialMatches(args[5], permissionManager.getFixableStyleNamesUserHasPermissionFor(pplayer), matches); } else if (args.length >= 7) { - ParticleEffect effect = ParticleEffect.fromName(args[4]); + ParticleEffect effect = particleManager.getEffectFromName(args[4]); if (effect != null) { - if (effect.hasProperty(ParticleProperty.COLORABLE)) { + if (effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { List possibleValues = new ArrayList<>(); if (effect == ParticleEffect.NOTE) { // Note data if (args.length == 7) { @@ -645,12 +646,10 @@ public class FixedCommandModule implements CommandModule { } } StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches); - } else if (args.length == 7 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material - StringUtil.copyPartialMatches(args[6], ParticleUtils.getAllBlockMaterials(), matches); - } else if (effect == ParticleEffect.ITEM) { // Item material - StringUtil.copyPartialMatches(args[6], ParticleUtils.getAllItemMaterials(), matches); - } + } else if (args.length == 7 && effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA)) { + StringUtil.copyPartialMatches(args[6], ParticleUtils.getAllBlockMaterials(), matches); + } else if (args.length == 7 && effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA)) { + StringUtil.copyPartialMatches(args[6], ParticleUtils.getAllItemMaterials(), matches); } } } @@ -704,7 +703,7 @@ public class FixedCommandModule implements CommandModule { FixedParticleEffect fixedEffect = pplayer.getFixedEffectById(id); if (fixedEffect != null) { ParticleEffect effect = fixedEffect.getParticlePair().getEffect(); - if (effect.hasProperty(ParticleProperty.COLORABLE)) { + if (effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { List possibleValues = new ArrayList<>(); if (effect == ParticleEffect.NOTE) { // Note data if (args.length == 4) { @@ -724,12 +723,10 @@ public class FixedCommandModule implements CommandModule { } } StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches); - } else if (args.length == 4 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material - StringUtil.copyPartialMatches(args[3], ParticleUtils.getAllBlockMaterials(), matches); - } else if (effect == ParticleEffect.ITEM) { // Item material - StringUtil.copyPartialMatches(args[3], ParticleUtils.getAllItemMaterials(), matches); - } + } else if (args.length == 4 && effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA)) { + StringUtil.copyPartialMatches(args[3], ParticleUtils.getAllBlockMaterials(), matches); + } else if (args.length == 4 && effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA)) { + StringUtil.copyPartialMatches(args[3], ParticleUtils.getAllItemMaterials(), matches); } } } diff --git a/src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java index 4e0263b..c05ae3b 100644 --- a/src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/GUICommandModule.java @@ -1,11 +1,11 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; import dev.esophose.playerparticles.manager.GuiManager; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; +import dev.esophose.playerparticles.PlayerParticles; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/command/GroupCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/GroupCommandModule.java similarity index 98% rename from src/main/java/dev/esophose/playerparticles/command/GroupCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/GroupCommandModule.java index 0f93c6a..fc8e242 100644 --- a/src/main/java/dev/esophose/playerparticles/command/GroupCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/GroupCommandModule.java @@ -1,14 +1,15 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.manager.ParticleGroupPresetManager; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticleGroupPreset; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.util.StringPlaceholders; import java.util.ArrayList; import java.util.Arrays; @@ -213,6 +214,7 @@ public class GroupCommandModule implements CommandModule { * @param groupName The target group name */ private void onInfo(PPlayer pplayer, String groupName) { + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); // Check that the groupName isn't the reserved name @@ -244,7 +246,7 @@ public class GroupCommandModule implements CommandModule { localeManager.sendMessage(pplayer, "group-info-header", StringPlaceholders.single("group", groupName)); for (ParticlePair particle : particles) { StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", particle.getId()) - .addPlaceholder("effect", particle.getEffect().getName()) + .addPlaceholder("effect", particleManager.getEffectSettings(particle.getEffect()).getName()) .addPlaceholder("style", particle.getStyle().getName()) .addPlaceholder("data", particle.getDataString()) .build(); diff --git a/src/main/java/dev/esophose/playerparticles/command/HelpCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/HelpCommandModule.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/command/HelpCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/HelpCommandModule.java index 7412671..6a6a4ba 100644 --- a/src/main/java/dev/esophose/playerparticles/command/HelpCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/HelpCommandModule.java @@ -1,9 +1,9 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.CommandManager; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.particles.PPlayer; +import dev.esophose.playerparticles.PlayerParticles; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/command/ListCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/ListCommandModule.java similarity index 87% rename from src/main/java/dev/esophose/playerparticles/command/ListCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/ListCommandModule.java index 8d2ba9a..66d0c7a 100644 --- a/src/main/java/dev/esophose/playerparticles/command/ListCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/ListCommandModule.java @@ -1,9 +1,10 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.LocaleManager; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.util.StringPlaceholders; import java.util.ArrayList; import java.util.Comparator; @@ -12,6 +13,7 @@ import java.util.List; public class ListCommandModule implements CommandModule { public void onCommandExecute(PPlayer pplayer, String[] args) { + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); List particles = new ArrayList<>(pplayer.getActiveParticles()); @@ -25,7 +27,7 @@ public class ListCommandModule implements CommandModule { localeManager.sendMessage(pplayer, "list-you-have"); for (ParticlePair particle : particles) { StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", particle.getId()) - .addPlaceholder("effect", particle.getEffect().getName()) + .addPlaceholder("effect", particleManager.getEffectSettings(particle.getEffect()).getName()) .addPlaceholder("style", particle.getStyle().getName()) .addPlaceholder("data", particle.getDataString()) .build(); diff --git a/src/main/java/dev/esophose/playerparticles/command/OtherCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/OtherCommandModule.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/command/OtherCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/OtherCommandModule.java index 58433f2..b06e2be 100644 --- a/src/main/java/dev/esophose/playerparticles/command/OtherCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/OtherCommandModule.java @@ -1,12 +1,12 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.CommandManager; import dev.esophose.playerparticles.manager.DataManager; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.OtherPPlayer; import dev.esophose.playerparticles.particles.PPlayer; +import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.util.StringPlaceholders; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/dev/esophose/playerparticles/command/ReloadCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/ReloadCommandModule.java similarity index 97% rename from src/main/java/dev/esophose/playerparticles/command/ReloadCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/ReloadCommandModule.java index 5658435..17b74d2 100644 --- a/src/main/java/dev/esophose/playerparticles/command/ReloadCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/ReloadCommandModule.java @@ -1,11 +1,11 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.manager.ParticleStyleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; +import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.styles.DefaultStyles; import java.util.ArrayList; import java.util.List; @@ -19,7 +19,6 @@ public class ReloadCommandModule implements CommandModule { LocaleManager localeManager = playerParticles.getManager(LocaleManager.class); if (playerParticles.getManager(PermissionManager.class).canReloadPlugin(pplayer.getUnderlyingExecutor())) { playerParticles.reload(); - ParticleEffect.reloadSettings(); DefaultStyles.reloadSettings(playerParticles.getManager(ParticleStyleManager.class)); localeManager.sendMessage(pplayer, "reload-success"); playerParticles.getLogger().info("Reloaded configuration."); diff --git a/src/main/java/dev/esophose/playerparticles/command/RemoveCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/RemoveCommandModule.java similarity index 88% rename from src/main/java/dev/esophose/playerparticles/command/RemoveCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/RemoveCommandModule.java index 2ac19e9..02bda1f 100644 --- a/src/main/java/dev/esophose/playerparticles/command/RemoveCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/RemoveCommandModule.java @@ -1,12 +1,13 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.manager.LocaleManager; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.util.StringPlaceholders; import java.util.ArrayList; @@ -19,6 +20,7 @@ import org.bukkit.util.StringUtil; public class RemoveCommandModule implements CommandModule { public void onCommandExecute(PPlayer pplayer, String[] args) { + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); if (args.length == 0) { @@ -51,7 +53,7 @@ public class RemoveCommandModule implements CommandModule { PlayerParticlesAPI.getInstance().savePlayerParticleGroup(pplayer.getPlayer(), activeGroup); localeManager.sendMessage(pplayer, "remove-id-success", StringPlaceholders.single("id", id)); } else { // Removing by effect/style name - ParticleEffect effect = ParticleEffect.fromName(args[0]); + ParticleEffect effect = particleManager.getEffectFromName(args[0]); ParticleStyle style = ParticleStyle.fromName(args[0]); if (effect != null) { @@ -65,9 +67,9 @@ public class RemoveCommandModule implements CommandModule { if (toRemove.size() > 0) { PlayerParticlesAPI.getInstance().savePlayerParticleGroup(pplayer.getPlayer(), activeGroup); - localeManager.sendMessage(pplayer, "remove-effect-success", StringPlaceholders.builder("amount", toRemove.size()).addPlaceholder("effect", effect.getName()).build()); + localeManager.sendMessage(pplayer, "remove-effect-success", StringPlaceholders.builder("amount", toRemove.size()).addPlaceholder("effect", particleManager.getEffectSettings(effect).getName()).build()); } else { - localeManager.sendMessage(pplayer, "remove-effect-none", StringPlaceholders.single("effect", effect.getName())); + localeManager.sendMessage(pplayer, "remove-effect-none", StringPlaceholders.single("effect", particleManager.getEffectSettings(effect).getName())); } } else if (style != null) { Set toRemove = new HashSet<>(); @@ -91,12 +93,14 @@ public class RemoveCommandModule implements CommandModule { } public List onTabComplete(PPlayer pplayer, String[] args) { + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); + List matches = new ArrayList<>(); Set removeBy = new HashSet<>(); for (ParticlePair particle : pplayer.getActiveParticles()) { removeBy.add(String.valueOf(particle.getId())); - removeBy.add(particle.getEffect().getName()); + removeBy.add(particleManager.getEffectSettings(particle.getEffect()).getName()); removeBy.add(particle.getStyle().getName()); } diff --git a/src/main/java/dev/esophose/playerparticles/command/ResetCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/ResetCommandModule.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/command/ResetCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/ResetCommandModule.java index d56210d..d4be469 100644 --- a/src/main/java/dev/esophose/playerparticles/command/ResetCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/ResetCommandModule.java @@ -1,10 +1,10 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleGroup; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.util.StringPlaceholders; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/command/StylesCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/StylesCommandModule.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/command/StylesCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/StylesCommandModule.java index 65948cd..1534efa 100644 --- a/src/main/java/dev/esophose/playerparticles/command/StylesCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/StylesCommandModule.java @@ -1,9 +1,9 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; +import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.util.StringPlaceholders; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/command/ToggleCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/ToggleCommandModule.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/command/ToggleCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/ToggleCommandModule.java index f645cb3..7bbbc01 100644 --- a/src/main/java/dev/esophose/playerparticles/command/ToggleCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/ToggleCommandModule.java @@ -1,9 +1,9 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.particles.PPlayer; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.api.PlayerParticlesAPI; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/command/VersionCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/VersionCommandModule.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/command/VersionCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/VersionCommandModule.java index b8870b5..93b159d 100644 --- a/src/main/java/dev/esophose/playerparticles/command/VersionCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/VersionCommandModule.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.particles.PPlayer; +import dev.esophose.playerparticles.PlayerParticles; import java.util.ArrayList; import java.util.List; import org.bukkit.ChatColor; diff --git a/src/main/java/dev/esophose/playerparticles/command/WorldsCommandModule.java b/Plugin/src/main/java/dev/esophose/playerparticles/command/WorldsCommandModule.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/command/WorldsCommandModule.java rename to Plugin/src/main/java/dev/esophose/playerparticles/command/WorldsCommandModule.java index 476cb2c..4c53d10 100644 --- a/src/main/java/dev/esophose/playerparticles/command/WorldsCommandModule.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/command/WorldsCommandModule.java @@ -1,9 +1,9 @@ package dev.esophose.playerparticles.command; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; +import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.util.StringPlaceholders; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/config/CommentedConfigurationSection.java b/Plugin/src/main/java/dev/esophose/playerparticles/config/CommentedConfigurationSection.java similarity index 97% rename from src/main/java/dev/esophose/playerparticles/config/CommentedConfigurationSection.java rename to Plugin/src/main/java/dev/esophose/playerparticles/config/CommentedConfigurationSection.java index 52c4616..be0b248 100644 --- a/src/main/java/dev/esophose/playerparticles/config/CommentedConfigurationSection.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/config/CommentedConfigurationSection.java @@ -191,6 +191,18 @@ public class CommentedConfigurationSection implements ConfigurationSection { return this.config.isDouble(s); } + public float getFloat(String s) { + return (float) this.config.getDouble(s); + } + + public float getFloat(String s, float v) { + return (float) this.config.getDouble(s, v); + } + + public boolean isFloat(String s) { + return this.config.isDouble(s); + } + @Override public long getLong(String s) { return this.config.getLong(s); diff --git a/src/main/java/dev/esophose/playerparticles/config/CommentedFileConfiguration.java b/Plugin/src/main/java/dev/esophose/playerparticles/config/CommentedFileConfiguration.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/config/CommentedFileConfiguration.java rename to Plugin/src/main/java/dev/esophose/playerparticles/config/CommentedFileConfiguration.java diff --git a/src/main/java/dev/esophose/playerparticles/config/CommentedFileConfigurationHelper.java b/Plugin/src/main/java/dev/esophose/playerparticles/config/CommentedFileConfigurationHelper.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/config/CommentedFileConfigurationHelper.java rename to Plugin/src/main/java/dev/esophose/playerparticles/config/CommentedFileConfigurationHelper.java diff --git a/src/main/java/dev/esophose/playerparticles/database/DataMigration.java b/Plugin/src/main/java/dev/esophose/playerparticles/database/DataMigration.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/database/DataMigration.java rename to Plugin/src/main/java/dev/esophose/playerparticles/database/DataMigration.java diff --git a/src/main/java/dev/esophose/playerparticles/database/DatabaseConnector.java b/Plugin/src/main/java/dev/esophose/playerparticles/database/DatabaseConnector.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/database/DatabaseConnector.java rename to Plugin/src/main/java/dev/esophose/playerparticles/database/DatabaseConnector.java diff --git a/src/main/java/dev/esophose/playerparticles/database/MySQLConnector.java b/Plugin/src/main/java/dev/esophose/playerparticles/database/MySQLConnector.java similarity index 97% rename from src/main/java/dev/esophose/playerparticles/database/MySQLConnector.java rename to Plugin/src/main/java/dev/esophose/playerparticles/database/MySQLConnector.java index 45b3985..2e1d176 100644 --- a/src/main/java/dev/esophose/playerparticles/database/MySQLConnector.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/database/MySQLConnector.java @@ -19,7 +19,7 @@ public class MySQLConnector implements DatabaseConnector { config.setJdbcUrl("jdbc:mysql://" + hostname + ":" + port + "/" + database + "?useSSL=" + useSSL); config.setUsername(username); config.setPassword(password); - config.setMaximumPoolSize(5); + config.setMaximumPoolSize(2); try { this.hikari = new HikariDataSource(config); diff --git a/src/main/java/dev/esophose/playerparticles/database/SQLiteConnector.java b/Plugin/src/main/java/dev/esophose/playerparticles/database/SQLiteConnector.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/database/SQLiteConnector.java rename to Plugin/src/main/java/dev/esophose/playerparticles/database/SQLiteConnector.java diff --git a/src/main/java/dev/esophose/playerparticles/database/migrations/_1_InitialMigration.java b/Plugin/src/main/java/dev/esophose/playerparticles/database/migrations/_1_InitialMigration.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/database/migrations/_1_InitialMigration.java rename to Plugin/src/main/java/dev/esophose/playerparticles/database/migrations/_1_InitialMigration.java diff --git a/src/main/java/dev/esophose/playerparticles/gui/GuiActionButton.java b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiActionButton.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/gui/GuiActionButton.java rename to Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiActionButton.java diff --git a/src/main/java/dev/esophose/playerparticles/gui/GuiInventory.java b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventory.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/gui/GuiInventory.java rename to Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventory.java index 760f148..1bf348d 100644 --- a/src/main/java/dev/esophose/playerparticles/gui/GuiInventory.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventory.java @@ -1,9 +1,9 @@ package dev.esophose.playerparticles.gui; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.util.ParticleUtils; +import dev.esophose.playerparticles.PlayerParticles; import java.util.ArrayList; import java.util.List; import org.bukkit.Bukkit; diff --git a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryDefault.java b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryDefault.java similarity index 98% rename from src/main/java/dev/esophose/playerparticles/gui/GuiInventoryDefault.java rename to Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryDefault.java index ed838f0..7bbbec7 100644 --- a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryDefault.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryDefault.java @@ -1,18 +1,18 @@ package dev.esophose.playerparticles.gui; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon; import dev.esophose.playerparticles.manager.GuiManager; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.manager.ParticleGroupPresetManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; -import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.particles.ParticleProperty; import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.StringPlaceholders; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.api.PlayerParticlesAPI; import java.util.ArrayList; import java.util.List; import org.bukkit.Bukkit; @@ -110,7 +110,7 @@ public class GuiInventoryDefault extends GuiInventory { final ParticlePair editingParticle = pplayer.getPrimaryParticle(); boolean canEditPrimaryStyleAndData = pplayer.getActiveParticle(1) != null; - boolean doesEffectUseData = editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA); + boolean doesEffectUseData = editingParticle.getEffect().hasProperties(); // Edit Primary Effect GuiActionButton editPrimaryEffect = new GuiActionButton( diff --git a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditData.java b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditData.java similarity index 97% rename from src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditData.java rename to Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditData.java index d0ccd15..c026cf1 100644 --- a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditData.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditData.java @@ -6,10 +6,10 @@ import dev.esophose.playerparticles.manager.GuiManager; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; -import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor; -import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; -import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.particles.ParticleProperty; +import dev.esophose.playerparticles.particles.color.NoteColor; +import dev.esophose.playerparticles.particles.color.OrdinaryColor; import dev.esophose.playerparticles.util.NMSUtil; import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.StringPlaceholders; @@ -147,19 +147,17 @@ public class GuiInventoryEditData extends GuiInventory { this.fillBorder(BorderColor.MAGENTA); - ParticleEffect pe = editingParticle.getEffect(); - if (pe.hasProperty(ParticleProperty.COLORABLE)) { - if (pe == ParticleEffect.NOTE) { // Note data + ParticleEffect effect = editingParticle.getEffect(); + if (effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { + if (effect == ParticleEffect.NOTE) { // Note data this.populateNoteData(editingParticle, pageNumber, callbackList, callbackListPosition); } else { // Color data this.populateColorData(editingParticle, pageNumber, callbackList, callbackListPosition); } - } else if (pe.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - if (pe == ParticleEffect.ITEM) { // Item data - this.populateItemData(editingParticle, pageNumber, callbackList, callbackListPosition); - } else { // Block data - this.populateBlockData(editingParticle, pageNumber, callbackList, callbackListPosition); - } + } else if (effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA)) { + this.populateBlockData(editingParticle, pageNumber, callbackList, callbackListPosition); + } else if (effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA)) { + this.populateItemData(editingParticle, pageNumber, callbackList, callbackListPosition); } // Back Button diff --git a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditEffect.java b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditEffect.java similarity index 90% rename from src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditEffect.java rename to Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditEffect.java index 301e66a..824ef36 100644 --- a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditEffect.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditEffect.java @@ -1,15 +1,17 @@ package dev.esophose.playerparticles.gui; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon; import dev.esophose.playerparticles.manager.GuiManager; import dev.esophose.playerparticles.manager.LocaleManager; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; +import dev.esophose.playerparticles.particles.ParticleEffectSettings; import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.StringPlaceholders; +import dev.esophose.playerparticles.PlayerParticles; import java.util.List; import org.bukkit.Bukkit; @@ -18,6 +20,7 @@ public class GuiInventoryEditEffect extends GuiInventory { public GuiInventoryEditEffect(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List callbackList, int callbackListPosition) { super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-select-effect"))); + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class); @@ -34,11 +37,12 @@ public class GuiInventoryEditEffect extends GuiInventory { for (int i = (pageNumber - 1) * itemsPerPage; i < numberOfItems; i++) { ParticleEffect effect = effectsUserHasPermissionFor.get(i); + ParticleEffectSettings effectSettings = particleManager.getEffectSettings(effect); GuiActionButton selectButton = new GuiActionButton( slot, - GuiIcon.EFFECT.get(effect.getInternalName()), - localeManager.getLocaleMessage("gui-color-icon-name") + ParticleUtils.formatName(effect.getName()), - new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-effect-description", StringPlaceholders.single("effect", ParticleUtils.formatName(effect.getName())))}, + GuiIcon.EFFECT.get(effectSettings.getInternalName()), + localeManager.getLocaleMessage("gui-color-icon-name") + ParticleUtils.formatName(effectSettings.getName()), + new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-effect-description", StringPlaceholders.single("effect", ParticleUtils.formatName(effectSettings.getName())))}, (button, isShiftClick) -> { editingParticle.setEffect(effect); callbackList.get(callbackListPosition + 1).run(); diff --git a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditParticle.java b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditParticle.java similarity index 96% rename from src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditParticle.java rename to Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditParticle.java index 626e1ba..1d80878 100644 --- a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditParticle.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditParticle.java @@ -1,15 +1,15 @@ package dev.esophose.playerparticles.gui; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon; import dev.esophose.playerparticles.manager.GuiManager; import dev.esophose.playerparticles.manager.LocaleManager; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.particles.PPlayer; -import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.util.StringPlaceholders; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.api.PlayerParticlesAPI; import java.util.ArrayList; import java.util.List; import org.bukkit.Bukkit; @@ -19,6 +19,7 @@ public class GuiInventoryEditParticle extends GuiInventory { public GuiInventoryEditParticle(PPlayer pplayer, ParticlePair editingParticle) { super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-editing-particle", StringPlaceholders.single("id", editingParticle.getId())))); + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class); @@ -26,7 +27,7 @@ public class GuiInventoryEditParticle extends GuiInventory { // Particle Info Icon StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", editingParticle.getId()) - .addPlaceholder("effect", editingParticle.getEffect().getName()) + .addPlaceholder("effect", particleManager.getEffectSettings(editingParticle.getEffect()).getName()) .addPlaceholder("style", editingParticle.getStyle().getName()) .addPlaceholder("data", editingParticle.getDataString()) .build(); @@ -93,7 +94,7 @@ public class GuiInventoryEditParticle extends GuiInventory { this.actionButtons.add(editStyleButton); // Edit Data Button - boolean usesData = editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA); + boolean usesData = editingParticle.getEffect().hasProperties(); GuiActionButton editDataButton = new GuiActionButton(42, GuiIcon.EDIT_DATA.get(), localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-data"), diff --git a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditStyle.java b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditStyle.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditStyle.java rename to Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditStyle.java index 8347801..2f4b0b3 100644 --- a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditStyle.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryEditStyle.java @@ -1,6 +1,5 @@ package dev.esophose.playerparticles.gui; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon; import dev.esophose.playerparticles.manager.GuiManager; import dev.esophose.playerparticles.manager.LocaleManager; @@ -10,6 +9,7 @@ import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.StringPlaceholders; +import dev.esophose.playerparticles.PlayerParticles; import java.util.List; import org.bukkit.Bukkit; diff --git a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryLoadPresetGroups.java b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryLoadPresetGroups.java similarity index 95% rename from src/main/java/dev/esophose/playerparticles/gui/GuiInventoryLoadPresetGroups.java rename to Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryLoadPresetGroups.java index 2f701a5..c75816a 100644 --- a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryLoadPresetGroups.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryLoadPresetGroups.java @@ -1,18 +1,19 @@ package dev.esophose.playerparticles.gui; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon; import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; import dev.esophose.playerparticles.manager.GuiManager; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.manager.ParticleGroupPresetManager; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticleGroupPreset; import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.StringPlaceholders; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.api.PlayerParticlesAPI; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -23,6 +24,7 @@ public class GuiInventoryLoadPresetGroups extends GuiInventory { public GuiInventoryLoadPresetGroups(PPlayer pplayer, boolean isEndPoint) { super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-load-a-preset-group"))); + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class); @@ -44,7 +46,7 @@ public class GuiInventoryLoadPresetGroups extends GuiInventory { int i = 1; for (ParticlePair particle : particles) { StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", particle.getId()) - .addPlaceholder("effect", ParticleUtils.formatName(particle.getEffect().getName())) + .addPlaceholder("effect", ParticleUtils.formatName(particleManager.getEffectSettings(particle.getEffect()).getName())) .addPlaceholder("style", ParticleUtils.formatName(particle.getStyle().getName())) .addPlaceholder("data", particle.getDataString()) .build(); diff --git a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryManageGroups.java b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryManageGroups.java similarity index 97% rename from src/main/java/dev/esophose/playerparticles/gui/GuiInventoryManageGroups.java rename to Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryManageGroups.java index 9a047b7..fd62427 100644 --- a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryManageGroups.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryManageGroups.java @@ -1,19 +1,20 @@ package dev.esophose.playerparticles.gui; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.gui.hook.PlayerChatHook; import dev.esophose.playerparticles.gui.hook.PlayerChatHookData; import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon; import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; import dev.esophose.playerparticles.manager.GuiManager; import dev.esophose.playerparticles.manager.LocaleManager; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.StringPlaceholders; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.api.PlayerParticlesAPI; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -26,6 +27,7 @@ public class GuiInventoryManageGroups extends GuiInventory { public GuiInventoryManageGroups(PPlayer pplayer) { super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-manage-your-groups"))); + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class); @@ -48,7 +50,7 @@ public class GuiInventoryManageGroups extends GuiInventory { int i = 1; for (ParticlePair particle : particles) { StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", particle.getId()) - .addPlaceholder("effect", ParticleUtils.formatName(particle.getEffect().getName())) + .addPlaceholder("effect", ParticleUtils.formatName(particleManager.getEffectSettings(particle.getEffect()).getName())) .addPlaceholder("style", ParticleUtils.formatName(particle.getStyle().getName())) .addPlaceholder("data", particle.getDataString()) .build(); diff --git a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryManageParticles.java b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryManageParticles.java similarity index 96% rename from src/main/java/dev/esophose/playerparticles/gui/GuiInventoryManageParticles.java rename to Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryManageParticles.java index f5deacc..4b7df29 100644 --- a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryManageParticles.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryManageParticles.java @@ -1,17 +1,17 @@ package dev.esophose.playerparticles.gui; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon; import dev.esophose.playerparticles.manager.GuiManager; import dev.esophose.playerparticles.manager.LocaleManager; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.PPlayer; -import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.StringPlaceholders; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.api.PlayerParticlesAPI; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -22,6 +22,7 @@ public class GuiInventoryManageParticles extends GuiInventory { public GuiInventoryManageParticles(PPlayer pplayer) { super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-manage-your-particles"))); + ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class); @@ -36,7 +37,7 @@ public class GuiInventoryManageParticles extends GuiInventory { int maxIndex = 35; for (ParticlePair particle : particles) { StringPlaceholders stringPlaceholders = StringPlaceholders.builder("id", particle.getId()) - .addPlaceholder("effect", ParticleUtils.formatName(particle.getEffect().getName())) + .addPlaceholder("effect", ParticleUtils.formatName(particleManager.getEffectSettings(particle.getEffect()).getName())) .addPlaceholder("style", ParticleUtils.formatName(particle.getStyle().getName())) .addPlaceholder("data", particle.getDataString()) .build(); @@ -89,7 +90,7 @@ public class GuiInventoryManageParticles extends GuiInventory { callbacks.add(() -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1))); callbacks.add(() -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 2))); callbacks.add(() -> { - if (editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { + if (editingParticle.getEffect().hasProperties()) { guiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 3)); } else { callbacks.get(4).run(); diff --git a/src/main/java/dev/esophose/playerparticles/gui/hook/PlayerChatHook.java b/Plugin/src/main/java/dev/esophose/playerparticles/gui/hook/PlayerChatHook.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/gui/hook/PlayerChatHook.java rename to Plugin/src/main/java/dev/esophose/playerparticles/gui/hook/PlayerChatHook.java index 9161887..50adfff 100644 --- a/src/main/java/dev/esophose/playerparticles/gui/hook/PlayerChatHook.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/gui/hook/PlayerChatHook.java @@ -1,9 +1,9 @@ package dev.esophose.playerparticles.gui.hook; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.util.NMSUtil; import dev.esophose.playerparticles.util.StringPlaceholders; +import dev.esophose.playerparticles.PlayerParticles; import java.util.HashSet; import java.util.Set; import net.md_5.bungee.api.ChatMessageType; diff --git a/src/main/java/dev/esophose/playerparticles/gui/hook/PlayerChatHookData.java b/Plugin/src/main/java/dev/esophose/playerparticles/gui/hook/PlayerChatHookData.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/gui/hook/PlayerChatHookData.java rename to Plugin/src/main/java/dev/esophose/playerparticles/gui/hook/PlayerChatHookData.java diff --git a/src/main/java/dev/esophose/playerparticles/hook/ParticlePlaceholderExpansion.java b/Plugin/src/main/java/dev/esophose/playerparticles/hook/ParticlePlaceholderExpansion.java similarity index 92% rename from src/main/java/dev/esophose/playerparticles/hook/ParticlePlaceholderExpansion.java rename to Plugin/src/main/java/dev/esophose/playerparticles/hook/ParticlePlaceholderExpansion.java index a5f69ca..9c447fe 100644 --- a/src/main/java/dev/esophose/playerparticles/hook/ParticlePlaceholderExpansion.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/hook/ParticlePlaceholderExpansion.java @@ -1,9 +1,10 @@ package dev.esophose.playerparticles.hook; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.DataManager; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -46,7 +47,8 @@ public class ParticlePlaceholderExpansion extends PlaceholderExpansion { return null; if (placeholder.startsWith("particle_effect_")) { - return particle.getEffect().getName(); + ParticleManager particleManager = this.playerParticles.getManager(ParticleManager.class); + return particleManager.getEffectSettings(particle.getEffect()).getName(); } else if (placeholder.startsWith("particle_style_")) { return particle.getStyle().getName(); } else if (placeholder.startsWith("particle_data_")) { diff --git a/src/main/java/dev/esophose/playerparticles/hook/PlaceholderAPIHook.java b/Plugin/src/main/java/dev/esophose/playerparticles/hook/PlaceholderAPIHook.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/hook/PlaceholderAPIHook.java rename to Plugin/src/main/java/dev/esophose/playerparticles/hook/PlaceholderAPIHook.java diff --git a/src/main/java/dev/esophose/playerparticles/locale/EnglishLocale.java b/Plugin/src/main/java/dev/esophose/playerparticles/locale/EnglishLocale.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/locale/EnglishLocale.java rename to Plugin/src/main/java/dev/esophose/playerparticles/locale/EnglishLocale.java diff --git a/src/main/java/dev/esophose/playerparticles/locale/FrenchLocale.java b/Plugin/src/main/java/dev/esophose/playerparticles/locale/FrenchLocale.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/locale/FrenchLocale.java rename to Plugin/src/main/java/dev/esophose/playerparticles/locale/FrenchLocale.java diff --git a/src/main/java/dev/esophose/playerparticles/locale/GermanLocale.java b/Plugin/src/main/java/dev/esophose/playerparticles/locale/GermanLocale.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/locale/GermanLocale.java rename to Plugin/src/main/java/dev/esophose/playerparticles/locale/GermanLocale.java diff --git a/src/main/java/dev/esophose/playerparticles/locale/Locale.java b/Plugin/src/main/java/dev/esophose/playerparticles/locale/Locale.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/locale/Locale.java rename to Plugin/src/main/java/dev/esophose/playerparticles/locale/Locale.java diff --git a/src/main/java/dev/esophose/playerparticles/locale/RussianLocale.java b/Plugin/src/main/java/dev/esophose/playerparticles/locale/RussianLocale.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/locale/RussianLocale.java rename to Plugin/src/main/java/dev/esophose/playerparticles/locale/RussianLocale.java diff --git a/src/main/java/dev/esophose/playerparticles/locale/SimplifiedChineseLocale.java b/Plugin/src/main/java/dev/esophose/playerparticles/locale/SimplifiedChineseLocale.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/locale/SimplifiedChineseLocale.java rename to Plugin/src/main/java/dev/esophose/playerparticles/locale/SimplifiedChineseLocale.java diff --git a/src/main/java/dev/esophose/playerparticles/locale/VietnameseLocale.java b/Plugin/src/main/java/dev/esophose/playerparticles/locale/VietnameseLocale.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/locale/VietnameseLocale.java rename to Plugin/src/main/java/dev/esophose/playerparticles/locale/VietnameseLocale.java diff --git a/src/main/java/dev/esophose/playerparticles/manager/CommandManager.java b/Plugin/src/main/java/dev/esophose/playerparticles/manager/CommandManager.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/manager/CommandManager.java rename to Plugin/src/main/java/dev/esophose/playerparticles/manager/CommandManager.java index 5a36e33..c1acc17 100644 --- a/src/main/java/dev/esophose/playerparticles/manager/CommandManager.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/manager/CommandManager.java @@ -1,5 +1,6 @@ package dev.esophose.playerparticles.manager; +import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.api.PlayerParticlesAPI; import dev.esophose.playerparticles.command.AddCommandModule; @@ -22,7 +23,6 @@ import dev.esophose.playerparticles.command.StylesCommandModule; import dev.esophose.playerparticles.command.ToggleCommandModule; import dev.esophose.playerparticles.command.VersionCommandModule; import dev.esophose.playerparticles.command.WorldsCommandModule; -import dev.esophose.playerparticles.particles.PPlayer; import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/manager/ConfigurationManager.java b/Plugin/src/main/java/dev/esophose/playerparticles/manager/ConfigurationManager.java similarity index 99% rename from src/main/java/dev/esophose/playerparticles/manager/ConfigurationManager.java rename to Plugin/src/main/java/dev/esophose/playerparticles/manager/ConfigurationManager.java index 9d2d118..d8f6b23 100644 --- a/src/main/java/dev/esophose/playerparticles/manager/ConfigurationManager.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/manager/ConfigurationManager.java @@ -55,7 +55,7 @@ public class ConfigurationManager extends Manager { PARTICLE_RENDER_RANGE_FIXED_EFFECT("particle-render-range-fixed-effect", 192, "From how many blocks away should a player be able to see the particles from a fixed effect?"), RAINBOW_CYCLE_SPEED("rainbow-cycle-speed", 2, "How many out of 360 hue ticks to move per game tick", "Higher values make the rainbow cycle faster", "Note: Must be a positive whole number"), DUST_SIZE("dust-size", 1.0, "How large should dust particles appear?", "Note: Can include decimals", "Only works in 1.13+"), - + OVERRIDE_PARTICLE_VERSION("override-particle-version", -1, "Allows you to override the version of Minecraft that will be assumed for spawning particles", "This should follow this format: 9, 12, 15, etc. 9 means 1.9, 14 means 1.14... and so on"), MYSQL_SETTINGS("mysql-settings", null, "Settings for if you want to use MySQL for data management"), MYSQL_ENABLED("mysql-settings.enabled", false, "Enable MySQL", "If false, SQLite will be used instead"), MYSQL_HOSTNAME("mysql-settings.hostname", "", "MySQL Database Hostname"), diff --git a/src/main/java/dev/esophose/playerparticles/manager/DataManager.java b/Plugin/src/main/java/dev/esophose/playerparticles/manager/DataManager.java similarity index 96% rename from src/main/java/dev/esophose/playerparticles/manager/DataManager.java rename to Plugin/src/main/java/dev/esophose/playerparticles/manager/DataManager.java index 8939990..fee189e 100644 --- a/src/main/java/dev/esophose/playerparticles/manager/DataManager.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/manager/DataManager.java @@ -1,18 +1,18 @@ package dev.esophose.playerparticles.manager; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.database.DatabaseConnector; import dev.esophose.playerparticles.database.MySQLConnector; import dev.esophose.playerparticles.database.SQLiteConnector; -import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; import dev.esophose.playerparticles.particles.ConsolePPlayer; import dev.esophose.playerparticles.particles.FixedParticleEffect; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; -import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor; -import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; +import dev.esophose.playerparticles.particles.color.NoteColor; +import dev.esophose.playerparticles.particles.color.OrdinaryColor; import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.util.ParticleUtils; import java.sql.PreparedStatement; @@ -147,7 +147,7 @@ public class DataManager extends Manager { // Particle properties int id = result.getInt("id"); - ParticleEffect effect = ParticleEffect.fromInternalName(result.getString("effect")); + ParticleEffect effect = this.playerParticles.getManager(ParticleManager.class).getEffectFromInternalName(result.getString("effect")); ParticleStyle style = ParticleStyle.fromInternalName(result.getString("style")); Material itemMaterial = ParticleUtils.closestMatchWithFallback(true, result.getString("item_material")); Material blockMaterial = ParticleUtils.closestMatchWithFallback(true, result.getString("block_material")); @@ -212,7 +212,7 @@ public class DataManager extends Manager { // Particle properties int particleId = result.getInt("p_id"); - ParticleEffect effect = ParticleEffect.fromInternalName(result.getString("effect")); + ParticleEffect effect = this.playerParticles.getManager(ParticleManager.class).getEffectFromInternalName(result.getString("effect")); ParticleStyle style = ParticleStyle.fromInternalName(result.getString("style")); Material itemMaterial = ParticleUtils.closestMatchWithFallback(true, result.getString("item_material")); Material blockMaterial = ParticleUtils.closestMatchWithFallback(true, result.getString("block_material")); @@ -347,7 +347,7 @@ public class DataManager extends Manager { particlesStatement.setString(1, UUID.randomUUID().toString()); particlesStatement.setString(2, groupUUID); particlesStatement.setInt(3, particle.getId()); - particlesStatement.setString(4, particle.getEffect().getInternalName()); + particlesStatement.setString(4, this.playerParticles.getManager(ParticleManager.class).getEffectSettings(particle.getEffect()).getInternalName()); particlesStatement.setString(5, particle.getStyle().getInternalName()); particlesStatement.setString(6, particle.getItemMaterial().name()); particlesStatement.setString(7, particle.getBlockMaterial().name()); @@ -418,7 +418,7 @@ public class DataManager extends Manager { ParticlePair particle = fixedEffect.getParticlePair(); statement.setString(1, particleUUID); statement.setInt(2, fixedEffect.getId()); - statement.setString(3, particle.getEffect().getInternalName()); + statement.setString(3, this.playerParticles.getManager(ParticleManager.class).getEffectSettings(particle.getEffect()).getInternalName()); statement.setString(4, particle.getStyle().getInternalName()); statement.setString(5, particle.getItemMaterial().name()); statement.setString(6, particle.getBlockMaterial().name()); @@ -467,7 +467,7 @@ public class DataManager extends Manager { "WHERE uuid = (SELECT particle_uuid FROM " + this.getTablePrefix() + "fixed WHERE owner_uuid = ? AND id = ?)"; try (PreparedStatement statement = connection.prepareStatement(particleUpdateQuery)) { ParticlePair particle = fixedEffect.getParticlePair(); - statement.setString(1, particle.getEffect().getInternalName()); + statement.setString(1, this.playerParticles.getManager(ParticleManager.class).getEffectSettings(particle.getEffect()).getInternalName()); statement.setString(2, particle.getStyle().getInternalName()); statement.setString(3, particle.getItemMaterial().name()); statement.setString(4, particle.getBlockMaterial().name()); diff --git a/src/main/java/dev/esophose/playerparticles/manager/DataMigrationManager.java b/Plugin/src/main/java/dev/esophose/playerparticles/manager/DataMigrationManager.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/manager/DataMigrationManager.java rename to Plugin/src/main/java/dev/esophose/playerparticles/manager/DataMigrationManager.java index c6632d4..e4d8909 100644 --- a/src/main/java/dev/esophose/playerparticles/manager/DataMigrationManager.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/manager/DataMigrationManager.java @@ -1,10 +1,10 @@ package dev.esophose.playerparticles.manager; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.database.DataMigration; import dev.esophose.playerparticles.database.DatabaseConnector; import dev.esophose.playerparticles.database.SQLiteConnector; import dev.esophose.playerparticles.database.migrations._1_InitialMigration; +import dev.esophose.playerparticles.PlayerParticles; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.Arrays; diff --git a/src/main/java/dev/esophose/playerparticles/manager/GuiManager.java b/Plugin/src/main/java/dev/esophose/playerparticles/manager/GuiManager.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/manager/GuiManager.java rename to Plugin/src/main/java/dev/esophose/playerparticles/manager/GuiManager.java index 02343c0..dc3d104 100644 --- a/src/main/java/dev/esophose/playerparticles/manager/GuiManager.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/manager/GuiManager.java @@ -1,11 +1,11 @@ package dev.esophose.playerparticles.manager; +import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.gui.GuiInventory; import dev.esophose.playerparticles.gui.GuiInventoryDefault; import dev.esophose.playerparticles.gui.GuiInventoryLoadPresetGroups; import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; -import dev.esophose.playerparticles.particles.PPlayer; import java.util.ArrayList; import java.util.List; import org.bukkit.Bukkit; diff --git a/src/main/java/dev/esophose/playerparticles/manager/LocaleManager.java b/Plugin/src/main/java/dev/esophose/playerparticles/manager/LocaleManager.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/manager/LocaleManager.java rename to Plugin/src/main/java/dev/esophose/playerparticles/manager/LocaleManager.java index 705bd62..3a56603 100644 --- a/src/main/java/dev/esophose/playerparticles/manager/LocaleManager.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/manager/LocaleManager.java @@ -1,5 +1,6 @@ package dev.esophose.playerparticles.manager; +import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.hook.PlaceholderAPIHook; @@ -11,7 +12,6 @@ import dev.esophose.playerparticles.locale.RussianLocale; import dev.esophose.playerparticles.locale.SimplifiedChineseLocale; import dev.esophose.playerparticles.locale.VietnameseLocale; import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; -import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.util.StringPlaceholders; import java.io.File; import java.io.IOException; diff --git a/src/main/java/dev/esophose/playerparticles/manager/Manager.java b/Plugin/src/main/java/dev/esophose/playerparticles/manager/Manager.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/manager/Manager.java rename to Plugin/src/main/java/dev/esophose/playerparticles/manager/Manager.java diff --git a/src/main/java/dev/esophose/playerparticles/manager/ParticleGroupPresetManager.java b/Plugin/src/main/java/dev/esophose/playerparticles/manager/ParticleGroupPresetManager.java similarity index 86% rename from src/main/java/dev/esophose/playerparticles/manager/ParticleGroupPresetManager.java rename to Plugin/src/main/java/dev/esophose/playerparticles/manager/ParticleGroupPresetManager.java index 147cfcc..edfb12d 100644 --- a/src/main/java/dev/esophose/playerparticles/manager/ParticleGroupPresetManager.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/manager/ParticleGroupPresetManager.java @@ -1,14 +1,14 @@ package dev.esophose.playerparticles.manager; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; -import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor; -import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; -import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticleGroupPreset; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.particles.ParticleProperty; +import dev.esophose.playerparticles.particles.color.NoteColor; +import dev.esophose.playerparticles.particles.color.OrdinaryColor; import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.util.inputparser.InputParser; import java.io.File; @@ -119,7 +119,7 @@ public class ParticleGroupPresetManager extends Manager { String[] args = dataString.split(" "); InputParser inputParser = new InputParser(null, args); - if (effect.hasProperty(ParticleProperty.COLORABLE)) { + if (effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { if (effect == ParticleEffect.NOTE) { noteColorData = inputParser.next(NoteColor.class); if (noteColorData == null) { @@ -133,19 +133,17 @@ public class ParticleGroupPresetManager extends Manager { throw new Exception(); } } - } else if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { - blockData = inputParser.next(Material.class); - if (blockData == null || !blockData.isBlock()) { - PlayerParticles.getInstance().getLogger().severe("Invalid block: '" + dataString + "'!"); - throw new Exception(); - } - } else if (effect == ParticleEffect.ITEM) { - itemData = inputParser.next(Material.class); - if (itemData == null || itemData.isBlock()) { - PlayerParticles.getInstance().getLogger().severe("Invalid item: '" + dataString + "'!"); - throw new Exception(); - } + } else if (effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA)) { + blockData = inputParser.next(Material.class); + if (blockData == null || !blockData.isBlock()) { + PlayerParticles.getInstance().getLogger().severe("Invalid block: '" + dataString + "'!"); + throw new Exception(); + } + } else if (effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA)) { + itemData = inputParser.next(Material.class); + if (itemData == null || itemData.isBlock()) { + PlayerParticles.getInstance().getLogger().severe("Invalid item: '" + dataString + "'!"); + throw new Exception(); } } } diff --git a/src/main/java/dev/esophose/playerparticles/manager/ParticleManager.java b/Plugin/src/main/java/dev/esophose/playerparticles/manager/ParticleManager.java similarity index 52% rename from src/main/java/dev/esophose/playerparticles/manager/ParticleManager.java rename to Plugin/src/main/java/dev/esophose/playerparticles/manager/ParticleManager.java index a5dfb16..202b9fd 100644 --- a/src/main/java/dev/esophose/playerparticles/manager/ParticleManager.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/manager/ParticleManager.java @@ -2,25 +2,38 @@ package dev.esophose.playerparticles.manager; import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; +import dev.esophose.playerparticles.nms.wrapper.ParticleHandler; import dev.esophose.playerparticles.particles.ConsolePPlayer; import dev.esophose.playerparticles.particles.FixedParticleEffect; +import dev.esophose.playerparticles.particles.ParticleEffectSettings; +import dev.esophose.playerparticles.particles.color.NoteColor; +import dev.esophose.playerparticles.particles.color.OrdinaryColor; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.PPlayer; +import dev.esophose.playerparticles.particles.color.ParticleColor; import dev.esophose.playerparticles.particles.ParticleEffect; -import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor; -import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.particles.ParticleProperty; +import dev.esophose.playerparticles.particles.version.VersionMapping; import dev.esophose.playerparticles.styles.DefaultStyles; +import dev.esophose.playerparticles.util.NMSUtil; import java.awt.Color; +import java.util.ArrayList; import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Random; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; +import java.util.stream.Stream; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; +import org.bukkit.Particle.DustOptions; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -28,6 +41,9 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.MaterialData; +import org.bukkit.metadata.MetadataValue; import org.bukkit.scheduler.BukkitTask; public class ParticleManager extends Manager implements Listener, Runnable { @@ -42,6 +58,9 @@ public class ParticleManager extends Manager implements Listener, Runnable { */ private BukkitTask particleTask; + private ParticleHandler particleHandler; + private Map supportedParticleEffects; + /** * Rainbow particle effect hue and note color used for rainbow colorable effects */ @@ -66,6 +85,14 @@ public class ParticleManager extends Manager implements Listener, Runnable { if (this.particleTask != null) this.particleTask.cancel(); + int overrideVersion = Setting.OVERRIDE_PARTICLE_VERSION.getInt(); + VersionMapping versionMapping = VersionMapping.getVersionMapping(overrideVersion != -1 ? overrideVersion : NMSUtil.getVersionNumber()); + this.particleHandler = NMSUtil.getHandler(versionMapping); + + this.supportedParticleEffects = new HashMap<>(); + for (ParticleEffect particleEffect : versionMapping.getParticleEffectNameMapping().keySet()) + this.supportedParticleEffects.put(particleEffect, new ParticleEffectSettings(particleEffect)); + Bukkit.getScheduler().runTaskLater(this.playerParticles, () -> { long ticks = Setting.TICKS_PER_PARTICLE.getLong(); this.particleTask = Bukkit.getScheduler().runTaskTimerAsynchronously(this.playerParticles, this, 5, ticks); @@ -132,6 +159,7 @@ public class ParticleManager extends Manager implements Listener, Runnable { * The main loop to display all the particles * Does not display particles if the world is disabled or if the player is in spectator mode */ + @Override public void run() { this.playerParticles.getManager(ParticleStyleManager.class).updateTimers(); @@ -175,32 +203,34 @@ public class ParticleManager extends Manager implements Listener, Runnable { if (Setting.TOGGLE_ON_COMBAT.getBoolean() && pplayer.isInCombat()) return; + List particles; if (Setting.TOGGLE_ON_MOVE.getBoolean() && particle.getStyle().canToggleWithMovement() && pplayer.isMoving()) { - for (PParticle pparticle : DefaultStyles.FEET.getParticles(particle, location)) - ParticleEffect.display(particle, pparticle, particle.getStyle().hasLongRangeVisibility(), pplayer.getPlayer()); + particles = DefaultStyles.FEET.getParticles(particle, location); } else { - for (PParticle pparticle : particle.getStyle().getParticles(particle, location)) - ParticleEffect.display(particle, pparticle, particle.getStyle().hasLongRangeVisibility(), pplayer.getPlayer()); + particles = particle.getStyle().getParticles(particle, location); } - } + + for (PParticle pparticle : particles) + this.displayParticles(particle, pparticle, particle.getStyle().hasLongRangeVisibility(), pplayer.getPlayer()); + } } /** * An alternative method used for event styles * - * @param player The player the particles are spawning from, nullable for special cases + * @param source The player the particles are spawning from, nullable for special cases * @param world The world the particles are spawning in * @param particle The ParticlePair to use for getting particle settings * @param particles The particles to display * @param isLongRange If the particle can be viewed from long range */ - public void displayParticles(Player player, World world, ParticlePair particle, List particles, boolean isLongRange) { + public void displayParticles(Player source, World world, ParticlePair particle, List particles, boolean isLongRange) { PermissionManager permissionManager = this.playerParticles.getManager(PermissionManager.class); - if ((player != null && player.getGameMode() == GameMode.SPECTATOR) || !permissionManager.isWorldEnabled(world.getName())) + if ((source != null && source.getGameMode() == GameMode.SPECTATOR) || !permissionManager.isWorldEnabled(world.getName())) return; for (PParticle pparticle : particles) - ParticleEffect.display(particle, pparticle, isLongRange, player); + this.displayParticles(particle, pparticle, isLongRange, source); } /** @@ -211,7 +241,163 @@ public class ParticleManager extends Manager implements Listener, Runnable { private void displayFixedParticleEffect(FixedParticleEffect fixedEffect) { ParticlePair particle = fixedEffect.getParticlePair(); for (PParticle pparticle : particle.getStyle().getParticles(particle, fixedEffect.getLocation().clone().add(0, particle.getStyle().getFixedEffectOffset(), 0))) - ParticleEffect.display(particle, pparticle, true, null); + this.displayParticles(particle, pparticle, true, null); + } + + /** + * The main internal method for spawning particles + * + * @param particle The ParticlePair to spawn + * @param pparticle The particle data to spawn with + * @param isLongRange true if the particle is viewable at long distances, otherwise false + * @param owner The owner of the particle, nullable for no online owner + */ + @SuppressWarnings("deprecation") + private void displayParticles(ParticlePair particle, PParticle pparticle, boolean isLongRange, Player owner) { + ParticleEffect effect = particle.getEffect(); + int count = pparticle.isDirectional() ? 0 : 1; + + Object data = null; + Location center; + float offsetX, offsetY, offsetZ; + if (effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA)) { + if (NMSUtil.getVersionNumber() >= 13) { + data = particle.getSpawnMaterial().createBlockData(); + } else { + data = new MaterialData(particle.getSpawnMaterial()); + } + + center = pparticle.getLocation(false); + offsetX = pparticle.getOffsetX(); + offsetY = pparticle.getOffsetY(); + offsetZ = pparticle.getOffsetZ(); + } else if (effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA)) { + data = new ItemStack(particle.getSpawnMaterial()); + center = pparticle.getLocation(false); + offsetX = pparticle.getOffsetX(); + offsetY = pparticle.getOffsetY(); + offsetZ = pparticle.getOffsetZ(); + } else if (effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { + center = pparticle.getLocation(true); + + ParticleColor color = particle.getSpawnColor(); + if (effect == ParticleEffect.DUST && NMSUtil.getVersionNumber() >= 13) { + OrdinaryColor dustColor = (OrdinaryColor) color; + data = new DustOptions(org.bukkit.Color.fromRGB(dustColor.getRed(), dustColor.getGreen(), dustColor.getBlue()), Setting.DUST_SIZE.getFloat()); + offsetX = 0; + offsetY = 0; + offsetZ = 0; + } else { + offsetX = effect == ParticleEffect.DUST && color.getValueX() == 0 ? Float.MIN_VALUE : color.getValueX(); + offsetY = color.getValueY(); + offsetZ = color.getValueZ(); + } + } else { + center = pparticle.getLocation(false); + offsetX = pparticle.getOffsetX(); + offsetY = pparticle.getOffsetY(); + offsetZ = pparticle.getOffsetZ(); + } + + this.particleHandler.spawnParticle(effect, this.getPlayersInRange(center, isLongRange, owner), center, count, offsetX, offsetY, offsetZ, pparticle.getSpeed(), data); + } + + /** + * Gets a List of Players within the particle display range + * + * @param center The center of the radius to check around + * @param isLongRange If the particle can be viewed from long range + * @param owner The player that owns the particles + * @return A List of Players within the particle display range + */ + private List getPlayersInRange(Location center, boolean isLongRange, Player owner) { + List players = new ArrayList<>(); + int range = !isLongRange ? Setting.PARTICLE_RENDER_RANGE_PLAYER.getInt() : Setting.PARTICLE_RENDER_RANGE_FIXED_EFFECT.getInt(); + range *= range; + + for (PPlayer pplayer : PlayerParticles.getInstance().getManager(ParticleManager.class).getPPlayers()) { + Player p = pplayer.getPlayer(); + if (!this.canSee(p, owner)) + continue; + + if (p != null && pplayer.canSeeParticles() && p.getWorld().equals(center.getWorld()) && center.distanceSquared(p.getLocation()) <= range) + players.add(p); + } + + return players; + } + + /** + * Checks if a player can see another player + * + * @param player The player + * @param target The target + * @return True if player can see target, otherwise false + */ + private boolean canSee(Player player, Player target) { + if (player == null || target == null) + return true; + + for (MetadataValue meta : target.getMetadata("vanished")) + if (meta.asBoolean()) + return false; + + return player.canSee(target); + } + + /** + * @return A sorted List of all enabled ParticleEffects + */ + public List getEnabledEffects() { + return this.getEnabledEffectsStream() + .sorted(Comparator.comparing(x -> x.getValue().getName())) + .map(Entry::getKey) + .collect(Collectors.toList()); + } + + /** + * Gets the settings for a ParticleEffect + * + * @param particleEffect The ParticleEffect to get the settings for + * @return The settings for a ParticleEffect + */ + public ParticleEffectSettings getEffectSettings(ParticleEffect particleEffect) { + return this.supportedParticleEffects.get(particleEffect); + } + + /** + * Returns the ParticleEffect with the given name + * + * @param name Name of the ParticleEffect + * @return The ParticleEffect, or null if not found + */ + public ParticleEffect getEffectFromName(String name) { + return this.getEnabledEffectsStream() + .filter(x -> x.getValue().getName().equalsIgnoreCase(name)) + .findFirst() + .map(Entry::getKey) + .orElse(null); + } + + /** + * Returns the ParticleEffect with the given internal name + * + * @param internalName Internal name of the particle effect + * @return The ParticleEffect, or null if not found + */ + public ParticleEffect getEffectFromInternalName(String internalName) { + return this.getEnabledEffectsStream() + .filter(x -> x.getValue().getInternalName().equalsIgnoreCase(internalName)) + .findFirst() + .map(Entry::getKey) + .orElse(null); + } + + /** + * @return A stream of enabled ParticleEffects + */ + private Stream> getEnabledEffectsStream() { + return this.supportedParticleEffects.entrySet().stream().filter(x -> x.getValue().isEnabled()); } /** @@ -251,4 +437,5 @@ public class ParticleManager extends Manager implements Listener, Runnable { public NoteColor getRandomNoteParticleColor() { return new NoteColor(this.random.nextInt(25)); } + } diff --git a/src/main/java/dev/esophose/playerparticles/manager/ParticleStyleManager.java b/Plugin/src/main/java/dev/esophose/playerparticles/manager/ParticleStyleManager.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/manager/ParticleStyleManager.java rename to Plugin/src/main/java/dev/esophose/playerparticles/manager/ParticleStyleManager.java diff --git a/src/main/java/dev/esophose/playerparticles/manager/PermissionManager.java b/Plugin/src/main/java/dev/esophose/playerparticles/manager/PermissionManager.java similarity index 93% rename from src/main/java/dev/esophose/playerparticles/manager/PermissionManager.java rename to Plugin/src/main/java/dev/esophose/playerparticles/manager/PermissionManager.java index 50943d5..6d1eda8 100644 --- a/src/main/java/dev/esophose/playerparticles/manager/PermissionManager.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/manager/PermissionManager.java @@ -1,10 +1,10 @@ package dev.esophose.playerparticles.manager; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; import dev.esophose.playerparticles.particles.OtherPPlayer; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; import dev.esophose.playerparticles.styles.ParticleStyle; import java.util.ArrayList; import java.util.HashMap; @@ -76,6 +76,7 @@ public class PermissionManager extends Manager { // Register plugin permissions to Bukkit PluginManager pluginManager = Bukkit.getPluginManager(); + ParticleManager particleManager = this.playerParticles.getManager(ParticleManager.class); // Don't register the permissions if we already have, could have happened because of a reload? if (pluginManager.getPermission("playerparticles.*") != null) @@ -85,8 +86,8 @@ public class PermissionManager extends Manager { // Effects Map effectPermissions = new HashMap<>(); - for (ParticleEffect effect : ParticleEffect.values()) { - Permission permission = new Permission("playerparticles.effect." + effect.getInternalName()); + for (ParticleEffect effect : particleManager.getEnabledEffects()) { + Permission permission = new Permission("playerparticles.effect." + particleManager.getEffectSettings(effect).getInternalName()); pluginManager.addPermission(permission); effectPermissions.put(permission.getName(), true); } @@ -257,7 +258,8 @@ public class PermissionManager extends Manager { * @return True if the player has permission to use the effect */ public boolean hasEffectPermission(PPlayer player, ParticleEffect effect) { - return PPermission.EFFECT.check(player.getUnderlyingExecutor(), effect.getInternalName()); + ParticleManager particleManager = this.playerParticles.getManager(ParticleManager.class); + return PPermission.EFFECT.check(player.getUnderlyingExecutor(), particleManager.getEffectSettings(effect).getInternalName()); } /** @@ -279,10 +281,11 @@ public class PermissionManager extends Manager { * @return A String List of all effect names the given player has permission for */ public List getEffectNamesUserHasPermissionFor(PPlayer p) { + ParticleManager particleManager = this.playerParticles.getManager(ParticleManager.class); List list = new ArrayList<>(); - for (ParticleEffect pe : ParticleEffect.getEnabledEffects()) - if (this.hasEffectPermission(p, pe)) - list.add(pe.getName()); + for (ParticleEffect particleEffect : particleManager.getEnabledEffects()) + if (this.hasEffectPermission(p, particleEffect)) + list.add(particleManager.getEffectSettings(particleEffect).getName()); return list; } @@ -294,9 +297,9 @@ public class PermissionManager extends Manager { */ public List getStyleNamesUserHasPermissionFor(PPlayer p) { List list = new ArrayList<>(); - for (ParticleStyle ps : this.playerParticles.getManager(ParticleStyleManager.class).getStyles()) - if (this.hasStylePermission(p, ps)) - list.add(ps.getName()); + for (ParticleStyle particleStyle : this.playerParticles.getManager(ParticleStyleManager.class).getStyles()) + if (this.hasStylePermission(p, particleStyle)) + list.add(particleStyle.getName()); return list; } @@ -321,8 +324,9 @@ public class PermissionManager extends Manager { * @return A List of all effects the given player has permission for */ public List getEffectsUserHasPermissionFor(PPlayer p) { + ParticleManager particleManager = this.playerParticles.getManager(ParticleManager.class); List list = new ArrayList<>(); - for (ParticleEffect pe : ParticleEffect.getEnabledEffects()) + for (ParticleEffect pe : particleManager.getEnabledEffects()) if (this.hasEffectPermission(p, pe)) list.add(pe); return list; diff --git a/src/main/java/dev/esophose/playerparticles/manager/PluginUpdateManager.java b/Plugin/src/main/java/dev/esophose/playerparticles/manager/PluginUpdateManager.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/manager/PluginUpdateManager.java rename to Plugin/src/main/java/dev/esophose/playerparticles/manager/PluginUpdateManager.java diff --git a/src/main/java/dev/esophose/playerparticles/particles/ConsolePPlayer.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/ConsolePPlayer.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/particles/ConsolePPlayer.java rename to Plugin/src/main/java/dev/esophose/playerparticles/particles/ConsolePPlayer.java diff --git a/src/main/java/dev/esophose/playerparticles/particles/FixedParticleEffect.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/FixedParticleEffect.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/particles/FixedParticleEffect.java rename to Plugin/src/main/java/dev/esophose/playerparticles/particles/FixedParticleEffect.java diff --git a/src/main/java/dev/esophose/playerparticles/particles/OtherPPlayer.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/OtherPPlayer.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/particles/OtherPPlayer.java rename to Plugin/src/main/java/dev/esophose/playerparticles/particles/OtherPPlayer.java diff --git a/src/main/java/dev/esophose/playerparticles/particles/PParticle.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/PParticle.java similarity index 67% rename from src/main/java/dev/esophose/playerparticles/particles/PParticle.java rename to Plugin/src/main/java/dev/esophose/playerparticles/particles/PParticle.java index f4ef70b..770d394 100644 --- a/src/main/java/dev/esophose/playerparticles/particles/PParticle.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/particles/PParticle.java @@ -8,25 +8,25 @@ public class PParticle { * Data that determines where the particle will spawn */ private Location location; - private double speed; - private double xOff, yOff, zOff; private boolean directional; + private float offsetX, offsetY, offsetZ; + private float speed; /** * The constructor with all the fancy parameters for customization * * @param location The location to display the particle at - * @param xOff The offset for the x-axis - * @param yOff The offset for the y-axis - * @param zOff The offset for the z-axis + * @param offsetX The offset for the x-axis + * @param offsetY The offset for the y-axis + * @param offsetZ The offset for the z-axis * @param speed The speed the particle will move at * @param directional If the particle should use the x, y, and z offsets as directions instead */ - public PParticle(Location location, double xOff, double yOff, double zOff, double speed, boolean directional) { + public PParticle(Location location, float offsetX, float offsetY, float offsetZ, float speed, boolean directional) { this.location = location; - this.xOff = xOff; - this.yOff = yOff; - this.zOff = zOff; + this.offsetX = offsetX; + this.offsetY = offsetY; + this.offsetZ = offsetZ; this.speed = speed; this.directional = directional; } @@ -35,13 +35,13 @@ public class PParticle { * The constructor with all the fancy parameters for customization * * @param location The location to display the particle at - * @param xOff The offset for the x-axis - * @param yOff The offset for the y-axis - * @param zOff The offset for the z-axis + * @param offsetX The offset for the x-axis + * @param offsetY The offset for the y-axis + * @param offsetZ The offset for the z-axis * @param speed The speed the particle will move at */ - public PParticle(Location location, double xOff, double yOff, double zOff, double speed) { - this(location, xOff, yOff, zOff, speed, false); + public PParticle(Location location, float offsetX, float offsetY, float offsetZ, float speed) { + this(location, offsetX, offsetY, offsetZ, speed, false); } /** @@ -70,22 +70,13 @@ public class PParticle { double y = this.location.getY(); double z = this.location.getZ(); - x += this.xOff * 1.75D * (Math.random() > 0.5 ? Math.random() : -Math.random()); - y += this.yOff * 1.75D * (Math.random() > 0.5 ? Math.random() : -Math.random()); - z += this.zOff * 1.75D * (Math.random() > 0.5 ? Math.random() : -Math.random()); + x += this.offsetX * 1.75D * (Math.random() > 0.5 ? Math.random() : -Math.random()); + y += this.offsetY * 1.75D * (Math.random() > 0.5 ? Math.random() : -Math.random()); + z += this.offsetZ * 1.75D * (Math.random() > 0.5 ? Math.random() : -Math.random()); return new Location(this.location.getWorld(), x, y, z); } - /** - * Gets the speed of the particle - * - * @return The particle's speed - */ - public double getSpeed() { - return this.speed; - } - /** * Gets if the particle is directional * @@ -100,8 +91,8 @@ public class PParticle { * * @return The x-axis offset */ - public double getXOff() { - return this.xOff; + public float getOffsetX() { + return this.offsetX; } /** @@ -109,8 +100,8 @@ public class PParticle { * * @return The y-axis offset */ - public double getYOff() { - return this.yOff; + public float getOffsetY() { + return this.offsetY; } /** @@ -118,8 +109,17 @@ public class PParticle { * * @return The z-axis offset */ - public double getZOff() { - return this.zOff; + public float getOffsetZ() { + return this.offsetZ; + } + + /** + * Gets the speed of the particle + * + * @return The particle's speed + */ + public float getSpeed() { + return this.speed; } } diff --git a/src/main/java/dev/esophose/playerparticles/particles/PPlayer.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/PPlayer.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/particles/PPlayer.java rename to Plugin/src/main/java/dev/esophose/playerparticles/particles/PPlayer.java diff --git a/Plugin/src/main/java/dev/esophose/playerparticles/particles/ParticleEffectSettings.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/ParticleEffectSettings.java new file mode 100644 index 0000000..2d115a7 --- /dev/null +++ b/Plugin/src/main/java/dev/esophose/playerparticles/particles/ParticleEffectSettings.java @@ -0,0 +1,105 @@ +package dev.esophose.playerparticles.particles; + +import com.google.common.collect.ObjectArrays; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; +import dev.esophose.playerparticles.util.ParticleUtils; +import java.io.File; +import java.util.Arrays; +import java.util.List; + +public class ParticleEffectSettings { + + private static final List disabledByDefaultParticleEffects = Arrays.asList(ParticleEffect.ELDER_GUARDIAN, ParticleEffect.FLASH); + + private ParticleEffect particleEffect; + + private CommentedFileConfiguration config; + private boolean enabledByDefault; + + private String effectName; + private boolean enabled; + + public ParticleEffectSettings(ParticleEffect particleEffect) { + this.particleEffect = particleEffect; + this.enabledByDefault = !disabledByDefaultParticleEffects.contains(particleEffect); + + this.setDefaultSettings(); + this.loadSettings(false); + } + + /** + * Sets the default settings for the particle type + */ + private void setDefaultSettings() { + File directory = new File(PlayerParticles.getInstance().getDataFolder(), "effects"); + directory.mkdirs(); + + File file = new File(directory, this.getInternalName() + ".yml"); + this.config = CommentedFileConfiguration.loadConfiguration(PlayerParticles.getInstance(), file); + + boolean changed = this.setIfNotExists("effect-name", this.getInternalName(), "The name the effect will display as"); + changed |= this.setIfNotExists("enabled", this.enabledByDefault, "If the effect is enabled or not"); + + if (changed) + this.config.save(); + } + + /** + * Loads the settings shared for each style then calls loadSettings(CommentedFileConfiguration) + * + * @param reloadConfig If the settings should be reloaded or not + */ + public void loadSettings(boolean reloadConfig) { + if (reloadConfig) + this.setDefaultSettings(); + + this.effectName = this.config.getString("effect-name"); + this.enabled = this.config.getBoolean("enabled"); + } + + /** + * Sets a value to the config if it doesn't already exist + * + * @param setting The setting name + * @param value The setting value + * @param comments Comments for the setting + * @return true if changes were made + */ + private boolean setIfNotExists(String setting, Object value, String... comments) { + if (this.config.get(setting) != null) + return false; + + String defaultMessage = "Default: "; + if (value instanceof String && ParticleUtils.containsConfigSpecialCharacters((String) value)) { + defaultMessage += "'" + value + "'"; + } else { + defaultMessage += value; + } + + this.config.set(setting, value, ObjectArrays.concat(comments, new String[] { defaultMessage }, String.class)); + return true; + } + + /** + * @return the internal name of this particle effect that will never change + */ + public String getInternalName() { + return this.particleEffect.name().toLowerCase(); + } + + /** + * @return the name that the style will display to the users as + */ + public String getName() { + return this.effectName; + } + + /** + * @return true if this effect is enabled, otherwise false + */ + public boolean isEnabled() { + return this.enabled; + } + +} diff --git a/src/main/java/dev/esophose/playerparticles/particles/ParticleGroup.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/ParticleGroup.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/particles/ParticleGroup.java rename to Plugin/src/main/java/dev/esophose/playerparticles/particles/ParticleGroup.java diff --git a/src/main/java/dev/esophose/playerparticles/particles/ParticleGroupPreset.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/ParticleGroupPreset.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/particles/ParticleGroupPreset.java rename to Plugin/src/main/java/dev/esophose/playerparticles/particles/ParticleGroupPreset.java diff --git a/src/main/java/dev/esophose/playerparticles/particles/ParticlePair.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/ParticlePair.java similarity index 93% rename from src/main/java/dev/esophose/playerparticles/particles/ParticlePair.java rename to Plugin/src/main/java/dev/esophose/playerparticles/particles/ParticlePair.java index db0ff2b..5df4683 100644 --- a/src/main/java/dev/esophose/playerparticles/particles/ParticlePair.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/particles/ParticlePair.java @@ -3,10 +3,9 @@ package dev.esophose.playerparticles.particles; import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.manager.ParticleManager; -import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor; -import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; -import dev.esophose.playerparticles.particles.ParticleEffect.ParticleColor; -import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; +import dev.esophose.playerparticles.particles.color.NoteColor; +import dev.esophose.playerparticles.particles.color.OrdinaryColor; +import dev.esophose.playerparticles.particles.color.ParticleColor; import dev.esophose.playerparticles.styles.DefaultStyles; import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.util.ParticleUtils; @@ -205,7 +204,7 @@ public class ParticlePair { public ParticleColor getSpawnColor() { ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); - if (this.effect.hasProperty(ParticleProperty.COLORABLE)) { + if (this.effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { if (this.effect == ParticleEffect.NOTE) { if (this.noteColor.equals(NoteColor.RAINBOW)) { return particleManager.getRainbowNoteParticleColor(); @@ -232,12 +231,10 @@ public class ParticlePair { * @return The Material the current particle effect requires */ public Material getSpawnMaterial() { - if (this.effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - if (this.effect == ParticleEffect.ITEM) { - return this.itemMaterial; - } else { - return this.blockMaterial; - } + if (this.effect.hasProperty(ParticleProperty.REQUIRES_ITEM_DATA)) { + return this.itemMaterial; + } else if (this.effect.hasProperty(ParticleProperty.REQUIRES_BLOCK_DATA)) { + return this.blockMaterial; } return null; } @@ -253,7 +250,7 @@ public class ParticlePair { return this.blockMaterial.toString().toLowerCase(); } else if (this.effect == ParticleEffect.ITEM) { return this.itemMaterial.toString().toLowerCase(); - } else if (this.effect.hasProperty(ParticleProperty.COLORABLE)) { + } else if (this.effect.hasProperty(ParticleProperty.REQUIRES_COLOR_DATA)) { if (this.effect == ParticleEffect.NOTE) { if (this.noteColor.equals(NoteColor.RAINBOW)) { return localeManager.getLocaleMessage("rainbow"); diff --git a/Plugin/src/main/java/dev/esophose/playerparticles/particles/color/NoteColor.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/color/NoteColor.java new file mode 100644 index 0000000..9d1b530 --- /dev/null +++ b/Plugin/src/main/java/dev/esophose/playerparticles/particles/color/NoteColor.java @@ -0,0 +1,94 @@ +package dev.esophose.playerparticles.particles.color; + +import dev.esophose.playerparticles.particles.ParticleEffect; +import java.util.Objects; + +/** + * Represents the color for the {@link ParticleEffect#NOTE} effect + *

+ * This class is part of the ParticleEffect Library and follows the + * same usage conditions + * + * @author DarkBlade12 + * @since 1.7 + */ +public final class NoteColor implements ParticleColor { + public static final NoteColor RAINBOW = new NoteColor(99); + public static final NoteColor RANDOM = new NoteColor(98); + + private final int note; + + /** + * Construct a new note color + * + * @param note Note id which determines color + * @throws IllegalArgumentException If the note value is lower than 0 or + * higher than 24 + */ + public NoteColor(int note) throws IllegalArgumentException { + if (note == 99 || note == 98) { // Allow rainbow and random values + this.note = note; + } else { + if (note < 0) { + throw new IllegalArgumentException("The note value is lower than 0"); + } + if (note > 24) { + throw new IllegalArgumentException("The note value is higher than 24"); + } + this.note = note; + } + } + + /** + * Returns the note value + * + * @return The note value + */ + public int getNote() { + return this.note; + } + + /** + * Returns the note value divided by 24 + * + * @return The offsetX value + */ + @Override + public float getValueX() { + return (float) this.note / 24F; + } + + /** + * Returns zero because the offsetY value is unused + * + * @return zero + */ + @Override + public float getValueY() { + return 0; + } + + /** + * Returns zero because the offsetZ value is unused + * + * @return zero + */ + @Override + public float getValueZ() { + return 0; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof NoteColor)) + return false; + NoteColor otherColor = (NoteColor) other; + return this.note == otherColor.note; + } + + @Override + public int hashCode() { + return Objects.hashCode(this.note); + } + +} \ No newline at end of file diff --git a/Plugin/src/main/java/dev/esophose/playerparticles/particles/color/OrdinaryColor.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/color/OrdinaryColor.java new file mode 100644 index 0000000..77ed4dc --- /dev/null +++ b/Plugin/src/main/java/dev/esophose/playerparticles/particles/color/OrdinaryColor.java @@ -0,0 +1,138 @@ +package dev.esophose.playerparticles.particles.color; + +import dev.esophose.playerparticles.particles.ParticleEffect; +import java.util.Objects; + +/** + * Represents the color for effects like {@link ParticleEffect#ENTITY_EFFECT}, + * {@link ParticleEffect#AMBIENT_ENTITY_EFFECT} and {@link ParticleEffect#NOTE} + *

+ * This class is part of the ParticleEffect Library and follows the + * same usage conditions + * + * @author DarkBlade12 + */ +public final class OrdinaryColor implements ParticleColor { + public static final OrdinaryColor RAINBOW = new OrdinaryColor(999, 999, 999); + public static final OrdinaryColor RANDOM = new OrdinaryColor(998, 998, 998); + + private final int red; + private final int green; + private final int blue; + + /** + * Construct a new ordinary color + * + * @param red Red value of the RGB format + * @param green Green value of the RGB format + * @param blue Blue value of the RGB format + * @throws IllegalArgumentException If one of the values is lower than 0 + * or higher than 255 + */ + public OrdinaryColor(int red, int green, int blue) throws IllegalArgumentException { + if ((red == 999 && green == 999 && blue == 999) || (red == 998 && green == 998 && blue == 998)) { // Allow rainbow and random values + this.red = red; + this.green = green; + this.blue = blue; + } else { + if (red < 0) { + throw new IllegalArgumentException("The red value is lower than 0"); + } + if (red > 255) { + throw new IllegalArgumentException("The red value is higher than 255"); + } + this.red = red; + if (green < 0) { + throw new IllegalArgumentException("The green value is lower than 0"); + } + if (green > 255) { + throw new IllegalArgumentException("The green value is higher than 255"); + } + this.green = green; + if (blue < 0) { + throw new IllegalArgumentException("The blue value is lower than 0"); + } + if (blue > 255) { + throw new IllegalArgumentException("The blue value is higher than 255"); + } + this.blue = blue; + } + } + + /** + * Returns the red value of the RGB format + * + * @return The red value + */ + public int getRed() { + return this.red; + } + + /** + * Returns the green value of the RGB format + * + * @return The green value + */ + public int getGreen() { + return this.green; + } + + /** + * Returns the blue value of the RGB format + * + * @return The blue value + */ + public int getBlue() { + return this.blue; + } + + /** + * Returns the red value divided by 255 + * + * @return The offsetX value + */ + @Override + public float getValueX() { + if (this.equals(OrdinaryColor.RAINBOW) || this.equals(OrdinaryColor.RANDOM)) + return 0F; + return (float) this.red / 255F; + } + + /** + * Returns the green value divided by 255 + * + * @return The offsetY value + */ + @Override + public float getValueY() { + if (this.equals(OrdinaryColor.RAINBOW) || this.equals(OrdinaryColor.RANDOM)) + return 0F; + return (float) this.green / 255F; + } + + /** + * Returns the blue value divided by 255 + * + * @return The offsetZ value + */ + @Override + public float getValueZ() { + if (this.equals(OrdinaryColor.RAINBOW) || this.equals(OrdinaryColor.RANDOM)) + return 0F; + return (float) this.blue / 255F; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof OrdinaryColor)) + return false; + OrdinaryColor otherColor = (OrdinaryColor) other; + return this.red == otherColor.red && this.green == otherColor.green && this.blue == otherColor.blue; + } + + @Override + public int hashCode() { + return Objects.hash(this.red, this.green, this.blue); + } + +} \ No newline at end of file diff --git a/Plugin/src/main/java/dev/esophose/playerparticles/particles/color/ParticleColor.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/color/ParticleColor.java new file mode 100644 index 0000000..49a4fc4 --- /dev/null +++ b/Plugin/src/main/java/dev/esophose/playerparticles/particles/color/ParticleColor.java @@ -0,0 +1,38 @@ +package dev.esophose.playerparticles.particles.color; + +import dev.esophose.playerparticles.particles.ParticleEffect; + +/** + * Represents the color for effects like {@link ParticleEffect#ENTITY_EFFECT}, + * {@link ParticleEffect#AMBIENT_ENTITY_EFFECT}, {@link ParticleEffect#DUST} + * and {@link ParticleEffect#NOTE} + *

+ * This class is part of the ParticleEffect Library and follows the + * same usage conditions + * + * @author DarkBlade12 + * @since 1.7 + */ +public interface ParticleColor { + /** + * Returns the value for the offsetX field + * + * @return The offsetX value + */ + float getValueX(); + + /** + * Returns the value for the offsetY field + * + * @return The offsetY value + */ + float getValueY(); + + /** + * Returns the value for the offsetZ field + * + * @return The offsetZ value + */ + float getValueZ(); + +} \ No newline at end of file diff --git a/src/main/java/dev/esophose/playerparticles/particles/listener/PPlayerCombatListener.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/listener/PPlayerCombatListener.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/particles/listener/PPlayerCombatListener.java rename to Plugin/src/main/java/dev/esophose/playerparticles/particles/listener/PPlayerCombatListener.java diff --git a/src/main/java/dev/esophose/playerparticles/particles/listener/PPlayerMovementListener.java b/Plugin/src/main/java/dev/esophose/playerparticles/particles/listener/PPlayerMovementListener.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/particles/listener/PPlayerMovementListener.java rename to Plugin/src/main/java/dev/esophose/playerparticles/particles/listener/PPlayerMovementListener.java diff --git a/src/main/java/dev/esophose/playerparticles/styles/DefaultParticleStyle.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/DefaultParticleStyle.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/DefaultParticleStyle.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/DefaultParticleStyle.java diff --git a/src/main/java/dev/esophose/playerparticles/styles/DefaultStyles.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/DefaultStyles.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/DefaultStyles.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/DefaultStyles.java index 2548336..7ac5b3b 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/DefaultStyles.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/DefaultStyles.java @@ -1,7 +1,7 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.ParticleStyleManager; +import dev.esophose.playerparticles.PlayerParticles; import org.bukkit.Bukkit; import org.bukkit.event.Listener; import org.bukkit.plugin.PluginManager; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyle.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyle.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyle.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyle.java index fa84857..7b1acac 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyle.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyle.java @@ -1,9 +1,9 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.manager.ParticleStyleManager; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; import java.util.List; import org.bukkit.Location; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleArrows.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleArrows.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleArrows.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleArrows.java index e24a17b..17126eb 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleArrows.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleArrows.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBatman.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBatman.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBatman.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBatman.java index 3bb779f..df87483 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBatman.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBatman.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.VectorUtils; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBeam.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBeam.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBeam.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBeam.java index 5bc53cf..722efd4 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBeam.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBeam.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBlockBreak.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBlockBreak.java similarity index 95% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBlockBreak.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBlockBreak.java index 4ab81d7..2c8b9a3 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBlockBreak.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBlockBreak.java @@ -1,12 +1,12 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.manager.DataManager; import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import java.util.ArrayList; import java.util.List; import org.bukkit.Location; @@ -19,8 +19,8 @@ import org.bukkit.event.block.BlockBreakEvent; public class ParticleStyleBlockBreak extends DefaultParticleStyle implements Listener { private int particleAmount; - private double particleSpread; - private double particleSpeed; + private float particleSpread; + private float particleSpeed; public ParticleStyleBlockBreak() { super("blockbreak", false, false, 0); @@ -54,7 +54,7 @@ public class ParticleStyleBlockBreak extends DefaultParticleStyle implements Lis protected void loadSettings(CommentedFileConfiguration config) { this.particleAmount = config.getInt("particle-amount"); this.particleSpread = config.getInt("particle-spread"); - this.particleSpeed = config.getDouble("particle-speed"); + this.particleSpeed = config.getFloat("particle-speed"); } @EventHandler(priority = EventPriority.MONITOR) diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBlockPlace.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBlockPlace.java similarity index 95% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBlockPlace.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBlockPlace.java index 3b5aa5c..7d1b5ef 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBlockPlace.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleBlockPlace.java @@ -1,12 +1,12 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.manager.DataManager; import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import java.util.ArrayList; import java.util.List; import org.bukkit.Location; @@ -19,8 +19,8 @@ import org.bukkit.event.block.BlockPlaceEvent; public class ParticleStyleBlockPlace extends DefaultParticleStyle implements Listener { private int particleAmount; - private double particleSpread; - private double particleSpeed; + private float particleSpread; + private float particleSpeed; public ParticleStyleBlockPlace() { super("blockplace", false, false, 0); @@ -54,7 +54,7 @@ public class ParticleStyleBlockPlace extends DefaultParticleStyle implements Lis protected void loadSettings(CommentedFileConfiguration config) { this.particleAmount = config.getInt("particle-amount"); this.particleSpread = config.getInt("particle-spread"); - this.particleSpeed = config.getDouble("particle-speed"); + this.particleSpeed = config.getFloat("particle-speed"); } @EventHandler(priority = EventPriority.MONITOR) diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCelebration.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCelebration.java similarity index 98% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCelebration.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCelebration.java index cc61927..44e9af1 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCelebration.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCelebration.java @@ -1,7 +1,5 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.particles.FixedParticleEffect; @@ -9,6 +7,8 @@ import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.Collections; @@ -96,7 +96,7 @@ public class ParticleStyleCelebration extends DefaultParticleStyle { this.baseDistanceFrom = config.getDouble("base-distance-from"); this.distanceFromRandomizer = config.getDouble("distance-from-randomizer"); this.fuseSpacing = config.getDouble("fuse-spacing"); - this.fuseEffect = ParticleEffect.fromInternalName(config.getString("fuse-effect")); + this.fuseEffect = PlayerParticles.getInstance().getManager(ParticleManager.class).getEffectFromInternalName(config.getString("fuse-effect")); if (this.fuseEffect == null) this.fuseEffect = ParticleEffect.FIREWORK; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleChains.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleChains.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleChains.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleChains.java index d49291a..bd249af 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleChains.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleChains.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import java.util.ArrayList; import java.util.List; import org.bukkit.Location; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCompanion.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCompanion.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCompanion.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCompanion.java index 3881d5f..19623f7 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCompanion.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCompanion.java @@ -23,9 +23,9 @@ */ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCube.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCube.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCube.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCube.java index c649049..45eed8e 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCube.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleCube.java @@ -23,9 +23,9 @@ */ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.VectorUtils; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleFeet.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleFeet.java similarity index 79% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleFeet.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleFeet.java index 7c67c54..71f0b33 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleFeet.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleFeet.java @@ -1,17 +1,17 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import java.util.ArrayList; import java.util.List; import org.bukkit.Location; public class ParticleStyleFeet extends DefaultParticleStyle { - private double feetOffset; - private double particleSpreadX, particleSpreadY, particleSpreadZ; - private double particleSpeed; + private float feetOffset; + private float particleSpreadX, particleSpreadY, particleSpreadZ; + private float particleSpeed; private int particlesPerTick; public ParticleStyleFeet() { @@ -43,11 +43,11 @@ public class ParticleStyleFeet extends DefaultParticleStyle { @Override protected void loadSettings(CommentedFileConfiguration config) { - this.feetOffset = config.getDouble("feet-offset"); - this.particleSpreadX = config.getDouble("particle-spread-x"); - this.particleSpreadY = config.getDouble("particle-spread-y"); - this.particleSpreadZ = config.getDouble("particle-spread-z"); - this.particleSpeed = config.getDouble("particle-speed"); + this.feetOffset = config.getFloat("feet-offset"); + this.particleSpreadX = config.getFloat("particle-spread-x"); + this.particleSpreadY = config.getFloat("particle-spread-y"); + this.particleSpreadZ = config.getFloat("particle-spread-z"); + this.particleSpeed = config.getFloat("particle-speed"); this.particlesPerTick = config.getInt("particles-per-tick"); } diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleHalo.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleHalo.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleHalo.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleHalo.java index 79442b6..fcb6d2d 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleHalo.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleHalo.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleHurt.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleHurt.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleHurt.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleHurt.java index e2ca3aa..dde0208 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleHurt.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleHurt.java @@ -1,12 +1,12 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.manager.DataManager; import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import java.util.ArrayList; import java.util.List; import org.bukkit.Location; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleInvocation.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleInvocation.java similarity index 84% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleInvocation.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleInvocation.java index e823946..e800bfe 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleInvocation.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleInvocation.java @@ -1,9 +1,9 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; @@ -17,8 +17,8 @@ public class ParticleStyleInvocation extends DefaultParticleStyle { private int points; private double radius; private int numSteps; - private double playerOffset; - private double speedMultiplier; + private float playerOffset; + private float speedMultiplier; public ParticleStyleInvocation() { super("invocation", true, true, 0.5); @@ -26,7 +26,7 @@ public class ParticleStyleInvocation extends DefaultParticleStyle { public List getParticles(ParticlePair particle, Location location) { List particles = new ArrayList<>(); - double speed = this.getSpeedByEffect(particle.getEffect()) * this.speedMultiplier; + float speed = this.getSpeedByEffect(particle.getEffect()) * this.speedMultiplier; // Circle around everything, spawn less often if (this.circleStep % 5 == 0) { @@ -44,8 +44,8 @@ public class ParticleStyleInvocation extends DefaultParticleStyle { double dy = this.playerOffset; double dz = MathL.sin(this.step + (Math.PI * 2 * ((double) i / this.points))) * this.radius; double angle = Math.atan2(dz, dx); - double xAng = -MathL.cos(angle); - double zAng = -MathL.sin(angle); + float xAng = -MathL.cos(angle); + float zAng = -MathL.sin(angle); particles.add(new PParticle(location.clone().add(dx, dy, dz), xAng, 0, zAng, speed, true)); } @@ -55,22 +55,22 @@ public class ParticleStyleInvocation extends DefaultParticleStyle { double dy = this.playerOffset; double dz = MathL.sin(-this.step + (Math.PI * 2 * ((double) i / this.points))) * this.radius; double angle = Math.atan2(dz, dx); - double xAng = -MathL.cos(angle); - double zAng = -MathL.sin(angle); + float xAng = -MathL.cos(angle); + float zAng = -MathL.sin(angle); particles.add(new PParticle(location.clone().add(dx, dy, dz), xAng, 0, zAng, speed, true)); } return particles; } - private double getSpeedByEffect(ParticleEffect effect) { + private float getSpeedByEffect(ParticleEffect effect) { switch (effect) { case CRIT: case DAMAGE_INDICATOR: case ENCHANTED_HIT: return 2; case DRAGON_BREATH: - return 0.01; + return 0.01F; case ENCHANT: case NAUTILUS: case PORTAL: @@ -78,17 +78,17 @@ public class ParticleStyleInvocation extends DefaultParticleStyle { case END_ROD: case SMOKE: case SQUID_INK: - return 0.3; + return 0.3F; case FIREWORK: case SPIT: case SPLASH: - return 0.5; + return 0.5F; case POOF: - return 0.4; + return 0.4F; case TOTEM_OF_UNDYING: - return 1.25; + return 1.25F; default: - return 0.2; // Flame + return 0.2F; // Flame } } @@ -111,8 +111,8 @@ public class ParticleStyleInvocation extends DefaultParticleStyle { this.points = config.getInt("spinning-points"); this.radius = config.getDouble("radius"); this.numSteps = config.getInt("circle-points"); - this.playerOffset = config.getDouble("player-offset"); - this.speedMultiplier = config.getDouble("speed-multiplier"); + this.playerOffset = config.getFloat("player-offset"); + this.speedMultiplier = config.getFloat("speed-multiplier"); } } diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleMove.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleMove.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleMove.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleMove.java index b65ba39..cac72ee 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleMove.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleMove.java @@ -1,12 +1,12 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.manager.DataManager; import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import java.util.ArrayList; import java.util.List; import org.bukkit.Location; diff --git a/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleNormal.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleNormal.java new file mode 100644 index 0000000..b33094c --- /dev/null +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleNormal.java @@ -0,0 +1,72 @@ +package dev.esophose.playerparticles.styles; + +import dev.esophose.playerparticles.config.CommentedFileConfiguration; +import dev.esophose.playerparticles.particles.PParticle; +import dev.esophose.playerparticles.particles.ParticlePair; +import java.util.ArrayList; +import java.util.List; +import org.bukkit.Location; + +public class ParticleStyleNormal extends DefaultParticleStyle { + + public ParticleStyleNormal() { + super("normal", true, false, 0); + } + + @Override + public List getParticles(ParticlePair particle, Location location) { + float speed = 0; + switch (particle.getEffect()) { + case ENCHANT: + case NAUTILUS: + case PORTAL: + speed = 1.0F; + break; + case FLAME: + speed = 0.05F; + break; + + } + + int amount = 1; + switch (particle.getEffect()) { + case FALLING_DUST: + amount = 2; + break; + case UNDERWATER: + amount = 5; + break; + } + + float offset = 0.5F; + switch (particle.getEffect()) { + case CLOUD: + offset = 0.0F; + break; + case FLAME: + offset = 0.1F; + break; + } + + List particles = new ArrayList<>(); + for (int i = 0; i < amount; i++) + particles.add(new PParticle(location, offset, offset, offset, speed)); + return particles; + } + + @Override + public void updateTimers() { + + } + + @Override + protected void setDefaultSettings(CommentedFileConfiguration config) { + + } + + @Override + protected void loadSettings(CommentedFileConfiguration config) { + + } + +} diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleOrbit.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleOrbit.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleOrbit.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleOrbit.java index 12f1a6f..ae1a14c 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleOrbit.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleOrbit.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleOverhead.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleOverhead.java similarity index 79% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleOverhead.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleOverhead.java index f95b99e..42903d2 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleOverhead.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleOverhead.java @@ -1,17 +1,17 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import java.util.ArrayList; import java.util.List; import org.bukkit.Location; public class ParticleStyleOverhead extends DefaultParticleStyle { - private double headOffset; - private double particleSpreadX, particleSpreadY, particleSpreadZ; - private double particleSpeed; + private float headOffset; + private float particleSpreadX, particleSpreadY, particleSpreadZ; + private float particleSpeed; private int particlesPerTick; public ParticleStyleOverhead() { @@ -45,11 +45,11 @@ public class ParticleStyleOverhead extends DefaultParticleStyle { @Override protected void loadSettings(CommentedFileConfiguration config) { - this.headOffset = config.getDouble("head-offset"); - this.particleSpreadX = config.getDouble("particle-spread-x"); - this.particleSpreadY = config.getDouble("particle-spread-y"); - this.particleSpreadZ = config.getDouble("particle-spread-z"); - this.particleSpeed = config.getDouble("particle-speed"); + this.headOffset = config.getFloat("head-offset"); + this.particleSpreadX = config.getFloat("particle-spread-x"); + this.particleSpreadY = config.getFloat("particle-spread-y"); + this.particleSpreadZ = config.getFloat("particle-spread-z"); + this.particleSpeed = config.getFloat("particle-speed"); this.particlesPerTick = config.getInt("particles-per-tick"); } diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePoint.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePoint.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStylePoint.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePoint.java index cfb97ad..2315267 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePoint.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePoint.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import java.util.Collections; import java.util.List; import org.bukkit.Location; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePopper.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePopper.java similarity index 91% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStylePopper.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePopper.java index efd4b3c..3268fed 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePopper.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePopper.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; @@ -19,9 +19,9 @@ public class ParticleStylePopper extends DefaultParticleStyle { private int helices; private int maxStep; private int popParticleAmount; - private double popSpread; - private double popSpeed; - private double popOffset; + private float popSpread; + private float popSpeed; + private float popOffset; public ParticleStylePopper() { super("popper", true, true, 0.5); @@ -72,9 +72,9 @@ public class ParticleStylePopper extends DefaultParticleStyle { this.helices = config.getInt("helices"); this.maxStep = config.getInt("step-amount"); this.popParticleAmount = config.getInt("pop-particle-amount"); - this.popSpread = config.getDouble("pop-particle-spread"); - this.popSpeed = config.getDouble("pop-particle-speed"); - this.popOffset = config.getDouble("pop-particle-offset"); + this.popSpread = config.getFloat("pop-particle-spread"); + this.popSpeed = config.getFloat("pop-particle-speed"); + this.popOffset = config.getFloat("pop-particle-offset"); } } diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePulse.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePulse.java similarity index 81% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStylePulse.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePulse.java index 889655f..645ced6 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePulse.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStylePulse.java @@ -1,9 +1,9 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; @@ -15,9 +15,9 @@ public class ParticleStylePulse extends DefaultParticleStyle { private int points; private double radius; - private double offset; + private float offset; private int numSteps; - private double speedMultiplier; + private float speedMultiplier; public ParticleStylePulse() { super("pulse", true, true, 0.5); @@ -26,7 +26,7 @@ public class ParticleStylePulse extends DefaultParticleStyle { @Override public List getParticles(ParticlePair particle, Location location) { List particles = new ArrayList<>(); - double speed = this.getSpeedByEffect(particle.getEffect()) * this.speedMultiplier; + float speed = this.getSpeedByEffect(particle.getEffect()) * this.speedMultiplier; if (this.step == 0) { for (int i = 0; i < this.points; i++) { @@ -34,8 +34,8 @@ public class ParticleStylePulse extends DefaultParticleStyle { double dy = this.offset; double dz = MathL.sin(Math.PI * 2 * ((double) i / this.points)) * this.radius; double angle = Math.atan2(dz, dx); - double xAng = MathL.cos(angle); - double zAng = MathL.sin(angle); + float xAng = MathL.cos(angle); + float zAng = MathL.sin(angle); particles.add(new PParticle(location.clone().add(dx, dy, dz), xAng, 0, zAng, speed, true)); } } @@ -43,32 +43,32 @@ public class ParticleStylePulse extends DefaultParticleStyle { return particles; } - private double getSpeedByEffect(ParticleEffect effect) { + private float getSpeedByEffect(ParticleEffect effect) { switch (effect) { case CRIT: case DAMAGE_INDICATOR: case ENCHANTED_HIT: return 1; case DRAGON_BREATH: - return 0.01; + return 0.01F; case ENCHANT: case NAUTILUS: case PORTAL: - return 0.5; + return 0.5F; case END_ROD: case SMOKE: case SQUID_INK: - return 0.15; + return 0.15F; case FIREWORK: case SPIT: case SPLASH: - return 0.25; + return 0.25F; case POOF: - return 0.2; + return 0.2F; case TOTEM_OF_UNDYING: - return 0.75; + return 0.75F; default: - return 0.1; // Flame + return 0.1F; // Flame } } @@ -90,9 +90,9 @@ public class ParticleStylePulse extends DefaultParticleStyle { protected void loadSettings(CommentedFileConfiguration config) { this.points = config.getInt("points"); this.radius = config.getDouble("radius"); - this.offset = config.getDouble("offset"); + this.offset = config.getFloat("offset"); this.numSteps = config.getInt("delay"); - this.speedMultiplier = config.getDouble("speed-multiplier"); + this.speedMultiplier = config.getFloat("speed-multiplier"); } } diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleQuadhelix.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleQuadhelix.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleQuadhelix.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleQuadhelix.java index fadcd4f..85200b5 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleQuadhelix.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleQuadhelix.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleRings.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleRings.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleRings.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleRings.java index 46672f2..6038b34 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleRings.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleRings.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSphere.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSphere.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSphere.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSphere.java index 757acdd..462add8 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSphere.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSphere.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSpin.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSpin.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSpin.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSpin.java index 973bffb..60645df 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSpin.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSpin.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.Collections; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSpiral.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSpiral.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSpiral.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSpiral.java index 8c6855b..442c075 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSpiral.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSpiral.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSwords.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSwords.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSwords.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSwords.java index 398dc6c..60655c8 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSwords.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleSwords.java @@ -1,12 +1,12 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.manager.DataManager; import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleThick.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleThick.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleThick.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleThick.java index 4b91b5f..83993e7 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleThick.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleThick.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import java.util.ArrayList; import java.util.List; import org.bukkit.Location; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleTrail.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleTrail.java similarity index 91% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleTrail.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleTrail.java index 2fa1cc9..f5a57cb 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleTrail.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleTrail.java @@ -18,9 +18,9 @@ import org.bukkit.event.player.PlayerMoveEvent; public class ParticleStyleTrail extends DefaultParticleStyle implements Listener { - private double offset; - private double spread; - private double speed; + private float offset; + private float spread; + private float speed; public ParticleStyleTrail() { super("trail", false, false, 0); @@ -45,9 +45,9 @@ public class ParticleStyleTrail extends DefaultParticleStyle implements Listener @Override protected void loadSettings(CommentedFileConfiguration config) { - this.offset = config.getDouble("player-offset"); - this.spread = config.getDouble("spread"); - this.speed = config.getDouble("speed"); + this.offset = config.getFloat("player-offset"); + this.spread = config.getFloat("spread"); + this.speed = config.getFloat("speed"); } @EventHandler(priority = EventPriority.MONITOR) diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleTwins.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleTwins.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleTwins.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleTwins.java index 5b62297..3499d0a 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleTwins.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleTwins.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleVortex.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleVortex.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleVortex.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleVortex.java index 19bba5a..e363705 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleVortex.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleVortex.java @@ -23,9 +23,9 @@ */ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWhirl.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWhirl.java similarity index 81% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWhirl.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWhirl.java index 716e50d..7b19465 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWhirl.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWhirl.java @@ -1,9 +1,9 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; @@ -15,8 +15,8 @@ public class ParticleStyleWhirl extends DefaultParticleStyle { private int points; private int numSteps; - private double speedMultiplier; - private double offset; + private float speedMultiplier; + private float offset; public ParticleStyleWhirl() { super("whirl", true, true, 0.5); @@ -25,29 +25,29 @@ public class ParticleStyleWhirl extends DefaultParticleStyle { @Override public List getParticles(ParticlePair particle, Location location) { List particles = new ArrayList<>(); - double speed = this.getSpeedByEffect(particle.getEffect()) * this.speedMultiplier; + float speed = this.getSpeedByEffect(particle.getEffect()) * this.speedMultiplier; for (int i = 0; i < this.points; i++) { double dx = MathL.cos(this.step + (Math.PI * 2 * ((double) i / this.points))); double dy = this.offset; double dz = MathL.sin(this.step + (Math.PI * 2 * ((double) i / this.points))); double angle = Math.atan2(dz, dx); - double xAng = MathL.cos(angle); - double zAng = MathL.sin(angle); + float xAng = MathL.cos(angle); + float zAng = MathL.sin(angle); particles.add(new PParticle(location.clone().add(0, dy, 0), xAng, 0, zAng, speed, true)); } return particles; } - private double getSpeedByEffect(ParticleEffect effect) { + private float getSpeedByEffect(ParticleEffect effect) { switch (effect) { case CRIT: case DAMAGE_INDICATOR: case ENCHANTED_HIT: return 1; case DRAGON_BREATH: - return 0.01; + return 0.01F; case ENCHANT: case NAUTILUS: case PORTAL: @@ -55,17 +55,17 @@ public class ParticleStyleWhirl extends DefaultParticleStyle { case END_ROD: case SMOKE: case SQUID_INK: - return 0.15; + return 0.15F; case FIREWORK: case SPIT: case SPLASH: - return 0.25; + return 0.25F; case POOF: - return 0.2; + return 0.2F; case TOTEM_OF_UNDYING: - return 0.75; + return 0.75F; default: - return 0.1; // Flame + return 0.1F; // Flame } } @@ -86,8 +86,8 @@ public class ParticleStyleWhirl extends DefaultParticleStyle { protected void loadSettings(CommentedFileConfiguration config) { this.points = config.getInt("rays"); this.numSteps = config.getInt("steps"); - this.speedMultiplier = config.getDouble("speed-multiplier"); - this.offset = config.getDouble("offset"); + this.speedMultiplier = config.getFloat("speed-multiplier"); + this.offset = config.getFloat("offset"); } } diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWhirlwind.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWhirlwind.java similarity index 80% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWhirlwind.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWhirlwind.java index b5f0a36..73492f8 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWhirlwind.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWhirlwind.java @@ -1,9 +1,9 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import java.util.ArrayList; import java.util.List; @@ -15,8 +15,8 @@ public class ParticleStyleWhirlwind extends DefaultParticleStyle { private int points; private int numSteps; - private double speedMultiplier; - private double offset; + private float speedMultiplier; + private float offset; public ParticleStyleWhirlwind() { super("whirlwind", true, true, 0.5); @@ -25,7 +25,7 @@ public class ParticleStyleWhirlwind extends DefaultParticleStyle { @Override public List getParticles(ParticlePair particle, Location location) { List particles = new ArrayList<>(); - double speed = this.getSpeedByEffect(particle.getEffect()) * this.speedMultiplier; + float speed = this.getSpeedByEffect(particle.getEffect()) * this.speedMultiplier; // Orbit going clockwise for (int i = 0; i < this.points; i++) { @@ -33,40 +33,39 @@ public class ParticleStyleWhirlwind extends DefaultParticleStyle { double dy = this.offset; double dz = MathL.sin(this.step + (Math.PI * 2 * ((double) i / this.points))); double angle = Math.atan2(dz, dx); - double xAng = MathL.cos(angle); - double zAng = MathL.sin(angle); + float xAng = MathL.cos(angle); + float zAng = MathL.sin(angle); particles.add(new PParticle(location.clone().add(0, dy, 0), xAng, 0, zAng, speed, true)); } return particles; } - private double getSpeedByEffect(ParticleEffect effect) { + private float getSpeedByEffect(ParticleEffect effect) { switch (effect) { case CRIT: case DAMAGE_INDICATOR: case ENCHANTED_HIT: - return 1; - case DRAGON_BREATH: - return 0.01; case ENCHANT: case NAUTILUS: case PORTAL: return 1; + case DRAGON_BREATH: + return 0.01F; case END_ROD: case SMOKE: case SQUID_INK: - return 0.15; + return 0.15F; case FIREWORK: case SPIT: case SPLASH: - return 0.25; + return 0.25F; case POOF: - return 0.2; + return 0.2F; case TOTEM_OF_UNDYING: - return 0.75; + return 0.75F; default: - return 0.1; // Flame + return 0.1F; // Flame } } @@ -87,8 +86,8 @@ public class ParticleStyleWhirlwind extends DefaultParticleStyle { protected void loadSettings(CommentedFileConfiguration config) { this.points = config.getInt("rays"); this.numSteps = config.getInt("steps"); - this.speedMultiplier = config.getDouble("speed-multiplier"); - this.offset = config.getDouble("offset"); + this.speedMultiplier = config.getFloat("speed-multiplier"); + this.offset = config.getFloat("offset"); } } diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWings.java b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWings.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWings.java rename to Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWings.java index f0e5671..78afdc8 100644 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWings.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleWings.java @@ -1,8 +1,8 @@ package dev.esophose.playerparticles.styles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.ParticlePair; +import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.util.MathL; import dev.esophose.playerparticles.util.VectorUtils; import java.util.ArrayList; diff --git a/src/main/java/dev/esophose/playerparticles/util/MathL.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/MathL.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/util/MathL.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/MathL.java diff --git a/src/main/java/dev/esophose/playerparticles/util/Metrics.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/Metrics.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/util/Metrics.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/Metrics.java diff --git a/src/main/java/dev/esophose/playerparticles/util/NMSUtil.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/NMSUtil.java similarity index 56% rename from src/main/java/dev/esophose/playerparticles/util/NMSUtil.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/NMSUtil.java index 6267048..c0c4d4a 100644 --- a/src/main/java/dev/esophose/playerparticles/util/NMSUtil.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/util/NMSUtil.java @@ -1,5 +1,7 @@ package dev.esophose.playerparticles.util; +import dev.esophose.playerparticles.nms.wrapper.ParticleHandler; +import dev.esophose.playerparticles.particles.version.VersionMapping; import org.bukkit.Bukkit; public final class NMSUtil { @@ -7,28 +9,33 @@ public final class NMSUtil { private static String cachedVersion = null; private static int cachedVersionNumber = -1; + public static ParticleHandler getHandler(VersionMapping versionMapping) { + try { + return (ParticleHandler) Class.forName("dev.esophose.playerparticles.nms." + getVersion() + ".ParticleHandlerImpl").getConstructor(VersionMapping.class).newInstance(versionMapping); + } catch (Exception ex) { + ex.printStackTrace(); + return null; + } + } + /** - * Gets the server version - * * @return The server version */ public static String getVersion() { if (cachedVersion == null) { String name = Bukkit.getServer().getClass().getPackage().getName(); - cachedVersion = name.substring(name.lastIndexOf('.') + 1) + "."; + cachedVersion = name.substring(name.lastIndexOf('.') + 1); } return cachedVersion; } /** - * Gets the server version major release number - * - * @return The server version major release number + * @return the server version major release number */ public static int getVersionNumber() { if (cachedVersionNumber == -1) { String name = getVersion().substring(3); - cachedVersionNumber = Integer.parseInt(name.substring(0, name.length() - 4)); + cachedVersionNumber = Integer.parseInt(name.substring(0, name.length() - 3)); } return cachedVersionNumber; } diff --git a/src/main/java/dev/esophose/playerparticles/util/ParticleUtils.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/ParticleUtils.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/util/ParticleUtils.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/ParticleUtils.java diff --git a/src/main/java/dev/esophose/playerparticles/util/StringPlaceholders.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/StringPlaceholders.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/util/StringPlaceholders.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/StringPlaceholders.java diff --git a/src/main/java/dev/esophose/playerparticles/util/VectorUtils.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/VectorUtils.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/util/VectorUtils.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/VectorUtils.java diff --git a/src/main/java/dev/esophose/playerparticles/util/inputparser/InputParser.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/InputParser.java similarity index 94% rename from src/main/java/dev/esophose/playerparticles/util/inputparser/InputParser.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/InputParser.java index f947d85..12a1d59 100644 --- a/src/main/java/dev/esophose/playerparticles/util/inputparser/InputParser.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/InputParser.java @@ -2,17 +2,17 @@ package dev.esophose.playerparticles.util.inputparser; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; -import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor; -import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; +import dev.esophose.playerparticles.particles.color.NoteColor; +import dev.esophose.playerparticles.particles.color.OrdinaryColor; import dev.esophose.playerparticles.styles.ParticleStyle; -import dev.esophose.playerparticles.util.inputparser.parsable.ParsableInteger; -import dev.esophose.playerparticles.util.inputparser.parsable.ParsableLocation; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableMaterial; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableNoteColor; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableOrdinaryColor; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableParticleEffect; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableParticleStyle; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableString; +import dev.esophose.playerparticles.util.inputparser.parsable.ParsableInteger; +import dev.esophose.playerparticles.util.inputparser.parsable.ParsableLocation; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; diff --git a/src/main/java/dev/esophose/playerparticles/util/inputparser/Parsable.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/Parsable.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/util/inputparser/Parsable.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/Parsable.java diff --git a/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableInteger.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableInteger.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableInteger.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableInteger.java diff --git a/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableLocation.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableLocation.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableLocation.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableLocation.java diff --git a/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableMaterial.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableMaterial.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableMaterial.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableMaterial.java diff --git a/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableNoteColor.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableNoteColor.java similarity index 91% rename from src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableNoteColor.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableNoteColor.java index 8d17dd7..29c2a19 100644 --- a/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableNoteColor.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableNoteColor.java @@ -1,7 +1,7 @@ package dev.esophose.playerparticles.util.inputparser.parsable; import dev.esophose.playerparticles.particles.PPlayer; -import dev.esophose.playerparticles.particles.ParticleEffect.NoteColor; +import dev.esophose.playerparticles.particles.color.NoteColor; import dev.esophose.playerparticles.util.inputparser.Parsable; import java.util.List; diff --git a/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableOrdinaryColor.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableOrdinaryColor.java similarity index 97% rename from src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableOrdinaryColor.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableOrdinaryColor.java index 84286cd..8d1863b 100644 --- a/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableOrdinaryColor.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableOrdinaryColor.java @@ -1,7 +1,7 @@ package dev.esophose.playerparticles.util.inputparser.parsable; import dev.esophose.playerparticles.particles.PPlayer; -import dev.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor; +import dev.esophose.playerparticles.particles.color.OrdinaryColor; import dev.esophose.playerparticles.util.inputparser.Parsable; import java.awt.Color; import java.util.Collections; diff --git a/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableParticleEffect.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableParticleEffect.java similarity index 71% rename from src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableParticleEffect.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableParticleEffect.java index 3601964..d7add5e 100644 --- a/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableParticleEffect.java +++ b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableParticleEffect.java @@ -1,5 +1,7 @@ package dev.esophose.playerparticles.util.inputparser.parsable; +import dev.esophose.playerparticles.PlayerParticles; +import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.util.inputparser.Parsable; @@ -14,7 +16,7 @@ public class ParsableParticleEffect extends Parsable { @Override public ParticleEffect parse(PPlayer pplayer, List inputs) { String input = inputs.remove(0); - return ParticleEffect.fromName(input); + return PlayerParticles.getInstance().getManager(ParticleManager.class).getEffectFromName(input); } } diff --git a/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableParticleStyle.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableParticleStyle.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableParticleStyle.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableParticleStyle.java diff --git a/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableString.java b/Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableString.java similarity index 100% rename from src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableString.java rename to Plugin/src/main/java/dev/esophose/playerparticles/util/inputparser/parsable/ParsableString.java diff --git a/src/main/resources/plugin.yml b/Plugin/src/main/resources/plugin.yml similarity index 100% rename from src/main/resources/plugin.yml rename to Plugin/src/main/resources/plugin.yml diff --git a/src/main/resources/preset_groups.yml b/Plugin/src/main/resources/preset_groups.yml similarity index 100% rename from src/main/resources/preset_groups.yml rename to Plugin/src/main/resources/preset_groups.yml diff --git a/build.gradle b/build.gradle index 0f1dea5..fa0e503 100644 --- a/build.gradle +++ b/build.gradle @@ -1,94 +1,64 @@ -import org.apache.tools.ant.filters.ReplaceTokens - plugins { id 'com.github.johnrengelman.shadow' version '5.1.0' id 'maven-publish' id 'java' } -sourceCompatibility = 1.8 -targetCompatibility = 1.8 -compileJava.options.encoding = 'UTF-8' -group = 'dev.esophose' -version = '7.4' +allprojects { + apply plugin: 'java' + apply plugin: 'com.github.johnrengelman.shadow' + group = 'dev.esophose' + version = '7.5' + sourceCompatibility = 1.8 + targetCompatibility = 1.8 -java { - withJavadocJar() - withSourcesJar() + repositories { + mavenCentral() + jcenter() + + maven { url = 'https://repo.codemc.org/repository/maven-public' } + maven { url = 'https://repo.codemc.org/repository/nms' } + maven { url = 'http://repo.extendedclip.com/content/repositories/placeholderapi/' } + maven { url = 'https://repo.dmulloy2.net/nexus/repository/public/' } + } } -repositories { - mavenCentral() - jcenter() - - maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' } - maven { url = 'https://repo.codemc.org/repository/maven-public' } - maven { url = 'http://repo.extendedclip.com/content/repositories/placeholderapi/' } +//javadoc { +// options.encoding = 'UTF-8' +// if (JavaVersion.current().isJava9Compatible()) { +// options.addBooleanOption('html5', true) +// } +//} +// +//java { +// withJavadocJar() +// withSourcesJar() +//} + +configurations { + childJars } dependencies { - compile 'org.slf4j:slf4j-api:1.7.25' - compile 'org.slf4j:slf4j-nop:1.7.25' - compile 'com.zaxxer:HikariCP:3.2.0' - shadow 'org.jetbrains:annotations:16.0.2' - shadow 'me.clip:placeholderapi:2.10.4' - shadow 'org.xerial:sqlite-jdbc:3.23.1' - shadow 'org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT' + implementation project(':Plugin') + implementation project(':NMS-Wrapper') + implementation project(':NMS-v1_15_R1') + + subprojects.each { + childJars project(it.path) + } } shadowJar { archiveClassifier.set(null) - minimize() } -processResources { - from (sourceSets.main.resources.srcDirs) { - include '**/*.yml' - filter ReplaceTokens, tokens: ["version": project.property("version")] - } -} - -publishing { - publications { - shadow(MavenPublication) { publication -> - project.shadow.component(publication) +jar { + dependsOn configurations.childJars + from { + configurations.childJars.collect { + zipTree(it) } - mavenJava(MavenPublication) { - artifactId = 'playerparticles' - from components.java - versionMapping { - usage('java-api') { - fromResolutionOf('runtimeClasspath') - } - usage('java-runtime') { - fromResolutionResult() - } - } - pom { - name = 'playerparticles' - } - } - } - repositories { - if (project.hasProperty('mavenUsername') && project.hasProperty('mavenPassword')) { - maven { - credentials { - username project.mavenUsername - password project.mavenPassword - } - - def releasesRepoUrl = 'https://repo.codemc.org/repository/maven-releases/' - def snapshotsRepoUrl = 'https://repo.codemc.org/repository/maven-snapshots/' - url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl - } - } - } -} - -javadoc { - options.encoding = 'UTF-8' - if (JavaVersion.current().isJava9Compatible()) { - options.addBooleanOption('html5', true) } } diff --git a/changelog.txt b/changelog.txt index fe471b6..333accd 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +=== v7.5 === ++ Added style 'trail' +* Adjusted the 'normal' style a bit (also includes thick, and move) === v7.4 === * Fixed '/pp fixed teleport' not working due to async event issues * Fixed issue with a fixed celebration effect while vanished @@ -20,7 +23,7 @@ + Added a setting 'dust-size' to change the size of dust particles in 1.13+ + Added sub-command '/pp fixed teleport ' that requires the permission playerparticles.fixed.teleport + Added named colors to the color data autocomplete -+ Added an API, accessible through the dev.esophose.playerparticles.api.PlayerParticlesAPI class ++ Added an API, accessible through the dev.esophose.PlayerParticlesAPI class + Added the ability for the console to manage its own fixed effects + Added PlaceholderAPI support + Added permission playerparticles.override for /ppo diff --git a/settings.gradle b/settings.gradle index 70fcc0f..cb6dd94 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,11 @@ rootProject.name = 'PlayerParticles' + +include(':Plugin') +project(':Plugin').projectDir = file('Plugin') + +include(':NMS-Wrapper') +project(':NMS-Wrapper').projectDir = file('Particles/Wrapper') + +include(':NMS-v1_15_R1') +project(':NMS-v1_15_R1').projectDir = file('Particles/v1_15_R1') + diff --git a/src/main/java/dev/esophose/playerparticles/particles/ParticleEffect.java b/src/main/java/dev/esophose/playerparticles/particles/ParticleEffect.java deleted file mode 100644 index 41f1396..0000000 --- a/src/main/java/dev/esophose/playerparticles/particles/ParticleEffect.java +++ /dev/null @@ -1,742 +0,0 @@ -package dev.esophose.playerparticles.particles; - -import com.google.common.collect.ObjectArrays; -import dev.esophose.playerparticles.PlayerParticles; -import dev.esophose.playerparticles.config.CommentedFileConfiguration; -import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; -import dev.esophose.playerparticles.manager.ParticleManager; -import dev.esophose.playerparticles.util.NMSUtil; -import dev.esophose.playerparticles.util.ParticleUtils; -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; -import java.util.stream.Stream; -import org.bukkit.Color; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.Particle.DustOptions; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; -import org.bukkit.metadata.MetadataValue; - -@SuppressWarnings("deprecation") -public enum ParticleEffect { - - // Ordered and named by their Minecraft 1.13+ internal names - AMBIENT_ENTITY_EFFECT("SPELL_MOB_AMBIENT", ParticleProperty.COLORABLE), - ANGRY_VILLAGER("VILLAGER_ANGRY"), - BARRIER("BARRIER"), - BLOCK("BLOCK_CRACK", ParticleProperty.REQUIRES_MATERIAL_DATA), - BUBBLE("WATER_BUBBLE"), - BUBBLE_COLUMN_UP("BUBBLE_COLUMN_UP"), - BUBBLE_POP("BUBBLE_POP"), - CAMPFIRE_COSY_SMOKE("CAMPFIRE_COSY_SMOKE"), - CAMPFIRE_SIGNAL_SMOKE("CAMPFIRE_SIGNAL_SMOKE"), - CLOUD("CLOUD"), - COMPOSTER("COMPOSTER"), - CRIT("CRIT"), - CURRENT_DOWN("CURRENT_DOWN"), - DAMAGE_INDICATOR("DAMAGE_INDICATOR"), - DOLPHIN("DOLPHIN"), - DRAGON_BREATH("DRAGON_BREATH"), - DRIPPING_HONEY("DRIPPING_HONEY"), - DRIPPING_LAVA("DRIP_LAVA"), - DRIPPING_WATER("DRIP_WATER"), - DUST("REDSTONE", ParticleProperty.COLORABLE), - ELDER_GUARDIAN("MOB_APPEARANCE", false), // No thank you - ENCHANT("ENCHANTMENT_TABLE"), - ENCHANTED_HIT("CRIT_MAGIC"), - END_ROD("END_ROD"), - ENTITY_EFFECT("SPELL_MOB", ParticleProperty.COLORABLE), - EXPLOSION("EXPLOSION_LARGE"), - EXPLOSION_EMITTER("EXPLOSION_HUGE"), - FALLING_DUST("FALLING_DUST", ParticleProperty.REQUIRES_MATERIAL_DATA), - FALLING_HONEY("FALLING_HONEY"), - FALLING_LAVA("FALLING_LAVA"), - FALLING_NECTAR("FALLING_NECTAR"), - FALLING_WATER("FALLING_WATER"), - FIREWORK("FIREWORKS_SPARK"), - FISHING("WATER_WAKE"), - FLAME("FLAME"), - FLASH("FLASH", false), // Also no thank you - FOOTSTEP("FOOTSTEP"), // Removed in Minecraft 1.13 :( - HAPPY_VILLAGER("VILLAGER_HAPPY"), - HEART("HEART"), - INSTANT_EFFECT("SPELL_INSTANT"), - ITEM("ITEM_CRACK", ParticleProperty.REQUIRES_MATERIAL_DATA), - ITEM_SLIME("SLIME"), - ITEM_SNOWBALL("SNOWBALL"), - LANDING_HONEY("LANDING_HONEY"), - LANDING_LAVA("LANDING_LAVA"), - LARGE_SMOKE("SMOKE_LARGE"), - LAVA("LAVA"), - MYCELIUM("TOWN_AURA"), - NAUTILUS("NAUTILUS"), - NOTE("NOTE", ParticleProperty.COLORABLE), - POOF("EXPLOSION_NORMAL"), // The 1.13 combination of explode and showshovel - PORTAL("PORTAL"), - RAIN("WATER_DROP"), - SMOKE("SMOKE_NORMAL"), - SNEEZE("SNEEZE"), - 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"), - SPLASH("WATER_SPLASH"), - SQUID_INK("SQUID_INK"), - SWEEP_ATTACK("SWEEP_ATTACK"), - TOTEM_OF_UNDYING("TOTEM"), - UNDERWATER("SUSPENDED_DEPTH"), - WITCH("SPELL_WITCH"); - - private Particle internalEnum; - private List properties; - - private CommentedFileConfiguration config; - private boolean enabledByDefault; - - private String effectName; - private boolean enabled; - - /** - * Construct a new particle effect - * - * @param enumName Name of the Particle Enum when the server version is greater than or equal to 1.13 - * @param properties Properties of this particle effect - */ - ParticleEffect(String enumName, ParticleProperty... properties) { - this(enumName, true, properties); - } - - /** - * Construct a new particle effect - * - * @param enumName Name of the Particle Enum when the server version is greater than or equal to 1.13 - * @param enabledByDefault If the particle type is enabled by default - * @param properties Properties of this particle effect - */ - ParticleEffect(String enumName, boolean enabledByDefault, ParticleProperty... properties) { - this.enabledByDefault = enabledByDefault; - this.properties = Arrays.asList(properties); - - // Will be null if this server's version doesn't support this particle type - this.internalEnum = Stream.of(Particle.values()).filter(x -> x.name().equals(enumName)).findFirst().orElse(null); - - this.setDefaultSettings(); - this.loadSettings(false); - } - - /** - * Sets the default settings for the particle type - */ - private void setDefaultSettings() { - if (!this.isSupported()) - return; - - File directory = new File(PlayerParticles.getInstance().getDataFolder(), "effects"); - directory.mkdirs(); - - File file = new File(directory, this.getInternalName() + ".yml"); - this.config = CommentedFileConfiguration.loadConfiguration(PlayerParticles.getInstance(), file); - - boolean changed = this.setIfNotExists("effect-name", this.getInternalName(), "The name the effect will display as"); - changed |= this.setIfNotExists("enabled", this.enabledByDefault, "If the effect is enabled or not"); - - if (changed) - this.config.save(); - } - - /** - * Loads the settings shared for each style then calls loadSettings(CommentedFileConfiguration) - * - * @param reloadConfig If the settings should be reloaded or not - */ - public void loadSettings(boolean reloadConfig) { - if (!this.isSupported()) - return; - - if (reloadConfig) - this.setDefaultSettings(); - - this.effectName = this.config.getString("effect-name"); - this.enabled = this.config.getBoolean("enabled"); - } - - /** - * Sets a value to the config if it doesn't already exist - * - * @param setting The setting name - * @param value The setting value - * @param comments Comments for the setting - * @return true if changes were made - */ - private boolean setIfNotExists(String setting, Object value, String... comments) { - if (this.config.get(setting) != null) - return false; - - String defaultMessage = "Default: "; - if (value instanceof String && ParticleUtils.containsConfigSpecialCharacters((String) value)) { - defaultMessage += "'" + value + "'"; - } else { - defaultMessage += value; - } - - this.config.set(setting, value, ObjectArrays.concat(comments, new String[] { defaultMessage }, String.class)); - return true; - } - - /** - * Reloads the settings for all ParticleEffects - */ - public static void reloadSettings() { - for (ParticleEffect effect : values()) - effect.loadSettings(true); - } - - /** - * @return the internal name of this particle effect that will never change - */ - public String getInternalName() { - return this.name().toLowerCase(); - } - - /** - * @return the name that the style will display to the users as - */ - public String getName() { - return this.effectName; - } - - /** - * Determine if this particle effect has a specific property - * - * @param property The property to check - * @return Whether it has the property or not - */ - public boolean hasProperty(ParticleProperty property) { - return this.properties.contains(property); - } - - /** - * Determine if this particle effect is supported by the current server version - * - * @return Whether the particle effect is supported or not - */ - public boolean isSupported() { - return this.internalEnum != null; - } - - /** - * @return true if this effect is enabled, otherwise false - */ - public boolean isEnabled() { - return this.enabled; - } - - /** - * Returns a ParticleEffect List of all enabled effects for the server version - * - * @return Enabled effects - */ - public static List getEnabledEffects() { - List effects = new ArrayList<>(); - for (ParticleEffect pe : values()) - if (pe.isSupported() && pe.isEnabled()) - effects.add(pe); - return effects; - } - - /** - * Returns the particle effect with the given name - * - * @param name Name of the particle effect - * @return The particle effect - */ - public static ParticleEffect fromName(String name) { - return Stream.of(values()).filter(x -> x.isSupported() && x.isEnabled() && x.getName().equalsIgnoreCase(name)).findFirst().orElse(null); - } - - /** - * Returns the particle effect with the given name - * - * @param internalName Internal name of the particle effect - * @return The particle effect - */ - public static ParticleEffect fromInternalName(String internalName) { - return Stream.of(values()).filter(x -> x.isSupported() && x.isEnabled() && x.getInternalName().equalsIgnoreCase(internalName)).findFirst().orElse(null); - } - - /** - * Invokes the correct spawn method for the particle information given - * - * @param particle The ParticlePair, given the effect/style/data - * @param pparticle The particle spawn information - * @param isLongRange If the particle can be viewed from long range - * @param owner The player that owns the particles - */ - public static void display(ParticlePair particle, PParticle pparticle, boolean isLongRange, Player owner) { - ParticleEffect effect = particle.getEffect(); - int count = pparticle.isDirectional() ? 0 : 1; - - if (effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - effect.display(particle.getSpawnMaterial(), pparticle.getXOff(), pparticle.getYOff(), pparticle.getZOff(), pparticle.getSpeed(), 1, pparticle.getLocation(false), isLongRange, owner); - } else if (effect.hasProperty(ParticleProperty.COLORABLE)) { - effect.display(particle.getSpawnColor(), pparticle.getLocation(true), isLongRange, owner); - } else { - effect.display(pparticle.getXOff(), pparticle.getYOff(), pparticle.getZOff(), pparticle.getSpeed(), count, pparticle.getLocation(false), isLongRange, owner); - } - } - - /** - * Displays a particle effect - * - * @param offsetX Maximum distance particles can fly away from the center on the x-axis - * @param offsetY Maximum distance particles can fly away from the center on the y-axis - * @param offsetZ Maximum distance particles can fly away from the center on the z-axis - * @param speed Display speed of the particles - * @param amount Amount of particles - * @param center Center location of the effect - * @param isLongRange If the particle can be viewed from long range - * @param owner The player that owns the particles - * @throws ParticleDataException If the particle effect requires additional data - */ - public void display(double offsetX, double offsetY, double offsetZ, double speed, int amount, Location center, boolean isLongRange, Player owner) throws ParticleDataException { - if (this.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) - throw new ParticleDataException("This particle effect requires additional data"); - - for (Player player : this.getPlayersInRange(center, isLongRange, owner)) - player.spawnParticle(this.internalEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed); - } - - /** - * Displays a single particle which is colored - * - * @param color Color of the particle - * @param center Center location of the effect - * @param isLongRange If the particle can be viewed from long range - * @param owner The player that owns the particles - * @throws ParticleColorException If the particle effect is not colorable or the color type is incorrect - */ - public void display(ParticleColor color, Location center, boolean isLongRange, Player owner) throws ParticleColorException { - if (!this.hasProperty(ParticleProperty.COLORABLE)) - throw new ParticleColorException("This particle effect is not colorable"); - - if (this == DUST && NMSUtil.getVersionNumber() >= 13) { // DUST uses a special data object for spawning in 1.13+ - OrdinaryColor dustColor = (OrdinaryColor) color; - DustOptions dustOptions = new DustOptions(Color.fromRGB(dustColor.getRed(), dustColor.getGreen(), dustColor.getBlue()), Setting.DUST_SIZE.getFloat()); - for (Player player : this.getPlayersInRange(center, isLongRange, owner)) - player.spawnParticle(this.internalEnum, center.getX(), center.getY(), center.getZ(), 1, 0, 0, 0, 0, dustOptions); - } else { - for (Player player : this.getPlayersInRange(center, isLongRange, owner)) { - // Minecraft clients require that you pass a non-zero value if the Red value should be zero - player.spawnParticle(this.internalEnum, center.getX(), center.getY(), center.getZ(), 0, this == ParticleEffect.DUST && color.getValueX() == 0 ? Float.MIN_VALUE : color.getValueX(), color.getValueY(), color.getValueZ(), 1); - } - } - } - - /** - * Displays a particle effect which requires additional data and is only - * visible for all players within a certain range in the world of @param - * center - * - * @param spawnMaterial Material of the effect - * @param offsetX Maximum distance particles can fly away from the center on the x-axis - * @param offsetY Maximum distance particles can fly away from the center on the y-axis - * @param offsetZ Maximum distance particles can fly away from the center on the z-axis - * @param speed Display speed of the particles - * @param amount Amount of particles - * @param center Center location of the effect - * @param isLongRange If the particle can be viewed from long range - * @param owner The player that owns the particles - * @throws ParticleDataException If the particle effect does not require additional data or if the data type is incorrect - */ - public void display(Material spawnMaterial, double offsetX, double offsetY, double offsetZ, double speed, int amount, Location center, boolean isLongRange, Player owner) throws ParticleDataException { - if (!this.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { - throw new ParticleDataException("This particle effect does not require additional data"); - } - - Object extraData = null; - if (this.internalEnum.getDataType().getTypeName().equals("org.bukkit.block.data.BlockData")) { - extraData = spawnMaterial.createBlockData(); - } else if (this.internalEnum.getDataType() == ItemStack.class) { - extraData = new ItemStack(spawnMaterial); - } else if (this.internalEnum.getDataType() == MaterialData.class) { - extraData = new MaterialData(spawnMaterial); // Deprecated, only used in versions < 1.13 - } - - for (Player player : this.getPlayersInRange(center, isLongRange, owner)) - player.spawnParticle(this.internalEnum, center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed, extraData); - } - - /** - * Gets a List of Players within the particle display range - * - * @param center The center of the radius to check around - * @param isLongRange If the particle can be viewed from long range - * @param owner The player that owns the particles - * @return A List of Players within the particle display range - */ - private List getPlayersInRange(Location center, boolean isLongRange, Player owner) { - List players = new ArrayList<>(); - int range = !isLongRange ? Setting.PARTICLE_RENDER_RANGE_PLAYER.getInt() : Setting.PARTICLE_RENDER_RANGE_FIXED_EFFECT.getInt(); - range *= range; - - for (PPlayer pplayer : PlayerParticles.getInstance().getManager(ParticleManager.class).getPPlayers()) { - Player p = pplayer.getPlayer(); - if (!this.canSee(p, owner)) - continue; - - if (p != null && pplayer.canSeeParticles() && p.getWorld().equals(center.getWorld()) && center.distanceSquared(p.getLocation()) <= range) - players.add(p); - } - - return players; - } - - /** - * Checks if a player can see another player - * - * @param player The player - * @param target The target - * @return True if player can see target, otherwise false - */ - private boolean canSee(Player player, Player target) { - if (player == null || target == null) - return true; - - for (MetadataValue meta : target.getMetadata("vanished")) - if (meta.asBoolean()) - return false; - - return player.canSee(target); - } - - /** - * Represents the property of a particle effect - *

- * This class is part of the ParticleEffect Library and follows the - * same usage conditions - * - * @author DarkBlade12 - * @since 1.7 - */ - public enum ParticleProperty { - /** - * The particle effect requires block or item material data to be displayed - */ - REQUIRES_MATERIAL_DATA, - /** - * The particle effect uses the offsets as color values - */ - COLORABLE - } - - /** - * Represents the color for effects like {@link ParticleEffect#ENTITY_EFFECT}, - * {@link ParticleEffect#AMBIENT_ENTITY_EFFECT}, {@link ParticleEffect#DUST} - * and {@link ParticleEffect#NOTE} - *

- * This class is part of the ParticleEffect Library and follows the - * same usage conditions - * - * @author DarkBlade12 - * @since 1.7 - */ - public static abstract class ParticleColor { - /** - * Returns the value for the offsetX field - * - * @return The offsetX value - */ - public abstract float getValueX(); - - /** - * Returns the value for the offsetY field - * - * @return The offsetY value - */ - public abstract float getValueY(); - - /** - * Returns the value for the offsetZ field - * - * @return The offsetZ value - */ - public abstract float getValueZ(); - } - - /** - * Represents the color for effects like {@link ParticleEffect#ENTITY_EFFECT}, - * {@link ParticleEffect#AMBIENT_ENTITY_EFFECT} and {@link ParticleEffect#NOTE} - *

- * This class is part of the ParticleEffect Library and follows the - * same usage conditions - * - * @author DarkBlade12 - * @since 1.7 - */ - public static final class OrdinaryColor extends ParticleColor { - public static final OrdinaryColor RAINBOW = new OrdinaryColor(999, 999, 999); - public static final OrdinaryColor RANDOM = new OrdinaryColor(998, 998, 998); - - private final int red; - private final int green; - private final int blue; - - /** - * Construct a new ordinary color - * - * @param red Red value of the RGB format - * @param green Green value of the RGB format - * @param blue Blue value of the RGB format - * @throws IllegalArgumentException If one of the values is lower than 0 - * or higher than 255 - */ - public OrdinaryColor(int red, int green, int blue) throws IllegalArgumentException { - if ((red == 999 && green == 999 && blue == 999) || (red == 998 && green == 998 && blue == 998)) { // Allow rainbow and random values - this.red = red; - this.green = green; - this.blue = blue; - } else { - if (red < 0) { - throw new IllegalArgumentException("The red value is lower than 0"); - } - if (red > 255) { - throw new IllegalArgumentException("The red value is higher than 255"); - } - this.red = red; - if (green < 0) { - throw new IllegalArgumentException("The green value is lower than 0"); - } - if (green > 255) { - throw new IllegalArgumentException("The green value is higher than 255"); - } - this.green = green; - if (blue < 0) { - throw new IllegalArgumentException("The blue value is lower than 0"); - } - if (blue > 255) { - throw new IllegalArgumentException("The blue value is higher than 255"); - } - this.blue = blue; - } - } - - /** - * Returns the red value of the RGB format - * - * @return The red value - */ - public int getRed() { - return this.red; - } - - /** - * Returns the green value of the RGB format - * - * @return The green value - */ - public int getGreen() { - return this.green; - } - - /** - * Returns the blue value of the RGB format - * - * @return The blue value - */ - public int getBlue() { - return this.blue; - } - - /** - * Returns the red value divided by 255 - * - * @return The offsetX value - */ - @Override - public float getValueX() { - if (this.equals(OrdinaryColor.RAINBOW) || this.equals(OrdinaryColor.RANDOM)) - return 0F; - return (float) this.red / 255F; - } - - /** - * Returns the green value divided by 255 - * - * @return The offsetY value - */ - @Override - public float getValueY() { - if (this.equals(OrdinaryColor.RAINBOW) || this.equals(OrdinaryColor.RANDOM)) - return 0F; - return (float) this.green / 255F; - } - - /** - * Returns the blue value divided by 255 - * - * @return The offsetZ value - */ - @Override - public float getValueZ() { - if (this.equals(OrdinaryColor.RAINBOW) || this.equals(OrdinaryColor.RANDOM)) - return 0F; - return (float) this.blue / 255F; - } - - @Override - public boolean equals(Object other) { - if (!(other instanceof OrdinaryColor)) - return false; - OrdinaryColor otherColor = (OrdinaryColor) other; - return this.red == otherColor.red && this.green == otherColor.green && this.blue == otherColor.blue; - } - - @Override - public int hashCode() { - return Objects.hash(this.red, this.green, this.blue); - } - } - - /** - * Represents the color for the {@link ParticleEffect#NOTE} effect - *

- * This class is part of the ParticleEffect Library and follows the - * same usage conditions - * - * @author DarkBlade12 - * @since 1.7 - */ - public static final class NoteColor extends ParticleColor { - public static final NoteColor RAINBOW = new NoteColor(99); - public static final NoteColor RANDOM = new NoteColor(98); - - private final int note; - - /** - * Construct a new note color - * - * @param note Note id which determines color - * @throws IllegalArgumentException If the note value is lower than 0 or - * higher than 24 - */ - public NoteColor(int note) throws IllegalArgumentException { - if (note == 99 || note == 98) { // Allow rainbow and random values - this.note = note; - } else { - if (note < 0) { - throw new IllegalArgumentException("The note value is lower than 0"); - } - if (note > 24) { - throw new IllegalArgumentException("The note value is higher than 24"); - } - this.note = note; - } - } - - /** - * Returns the note value - * - * @return The note value - */ - public int getNote() { - return this.note; - } - - /** - * Returns the note value divided by 24 - * - * @return The offsetX value - */ - @Override - public float getValueX() { - return (float) this.note / 24F; - } - - /** - * Returns zero because the offsetY value is unused - * - * @return zero - */ - @Override - public float getValueY() { - return 0; - } - - /** - * Returns zero because the offsetZ value is unused - * - * @return zero - */ - @Override - public float getValueZ() { - return 0; - } - - @Override - public boolean equals(Object other) { - if (!(other instanceof NoteColor)) - return false; - NoteColor otherColor = (NoteColor) other; - return this.note == otherColor.note; - } - - @Override - public int hashCode() { - return Objects.hashCode(this.note); - } - - } - - /** - * Represents a runtime exception that is thrown either if the displayed - * particle effect requires data and has none or vice-versa or if the data - * type is incorrect - *

- * This class is part of the ParticleEffect Library and follows the - * same usage conditions - * - * @author DarkBlade12 - * @since 1.6 - */ - private static final class ParticleDataException extends RuntimeException { - private static final long serialVersionUID = 3203085387160737484L; - - /** - * Construct a new particle data exception - * - * @param message Message that will be logged - */ - public ParticleDataException(String message) { - super(message); - } - } - - /** - * Represents a runtime exception that is thrown either if the displayed - * particle effect is not colorable or if the particle color type is - * incorrect - *

- * This class is part of the ParticleEffect Library and follows the - * same usage conditions - * - * @author DarkBlade12 - * @since 1.7 - */ - private static final class ParticleColorException extends RuntimeException { - private static final long serialVersionUID = 3203085387160737485L; - - /** - * Construct a new particle color exception - * - * @param message Message that will be logged - */ - public ParticleColorException(String message) { - super(message); - } - } - -} diff --git a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleNormal.java b/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleNormal.java deleted file mode 100644 index 861cf06..0000000 --- a/src/main/java/dev/esophose/playerparticles/styles/ParticleStyleNormal.java +++ /dev/null @@ -1,148 +0,0 @@ -package dev.esophose.playerparticles.styles; - -import dev.esophose.playerparticles.config.CommentedFileConfiguration; -import dev.esophose.playerparticles.particles.PParticle; -import dev.esophose.playerparticles.particles.ParticleEffect; -import dev.esophose.playerparticles.particles.ParticlePair; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import org.bukkit.Location; - -public class ParticleStyleNormal extends DefaultParticleStyle { - - public ParticleStyleNormal() { - super("normal", true, false, 0); - } - - @Override - public List getParticles(ParticlePair particle, Location location) { - ParticleEffect particleEffect = particle.getEffect(); - List particles = new ArrayList<>(); - - switch (particleEffect) { - case AMBIENT_ENTITY_EFFECT: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0)); - case ANGRY_VILLAGER: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0)); - case BARRIER: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0)); - case BLOCK: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0)); - case BUBBLE: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case BUBBLE_COLUMN_UP: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case BUBBLE_POP: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case CLOUD: - return Collections.singletonList(new PParticle(location, 0.0, 0.0, 0.0, 0.0)); - case CRIT: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case CURRENT_DOWN: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case DAMAGE_INDICATOR: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case DOLPHIN: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case DRAGON_BREATH: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case DRIPPING_LAVA: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0)); - case DRIPPING_WATER: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0)); - case DUST: - return Collections.singletonList(new PParticle(location, 0.5, 0.5, 0.5, 0.0)); - case ENCHANT: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 1.0)); - case ENCHANTED_HIT: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case END_ROD: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case ENTITY_EFFECT: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case EXPLOSION: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case EXPLOSION_EMITTER: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case FALLING_DUST: - for (int i = 0; i < 2; i++) - particles.add(new PParticle(location.add(0, 0.75, 0), 0.6, 0.4, 0.6, 0.0)); - return particles; - case FIREWORK: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case FISHING: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case FLAME: - return Collections.singletonList(new PParticle(location, 0.1, 0.1, 0.1, 0.05)); - case FOOTSTEP: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case HAPPY_VILLAGER: - return Collections.singletonList(new PParticle(location, 0.5, 0.5, 0.5, 0.0)); - case HEART: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0)); - case INSTANT_EFFECT: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case ITEM: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0)); - case ITEM_SLIME: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case ITEM_SNOWBALL: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case LARGE_SMOKE: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case LAVA: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case MYCELIUM: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case NAUTILUS: - return Collections.singletonList(new PParticle(location, 0.5, 0.5, 0.5, 1.0)); - case NOTE: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0)); - case POOF: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case PORTAL: - return Collections.singletonList(new PParticle(location, 0.5, 0.5, 0.5, 1.0)); - case RAIN: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case SMOKE: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case SPELL: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case SPIT: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0)); - case SPLASH: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case SQUID_INK: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0)); - case SWEEP_ATTACK: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - case TOTEM_OF_UNDYING: - return Collections.singletonList(new PParticle(location, 0.6, 0.6, 0.6, 0.0)); - case UNDERWATER: - for (int i = 0; i < 5; i++) - particles.add(new PParticle(location, 0.5, 0.5, 0.5, 0.0)); - return particles; - case WITCH: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - default: - return Collections.singletonList(new PParticle(location, 0.4, 0.4, 0.4, 0.0)); - } - } - - @Override - public void updateTimers() { - - } - - @Override - protected void setDefaultSettings(CommentedFileConfiguration config) { - - } - - @Override - protected void loadSettings(CommentedFileConfiguration config) { - - } - -}