Compare commits

..

No commits in common. "1caef4bb83796914d500b733fc338ed9114d9fe5" and "850284810366c34728fa3d7deb7caf38c3a83451" have entirely different histories.

19 changed files with 449 additions and 371 deletions

View File

@ -1,6 +1,8 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
plugins {
id("java")
id("com.gradleup.shadow") version "9.0.0-beta4"
id("com.github.johnrengelman.shadow") version "7.1.0"
}
group = "com.alttd"
@ -11,7 +13,7 @@ apply<JavaLibraryPlugin>()
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
languageVersion.set(JavaLanguageVersion.of(17))
}
}
@ -25,6 +27,7 @@ tasks {
}
shadowJar {
dependsOn(getByName("relocateJars") as ConfigureShadowRelocation)
archiveFileName.set("${project.name}-${project.version}.jar")
minimize()
configurations = listOf(project.configurations.shadow.get())
@ -33,9 +36,14 @@ tasks {
build {
dependsOn(shadowJar)
}
create<ConfigureShadowRelocation>("relocateJars") {
target = shadowJar.get()
prefix = "${project.name}.lib"
}
}
dependencies {
compileOnly("com.alttd:Galaxy-API:1.21-R0.1-SNAPSHOT")
compileOnly("com.github.LeonMangler:PremiumVanishAPI:2.9.0-4")
compileOnly("com.alttd:Galaxy-API:1.18.2-R0.1-SNAPSHOT")
compileOnly("com.github.LeonMangler:PremiumVanishAPI:2.7.11-2")
}

Binary file not shown.

View File

@ -1,7 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists

282
gradlew vendored
View File

@ -1,7 +1,7 @@
#!/bin/sh
#!/usr/bin/env sh
#
# Copyright © 2015-2021 the original authors.
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -17,99 +17,67 @@
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
MAX_FD="maximum"
warn () {
echo "$*"
} >&2
}
die () {
echo
echo "$*"
echo
exit 1
} >&2
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@ -119,9 +87,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD=$JAVA_HOME/bin/java
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -130,120 +98,88 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=$( cygpath --unix "$JAVACMD" )
JAVACMD=`cygpath --unix "$JAVACMD"`
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

35
gradlew.bat vendored
View File

@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@ -25,8 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@ -41,13 +40,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
if "%ERRORLEVEL%" == "0" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
@ -57,11 +56,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
@ -76,15 +75,13 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal

View File

@ -1,12 +1,14 @@
package com.alttd;
import com.alttd.commands.CommandManager;
import com.alttd.commands.subcommands.CommandReload;
import com.alttd.config.Config;
import com.alttd.config.DatabaseConfig;
import com.alttd.config.ParticleConfig;
import com.alttd.database.Database;
import com.alttd.listeners.*;
import com.alttd.objects.APartType;
import com.alttd.particles.InitParticles;
import com.alttd.util.Logger;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@ -30,6 +32,7 @@ public class AltitudeParticles extends JavaPlugin {
Database.getDatabase().init();
new CommandManager();
registerEvents();
InitParticles.init();
Logger.info("--------------------------------------------------");
Logger.info("Altitude Particles started");
Logger.info("--------------------------------------------------");

View File

@ -7,7 +7,7 @@ public final class Config extends AbstractConfig {
static Config config;
static int version;
public Config() {
super(new File(File.separator + "mnt" + File.separator + "configs" + File.separator + "AltitudeParticles"), "config.yml");
super(new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "AltitudeParticles"), "config.yml");
}
public static void reload() {

View File

@ -8,7 +8,7 @@ public class DatabaseConfig extends AbstractConfig {
static DatabaseConfig config;
public DatabaseConfig() {
super(new File(File.separator + "mnt" + File.separator + "configs"
super(new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs"
+ File.separator + "AltitudeParticles"), "database.yml");
}

View File

@ -1,6 +1,5 @@
package com.alttd.config;
import com.alttd.objects.APartType;
import com.alttd.objects.AParticle;
import com.alttd.objects.Frame;
@ -8,133 +7,105 @@ import com.alttd.objects.ParticleSet;
import com.alttd.storage.ParticleStorage;
import com.alttd.util.Logger;
import com.destroystokyo.paper.ParticleBuilder;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.block.data.BlockData;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HexFormat;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class ParticleConfig {
public class ParticleConfig extends AbstractConfig {
private static final File particlesDir = new File(File.separator + "mnt" + File.separator + "configs"
+ File.separator + "AltitudeParticles" + File.separator + "particles");
private static ParticleConfig instance = null;
private static ParticleConfig getInstance() {
if (instance == null)
instance = new ParticleConfig();
return instance;
}
/**
* Finds all files in particles directory that are valid .json files
* @return all files found
*/
private List<File> getJsonFiles() {
List<File> files = new ArrayList<>();
if (!particlesDir.exists()) {
if (!particlesDir.mkdir())
Logger.warning("Unable to create particles directory");
return files;
}
if (!particlesDir.isDirectory()) {
Logger.warning("Particles directory doesn't exist (it's a file??)");
return files;
}
File[] validFiles = particlesDir.listFiles(file -> file.isFile() && file.canRead() && file.getName().endsWith(".json"));
if (validFiles == null)
return files;
files.addAll(List.of(validFiles));
return files;
}
public ParticleSet loadParticle(JSONObject jsonObject) throws Exception {
String particleName = (String) jsonObject.get("particle_name");
String displayName = (String) jsonObject.get("display_name");
APartType aPartType = APartType.valueOf((String) jsonObject.get("particle_type"));
String lore = (String) jsonObject.get("lore");
ItemStack displayItem = new ItemStack(Material.valueOf((String) jsonObject.get("display_item")));
String permission = (String) jsonObject.get("permission");
String packagePermission = (String) jsonObject.get("package_permission");
int frameDelay = (int) (long) jsonObject.get("frame_delay");
int repeat = (int) (long) jsonObject.get("repeat");
int repeatDelay = (int) (long) jsonObject.get("repeat_delay");
double randomOffset = (double) jsonObject.get("random_offset");
boolean stationary = (boolean) jsonObject.get("stationary");
JSONObject frames = (JSONObject) jsonObject.get("frames");
List<Frame> loadedFrames = new ArrayList<>();
for (Object key : frames.keySet()) {
Object o = frames.get(key);
List<AParticle> aParticleList = new ArrayList<>();
for (Object o1 : ((JSONArray) o)) {
JSONObject pData = (JSONObject) o1;
Particle particleType = Particle.valueOf((String) pData.get("particle_type"));
double x = (double) pData.get("x");
double y = (double) pData.get("y");
double z = (double) pData.get("z");
ParticleBuilder particleBuilder = new ParticleBuilder(particleType);
if (particleType.getDataType().equals(Particle.DustOptions.class)) {
int rgb = HexFormat.fromHexDigits((String) pData.get("color"));
particleBuilder.data(new Particle.DustOptions(Color.fromRGB(rgb), 1));
}
// else if (particleType.getDataType().equals(MaterialData.class)) {
// //TODO implement
// }
else if (particleType.getDataType().equals(BlockData.class)) {
//TODO implement
} else if (particleType.getDataType().equals(Integer.class)) {
//TODO implement
} else if (particleType.getDataType().equals(Float.class)) {
//TODO implement
} else if (particleType.getDataType().equals(Particle.DustTransition.class)) {
//TODO implement
} else if (particleType.getDataType().equals(ItemStack.class)) {
//TODO implement
} else {
double data = (double) pData.get("extra");
particleBuilder.extra(data);
}
aParticleList.add(new AParticle(x, y, z, randomOffset, particleBuilder));
}
loadedFrames.add(new Frame(aParticleList));
}
return new ParticleSet(loadedFrames, displayName, List.of(lore.split("\n")), frameDelay, repeat, repeatDelay, stationary, aPartType, particleName, permission, packagePermission, displayItem);
static ParticleConfig config;
public ParticleConfig() {
super(new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "AltitudeParticles"), "particles.yml");
}
public static void reload() {
ParticleStorage.clear();
ParticleConfig instance = getInstance();
for (File file : instance.getJsonFiles()) {
JSONParser parser = new JSONParser();
try {
Object obj = parser.parse(new FileReader(file));
ParticleSet particleSet = instance.loadParticle((JSONObject) obj);
ParticleStorage.addParticleSet(particleSet.getAPartType(), particleSet);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
} catch (Exception exception) {
exception.printStackTrace();
}
}
config = new ParticleConfig();
//TODO implement
config.readConfig(config.getClass(), null);
}
private static void loadParticles() {
ParticleStorage.clear();
ConfigurationSection particles = config.getConfigurationSection("particles");
if (particles == null) {
Logger.warning("No particles in particles config");
return;
}
for (String key : particles.getKeys(false)) {
ConfigurationSection cs = particles.getConfigurationSection(key);
if (cs == null)
continue;
APartType aPartType;
ParticleSet particleSet;
try {
aPartType = APartType.valueOf(cs.getString("part-type"));
particleSet = new ParticleSet(
getAParticle(cs),
cs.getString("name"),
cs.getStringList("lore"),
cs.getInt("frame-delay"),
cs.getInt("repeat"),
cs.getInt("repeat-delay"),
aPartType,
cs.getString("unique-name"),
cs.getString("permission"),
cs.getString("package-permission"),
new ItemStack(Material.valueOf(cs.getString("material"))));
} catch (Exception e) {//Im lazy rn sorry
e.printStackTrace();
continue;
}
ParticleStorage.addParticleSet(aPartType, particleSet);
}
}
private static List<Frame> getAParticle(ConfigurationSection configurationSection) {
List<Frame> list = new ArrayList<>();
ConfigurationSection frames = configurationSection.getConfigurationSection("frames");
if (frames == null) {
Logger.warning("Unable to find frames for something");
return null;
}
for (String key : frames.getKeys(false)) {
ConfigurationSection cs = frames.getConfigurationSection(key);
if (cs == null) {
Logger.warning("Unable to load particle %", key);
return null;
}
int offset = frames.getInt("offset-range");
List<AParticle> aParticleList = new ArrayList<>();
List<Double> x = Arrays.stream(cs.getString("x").split(", ")).map(Double::valueOf).collect(Collectors.toList());
List<Double> y = Arrays.stream(cs.getString("y").split(", ")).map(Double::valueOf).collect(Collectors.toList());
List<Double> z = Arrays.stream(cs.getString("z").split(", ")).map(Double::valueOf).collect(Collectors.toList());
if (x.size() != y.size() || y.size() != z.size()) {
Logger.warning("Unable to load % xyz is not the same length", key);
}
ParticleBuilder particleBuilder = getParticleBuilder(cs);
for (int i = 0; i < x.size(); i++) {
aParticleList.add(new AParticle(x.get(i), y.get(i), z.get(i), offset, particleBuilder));
}
list.add(new Frame(aParticleList));
}
return list;
}
private static ParticleBuilder getParticleBuilder(ConfigurationSection cs) {
cs.getString("particle");
ConfigurationSection color = cs.getConfigurationSection("color");
ParticleBuilder particle = new ParticleBuilder(Particle.valueOf(cs.getString("particle")));
// Class<?> dataType = particle.particle().getDataType();
// Logger.warning(dataType.getSimpleName());
particle.extra(cs.getDouble("extra"));
if (color != null) {
particle = particle.color(color.getInt("r"), color.getInt("g"), color.getInt("b"));
}
return particle.count(cs.getInt("count", 1));
}
}

View File

@ -33,7 +33,7 @@ public class Queries {
public static void setParticlesActive(UUID uuid, boolean particlesActive) {
String sql = "UPDATE user_settings " +
"SET particles_active = ? " +
"SET particles_active = ?" +
"WHERE uuid = ?";
try {

View File

@ -1,6 +1,5 @@
package com.alttd.frameSpawners;
import com.alttd.AltitudeParticles;
import com.alttd.config.Config;
import com.alttd.objects.Frame;
import com.alttd.util.Logger;
@ -13,37 +12,39 @@ import java.util.List;
public class FrameSpawnerLocation extends BukkitRunnable {
private int amount;
private final long repeatDelay;
private final List<Frame> frames;
private Iterator<Frame> iterator;
private final Location location;
private final float rotation;
private final int frameDelay;
public FrameSpawnerLocation(int amount, List<Frame> frames, int frameDelay, Location location, float rotation) {
public FrameSpawnerLocation(int amount, int repeatDelay, List<Frame> frames, Location location, float rotation) {
this.amount = amount;
this.repeatDelay = (repeatDelay * 1000L) / 20;
this.frames = frames;
this.iterator = frames.iterator();
this.location = location;
this.rotation = rotation;
this.frameDelay = frameDelay;
}
@Override
public void run() {
if (amount == 0){
if (iterator.hasNext())
iterator.next().spawn(location, rotation);
else if (amount != 0) {
iterator = frames.iterator();
if (amount > 0)
amount--;
if (repeatDelay <= 0)
return;
try { //Wait before repeating the frames
Thread.sleep(repeatDelay); //TODO figure out why this isn't working and fix it
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
this.cancel();
if (Config.DEBUG)
Logger.info("Stopped repeating task due to end of frames");
}
new BukkitRunnable() {
@Override
public void run() {
if (!iterator.hasNext())
this.cancel();
iterator.next().spawn(location, rotation);
}
}.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, frameDelay);
iterator = frames.iterator();
if (amount != -1)
amount--;
}
}

View File

@ -1,13 +1,11 @@
package com.alttd.frameSpawners;
import com.alttd.AltitudeParticles;
import com.alttd.config.Config;
import com.alttd.objects.APartType;
import com.alttd.objects.Frame;
import com.alttd.objects.ParticleSet;
import com.alttd.storage.PlayerSettings;
import com.alttd.util.Logger;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@ -17,24 +15,22 @@ import java.util.List;
public class FrameSpawnerPlayer extends BukkitRunnable {
private int amount;
private final long repeatDelay;
private final List<Frame> frames;
private Iterator<Frame> iterator;
private final Player player;
private final PlayerSettings playerSettings;
private final APartType aPartType;
private final String uniqueId;
private final int frameDelay;
private final boolean stationary;
public FrameSpawnerPlayer(int amount, List<Frame> frames, int frameDelay, Player player, PlayerSettings playerSettings, APartType aPartType, String uniqueId, boolean stationary) {
public FrameSpawnerPlayer(int amount, int repeatDelay, List<Frame> frames, Player player, PlayerSettings playerSettings, APartType aPartType, String uniqueId) {
this.amount = amount;
this.repeatDelay = (repeatDelay * 1000L) / 20;
this.frames = frames;
this.iterator = frames.iterator();
this.player = player;
this.playerSettings = playerSettings;
this.aPartType = aPartType;
this.uniqueId = uniqueId;
this.frameDelay = frameDelay;
this.stationary = stationary;
}
@Override
@ -45,8 +41,6 @@ public class FrameSpawnerPlayer extends BukkitRunnable {
Logger.info("Stopped repeating task due to player offline.");
return;
}
Location location = player.getLocation();
float yaw = location.getYaw();
ParticleSet activeParticleSet = playerSettings.getParticles(aPartType);
if (activeParticleSet == null || !activeParticleSet.getParticleId().equalsIgnoreCase(uniqueId) || !playerSettings.hasActiveParticles()) {
this.cancel();
@ -54,27 +48,22 @@ public class FrameSpawnerPlayer extends BukkitRunnable {
Logger.info("Stopped repeating task due to player switching/disabling particles.");
return;
}
if (amount == 0) {
if (iterator.hasNext())
iterator.next().spawn(player.getLocation(), player.getLocation().getYaw());
else if (amount != 0) {
iterator = frames.iterator();
amount--;
if (repeatDelay <= 0)
return;
try { //Wait before repeating the frames
Thread.sleep(repeatDelay); //TODO figure out why this doesn't work and fix it
} catch (InterruptedException e) {
e.printStackTrace();
}
} else {
this.cancel();
if (Config.DEBUG)
Logger.info("Stopped repeating task due to end of frames.");
}
new BukkitRunnable() {
@Override
public void run() {
if (!iterator.hasNext()) {
this.cancel();
return;
}
Frame next = iterator.next();
if (stationary)
next.spawn(location, yaw);
else
next.spawn(player.getLocation(), player.getLocation().getYaw());
}
}.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, frameDelay);
iterator = frames.iterator();
if (amount != -1)
amount--;
}
}

View File

@ -58,7 +58,7 @@ public class ActivateParticleSet implements GUIAction {
meta.getEnchants().forEach((enchantment, integer) -> meta.removeEnchant(enchantment));
item.setItemMeta(meta);
});
itemMeta.addEnchant(Enchantment.INFINITY, 1, true);
itemMeta.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
Queries.addParticle(player.getUniqueId(), particleSet.getAPartType(), particleSet.getParticleId());
enable = true;

View File

@ -49,7 +49,7 @@ public class ChooseParticleGUI extends DefaultGUI {
if (activeParticleSet != null && playerSettings.getParticles(aPartType).equals(particleSet)) {
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.addEnchant(Enchantment.INFINITY, 1, true);
itemMeta.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemStack.setItemMeta(itemMeta);
}

View File

@ -27,9 +27,8 @@ public class ParticleSet {
private final String permission;
private final String packPermission;
private final ItemStack itemStack;
private final boolean stationary;
public ParticleSet(List<Frame> frames, String name, List<String> lore, int frameDelay, int repeat, int repeatDelay, boolean stationary, APartType aPartType, String uniqueId, String permission, String packPermission, ItemStack itemStack) {
public ParticleSet(List<Frame> frames, String name, List<String> lore, int frameDelay, int repeat, int repeatDelay, APartType aPartType, String uniqueId, String permission, String packPermission,ItemStack itemStack) {
MiniMessage miniMessage = MiniMessage.miniMessage();
this.frames = frames;
this.frameDelay = frameDelay;
@ -39,7 +38,6 @@ public class ParticleSet {
this.uniqueId = uniqueId;
this.permission = permission;
this.packPermission = packPermission;
this.stationary = stationary;
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.displayName(miniMessage.deserialize(name));
itemMeta.lore(lore.stream().map(miniMessage::deserialize).collect(Collectors.toList()));
@ -50,8 +48,8 @@ public class ParticleSet {
public void run(Location location, Player player) {
if (tooSoon(player.getUniqueId()) || isVanished(player))
return;
FrameSpawnerLocation frameSpawnerLocation = new FrameSpawnerLocation(repeat, frames, frameDelay, location, player.getLocation().getYaw());
frameSpawnerLocation.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, repeatDelay);
FrameSpawnerLocation frameSpawnerLocation = new FrameSpawnerLocation(repeat, repeatDelay, frames, location, player.getLocation().getYaw());
frameSpawnerLocation.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, frameDelay);
}
public void run(Player player, PlayerSettings playerSettings) {
@ -59,8 +57,8 @@ public class ParticleSet {
return;
if (Config.DEBUG)
Logger.info("Starting particle set % for %.", uniqueId, player.getName());
FrameSpawnerPlayer frameSpawnerPlayer = new FrameSpawnerPlayer(repeat, frames, frameDelay, player, playerSettings, aPartType, uniqueId, stationary);
frameSpawnerPlayer.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, repeatDelay);
FrameSpawnerPlayer frameSpawnerPlayer = new FrameSpawnerPlayer(repeat, repeatDelay, frames, player, playerSettings, aPartType, uniqueId);
frameSpawnerPlayer.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, frameDelay);
}
private boolean isVanished(Player player) {

View File

@ -0,0 +1,53 @@
package com.alttd.particles;
import com.alttd.objects.APartType;
import com.alttd.objects.AParticle;
import com.alttd.objects.Frame;
import com.alttd.objects.ParticleSet;
import com.alttd.storage.ParticleStorage;
import com.destroystokyo.paper.ParticleBuilder;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class Alpha {
// private static final ItemStack itemStack;
//
// static {
// MiniMessage miniMessage = MiniMessage.miniMessage();
// itemStack = new ItemStack(Material.ANVIL);
// ItemMeta itemMeta = itemStack.getItemMeta();
// itemMeta.displayName(miniMessage.deserialize("<gold>Alpha Particles</gold>"));
// itemMeta.lore(List.of(
// miniMessage.deserialize("<dark_aqua>An exclusive particle</dark_aqua>"),
// miniMessage.deserialize("<dark_aqua>set for Alpha testers!</dark_aqua>")));
// itemStack.setItemMeta(itemMeta);
// }
//
// public Alpha() {
// List<Frame> frameList = new ArrayList<>();
//
// frameList.add(new Frame(frameOne()));
//
// ParticleStorage.addParticleSet(APartType.TELEPORT_ARRIVE, new ParticleSet(frameList, 5, 10, 10, APartType.TELEPORT_ARRIVE, "ALPHA_TELEPORT", "apart.particle.alpha", itemStack));
// ParticleStorage.addParticleSet(APartType.CLICK_BLOCK, new ParticleSet(frameList, 5, 10, 10, APartType.CLICK_BLOCK, "ALPHA_CLICK", "apart.particle.alpha", itemStack));
// }
//
//
// public List<AParticle> frameOne() {
// List<AParticle> list = new ArrayList<>();
// double[] xPts = {0.23, 0.21, 0.19, 0.17, 0.15, 0.13, 0.11, 0.09, 0.06, 0.02, -0.03, -0.08, -0.14, -0.19, -0.24, -0.26, -0.28, -0.28, -0.27, -0.25, -0.22, -0.18, -0.13, -0.08, -0.03, 0.00, 0.03, 0.06, 0.09, 0.11, 0.14, 0.15, 0.16, 0.18, 0.22, 0.26, 0.30, 0.32};
// double[] yPts = {0.91, 0.86, 0.81, 0.76, 0.70, 0.63, 0.58, 0.52, 0.47, 0.42, 0.39, 0.38, 0.39, 0.42, 0.47, 0.52, 0.58, 0.63, 0.69, 0.75, 0.81, 0.86, 0.89, 0.90, 0.89, 0.87, 0.83, 0.79, 0.74, 0.69, 0.57, 0.51, 0.46, 0.42, 0.40, 0.40, 0.42, 0.47};
//
// for(int i = 0; i < xPts.length; i++) {
// list.add(new AParticle(xPts[i] * 2, (yPts[i] * 2) + 1.5, 0.5, 0, new ParticleBuilder(Particle.REDSTONE).color(Color.GRAY).count(1)));
// }
// return list;
// }
}

View File

@ -0,0 +1,59 @@
package com.alttd.particles;
import com.alttd.objects.APartType;
import com.alttd.objects.AParticle;
import com.alttd.objects.Frame;
import com.alttd.objects.ParticleSet;
import com.alttd.storage.ParticleStorage;
import com.destroystokyo.paper.ParticleBuilder;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import java.util.ArrayList;
import java.util.List;
public class Cupid {
// private static final ItemStack itemStack;
//
// static {
// MiniMessage miniMessage = MiniMessage.miniMessage();
// itemStack = new ItemStack(Material.PINK_TULIP);
// /*PotionMeta meta = (PotionMeta) itemStack.getItemMeta();
// meta.setBasePotionData(new PotionData(PotionType.REGEN));
// itemStack.setItemMeta(meta);*/
// ItemMeta itemMeta = itemStack.getItemMeta();
// itemMeta.displayName(miniMessage.deserialize("<gold>Cupid Particles</gold>"));
// itemMeta.lore(List.of(
// miniMessage.deserialize("<dark_aqua>No one is immune</dark_aqua>"),
// miniMessage.deserialize("<dark_aqua>to Cupid's arrow...</dark_aqua>")));
// itemStack.setItemMeta(itemMeta);
// }
//
// public Cupid() {
// List<Frame> frameList = new ArrayList<>();
//
// frameList.add(new Frame(frameOne()));
//
// ParticleStorage.addParticleSet(APartType.HEAD, new ParticleSet(frameList, 10, 5, 40, APartType.HEAD, "CUPID_HEAD", "apart.particle.test", itemStack));
// ParticleStorage.addParticleSet(APartType.TELEPORT_ARRIVE, new ParticleSet(frameList, 10, 5, 40, APartType.TELEPORT_ARRIVE, "CUPID_TELEPORT", "apart.particle.test", itemStack));
// ParticleStorage.addParticleSet(APartType.CLICK_BLOCK, new ParticleSet(frameList, 10, 5, 40, APartType.CLICK_BLOCK, "CUPID_CLICK", "apart.particle.test", itemStack));
// }
//
//
// public List<AParticle> frameOne() {
// List<AParticle> list = new ArrayList<>();
//
// list.add(new AParticle((Math.random() * 2) - 1, (Math.random() * 2) - 1, (Math.random() * 2) - 1, 0.5, new ParticleBuilder(Particle.HEART).count(1)));
// list.add(new AParticle((Math.random() * 2) - 1, (Math.random() * 2) - 1, (Math.random() * 2) - 1, 0.5, new ParticleBuilder(Particle.HEART).count(1)));
// list.add(new AParticle((Math.random() * 2) - 1, (Math.random() * 2) - 1, (Math.random() * 2) - 1, 0.5,new ParticleBuilder(Particle.HEART).count(1)));
// return list;
// }
}

View File

@ -0,0 +1,9 @@
package com.alttd.particles;
public class InitParticles {
public static void init() {
// new Test();
// new Alpha();
// new Cupid();
}
}

View File

@ -0,0 +1,56 @@
package com.alttd.particles;
import com.alttd.objects.APartType;
import com.alttd.objects.AParticle;
import com.alttd.objects.Frame;
import com.alttd.objects.ParticleSet;
import com.alttd.storage.ParticleStorage;
import com.destroystokyo.paper.ParticleBuilder;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class Test {
//
// private static final ItemStack itemStack;
//
// static {
// MiniMessage miniMessage = MiniMessage.miniMessage();
// itemStack = new ItemStack(Material.BUCKET);
// ItemMeta itemMeta = itemStack.getItemMeta();
// itemMeta.displayName(miniMessage.deserialize("<gold>TestParticles</gold>"));
// itemMeta.lore(List.of(
// miniMessage.deserialize("<dark_aqua>A particle to test</dark_aqua>"),
// miniMessage.deserialize("<dark_aqua>the functionality of this plugin</dark_aqua>")));
// itemStack.setItemMeta(itemMeta);
// }
//
// public Test() {
// APartType test = APartType.BREAK_PLACE_BLOCK;
// List<Frame> frameList = new ArrayList<>();
// //
// frameList.add(new Frame(frameOne()));
// //....
// ParticleStorage.addParticleSet(test, new ParticleSet(frameList, 5, 5, 0, test, "UNIQUE_NAME_TEST", "apart.particle.test", itemStack));
// ParticleStorage.addParticleSet(APartType.TRAIL, new ParticleSet(frameList, 5, -1, 40, APartType.TRAIL, "UNIQUE_NAME_TEST", "apart.particle.test", itemStack));
// ParticleStorage.addParticleSet(APartType.DEATH, new ParticleSet(frameList, 5, 2, 10, APartType.DEATH, "UNIQUE_NAME_TEST", "apart.particle.test", itemStack));
// ParticleStorage.addParticleSet(APartType.KILL, new ParticleSet(frameList, 5, -1, 10, APartType.KILL, "UNIQUE_NAME_TEST", "apart.particle.test", itemStack));
// ParticleStorage.addParticleSet(APartType.TELEPORT_ARRIVE, new ParticleSet(frameList, 5, 5, 40, APartType.TELEPORT_ARRIVE, "UNIQUE_NAME_TEST", "apart.particle.test", itemStack));
// ParticleStorage.addParticleSet(APartType.CLICK_BLOCK, new ParticleSet(frameList, 5, 5, 40, APartType.CLICK_BLOCK, "UNIQUE_NAME_TEST", "apart.particle.test", itemStack));
// }
//
//
// public List<AParticle> frameOne() {
// List<AParticle> list = new ArrayList<>();
// list.add(new AParticle(0, 2, 0, 0.3, new ParticleBuilder(Particle.TOTEM)));
// list.add(new AParticle(0, 2, 0, 0.3, new ParticleBuilder(Particle.TOTEM)));
// list.add(new AParticle(0, 2, 0, 0.3, new ParticleBuilder(Particle.TOTEM)));
// list.add(new AParticle(0, 2, 0, 0.3, new ParticleBuilder(Particle.TOTEM)));
// return list;
// }
}