Added 1.17 particles

This commit is contained in:
Esophose 2021-06-21 13:26:50 -06:00
parent 70c398c41e
commit dc72e39f46
No known key found for this signature in database
GPG key ID: DE0E013CAE5C630A
62 changed files with 1378 additions and 379 deletions

View file

@ -1,16 +1,16 @@
import org.apache.tools.ant.filters.ReplaceTokens import org.apache.tools.ant.filters.ReplaceTokens
plugins { plugins {
id 'com.github.johnrengelman.shadow' version '5.1.0' id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'maven-publish' id 'maven-publish'
id 'java' id 'java-library'
} }
sourceCompatibility = 1.8 sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
compileJava.options.encoding = 'UTF-8' compileJava.options.encoding = 'UTF-8'
group = 'dev.esophose' group = 'dev.esophose'
version = '7.19' version = '7.20'
java { java {
withJavadocJar() withJavadocJar()
@ -19,25 +19,24 @@ java {
repositories { repositories {
mavenCentral() mavenCentral()
jcenter()
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' } maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url = 'https://repo.codemc.org/repository/maven-public' } maven { url = 'https://repo.codemc.org/repository/maven-public' }
maven { url = 'http://repo.extendedclip.com/content/repositories/placeholderapi/' } maven { url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
maven { url = 'https://repo.rosewooddev.io/repository/public/' } maven { url = 'https://repo.rosewooddev.io/repository/public/' }
} }
dependencies { dependencies {
compile 'org.slf4j:slf4j-api:1.7.25' api 'org.slf4j:slf4j-api:1.7.25'
compile 'org.slf4j:slf4j-nop:1.7.25' api 'org.slf4j:slf4j-nop:1.7.25'
compile 'com.zaxxer:HikariCP:3.2.0' api 'com.zaxxer:HikariCP:3.2.0'
compile 'org.bstats:bstats-bukkit-lite:1.7' api 'org.bstats:bstats-bukkit-lite:1.7'
compile 'org.codemc.worldguardwrapper:worldguardwrapper:1.2.0-SNAPSHOT' api 'org.codemc.worldguardwrapper:worldguardwrapper:1.2.0-SNAPSHOT'
compileOnly 'com.googlecode.json-simple:json-simple:1.1.1' compileOnly 'com.googlecode.json-simple:json-simple:1.1.1'
compileOnly 'org.jetbrains:annotations:16.0.2' compileOnly 'org.jetbrains:annotations:16.0.2'
compileOnly 'me.clip:placeholderapi:2.10.4' compileOnly 'me.clip:placeholderapi:2.10.4'
compileOnly 'org.xerial:sqlite-jdbc:3.23.1' compileOnly 'org.xerial:sqlite-jdbc:3.23.1'
compileOnly 'org.spigotmc:spigot:1.16.3' compileOnly 'org.spigotmc:spigot:1.17'
} }
shadowJar { shadowJar {
@ -54,6 +53,7 @@ processResources {
from (sourceSets.main.resources.srcDirs) { from (sourceSets.main.resources.srcDirs) {
include '**/*.yml' include '**/*.yml'
filter ReplaceTokens, tokens: ["version": project.property("version")] filter ReplaceTokens, tokens: ["version": project.property("version")]
duplicatesStrategy DuplicatesStrategy.INCLUDE
} }
} }

Binary file not shown.

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

2
gradlew vendored
View file

@ -82,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath # We build the pattern for arguments to be converted via cygpath

25
gradlew.bat vendored
View file

@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -51,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -61,28 +64,14 @@ echo location of your Java installation.
goto fail goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell

View file

@ -1 +1 @@
rootProject.name = 'playerparticles' rootProject.name = 'PlayerParticles'

View file

@ -10,8 +10,10 @@ import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.NoteColor; import dev.esophose.playerparticles.particles.data.NoteColor;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.styles.ParticleStyle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -163,7 +165,7 @@ public final class PlayerParticlesAPI {
*/ */
@Nullable @Nullable
public ParticlePair addActivePlayerParticle(@NotNull Player player, @NotNull ParticleEffect effect, @NotNull ParticleStyle style) { public ParticlePair addActivePlayerParticle(@NotNull Player player, @NotNull ParticleEffect effect, @NotNull ParticleStyle style) {
return this.addActivePlayerParticle(player, effect, style, null, null, null); return this.addActivePlayerParticle(player, effect, style, null, null, null, null, null);
} }
/** /**
@ -177,7 +179,7 @@ public final class PlayerParticlesAPI {
*/ */
@Nullable @Nullable
public ParticlePair addActivePlayerParticle(@NotNull Player player, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull OrdinaryColor colorData) { public ParticlePair addActivePlayerParticle(@NotNull Player player, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull OrdinaryColor colorData) {
return this.addActivePlayerParticle(player, effect, style, colorData, null, null); return this.addActivePlayerParticle(player, effect, style, colorData, null, null, null, null);
} }
/** /**
@ -191,7 +193,7 @@ public final class PlayerParticlesAPI {
*/ */
@Nullable @Nullable
public ParticlePair addActivePlayerParticle(@NotNull Player player, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull NoteColor noteColorData) { public ParticlePair addActivePlayerParticle(@NotNull Player player, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull NoteColor noteColorData) {
return this.addActivePlayerParticle(player, effect, style, null, noteColorData, null); return this.addActivePlayerParticle(player, effect, style, null, noteColorData, null, null, null);
} }
/** /**
@ -205,7 +207,35 @@ public final class PlayerParticlesAPI {
*/ */
@Nullable @Nullable
public ParticlePair addActivePlayerParticle(@NotNull Player player, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull Material materialData) { public ParticlePair addActivePlayerParticle(@NotNull Player player, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull Material materialData) {
return this.addActivePlayerParticle(player, effect, style, null, null, materialData); return this.addActivePlayerParticle(player, effect, style, null, null, materialData, null, null);
}
/**
* Adds an active particle to a Player's particles
*
* @param player The player to add to
* @param effect The effect of the particle
* @param style The style of the particle
* @param colorTransitionData The color transition data of the particle
* @return The ParticlePair that was added or null if failed
*/
@Nullable
public ParticlePair addActivePlayerParticle(@NotNull Player player, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull ColorTransition colorTransitionData) {
return this.addActivePlayerParticle(player, effect, style, null, null, null, colorTransitionData, null);
}
/**
* Adds an active particle to a Player's particles
*
* @param player The player to add to
* @param effect The effect of the particle
* @param style The style of the particle
* @param vibrationData The vibration data of the particle
* @return The ParticlePair that was added or null if failed
*/
@Nullable
public ParticlePair addActivePlayerParticle(@NotNull Player player, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull Vibration vibrationData) {
return this.addActivePlayerParticle(player, effect, style, null, null, null, null, vibrationData);
} }
/** /**
@ -216,9 +246,10 @@ public final class PlayerParticlesAPI {
* @param noteColorData The note color data of the particle * @param noteColorData The note color data of the particle
* @param materialData The material data of the particle * @param materialData The material data of the particle
* @return The ParticlePair that was added or null if failed * @return The ParticlePair that was added or null if failed
* @deprecated Use
*/ */
@Nullable @Nullable
private ParticlePair addActivePlayerParticle(@NotNull Player player, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @Nullable OrdinaryColor colorData, @Nullable NoteColor noteColorData, @Nullable Material materialData) { private ParticlePair addActivePlayerParticle(@NotNull Player player, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @Nullable OrdinaryColor colorData, @Nullable NoteColor noteColorData, @Nullable Material materialData, @Nullable ColorTransition colorTransitionData, @Nullable Vibration vibrationData) {
Objects.requireNonNull(effect); Objects.requireNonNull(effect);
Objects.requireNonNull(style); Objects.requireNonNull(style);
@ -236,7 +267,7 @@ public final class PlayerParticlesAPI {
} }
} }
ParticlePair particle = new ParticlePair(player.getUniqueId(), pplayer.getNextActiveParticleId(), effect, style, itemMaterialData, blockMaterialData, colorData, noteColorData); ParticlePair particle = new ParticlePair(player.getUniqueId(), pplayer.getNextActiveParticleId(), effect, style, itemMaterialData, blockMaterialData, colorData, noteColorData, colorTransitionData, vibrationData);
this.addActivePlayerParticle(player, particle); this.addActivePlayerParticle(player, particle);
return particle; return particle;
} }
@ -677,7 +708,7 @@ public final class PlayerParticlesAPI {
*/ */
@Nullable @Nullable
public FixedParticleEffect createFixedParticleEffect(@NotNull CommandSender sender, @NotNull Location location, @NotNull ParticleEffect effect, @NotNull ParticleStyle style) { public FixedParticleEffect createFixedParticleEffect(@NotNull CommandSender sender, @NotNull Location location, @NotNull ParticleEffect effect, @NotNull ParticleStyle style) {
return this.createFixedParticleEffect(sender, location, effect, style, null, null, null); return this.createFixedParticleEffect(sender, location, effect, style, null, null, null, null, null);
} }
/** /**
@ -692,7 +723,7 @@ public final class PlayerParticlesAPI {
*/ */
@Nullable @Nullable
public FixedParticleEffect createFixedParticleEffect(@NotNull CommandSender sender, @NotNull Location location, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull OrdinaryColor colorData) { public FixedParticleEffect createFixedParticleEffect(@NotNull CommandSender sender, @NotNull Location location, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull OrdinaryColor colorData) {
return this.createFixedParticleEffect(sender, location, effect, style, colorData, null, null); return this.createFixedParticleEffect(sender, location, effect, style, colorData, null, null, null, null);
} }
/** /**
@ -707,7 +738,7 @@ public final class PlayerParticlesAPI {
*/ */
@Nullable @Nullable
public FixedParticleEffect createFixedParticleEffect(@NotNull CommandSender sender, @NotNull Location location, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull NoteColor noteColorData) { public FixedParticleEffect createFixedParticleEffect(@NotNull CommandSender sender, @NotNull Location location, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull NoteColor noteColorData) {
return this.createFixedParticleEffect(sender, location, effect, style, null, noteColorData, null); return this.createFixedParticleEffect(sender, location, effect, style, null, noteColorData, null, null, null);
} }
/** /**
@ -722,7 +753,37 @@ public final class PlayerParticlesAPI {
*/ */
@Nullable @Nullable
public FixedParticleEffect createFixedParticleEffect(@NotNull CommandSender sender, @NotNull Location location, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull Material materialData) { public FixedParticleEffect createFixedParticleEffect(@NotNull CommandSender sender, @NotNull Location location, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull Material materialData) {
return this.createFixedParticleEffect(sender, location, effect, style, null, null, materialData); return this.createFixedParticleEffect(sender, location, effect, style, null, null, materialData, null, null);
}
/**
* Creates a fixed particle effect for a player
*
* @param sender The sender to create for, either a Player or ConsoleCommandSender
* @param location The location to create at
* @param effect The effect of the particle
* @param style The style of the particle
* @param colorTransitionData The color transition data of the particle
* @return The FixedParticleEffect that was created or null if failed
*/
@Nullable
public FixedParticleEffect createFixedParticleEffect(@NotNull CommandSender sender, @NotNull Location location, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull ColorTransition colorTransitionData) {
return this.createFixedParticleEffect(sender, location, effect, style, null, null, null, colorTransitionData, null);
}
/**
* Creates a fixed particle effect for a player
*
* @param sender The sender to create for, either a Player or ConsoleCommandSender
* @param location The location to create at
* @param effect The effect of the particle
* @param style The style of the particle
* @param vibrationData The vibration data of the particle
* @return The FixedParticleEffect that was created or null if failed
*/
@Nullable
public FixedParticleEffect createFixedParticleEffect(@NotNull CommandSender sender, @NotNull Location location, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @NotNull Vibration vibrationData) {
return this.createFixedParticleEffect(sender, location, effect, style, null, null, null, null, vibrationData);
} }
/** /**
@ -738,7 +799,7 @@ public final class PlayerParticlesAPI {
* @return The FixedParticleEffect that was created or null if failed * @return The FixedParticleEffect that was created or null if failed
*/ */
@Nullable @Nullable
private FixedParticleEffect createFixedParticleEffect(@NotNull CommandSender sender, @NotNull Location location, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @Nullable OrdinaryColor colorData, @Nullable NoteColor noteColorData, @Nullable Material materialData) { private FixedParticleEffect createFixedParticleEffect(@NotNull CommandSender sender, @NotNull Location location, @NotNull ParticleEffect effect, @NotNull ParticleStyle style, @Nullable OrdinaryColor colorData, @Nullable NoteColor noteColorData, @Nullable Material materialData, @Nullable ColorTransition colorTransitionData, @Nullable Vibration vibrationData) {
Objects.requireNonNull(location); Objects.requireNonNull(location);
Objects.requireNonNull(location.getWorld()); Objects.requireNonNull(location.getWorld());
Objects.requireNonNull(effect); Objects.requireNonNull(effect);
@ -758,7 +819,7 @@ public final class PlayerParticlesAPI {
} }
} }
ParticlePair particle = new ParticlePair(pplayer.getUniqueId(), 1, effect, style, itemMaterialData, blockMaterialData, colorData, noteColorData); ParticlePair particle = new ParticlePair(pplayer.getUniqueId(), 1, effect, style, itemMaterialData, blockMaterialData, colorData, noteColorData, colorTransitionData, vibrationData);
return this.createFixedParticleEffect(sender, location, particle); return this.createFixedParticleEffect(sender, location, particle);
} }
@ -961,7 +1022,7 @@ public final class PlayerParticlesAPI {
ParticleManager particleManager = this.playerParticles.getManager(ParticleManager.class); ParticleManager particleManager = this.playerParticles.getManager(ParticleManager.class);
int removedAmount = 0; int removedAmount = 0;
for (PPlayer pplayer : particleManager.getPPlayers()) { for (PPlayer pplayer : particleManager.getPPlayers().values()) {
Set<Integer> removedIds = new HashSet<>(); Set<Integer> removedIds = new HashSet<>();
for (FixedParticleEffect fixedEffect : pplayer.getFixedParticles()) for (FixedParticleEffect fixedEffect : pplayer.getFixedParticles())
if (fixedEffect.getLocation().getWorld() == location.getWorld() && fixedEffect.getLocation().distance(location) <= radius) if (fixedEffect.getLocation().getWorld() == location.getWorld() && fixedEffect.getLocation().distance(location) <= radius)

View file

@ -10,14 +10,17 @@ import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.NoteColor; import dev.esophose.playerparticles.particles.data.NoteColor;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders; import dev.esophose.playerparticles.util.StringPlaceholders;
import dev.esophose.playerparticles.util.inputparser.InputParser; import dev.esophose.playerparticles.util.inputparser.InputParser;
import dev.esophose.playerparticles.util.inputparser.parsable.ParsableOrdinaryColor; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableOrdinaryColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
@ -64,6 +67,8 @@ public class AddCommandModule implements CommandModule {
Material blockData = null; Material blockData = null;
OrdinaryColor colorData = null; OrdinaryColor colorData = null;
NoteColor noteColorData = null; NoteColor noteColorData = null;
ColorTransition colorTransitionData = null;
Vibration vibrationData = null;
if (args.length > 2) { if (args.length > 2) {
if (effect.hasProperty(ParticleProperty.COLORABLE)) { if (effect.hasProperty(ParticleProperty.COLORABLE)) {
@ -94,11 +99,23 @@ public class AddCommandModule implements CommandModule {
return; return;
} }
} }
} else if (effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
colorTransitionData = inputParser.next(ColorTransition.class);
if (colorTransitionData == null) {
localeManager.sendMessage(pplayer, "data-invalid-color-transition");
return;
}
} else if (effect.hasProperty(ParticleProperty.VIBRATION)) {
vibrationData = inputParser.next(Vibration.class);
if (vibrationData == null) {
localeManager.sendMessage(pplayer, "data-invalid-vibration");
return;
}
} }
} }
ParticleGroup group = pplayer.getActiveParticleGroup(); ParticleGroup group = pplayer.getActiveParticleGroup();
ParticlePair newParticle = new ParticlePair(pplayer.getUniqueId(), pplayer.getNextActiveParticleId(), effect, style, itemData, blockData, colorData, noteColorData); ParticlePair newParticle = new ParticlePair(pplayer.getUniqueId(), pplayer.getNextActiveParticleId(), effect, style, itemData, blockData, colorData, noteColorData, colorTransitionData, vibrationData);
group.getParticles().put(newParticle.getId(), newParticle); group.getParticles().put(newParticle.getId(), newParticle);
PlayerParticlesAPI.getInstance().savePlayerParticleGroup(pplayer.getPlayer(), group); PlayerParticlesAPI.getInstance().savePlayerParticleGroup(pplayer.getPlayer(), group);
@ -136,11 +153,11 @@ public class AddCommandModule implements CommandModule {
} else { // Color data } else { // Color data
if (args.length <= 3) { if (args.length <= 3) {
possibleValues.add("<0-255> <0-255> <0-255>"); possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.getColorNameMap().keySet()); possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>"); possibleValues.add("<#hexCode>");
} else if (args.length <= 4 && !ParsableOrdinaryColor.getColorNameMap().containsKey(args[2].toLowerCase())) { } else if (args.length <= 4 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[2].toLowerCase())) {
possibleValues.add("<0-255> <0-255>"); possibleValues.add("<0-255> <0-255>");
} else if (args.length <= 5 && !ParsableOrdinaryColor.getColorNameMap().containsKey(args[2].toLowerCase())) { } else if (args.length <= 5 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[2].toLowerCase())) {
possibleValues.add("<0-255>"); possibleValues.add("<0-255>");
} }
} }
@ -151,6 +168,37 @@ public class AddCommandModule implements CommandModule {
} else if (effect == ParticleEffect.ITEM) { // Item material } else if (effect == ParticleEffect.ITEM) { // Item material
StringUtil.copyPartialMatches(args[2], ParticleUtils.ITEM_MATERIALS_STRING, matches); StringUtil.copyPartialMatches(args[2], ParticleUtils.ITEM_MATERIALS_STRING, matches);
} }
} else if (effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
String[] dataArgs = Arrays.copyOfRange(args, 2, args.length);
InputParser inputParser = new InputParser(pplayer, dataArgs);
List<String> possibleValues = new ArrayList<>();
boolean firstComplete = inputParser.next(OrdinaryColor.class) == null;
int argsRemaining = inputParser.numRemaining();
int nextStart = 2 + dataArgs.length - argsRemaining;
if (firstComplete) {
if (args.length <= 3) {
possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>");
} else if (args.length <= 4 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[2].toLowerCase())) {
possibleValues.add("<0-255> <0-255>");
} else if (args.length <= 5 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[2].toLowerCase())) {
possibleValues.add("<0-255>");
}
} else if (inputParser.next(OrdinaryColor.class) == null) {
if (argsRemaining == 1) {
possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>");
} else if (argsRemaining == 2 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[nextStart].toLowerCase())) {
possibleValues.add("<0-255> <0-255>");
} else if (argsRemaining == 3 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[nextStart].toLowerCase())) {
possibleValues.add("<0-255>");
}
}
StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches);
} else if (args.length == 3 && effect.hasProperty(ParticleProperty.VIBRATION)) {
return Arrays.asList("<duration>", "20", "40", "60");
} }
} }
} }

View file

@ -36,6 +36,10 @@ public class DataCommandModule implements CommandModule {
} else { } else {
localeManager.sendMessage(pplayer, "data-usage-block", StringPlaceholders.single("effect", effect.getName())); localeManager.sendMessage(pplayer, "data-usage-block", StringPlaceholders.single("effect", effect.getName()));
} }
} else if (effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
localeManager.sendMessage(pplayer, "data-usage-color-transition", StringPlaceholders.single("effect", effect.getName()));
} else if (effect.hasProperty(ParticleProperty.VIBRATION)) {
localeManager.sendMessage(pplayer, "data-usage-vibration", StringPlaceholders.single("effect", effect.getName()));
} else { } else {
localeManager.sendMessage(pplayer, "data-usage-none", StringPlaceholders.single("effect", effect.getName())); localeManager.sendMessage(pplayer, "data-usage-none", StringPlaceholders.single("effect", effect.getName()));
} }

View file

@ -9,14 +9,17 @@ import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.NoteColor; import dev.esophose.playerparticles.particles.data.NoteColor;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders; import dev.esophose.playerparticles.util.StringPlaceholders;
import dev.esophose.playerparticles.util.inputparser.InputParser; import dev.esophose.playerparticles.util.inputparser.InputParser;
import dev.esophose.playerparticles.util.inputparser.parsable.ParsableOrdinaryColor; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableOrdinaryColor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
@ -147,6 +150,8 @@ public class EditCommandModule implements CommandModule {
Material blockData = null; Material blockData = null;
OrdinaryColor colorData = null; OrdinaryColor colorData = null;
NoteColor noteColorData = null; NoteColor noteColorData = null;
ColorTransition colorTransitionData = null;
Vibration vibrationData = null;
ParticleEffect effect = pplayer.getActiveParticle(id).getEffect(); ParticleEffect effect = pplayer.getActiveParticle(id).getEffect();
@ -179,6 +184,18 @@ public class EditCommandModule implements CommandModule {
return; return;
} }
} }
} else if (effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
colorTransitionData = inputParser.next(ColorTransition.class);
if (colorTransitionData == null) {
localeManager.sendMessage(pplayer, "data-invalid-color-transition");
return;
}
} else if (effect.hasProperty(ParticleProperty.VIBRATION)) {
vibrationData = inputParser.next(Vibration.class);
if (vibrationData == null) {
localeManager.sendMessage(pplayer, "data-invalid-vibration");
return;
}
} }
String updatedDataString = null; String updatedDataString = null;
@ -189,6 +206,8 @@ public class EditCommandModule implements CommandModule {
if (blockData != null) particle.setBlockMaterial(blockData); if (blockData != null) particle.setBlockMaterial(blockData);
if (colorData != null) particle.setColor(colorData); if (colorData != null) particle.setColor(colorData);
if (noteColorData != null) particle.setNoteColor(noteColorData); if (noteColorData != null) particle.setNoteColor(noteColorData);
if (colorTransitionData != null) particle.setColorTransition(colorTransitionData);
if (vibrationData != null) particle.setVibration(vibrationData);
updatedDataString = particle.getDataString(); updatedDataString = particle.getDataString();
break; break;
} }
@ -248,11 +267,11 @@ public class EditCommandModule implements CommandModule {
} else { // Color data } else { // Color data
if (args.length <= 3) { if (args.length <= 3) {
possibleValues.add("<0-255> <0-255> <0-255>"); possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.getColorNameMap().keySet()); possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>"); possibleValues.add("<#hexCode>");
} else if (args.length <= 4 && !ParsableOrdinaryColor.getColorNameMap().containsKey(args[2].toLowerCase())) { } else if (args.length <= 4 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[2].toLowerCase())) {
possibleValues.add("<0-255> <0-255>"); possibleValues.add("<0-255> <0-255>");
} else if (args.length <= 5 && !ParsableOrdinaryColor.getColorNameMap().containsKey(args[2].toLowerCase())) { } else if (args.length <= 5 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[2].toLowerCase())) {
possibleValues.add("<0-255>"); possibleValues.add("<0-255>");
} }
} }
@ -263,6 +282,37 @@ public class EditCommandModule implements CommandModule {
} else if (effect == ParticleEffect.ITEM) { // Item material } else if (effect == ParticleEffect.ITEM) { // Item material
StringUtil.copyPartialMatches(args[2], ParticleUtils.ITEM_MATERIALS_STRING, matches); StringUtil.copyPartialMatches(args[2], ParticleUtils.ITEM_MATERIALS_STRING, matches);
} }
} else if (effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
String[] dataArgs = Arrays.copyOfRange(args, 2, args.length);
InputParser inputParser = new InputParser(pplayer, dataArgs);
List<String> possibleValues = new ArrayList<>();
boolean firstComplete = inputParser.next(OrdinaryColor.class) == null;
int argsRemaining = inputParser.numRemaining();
int nextStart = 2 + dataArgs.length - argsRemaining;
if (firstComplete) {
if (args.length <= 3) {
possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>");
} else if (args.length <= 4 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[2].toLowerCase())) {
possibleValues.add("<0-255> <0-255>");
} else if (args.length <= 5 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[2].toLowerCase())) {
possibleValues.add("<0-255>");
}
} else if (inputParser.next(OrdinaryColor.class) == null) {
if (argsRemaining == 1) {
possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>");
} else if (argsRemaining == 2 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[nextStart].toLowerCase())) {
possibleValues.add("<0-255> <0-255>");
} else if (argsRemaining == 3 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[nextStart].toLowerCase())) {
possibleValues.add("<0-255>");
}
}
StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches);
} else if (args.length == 3 && effect.hasProperty(ParticleProperty.VIBRATION)) {
return Arrays.asList("<duration>", "20", "40", "60");
} }
break; break;
} }

View file

@ -9,8 +9,10 @@ import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.NoteColor; import dev.esophose.playerparticles.particles.data.NoteColor;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders; import dev.esophose.playerparticles.util.StringPlaceholders;
@ -194,8 +196,10 @@ public class FixedCommandModule implements CommandModule {
Material blockData = null; Material blockData = null;
OrdinaryColor colorData = null; OrdinaryColor colorData = null;
NoteColor noteColorData = null; NoteColor noteColorData = null;
ColorTransition colorTransitionData = null;
Vibration vibrationData = null;
if (inputParser.hasNext() && (effect.hasProperty(ParticleProperty.COLORABLE) || effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA))) { if (inputParser.hasNext()) {
if (effect.hasProperty(ParticleProperty.COLORABLE)) { if (effect.hasProperty(ParticleProperty.COLORABLE)) {
if (effect == ParticleEffect.NOTE) { if (effect == ParticleEffect.NOTE) {
noteColorData = inputParser.next(NoteColor.class); noteColorData = inputParser.next(NoteColor.class);
@ -224,10 +228,22 @@ public class FixedCommandModule implements CommandModule {
return; return;
} }
} }
} else if (effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
colorTransitionData = inputParser.next(ColorTransition.class);
if (colorTransitionData == null) {
localeManager.sendMessage(pplayer, "fixed-create-data-error");
return;
}
} else if (effect.hasProperty(ParticleProperty.VIBRATION)) {
vibrationData = inputParser.next(Vibration.class);
if (vibrationData == null) {
localeManager.sendMessage(pplayer, "fixed-create-data-error");
return;
}
} }
} }
ParticlePair particle = new ParticlePair(pplayer.getUniqueId(), pplayer.getNextFixedEffectId(), effect, style, itemData, blockData, colorData, noteColorData); ParticlePair particle = new ParticlePair(pplayer.getUniqueId(), pplayer.getNextFixedEffectId(), effect, style, itemData, blockData, colorData, noteColorData, colorTransitionData, vibrationData);
PlayerParticlesAPI.getInstance().createFixedParticleEffect(player == null ? Bukkit.getConsoleSender() : player, location, particle); PlayerParticlesAPI.getInstance().createFixedParticleEffect(player == null ? Bukkit.getConsoleSender() : player, location, particle);
localeManager.sendMessage(pplayer, "fixed-create-success"); localeManager.sendMessage(pplayer, "fixed-create-success");
} }
@ -319,6 +335,8 @@ public class FixedCommandModule implements CommandModule {
Material blockData = null; Material blockData = null;
OrdinaryColor colorData = null; OrdinaryColor colorData = null;
NoteColor noteColorData = null; NoteColor noteColorData = null;
ColorTransition colorTransitionData = null;
Vibration vibrationData = null;
ParticleEffect effect = fixedEffect.getParticlePair().getEffect(); ParticleEffect effect = fixedEffect.getParticlePair().getEffect();
if (effect.hasProperty(ParticleProperty.COLORABLE)) { if (effect.hasProperty(ParticleProperty.COLORABLE)) {
@ -349,6 +367,18 @@ public class FixedCommandModule implements CommandModule {
return; return;
} }
} }
} else if (effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
colorTransitionData = inputParser.next(ColorTransition.class);
if (colorTransitionData == null) {
localeManager.sendMessage(pplayer, "fixed-edit-data-error");
return;
}
} else if (effect.hasProperty(ParticleProperty.VIBRATION)) {
vibrationData = inputParser.next(Vibration.class);
if (vibrationData == null) {
localeManager.sendMessage(pplayer, "fixed-edit-data-error");
return;
}
} else { } else {
localeManager.sendMessage(pplayer, "fixed-edit-data-none"); localeManager.sendMessage(pplayer, "fixed-edit-data-none");
return; return;
@ -358,6 +388,8 @@ public class FixedCommandModule implements CommandModule {
fixedEffect.getParticlePair().setNoteColor(noteColorData); fixedEffect.getParticlePair().setNoteColor(noteColorData);
fixedEffect.getParticlePair().setItemMaterial(itemData); fixedEffect.getParticlePair().setItemMaterial(itemData);
fixedEffect.getParticlePair().setBlockMaterial(blockData); fixedEffect.getParticlePair().setBlockMaterial(blockData);
fixedEffect.getParticlePair().setColorTransition(colorTransitionData);
fixedEffect.getParticlePair().setVibration(vibrationData);
break; break;
} }
default: default:
@ -638,11 +670,11 @@ public class FixedCommandModule implements CommandModule {
} else { // Color data } else { // Color data
if (args.length <= 7) { if (args.length <= 7) {
possibleValues.add("<0-255> <0-255> <0-255>"); possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.getColorNameMap().keySet()); possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>"); possibleValues.add("<#hexCode>");
} else if (args.length <= 8 && !ParsableOrdinaryColor.getColorNameMap().containsKey(args[2].toLowerCase())) { } else if (args.length <= 8 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[6].toLowerCase())) {
possibleValues.add("<0-255> <0-255>"); possibleValues.add("<0-255> <0-255>");
} else if (args.length <= 9 && !ParsableOrdinaryColor.getColorNameMap().containsKey(args[2].toLowerCase())) { } else if (args.length <= 9 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[6].toLowerCase())) {
possibleValues.add("<0-255>"); possibleValues.add("<0-255>");
} }
} }
@ -653,6 +685,37 @@ public class FixedCommandModule implements CommandModule {
} else if (effect == ParticleEffect.ITEM) { // Item material } else if (effect == ParticleEffect.ITEM) { // Item material
StringUtil.copyPartialMatches(args[6], ParticleUtils.ITEM_MATERIALS_STRING, matches); StringUtil.copyPartialMatches(args[6], ParticleUtils.ITEM_MATERIALS_STRING, matches);
} }
} else if (effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
String[] dataArgs = Arrays.copyOfRange(args, 6, args.length);
InputParser inputParser = new InputParser(pplayer, dataArgs);
List<String> possibleValues = new ArrayList<>();
boolean firstComplete = inputParser.next(OrdinaryColor.class) == null;
int argsRemaining = inputParser.numRemaining();
int nextStart = 6 + dataArgs.length - argsRemaining;
if (firstComplete) {
if (args.length <= 7) {
possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>");
} else if (args.length <= 8 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[6].toLowerCase())) {
possibleValues.add("<0-255> <0-255>");
} else if (args.length <= 9 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[6].toLowerCase())) {
possibleValues.add("<0-255>");
}
} else if (inputParser.next(OrdinaryColor.class) == null) {
if (argsRemaining == 1) {
possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>");
} else if (argsRemaining == 2 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[nextStart].toLowerCase())) {
possibleValues.add("<0-255> <0-255>");
} else if (argsRemaining == 3 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[nextStart].toLowerCase())) {
possibleValues.add("<0-255>");
}
}
StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches);
} else if (args.length == 7 && effect.hasProperty(ParticleProperty.VIBRATION)) {
return Arrays.asList("<duration>", "20", "40", "60");
} }
} }
} }
@ -701,7 +764,7 @@ public class FixedCommandModule implements CommandModule {
int id = -1; int id = -1;
try { try {
id = Integer.parseInt(args[1]); id = Integer.parseInt(args[1]);
} catch (Exception e) { } } catch (Exception ignored) { }
FixedParticleEffect fixedEffect = pplayer.getFixedEffectById(id); FixedParticleEffect fixedEffect = pplayer.getFixedEffectById(id);
if (fixedEffect != null) { if (fixedEffect != null) {
@ -717,11 +780,11 @@ public class FixedCommandModule implements CommandModule {
} else { // Color data } else { // Color data
if (args.length <= 4) { if (args.length <= 4) {
possibleValues.add("<0-255> <0-255> <0-255>"); possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.getColorNameMap().keySet()); possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>"); possibleValues.add("<#hexCode>");
} else if (args.length <= 5 && !ParsableOrdinaryColor.getColorNameMap().containsKey(args[3].toLowerCase())) { } else if (args.length <= 5 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[3].toLowerCase())) {
possibleValues.add("<0-255> <0-255>"); possibleValues.add("<0-255> <0-255>");
} else if (args.length <= 6 && !ParsableOrdinaryColor.getColorNameMap().containsKey(args[3].toLowerCase())) { } else if (args.length <= 6 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[3].toLowerCase())) {
possibleValues.add("<0-255>"); possibleValues.add("<0-255>");
} }
} }
@ -732,6 +795,37 @@ public class FixedCommandModule implements CommandModule {
} else if (effect == ParticleEffect.ITEM) { // Item material } else if (effect == ParticleEffect.ITEM) { // Item material
StringUtil.copyPartialMatches(args[3], ParticleUtils.ITEM_MATERIALS_STRING, matches); StringUtil.copyPartialMatches(args[3], ParticleUtils.ITEM_MATERIALS_STRING, matches);
} }
} else if (effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
String[] dataArgs = Arrays.copyOfRange(args, 3, args.length);
InputParser inputParser = new InputParser(pplayer, dataArgs);
List<String> possibleValues = new ArrayList<>();
boolean firstComplete = inputParser.next(OrdinaryColor.class) == null;
int argsRemaining = inputParser.numRemaining();
int nextStart = 3 + dataArgs.length - argsRemaining;
if (firstComplete) {
if (args.length <= 4) {
possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>");
} else if (args.length <= 5 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[3].toLowerCase())) {
possibleValues.add("<0-255> <0-255>");
} else if (args.length <= 6 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[3].toLowerCase())) {
possibleValues.add("<0-255>");
}
} else if (inputParser.next(OrdinaryColor.class) == null) {
if (argsRemaining == 1) {
possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>");
} else if (argsRemaining == 2 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[nextStart].toLowerCase())) {
possibleValues.add("<0-255> <0-255>");
} else if (argsRemaining == 3 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[nextStart].toLowerCase())) {
possibleValues.add("<0-255>");
}
}
StringUtil.copyPartialMatches(args[args.length - 1], possibleValues, matches);
} else if (args.length == 4 && effect.hasProperty(ParticleProperty.VIBRATION)) {
return Arrays.asList("<duration>", "20", "40", "60");
} }
} }
} }

View file

@ -9,8 +9,10 @@ import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.NoteColor; import dev.esophose.playerparticles.particles.data.NoteColor;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders; import dev.esophose.playerparticles.util.StringPlaceholders;
@ -100,6 +102,20 @@ public class UseCommandModule implements CommandModule {
} }
primaryParticle.setItemMaterial(itemData); primaryParticle.setItemMaterial(itemData);
} }
} else if (effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
ColorTransition colorTransitionData = inputParser.next(ColorTransition.class);
if (colorTransitionData == null) {
localeManager.sendMessage(pplayer, "data-invalid-color-transition");
return;
}
primaryParticle.setColorTransition(colorTransitionData);
} else if (effect.hasProperty(ParticleProperty.VIBRATION)) {
Vibration vibrationData = inputParser.next(Vibration.class);
if (vibrationData == null) {
localeManager.sendMessage(pplayer, "data-invalid-vibration");
return;
}
primaryParticle.setVibration(vibrationData);
} }
break; break;
} }
@ -152,20 +168,49 @@ public class UseCommandModule implements CommandModule {
} else { // Color data } else { // Color data
if (args.length == 2) { if (args.length == 2) {
possibleValues.add("<0-255> <0-255> <0-255>"); possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.getColorNameMap().keySet()); possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>"); possibleValues.add("<#hexCode>");
} else if (args.length <= 3 && !ParsableOrdinaryColor.getColorNameMap().containsKey(args[1].toLowerCase())) { } else if (args.length <= 3 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[1].toLowerCase())) {
possibleValues.add("<0-255> <0-255>"); possibleValues.add("<0-255> <0-255>");
} else if (args.length <= 4 && !ParsableOrdinaryColor.getColorNameMap().containsKey(args[1].toLowerCase())) { } else if (args.length <= 4 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[1].toLowerCase())) {
possibleValues.add("<0-255>"); possibleValues.add("<0-255>");
} }
} }
} else if (args.length == 3 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) { } else if (args.length == 2 && effect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material if (effect == ParticleEffect.BLOCK || effect == ParticleEffect.FALLING_DUST) { // Block material
possibleValues.addAll(ParticleUtils.BLOCK_MATERIALS_STRING); possibleValues.addAll(ParticleUtils.BLOCK_MATERIALS_STRING);
} else if (effect == ParticleEffect.ITEM) { // Item material } else if (effect == ParticleEffect.ITEM) { // Item material
possibleValues.addAll(ParticleUtils.ITEM_MATERIALS_STRING); possibleValues.addAll(ParticleUtils.ITEM_MATERIALS_STRING);
} }
} else if (effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
String[] dataArgs = Arrays.copyOfRange(args, 1, args.length);
InputParser inputParser = new InputParser(pplayer, dataArgs);
boolean firstComplete = inputParser.next(OrdinaryColor.class) == null;
int argsRemaining = inputParser.numRemaining();
int nextStart = 1 + dataArgs.length - argsRemaining;
if (firstComplete) {
if (args.length <= 2) {
possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>");
} else if (args.length <= 3 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[1].toLowerCase())) {
possibleValues.add("<0-255> <0-255>");
} else if (args.length <= 4 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[1].toLowerCase())) {
possibleValues.add("<0-255>");
}
} else if (inputParser.next(OrdinaryColor.class) == null) {
if (argsRemaining == 1) {
possibleValues.add("<0-255> <0-255> <0-255>");
possibleValues.addAll(ParsableOrdinaryColor.COLOR_NAME_MAP.keySet());
possibleValues.add("<#hexCode>");
} else if (argsRemaining == 2 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[nextStart].toLowerCase())) {
possibleValues.add("<0-255> <0-255>");
} else if (argsRemaining == 3 && !ParsableOrdinaryColor.COLOR_NAME_MAP.containsKey(args[nextStart].toLowerCase())) {
possibleValues.add("<0-255>");
}
}
} else if (args.length == 2 && effect.hasProperty(ParticleProperty.VIBRATION)) {
possibleValues.addAll(Arrays.asList("<duration>", "20", "40", "60"));
} }
break; break;
} }

View file

@ -0,0 +1,27 @@
package dev.esophose.playerparticles.database.migrations;
import dev.esophose.playerparticles.database.DataMigration;
import dev.esophose.playerparticles.database.DatabaseConnector;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
public class _2_Add_Data_Columns extends DataMigration {
public _2_Add_Data_Columns() {
super(2);
}
@Override
public void migrate(DatabaseConnector connector, Connection connection, String tablePrefix) throws SQLException {
try (Statement statement = connection.createStatement()) {
statement.addBatch("ALTER TABLE " + tablePrefix + "particle ADD COLUMN r_end SMALLINT DEFAULT 0");
statement.addBatch("ALTER TABLE " + tablePrefix + "particle ADD COLUMN g_end SMALLINT DEFAULT 0");
statement.addBatch("ALTER TABLE " + tablePrefix + "particle ADD COLUMN b_end SMALLINT DEFAULT 0");
statement.addBatch("ALTER TABLE " + tablePrefix + "particle ADD COLUMN duration INT DEFAULT 20");
statement.executeBatch();
}
}
}

View file

@ -8,7 +8,6 @@ import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.ParticleGroupPresetManager; import dev.esophose.playerparticles.manager.ParticleGroupPresetManager;
import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.ParticleUtils;
@ -121,7 +120,7 @@ public class GuiInventoryDefault extends GuiInventory {
final ParticlePair editingParticle = pplayer.getPrimaryParticle(); final ParticlePair editingParticle = pplayer.getPrimaryParticle();
boolean canEditPrimaryStyleAndData = pplayer.getActiveParticle(1) != null; 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 // Edit Primary Effect
GuiActionButton editPrimaryEffect = new GuiActionButton( GuiActionButton editPrimaryEffect = new GuiActionButton(
@ -217,7 +216,7 @@ public class GuiInventoryDefault extends GuiInventory {
List<Runnable> callbacks = new ArrayList<>(); List<Runnable> callbacks = new ArrayList<>();
callbacks.add(() -> guiManager.transition(new GuiInventoryDefault(pplayer))); callbacks.add(() -> guiManager.transition(new GuiInventoryDefault(pplayer)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1))); callbacks.add(() -> guiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1, null)));
callbacks.add(() -> { callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup(); ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles().values()) { for (ParticlePair particle : group.getParticles().values()) {

View file

@ -8,8 +8,10 @@ import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.NoteColor; import dev.esophose.playerparticles.particles.data.NoteColor;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.util.NMSUtil; import dev.esophose.playerparticles.util.NMSUtil;
import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.StringPlaceholders; import dev.esophose.playerparticles.util.StringPlaceholders;
@ -20,6 +22,9 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.type.Light;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockDataMeta;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class GuiInventoryEditData extends GuiInventory { public class GuiInventoryEditData extends GuiInventory {
@ -118,7 +123,7 @@ public class GuiInventoryEditData extends GuiInventory {
}; };
} }
public GuiInventoryEditData(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) { public GuiInventoryEditData(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition, OrdinaryColor startColor) {
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-select-data"))); super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-select-data")));
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class); LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
@ -138,6 +143,10 @@ public class GuiInventoryEditData extends GuiInventory {
} else { // Block data } else { // Block data
this.populateBlockData(editingParticle, pageNumber, callbackList, callbackListPosition); this.populateBlockData(editingParticle, pageNumber, callbackList, callbackListPosition);
} }
} else if (pe.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
this.populateColorTransitionData(editingParticle, callbackList, callbackListPosition, startColor);
} else if (pe.hasProperty(ParticleProperty.VIBRATION)) {
this.populateVibrationData(editingParticle, callbackList, callbackListPosition);
} }
// Back Button // Back Button
@ -198,7 +207,7 @@ public class GuiInventoryEditData extends GuiInventory {
}); });
this.actionButtons.add(setRainbowColorButton); this.actionButtons.add(setRainbowColorButton);
// Rainbow Color Data Button // Random Color Data Button
List<ColorData> randomizedColorsList = Arrays.asList(colorMapping.clone()); List<ColorData> randomizedColorsList = Arrays.asList(colorMapping.clone());
Collections.shuffle(randomizedColorsList); Collections.shuffle(randomizedColorsList);
ColorData[] randomizedColors = new ColorData[randomizedColorsList.size()]; ColorData[] randomizedColors = new ColorData[randomizedColorsList.size()];
@ -294,7 +303,7 @@ public class GuiInventoryEditData extends GuiInventory {
GuiIcon.PREVIOUS_PAGE.get(), GuiIcon.PREVIOUS_PAGE.get(),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-previous-page-button", StringPlaceholders.builder("start", pageNumber - 1).addPlaceholder("end", maxPages).build()), localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-previous-page-button", StringPlaceholders.builder("start", pageNumber - 1).addPlaceholder("end", maxPages).build()),
new String[]{}, new String[]{},
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition))); (button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition, null)));
this.actionButtons.add(previousPageButton); this.actionButtons.add(previousPageButton);
} }
@ -305,7 +314,7 @@ public class GuiInventoryEditData extends GuiInventory {
GuiIcon.NEXT_PAGE.get(), GuiIcon.NEXT_PAGE.get(),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-next-page-button", StringPlaceholders.builder("start", pageNumber + 1).addPlaceholder("end", maxPages).build()), localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-next-page-button", StringPlaceholders.builder("start", pageNumber + 1).addPlaceholder("end", maxPages).build()),
new String[]{}, new String[]{},
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition))); (button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition, null)));
this.actionButtons.add(nextPageButton); this.actionButtons.add(nextPageButton);
} }
} }
@ -358,7 +367,7 @@ public class GuiInventoryEditData extends GuiInventory {
GuiIcon.PREVIOUS_PAGE.get(), GuiIcon.PREVIOUS_PAGE.get(),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-previous-page-button", StringPlaceholders.builder("start", pageNumber - 1).addPlaceholder("end", maxPages).build()), localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-previous-page-button", StringPlaceholders.builder("start", pageNumber - 1).addPlaceholder("end", maxPages).build()),
new String[]{}, new String[]{},
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition))); (button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition, null)));
this.actionButtons.add(previousPageButton); this.actionButtons.add(previousPageButton);
} }
@ -369,7 +378,7 @@ public class GuiInventoryEditData extends GuiInventory {
GuiIcon.NEXT_PAGE.get(), GuiIcon.NEXT_PAGE.get(),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-next-page-button", StringPlaceholders.builder("start", pageNumber + 1).addPlaceholder("end", maxPages).build()), localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-next-page-button", StringPlaceholders.builder("start", pageNumber + 1).addPlaceholder("end", maxPages).build()),
new String[]{}, new String[]{},
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition))); (button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition, null)));
this.actionButtons.add(nextPageButton); this.actionButtons.add(nextPageButton);
} }
} }
@ -422,7 +431,7 @@ public class GuiInventoryEditData extends GuiInventory {
GuiIcon.PREVIOUS_PAGE.get(), GuiIcon.PREVIOUS_PAGE.get(),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-previous-page-button", StringPlaceholders.builder("start", pageNumber - 1).addPlaceholder("end", maxPages).build()), localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-previous-page-button", StringPlaceholders.builder("start", pageNumber - 1).addPlaceholder("end", maxPages).build()),
new String[]{}, new String[]{},
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition))); (button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber - 1, callbackList, callbackListPosition, null)));
this.actionButtons.add(previousPageButton); this.actionButtons.add(previousPageButton);
} }
@ -433,19 +442,142 @@ public class GuiInventoryEditData extends GuiInventory {
GuiIcon.NEXT_PAGE.get(), GuiIcon.NEXT_PAGE.get(),
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-next-page-button", StringPlaceholders.builder("start", pageNumber + 1).addPlaceholder("end", maxPages).build()), localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-next-page-button", StringPlaceholders.builder("start", pageNumber + 1).addPlaceholder("end", maxPages).build()),
new String[]{}, new String[]{},
(button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition))); (button, isShiftClick) -> guiManager.transition(new GuiInventoryEditData(this.pplayer, editingParticle, pageNumber + 1, callbackList, callbackListPosition, null)));
this.actionButtons.add(nextPageButton); this.actionButtons.add(nextPageButton);
} }
} }
/**
* Populates the Inventory with available color transition data options.
* This is a copy of the Color data options, but it will be displayed twice.
*
* @param editingParticle The ParticlePair that's being edited
* @param callbackList The List of GuiInventoryEditFinishedCallbacks
* @param callbackListPosition The index of the callbackList we're currently at
* @param startColor The start color of the color transition, will be null if no start color has been selected yet
*/
private void populateColorTransitionData(ParticlePair editingParticle, List<Runnable> callbackList, int callbackListPosition, OrdinaryColor startColor) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
int index = 10;
int nextWrap = 17;
for (ColorData colorData : colorMapping) {
String formattedDisplayColor = ChatColor.RED.toString() + colorData.getOrdinaryColor().getRed() + " " + ChatColor.GREEN + colorData.getOrdinaryColor().getGreen() + " " + ChatColor.AQUA + colorData.getOrdinaryColor().getBlue();
// Color Data Buttons
GuiActionButton setColorButton = new GuiActionButton(
index,
colorData,
colorData.getName(),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", formattedDisplayColor))},
(button, isShiftClick) -> {
if (startColor == null) {
PlayerParticles.getInstance().getManager(GuiManager.class).transition(new GuiInventoryEditData(this.pplayer, editingParticle, 1, callbackList, callbackListPosition, colorData.getOrdinaryColor()));
} else {
editingParticle.setColorTransition(new ColorTransition(startColor, colorData.getOrdinaryColor()));
callbackList.get(callbackListPosition + 1).run();
}
});
this.actionButtons.add(setColorButton);
index++;
if (index == nextWrap) { // Loop around border
nextWrap += 9;
index += 2;
}
}
// Rainbow Color Data Button
GuiActionButton setRainbowColorButton = new GuiActionButton(
39,
rainbowColorMapping,
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("rainbow"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", localeManager.getLocaleMessage("rainbow")))},
(button, isShiftClick) -> {
if (startColor == null) {
PlayerParticles.getInstance().getManager(GuiManager.class).transition(new GuiInventoryEditData(this.pplayer, editingParticle, 1, callbackList, callbackListPosition, OrdinaryColor.RAINBOW));
} else {
editingParticle.setColorTransition(new ColorTransition(startColor, OrdinaryColor.RAINBOW));
callbackList.get(callbackListPosition + 1).run();
}
});
this.actionButtons.add(setRainbowColorButton);
// Random Color Data Button
List<ColorData> randomizedColorsList = Arrays.asList(colorMapping.clone());
Collections.shuffle(randomizedColorsList);
ColorData[] randomizedColors = new ColorData[randomizedColorsList.size()];
randomizedColors = randomizedColorsList.toArray(randomizedColors);
GuiActionButton setRandomColorButton = new GuiActionButton(41,
randomizedColors,
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("random"),
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", localeManager.getLocaleMessage("random")))},
(button, isShiftClick) -> {
if (startColor == null) {
PlayerParticles.getInstance().getManager(GuiManager.class).transition(new GuiInventoryEditData(this.pplayer, editingParticle, 1, callbackList, callbackListPosition, OrdinaryColor.RANDOM));
} else {
editingParticle.setColorTransition(new ColorTransition(startColor, OrdinaryColor.RANDOM));
callbackList.get(callbackListPosition + 1).run();
}
});
this.actionButtons.add(setRandomColorButton);
// Which particle are we selecting?
// Display a light with either the number 1 or 2
ItemStack light = new ItemStack(Material.LIGHT);
BlockDataMeta blockDataMeta = (BlockDataMeta) light.getItemMeta();
if (blockDataMeta != null) {
Light lightData = (Light) Material.LIGHT.createBlockData();
lightData.setLevel(startColor == null ? 1 : 2);
blockDataMeta.setBlockData(lightData);
blockDataMeta.setDisplayName(localeManager.getLocaleMessage("gui-select-data-color-transition-" + (startColor == null ? "start" : "end")));
}
light.setItemMeta(blockDataMeta);
this.inventory.setItem(4, light);
}
/**
* Populates the Inventory with available vibration data options
*
* @param editingParticle The ParticlePair that's being edited
* @param callbackList The List of GuiInventoryEditFinishedCallbacks
* @param callbackListPosition The index of the callbackList we're currently at
*/
private void populateVibrationData(ParticlePair editingParticle, List<Runnable> callbackList, int callbackListPosition) {
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
int slot = 21;
for (int i = 1; i <= 6; i++) {
int vibration = i * 10;
String formattedDisplayName = localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-select-data-vibration", StringPlaceholders.single("ticks", vibration));
String formattedDescription = localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", localeManager.getLocaleMessage("gui-select-data-vibration", StringPlaceholders.single("ticks", vibration))));
// Vibration Buttons
GuiActionButton setColorButton = new GuiActionButton(
slot,
Material.SCULK_SENSOR,
formattedDisplayName,
new String[]{formattedDescription},
(button, isShiftClick) -> {
editingParticle.setVibration(new Vibration(vibration));
callbackList.get(callbackListPosition + 1).run();
});
this.actionButtons.add(setColorButton);
if (slot++ == 23) // Loop around
slot = 30;
}
}
/** /**
* A data class used for storing information about the color data * A data class used for storing information about the color data
*/ */
protected static class ColorData { protected static class ColorData {
private DyeColor dyeColor; private final DyeColor dyeColor;
private Material material; private final Material material;
private OrdinaryColor ordinaryColor; private final OrdinaryColor ordinaryColor;
private String nameKey; private final String nameKey;
public ColorData(DyeColor dyeColor, Material material, OrdinaryColor ordinaryColor, String nameKey) { public ColorData(DyeColor dyeColor, Material material, OrdinaryColor ordinaryColor, String nameKey) {
this.dyeColor = dyeColor; this.dyeColor = dyeColor;

View file

@ -6,7 +6,6 @@ import dev.esophose.playerparticles.manager.ConfigurationManager.GuiIcon;
import dev.esophose.playerparticles.manager.GuiManager; import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.StringPlaceholders; import dev.esophose.playerparticles.util.StringPlaceholders;
@ -93,7 +92,7 @@ public class GuiInventoryEditParticle extends GuiInventory {
this.actionButtons.add(editStyleButton); this.actionButtons.add(editStyleButton);
// Edit Data Button // 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, GuiActionButton editDataButton = new GuiActionButton(42,
GuiIcon.EDIT_DATA.get(), GuiIcon.EDIT_DATA.get(),
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-data"), localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-data"),
@ -103,7 +102,7 @@ public class GuiInventoryEditParticle extends GuiInventory {
if (usesData) { if (usesData) {
List<Runnable> callbacks = new ArrayList<>(); List<Runnable> callbacks = new ArrayList<>();
callbacks.add(() -> guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle))); callbacks.add(() -> guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1))); callbacks.add(() -> guiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1, null)));
callbacks.add(() -> { callbacks.add(() -> {
ParticleGroup group = pplayer.getActiveParticleGroup(); ParticleGroup group = pplayer.getActiveParticleGroup();
for (ParticlePair particle : group.getParticles().values()) { for (ParticlePair particle : group.getParticles().values()) {

View file

@ -7,7 +7,6 @@ import dev.esophose.playerparticles.manager.GuiManager;
import dev.esophose.playerparticles.manager.LocaleManager; import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.ParticleUtils;
@ -89,8 +88,8 @@ public class GuiInventoryManageParticles extends GuiInventory {
callbacks.add(() -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1))); callbacks.add(() -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
callbacks.add(() -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 2))); callbacks.add(() -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 2)));
callbacks.add(() -> { 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)); guiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 3, null));
} else { } else {
callbacks.get(4).run(); callbacks.get(4).run();
} }

View file

@ -154,12 +154,16 @@ public class EnglishLocale implements Locale {
this.put("data-usage-none", "&eThe effect &b%effect% &edoes not use any data!"); this.put("data-usage-none", "&eThe effect &b%effect% &edoes not use any data!");
this.put("data-usage-block", "&eThe effect &b%effect% &erequires &bblock &edata! &bFormat: <blockName>"); this.put("data-usage-block", "&eThe effect &b%effect% &erequires &bblock &edata! &bFormat: <blockName>");
this.put("data-usage-item", "&eThe effect &b%effect% &erequires &bitem &edata! &bFormat: <itemName>"); this.put("data-usage-item", "&eThe effect &b%effect% &erequires &bitem &edata! &bFormat: <itemName>");
this.put("data-usage-color", "&eThe effect &b%effect% &erequires &bcolor &edata! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>"); this.put("data-usage-color", "&eThe effect &b%effect% &erequires &bcolor &edata! &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-usage-note", "&eThe effect &b%effect% &erequires &bnote &edata! &bFormat: <0-24>|<rainbow>|<random>"); this.put("data-usage-note", "&eThe effect &b%effect% &erequires &bnote &edata! &bFormat: <0-24>|<&brainbow>|<random>");
this.put("data-usage-color-transition", "&eThe effect &b%effect% &erequires &bcolor transition &edata! &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random> <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-usage-vibration", "&eThe effect &b%effect% &erequires &bvibration &edata! &bFormat: <duration>");
this.put("data-invalid-block", "&cThe &bblock &cdata you entered is invalid! &bFormat: <blockName>"); this.put("data-invalid-block", "&cThe &bblock &cdata you entered is invalid! &bFormat: <blockName>");
this.put("data-invalid-item", "&cThe &bitem &cdata you entered is invalid! &bFormat: <itemName>"); this.put("data-invalid-item", "&cThe &bitem &cdata you entered is invalid! &bFormat: <itemName>");
this.put("data-invalid-color", "&cThe &bcolor &cdata you entered is invalid! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>"); this.put("data-invalid-color", "&cThe &bcolor &cdata you entered is invalid! &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-invalid-note", "&cThe &bnote &cdata you entered is invalid! &bFormat: <0-24>|<rainbow>|<random>"); this.put("data-invalid-note", "&cThe &bnote &cdata you entered is invalid! &bFormat: <0-24>|<&brainbow>|<random>");
this.put("data-invalid-color-transition", "&cThe &bcolor transition &cdata you entered is invalid! &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random> <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-invalid-vibration", "&cThe &bvibration &cdata you entered is invalid! &bFormat: <duration>");
this.put("data-invalid-material-not-item", "&cThe &bitem &cmaterial &b%material% &cyou entered is not an item!"); this.put("data-invalid-material-not-item", "&cThe &bitem &cmaterial &b%material% &cyou entered is not an item!");
this.put("data-invalid-material-not-block", "&cThe &bblock &cmaterial &b%material% &cyou entered is not a block!"); this.put("data-invalid-material-not-block", "&cThe &bblock &cmaterial &b%material% &cyou entered is not a block!");
this.put("data-invalid-material-item", "&cThe &bitem &cmaterial &b%material% you entered does not exist!"); this.put("data-invalid-material-item", "&cThe &bitem &cmaterial &b%material% you entered does not exist!");
@ -325,25 +329,28 @@ public class EnglishLocale implements Locale {
this.put("gui-select-style-description", "Sets the particle style to &b%style%"); this.put("gui-select-style-description", "Sets the particle style to &b%style%");
this.put("gui-select-data", "Select Particle Data"); this.put("gui-select-data", "Select Particle Data");
this.put("gui-select-data-description", "Sets the particle data to &b%data%"); this.put("gui-select-data-description", "Sets the particle data to &b%data%");
this.put("gui-select-data-note", "note #%note%"); this.put("gui-select-data-note", "Note #%note%");
this.put("gui-select-data-color-transition-start", "&eSelect the &bstart &ecolor");
this.put("gui-select-data-color-transition-end", "&eSelect the &bend &ecolor");
this.put("gui-select-data-vibration", "&b%ticks% &eticks");
this.put("#38", "GUI Color Name Messages"); this.put("#38", "GUI Color Name Messages");
this.put("gui-edit-data-color-red", "&cred"); this.put("gui-edit-data-color-red", "#ff0000Red");
this.put("gui-edit-data-color-orange", "&6orange"); this.put("gui-edit-data-color-orange", "#ff8c00Orange");
this.put("gui-edit-data-color-yellow", "&eyellow"); this.put("gui-edit-data-color-yellow", "#ffff00Yellow");
this.put("gui-edit-data-color-lime-green", "&alime green"); this.put("gui-edit-data-color-lime-green", "#32cd32Lime Green");
this.put("gui-edit-data-color-green", "&2green"); this.put("gui-edit-data-color-green", "#008000Green");
this.put("gui-edit-data-color-blue", "&1blue"); this.put("gui-edit-data-color-blue", "#0000ffBlue");
this.put("gui-edit-data-color-cyan", "&3cyan"); this.put("gui-edit-data-color-cyan", "#008b8bCyan");
this.put("gui-edit-data-color-light-blue", "&blight blue"); this.put("gui-edit-data-color-light-blue", "#add8e6Light Blue");
this.put("gui-edit-data-color-purple", "&5purple"); this.put("gui-edit-data-color-purple", "#8a2be2Purple");
this.put("gui-edit-data-color-magenta", "&dmagenta"); this.put("gui-edit-data-color-magenta", "#ca1f7bMagenta");
this.put("gui-edit-data-color-pink", "&dpink"); this.put("gui-edit-data-color-pink", "#ffb6c1Pink");
this.put("gui-edit-data-color-brown", "&6brown"); this.put("gui-edit-data-color-brown", "#8b4513Brown");
this.put("gui-edit-data-color-black", "&8black"); this.put("gui-edit-data-color-black", "#000000Black");
this.put("gui-edit-data-color-gray", "&8gray"); this.put("gui-edit-data-color-gray", "#808080Gray");
this.put("gui-edit-data-color-light-gray", "&7light gray"); this.put("gui-edit-data-color-light-gray", "#c0c0c0Light Gray");
this.put("gui-edit-data-color-white", "&fwhite"); this.put("gui-edit-data-color-white", "#ffffffWhite");
}}; }};
} }

View file

@ -154,16 +154,20 @@ public class FrenchLocale implements Locale {
this.put("data-usage-none", "&eL'effet &b%effect% &en'est pas paramétrable."); this.put("data-usage-none", "&eL'effet &b%effect% &en'est pas paramétrable.");
this.put("data-usage-block", "&eL'effet &b%effect% &erequière l'ID du bloc ! &bFormat: <blockName>"); this.put("data-usage-block", "&eL'effet &b%effect% &erequière l'ID du bloc ! &bFormat: <blockName>");
this.put("data-usage-item", "&eL'effet &b%effect% &erequière l'ID de l'item ! &bFormat: <itemName>"); this.put("data-usage-item", "&eL'effet &b%effect% &erequière l'ID de l'item ! &bFormat: <itemName>");
this.put("data-usage-color", "&eL'effet &b%effect% &erequière l'ID de la couleur ! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>"); this.put("data-usage-color", "&eL'effet &b%effect% &erequière l'ID de la couleur ! &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-usage-note", "&eL'effet&b%effect% &erequière l'ID de la note ! &bFormat: <0-24>|<rainbow>|<random>"); this.put("data-usage-note", "&eL'effet &b%effect% &erequière l'ID de la note ! &bFormat: <0-24>|<&brainbow>|<random>");
this.put("data-usage-color-transition", "&eL'effet &b%effect% &erequière l'ID de transition de couleur ! &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random> <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-usage-vibration", "&eL'effet &b%effect% &erequière l'ID de la vibration ! &bFormat: <duration>");
this.put("data-invalid-block", "&cL'ID du bloc que vous avez rentré n'est pas valide ! &bFormat: <blockName>"); this.put("data-invalid-block", "&cL'ID du bloc que vous avez rentré n'est pas valide ! &bFormat: <blockName>");
this.put("data-invalid-item", "&cL'ID de l'item que vous avez rentré n'est pas valide ! &bFormat: <itemName>"); this.put("data-invalid-item", "&cL'ID de l'item que vous avez rentré n'est pas valide ! &bFormat: <itemName>");
this.put("data-invalid-color", "&cL'ID de la couleur que vous avez rentré n'est pas valide ! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>"); this.put("data-invalid-color", "&cL'ID de la couleur que vous avez rentré n'est pas valide ! &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-invalid-note", "&cL'ID du bloc que vous avez rentré n'est pas valide ! &bFormat: <0-24>|<rainbow>|<random>"); this.put("data-invalid-note", "&cL'ID de la note que vous avez rentré n'est pas valide ! &bFormat: <0-24>|<&brainbow>|<random>");
this.put("data-invalid-color-transition", "&cL'ID de transition de couleur que vous avez rentré n'est pas valide ! &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random> <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-invalid-vibration", "&cL'ID de la vibration que vous avez rentré n'est pas valide ! &bFormat: <duration>");
this.put("data-invalid-material-not-item", "&cL'ID &b%material% &cne correspond pas à un item !"); this.put("data-invalid-material-not-item", "&cL'ID &b%material% &cne correspond pas à un item !");
this.put("data-invalid-material-not-block", "&cL'ID &b%material% &cne correspond pas à un bloc !"); this.put("data-invalid-material-not-block", "&cL'ID &b%material% &cne correspond pas à un bloc !");
this.put("data-invalid-material-item", "&cL'ID &b%material% n'existe pas !"); this.put("data-invalid-material-item", "&cL'ID &b%material% n'existe pas !");
this.put("data-invalid-material-block", "&cL'ID&b%material% n'existe pas !"); this.put("data-invalid-material-block", "&cL'ID &b%material% n'existe pas !");
this.put("#16", "World Messages"); this.put("#16", "World Messages");
this.put("disabled-worlds", "&eLes particules sont désactivées dans ces mondes : &b%worlds%"); this.put("disabled-worlds", "&eLes particules sont désactivées dans ces mondes : &b%worlds%");
@ -325,25 +329,28 @@ public class FrenchLocale implements Locale {
this.put("gui-select-style-description", "Mets le style de la particule à &b%style%"); this.put("gui-select-style-description", "Mets le style de la particule à &b%style%");
this.put("gui-select-data", "Sélectionnez les paramètres"); this.put("gui-select-data", "Sélectionnez les paramètres");
this.put("gui-select-data-description", "Mets les paramètres de la particule à &b%data%"); this.put("gui-select-data-description", "Mets les paramètres de la particule à &b%data%");
this.put("gui-select-data-note", "note #%note%"); this.put("gui-select-data-note", "Note #%note%");
this.put("gui-select-data-color-transition-start", "&eSélectionnez la couleur de &bdépart");
this.put("gui-select-data-color-transition-end", "&eSélectionnez la couleur de &bfin");
this.put("gui-select-data-vibration", "&b%ticks% &eticks");
this.put("#38", "GUI Color Name Messages"); this.put("#38", "GUI Color Name Messages");
this.put("gui-edit-data-color-red", "&crouge"); this.put("gui-edit-data-color-red", "#ff0000Rouge");
this.put("gui-edit-data-color-orange", "&6orange"); this.put("gui-edit-data-color-orange", "#ff8c00Orange");
this.put("gui-edit-data-color-yellow", "&ejaune"); this.put("gui-edit-data-color-yellow", "#ffff00Jaune");
this.put("gui-edit-data-color-lime-green", "&avert citron"); this.put("gui-edit-data-color-lime-green", "#32cd32Vert Citron");
this.put("gui-edit-data-color-green", "&2vert"); this.put("gui-edit-data-color-green", "#008000Vert");
this.put("gui-edit-data-color-blue", "&1bleu"); this.put("gui-edit-data-color-blue", "#0000ffBleu");
this.put("gui-edit-data-color-cyan", "&3cyan"); this.put("gui-edit-data-color-cyan", "#008b8bCyan");
this.put("gui-edit-data-color-light-blue", "&bbleu clair"); this.put("gui-edit-data-color-light-blue", "#add8e6Bleu Clair");
this.put("gui-edit-data-color-purple", "&5mauve"); this.put("gui-edit-data-color-purple", "#8a2be2Mauve");
this.put("gui-edit-data-color-magenta", "&dmagenta"); this.put("gui-edit-data-color-magenta", "#ca1f7bMagenta");
this.put("gui-edit-data-color-pink", "&drose"); this.put("gui-edit-data-color-pink", "#ffb6c1Rose");
this.put("gui-edit-data-color-brown", "&6brun"); this.put("gui-edit-data-color-brown", "#8b4513Brun");
this.put("gui-edit-data-color-black", "&8noir"); this.put("gui-edit-data-color-black", "#000000Noir");
this.put("gui-edit-data-color-gray", "&8gris"); this.put("gui-edit-data-color-gray", "#808080Gris");
this.put("gui-edit-data-color-light-gray", "&7gris clair"); this.put("gui-edit-data-color-light-gray", "#c0c0c0Gris Clair");
this.put("gui-edit-data-color-white", "&fblanc"); this.put("gui-edit-data-color-white", "#ffffffBlanc");
}}; }};
} }
} }

View file

@ -154,12 +154,16 @@ public class GermanLocale implements Locale {
this.put("data-usage-none", "&eDer Effekt &b%effect% &everwendet keine Daten!"); this.put("data-usage-none", "&eDer Effekt &b%effect% &everwendet keine Daten!");
this.put("data-usage-block", "&eFür den Effekt &b%effect% &ewerden &bBlockdaten &ebenötigt! &bFormat: <blockName>"); this.put("data-usage-block", "&eFür den Effekt &b%effect% &ewerden &bBlockdaten &ebenötigt! &bFormat: <blockName>");
this.put("data-usage-item", "&eFür den Effekt &b%effect% &esind &bItem &eDaten erforderlich! &bFormat: <itemName>"); this.put("data-usage-item", "&eFür den Effekt &b%effect% &esind &bItem &eDaten erforderlich! &bFormat: <itemName>");
this.put("data-usage-color", "&eFür den Effekt &b%effect% &esind &bFarbdaten &eerforderlich! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>"); this.put("data-usage-color", "&eFür den Effekt &b%effect% &esind &bFarbdaten &eerforderlich! &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-usage-note", "&eFür den Effekt &b%effect% &esind &bAnmeldedaten &eerforderlich! &bFormat: <0-24>|<rainbow>|<random>"); this.put("data-usage-note", "&eFür den Effekt &b%effect% &esind &bAnmeldedaten &eerforderlich! &bFormat: <0-24>|<&brainbow>|<random>");
this.put("data-usage-color-transition", "&eFür den Effekt &b%effect% &esind &bFarbübergang &eerforderlich! &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random> <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-usage-vibration", "&eFür den Effekt &b%effect% &esind &bVibration &eerforderlich! &bFormat: <duration>");
this.put("data-invalid-block", "&cDie von Ihnen eingegebenen &bBlock &cDaten sind ungültig! &bFormat: <blockName>"); this.put("data-invalid-block", "&cDie von Ihnen eingegebenen &bBlock &cDaten sind ungültig! &bFormat: <blockName>");
this.put("data-invalid-item", "&cDie von Ihnen eingegebenen &bItem &cDaten sind ungültig! &bFormat: <itemName>"); this.put("data-invalid-item", "&cDie von Ihnen eingegebenen &bItem &cDaten sind ungültig! &bFormat: <itemName>");
this.put("data-invalid-color", "&cDie von Ihnen eingegebenen &bFarbdaten &csind ungültig! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>|<random>"); this.put("data-invalid-color", "&cDie von Ihnen eingegebenen &bFarbdaten &csind ungültig! &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-invalid-note", "&cDie von Ihnen eingegebenen &bNotizdaten &csind ungültig! &bFormat: <0-24>|<rainbow>|<random>"); this.put("data-invalid-note", "&cDie von Ihnen eingegebenen &bNotizdaten &csind ungültig! &bFormat: <0-24>|<&brainbow>|<random>");
this.put("data-invalid-color-transition", "&cDie von Ihnen eingegebenen &bFarbübergang &csind ungültig! &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random> <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-invalid-vibration", "&cDie von Ihnen eingegebenen &bVibration &csind ungültig! &bFormat: <duration>");
this.put("data-invalid-material-not-item", "&cDas von Ihnen eingegebene &bItem &cMaterial &b%material% &cist kein Item!"); this.put("data-invalid-material-not-item", "&cDas von Ihnen eingegebene &bItem &cMaterial &b%material% &cist kein Item!");
this.put("data-invalid-material-not-block", "&cDas von Ihnen eingegebene &bBlock &cMaterial &b%material% &cist kein Block!"); this.put("data-invalid-material-not-block", "&cDas von Ihnen eingegebene &bBlock &cMaterial &b%material% &cist kein Block!");
this.put("data-invalid-material-item", "&cDas von Ihnen eingegebene &bItem &cMaterial &b%material% &cexistiert nicht!"); this.put("data-invalid-material-item", "&cDas von Ihnen eingegebene &bItem &cMaterial &b%material% &cexistiert nicht!");
@ -326,24 +330,27 @@ public class GermanLocale implements Locale {
this.put("gui-select-data", "Wählen Sie Partikeldaten"); this.put("gui-select-data", "Wählen Sie Partikeldaten");
this.put("gui-select-data-description", "Setzt die Partikeldaten auf &b%data%"); this.put("gui-select-data-description", "Setzt die Partikeldaten auf &b%data%");
this.put("gui-select-data-note", "Hinweis #%note%"); this.put("gui-select-data-note", "Hinweis #%note%");
this.put("gui-select-data-color-transition-start", "&eWählen Sie die &bStartfarbe");
this.put("gui-select-data-color-transition-end", "&eWählen Sie die &bEndfarbe");
this.put("gui-select-data-vibration", "&b%ticks% &eticks");
this.put("#38", "GUI Color Name Messages"); this.put("#38", "GUI Color Name Messages");
this.put("gui-edit-data-color-red", "Rot"); this.put("gui-edit-data-color-red", "#ff0000Rot");
this.put("gui-edit-data-color-orange", "Orange"); this.put("gui-edit-data-color-orange", "#ff8c00Orange");
this.put("gui-edit-data-color-yellow", "Gelb"); this.put("gui-edit-data-color-yellow", "#ffff00Gelb");
this.put("gui-edit-data-color-lime-green", "Limetten-Grün"); this.put("gui-edit-data-color-lime-green", "#32cd32Limetten-Grün");
this.put("gui-edit-data-color-green", "Grün"); this.put("gui-edit-data-color-green", "#008000Grün");
this.put("gui-edit-data-color-blue", "Blau"); this.put("gui-edit-data-color-blue", "#0000ffBlau");
this.put("gui-edit-data-color-cyan", "Cyan"); this.put("gui-edit-data-color-cyan", "#008b8bCyan");
this.put("gui-edit-data-color-light-blue", "Hellblau"); this.put("gui-edit-data-color-light-blue", "#add8e6Hellblau");
this.put("gui-edit-data-color-purple", "Lila"); this.put("gui-edit-data-color-purple", "#8a2be2Lila");
this.put("gui-edit-data-color-magenta", "Magenta"); this.put("gui-edit-data-color-magenta", "#ca1f7bMagenta");
this.put("gui-edit-data-color-pink", "Pink"); this.put("gui-edit-data-color-pink", "#ffb6c1Pink");
this.put("gui-edit-data-color-brown", "Braun"); this.put("gui-edit-data-color-brown", "#8b4513Braun");
this.put("gui-edit-data-color-black", "Schwarz"); this.put("gui-edit-data-color-black", "#000000Schwarz");
this.put("gui-edit-data-color-gray", "Grau"); this.put("gui-edit-data-color-gray", "#808080Grau");
this.put("gui-edit-data-color-light-gray", "Hellgrau"); this.put("gui-edit-data-color-light-gray", "#c0c0c0Hellgrau");
this.put("gui-edit-data-color-white", "Weiss"); this.put("gui-edit-data-color-white", "#ffffffWeiss");
}}; }};
} }
} }

View file

@ -154,12 +154,16 @@ public class RussianLocale implements Locale {
this.put("data-usage-none", "&eЭффект &b%effect% &eне использует какие-либо данные!"); this.put("data-usage-none", "&eЭффект &b%effect% &eне использует какие-либо данные!");
this.put("data-usage-block", "&eЭффект &b%effect% &eзапрашивает &bблок &eданных! &bФормат: <названиеБлока>"); this.put("data-usage-block", "&eЭффект &b%effect% &eзапрашивает &bблок &eданных! &bФормат: <названиеБлока>");
this.put("data-usage-item", "&eЭффект &b%effect% &eзапрашивает &bпредмет &eданных! &bФормат: <названиеПредмета>"); this.put("data-usage-item", "&eЭффект &b%effect% &eзапрашивает &bпредмет &eданных! &bФормат: <названиеПредмета>");
this.put("data-usage-color", "&eЭффект &b%effect% &eзапрашивает &bцвет &eданных! &bФормат: <0-255> <0-255> <0-255>|<rainbow>|<random>"); this.put("data-usage-color", "&eЭффект &b%effect% &eзапрашивает &bцвет &eданных! &bФормат: <0-255> <0-255> <0-255>|<&brainbow>|<random>");
this.put("data-usage-note", "&eЭффект &b%effect% &eзапрашивает &bноту &eданных! &bФормат: <0-24>|<rainbow>|<random>"); this.put("data-usage-note", "&eЭффект &b%effect% &eзапрашивает &bноту &eданных! &bФормат: <0-24>|<&brainbow>|<random>");
this.put("data-usage-color-transition", "&eЭффект &b%effect% &eзапрашивает &bпереход цвета &eданных! &bФормат: <<0-255> <0-255> <0-255>>|<&brainbow>|<random> <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-usage-vibration", "&eЭффект &b%effect% &eзапрашивает &bвибрация &eданных! &bФормат: <продолжительность>");
this.put("data-invalid-block", "&bБлок &cданных, который Вы ввели, недействителен! &bФормат: <названиеБлока>"); this.put("data-invalid-block", "&bБлок &cданных, который Вы ввели, недействителен! &bФормат: <названиеБлока>");
this.put("data-invalid-item", "&bПредмет &cданных, который Вы ввели, недействителен! &bФормат: <названиеПредмета>"); this.put("data-invalid-item", "&bПредмет &cданных, который Вы ввели, недействителен! &bФормат: <названиеПредмета>");
this.put("data-invalid-color", "&bЦвет &cданных, который Вы ввели, недействителен! &bФормат: <0-255> <0-255> <0-255>|<rainbow>|<random>"); this.put("data-invalid-color", "&bЦвет &cданных, который Вы ввели, недействителен! &bФормат: <0-255> <0-255> <0-255>|<&brainbow>|<random>");
this.put("data-invalid-note", "&bНота &cданных, которую Вы ввели, недействительна! &bФормат: <0-24>|<rainbow>|<random>"); this.put("data-invalid-note", "&bНота &cданных, которую Вы ввели, недействительна! &bФормат: <0-24>|<&brainbow>|<random>");
this.put("data-invalid-color-transition", "&bпереход цвета &cданных, которую Вы ввели, недействительна! &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random> <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-invalid-vibration", "&bвибрация &cданных, которую Вы ввели, недействительна! &bFormat: <duration>");
this.put("data-invalid-material-not-item", "&bМатериал &cпредмета&b%material%&c, который Вы ввели, не является предметом!"); this.put("data-invalid-material-not-item", "&bМатериал &cпредмета&b%material%&c, который Вы ввели, не является предметом!");
this.put("data-invalid-material-not-block", "&bМатериал &cблока&b%material%&c, который Вы ввели, не является блоком!"); this.put("data-invalid-material-not-block", "&bМатериал &cблока&b%material%&c, который Вы ввели, не является блоком!");
this.put("data-invalid-material-item", "&bМатериал &cпредмета&b%material%, который Вы ввели, не существует!"); this.put("data-invalid-material-item", "&bМатериал &cпредмета&b%material%, который Вы ввели, не существует!");
@ -326,24 +330,27 @@ public class RussianLocale implements Locale {
this.put("gui-select-data", "Выбор данных частиц"); this.put("gui-select-data", "Выбор данных частиц");
this.put("gui-select-data-description", "Выбрать данные для частиц &b%data%"); this.put("gui-select-data-description", "Выбрать данные для частиц &b%data%");
this.put("gui-select-data-note", "записка #%note%"); this.put("gui-select-data-note", "записка #%note%");
this.put("gui-select-data-color-transition-start", "&eВыберите &bначальный &eцвет");
this.put("gui-select-data-color-transition-end", "&eВыберите &bконечный &eцвет");
this.put("gui-select-data-vibration", "&b%ticks% &eticks");
this.put("#38", "GUI Color Name Messages"); this.put("#38", "GUI Color Name Messages");
this.put("gui-edit-data-color-red", "&cкрасный"); this.put("gui-edit-data-color-red", "#ff0000красный");
this.put("gui-edit-data-color-orange", "&6оранжевый"); this.put("gui-edit-data-color-orange", "#ff8c00оранжевый");
this.put("gui-edit-data-color-yellow", "&eжелтый"); this.put("gui-edit-data-color-yellow", "#ffff00желтый");
this.put("gui-edit-data-color-lime-green", "&aзеленый лайм"); this.put("gui-edit-data-color-lime-green", "#32cd32зеленый лайм");
this.put("gui-edit-data-color-green", "&2зеленый"); this.put("gui-edit-data-color-green", "#008000зеленый");
this.put("gui-edit-data-color-blue", "&1синий"); this.put("gui-edit-data-color-blue", "#0000ffсиний");
this.put("gui-edit-data-color-cyan", "&3циан"); this.put("gui-edit-data-color-cyan", "#008b8bциан");
this.put("gui-edit-data-color-light-blue", "&bсветло-синий"); this.put("gui-edit-data-color-light-blue", "#add8e6светло-синий");
this.put("gui-edit-data-color-purple", "&5фиолетовый"); this.put("gui-edit-data-color-purple", "#8a2be2фиолетовый");
this.put("gui-edit-data-color-magenta", "&dфуксин"); this.put("gui-edit-data-color-magenta", "#ca1f7bфуксин");
this.put("gui-edit-data-color-pink", "&dрозовый"); this.put("gui-edit-data-color-pink", "#ffb6c1розовый");
this.put("gui-edit-data-color-brown", "&6коричневый"); this.put("gui-edit-data-color-brown", "#8b4513коричневый");
this.put("gui-edit-data-color-black", "&8черный"); this.put("gui-edit-data-color-black", "#000000черный");
this.put("gui-edit-data-color-gray", "&8серый"); this.put("gui-edit-data-color-gray", "#808080серый");
this.put("gui-edit-data-color-light-gray", "&7светло-серый"); this.put("gui-edit-data-color-light-gray", "#c0c0c0светло-серый");
this.put("gui-edit-data-color-white", "&fбелый"); this.put("gui-edit-data-color-white", "#ffffffбелый");
}}; }};
} }
} }

View file

@ -154,12 +154,16 @@ public class SimplifiedChineseLocale implements Locale {
this.put("data-usage-none", "&e粒子特效&b%effect%&e不使用任何数据!"); this.put("data-usage-none", "&e粒子特效&b%effect%&e不使用任何数据!");
this.put("data-usage-block", "&e粒子特效&b%effect%&e需要设置&b方块&e数据! &b格式: <方块ID>"); this.put("data-usage-block", "&e粒子特效&b%effect%&e需要设置&b方块&e数据! &b格式: <方块ID>");
this.put("data-usage-item", "&e粒子特效&b%effect%&e需要设置&b物品&e数据! &b格式: <物品ID>"); this.put("data-usage-item", "&e粒子特效&b%effect%&e需要设置&b物品&e数据! &b格式: <物品ID>");
this.put("data-usage-color", "&e粒子特效&b%effect%&e需要设置&b颜色&e数据! &b格式: <<0-255> <0-255> <0-255>>|<rainbow>|<random>"); this.put("data-usage-color", "&e粒子特效&b%effect%&e需要设置&b颜色&e数据! &b格式: <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-usage-note", "&e粒子特效&b%effect%&e需要设置&b音符&e数据! &b格式: <0-24>|<rainbow>|<random>"); this.put("data-usage-note", "&e粒子特效&b%effect%&e需要设置&b音符&e数据! &b格式: <0-24>|<&brainbow>|<random>");
this.put("data-usage-color-transition", "&e粒子特效&b%effect%&e需要设置&b颜色过渡&e数据! &b格式: <<0-255> <0-255> <0-255>>|<&brainbow>|<random> <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-usage-vibration", "&e粒子特效&b%effect%&e需要设置&b振动&e数据! &b格式: <持续时间>");
this.put("data-invalid-block", "&c你输入的&b方块&c数据 无效! &b格式: <方块ID>"); this.put("data-invalid-block", "&c你输入的&b方块&c数据 无效! &b格式: <方块ID>");
this.put("data-invalid-item", "&c你输入的&b物品&c数据 无效! &b格式: <物品ID>"); this.put("data-invalid-item", "&c你输入的&b物品&c数据 无效! &b格式: <物品ID>");
this.put("data-invalid-color", "&c你输入的&b颜色&c数据 无效! &b格式: <<0-255> <0-255> <0-255>>|<rainbow>|<random>"); this.put("data-invalid-color", "&c你输入的&b颜色&c数据 无效! &b格式: <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-invalid-note", "&c你输入的&b音符&c数据 无效! &b格式: <0-24>|<rainbow>|<random>"); this.put("data-invalid-note", "&c你输入的&b音符&c数据 无效! &b格式: <0-24>|<&brainbow>|<random>");
this.put("data-invalid-color-transition", "&c你输入的&b颜色过渡&c数据 无效! &b格式: <<0-255> <0-255> <0-255>>|<&brainbow>|<random> <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-invalid-vibration", "&c你输入的&b振动&c数据 无效! &b格式: <duration>");
this.put("data-invalid-material-not-item", "&c你输入的&b物品&c材料名 &b%material%&c不是一件物品!"); this.put("data-invalid-material-not-item", "&c你输入的&b物品&c材料名 &b%material%&c不是一件物品!");
this.put("data-invalid-material-not-block", "&c你输入的&b方块&c材料名&b%material%&c不是一个方块!"); this.put("data-invalid-material-not-block", "&c你输入的&b方块&c材料名&b%material%&c不是一个方块!");
this.put("data-invalid-material-item", "&c你输入的&b物品&c材料&b%material%不存在!"); this.put("data-invalid-material-item", "&c你输入的&b物品&c材料&b%material%不存在!");
@ -325,25 +329,28 @@ public class SimplifiedChineseLocale implements Locale {
this.put("gui-select-style-description", "将粒子风格设置为 &b%style%"); this.put("gui-select-style-description", "将粒子风格设置为 &b%style%");
this.put("gui-select-data", "选择粒子数据"); this.put("gui-select-data", "选择粒子数据");
this.put("gui-select-data-description", "将粒子数据设置为&b%data%"); this.put("gui-select-data-description", "将粒子数据设置为&b%data%");
this.put("gui-select-data-note", "note #%note%"); this.put("gui-select-data-note", "Note #%note%");
this.put("gui-select-data-color-transition-start", "&e选择起始颜色");
this.put("gui-select-data-color-transition-end", "&e选择末端颜色");
this.put("gui-select-data-vibration", "&b%ticks% &eticks");
this.put("#38", "GUI Color Name Messages"); this.put("#38", "GUI Color Name Messages");
this.put("gui-edit-data-color-red", "&c红色"); this.put("gui-edit-data-color-red", "#ff0000红色");
this.put("gui-edit-data-color-orange", "&6橙黄"); this.put("gui-edit-data-color-orange", "#ff8c00橙黄");
this.put("gui-edit-data-color-yellow", "&e黄色"); this.put("gui-edit-data-color-yellow", "#ffff00黄色");
this.put("gui-edit-data-color-lime-green", "&a淡绿"); this.put("gui-edit-data-color-lime-green", "#32cd32淡绿");
this.put("gui-edit-data-color-green", "&2绿色"); this.put("gui-edit-data-color-green", "#008000绿色");
this.put("gui-edit-data-color-blue", "&1蓝色"); this.put("gui-edit-data-color-blue", "#0000ff蓝色");
this.put("gui-edit-data-color-cyan", "&3青色"); this.put("gui-edit-data-color-cyan", "#008b8b青色");
this.put("gui-edit-data-color-light-blue", "&b淡蓝色"); this.put("gui-edit-data-color-light-blue", "#add8e6淡蓝色");
this.put("gui-edit-data-color-purple", "&5紫色"); this.put("gui-edit-data-color-purple", "#8a2be2紫色");
this.put("gui-edit-data-color-magenta", "&d洋红"); this.put("gui-edit-data-color-magenta", "#ca1f7b洋红");
this.put("gui-edit-data-color-pink", "&d粉色"); this.put("gui-edit-data-color-pink", "#ffb6c1粉色");
this.put("gui-edit-data-color-brown", "&6棕色"); this.put("gui-edit-data-color-brown", "#8b4513棕色");
this.put("gui-edit-data-color-black", "&8黑色"); this.put("gui-edit-data-color-black", "#000000黑色");
this.put("gui-edit-data-color-gray", "&8灰色"); this.put("gui-edit-data-color-gray", "#808080灰色");
this.put("gui-edit-data-color-light-gray", "&7淡灰"); this.put("gui-edit-data-color-light-gray", "#c0c0c0淡灰");
this.put("gui-edit-data-color-white", "&f白色"); this.put("gui-edit-data-color-white", "#ffffff白色");
}}; }};
} }

View file

@ -154,12 +154,16 @@ public class VietnameseLocale implements Locale {
this.put("data-usage-none", "&eHiệu ứng &b%effect% &ekhông sử dụng bất kì Dữ liệu nào!"); this.put("data-usage-none", "&eHiệu ứng &b%effect% &ekhông sử dụng bất kì Dữ liệu nào!");
this.put("data-usage-block", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bblock ! &bĐịnh dạng: <blockName>"); this.put("data-usage-block", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bblock ! &bĐịnh dạng: <blockName>");
this.put("data-usage-item", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bitem! &bĐịnh dạng: <itemName>"); this.put("data-usage-item", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bitem! &bĐịnh dạng: <itemName>");
this.put("data-usage-color", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bcolor! &bĐịnh dạng: <<0-255> <0-255> <0-255>>|<rainbow>|<random>"); this.put("data-usage-color", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bcolor! &bĐịnh dạng: <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-usage-note", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bnote! &bĐịnh dạng: <0-24>|<rainbow>|<random>"); this.put("data-usage-note", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bnote! &bĐịnh dạng: <0-24>|<&brainbow>|<random>");
this.put("data-usage-color-transition", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bcolor transition! &bĐịnh dạng: &bFormat: <<0-255> <0-255> <0-255>>|<&brainbow>|<random> <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-usage-vibration", "&eHiệu ứng &b%effect% &eyêu cầu dữ liệu &bvibration! &bĐịnh dạng: <duration>");
this.put("data-invalid-block", "&cDữ liệu &bblock &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <blockName>"); this.put("data-invalid-block", "&cDữ liệu &bblock &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <blockName>");
this.put("data-invalid-item", "&cDữ liệu &bitem &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <itemName>"); this.put("data-invalid-item", "&cDữ liệu &bitem &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <itemName>");
this.put("data-invalid-color", "&cDữ liệu &bcolor &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <<0-255> <0-255> <0-255>>|<rainbow>|<random>"); this.put("data-invalid-color", "&cDữ liệu &bcolor &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-invalid-note", "&cDữ liệu &bnote &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <0-24>|<rainbow>|<random>"); this.put("data-invalid-note", "&cDữ liệu &bnote &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <0-24>|<&brainbow>|<random>");
this.put("data-invalid-color-transition", "&cDữ liệu &bcolor transition &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <<0-255> <0-255> <0-255>>|<&brainbow>|<random> <<0-255> <0-255> <0-255>>|<&brainbow>|<random>");
this.put("data-invalid-vibration", "&cDữ liệu &bvibration &cbạn đã nhập không hợp lệ! &bĐịnh dạng: <duration>");
this.put("data-invalid-material-not-item", "&cDữ liệu &bitem &c: Vật phẩm &b%material% &cbạn đã nhập không phải là một vật phẩm!"); this.put("data-invalid-material-not-item", "&cDữ liệu &bitem &c: Vật phẩm &b%material% &cbạn đã nhập không phải là một vật phẩm!");
this.put("data-invalid-material-not-block", "&cDữ liệu &bblock &c: Vật phẩm &b%material% &cbạn đã nhập không phải là một khối!"); this.put("data-invalid-material-not-block", "&cDữ liệu &bblock &c: Vật phẩm &b%material% &cbạn đã nhập không phải là một khối!");
this.put("data-invalid-material-item", "&cDữ liệu &bitem &c: Vật phẩm &b%material% bạn đã nhập không tồn tại!"); this.put("data-invalid-material-item", "&cDữ liệu &bitem &c: Vật phẩm &b%material% bạn đã nhập không tồn tại!");
@ -325,25 +329,28 @@ public class VietnameseLocale implements Locale {
this.put("gui-select-style-description", "Thiết lập Kiểu hiệu ứng của Hạt thành &b%style%"); this.put("gui-select-style-description", "Thiết lập Kiểu hiệu ứng của Hạt thành &b%style%");
this.put("gui-select-data", "Chọn Dữ liệu của Hạt"); this.put("gui-select-data", "Chọn Dữ liệu của Hạt");
this.put("gui-select-data-description", "Thiết lập DỮ liệu của Hạt thành &b%data%"); this.put("gui-select-data-description", "Thiết lập DỮ liệu của Hạt thành &b%data%");
this.put("gui-select-data-note", "note #%note%"); this.put("gui-select-data-note", "Note #%note%");
this.put("gui-select-data-color-transition-start", "&eChọn màu &bbắt đầu");
this.put("gui-select-data-color-transition-end", "&eChọn màu &bkết thúc");
this.put("gui-select-data-vibration", "&b%ticks% &eticks");
this.put("#38", "GUI Color Name Messages"); this.put("#38", "GUI Color Name Messages");
this.put("gui-edit-data-color-red", "&cĐỏ mạnh mẽ"); this.put("gui-edit-data-color-red", "#ff0000Đỏ mạnh mẽ");
this.put("gui-edit-data-color-orange", "&6Cam dịu dàng"); this.put("gui-edit-data-color-orange", "#ff8c00Cam dịu dàng");
this.put("gui-edit-data-color-yellow", "&eVàng yêu thương"); this.put("gui-edit-data-color-yellow", "#ffff00Vàng yêu thương");
this.put("gui-edit-data-color-lime-green", "&aXanh nhẹ nhàng"); this.put("gui-edit-data-color-lime-green", "#32cd32Xanh nhẹ nhàng");
this.put("gui-edit-data-color-green", "&2Xanh đen tối"); this.put("gui-edit-data-color-green", "#008000Xanh đen tối");
this.put("gui-edit-data-color-blue", "&1Xanh lam"); this.put("gui-edit-data-color-blue", "#0000ffXanh lam");
this.put("gui-edit-data-color-cyan", "&3Lục lam"); this.put("gui-edit-data-color-cyan", "#008b8bLục lam");
this.put("gui-edit-data-color-light-blue", "&bXanh Da trời"); this.put("gui-edit-data-color-light-blue", "#add8e6Xanh Da trời");
this.put("gui-edit-data-color-purple", "&5Tím cá tính"); this.put("gui-edit-data-color-purple", "#8a2be2Tím cá tính");
this.put("gui-edit-data-color-magenta", "&dĐỏ tươi"); this.put("gui-edit-data-color-magenta", "#ca1f7bĐỏ tươi");
this.put("gui-edit-data-color-pink", "&dHồng nam tính"); this.put("gui-edit-data-color-pink", "#ffb6c1Hồng nam tính");
this.put("gui-edit-data-color-brown", "&6Nâu thâm thâm"); this.put("gui-edit-data-color-brown", "#8b4513Nâu thâm thâm");
this.put("gui-edit-data-color-black", "&8Đen như tâm hồn"); this.put("gui-edit-data-color-black", "#000000Đen như tâm hồn");
this.put("gui-edit-data-color-gray", "&8Xám"); this.put("gui-edit-data-color-gray", "#808080Xám");
this.put("gui-edit-data-color-light-gray", "&7Xám nhạt"); this.put("gui-edit-data-color-light-gray", "#c0c0c0Xám nhạt");
this.put("gui-edit-data-color-white", "&fTrắng tinh khiết"); this.put("gui-edit-data-color-white", "#ffffffTrắng tinh khiết");
}}; }};
} }
} }

View file

@ -24,11 +24,13 @@ import dev.esophose.playerparticles.command.UseCommandModule;
import dev.esophose.playerparticles.command.VersionCommandModule; import dev.esophose.playerparticles.command.VersionCommandModule;
import dev.esophose.playerparticles.command.WorldsCommandModule; import dev.esophose.playerparticles.command.WorldsCommandModule;
import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.util.ParticleUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -157,7 +159,7 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
sender.sendMessage(ChatColor.RED + "Error: This command can only be executed by a player."); sender.sendMessage(ChatColor.RED + "Error: This command can only be executed by a player.");
return; return;
} }
} else if (sender instanceof ConsoleCommandSender) { } else if (sender instanceof ConsoleCommandSender || sender instanceof BlockCommandSender) {
commandModule.onCommandExecute(PlayerParticlesAPI.getInstance().getConsolePPlayer(), cmdArgs); commandModule.onCommandExecute(PlayerParticlesAPI.getInstance().getConsolePPlayer(), cmdArgs);
return; return;
} }
@ -194,7 +196,13 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
if (cmd.getName().equalsIgnoreCase("pp")) { if (cmd.getName().equalsIgnoreCase("pp")) {
PPlayer pplayer = PlayerParticlesAPI.getInstance().getPPlayer(sender); PPlayer pplayer;
if (sender instanceof Player && !ParticleUtils.getTargetBlock((Player) sender).getType().name().contains("COMMAND_BLOCK")) {
pplayer = PlayerParticlesAPI.getInstance().getPPlayer(sender);
} else {
pplayer = PlayerParticlesAPI.getInstance().getConsolePPlayer();
}
if (pplayer == null) if (pplayer == null)
return new ArrayList<>(); return new ArrayList<>();
@ -204,7 +212,7 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
} else { } else {
CommandModule commandModule = this.findMatchingCommand(args[0]); CommandModule commandModule = this.findMatchingCommand(args[0]);
if (commandModule != null) { if (commandModule != null) {
if (sender instanceof ConsoleCommandSender && !commandModule.canConsoleExecute()) if (pplayer.getPlayer() == null && !commandModule.canConsoleExecute())
return new ArrayList<>(); return new ArrayList<>();
String[] cmdArgs = Arrays.copyOfRange(args, 1, args.length); String[] cmdArgs = Arrays.copyOfRange(args, 1, args.length);

View file

@ -11,8 +11,10 @@ import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.NoteColor; import dev.esophose.playerparticles.particles.data.NoteColor;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.ParticleUtils;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -91,10 +93,7 @@ public class DataManager extends Manager {
* @return The PPlayer from cache * @return The PPlayer from cache
*/ */
public PPlayer getPPlayer(UUID playerUUID) { public PPlayer getPPlayer(UUID playerUUID) {
for (PPlayer pp : this.playerParticles.getManager(ParticleManager.class).getPPlayers()) return this.playerParticles.getManager(ParticleManager.class).getPPlayers().get(playerUUID);
if (pp.getUniqueId().equals(playerUUID))
return pp;
return null;
} }
/** /**
@ -160,7 +159,9 @@ public class DataManager extends Manager {
Material blockMaterial = ParticleUtils.closestMatchWithFallback(true, result.getString("block_material")); Material blockMaterial = ParticleUtils.closestMatchWithFallback(true, result.getString("block_material"));
NoteColor noteColor = new NoteColor(result.getInt("note")); NoteColor noteColor = new NoteColor(result.getInt("note"));
OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b")); OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b"));
ParticlePair particle = new ParticlePair(playerUUID, id, effect, style, itemMaterial, blockMaterial, color, noteColor); ColorTransition colorTransition = new ColorTransition(new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b")), new OrdinaryColor(result.getInt("r_end"), result.getInt("g_end"), result.getInt("b_end")));
Vibration vibration = new Vibration(result.getInt("duration"));
ParticlePair particle = new ParticlePair(playerUUID, id, effect, style, itemMaterial, blockMaterial, color, noteColor, colorTransition, vibration);
boolean invalid = effect == null || style == null; boolean invalid = effect == null || style == null;
if (invalid) // Effect or style is now missing or disabled, remove the particle if (invalid) // Effect or style is now missing or disabled, remove the particle
@ -197,7 +198,7 @@ public class DataManager extends Manager {
} }
// Load fixed effects // Load fixed effects
String fixedQuery = "SELECT f.id AS f_id, f.world, f.xPos, f.yPos, f.zPos, p.id AS p_id, p.effect, p.style, p.item_material, p.block_material, p.note, p.r, p.g, p.b FROM " + this.getTablePrefix() + "fixed f " + String fixedQuery = "SELECT f.id AS f_id, f.world, f.xPos, f.yPos, f.zPos, p.id AS p_id, p.effect, p.style, p.item_material, p.block_material, p.note, p.r, p.g, p.b, p.r_end, p.g_end, p.b_end, p.duration FROM " + this.getTablePrefix() + "fixed f " +
"JOIN " + this.getTablePrefix() + "particle p ON f.particle_uuid = p.uuid " + "JOIN " + this.getTablePrefix() + "particle p ON f.particle_uuid = p.uuid " +
"WHERE f.owner_uuid = ?"; "WHERE f.owner_uuid = ?";
try (PreparedStatement statement = connection.prepareStatement(fixedQuery)) { try (PreparedStatement statement = connection.prepareStatement(fixedQuery)) {
@ -227,7 +228,9 @@ public class DataManager extends Manager {
Material blockMaterial = ParticleUtils.closestMatchWithFallback(true, result.getString("block_material")); Material blockMaterial = ParticleUtils.closestMatchWithFallback(true, result.getString("block_material"));
NoteColor noteColor = new NoteColor(result.getInt("note")); NoteColor noteColor = new NoteColor(result.getInt("note"));
OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b")); OrdinaryColor color = new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b"));
ParticlePair particle = new ParticlePair(playerUUID, particleId, effect, style, itemMaterial, blockMaterial, color, noteColor); ColorTransition colorTransition = new ColorTransition(new OrdinaryColor(result.getInt("r"), result.getInt("g"), result.getInt("b")), new OrdinaryColor(result.getInt("r_end"), result.getInt("g_end"), result.getInt("b_end")));
Vibration vibration = new Vibration(result.getInt("duration"));
ParticlePair particle = new ParticlePair(playerUUID, particleId, effect, style, itemMaterial, blockMaterial, color, noteColor, colorTransition, vibration);
// Effect or style is now missing or disabled, remove the fixed effect // Effect or style is now missing or disabled, remove the fixed effect
if (effect == null || style == null) { if (effect == null || style == null) {
@ -351,7 +354,7 @@ public class DataManager extends Manager {
} }
// Fill group with new particles // Fill group with new particles
String createParticlesQuery = "INSERT INTO " + this.getTablePrefix() + "particle (uuid, group_uuid, id, effect, style, item_material, block_material, note, r, g, b) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; String createParticlesQuery = "INSERT INTO " + this.getTablePrefix() + "particle (uuid, group_uuid, id, effect, style, item_material, block_material, note, r, g, b, r_end, g_end, b_end, duration) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try (PreparedStatement particlesStatement = connection.prepareStatement(createParticlesQuery)) { try (PreparedStatement particlesStatement = connection.prepareStatement(createParticlesQuery)) {
for (ParticlePair particle : group.getParticles().values()) { for (ParticlePair particle : group.getParticles().values()) {
particlesStatement.setString(1, UUID.randomUUID().toString()); particlesStatement.setString(1, UUID.randomUUID().toString());
@ -365,6 +368,10 @@ public class DataManager extends Manager {
particlesStatement.setInt(9, particle.getColor().getRed()); particlesStatement.setInt(9, particle.getColor().getRed());
particlesStatement.setInt(10, particle.getColor().getGreen()); particlesStatement.setInt(10, particle.getColor().getGreen());
particlesStatement.setInt(11, particle.getColor().getBlue()); particlesStatement.setInt(11, particle.getColor().getBlue());
particlesStatement.setInt(12, particle.getColorTransition().getEndColor().getRed());
particlesStatement.setInt(13, particle.getColorTransition().getEndColor().getGreen());
particlesStatement.setInt(14, particle.getColorTransition().getEndColor().getBlue());
particlesStatement.setInt(15, particle.getVibration().getDuration());
particlesStatement.addBatch(); particlesStatement.addBatch();
} }
@ -444,7 +451,7 @@ public class DataManager extends Manager {
this.async(() -> this.databaseConnector.connect((connection) -> { this.async(() -> this.databaseConnector.connect((connection) -> {
String particleUUID = UUID.randomUUID().toString(); String particleUUID = UUID.randomUUID().toString();
String particleQuery = "INSERT INTO " + this.getTablePrefix() + "particle (uuid, id, effect, style, item_material, block_material, note, r, g, b) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; String particleQuery = "INSERT INTO " + this.getTablePrefix() + "particle (uuid, id, effect, style, item_material, block_material, note, r, g, b, r_end, g_end, b_end, duration) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try (PreparedStatement statement = connection.prepareStatement(particleQuery)) { try (PreparedStatement statement = connection.prepareStatement(particleQuery)) {
ParticlePair particle = fixedEffect.getParticlePair(); ParticlePair particle = fixedEffect.getParticlePair();
statement.setString(1, particleUUID); statement.setString(1, particleUUID);
@ -457,6 +464,10 @@ public class DataManager extends Manager {
statement.setInt(8, particle.getColor().getRed()); statement.setInt(8, particle.getColor().getRed());
statement.setInt(9, particle.getColor().getGreen()); statement.setInt(9, particle.getColor().getGreen());
statement.setInt(10, particle.getColor().getBlue()); statement.setInt(10, particle.getColor().getBlue());
statement.setInt(11, particle.getColorTransition().getEndColor().getRed());
statement.setInt(12, particle.getColorTransition().getEndColor().getGreen());
statement.setInt(13, particle.getColorTransition().getEndColor().getBlue());
statement.setInt(14, particle.getVibration().getDuration());
statement.executeUpdate(); statement.executeUpdate();
} }
@ -494,7 +505,7 @@ public class DataManager extends Manager {
// Update particle // Update particle
String particleUpdateQuery = "UPDATE " + this.getTablePrefix() + "particle " + String particleUpdateQuery = "UPDATE " + this.getTablePrefix() + "particle " +
"SET effect = ?, style = ?, item_material = ?, block_material = ?, note = ?, r = ?, g = ?, b = ? " + "SET effect = ?, style = ?, item_material = ?, block_material = ?, note = ?, r = ?, g = ?, b = ?, r_end = ?, g_end = ?, b_end = ?, duration = ? " +
"WHERE uuid = (SELECT particle_uuid FROM " + this.getTablePrefix() + "fixed WHERE owner_uuid = ? AND id = ?)"; "WHERE uuid = (SELECT particle_uuid FROM " + this.getTablePrefix() + "fixed WHERE owner_uuid = ? AND id = ?)";
try (PreparedStatement statement = connection.prepareStatement(particleUpdateQuery)) { try (PreparedStatement statement = connection.prepareStatement(particleUpdateQuery)) {
ParticlePair particle = fixedEffect.getParticlePair(); ParticlePair particle = fixedEffect.getParticlePair();
@ -506,8 +517,12 @@ public class DataManager extends Manager {
statement.setInt(6, particle.getColor().getRed()); statement.setInt(6, particle.getColor().getRed());
statement.setInt(7, particle.getColor().getGreen()); statement.setInt(7, particle.getColor().getGreen());
statement.setInt(8, particle.getColor().getBlue()); statement.setInt(8, particle.getColor().getBlue());
statement.setString(9, fixedEffect.getOwnerUniqueId().toString()); statement.setInt(9, particle.getColorTransition().getEndColor().getRed());
statement.setInt(10, fixedEffect.getId()); statement.setInt(10, particle.getColorTransition().getEndColor().getGreen());
statement.setInt(11, particle.getColorTransition().getEndColor().getBlue());
statement.setInt(12, particle.getVibration().getDuration());
statement.setString(13, fixedEffect.getOwnerUniqueId().toString());
statement.setInt(14, fixedEffect.getId());
statement.executeUpdate(); statement.executeUpdate();
} }
})); }));

View file

@ -5,6 +5,7 @@ import dev.esophose.playerparticles.database.DataMigration;
import dev.esophose.playerparticles.database.DatabaseConnector; import dev.esophose.playerparticles.database.DatabaseConnector;
import dev.esophose.playerparticles.database.SQLiteConnector; import dev.esophose.playerparticles.database.SQLiteConnector;
import dev.esophose.playerparticles.database.migrations._1_InitialMigration; import dev.esophose.playerparticles.database.migrations._1_InitialMigration;
import dev.esophose.playerparticles.database.migrations._2_Add_Data_Columns;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.Arrays; import java.util.Arrays;
@ -20,7 +21,8 @@ public class DataMigrationManager extends Manager {
super(playerParticles); super(playerParticles);
this.migrations = Arrays.asList( this.migrations = Arrays.asList(
new _1_InitialMigration() new _1_InitialMigration(),
new _2_Add_Data_Columns()
); );
} }

View file

@ -9,8 +9,10 @@ import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.ParticleGroup; import dev.esophose.playerparticles.particles.ParticleGroup;
import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.particles.ParticlePair;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.NoteColor; import dev.esophose.playerparticles.particles.data.NoteColor;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.particles.preset.ParticleGroupPreset; import dev.esophose.playerparticles.particles.preset.ParticleGroupPreset;
import dev.esophose.playerparticles.particles.preset.ParticleGroupPresetPage; import dev.esophose.playerparticles.particles.preset.ParticleGroupPresetPage;
import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.styles.ParticleStyle;
@ -147,6 +149,8 @@ public class ParticleGroupPresetManager extends Manager {
Material blockData = null; Material blockData = null;
OrdinaryColor colorData = null; OrdinaryColor colorData = null;
NoteColor noteColorData = null; NoteColor noteColorData = null;
ColorTransition colorTransitionData = null;
Vibration vibrationData = null;
String dataString = particleSection.getString("data"); String dataString = particleSection.getString("data");
if (dataString != null && !dataString.isEmpty()) { if (dataString != null && !dataString.isEmpty()) {
@ -181,10 +185,22 @@ public class ParticleGroupPresetManager extends Manager {
continue; continue;
} }
} }
} else if (effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
colorTransitionData = inputParser.next(ColorTransition.class);
if (colorTransitionData == null) {
PlayerParticles.getInstance().getLogger().severe("Invalid color transition: '" + dataString + "'!");
return;
}
} else if (effect.hasProperty(ParticleProperty.VIBRATION)) {
vibrationData = inputParser.next(Vibration.class);
if (vibrationData == null) {
PlayerParticles.getInstance().getLogger().severe("Invalid vibration: '" + dataString + "'!");
return;
}
} }
} }
particles.put(id, new ParticlePair(null, id, effect, style, itemData, blockData, colorData, noteColorData)); particles.put(id, new ParticlePair(null, id, effect, style, itemData, blockData, colorData, noteColorData, colorTransitionData, vibrationData));
} }
presets.add(new ParticleGroupPreset(displayName, guiIcon, guiSlot, lore, permission, allowPermissionOverride, new ParticleGroup(groupName, particles))); presets.add(new ParticleGroupPreset(displayName, guiIcon, guiSlot, lore, permission, allowPermissionOverride, new ParticleGroup(groupName, particles)));

View file

@ -14,7 +14,7 @@ import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.styles.DefaultStyles; import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.ParticleUtils;
import java.awt.Color; import java.awt.Color;
import java.util.Collection; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -160,8 +160,8 @@ public class ParticleManager extends Manager implements Listener, Runnable {
* *
* @return The loaded PPlayers * @return The loaded PPlayers
*/ */
public Collection<PPlayer> getPPlayers() { public Map<UUID, PPlayer> getPPlayers() {
return this.particlePlayers.values(); return Collections.unmodifiableMap(this.particlePlayers);
} }
/** /**
@ -312,6 +312,16 @@ public class ParticleManager extends Manager implements Listener, Runnable {
return new OrdinaryColor(rgb.getRed(), rgb.getGreen(), rgb.getBlue()); return new OrdinaryColor(rgb.getRed(), rgb.getGreen(), rgb.getBlue());
} }
/**
* Gets the rainbow OrdinaryColor for particle spawning with data 'rainbow', shifted half way through the HSB spectrum
*
* @return The rainbow OrdinaryColor for particle spawning with data 'rainbow', shifted half way through the HSB spectrum
*/
public OrdinaryColor getShiftedRainbowParticleColor() {
Color rgb = Color.getHSBColor((this.hue / 360F) + 0.5F, 1.0F, 1.0F);
return new OrdinaryColor(rgb.getRed(), rgb.getGreen(), rgb.getBlue());
}
/** /**
* Gets the rainbow NoteColor for particle spawning with data 'rainbow' * Gets the rainbow NoteColor for particle spawning with data 'rainbow'
* *

View file

@ -7,7 +7,7 @@ import dev.esophose.playerparticles.styles.ParticleStyle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -25,8 +25,8 @@ public class ParticleStyleManager extends Manager {
public ParticleStyleManager(PlayerParticles playerParticles) { public ParticleStyleManager(PlayerParticles playerParticles) {
super(playerParticles); super(playerParticles);
this.stylesByName = new HashMap<>(); this.stylesByName = new LinkedHashMap<>();
this.stylesByInternalName = new HashMap<>(); this.stylesByInternalName = new LinkedHashMap<>();
this.eventStyles = new ArrayList<>(); this.eventStyles = new ArrayList<>();
DefaultStyles.initStyles(); DefaultStyles.initStyles();

View file

@ -3,9 +3,11 @@ package dev.esophose.playerparticles.particles;
import com.google.common.collect.ObjectArrays; import com.google.common.collect.ObjectArrays;
import dev.esophose.playerparticles.PlayerParticles; import dev.esophose.playerparticles.PlayerParticles;
import dev.esophose.playerparticles.config.CommentedFileConfiguration; import dev.esophose.playerparticles.config.CommentedFileConfiguration;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.NoteColor; import dev.esophose.playerparticles.particles.data.NoteColor;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.particles.data.ParticleColor; import dev.esophose.playerparticles.particles.data.ParticleColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.particles.spawning.ParticleSpawner; import dev.esophose.playerparticles.particles.spawning.ParticleSpawner;
import dev.esophose.playerparticles.particles.spawning.ParticleSpawner.ParticleColorException; import dev.esophose.playerparticles.particles.spawning.ParticleSpawner.ParticleColorException;
import dev.esophose.playerparticles.particles.spawning.ParticleSpawner.ParticleDataException; import dev.esophose.playerparticles.particles.spawning.ParticleSpawner.ParticleDataException;
@ -46,28 +48,37 @@ public enum ParticleEffect {
DAMAGE_INDICATOR("DAMAGE_INDICATOR", Collections.singletonList("BOW")), DAMAGE_INDICATOR("DAMAGE_INDICATOR", Collections.singletonList("BOW")),
DOLPHIN("DOLPHIN", Collections.singletonList("DOLPHIN_SPAWN_EGG")), DOLPHIN("DOLPHIN", Collections.singletonList("DOLPHIN_SPAWN_EGG")),
DRAGON_BREATH("DRAGON_BREATH", Arrays.asList("DRAGON_BREATH", "DRAGONS_BREATH")), DRAGON_BREATH("DRAGON_BREATH", Arrays.asList("DRAGON_BREATH", "DRAGONS_BREATH")),
DRIPPING_DRIPSTONE_LAVA("DRIPPING_DRIPSTONE_LAVA", Collections.singletonList("POINTED_DRIPSTONE")),
DRIPPING_DRIPSTONE_WATER("DRIPPING_DRIPSTONE_WATER", Collections.singletonList("DRIPSTONE_BLOCK")),
DRIPPING_HONEY("DRIPPING_HONEY", Collections.singletonList("BEE_NEST")), DRIPPING_HONEY("DRIPPING_HONEY", Collections.singletonList("BEE_NEST")),
DRIPPING_LAVA("DRIP_LAVA", Collections.singletonList("LAVA_BUCKET")), DRIPPING_LAVA("DRIP_LAVA", Collections.singletonList("LAVA_BUCKET")),
DRIPPING_OBSIDIAN_TEAR("DRIPPING_OBSIDIAN_TEAR", Collections.singletonList("CRYING_OBSIDIAN")), DRIPPING_OBSIDIAN_TEAR("DRIPPING_OBSIDIAN_TEAR", Collections.singletonList("CRYING_OBSIDIAN")),
DRIPPING_WATER("DRIP_WATER", Collections.singletonList("WATER_BUCKET")), DRIPPING_WATER("DRIP_WATER", Collections.singletonList("WATER_BUCKET")),
DUST("REDSTONE", Collections.singletonList("REDSTONE"), ParticleProperty.COLORABLE), DUST("REDSTONE", Collections.singletonList("REDSTONE"), ParticleProperty.COLORABLE),
DUST_COLOR_TRANSITION("DUST_COLOR_TRANSITION", Collections.singletonList("DEEPSLATE_REDSTONE_ORE"), ParticleProperty.COLORABLE_TRANSITION),
ELDER_GUARDIAN("MOB_APPEARANCE", Arrays.asList("ELDER_GUARDIAN_SPAWN_EGG", "PRISMARINE_CRYSTALS"), false), // No thank you ELDER_GUARDIAN("MOB_APPEARANCE", Arrays.asList("ELDER_GUARDIAN_SPAWN_EGG", "PRISMARINE_CRYSTALS"), false), // No thank you
ELECTRIC_SPARK("ELECTRIC_SPARK", Collections.singletonList("LIGHTNING_ROD")),
ENCHANT("ENCHANTMENT_TABLE", Arrays.asList("ENCHANTING_TABLE", "ENCHANTMENT_TABLE")), ENCHANT("ENCHANTMENT_TABLE", Arrays.asList("ENCHANTING_TABLE", "ENCHANTMENT_TABLE")),
ENCHANTED_HIT("CRIT_MAGIC", Collections.singletonList("DIAMOND_SWORD")), ENCHANTED_HIT("CRIT_MAGIC", Collections.singletonList("DIAMOND_SWORD")),
END_ROD("END_ROD", Collections.singletonList("END_ROD")), END_ROD("END_ROD", Collections.singletonList("END_ROD")),
ENTITY_EFFECT("SPELL_MOB", Collections.singletonList("GLOWSTONE_DUST"), ParticleProperty.COLORABLE), ENTITY_EFFECT("SPELL_MOB", Collections.singletonList("GLOWSTONE_DUST"), ParticleProperty.COLORABLE),
EXPLOSION("EXPLOSION_LARGE", Arrays.asList("FIRE_CHARGE", "FIREBALL")), EXPLOSION("EXPLOSION_LARGE", Arrays.asList("FIRE_CHARGE", "FIREBALL")),
EXPLOSION_EMITTER("EXPLOSION_HUGE", Collections.singletonList("TNT")), EXPLOSION_EMITTER("EXPLOSION_HUGE", Collections.singletonList("TNT")),
FALLING_DRIPSTONE_LAVA("FALLING_DRIPSTONE_LAVA", Collections.singletonList("SMOOTH_BASALT")),
FALLING_DRIPSTONE_WATER("FALLING_DRIPSTONE_WATER", Collections.singletonList("CALCITE")),
FALLING_DUST("FALLING_DUST", Collections.singletonList("SAND"), ParticleProperty.REQUIRES_MATERIAL_DATA), FALLING_DUST("FALLING_DUST", Collections.singletonList("SAND"), ParticleProperty.REQUIRES_MATERIAL_DATA),
FALLING_HONEY("FALLING_HONEY", Collections.singletonList("HONEY_BOTTLE")), FALLING_HONEY("FALLING_HONEY", Collections.singletonList("HONEY_BOTTLE")),
FALLING_LAVA("FALLING_LAVA", Collections.singletonList("RED_DYE")), FALLING_LAVA("FALLING_LAVA", Collections.singletonList("RED_DYE")),
FALLING_NECTAR("FALLING_NECTAR", Collections.singletonList("HONEYCOMB")), FALLING_NECTAR("FALLING_NECTAR", Collections.singletonList("HONEYCOMB")),
FALLING_OBSIDIAN_TEAR("FALLING_OBSIDIAN_TEAR", Collections.singletonList("ANCIENT_DEBRIS")), FALLING_OBSIDIAN_TEAR("FALLING_OBSIDIAN_TEAR", Collections.singletonList("ANCIENT_DEBRIS")),
FALLING_SPORE_BLOSSOM("FALLING_SPORE_BLOSSOM", Collections.singletonList("FLOWERING_AZALEA")),
FALLING_WATER("FALLING_WATER", Collections.singletonList("BLUE_DYE")), FALLING_WATER("FALLING_WATER", Collections.singletonList("BLUE_DYE")),
FIREWORK("FIREWORKS_SPARK", Arrays.asList("FIREWORK_ROCKET", "FIREWORK")), FIREWORK("FIREWORKS_SPARK", Arrays.asList("FIREWORK_ROCKET", "FIREWORK")),
FISHING("WATER_WAKE", Collections.singletonList("FISHING_ROD")), FISHING("WATER_WAKE", Collections.singletonList("FISHING_ROD")),
FLAME("FLAME", Collections.singletonList("BLAZE_POWDER")), FLAME("FLAME", Collections.singletonList("BLAZE_POWDER")),
FLASH("FLASH", Collections.singletonList("GOLD_INGOT"), false), // Also no thank you FLASH("FLASH", Collections.singletonList("GOLD_INGOT"), false), // Also no thank you
GLOW("GLOW", Collections.singletonList("GLOW_ITEM_FRAME")),
GLOW_SQUID_INK("GLOW_SQUID_INK", Collections.singletonList("GLOW_INK_SAC")),
FOOTSTEP("FOOTSTEP", Collections.singletonList("GRASS")), // Removed in Minecraft 1.13 :( FOOTSTEP("FOOTSTEP", Collections.singletonList("GRASS")), // Removed in Minecraft 1.13 :(
HAPPY_VILLAGER("VILLAGER_HAPPY", Arrays.asList("DARK_OAK_DOOR_ITEM", "DARK_OAK_DOOR")), HAPPY_VILLAGER("VILLAGER_HAPPY", Arrays.asList("DARK_OAK_DOOR_ITEM", "DARK_OAK_DOOR")),
HEART("HEART", Arrays.asList("POPPY", "RED_ROSE")), HEART("HEART", Arrays.asList("POPPY", "RED_ROSE")),
@ -80,6 +91,7 @@ public enum ParticleEffect {
LANDING_OBSIDIAN_TEAR("LANDING_OBSIDIAN_TEAR", Collections.singletonList("NETHERITE_BLOCK")), LANDING_OBSIDIAN_TEAR("LANDING_OBSIDIAN_TEAR", Collections.singletonList("NETHERITE_BLOCK")),
LARGE_SMOKE("SMOKE_LARGE", Arrays.asList("COBWEB", "WEB")), LARGE_SMOKE("SMOKE_LARGE", Arrays.asList("COBWEB", "WEB")),
LAVA("LAVA", Collections.singletonList("MAGMA_CREAM")), LAVA("LAVA", Collections.singletonList("MAGMA_CREAM")),
LIGHT("LIGHT", Collections.singletonList("LIGHT")),
MYCELIUM("TOWN_AURA", Arrays.asList("MYCELIUM", "MYCEL")), MYCELIUM("TOWN_AURA", Arrays.asList("MYCELIUM", "MYCEL")),
NAUTILUS("NAUTILUS", Collections.singletonList("HEART_OF_THE_SEA")), NAUTILUS("NAUTILUS", Collections.singletonList("HEART_OF_THE_SEA")),
NOTE("NOTE", Collections.singletonList("NOTE_BLOCK"), ParticleProperty.COLORABLE), NOTE("NOTE", Collections.singletonList("NOTE_BLOCK"), ParticleProperty.COLORABLE),
@ -87,25 +99,29 @@ public enum ParticleEffect {
PORTAL("PORTAL", Collections.singletonList("OBSIDIAN")), PORTAL("PORTAL", Collections.singletonList("OBSIDIAN")),
RAIN("WATER_DROP", Arrays.asList("PUFFERFISH_BUCKET", "LAPIS_BLOCK")), RAIN("WATER_DROP", Arrays.asList("PUFFERFISH_BUCKET", "LAPIS_BLOCK")),
REVERSE_PORTAL("REVERSE_PORTAL", Collections.singletonList("FLINT_AND_STEEL")), REVERSE_PORTAL("REVERSE_PORTAL", Collections.singletonList("FLINT_AND_STEEL")),
SCRAPE("SCRAPE", Collections.singletonList("GOLDEN_AXE")),
SMALL_FLAME("SMALL_FLAME", Collections.singletonList("CANDLE")),
SMOKE("SMOKE_NORMAL", Collections.singletonList("TORCH")), SMOKE("SMOKE_NORMAL", Collections.singletonList("TORCH")),
SNEEZE("SNEEZE", Collections.singletonList("BAMBOO")), SNEEZE("SNEEZE", Collections.singletonList("BAMBOO")),
SNOWFLAKE("SNOWFLAKE", Collections.singletonList("POWDER_SNOW_BUCKET")),
SOUL("SOUL", Collections.singletonList("SOUL_LANTERN")), SOUL("SOUL", Collections.singletonList("SOUL_LANTERN")),
SOUL_FIRE_FLAME("SOUL_FIRE_FLAME", Collections.singletonList("SOUL_CAMPFIRE")), SOUL_FIRE_FLAME("SOUL_FIRE_FLAME", Collections.singletonList("SOUL_CAMPFIRE")),
SPELL("SPELL", Arrays.asList("POTION", "GLASS_BOTTLE")), // The Minecraft internal name for this is actually "effect", but that's the command name, so it's SPELL for the plugin instead SPELL("SPELL", Arrays.asList("POTION", "GLASS_BOTTLE")), // 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", Arrays.asList("LLAMA_SPAWN_EGG", "PUMPKIN_SEEDS")), SPIT("SPIT", Arrays.asList("LLAMA_SPAWN_EGG", "PUMPKIN_SEEDS")),
SPLASH("WATER_SPLASH", Arrays.asList("SALMON", "FISH", "RAW_FISH")), SPLASH("WATER_SPLASH", Arrays.asList("SALMON", "FISH", "RAW_FISH")),
SPORE_BLOSSOM_AIR("SPORE_BLOSSOM_AIR", Collections.singletonList("SPORE_BLOSSOM")),
SQUID_INK("SQUID_INK", Collections.singletonList("INK_SAC")), SQUID_INK("SQUID_INK", Collections.singletonList("INK_SAC")),
SWEEP_ATTACK("SWEEP_ATTACK", Arrays.asList("GOLDEN_SWORD", "GOLD_SWORD")), SWEEP_ATTACK("SWEEP_ATTACK", Arrays.asList("GOLDEN_SWORD", "GOLD_SWORD")),
TOTEM_OF_UNDYING("TOTEM", Arrays.asList("TOTEM_OF_UNDYING", "TOTEM")), TOTEM_OF_UNDYING("TOTEM", Arrays.asList("TOTEM_OF_UNDYING", "TOTEM")),
UNDERWATER("SUSPENDED_DEPTH", Arrays.asList("TURTLE_HELMET", "SPONGE")), UNDERWATER("SUSPENDED_DEPTH", Arrays.asList("TURTLE_HELMET", "SPONGE")),
VIBRATION("VIBRATION", Collections.singletonList("SCULK_SENSOR"), false, ParticleProperty.VIBRATION),
WARPED_SPORE("WARPED_SPORE", Collections.singletonList("WARPED_FUNGUS")), WARPED_SPORE("WARPED_SPORE", Collections.singletonList("WARPED_FUNGUS")),
WAX_OFF("WAX_OFF", Collections.singletonList("OXIDIZED_COPPER")),
WAX_ON("WAX_ON", Collections.singletonList("WAXED_COPPER_BLOCK")),
WHITE_ASH("WHITE_ASH", Collections.singletonList("BASALT")), WHITE_ASH("WHITE_ASH", Collections.singletonList("BASALT")),
WITCH("SPELL_WITCH", Collections.singletonList("CAULDRON")); WITCH("SPELL_WITCH", Collections.singletonList("CAULDRON"));
private final static ParticleSpawner particleSpawner; private final static ParticleSpawner particleSpawner = NMSUtil.getVersionNumber() >= 9 ? new SpigotParticleSpawner() : new ReflectiveParticleSpawner();
static {
particleSpawner = NMSUtil.getVersionNumber() >= 9 ? new SpigotParticleSpawner() : new ReflectiveParticleSpawner();
}
private Particle internalEnum; private Particle internalEnum;
private List<ParticleProperty> properties; private List<ParticleProperty> properties;
@ -266,6 +282,13 @@ public enum ParticleEffect {
return this.properties.contains(property); return this.properties.contains(property);
} }
/**
* @return true if this effect has any properties
*/
public boolean hasProperties() {
return !this.properties.isEmpty();
}
/** /**
* Determine if this particle effect is supported by the current server version * Determine if this particle effect is supported by the current server version
* *
@ -345,6 +368,22 @@ public enum ParticleEffect {
data = particle.getSpawnColor(); data = particle.getSpawnColor();
} }
effect.display(data, pparticle.getLocation(true), isLongRange, owner); effect.display(data, pparticle.getLocation(true), isLongRange, owner);
} else if (effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
ColorTransition data;
if (pparticle.getOverrideData() instanceof ColorTransition) {
data = (ColorTransition) pparticle.getOverrideData();
} else {
data = particle.getSpawnColorTransition();
}
effect.display(data, pparticle.getXOff(), pparticle.getYOff(), pparticle.getZOff(), 1, pparticle.getLocation(false), isLongRange, owner);
} else if (effect.hasProperty(ParticleProperty.VIBRATION)) {
Vibration data;
if (pparticle.getOverrideData() instanceof Vibration) {
data = (Vibration) pparticle.getOverrideData();
} else {
data = particle.getVibration();
}
effect.display(data, pparticle.getXOff(), pparticle.getYOff(), pparticle.getZOff(), 1, pparticle.getLocation(false), isLongRange, owner);
} else { } else {
effect.display(pparticle.getXOff(), pparticle.getYOff(), pparticle.getZOff(), pparticle.getSpeed(), count, pparticle.getLocation(false), isLongRange, owner); effect.display(pparticle.getXOff(), pparticle.getYOff(), pparticle.getZOff(), pparticle.getSpeed(), count, pparticle.getLocation(false), isLongRange, owner);
} }
@ -400,14 +439,46 @@ public enum ParticleEffect {
particleSpawner.display(this, spawnMaterial, offsetX, offsetY, offsetZ, speed, amount, center, isLongRange, owner); particleSpawner.display(this, spawnMaterial, offsetX, offsetY, offsetZ, speed, amount, center, isLongRange, owner);
} }
/**
* 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 colorTransition Color transition 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 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(ColorTransition colorTransition, double offsetX, double offsetY, double offsetZ, int amount, Location center, boolean isLongRange, Player owner) {
particleSpawner.display(this, colorTransition, offsetX, offsetY, offsetZ, amount, center, isLongRange, owner);
}
/**
* 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 vibration Vibration 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 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(Vibration vibration, double offsetX, double offsetY, double offsetZ, int amount, Location center, boolean isLongRange, Player owner) {
particleSpawner.display(this, vibration, offsetX, offsetY, offsetZ, amount, center, isLongRange, owner);
}
/** /**
* Represents the property of a particle effect * Represents the property of a particle effect
* <p>
* This class is part of the <b>ParticleEffect Library</b> and follows the
* same usage conditions
*
* @author DarkBlade12
* @since 1.7
*/ */
public enum ParticleProperty { public enum ParticleProperty {
/** /**
@ -417,7 +488,15 @@ public enum ParticleEffect {
/** /**
* The particle effect uses the offsets as color values * The particle effect uses the offsets as color values
*/ */
COLORABLE COLORABLE,
/**
* The particle effect uses two color values to transition between
*/
COLORABLE_TRANSITION,
/**
* The particle effect uses an origin location, destination location, and duration in ticks
*/
VIBRATION
} }
} }

View file

@ -5,9 +5,11 @@ import dev.esophose.playerparticles.manager.LocaleManager;
import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.manager.PermissionManager; import dev.esophose.playerparticles.manager.PermissionManager;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.NoteColor; import dev.esophose.playerparticles.particles.data.NoteColor;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.particles.data.ParticleColor; import dev.esophose.playerparticles.particles.data.ParticleColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.styles.DefaultStyles; import dev.esophose.playerparticles.styles.DefaultStyles;
import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.ParticleUtils; import dev.esophose.playerparticles.util.ParticleUtils;
@ -30,8 +32,10 @@ public class ParticlePair {
private Material blockMaterial; private Material blockMaterial;
private OrdinaryColor color; private OrdinaryColor color;
private NoteColor noteColor; private NoteColor noteColor;
private ColorTransition colorTransition;
private Vibration vibration;
public ParticlePair(UUID ownerUUID, int id, ParticleEffect effect, ParticleStyle style, Material itemMaterial, Material blockMaterial, OrdinaryColor color, NoteColor noteColor) { public ParticlePair(UUID ownerUUID, int id, ParticleEffect effect, ParticleStyle style, Material itemMaterial, Material blockMaterial, OrdinaryColor color, NoteColor noteColor, ColorTransition colorTransition, Vibration vibration) {
this.ownerUUID = ownerUUID; this.ownerUUID = ownerUUID;
this.id = id; this.id = id;
@ -44,6 +48,13 @@ public class ParticlePair {
this.setBlockMaterial(blockMaterial); this.setBlockMaterial(blockMaterial);
this.setColor(color); this.setColor(color);
this.setNoteColor(noteColor); this.setNoteColor(noteColor);
this.setColorTransition(colorTransition);
this.setVibration(vibration);
}
@Deprecated
public ParticlePair(UUID ownerUUID, int id, ParticleEffect effect, ParticleStyle style, Material itemMaterial, Material blockMaterial, OrdinaryColor color, NoteColor noteColor) {
this(ownerUUID, id, effect, style, itemMaterial, blockMaterial, color, noteColor, null, null);
} }
/** /**
@ -58,79 +69,114 @@ public class ParticlePair {
/** /**
* Sets the player's particle effect * Sets the player's particle effect
* *
* @param effect The player's new particle effect * @param effect The player's new particle effect
*/ */
public void setEffect(ParticleEffect effect) { public void setEffect(ParticleEffect effect) {
if (effect == null) if (effect == null) {
this.effect = getDefault().getEffect(); this.effect = getDefault().getEffect();
else } else {
this.effect = effect; this.effect = effect;
}
} }
/** /**
* Sets the player's particle style * Sets the player's particle style
* *
* @param style The player's new particle style * @param style The player's new particle style
*/ */
public void setStyle(ParticleStyle style) { public void setStyle(ParticleStyle style) {
if (style == null) if (style == null) {
this.style = getDefault().getStyle(); this.style = getDefault().getStyle();
else } else {
this.style = style; this.style = style;
}
} }
/** /**
* Sets the player's item material * Sets the player's item material
* *
* @param itemMaterial The player's new item material * @param itemMaterial The player's new item material
*/ */
public void setItemMaterial(Material itemMaterial) { public void setItemMaterial(Material itemMaterial) {
if (itemMaterial == null || itemMaterial.isBlock()) if (itemMaterial == null || itemMaterial.isBlock()) {
this.itemMaterial = getDefault().getItemMaterial(); this.itemMaterial = getDefault().getItemMaterial();
else } else {
this.itemMaterial = itemMaterial; this.itemMaterial = itemMaterial;
}
} }
/** /**
* Sets the player's block material * Sets the player's block material
* *
* @param blockMaterial The player's new block material * @param blockMaterial The player's new block material
*/ */
public void setBlockMaterial(Material blockMaterial) { public void setBlockMaterial(Material blockMaterial) {
if (blockMaterial == null || !blockMaterial.isBlock()) if (blockMaterial == null || !blockMaterial.isBlock()) {
this.blockMaterial = getDefault().getBlockMaterial(); this.blockMaterial = getDefault().getBlockMaterial();
else } else {
this.blockMaterial = blockMaterial; this.blockMaterial = blockMaterial;
}
} }
/** /**
* Sets the player's color data * Sets the player's color data
* *
* @param colorData The player's new color data * @param colorData The player's new color data
*/ */
public void setColor(OrdinaryColor colorData) { public void setColor(OrdinaryColor colorData) {
if (colorData == null) if (colorData == null) {
this.color = getDefault().getColor(); this.color = getDefault().getColor();
else } else {
this.color = colorData; this.color = colorData;
if (this.colorTransition != null)
this.colorTransition = new ColorTransition(this.color, this.colorTransition.getEndColor());
}
} }
/** /**
* Sets the player's note color data * Sets the player's note color data
* *
* @param noteColorData The player's new note color data * @param noteColorData The player's new note color data
*/ */
public void setNoteColor(NoteColor noteColorData) { public void setNoteColor(NoteColor noteColorData) {
if (noteColorData == null) if (noteColorData == null) {
this.noteColor = getDefault().getNoteColor(); this.noteColor = getDefault().getNoteColor();
else } else {
this.noteColor = noteColorData; this.noteColor = noteColorData;
}
}
/**
* Sets the player's color transition data
*
* @param colorTransitionData The player's new color transition data
*/
public void setColorTransition(ColorTransition colorTransitionData) {
if (colorTransitionData == null) {
this.colorTransition = new ColorTransition(this.getColor(), getDefault().getColorTransition().getEndColor());
} else {
this.color = colorTransitionData.getStartColor();
this.colorTransition = colorTransitionData;
}
}
/**
* Sets the player's vibration data
*
* @param vibrationData The player's new vibration data
*/
public void setVibration(Vibration vibrationData) {
if (vibrationData == null) {
this.vibration = getDefault().getVibration();
} else {
this.vibration = vibrationData;
}
} }
/** /**
* Get the UUID of the PPlayer that owns this ParticlePair * Get the UUID of the PPlayer that owns this ParticlePair
* *
* @return The owner's UUID * @return The owner's UUID
*/ */
public UUID getOwnerUniqueId() { public UUID getOwnerUniqueId() {
@ -139,7 +185,7 @@ public class ParticlePair {
/** /**
* Get the id of this particle * Get the id of this particle
* *
* @return The id of this particle * @return The id of this particle
*/ */
public int getId() { public int getId() {
@ -148,7 +194,7 @@ public class ParticlePair {
/** /**
* Get the ParticleEffect that this ParticlePair represents * Get the ParticleEffect that this ParticlePair represents
* *
* @return The effect * @return The effect
*/ */
public ParticleEffect getEffect() { public ParticleEffect getEffect() {
@ -157,7 +203,7 @@ public class ParticlePair {
/** /**
* Get the ParticleStyle that this ParticlePair represents * Get the ParticleStyle that this ParticlePair represents
* *
* @return The style * @return The style
*/ */
public ParticleStyle getStyle() { public ParticleStyle getStyle() {
@ -166,7 +212,7 @@ public class ParticlePair {
/** /**
* Get the item Material this particle uses * Get the item Material this particle uses
* *
* @return The item Material * @return The item Material
*/ */
public Material getItemMaterial() { public Material getItemMaterial() {
@ -175,7 +221,7 @@ public class ParticlePair {
/** /**
* Get the block Material this particle uses * Get the block Material this particle uses
* *
* @return The block Material * @return The block Material
*/ */
public Material getBlockMaterial() { public Material getBlockMaterial() {
@ -184,7 +230,7 @@ public class ParticlePair {
/** /**
* Get the color this particle uses * Get the color this particle uses
* *
* @return The color * @return The color
*/ */
public OrdinaryColor getColor() { public OrdinaryColor getColor() {
@ -193,17 +239,35 @@ public class ParticlePair {
/** /**
* Get the note color this particle uses * Get the note color this particle uses
* *
* @return The note color * @return The note color
*/ */
public NoteColor getNoteColor() { public NoteColor getNoteColor() {
return this.noteColor; return this.noteColor;
} }
/**
* Get the color transition this particle uses
*
* @return The color transition
*/
public ColorTransition getColorTransition() {
return this.colorTransition;
}
/**
* Get the vibration this particle uses
*
* @return The vibration
*/
public Vibration getVibration() {
return this.vibration;
}
/** /**
* Gets the color the current particle effect will spawn with * Gets the color the current particle effect will spawn with
* *
* @return Gets the ParticleColor the current particle effect will spawn with * @return The ParticleColor the current particle effect will spawn with
*/ */
public ParticleColor getSpawnColor() { public ParticleColor getSpawnColor() {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
@ -226,12 +290,45 @@ public class ParticlePair {
} }
} }
} }
return null;
}
/**
* Gets the color transition the current particle effect will spawn with
*
* @return The ColorTransition the current particle effect will spawn with
*/
public ColorTransition getSpawnColorTransition() {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
if (this.effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
OrdinaryColor startColor, endColor;
if (this.colorTransition.getStartColor().equals(OrdinaryColor.RAINBOW)) {
startColor = particleManager.getRainbowParticleColor();
} else if (this.colorTransition.getStartColor().equals(OrdinaryColor.RANDOM)) {
startColor = particleManager.getRandomParticleColor();
} else {
startColor = this.colorTransition.getStartColor();
}
if (this.colorTransition.getEndColor().equals(OrdinaryColor.RAINBOW)) {
endColor = particleManager.getShiftedRainbowParticleColor();
} else if (this.colorTransition.getEndColor().equals(OrdinaryColor.RANDOM)) {
endColor = particleManager.getRandomParticleColor();
} else {
endColor = this.colorTransition.getEndColor();
}
return new ColorTransition(startColor, endColor);
}
return null; return null;
} }
/** /**
* Gets the material the current particle effect will spawn with * Gets the material the current particle effect will spawn with
* *
* @return The Material the current particle effect requires * @return The Material the current particle effect requires
*/ */
public Material getSpawnMaterial() { public Material getSpawnMaterial() {
@ -247,7 +344,7 @@ public class ParticlePair {
/** /**
* Gets the current particle data as a string * Gets the current particle data as a string
* *
* @return The particle data in a human-readable string * @return The particle data in a human-readable string
*/ */
public String getDataString() { public String getDataString() {
@ -270,40 +367,64 @@ public class ParticlePair {
} else if (this.color.equals(OrdinaryColor.RANDOM)) { } else if (this.color.equals(OrdinaryColor.RANDOM)) {
return localeManager.getLocaleMessage("random"); return localeManager.getLocaleMessage("random");
} else { } else {
return ChatColor.RED + "" + this.color.getRed() + " " + ChatColor.GREEN + this.color.getGreen() + " " + ChatColor.AQUA + this.color.getBlue(); return ChatColor.AQUA + "#" + ChatColor.AQUA + ParticleUtils.rgbToHex(this.color.getRed(), this.color.getGreen(), this.color.getBlue());
} }
} }
} else if (this.effect.hasProperty(ParticleProperty.COLORABLE_TRANSITION)) {
String start, end;
if (this.colorTransition.getStartColor().equals(OrdinaryColor.RAINBOW)) {
start = localeManager.getLocaleMessage("rainbow");
} else if (this.colorTransition.getStartColor().equals(OrdinaryColor.RANDOM)) {
start = localeManager.getLocaleMessage("random");
} else {
start = "#" + ChatColor.AQUA + ParticleUtils.rgbToHex(this.colorTransition.getStartColor().getRed(), this.colorTransition.getStartColor().getGreen(), this.colorTransition.getStartColor().getBlue());
}
if (this.colorTransition.getEndColor().equals(OrdinaryColor.RAINBOW)) {
end = localeManager.getLocaleMessage("rainbow");
} else if (this.colorTransition.getEndColor().equals(OrdinaryColor.RANDOM)) {
end = localeManager.getLocaleMessage("random");
} else {
end = "#" + ChatColor.AQUA + ParticleUtils.rgbToHex(this.colorTransition.getEndColor().getRed(), this.colorTransition.getEndColor().getGreen(), this.colorTransition.getEndColor().getBlue());
}
return ChatColor.AQUA + start + " " + ChatColor.AQUA + end;
} else if (this.effect.hasProperty(ParticleProperty.VIBRATION)) {
return String.valueOf(this.vibration.getDuration());
} }
return localeManager.getLocaleMessage("gui-data-none"); return localeManager.getLocaleMessage("gui-data-none");
} }
/** /**
* Gets a copy of this ParticlePair * Gets a copy of this ParticlePair
*/ */
public ParticlePair clone() { public ParticlePair clone() {
return new ParticlePair(this.ownerUUID, this.id, this.effect, this.style, this.itemMaterial, this.blockMaterial, this.color, this.noteColor); return new ParticlePair(this.ownerUUID, this.id, this.effect, this.style, this.itemMaterial, this.blockMaterial, this.color, this.noteColor, this.colorTransition, this.vibration);
} }
/** /**
* Gets a ParticlePair with the default values applied * Gets a ParticlePair with the default values applied
* Used for getting internal default values in the cases that null is specified * Used for getting internal default values in the cases that null is specified
* *
* @return A ParticlePair with default values * @return A ParticlePair with default values
*/ */
private static ParticlePair getDefault() { private static ParticlePair getDefault() {
return new ParticlePair(null, // @formatter:off return new ParticlePair(null,
-1, -1,
ParticleEffect.FLAME, ParticleEffect.FLAME,
DefaultStyles.NORMAL, DefaultStyles.NORMAL,
ParticleUtils.closestMatchWithFallback(true, "IRON_SHOVEL", "IRON_SPADE"), ParticleUtils.closestMatchWithFallback(true, "IRON_SHOVEL", "IRON_SPADE"),
Material.STONE, Material.STONE,
new OrdinaryColor(0, 0, 0), new OrdinaryColor(0, 0, 0),
new NoteColor(0)); // @formatter:on new NoteColor(0),
new ColorTransition(new OrdinaryColor(0, 0, 0), new OrdinaryColor(255, 255, 255)),
new Vibration(20)
);
} }
/** /**
* Gets a ParticlePair for a PPlayer with the default values applied * Gets a ParticlePair for a PPlayer with the default values applied
* *
* @param pplayer The PPlayer that will own this ParticlePair * @param pplayer The PPlayer that will own this ParticlePair
* @return A ParticlePair with default values * @return A ParticlePair with default values
*/ */
@ -320,14 +441,17 @@ public class ParticlePair {
styles = permissionManager.getStylesUserHasPermissionFor(pplayer); styles = permissionManager.getStylesUserHasPermissionFor(pplayer);
} }
return new ParticlePair(pplayer.getUniqueId(), // @formatter:off return new ParticlePair(pplayer.getUniqueId(),
pplayer.getNextActiveParticleId(), pplayer.getNextActiveParticleId(),
effects.stream().findFirst().orElse(ParticleEffect.FLAME), effects.stream().findFirst().orElse(ParticleEffect.FLAME),
styles.stream().findFirst().orElse(DefaultStyles.NORMAL), styles.stream().findFirst().orElse(DefaultStyles.NORMAL),
ParticleUtils.closestMatchWithFallback(true, "IRON_SHOVEL", "IRON_SPADE"), ParticleUtils.closestMatchWithFallback(true, "IRON_SHOVEL", "IRON_SPADE"),
Material.STONE, Material.STONE,
new OrdinaryColor(0, 0, 0), new OrdinaryColor(0, 0, 0),
new NoteColor(0)); // @formatter:on new NoteColor(0),
new ColorTransition(new OrdinaryColor(0, 0, 0), new OrdinaryColor(255, 255, 255)),
new Vibration(20)
);
} }
} }

View file

@ -0,0 +1,20 @@
package dev.esophose.playerparticles.particles.data;
public class ColorTransition {
private final OrdinaryColor startColor, endColor;
public ColorTransition(OrdinaryColor startColor, OrdinaryColor endColor) {
this.startColor = startColor;
this.endColor = endColor;
}
public OrdinaryColor getStartColor() {
return this.startColor;
}
public OrdinaryColor getEndColor() {
return this.endColor;
}
}

View file

@ -2,6 +2,7 @@ package dev.esophose.playerparticles.particles.data;
import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticleEffect;
import java.util.Objects; import java.util.Objects;
import org.bukkit.Color;
/** /**
* Represents the color for effects like {@link ParticleEffect#ENTITY_EFFECT}, * Represents the color for effects like {@link ParticleEffect#ENTITY_EFFECT},
@ -135,4 +136,11 @@ public final class OrdinaryColor extends ParticleColor {
public int hashCode() { public int hashCode() {
return Objects.hash(this.red, this.green, this.blue); return Objects.hash(this.red, this.green, this.blue);
} }
public Color toSpigot() {
if (this == RAINBOW || this == RANDOM)
throw new IllegalStateException("Cannot convert special value to Spigot Color");
return Color.fromRGB(this.red, this.green, this.blue);
}
} }

View file

@ -0,0 +1,15 @@
package dev.esophose.playerparticles.particles.data;
public class Vibration {
private final int duration;
public Vibration(int duration) {
this.duration = duration;
}
public int getDuration() {
return this.duration;
}
}

View file

@ -5,7 +5,9 @@ import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.manager.ParticleManager; import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.ParticleColor; import dev.esophose.playerparticles.particles.data.ParticleColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;
@ -62,6 +64,42 @@ public abstract class ParticleSpawner {
*/ */
public abstract void display(ParticleEffect particleEffect, Material spawnMaterial, double offsetX, double offsetY, double offsetZ, double speed, int amount, Location center, boolean isLongRange, Player owner); public abstract void display(ParticleEffect particleEffect, Material spawnMaterial, double offsetX, double offsetY, double offsetZ, double speed, int amount, Location center, boolean isLongRange, Player owner);
/**
* 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 particleEffect The particle type to display
* @param colorTransition Color transition 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 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 abstract void display(ParticleEffect particleEffect, ColorTransition colorTransition, double offsetX, double offsetY, double offsetZ, int amount, Location center, boolean isLongRange, Player owner);
/**
* 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 particleEffect The particle type to display
* @param vibration Vibration 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 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 abstract void display(ParticleEffect particleEffect, Vibration vibration, double offsetX, double offsetY, double offsetZ, int amount, Location center, boolean isLongRange, Player owner);
/** /**
* Gets a List of Players within the particle display range * Gets a List of Players within the particle display range
* *
@ -70,14 +108,14 @@ public abstract class ParticleSpawner {
* @param owner The player that owns the particles * @param owner The player that owns the particles
* @return A List of Players within the particle display range * @return A List of Players within the particle display range
*/ */
protected List<Player> getPlayersInRange(Location center, boolean isLongRange, Player owner) { public static List<Player> getPlayersInRange(Location center, boolean isLongRange, Player owner) {
List<Player> players = new ArrayList<>(); List<Player> players = new ArrayList<>();
int range = !isLongRange ? Setting.PARTICLE_RENDER_RANGE_PLAYER.getInt() : Setting.PARTICLE_RENDER_RANGE_FIXED_EFFECT.getInt(); int range = !isLongRange ? Setting.PARTICLE_RENDER_RANGE_PLAYER.getInt() : Setting.PARTICLE_RENDER_RANGE_FIXED_EFFECT.getInt();
range *= range; range *= range;
for (PPlayer pplayer : PlayerParticles.getInstance().getManager(ParticleManager.class).getPPlayers()) { for (PPlayer pplayer : PlayerParticles.getInstance().getManager(ParticleManager.class).getPPlayers().values()) {
Player p = pplayer.getPlayer(); Player p = pplayer.getPlayer();
if (!this.canSee(p, owner)) if (!canSee(p, owner))
continue; continue;
if (p != null && pplayer.canSeeParticles() && p.getWorld().equals(center.getWorld()) && center.distanceSquared(p.getLocation()) <= range) if (p != null && pplayer.canSeeParticles() && p.getWorld().equals(center.getWorld()) && center.distanceSquared(p.getLocation()) <= range)
@ -94,7 +132,7 @@ public abstract class ParticleSpawner {
* @param target The target * @param target The target
* @return True if player can see target, otherwise false * @return True if player can see target, otherwise false
*/ */
private boolean canSee(Player player, Player target) { public static boolean canSee(Player player, Player target) {
if (player == null || target == null) if (player == null || target == null)
return true; return true;

View file

@ -2,8 +2,10 @@ package dev.esophose.playerparticles.particles.spawning;
import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.particles.data.ParticleColor; import dev.esophose.playerparticles.particles.data.ParticleColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.particles.spawning.reflective.ReflectionUtils; import dev.esophose.playerparticles.particles.spawning.reflective.ReflectionUtils;
import dev.esophose.playerparticles.particles.spawning.reflective.ReflectionUtils.PackageType; import dev.esophose.playerparticles.particles.spawning.reflective.ReflectionUtils.PackageType;
import dev.esophose.playerparticles.particles.spawning.reflective.ReflectiveParticleEffectMapping; import dev.esophose.playerparticles.particles.spawning.reflective.ReflectiveParticleEffectMapping;
@ -24,7 +26,7 @@ public class ReflectiveParticleSpawner extends ParticleSpawner {
if (particleEffect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) if (particleEffect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA))
throw new ParticleDataException("This particle effect requires additional data"); throw new ParticleDataException("This particle effect requires additional data");
List<Player> players = this.getPlayersInRange(center, isLongRange, owner); List<Player> players = getPlayersInRange(center, isLongRange, owner);
if (players.isEmpty()) if (players.isEmpty())
return; return;
@ -36,11 +38,11 @@ public class ReflectiveParticleSpawner extends ParticleSpawner {
if (!particleEffect.hasProperty(ParticleProperty.COLORABLE)) if (!particleEffect.hasProperty(ParticleProperty.COLORABLE))
throw new ParticleColorException("This particle effect is not colorable"); throw new ParticleColorException("This particle effect is not colorable");
List<Player> players = this.getPlayersInRange(center, isLongRange, owner); List<Player> players = getPlayersInRange(center, isLongRange, owner);
if (players.isEmpty()) if (players.isEmpty())
return; return;
new ParticlePacket(particleEffect, color, true).sendTo(center, this.getPlayersInRange(center, isLongRange, owner)); new ParticlePacket(particleEffect, color, true).sendTo(center, getPlayersInRange(center, isLongRange, owner));
} }
@Override @Override
@ -48,11 +50,21 @@ public class ReflectiveParticleSpawner extends ParticleSpawner {
if (!particleEffect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) if (!particleEffect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA))
throw new ParticleDataException("This particle effect does not require additional data"); throw new ParticleDataException("This particle effect does not require additional data");
List<Player> players = this.getPlayersInRange(center, isLongRange, owner); List<Player> players = getPlayersInRange(center, isLongRange, owner);
if (players.isEmpty()) if (players.isEmpty())
return; return;
new ParticlePacket(particleEffect, offsetX, offsetY, offsetZ, speed, amount, true, spawnMaterial).sendTo(center, this.getPlayersInRange(center, isLongRange, owner)); new ParticlePacket(particleEffect, offsetX, offsetY, offsetZ, speed, amount, true, spawnMaterial).sendTo(center, getPlayersInRange(center, isLongRange, owner));
}
@Override
public void display(ParticleEffect particleEffect, ColorTransition colorTransition, double offsetX, double offsetY, double offsetZ, int amount, Location center, boolean isLongRange, Player owner) {
throw new IllegalStateException("This method is unavailable for legacy versions");
}
@Override
public void display(ParticleEffect particleEffect, Vibration vibration, double offsetX, double offsetY, double offsetZ, int amount, Location center, boolean isLongRange, Player owner) {
throw new IllegalStateException("This method is unavailable for legacy versions");
} }
/** /**

View file

@ -3,10 +3,12 @@ package dev.esophose.playerparticles.particles.spawning;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty; import dev.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.particles.data.ParticleColor; import dev.esophose.playerparticles.particles.data.ParticleColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.util.NMSUtil; import dev.esophose.playerparticles.util.NMSUtil;
import org.bukkit.Color; import dev.esophose.playerparticles.util.VibrationUtil;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Particle.DustOptions; import org.bukkit.Particle.DustOptions;
@ -21,7 +23,7 @@ public class SpigotParticleSpawner extends ParticleSpawner {
if (particleEffect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) if (particleEffect.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA))
throw new ParticleDataException("This particle effect requires additional data"); throw new ParticleDataException("This particle effect requires additional data");
for (Player player : this.getPlayersInRange(center, isLongRange, owner)) for (Player player : getPlayersInRange(center, isLongRange, owner))
player.spawnParticle(particleEffect.getSpigotEnum(), center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed); player.spawnParticle(particleEffect.getSpigotEnum(), center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed);
} }
@ -32,11 +34,11 @@ public class SpigotParticleSpawner extends ParticleSpawner {
if (particleEffect == ParticleEffect.DUST && NMSUtil.getVersionNumber() >= 13) { // DUST uses a special data object for spawning in 1.13+ if (particleEffect == ParticleEffect.DUST && NMSUtil.getVersionNumber() >= 13) { // DUST uses a special data object for spawning in 1.13+
OrdinaryColor dustColor = (OrdinaryColor) color; OrdinaryColor dustColor = (OrdinaryColor) color;
DustOptions dustOptions = new DustOptions(Color.fromRGB(dustColor.getRed(), dustColor.getGreen(), dustColor.getBlue()), Setting.DUST_SIZE.getFloat()); DustOptions dustOptions = new DustOptions(dustColor.toSpigot(), Setting.DUST_SIZE.getFloat());
for (Player player : this.getPlayersInRange(center, isLongRange, owner)) for (Player player : getPlayersInRange(center, isLongRange, owner))
player.spawnParticle(particleEffect.getSpigotEnum(), center.getX(), center.getY(), center.getZ(), 1, 0, 0, 0, 0, dustOptions); player.spawnParticle(particleEffect.getSpigotEnum(), center.getX(), center.getY(), center.getZ(), 1, 0, 0, 0, 0, dustOptions);
} else { } else {
for (Player player : this.getPlayersInRange(center, isLongRange, owner)) { for (Player player : getPlayersInRange(center, isLongRange, owner)) {
// Minecraft clients require that you pass a non-zero value if the Red value should be zero // Minecraft clients require that you pass a non-zero value if the Red value should be zero
player.spawnParticle(particleEffect.getSpigotEnum(), center.getX(), center.getY(), center.getZ(), 0, particleEffect == ParticleEffect.DUST && color.getValueX() == 0 ? Float.MIN_VALUE : color.getValueX(), color.getValueY(), color.getValueZ(), 1); player.spawnParticle(particleEffect.getSpigotEnum(), center.getX(), center.getY(), center.getZ(), 0, particleEffect == ParticleEffect.DUST && color.getValueX() == 0 ? Float.MIN_VALUE : color.getValueX(), color.getValueY(), color.getValueZ(), 1);
} }
@ -58,8 +60,29 @@ public class SpigotParticleSpawner extends ParticleSpawner {
extraData = new MaterialData(spawnMaterial); // Deprecated, only used in versions < 1.13 extraData = new MaterialData(spawnMaterial); // Deprecated, only used in versions < 1.13
} }
for (Player player : this.getPlayersInRange(center, isLongRange, owner)) for (Player player : getPlayersInRange(center, isLongRange, owner))
player.spawnParticle(particleEffect.getSpigotEnum(), center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed, extraData); player.spawnParticle(particleEffect.getSpigotEnum(), center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, speed, extraData);
} }
@Override
public void display(ParticleEffect particleEffect, ColorTransition colorTransition, double offsetX, double offsetY, double offsetZ, int amount, Location center, boolean isLongRange, Player owner) {
if (NMSUtil.getVersionNumber() < 17)
return;
if (!particleEffect.hasProperty(ParticleProperty.COLORABLE_TRANSITION))
throw new ParticleDataException("This particle effect does not require additional data");
org.bukkit.Particle.DustTransition dustTransition = new org.bukkit.Particle.DustTransition(colorTransition.getStartColor().toSpigot(), colorTransition.getEndColor().toSpigot(), Setting.DUST_SIZE.getFloat());
for (Player player : getPlayersInRange(center, isLongRange, owner))
player.spawnParticle(particleEffect.getSpigotEnum(), center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, dustTransition);
}
@Override
public void display(ParticleEffect particleEffect, Vibration vibration, double offsetX, double offsetY, double offsetZ, int amount, Location center, boolean isLongRange, Player owner) {
if (NMSUtil.getVersionNumber() < 17)
return;
VibrationUtil.spawnParticles(particleEffect, vibration, offsetX, offsetY, offsetZ, amount, center, isLongRange, owner);
}
} }

View file

@ -13,6 +13,7 @@ import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.entity.ProjectileLaunchEvent;
@ -84,7 +85,7 @@ public class ParticleStyleArrows extends DefaultParticleStyle implements Listene
* *
* @param event The ProjectileLaunchEvent * @param event The ProjectileLaunchEvent
*/ */
@EventHandler @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onProjectileLaunch(ProjectileLaunchEvent event) { public void onProjectileLaunch(ProjectileLaunchEvent event) {
if (!(event.getEntity().getShooter() instanceof Player)) if (!(event.getEntity().getShooter() instanceof Player))
return; return;

View file

@ -63,7 +63,7 @@ public class ParticleStyleBlockBreak extends DefaultParticleStyle implements Lis
this.particleSpeed = config.getDouble("particle-speed"); this.particleSpeed = config.getDouble("particle-speed");
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);

View file

@ -63,7 +63,7 @@ public class ParticleStyleBlockPlace extends DefaultParticleStyle implements Lis
this.particleSpeed = config.getDouble("particle-speed"); this.particleSpeed = config.getDouble("particle-speed");
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);

View file

@ -59,7 +59,7 @@ public class ParticleStyleCelebration extends DefaultParticleStyle {
this.step = 0; this.step = 0;
Random random = new Random(); Random random = new Random();
for (PPlayer pplayer : particleManager.getPPlayers()) { for (PPlayer pplayer : particleManager.getPPlayers().values()) {
Player player = pplayer.getPlayer(); Player player = pplayer.getPlayer();
if (player != null && (NMSUtil.getVersionNumber() < 8 || player.getGameMode() != GameMode.SPECTATOR) && permissionManager.isWorldEnabled(player.getWorld().getName())) if (player != null && (NMSUtil.getVersionNumber() < 8 || player.getGameMode() != GameMode.SPECTATOR) && permissionManager.isWorldEnabled(player.getWorld().getName()))
for (ParticlePair particle : pplayer.getActiveParticles()) for (ParticlePair particle : pplayer.getActiveParticles())

View file

@ -8,6 +8,10 @@ import dev.esophose.playerparticles.manager.ParticleManager;
import dev.esophose.playerparticles.particles.PParticle; import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -16,11 +20,6 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class ParticleStyleDeath extends DefaultParticleStyle implements Listener { public class ParticleStyleDeath extends DefaultParticleStyle implements Listener {
private String style; private String style;
@ -70,7 +69,7 @@ public class ParticleStyleDeath extends DefaultParticleStyle implements Listener
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onDeath(PlayerDeathEvent event) { public void onDeath(PlayerDeathEvent event) {
final EntityDamageEvent damageEvent = event.getEntity().getLastDamageCause(); final EntityDamageEvent damageEvent = event.getEntity().getLastDamageCause();

View file

@ -5,7 +5,6 @@ import dev.esophose.playerparticles.particles.PParticle;
import dev.esophose.playerparticles.particles.ParticlePair; import dev.esophose.playerparticles.particles.ParticlePair;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;

View file

@ -15,6 +15,7 @@ import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
@ -71,7 +72,7 @@ public class ParticleStyleFishing extends DefaultParticleStyle implements Listen
return false; return false;
} }
@EventHandler @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) { public void onPlayerFish(PlayerFishEvent event) {
// Done through a string switch for 1.9.4 compatibility // Done through a string switch for 1.9.4 compatibility
switch (event.getState().toString()) { switch (event.getState().toString()) {

View file

@ -45,7 +45,7 @@ public class ParticleStyleHurt extends DefaultParticleStyle implements Listener
return Collections.singletonList("CACTUS"); return Collections.singletonList("CACTUS");
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);

View file

@ -70,6 +70,13 @@ public class ParticleStyleInvocation extends DefaultParticleStyle {
case DAMAGE_INDICATOR: case DAMAGE_INDICATOR:
case ENCHANTED_HIT: case ENCHANTED_HIT:
return 2; return 2;
case ELECTRIC_SPARK:
return 3;
case SCRAPE:
return 2.5;
case WAX_OFF:
case WAX_ON:
return 4.5;
case DRAGON_BREATH: case DRAGON_BREATH:
return 0.01; return 0.01;
case ENCHANT: case ENCHANT:

View file

@ -19,6 +19,9 @@ import org.bukkit.event.player.PlayerMoveEvent;
public class ParticleStyleMove extends DefaultParticleStyle implements Listener { public class ParticleStyleMove extends DefaultParticleStyle implements Listener {
private final ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
private final DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
private int multiplier; private int multiplier;
protected ParticleStyleMove() { protected ParticleStyleMove() {
@ -55,19 +58,22 @@ public class ParticleStyleMove extends DefaultParticleStyle implements Listener
this.multiplier = config.getInt("multiplier"); this.multiplier = config.getInt("multiplier");
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) { public void onPlayerMove(PlayerMoveEvent event) {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); Location from = event.getFrom();
Location to = event.getTo();
if (to == null || (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ()))
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
PPlayer pplayer = PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(player.getUniqueId()); PPlayer pplayer = this.dataManager.getPPlayer(player.getUniqueId());
if (pplayer == null) if (pplayer == null)
return; return;
for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.MOVE)) { for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.MOVE)) {
Location loc = player.getLocation().clone(); Location loc = player.getLocation().clone();
loc.setY(loc.getY() + 0.05); loc.setY(loc.getY() + 0.05);
particleManager.displayParticles(pplayer, player.getWorld(), particle, DefaultStyles.MOVE.getParticles(particle, loc), false); this.particleManager.displayParticles(pplayer, player.getWorld(), particle, DefaultStyles.MOVE.getParticles(particle, loc), false);
} }
} }

View file

@ -34,7 +34,7 @@ public class ParticleStyleOutline extends DefaultParticleStyle {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
boolean fixed = false; boolean fixed = false;
for (PPlayer pplayer : particleManager.getPPlayers()) { for (PPlayer pplayer : particleManager.getPPlayers().values()) {
if (!pplayer.getUniqueId().equals(particle.getOwnerUniqueId())) if (!pplayer.getUniqueId().equals(particle.getOwnerUniqueId()))
continue; continue;

View file

@ -50,6 +50,12 @@ public class ParticleStylePulse extends DefaultParticleStyle {
case DAMAGE_INDICATOR: case DAMAGE_INDICATOR:
case ENCHANTED_HIT: case ENCHANTED_HIT:
return 1; return 1;
case ELECTRIC_SPARK:
case SCRAPE:
return 2;
case WAX_OFF:
case WAX_ON:
return 3;
case DRAGON_BREATH: case DRAGON_BREATH:
return 0.01; return 0.01;
case ENCHANT: case ENCHANT:

View file

@ -69,7 +69,7 @@ public class ParticleStyleSwords extends DefaultParticleStyle implements Listene
this.swordNames = config.getStringList("sword-materials"); this.swordNames = config.getStringList("sword-materials");
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityDamageEntity(EntityDamageByEntityEvent event) { public void onEntityDamageEntity(EntityDamageByEntityEvent event) {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);

View file

@ -70,7 +70,7 @@ public class ParticleStyleTeleport extends DefaultParticleStyle implements Liste
this.speed = config.getDouble("speed"); this.speed = config.getDouble("speed");
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) { public void onPlayerTeleport(PlayerTeleportEvent event) {
TeleportCause cause = event.getCause(); TeleportCause cause = event.getCause();
if (cause == TeleportCause.UNKNOWN) if (cause == TeleportCause.UNKNOWN)

View file

@ -18,6 +18,9 @@ import org.bukkit.event.player.PlayerMoveEvent;
public class ParticleStyleTrail extends DefaultParticleStyle implements Listener { public class ParticleStyleTrail extends DefaultParticleStyle implements Listener {
private final ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class);
private final DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
private double offset; private double offset;
private double spread; private double spread;
private double speed; private double speed;
@ -55,19 +58,22 @@ public class ParticleStyleTrail extends DefaultParticleStyle implements Listener
this.speed = config.getDouble("speed"); this.speed = config.getDouble("speed");
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) { public void onPlayerMove(PlayerMoveEvent event) {
ParticleManager particleManager = PlayerParticles.getInstance().getManager(ParticleManager.class); Location from = event.getFrom();
Location to = event.getTo();
if (to == null || (from.getX() == to.getX() && from.getY() == to.getY() && from.getZ() == to.getZ()))
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
PPlayer pplayer = PlayerParticles.getInstance().getManager(DataManager.class).getPPlayer(player.getUniqueId()); PPlayer pplayer = this.dataManager.getPPlayer(player.getUniqueId());
if (pplayer == null) if (pplayer == null)
return; return;
for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.TRAIL)) { for (ParticlePair particle : pplayer.getActiveParticlesForStyle(DefaultStyles.TRAIL)) {
Location loc = player.getLocation().clone(); Location loc = player.getLocation().clone();
loc.setY(loc.getY() + 1); loc.setY(loc.getY() + 1);
particleManager.displayParticles(pplayer, player.getWorld(), particle, DefaultStyles.TRAIL.getParticles(particle, loc), false); this.particleManager.displayParticles(pplayer, player.getWorld(), particle, DefaultStyles.TRAIL.getParticles(particle, loc), false);
} }
} }

View file

@ -47,6 +47,12 @@ public class ParticleStyleWhirl extends DefaultParticleStyle {
case DAMAGE_INDICATOR: case DAMAGE_INDICATOR:
case ENCHANTED_HIT: case ENCHANTED_HIT:
return 1; return 1;
case ELECTRIC_SPARK:
case SCRAPE:
return 2;
case WAX_OFF:
case WAX_ON:
return 3;
case DRAGON_BREATH: case DRAGON_BREATH:
return 0.01; return 0.01;
case ENCHANT: case ENCHANT:

View file

@ -48,6 +48,12 @@ public class ParticleStyleWhirlwind extends DefaultParticleStyle {
case DAMAGE_INDICATOR: case DAMAGE_INDICATOR:
case ENCHANTED_HIT: case ENCHANTED_HIT:
return 1; return 1;
case ELECTRIC_SPARK:
case SCRAPE:
return 2;
case WAX_OFF:
case WAX_ON:
return 3;
case DRAGON_BREATH: case DRAGON_BREATH:
return 0.01; return 0.01;
case ENCHANT: case ENCHANT:

View file

@ -15,7 +15,7 @@ public final class NMSUtil {
public static String getVersion() { public static String getVersion() {
if (cachedVersion == null) { if (cachedVersion == null) {
String name = Bukkit.getServer().getClass().getPackage().getName(); String name = Bukkit.getServer().getClass().getPackage().getName();
cachedVersion = name.substring(name.lastIndexOf('.') + 1) + "."; cachedVersion = name.substring(name.lastIndexOf('.') + 1);
} }
return cachedVersion; return cachedVersion;
} }
@ -28,7 +28,7 @@ public final class NMSUtil {
public static int getVersionNumber() { public static int getVersionNumber() {
if (cachedVersionNumber == -1) { if (cachedVersionNumber == -1) {
String name = getVersion().substring(3); 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; return cachedVersionNumber;
} }

View file

@ -1,14 +1,19 @@
package dev.esophose.playerparticles.util; package dev.esophose.playerparticles.util;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting; import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.lang.WordUtils; import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -19,6 +24,7 @@ public final class ParticleUtils {
public static final Material FALLBACK_MATERIAL; public static final Material FALLBACK_MATERIAL;
public static final List<Material> BLOCK_MATERIALS, ITEM_MATERIALS; public static final List<Material> BLOCK_MATERIALS, ITEM_MATERIALS;
public static final List<String> BLOCK_MATERIALS_STRING, ITEM_MATERIALS_STRING; public static final List<String> BLOCK_MATERIALS_STRING, ITEM_MATERIALS_STRING;
private static Method LivingEntity_getTargetBlock;
static { static {
if (NMSUtil.getVersionNumber() > 7) { if (NMSUtil.getVersionNumber() > 7) {
@ -48,6 +54,14 @@ public final class ParticleUtils {
BLOCK_MATERIALS_STRING = BLOCK_MATERIALS.stream().map(Enum::name).map(String::toLowerCase).collect(Collectors.toList()); BLOCK_MATERIALS_STRING = BLOCK_MATERIALS.stream().map(Enum::name).map(String::toLowerCase).collect(Collectors.toList());
ITEM_MATERIALS_STRING = ITEM_MATERIALS.stream().map(Enum::name).map(String::toLowerCase).collect(Collectors.toList()); ITEM_MATERIALS_STRING = ITEM_MATERIALS.stream().map(Enum::name).map(String::toLowerCase).collect(Collectors.toList());
if (NMSUtil.getVersionNumber() < 8) {
try {
LivingEntity_getTargetBlock = LivingEntity.class.getDeclaredMethod("getTargetBlock", HashSet.class, int.class);
} catch (ReflectiveOperationException e) {
e.printStackTrace();
}
}
} }
private ParticleUtils() { private ParticleUtils() {
@ -137,4 +151,21 @@ public final class ParticleUtils {
&& !player.hasPotionEffect(PotionEffectType.INVISIBILITY)); && !player.hasPotionEffect(PotionEffectType.INVISIBILITY));
} }
public static String rgbToHex(int r, int g, int b) {
return String.format("%02x%02x%02x", r, g, b);
}
public static Block getTargetBlock(Player player) {
if (NMSUtil.getVersionNumber() > 7) {
return player.getTargetBlock((Set<Material>) null, 8); // Need the Set<Material> cast for 1.9 support
} else {
try {
return (Block) LivingEntity_getTargetBlock.invoke(player, null, 8);
} catch (ReflectiveOperationException e) {
e.printStackTrace();
return player.getLocation().getBlock();
}
}
}
} }

View file

@ -0,0 +1,25 @@
package dev.esophose.playerparticles.util;
import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.particles.spawning.ParticleSpawner;
import dev.esophose.playerparticles.particles.spawning.SpigotParticleSpawner;
import org.bukkit.Location;
import org.bukkit.entity.Player;
/**
* For some reason the Classloader absolutely needs this to not be loaded for versions lower than 1.17.
* It really likes complaining about org.bukkit.Vibration$Destination being missing even before it's accessed.
*/
public class VibrationUtil {
public static void spawnParticles(ParticleEffect particleEffect, Vibration vibration, double offsetX, double offsetY, double offsetZ, int amount, Location center, boolean isLongRange, Player owner) {
if (!particleEffect.hasProperty(ParticleEffect.ParticleProperty.VIBRATION))
throw new ParticleSpawner.ParticleDataException("This particle effect does not require additional data");
org.bukkit.Vibration data = new org.bukkit.Vibration(center, new org.bukkit.Vibration.Destination.BlockDestination(center), vibration.getDuration());
for (Player player : SpigotParticleSpawner.getPlayersInRange(center, isLongRange, owner))
player.spawnParticle(particleEffect.getSpigotEnum(), center.getX(), center.getY(), center.getZ(), amount, offsetX, offsetY, offsetZ, data);
}
}

View file

@ -2,9 +2,12 @@ package dev.esophose.playerparticles.util.inputparser;
import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.ParticleEffect; import dev.esophose.playerparticles.particles.ParticleEffect;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.NoteColor; import dev.esophose.playerparticles.particles.data.NoteColor;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.styles.ParticleStyle; import dev.esophose.playerparticles.styles.ParticleStyle;
import dev.esophose.playerparticles.util.inputparser.parsable.ParsableColorTransition;
import dev.esophose.playerparticles.util.inputparser.parsable.ParsableInteger; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableInteger;
import dev.esophose.playerparticles.util.inputparser.parsable.ParsableLocation; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableLocation;
import dev.esophose.playerparticles.util.inputparser.parsable.ParsableMaterial; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableMaterial;
@ -13,6 +16,7 @@ import dev.esophose.playerparticles.util.inputparser.parsable.ParsableOrdinaryCo
import dev.esophose.playerparticles.util.inputparser.parsable.ParsableParticleEffect; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableParticleEffect;
import dev.esophose.playerparticles.util.inputparser.parsable.ParsableParticleStyle; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableParticleStyle;
import dev.esophose.playerparticles.util.inputparser.parsable.ParsableString; import dev.esophose.playerparticles.util.inputparser.parsable.ParsableString;
import dev.esophose.playerparticles.util.inputparser.parsable.ParsableVibration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -32,6 +36,8 @@ public class InputParser {
this.put(Material.class, new ParsableMaterial()); this.put(Material.class, new ParsableMaterial());
this.put(NoteColor.class, new ParsableNoteColor()); this.put(NoteColor.class, new ParsableNoteColor());
this.put(OrdinaryColor.class, new ParsableOrdinaryColor()); this.put(OrdinaryColor.class, new ParsableOrdinaryColor());
this.put(ColorTransition.class, new ParsableColorTransition());
this.put(Vibration.class, new ParsableVibration());
this.put(ParticleEffect.class, new ParsableParticleEffect()); this.put(ParticleEffect.class, new ParsableParticleEffect());
this.put(ParticleStyle.class, new ParsableParticleStyle()); this.put(ParticleStyle.class, new ParsableParticleStyle());
this.put(String.class, new ParsableString()); this.put(String.class, new ParsableString());
@ -72,4 +78,11 @@ public class InputParser {
return !this.input.isEmpty(); return !this.input.isEmpty();
} }
/**
* @return the number of input values remaining
*/
public int numRemaining() {
return this.input.size();
}
} }

View file

@ -0,0 +1,46 @@
package dev.esophose.playerparticles.util.inputparser.parsable;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.data.ColorTransition;
import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.util.inputparser.Parsable;
import java.awt.Color;
import java.util.List;
public class ParsableColorTransition extends Parsable<ColorTransition> {
public ParsableColorTransition() {
super(ColorTransition.class);
}
@Override
public ColorTransition parse(PPlayer pplayer, List<String> inputs) {
OrdinaryColor startColor = this.parseColor(inputs);
OrdinaryColor endColor = this.parseColor(inputs);
return new ColorTransition(startColor, endColor);
}
private OrdinaryColor parseColor(List<String> inputs) {
String input = inputs.remove(0);
// Try hex values first
if (input.startsWith("#")) {
try {
Color color = Color.decode(input);
return new OrdinaryColor(color.getRed(), color.getGreen(), color.getBlue());
} catch (NumberFormatException ignored) { }
}
// Try color names
OrdinaryColor namedColor = ParsableOrdinaryColor.COLOR_NAME_MAP.get(input.toLowerCase());
if (namedColor != null)
return namedColor;
String input2 = inputs.remove(0);
String input3 = inputs.remove(0);
// Use rgb
return new OrdinaryColor(Integer.parseInt(input), Integer.parseInt(input2), Integer.parseInt(input3));
}
}

View file

@ -1,33 +1,17 @@
package dev.esophose.playerparticles.util.inputparser.parsable; package dev.esophose.playerparticles.util.inputparser.parsable;
import dev.esophose.playerparticles.particles.PPlayer; import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.util.NMSUtil; import dev.esophose.playerparticles.util.ParticleUtils;
import dev.esophose.playerparticles.util.inputparser.Parsable; import dev.esophose.playerparticles.util.inputparser.Parsable;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class ParsableLocation extends Parsable<Location> { public class ParsableLocation extends Parsable<Location> {
private static Method LivingEntity_getTargetBlock;
static {
if (NMSUtil.getVersionNumber() < 8) {
try {
LivingEntity_getTargetBlock = LivingEntity.class.getDeclaredMethod("getTargetBlock", HashSet.class, int.class);
} catch (ReflectiveOperationException e) {
e.printStackTrace();
}
}
}
public ParsableLocation() { public ParsableLocation() {
super(Location.class); super(Location.class);
} }
@ -38,17 +22,7 @@ public class ParsableLocation extends Parsable<Location> {
Player player = pplayer.getPlayer(); Player player = pplayer.getPlayer();
if (player != null && input.equalsIgnoreCase("looking")) { if (player != null && input.equalsIgnoreCase("looking")) {
Block targetBlock; Block targetBlock = ParticleUtils.getTargetBlock(player);
if (NMSUtil.getVersionNumber() > 7) {
targetBlock = player.getTargetBlock((Set<Material>) null, 8); // Need the Set<Material> cast for 1.9 support
} else {
try {
targetBlock = (Block) LivingEntity_getTargetBlock.invoke(player, null, 8);
} catch (ReflectiveOperationException e) {
targetBlock = player.getLocation().getBlock();
e.printStackTrace();
}
}
int maxDistanceSqrd = 6 * 6; int maxDistanceSqrd = 6 * 6;
if (targetBlock.getLocation().distanceSquared(player.getLocation()) > maxDistanceSqrd) if (targetBlock.getLocation().distanceSquared(player.getLocation()) > maxDistanceSqrd)

View file

@ -4,17 +4,16 @@ import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.data.OrdinaryColor; import dev.esophose.playerparticles.particles.data.OrdinaryColor;
import dev.esophose.playerparticles.util.inputparser.Parsable; import dev.esophose.playerparticles.util.inputparser.Parsable;
import java.awt.Color; import java.awt.Color;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class ParsableOrdinaryColor extends Parsable<OrdinaryColor> { public class ParsableOrdinaryColor extends Parsable<OrdinaryColor> {
private static Map<String, OrdinaryColor> colorNameMap; public static final Map<String, OrdinaryColor> COLOR_NAME_MAP;
static { static {
colorNameMap = new HashMap<String, OrdinaryColor>() {{ COLOR_NAME_MAP = new HashMap<String, OrdinaryColor>() {{
this.put("red", new OrdinaryColor(255, 0, 0)); this.put("red", new OrdinaryColor(255, 0, 0));
this.put("orange", new OrdinaryColor(255, 140, 0)); this.put("orange", new OrdinaryColor(255, 140, 0));
this.put("yellow", new OrdinaryColor(255, 255, 0)); this.put("yellow", new OrdinaryColor(255, 255, 0));
@ -53,7 +52,7 @@ public class ParsableOrdinaryColor extends Parsable<OrdinaryColor> {
} }
// Try color names // Try color names
OrdinaryColor namedColor = colorNameMap.get(input.toLowerCase()); OrdinaryColor namedColor = COLOR_NAME_MAP.get(input.toLowerCase());
if (namedColor != null) if (namedColor != null)
return namedColor; return namedColor;
@ -63,12 +62,5 @@ public class ParsableOrdinaryColor extends Parsable<OrdinaryColor> {
// Use rgb // Use rgb
return new OrdinaryColor(Integer.parseInt(input), Integer.parseInt(input2), Integer.parseInt(input3)); return new OrdinaryColor(Integer.parseInt(input), Integer.parseInt(input2), Integer.parseInt(input3));
} }
/**
* @return the color String to OrdinaryColor mapping
*/
public static Map<String, OrdinaryColor> getColorNameMap() {
return Collections.unmodifiableMap(colorNameMap);
}
} }

View file

@ -0,0 +1,20 @@
package dev.esophose.playerparticles.util.inputparser.parsable;
import dev.esophose.playerparticles.particles.PPlayer;
import dev.esophose.playerparticles.particles.data.Vibration;
import dev.esophose.playerparticles.util.inputparser.Parsable;
import java.util.List;
public class ParsableVibration extends Parsable<Vibration> {
public ParsableVibration() {
super(Vibration.class);
}
@Override
public Vibration parse(PPlayer pplayer, List<String> inputs) {
String input = inputs.remove(0);
return new Vibration(Math.abs(Integer.parseInt(input)));
}
}