Compare commits

..

11 Commits

Author SHA1 Message Date
Teriuihi fa14d001da Code cleanup 2025-06-22 21:45:51 +02:00
Teriuihi c163885345 Switched to cosmos (1.21.6) 2025-06-22 21:33:06 +02:00
Teriuihi 95bb1e90fe Refactor ParticleConfig with Jackson, add ParticleData models, and update dependencies
Replaced JSON-Simple with Jackson for particle configuration parsing. Introduced `ParticleData` and `ParticleInfo` models for structured data. Updated `ParticleConfig` structure for clarity and modularity. Added Jackson and Lombok dependencies in `build.gradle.kts`.
2025-06-22 21:30:14 +02:00
Teriuihi a3b4922b70 Refactor particle spawning logic into utility class.
Moved repetitive particle spawning code into a new `SpawnParticleUtil` class to improve readability and maintainability. Updated event listeners to use the utility, simplifying their implementations while preserving functionality.
2025-03-09 18:48:59 +01:00
Teriuihi 1caef4bb83 Update Gradle and Java versions, refactor, and fix enchantments
Upgraded Gradle to v8.5, updated Java language version to 21, and replaced the Shadow plugin. Deprecated `MaterialData` was removed. Fixed enchantment from ARROW_INFINITE to INFINITY in GUI and particle actions.
2025-01-18 18:13:58 +01:00
Teriuihi 1862288183 Update config file paths
The file paths for DatabaseConfig, ParticleConfig, and Config have been updated. They no longer depend on "user.home" system property, instead they directly point to "/mnt/configs" location. This change is necessary for aligning with the new configuration directories.
2024-07-20 00:19:21 +02:00
Teriuihi e33a9ff5b9 idk what this is sorry me 2024-07-20 00:19:08 +02:00
Teriuihi d416ec80e1 Added a way to load extra data for particles and added a boolean to determine if all frames should spawn at the same location 2022-09-07 22:39:48 +02:00
Teriuihi be97b45833 Fixed frames not properly repeating at the right speed 2022-08-31 05:13:18 +02:00
Teriuihi 77dcd8862c Fixed loading colors incorrectly 2022-08-31 05:12:55 +02:00
Teriuihi 867d436d0a Converted to json for particle storage 2022-08-30 05:19:05 +02:00
39 changed files with 679 additions and 719 deletions

View File

@ -1,8 +1,6 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
plugins {
id("java")
id("com.github.johnrengelman.shadow") version "7.1.0"
id("com.gradleup.shadow") version "9.0.0-beta4"
}
group = "com.alttd"
@ -13,7 +11,7 @@ apply<JavaLibraryPlugin>()
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
languageVersion.set(JavaLanguageVersion.of(21))
}
}
@ -27,7 +25,6 @@ tasks {
}
shadowJar {
dependsOn(getByName("relocateJars") as ConfigureShadowRelocation)
archiveFileName.set("${project.name}-${project.version}.jar")
minimize()
configurations = listOf(project.configurations.shadow.get())
@ -36,14 +33,21 @@ tasks {
build {
dependsOn(shadowJar)
}
create<ConfigureShadowRelocation>("relocateJars") {
target = shadowJar.get()
prefix = "${project.name}.lib"
}
}
dependencies {
compileOnly("com.alttd:Galaxy-API:1.19-R0.1-SNAPSHOT")
compileOnly("com.github.LeonMangler:PremiumVanishAPI:2.7.11-2")
// Cosmos
compileOnly("com.alttd.cosmos:cosmos-api:1.21.6-R0.1-SNAPSHOT") {
isChanging = true
}
// Lombok
compileOnly("org.projectlombok:lombok:1.18.32")
annotationProcessor("org.projectlombok:lombok:1.18.32")
// Premium vanish
compileOnly("com.github.LeonMangler:PremiumVanishAPI:2.9.0-4")
// Jackson/Dynamic Beans Integration
implementation("com.fasterxml.jackson.module:jackson-module-parameter-names:2.15.2")
// Jackson for JSON Parsing
implementation("com.fasterxml.jackson.core:jackson-databind:2.15.2")
implementation("com.fasterxml.jackson.core:jackson-annotations:2.15.2")
}

Binary file not shown.

View File

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

294
gradlew vendored
View File

@ -1,7 +1,7 @@
#!/usr/bin/env sh
#!/bin/sh
#
# Copyright 2015 the original author or authors.
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -17,67 +17,99 @@
#
##############################################################################
##
## Gradle start up script for UN*X
##
#
# 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/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
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
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
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
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"'
# 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
# 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
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@ -87,9 +119,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
@ -98,88 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
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.
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.
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" = "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
# 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" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# 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" ;;
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
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# 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.
# 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"
# 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" )
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
done
fi
# 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' ' '
)" '"$@"'
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,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@ -40,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute
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.
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
goto fail
@ -56,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
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.
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
goto fail
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 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!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
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%
:mainEnd
if "%OS%"=="Windows_NT" endlocal

View File

@ -1,26 +1,22 @@
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 lombok.Getter;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
public class AltitudeParticles extends JavaPlugin {
@Getter
public static AltitudeParticles instance;
public static AltitudeParticles getInstance() {
return instance;
}
@Override
public void onLoad() {
instance = this;
@ -32,7 +28,6 @@ public class AltitudeParticles extends JavaPlugin {
Database.getDatabase().init();
new CommandManager();
registerEvents();
InitParticles.init();
Logger.info("--------------------------------------------------");
Logger.info("Altitude Particles started");
Logger.info("--------------------------------------------------");

View File

@ -6,6 +6,7 @@ import com.alttd.commands.subcommands.CommandHelp;
import com.alttd.commands.subcommands.CommandReload;
import com.alttd.config.Config;
import com.alttd.util.Logger;
import lombok.Getter;
import org.bukkit.command.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -13,8 +14,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
@Getter
public class CommandManager implements CommandExecutor, TabExecutor {
private final List<SubCommand> subCommands;
@ -45,7 +46,7 @@ public class CommandManager implements CommandExecutor, TabExecutor {
subCommand = getSubCommand(args[0]);
if (!commandSender.hasPermission(subCommand.getPermission())) {
commandSender.sendMiniMessage(Config.NO_PERMISSION, null);
commandSender.sendRichMessage(Config.NO_PERMISSION);
return true;
}
@ -61,7 +62,7 @@ public class CommandManager implements CommandExecutor, TabExecutor {
.filter(subCommand -> commandSender.hasPermission(subCommand.getPermission()))
.map(SubCommand::getName)
.filter(name -> args.length == 0 || name.startsWith(args[0]))
.collect(Collectors.toList())
.toList()
);
} else {
SubCommand subCommand = getSubCommand(args[0]);
@ -71,10 +72,6 @@ public class CommandManager implements CommandExecutor, TabExecutor {
return res;
}
public List<SubCommand> getSubCommands() {
return subCommands;
}
private SubCommand getSubCommand(String cmdName) {
return subCommands.stream()
.filter(subCommand -> subCommand.getName().equals(cmdName))

View File

@ -14,7 +14,7 @@ public class CommandGUI extends SubCommand {
@Override
public boolean onCommand(CommandSender commandSender, String[] args) {
if (!(commandSender instanceof Player player)) {
commandSender.sendMiniMessage(Config.NO_CONSOLE, null);
commandSender.sendRichMessage(Config.NO_CONSOLE);
return true;
}
new OpenParticleGUI(player).open(player);

View File

@ -20,11 +20,11 @@ public class CommandHelp extends SubCommand {
@Override
public boolean onCommand(CommandSender commandSender, String[] args) {
commandSender.sendMiniMessage(Config.HELP_MESSAGE_WRAPPER.replaceAll("<commands>", commandManager
commandSender.sendRichMessage(Config.HELP_MESSAGE_WRAPPER.replaceAll("<commands>", commandManager
.getSubCommands().stream()
.filter(subCommand -> commandSender.hasPermission(subCommand.getPermission()))
.map(SubCommand::getHelpMessage)
.collect(Collectors.joining("\n"))), null);
.collect(Collectors.joining("\n"))));
return true;
}

View File

@ -3,8 +3,6 @@ package com.alttd.commands.subcommands;
import com.alttd.AltitudeParticles;
import com.alttd.commands.SubCommand;
import com.alttd.config.Config;
import com.alttd.config.DatabaseConfig;
import com.alttd.config.ParticleConfig;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
@ -15,7 +13,7 @@ public class CommandReload extends SubCommand {
@Override
public boolean onCommand(CommandSender commandSender, String[] args) {
AltitudeParticles.getInstance().reload();
commandSender.sendMiniMessage("<green>Reloaded AltitudeParticles config.</green>", null);
commandSender.sendRichMessage("<green>Reloaded AltitudeParticles config.</green>");
return true;
}

View File

@ -55,7 +55,7 @@ abstract class AbstractConfig {
throw new RuntimeException(ex.getCause());
} catch (Exception ex) {
Logger.severe("Error invoking %.", method.toString());
ex.printStackTrace();
Logger.error("Failed to invoke", ex);
}
}
}
@ -69,7 +69,7 @@ abstract class AbstractConfig {
yaml.save(file);
} catch (IOException ex) {
Logger.severe("Could not save %.", file.toString());
ex.printStackTrace();
Logger.error("Failed to save", ex);
}
}

View File

@ -2,12 +2,13 @@ package com.alttd.config;
import java.io.File;
@SuppressWarnings("unused")
public final class Config extends AbstractConfig {
static Config config;
static int version;
public Config() {
super(new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "AltitudeParticles"), "config.yml");
super(new File(File.separator + "mnt" + File.separator + "configs" + File.separator + "AltitudeParticles"), "config.yml");
}
public static void reload() {

View File

@ -1,14 +1,13 @@
package com.alttd.config;
import com.alttd.database.Database;
import java.io.File;
@SuppressWarnings("unused")
public class DatabaseConfig extends AbstractConfig {
static DatabaseConfig config;
public DatabaseConfig() {
super(new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs"
super(new File(File.separator + "mnt" + File.separator + "configs"
+ File.separator + "AltitudeParticles"), "database.yml");
}

View File

@ -1,111 +1,146 @@
package com.alttd.config;
import com.alttd.objects.APartType;
import com.alttd.models.ParticleData;
import com.alttd.models.ParticleInfo;
import com.alttd.objects.AParticle;
import com.alttd.objects.Frame;
import com.alttd.objects.ParticleSet;
import com.alttd.storage.ParticleStorage;
import com.alttd.util.Logger;
import com.destroystokyo.paper.ParticleBuilder;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HexFormat;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Map;
public class ParticleConfig extends AbstractConfig {
public class ParticleConfig {
static ParticleConfig config;
public ParticleConfig() {
super(new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "AltitudeParticles"), "particles.yml");
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 final ObjectMapper objectMapper = new ObjectMapper();
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;
}
/**
* Converts a ParticleData object to a ParticleSet
* @param particleData The ParticleData object to convert
* @return A ParticleSet created from the ParticleData
*/
public ParticleSet convertToParticleSet(ParticleData particleData) {
List<Frame> loadedFrames = new ArrayList<>();
double randomOffset = particleData.getRandomOffset();
// Process each frame
for (Map.Entry<String, List<ParticleInfo>> entry : particleData.getFrames().entrySet()) {
List<AParticle> aParticleList = new ArrayList<>();
// Process each particle in the frame
for (ParticleInfo particleInfo : entry.getValue()) {
Particle particleType = Particle.valueOf(particleInfo.getParticleType());
double x = particleInfo.getX();
double y = particleInfo.getY();
double z = particleInfo.getZ();
ParticleBuilder particleBuilder = new ParticleBuilder(particleType);
// Handle different particle data types
if (particleType.getDataType().equals(Particle.DustOptions.class) && particleInfo.getColor() != null) {
int rgb = HexFormat.fromHexDigits(particleInfo.getColor());
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 if (particleInfo.getExtra() != null) {
particleBuilder.extra(particleInfo.getExtra());
}
aParticleList.add(new AParticle(x, y, z, randomOffset, particleBuilder));
}
loadedFrames.add(new Frame(aParticleList));
}
// Create and return the ParticleSet
ItemStack displayItem = new ItemStack(Material.valueOf(particleData.getDisplayItem()));
return new ParticleSet(
loadedFrames,
particleData.getDisplayName(),
List.of(particleData.getLore().split("\n")),
particleData.getFrameDelay(),
particleData.getRepeat(),
particleData.getRepeatDelay(),
particleData.isStationary(),
particleData.getAPartType(),
particleData.getParticleName(),
particleData.getPermission(),
particleData.getPackagePermission(),
displayItem
);
}
public static void reload() {
config = new ParticleConfig();
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;
ParticleConfig instance = getInstance();
for (File file : instance.getJsonFiles()) {
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);
}
}
ParticleData particleData = objectMapper.readValue(file, ParticleData.class);
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;
}
ParticleSet particleSet = instance.convertToParticleSet(particleData);
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"));
ParticleStorage.addParticleSet(particleSet.getAPartType(), particleSet);
} catch (IOException e) {
Logger.error("Error reading particle file " + file.getName(), e);
} catch (Exception exception) {
Logger.error("Error processing particle file " + file.getName(), exception);
}
}
return particle.count(cs.getInt("count", 1));
}
}

View File

@ -24,7 +24,7 @@ public class Database {
try {
openConnection();
} catch (SQLException e) {
e.printStackTrace();
Logger.error("Unable to open connection", e);
}
// Tables
@ -48,7 +48,7 @@ public class Database {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
Logger.error("Error while trying to open connection", e);
}
connection = DriverManager.getConnection(
@ -66,7 +66,7 @@ public class Database {
try {
instance.openConnection();
} catch (Exception e) {
e.printStackTrace();
Logger.error("Error while trying to get connection", e);
}
return connection;
@ -74,15 +74,17 @@ public class Database {
private static void createActiveParticlesTable() {
try {
String sql = "CREATE TABLE IF NOT EXISTS active_particles(" +
"uuid VARCHAR(36) NOT NULL, " +
"particle_type VARCHAR(36) NOT NULL, " +
"particle_id VARCHAR(36) NOT NULL, " +
"PRIMARY KEY (uuid, particle_type)" +
")";
String sql = """
CREATE TABLE IF NOT EXISTS active_particles(
uuid VARCHAR(36) NOT NULL,
particle_type VARCHAR(36) NOT NULL,
particle_id VARCHAR(36) NOT NULL,
PRIMARY KEY (uuid, particle_type)
)""";
connection.prepareStatement(sql).executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
Logger.error("Error while trying to create user point table", e);
Logger.severe("Error while trying to create user point table");
Logger.severe("Shutting down AltitudeParticles");
Bukkit.getPluginManager().disablePlugin(AltitudeParticles.getInstance());
@ -91,16 +93,16 @@ public class Database {
private static void createUserSettingsTable() {
try {
String sql = "CREATE TABLE IF NOT EXISTS user_settings(" +
"uuid VARCHAR(36) NOT NULL, " +
"particles_active BIT(1) NOT NULL DEFAULT b'1', " +
"seeing_particles BIT(1) NOT NULL DEFAULT b'1', " +
"PRIMARY KEY (uuid)" +
")";
String sql = """
CREATE TABLE IF NOT EXISTS user_settings(
uuid VARCHAR(36) NOT NULL,
particles_active BIT(1) NOT NULL DEFAULT b'1',
seeing_particles BIT(1) NOT NULL DEFAULT b'1',
PRIMARY KEY (uuid)
)""";
connection.prepareStatement(sql).executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
Logger.severe("Error while trying to create user point table");
Logger.error("Error while trying to create user point table", e);
Logger.severe("Shutting down AltitudeParticles");
Bukkit.getPluginManager().disablePlugin(AltitudeParticles.getInstance());
}

View File

@ -16,44 +16,44 @@ import java.util.UUID;
public class Queries {
public static void setSeeingParticles(UUID uuid, boolean seeingParticles) {
String sql = "UPDATE user_settings " +
"SET seeing_particles = ?" +
"WHERE uuid = ?";
String sql = """
UPDATE user_settings
SET seeing_particles = ?
WHERE uuid = ?""";
try {
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
preparedStatement.setInt(1, seeingParticles ? 1 : 0);
preparedStatement.setString(2, uuid.toString());
preparedStatement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
Logger.error(String.format("unable to set seeing particles for %s", uuid.toString()), e);
}
}
public static void setParticlesActive(UUID uuid, boolean particlesActive) {
String sql = "UPDATE user_settings " +
"SET particles_active = ?" +
"WHERE uuid = ?";
String sql = """
UPDATE user_settings
SET particles_active = ?
WHERE uuid = ?""";
try {
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
preparedStatement.setInt(1, particlesActive ? 1 : 0);
preparedStatement.setString(2, uuid.toString());
preparedStatement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
Logger.error(String.format("unable to set particles for %s", uuid.toString()), e);
}
}
public static void addParticle(UUID uuid, APartType aPartType, String particleId) {
String sql = "INSERT INTO active_particles (uuid, particle_type, particle_id) " +
"VALUES (?, ?, ?) " +
"ON DUPLICATE KEY UPDATE particle_id = ?";
String sql = """
INSERT INTO active_particles (uuid, particle_type, particle_id)
VALUES (?, ?, ?)
ON DUPLICATE KEY UPDATE particle_id = ?""";
try {
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
preparedStatement.setString(1, uuid.toString());
preparedStatement.setString(2, aPartType.getName());
preparedStatement.setString(3, particleId);
@ -61,43 +61,45 @@ public class Queries {
preparedStatement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
Logger.error(String.format("unable to add particle for %s", uuid.toString()), e);
}
}
public static void removeParticle(UUID uuid, APartType aPartType) {
String sql = "DELETE FROM active_particles " +
"WHERE uuid = ? " +
"AND particle_type = ?";
String sql = """
DELETE FROM active_particles
WHERE uuid = ?
AND particle_type = ?""";
try {
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
preparedStatement.setString(1, uuid.toString());
preparedStatement.setString(2, aPartType.getName());
preparedStatement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
Logger.error(String.format("unable to remove particles for %s", uuid.toString()), e);
}
}
public static void clearParticles(UUID uuid) {
String sql = "DELETE FROM active_particles " +
"WHERE uuid = ?";
try {
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
String sql = """
DELETE FROM active_particles
WHERE uuid = ?""";
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
preparedStatement.setString(1, uuid.toString());
preparedStatement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
Logger.error(String.format("unable to clear particles for %s", uuid.toString()), e);
}
}
public static PlayerSettings getPlayerSettings(UUID uuid) {
String sql = "SELECT * FROM user_settings WHERE uuid = ?";
try {
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
String sql = """
SELECT * FROM user_settings
WHERE uuid = ?""";
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
preparedStatement.setString(1, uuid.toString());
ResultSet resultSet = preparedStatement.executeQuery();
@ -109,18 +111,18 @@ public class Queries {
return new PlayerSettings(particlesActive, seeingParticles, uuid, activeParticles);
}
} catch (SQLException e) {
e.printStackTrace();
Logger.error(String.format("unable to get player settings for %s", uuid.toString()), e);
}
return createNewPlayerSettings(uuid);
}
private static HashMap<APartType, ParticleSet> getActiveParticles(UUID uuid) {
HashMap<APartType, ParticleSet> activeParticles = new HashMap<>();
String sql = "SELECT * FROM active_particles " +
"WHERE uuid = ?";
String sql = """
SELECT * FROM active_particles
WHERE uuid = ?""";
try {
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
preparedStatement.setString(1, uuid.toString());
ResultSet resultSet = preparedStatement.executeQuery();
@ -145,19 +147,19 @@ public class Queries {
activeParticles.put(aPartType, first.get());
}
} catch (SQLException e) {
e.printStackTrace();
Logger.error(String.format("unable to get player settings for %s", uuid.toString()), e);
}
return activeParticles;
}
private static PlayerSettings createNewPlayerSettings(UUID uuid) {
String sql = "INSERT INTO user_settings (uuid, particles_active, seeing_particles)" +
"VALUES (?, ?, ?)" +
"ON DUPLICATE KEY UPDATE particles_active = ?, seeing_particles = ?";
String sql = """
INSERT INTO user_settings (uuid, particles_active, seeing_particles)
VALUES (?, ?, ?)
ON DUPLICATE KEY UPDATE particles_active = ?, seeing_particles = ?""";
try {
PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql);
try (PreparedStatement preparedStatement = Database.getConnection().prepareStatement(sql)) {
preparedStatement.setString(1, uuid.toString());
preparedStatement.setInt(2, 1);
preparedStatement.setInt(3, 1);
@ -166,7 +168,7 @@ public class Queries {
preparedStatement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
Logger.error(String.format("unable to get player settings for %s", uuid.toString()), e);
}
return new PlayerSettings(true, true, uuid);

View File

@ -1,5 +1,6 @@
package com.alttd.frameSpawners;
import com.alttd.AltitudeParticles;
import com.alttd.config.Config;
import com.alttd.objects.Frame;
import com.alttd.util.Logger;
@ -16,26 +17,33 @@ public class FrameSpawnerLocation extends BukkitRunnable {
private Iterator<Frame> iterator;
private final Location location;
private final float rotation;
public FrameSpawnerLocation(int amount, List<Frame> frames, Location location, float rotation) {
private final int frameDelay;
public FrameSpawnerLocation(int amount, List<Frame> frames, int frameDelay, Location location, float rotation) {
this.amount = amount;
this.frames = frames;
this.iterator = frames.iterator();
this.location = location;
this.rotation = rotation;
this.frameDelay = frameDelay;
}
@Override
public void run() {
if (iterator.hasNext())
iterator.next().spawn(location, rotation);
else if (amount != 0) {
iterator = frames.iterator();
if (amount > 0)
amount--;
} else {
if (amount == 0){
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,11 +1,13 @@
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;
@ -21,7 +23,9 @@ public class FrameSpawnerPlayer extends BukkitRunnable {
private final PlayerSettings playerSettings;
private final APartType aPartType;
private final String uniqueId;
public FrameSpawnerPlayer(int amount, List<Frame> frames, Player player, PlayerSettings playerSettings, APartType aPartType, 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) {
this.amount = amount;
this.frames = frames;
this.iterator = frames.iterator();
@ -29,6 +33,8 @@ public class FrameSpawnerPlayer extends BukkitRunnable {
this.playerSettings = playerSettings;
this.aPartType = aPartType;
this.uniqueId = uniqueId;
this.frameDelay = frameDelay;
this.stationary = stationary;
}
@Override
@ -39,6 +45,8 @@ 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();
@ -46,15 +54,27 @@ public class FrameSpawnerPlayer extends BukkitRunnable {
Logger.info("Stopped repeating task due to player switching/disabling particles.");
return;
}
if (iterator.hasNext())
iterator.next().spawn(player.getLocation(), player.getLocation().getYaw());
else if (amount != 0) {
iterator = frames.iterator();
amount--;
} else {
if (amount == 0) {
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.ARROW_INFINITE, 1, true);
itemMeta.addEnchant(Enchantment.INFINITY, 1, true);
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
Queries.addParticle(player.getUniqueId(), particleSet.getAPartType(), particleSet.getParticleId());
enable = true;

View File

@ -19,7 +19,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.stream.Collectors;
public class ChooseParticleGUI extends DefaultGUI {
@ -38,7 +37,7 @@ public class ChooseParticleGUI extends DefaultGUI {
super(name);
List<ParticleSet> availableParticles = ParticleStorage.getParticleSets(aPartType).stream()
.filter(particleSet -> player.hasPermission(particleSet.getPackPermission()) || player.hasPermission(particleSet.getPermission()))
.collect(Collectors.toList());
.toList();
PlayerSettings playerSettings = PlayerSettings.getPlayer(player.getUniqueId());
int i = 0;
for (ParticleSet particleSet : availableParticles) {
@ -49,7 +48,7 @@ public class ChooseParticleGUI extends DefaultGUI {
if (activeParticleSet != null && playerSettings.getParticles(aPartType).equals(particleSet)) {
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.addEnchant(Enchantment.ARROW_INFINITE, 1, true);
itemMeta.addEnchant(Enchantment.INFINITY, 1, true);
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemStack.setItemMeta(itemMeta);
}

View File

@ -1,19 +1,12 @@
package com.alttd.listeners;
import com.alttd.AltitudeParticles;
import com.alttd.objects.APartType;
import com.alttd.objects.ParticleSet;
import com.alttd.storage.PlayerSettings;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.UUID;
public class BlockBreakListener implements Listener {
@ -27,21 +20,7 @@ public class BlockBreakListener implements Listener {
public void onBlockBreak(BlockBreakEvent event) {
if (event.isCancelled())
return;
new BukkitRunnable() {
@Override
public void run() {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
if (!playerSettings.hasActiveParticles())
return;
particlesToActivate.forEach(aPartType -> {
ParticleSet particleSet = playerSettings.getParticles(aPartType);
if (particleSet == null)
return;
particleSet.run(event.getBlock().getLocation(), player);
});
}
}.runTaskAsynchronously(AltitudeParticles.getInstance());
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, event.getPlayer(), () ->
event.getBlock().getLocation());
}
}

View File

@ -1,19 +1,12 @@
package com.alttd.listeners;
import com.alttd.AltitudeParticles;
import com.alttd.objects.APartType;
import com.alttd.objects.ParticleSet;
import com.alttd.storage.PlayerSettings;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.UUID;
public class BlockPlaceListener implements Listener {
@ -27,21 +20,7 @@ public class BlockPlaceListener implements Listener {
public void onBlockPlace(BlockPlaceEvent event) {
if (event.isCancelled())
return;
new BukkitRunnable() {
@Override
public void run() {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
if (!playerSettings.hasActiveParticles())
return;
particlesToActivate.forEach(aPartType -> {
ParticleSet particleSet = playerSettings.getParticles(aPartType);
if (particleSet == null)
return;
particleSet.run(event.getBlock().getLocation(), player);
});
}
}.runTaskAsynchronously(AltitudeParticles.getInstance());
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, event.getPlayer(), () ->
event.getBlock().getLocation());
}
}

View File

@ -1,18 +1,13 @@
package com.alttd.listeners;
import com.alttd.AltitudeParticles;
import com.alttd.objects.APartType;
import com.alttd.objects.ParticleSet;
import com.alttd.storage.PlayerSettings;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.UUID;
public class DeathListener implements Listener {
@ -26,21 +21,7 @@ public class DeathListener implements Listener {
public void onDeath(PlayerDeathEvent event) {
if (event.isCancelled())
return;
new BukkitRunnable() {
@Override
public void run() {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
if (!playerSettings.hasActiveParticles())
return;
particlesToActivate.forEach(aPartType -> {
ParticleSet particleSet = playerSettings.getParticles(aPartType);
if (particleSet == null)
return;
particleSet.run(player.getLocation(), player);
});
}
}.runTaskAsynchronously(AltitudeParticles.getInstance());
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, player, player::getLocation);
}
}

View File

@ -1,19 +1,13 @@
package com.alttd.listeners;
import com.alttd.AltitudeParticles;
import com.alttd.objects.APartType;
import com.alttd.objects.ParticleSet;
import com.alttd.storage.PlayerSettings;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.UUID;
public class KillListener implements Listener {
private final List<APartType> particlesToActivate;
@ -29,20 +23,6 @@ public class KillListener implements Listener {
Player player = event.getEntity().getKiller();
if (player == null)
return;
new BukkitRunnable() {
@Override
public void run() {
UUID uuid = player.getUniqueId();
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
if (!playerSettings.hasActiveParticles())
return;
particlesToActivate.forEach(aPartType -> {
ParticleSet particleSet = playerSettings.getParticles(aPartType);
if (particleSet == null)
return;
particleSet.run(event.getEntity().getLocation(), player);
});
}
}.runTaskAsynchronously(AltitudeParticles.getInstance());
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, player, () -> event.getEntity().getLocation());
}
}

View File

@ -8,7 +8,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
public class PlayerQuitListener implements Listener {
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event) {
public void onPlayerLeave(PlayerQuitEvent event) { //TODO particles when a player leaves
PlayerSettings.removePlayer(event.getPlayer().getUniqueId());
}
}

View File

@ -1,9 +1,6 @@
package com.alttd.listeners;
import com.alttd.AltitudeParticles;
import com.alttd.objects.APartType;
import com.alttd.objects.ParticleSet;
import com.alttd.storage.PlayerSettings;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -14,10 +11,8 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.UUID;
public class RightClickListener implements Listener {
@ -38,22 +33,7 @@ public class RightClickListener implements Listener {
Block clickedBlock = event.getClickedBlock();
if (clickedBlock == null)
return;
new BukkitRunnable() {
@Override
public void run() {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
if (!playerSettings.hasActiveParticles())
return;
particlesToActivate.forEach(aPartType -> {
ParticleSet particleSet = playerSettings.getParticles(aPartType);
if (particleSet == null)
return;
particleSet.run(player.getLocation(), player);
});
}
}.runTaskAsynchronously(AltitudeParticles.getInstance());
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, player, player::getLocation);
}
}

View File

@ -0,0 +1,43 @@
package com.alttd.listeners;
import com.alttd.AltitudeParticles;
import com.alttd.objects.APartType;
import com.alttd.objects.ParticleSet;
import com.alttd.storage.PlayerSettings;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.UUID;
public class SpawnParticleUtil {
@FunctionalInterface
public interface LocationConsumer {
Location getLocation();
}
public static void spawnAsyncParticles(List<APartType> particlesToActivate, Player player, LocationConsumer locationConsumer) {
new BukkitRunnable() {
@Override
public void run() {
spawn(particlesToActivate, player, locationConsumer);
}
}.runTaskAsynchronously(AltitudeParticles.getInstance());
}
private static void spawn(List<APartType> particlesToActivate, Player player, LocationConsumer locationConsumer) {
UUID uuid = player.getUniqueId();
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
if (!playerSettings.hasActiveParticles())
return;
particlesToActivate.forEach(aPartType -> {
ParticleSet particleSet = playerSettings.getParticles(aPartType);
if (particleSet == null)
return;
particleSet.run(locationConsumer.getLocation(), player);
});
}
}

View File

@ -1,19 +1,12 @@
package com.alttd.listeners;
import com.alttd.AltitudeParticles;
import com.alttd.objects.APartType;
import com.alttd.objects.ParticleSet;
import com.alttd.storage.PlayerSettings;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.UUID;
public class TeleportArriveListener implements Listener {
private final List<APartType> particlesToActivate;
@ -26,22 +19,7 @@ public class TeleportArriveListener implements Listener {
public void onTeleportArrive(PlayerTeleportEvent event) {
if (event.isCancelled())
return;
new BukkitRunnable() {
@Override
public void run() {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
PlayerSettings playerSettings = PlayerSettings.getPlayer(uuid);
if (!playerSettings.hasActiveParticles())
return;
particlesToActivate.forEach(aPartType -> {
ParticleSet particleSet = playerSettings.getParticles(aPartType);
if (particleSet == null)
return;
particleSet.run(event.getTo(), player);
});
}
}.runTaskAsynchronously(AltitudeParticles.getInstance());
SpawnParticleUtil.spawnAsyncParticles(particlesToActivate, event.getPlayer(), event::getTo);
}
}

View File

@ -0,0 +1,77 @@
package com.alttd.models;
import com.alttd.objects.APartType;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import java.util.Map;
import java.util.List;
/**
* Represents the configuration data for a particle effect, including its name, type, display properties,
* animations, and permissions. This class is primarily used for managing particle data in the context
* of custom particle effects and animations.
* <p>
* Fields:
* - particleName: The unique name of the particle effect, used internally.
* - displayName: The name displayed to the user.
* - particleType: The type of the particle effect, which corresponds to an {@link APartType}.
* - lore: Additional descriptive text associated with the particle effect.
* - displayItem: An item representation for display purposes in order to visually represent the effect.
* - permission: The permission string required for accessing the particle effect.
* - packagePermission: A specific permission string linked to a grouped set of effects.
* - frameDelay: The delay between animation frames, in milliseconds.
* - repeat: The number of times the particle animation should repeat.
* - repeatDelay: The delay between repeat executions, in milliseconds.
* - randomOffset: A random position offset applied to the particle effect for variances.
* - stationary: Determines if the particle effect remains static or follows movement.
* - frames: A map defining animation frames for the particle effect. The key is an identifier, and the
* value is a list of {@link ParticleInfo} objects representing the frame's particle configuration.
* <p>
* Methods:
* - getAPartType(): Converts the particleType string field into an equivalent {@link APartType} enum value.
* This allows for accessing predefined properties of the particle type.
*/
@Setter
@Getter
public class ParticleData {
@JsonProperty("particle_name")
private String particleName;
@JsonProperty("display_name")
private String displayName;
@JsonProperty("particle_type")
private String particleType;
private String lore;
@JsonProperty("display_item")
private String displayItem;
private String permission;
@JsonProperty("package_permission")
private String packagePermission;
@JsonProperty("frame_delay")
private int frameDelay;
private int repeat;
@JsonProperty("repeat_delay")
private int repeatDelay;
@JsonProperty("random_offset")
private double randomOffset;
private boolean stationary;
private Map<String, List<ParticleInfo>> frames;
public APartType getAPartType() {
return APartType.valueOf(particleType);
}
}

View File

@ -0,0 +1,39 @@
package com.alttd.models;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
/**
* Represents information about a particle, including its type, position, and additional properties.
* This class is used to describe the details of individual particles, including support for
* particle-specific attributes such as color and extra data.
* <p>
* Fields:
* - particleType: The type of the particle, as defined by its name or identifier.
* - x, y, z: Coordinates representing the position of the particle in the 3D space.
* - color: A string representing the color of the particle, used primarily for "DustOptions".
* - extra: An additional property used for some specific particle types, allowing for further customization.
* <p>
* The class is annotated for JSON serialization and deserialization using the Jackson library,
* ensuring smooth integration with JSON-based configurations.
* <p>
* This object is used in the context of particle data configurations and animations.
*/
@Setter
@Getter
public class ParticleInfo {
@JsonProperty("particle_type")
private String particleType;
private double x;
private double y;
private double z;
// For DustOptions
private String color;
// For other particle types
private Double extra;
}

View File

@ -1,6 +1,8 @@
package com.alttd.objects;
import com.alttd.config.Config;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@ -15,37 +17,19 @@ public enum APartType { //TODO add description?
CLICK_BLOCK("CLICK_BLOCK", "Right click block", Material.DIAMOND_BLOCK, TimeUnit.SECONDS.toMillis(Config.CLICK_BLOCK_COOL_DOWN), null, true),
TELEPORT_ARRIVE("TELEPORT", "Teleport", Material.DRAGON_EGG, TimeUnit.SECONDS.toMillis(Config.TELEPORT_ARRIVE_COOL_DOWN), null, true);
@Getter
private final String name;
@Getter
private final String displayName;
@Getter
private final Material material;
@Getter
private final long delay;
@Setter
@Getter
private ItemStack itemStack;
private final boolean event;
public String getName() {
return name;
}
public String getDisplayName() {
return displayName;
}
public Material getMaterial() {
return material;
}
public long getDelay() {
return delay;
}
public ItemStack getItemStack() {
return itemStack;
}
public void setItemStack(ItemStack itemStack) {
this.itemStack = itemStack;
}
public boolean hasEvent() {
return event;
}

View File

@ -1,8 +1,6 @@
package com.alttd.objects;
import com.alttd.config.Config;
import com.alttd.storage.PlayerSettings;
import com.alttd.util.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -24,18 +22,18 @@ public class Frame {
*/
public void spawn(Location location, float rotation) {
Location tmpLocation = location.clone();
AParticles.forEach(AParticle -> {
AParticles.forEach(aParticle -> {
ThreadLocalRandom current = ThreadLocalRandom.current();
double offsetX = ((AParticle.offset_range() == 0) ? 0 : current.nextDouble(-AParticle.offset_range(), AParticle.offset_range()));
double offsetZ = ((AParticle.offset_range() == 0) ? 0 : current.nextDouble(-AParticle.offset_range(), AParticle.offset_range()));
double offsetY = ((AParticle.offset_range() == 0) ? 0 : current.nextDouble(-AParticle.offset_range(), AParticle.offset_range()));
XZ xz = new XZ(location.getX(), location.getX() + AParticle.x() + offsetX,
location.getZ(), location.getZ() + AParticle.z() + offsetZ,
double offsetX = ((aParticle.offset_range() == 0) ? 0 : current.nextDouble(-aParticle.offset_range(), aParticle.offset_range()));
double offsetZ = ((aParticle.offset_range() == 0) ? 0 : current.nextDouble(-aParticle.offset_range(), aParticle.offset_range()));
double offsetY = ((aParticle.offset_range() == 0) ? 0 : current.nextDouble(-aParticle.offset_range(), aParticle.offset_range()));
XZ xz = new XZ(location.getX(), location.getX() + aParticle.x() + offsetX,
location.getZ(), location.getZ() + aParticle.z() + offsetZ,
rotation);
AParticle.particleBuilder()
aParticle.particleBuilder()
.location(tmpLocation.set(
xz.getRotatedX(),
location.getY() + AParticle.y() + offsetY,
location.getY() + aParticle.y() + offsetY,
xz.getRotatedZ()))
.receivers(Bukkit.getOnlinePlayers().stream()
.filter(player -> {
@ -51,7 +49,7 @@ public class Frame {
});
}
private class XZ {
private static class XZ {
private final double cx, cz; //Coordinates to rotate around
private double x, z; //Coordinated to rotate

View File

@ -7,6 +7,7 @@ import com.alttd.frameSpawners.FrameSpawnerPlayer;
import com.alttd.storage.PlayerSettings;
import com.alttd.util.Logger;
import de.myzelyam.api.vanish.VanishAPI;
import lombok.Getter;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -22,13 +23,18 @@ public class ParticleSet {
private final List<Frame> frames;
private final int frameDelay, repeat, repeatDelay;
@Getter
private final APartType aPartType;
private final String uniqueId;
@Getter
private final String permission;
@Getter
private final String packPermission;
@Getter
private final ItemStack itemStack;
private final boolean stationary;
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) {
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) {
MiniMessage miniMessage = MiniMessage.miniMessage();
this.frames = frames;
this.frameDelay = frameDelay;
@ -38,6 +44,7 @@ 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()));
@ -48,8 +55,8 @@ public class ParticleSet {
public void run(Location location, Player player) {
if (tooSoon(player.getUniqueId()) || isVanished(player))
return;
FrameSpawnerLocation frameSpawnerLocation = new FrameSpawnerLocation(repeat, frames, location, player.getLocation().getYaw());
frameSpawnerLocation.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), frameDelay, repeatDelay);
FrameSpawnerLocation frameSpawnerLocation = new FrameSpawnerLocation(repeat, frames, frameDelay, location, player.getLocation().getYaw());
frameSpawnerLocation.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, repeatDelay);
}
public void run(Player player, PlayerSettings playerSettings) {
@ -57,8 +64,8 @@ public class ParticleSet {
return;
if (Config.DEBUG)
Logger.info("Starting particle set % for %.", uniqueId, player.getName());
FrameSpawnerPlayer frameSpawnerPlayer = new FrameSpawnerPlayer(repeat, frames, player, playerSettings, aPartType, uniqueId);
frameSpawnerPlayer.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), frameDelay, repeatDelay);
FrameSpawnerPlayer frameSpawnerPlayer = new FrameSpawnerPlayer(repeat, frames, frameDelay, player, playerSettings, aPartType, uniqueId, stationary);
frameSpawnerPlayer.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, repeatDelay);
}
private boolean isVanished(Player player) {
@ -75,22 +82,6 @@ public class ParticleSet {
return true;
}
public APartType getAPartType() {
return aPartType;
}
public String getPermission() {
return permission;
}
public String getPackPermission() {
return packPermission;
}
public ItemStack getItemStack() {
return itemStack;
}
public String getParticleId() {
return uniqueId;
}

View File

@ -1,53 +0,0 @@
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

@ -1,59 +0,0 @@
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

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

View File

@ -1,56 +0,0 @@
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;
// }
}

View File

@ -3,6 +3,7 @@ package com.alttd.storage;
import com.alttd.database.Queries;
import com.alttd.objects.APartType;
import com.alttd.objects.ParticleSet;
import lombok.Getter;
import java.util.Date;
import java.util.HashMap;
@ -12,8 +13,12 @@ public class PlayerSettings {
private static final HashMap<UUID, PlayerSettings> playerSettingsMap = new HashMap<>();
private boolean particlesActive, seeingParticles;
private boolean particlesActive;
@Getter
private boolean seeingParticles;
@Getter
private final UUID uuid;
@Getter
private final HashMap<APartType, ParticleSet> particles;
private final HashMap<APartType, Long> lastUsed;
@ -54,23 +59,11 @@ public class PlayerSettings {
return particlesActive;
}
public boolean isSeeingParticles() {
return seeingParticles;
}
public boolean toggleSeeingParticles() {
seeingParticles = !seeingParticles;
return seeingParticles;
}
public UUID getUuid() {
return uuid;
}
public HashMap<APartType, ParticleSet> getParticles() {
return particles;
}
public void addParticle(APartType aPartType, ParticleSet particleSet) {
particles.put(aPartType, particleSet);
}

View File

@ -2,6 +2,8 @@ package com.alttd.util;
import com.alttd.AltitudeParticles;
import java.util.logging.Level;
public class Logger {
static private final java.util.logging.Logger logger;
@ -33,4 +35,8 @@ public class Logger {
}
logger.severe(severe);
}
public static void error(String error, Throwable throwable) {
logger.log(Level.SEVERE, error, throwable);
}
}