Compare commits
12
Commits
42c9530348
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4bd7b6a2cd | ||
|
|
9a775b2702 | ||
|
|
e65b4759b4 | ||
|
|
f4320de479 | ||
|
|
b60df9dc8d | ||
|
|
f6ee8eacf5 | ||
|
|
caebd1fed3 | ||
|
|
26cb4474c4 | ||
|
|
e2ab17fb20 | ||
|
|
5425b89b2b | ||
|
|
d7c744c20b | ||
|
|
26b1e6f46c |
Vendored
+7
-1
@@ -3,7 +3,13 @@ pipeline {
|
||||
stages {
|
||||
stage('Gradle') {
|
||||
steps {
|
||||
sh 'bash gradlew shadowJar'
|
||||
withCredentials([usernamePassword(credentialsId: 'alttd-snapshot-user', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
|
||||
sh '''
|
||||
set +x
|
||||
chmod +x gradlew
|
||||
./gradlew build -PalttdSnapshotUsername=$USERNAME -PalttdSnapshotPassword=$PASSWORD
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archive') {
|
||||
|
||||
+7
-14
@@ -1,20 +1,14 @@
|
||||
plugins {
|
||||
id("java")
|
||||
id("com.gradleup.shadow") version "9.0.0-beta4"
|
||||
id("com.gradleup.shadow") version "9.6.1"
|
||||
}
|
||||
|
||||
group = "com.alttd"
|
||||
version = "1.0.0-SNAPSHOT"
|
||||
version = System.getenv("BUILD_NUMBER") ?: "1.0.0-SNAPSHOT"
|
||||
description = "Altitude Particles plugin."
|
||||
|
||||
apply<JavaLibraryPlugin>()
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<JavaCompile> {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
@@ -25,7 +19,8 @@ tasks {
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveFileName.set("${project.name}-${project.version}.jar")
|
||||
// archiveFileName.set("${project.name}-${project.version}.jar")
|
||||
archiveFileName.set("${project.name}.jar")
|
||||
minimize()
|
||||
configurations = listOf(project.configurations.shadow.get())
|
||||
}
|
||||
@@ -37,12 +32,10 @@ tasks {
|
||||
|
||||
dependencies {
|
||||
// Cosmos
|
||||
compileOnly("com.alttd.cosmos:cosmos-api:1.21.6-R0.1-SNAPSHOT") {
|
||||
isChanging = true
|
||||
}
|
||||
compileOnly("com.alttd.cosmos:cosmos-api:26.2.build.17-stable")
|
||||
// Lombok
|
||||
compileOnly("org.projectlombok:lombok:1.18.32")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.32")
|
||||
compileOnly("org.projectlombok:lombok:1.18.38")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.38")
|
||||
// Premium vanish
|
||||
compileOnly("com.github.LeonMangler:PremiumVanishAPI:2.9.0-4")
|
||||
// Jackson/Dynamic Beans Integration
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+2
-2
@@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
# Copyright © 2015 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.
|
||||
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -55,7 +57,7 @@
|
||||
# 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
|
||||
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/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/.
|
||||
@@ -84,7 +86,7 @@ done
|
||||
# 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_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -112,7 +114,6 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -170,7 +171,6 @@ 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" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
@@ -203,15 +203,14 @@ fi
|
||||
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,
|
||||
# * DEFAULT_JVM_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 \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+3
-2
@@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@@ -68,11 +70,10 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
@@ -1,9 +1,28 @@
|
||||
import org.gradle.kotlin.dsl.maven
|
||||
|
||||
val nexusUser = providers.gradleProperty("alttdSnapshotUsername").orNull ?: System.getenv("NEXUS_USERNAME")
|
||||
val nexusPass = providers.gradleProperty("alttdSnapshotPassword").orNull ?: System.getenv("NEXUS_PASSWORD")
|
||||
|
||||
rootProject.name = "AltitudeParticles"
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
maven {
|
||||
url = uri("https://repo.alttd.com/repository/alttd-snapshot/")
|
||||
credentials {
|
||||
username = nexusUser
|
||||
password = nexusPass
|
||||
}
|
||||
}
|
||||
maven {
|
||||
url = uri("https://repo.alttd.com/repository/alttd/")
|
||||
credentials {
|
||||
username = nexusUser
|
||||
password = nexusPass
|
||||
}
|
||||
}
|
||||
maven("https://repo.destro.xyz/snapshots") // Galaxy
|
||||
maven("https://papermc.io/repo/repository/maven-public/") // Paper
|
||||
maven("https://jitpack.io") //PremiumVanish
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.alttd.util.Logger;
|
||||
import com.destroystokyo.paper.ParticleBuilder;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
@@ -23,9 +24,10 @@ import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
public class ParticleConfig {
|
||||
|
||||
private static final int MAX_DEPTH = 1;
|
||||
private static final int MAX_DEPTH = 2;
|
||||
private static final File particlesDir = new File(File.separator + "mnt" + File.separator + "configs"
|
||||
+ File.separator + "AltitudeParticles" + File.separator + "particles");
|
||||
private static ParticleConfig instance = null;
|
||||
@@ -50,45 +52,58 @@ public class ParticleConfig {
|
||||
private List<File> getJsonFiles() {
|
||||
List<File> files = new ArrayList<>();
|
||||
|
||||
// Ensure particles directory exists
|
||||
if (!ensureParticlesDirectoryExists()) {
|
||||
log.debug("Particles directory missing or not creatable: {}", particlesDir.getAbsolutePath());
|
||||
return files;
|
||||
}
|
||||
|
||||
log.debug("Traversing particles directory: {} (exists={}, isDirectory={})", particlesDir.getAbsolutePath(),
|
||||
particlesDir.exists(), particlesDir.isDirectory());
|
||||
|
||||
try {
|
||||
Files.walkFileTree(particlesDir.toPath(), getJsonFileVistor(files));
|
||||
Files.walkFileTree(particlesDir.toPath(),
|
||||
EnumSet.of(FileVisitOption.FOLLOW_LINKS),
|
||||
ParticleConfig.MAX_DEPTH,
|
||||
getJsonFileVistor(files));
|
||||
|
||||
} catch (IOException e) {
|
||||
Logger.warning("Error while traversing directory: " + e.getMessage());
|
||||
log.error("Error while traversing directory: {}", e.getMessage(), e);
|
||||
}
|
||||
|
||||
log.info("Found {} json files in particles directory", files.size());
|
||||
return files;
|
||||
}
|
||||
|
||||
private FileVisitor<? super @NotNull Path> getJsonFileVistor(List<File> files) {
|
||||
return new SimpleFileVisitor<>() {
|
||||
private int depth = 0;
|
||||
|
||||
@Override
|
||||
public @NotNull FileVisitResult preVisitDirectory(@NotNull Path dir, @NotNull BasicFileAttributes attrs) {
|
||||
if (depth > ParticleConfig.MAX_DEPTH) {
|
||||
return FileVisitResult.SKIP_SUBTREE;
|
||||
}
|
||||
depth++;
|
||||
log.debug("preVisitDirectory: {}", dir.toAbsolutePath());
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull FileVisitResult visitFile(@NotNull Path file, @NotNull BasicFileAttributes attrs) {
|
||||
if (!attrs.isRegularFile()) {
|
||||
log.debug("Skipping non-regular file path: {} (isDirectory={}, isOther={})", file.toAbsolutePath(), attrs.isDirectory(), attrs.isOther());
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
File physicalFile = file.toFile();
|
||||
log.debug("visitFile: {} (isFile={}, canRead={}, name={})", physicalFile.getAbsolutePath(), physicalFile.isFile(), physicalFile.canRead(), physicalFile.getName());
|
||||
if (isValidJsonFile(physicalFile)) {
|
||||
log.debug("Found JSON file: {}", physicalFile.getAbsolutePath());
|
||||
files.add(physicalFile);
|
||||
} else {
|
||||
log.debug("Ignoring non-json or unreadable file: {}", physicalFile.getAbsolutePath());
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull FileVisitResult postVisitDirectory(@NotNull Path dir, IOException exc) {
|
||||
depth--;
|
||||
log.debug("postVisitDirectory: {}", dir.toAbsolutePath());
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
};
|
||||
@@ -101,15 +116,17 @@ public class ParticleConfig {
|
||||
*/
|
||||
private boolean ensureParticlesDirectoryExists() {
|
||||
if (!particlesDir.exists()) {
|
||||
log.info("Particles directory does not exist, attempting to create: {}", particlesDir.getAbsolutePath());
|
||||
if (!particlesDir.mkdirs()) {
|
||||
Logger.warning("Unable to create particles directory");
|
||||
Logger.warning("Unable to create particles directory at {}", particlesDir.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
log.info("Created particles directory at {}", particlesDir.getAbsolutePath());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!particlesDir.isDirectory()) {
|
||||
Logger.warning("Particles path exists but is not a directory: " + particlesDir.getAbsolutePath());
|
||||
Logger.warning("Particles path exists but is not a directory: {}", particlesDir.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -133,6 +150,7 @@ public class ParticleConfig {
|
||||
* @return A ParticleSet created from the ParticleData
|
||||
*/
|
||||
public ParticleSet convertToParticleSet(ParticleData particleData) {
|
||||
log.info("Converting ParticleData to ParticleSet for [{}]", particleData.getParticleName());
|
||||
List<Frame> loadedFrames = new ArrayList<>();
|
||||
double randomOffset = particleData.getRandomOffset();
|
||||
|
||||
@@ -151,41 +169,17 @@ public class ParticleConfig {
|
||||
Class<?> dataType = particleType.getDataType();
|
||||
|
||||
// Handle different particle data types
|
||||
if (dataType.equals(Particle.DustOptions.class)) {
|
||||
if (particleInfo.getColor() != null) {
|
||||
particleBuilder.color(getColor(particleInfo.getColor()),
|
||||
particleInfo.getSize());
|
||||
}
|
||||
} else if (dataType.equals(Particle.DustTransition.class)) {
|
||||
if (particleInfo.getColorGradientEnd() != null) {
|
||||
particleBuilder.colorTransition(getColor(particleInfo.getColor()),
|
||||
getColor(particleInfo.getColorGradientEnd()),
|
||||
particleInfo.getSize());
|
||||
}
|
||||
}
|
||||
else if (dataType.equals(Color.class)) {
|
||||
particleBuilder.color(getColor(particleInfo.getColor()));
|
||||
} else if (dataType.equals(BlockData.class)) {
|
||||
particleBuilder.data(Material.STONE.createBlockData());
|
||||
//TODO implement
|
||||
} else if (dataType.equals(Integer.class)) {
|
||||
particleBuilder.data(1);
|
||||
//TODO implement
|
||||
} else if (dataType.equals(Float.class)) {
|
||||
particleBuilder.data(1f);
|
||||
//TODO implement
|
||||
} else if (dataType.equals(ItemStack.class)) {
|
||||
particleBuilder.data(new ItemStack(Material.STONE));
|
||||
//TODO implement
|
||||
} else if (particleInfo.getExtra() != null) {
|
||||
particleBuilder.extra(particleInfo.getExtra());
|
||||
}
|
||||
setParticleType(particleInfo, dataType, particleBuilder);
|
||||
|
||||
//Add 0.2 to adjust for the player model being 1.6 blocks high
|
||||
aParticleList.add(new AParticle(x, y + 0.2, z, randomOffset, particleBuilder));
|
||||
}
|
||||
|
||||
loadedFrames.add(new Frame(aParticleList));
|
||||
loadedFrames.add(new Frame(entry.getKey(), aParticleList));
|
||||
}
|
||||
|
||||
if (Config.DEBUG) {
|
||||
log.info("Loaded {} frames for [{}]", loadedFrames.size(), particleData.getParticleName());
|
||||
}
|
||||
|
||||
// Create and return the ParticleSet
|
||||
@@ -206,18 +200,66 @@ public class ParticleConfig {
|
||||
);
|
||||
}
|
||||
|
||||
private Color getColor(String hexColor) {
|
||||
int color = HexFormat.fromHexDigits(hexColor);
|
||||
if (hexColor.length() == 6) {
|
||||
return Color.fromARGB(color);
|
||||
} else {
|
||||
return Color.fromRGB(color);
|
||||
private void setParticleType(ParticleInfo particleInfo, Class<?> dataType, ParticleBuilder particleBuilder) {
|
||||
String color = particleInfo.getColor();
|
||||
if (dataType.equals(Particle.DustOptions.class)) {
|
||||
if (color != null) {
|
||||
particleBuilder.color(getColor(color),
|
||||
particleInfo.getSize());
|
||||
log.info("Dust particle color: {} with size: {}", color, particleInfo.getSize());
|
||||
} else {
|
||||
log.error("Dust particle must have a color");
|
||||
}
|
||||
} else if (dataType.equals(Particle.DustTransition.class)) {
|
||||
if (color == null || particleInfo.getColorGradientEnd() != null) {
|
||||
particleBuilder.colorTransition(getColor(color),
|
||||
getColor(particleInfo.getColorGradientEnd()),
|
||||
particleInfo.getSize());
|
||||
log.info("Dust transition particle color start: {} with size: {}", color, particleInfo.getSize());
|
||||
} else {
|
||||
log.error("Dust transition particle must have a color gradient start and end");
|
||||
}
|
||||
}
|
||||
else if (dataType.equals(Color.class)) {
|
||||
particleBuilder.color(getColor(color));
|
||||
} else if (dataType.equals(BlockData.class)) {
|
||||
particleBuilder.data(Material.STONE.createBlockData());
|
||||
log.warn("Block data particles are not yet supported");
|
||||
//TODO implement
|
||||
} else if (dataType.equals(Integer.class)) {
|
||||
particleBuilder.data(1);
|
||||
log.warn("Integer data particles are not yet supported");
|
||||
//TODO implement
|
||||
} else if (dataType.equals(Float.class)) {
|
||||
particleBuilder.data(1f);
|
||||
log.warn("Float data particles are not yet supported");
|
||||
//TODO implement
|
||||
} else if (dataType.equals(ItemStack.class)) {
|
||||
particleBuilder.data(new ItemStack(Material.STONE));
|
||||
log.warn("ItemStack data particles are not yet supported");
|
||||
//TODO implement
|
||||
} else if (particleInfo.getExtra() != null) {
|
||||
particleBuilder.extra(particleInfo.getExtra());
|
||||
} else {
|
||||
log.debug("No relevant data type: {}", dataType.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private Color getColor(String hexColor) {
|
||||
int hexFormatColor = HexFormat.fromHexDigits(hexColor);
|
||||
Color color;
|
||||
if (hexColor.length() == 6) {
|
||||
color = Color.fromRGB(hexFormatColor);
|
||||
} else {
|
||||
color = Color.fromARGB(hexFormatColor);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
ParticleStorage.clear();
|
||||
instance = getInstance();
|
||||
log.info("Reloading particles...");
|
||||
|
||||
for (File file : instance.getJsonFiles()) {
|
||||
loadParticleFromFile(file);
|
||||
|
||||
@@ -7,18 +7,23 @@ import com.alttd.objects.Frame;
|
||||
import com.alttd.objects.ParticleSet;
|
||||
import com.alttd.storage.PlayerSettings;
|
||||
import com.alttd.util.Logger;
|
||||
import com.destroystokyo.paper.ParticleBuilder;
|
||||
import de.myzelyam.api.vanish.VanishAPI;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class FrameSpawnerPlayer extends BukkitRunnable {
|
||||
|
||||
private int amount;
|
||||
private final List<Frame> frames;
|
||||
private Iterator<Frame> iterator;
|
||||
private final Player player;
|
||||
private final PlayerSettings playerSettings;
|
||||
private final APartType aPartType;
|
||||
@@ -28,7 +33,6 @@ public class FrameSpawnerPlayer extends BukkitRunnable {
|
||||
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();
|
||||
this.player = player;
|
||||
this.playerSettings = playerSettings;
|
||||
this.aPartType = aPartType;
|
||||
@@ -42,39 +46,60 @@ public class FrameSpawnerPlayer extends BukkitRunnable {
|
||||
if (!player.isOnline()) {
|
||||
this.cancel();
|
||||
if (Config.DEBUG)
|
||||
Logger.info("Stopped repeating task due to player offline.");
|
||||
log.info("Stopped repeating task due to player offline.");
|
||||
return;
|
||||
}
|
||||
if (isVanished(player)) {
|
||||
log.debug("Player {} is vanished, skipping frame spawn.", player.getName());
|
||||
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();
|
||||
if (Config.DEBUG)
|
||||
Logger.info("Stopped repeating task due to player switching/disabling particles.");
|
||||
return;
|
||||
}
|
||||
if (shouldStopTask(activeParticleSet)) return;
|
||||
if (amount == 0) {
|
||||
this.cancel();
|
||||
if (Config.DEBUG)
|
||||
Logger.info("Stopped repeating task due to end of frames.");
|
||||
log.info("Stopped repeating task due to end of frames.");
|
||||
}
|
||||
final Iterator<Frame> iterator = frames.iterator();
|
||||
if (Config.DEBUG) {
|
||||
log.info("Starting frame spawn for player {}.", player.getName());
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!iterator.hasNext()) {
|
||||
if (!iterator.hasNext() || shouldStopTask(activeParticleSet)) {
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
Frame next = iterator.next();
|
||||
if (stationary)
|
||||
if (Config.DEBUG) {
|
||||
log.info("Spawning frame with {} particles at {} for player {}", next.getKey(), location, player.getName());
|
||||
}
|
||||
if (stationary) {
|
||||
next.spawn(location, yaw);
|
||||
else
|
||||
}
|
||||
else {
|
||||
next.spawn(player.getLocation(), player.getLocation().getYaw());
|
||||
}
|
||||
}
|
||||
}.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, frameDelay);
|
||||
iterator = frames.iterator();
|
||||
if (amount != -1)
|
||||
amount--;
|
||||
}
|
||||
|
||||
private boolean shouldStopTask(ParticleSet activeParticleSet) {
|
||||
if (activeParticleSet == null || !activeParticleSet.getParticleId().equalsIgnoreCase(uniqueId) || !playerSettings.hasActiveParticles()) {
|
||||
this.cancel();
|
||||
if (Config.DEBUG)
|
||||
log.info("Stopped repeating task due to player switching/disabling particles.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isVanished(Player player) {
|
||||
return VanishAPI.isInvisible(player) || player.getGameMode().equals(GameMode.SPECTATOR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ParticleInfo {
|
||||
// For DustOptions
|
||||
|
||||
@JsonProperty(value = "size", defaultValue = "1")
|
||||
private int size;
|
||||
private float size = 1;
|
||||
|
||||
// For other particle types
|
||||
private Double extra;
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
package com.alttd.objects;
|
||||
|
||||
import com.alttd.storage.PlayerSettings;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Frame {
|
||||
List<AParticle> AParticles;
|
||||
@Getter
|
||||
private final String key;
|
||||
private final List<AParticle> aParticles;
|
||||
|
||||
public Frame(List<AParticle> AParticles) {
|
||||
this.AParticles = AParticles;
|
||||
public Frame(String key, List<AParticle> aParticles) {
|
||||
this.key = key;
|
||||
this.aParticles = aParticles;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -22,7 +28,7 @@ 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()));
|
||||
@@ -30,25 +36,31 @@ public class Frame {
|
||||
XZ xz = new XZ(location.getX(), location.getX() + aParticle.x() + offsetX,
|
||||
location.getZ(), location.getZ() + aParticle.z() + offsetZ,
|
||||
rotation);
|
||||
List<Player> receivers = getReceivers(location);
|
||||
tmpLocation.set(
|
||||
xz.getRotatedX(),
|
||||
location.getY() + aParticle.y() + offsetY,
|
||||
xz.getRotatedZ());
|
||||
aParticle.particleBuilder()
|
||||
.location(tmpLocation.set(
|
||||
xz.getRotatedX(),
|
||||
location.getY() + aParticle.y() + offsetY,
|
||||
xz.getRotatedZ()))
|
||||
.receivers(Bukkit.getOnlinePlayers().stream()
|
||||
.filter(player -> {
|
||||
PlayerSettings playerSettings = PlayerSettings.getPlayer(player.getUniqueId());
|
||||
if (playerSettings == null)
|
||||
return false;
|
||||
if (!playerSettings.isSeeingParticles())
|
||||
return false;
|
||||
Location playerLocation = player.getLocation();
|
||||
return location.getWorld().getUID().equals(playerLocation.getWorld().getUID()) && player.getLocation().distance(location) < 100;
|
||||
}).collect(Collectors.toList()))
|
||||
.location(tmpLocation)
|
||||
.receivers(receivers)
|
||||
.spawn();
|
||||
});
|
||||
}
|
||||
|
||||
private static @NotNull List<Player> getReceivers(Location location) {
|
||||
return Bukkit.getOnlinePlayers().stream()
|
||||
.filter(player -> {
|
||||
PlayerSettings playerSettings = PlayerSettings.getPlayer(player.getUniqueId());
|
||||
if (playerSettings == null)
|
||||
return false;
|
||||
if (!playerSettings.isSeeingParticles())
|
||||
return false;
|
||||
Location playerLocation = player.getLocation();
|
||||
return location.getWorld().getUID().equals(playerLocation.getWorld().getUID()) && player.getLocation().distance(location) < 100;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static class XZ {
|
||||
private final double cx, cz; //Coordinates to rotate around
|
||||
private double x, z; //Coordinated to rotate
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.alttd.storage.PlayerSettings;
|
||||
import com.alttd.util.Logger;
|
||||
import de.myzelyam.api.vanish.VanishAPI;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@@ -19,6 +20,7 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
public class ParticleSet {
|
||||
|
||||
private final List<Frame> frames;
|
||||
@@ -53,7 +55,7 @@ public class ParticleSet {
|
||||
}
|
||||
|
||||
public void run(Location location, Player player) {
|
||||
if (tooSoon(player.getUniqueId()) || isVanished(player))
|
||||
if (tooSoon(player.getUniqueId()))
|
||||
return;
|
||||
FrameSpawnerLocation frameSpawnerLocation = new FrameSpawnerLocation(repeat, frames, frameDelay, location, player.getLocation().getYaw());
|
||||
frameSpawnerLocation.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, repeatDelay);
|
||||
@@ -62,20 +64,16 @@ public class ParticleSet {
|
||||
public void run(Player player, PlayerSettings playerSettings) {
|
||||
if (tooSoon(player.getUniqueId()) && !player.hasPermission("apart.bypass-cooldown"))
|
||||
return;
|
||||
if (Config.DEBUG)
|
||||
Logger.info("Starting particle set % for %.", uniqueId, player.getName());
|
||||
if (Config.DEBUG) {
|
||||
log.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);
|
||||
}
|
||||
|
||||
private boolean isVanished(Player player) {
|
||||
return VanishAPI.isInvisible(player) || player.getGameMode().equals(GameMode.SPECTATOR);
|
||||
}
|
||||
|
||||
private boolean tooSoon(UUID uuid) {
|
||||
PlayerSettings ps = PlayerSettings.getPlayer(uuid);
|
||||
if (ps.canRun(aPartType))
|
||||
{
|
||||
if (ps.canRun(aPartType)) {
|
||||
ps.run(aPartType);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ public class ParticleStorage {
|
||||
if (existingParticleSet.isPresent()) {
|
||||
Logger.warning("Overwriting particle set %", particleSet.getParticleId());
|
||||
particleSets.remove(existingParticleSet.get());
|
||||
return;
|
||||
}
|
||||
particleSets.add(particleSet);
|
||||
particles.put(aPartType, particleSets);
|
||||
|
||||
Reference in New Issue
Block a user