Compare commits
2 Commits
42c9530348
...
d7c744c20b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7c744c20b | ||
|
|
26b1e6f46c |
|
|
@ -37,7 +37,7 @@ tasks {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Cosmos
|
// Cosmos
|
||||||
compileOnly("com.alttd.cosmos:cosmos-api:1.21.6-R0.1-SNAPSHOT") {
|
compileOnly("com.alttd.cosmos:cosmos-api:1.21.10-R0.1-SNAPSHOT") {
|
||||||
isChanging = true
|
isChanging = true
|
||||||
}
|
}
|
||||||
// Lombok
|
// Lombok
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,21 @@
|
||||||
|
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"
|
rootProject.name = "AltitudeParticles"
|
||||||
|
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url = uri("https://repo.alttd.com/repository/alttd-snapshot/")
|
||||||
|
credentials {
|
||||||
|
username = nexusUser
|
||||||
|
password = nexusPass
|
||||||
|
}
|
||||||
|
}
|
||||||
maven("https://repo.destro.xyz/snapshots") // Galaxy
|
maven("https://repo.destro.xyz/snapshots") // Galaxy
|
||||||
maven("https://papermc.io/repo/repository/maven-public/") // Paper
|
maven("https://papermc.io/repo/repository/maven-public/") // Paper
|
||||||
maven("https://jitpack.io") //PremiumVanish
|
maven("https://jitpack.io") //PremiumVanish
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import com.alttd.util.Logger;
|
||||||
import com.destroystokyo.paper.ParticleBuilder;
|
import com.destroystokyo.paper.ParticleBuilder;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
|
|
@ -23,9 +24,10 @@ import java.nio.file.*;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
public class ParticleConfig {
|
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"
|
private static final File particlesDir = new File(File.separator + "mnt" + File.separator + "configs"
|
||||||
+ File.separator + "AltitudeParticles" + File.separator + "particles");
|
+ File.separator + "AltitudeParticles" + File.separator + "particles");
|
||||||
private static ParticleConfig instance = null;
|
private static ParticleConfig instance = null;
|
||||||
|
|
@ -50,45 +52,58 @@ public class ParticleConfig {
|
||||||
private List<File> getJsonFiles() {
|
private List<File> getJsonFiles() {
|
||||||
List<File> files = new ArrayList<>();
|
List<File> files = new ArrayList<>();
|
||||||
|
|
||||||
// Ensure particles directory exists
|
|
||||||
if (!ensureParticlesDirectoryExists()) {
|
if (!ensureParticlesDirectoryExists()) {
|
||||||
|
log.debug("Particles directory missing or not creatable: {}", particlesDir.getAbsolutePath());
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.debug("Traversing particles directory: {} (exists={}, isDirectory={})", particlesDir.getAbsolutePath(),
|
||||||
|
particlesDir.exists(), particlesDir.isDirectory());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Files.walkFileTree(particlesDir.toPath(), getJsonFileVistor(files));
|
Files.walkFileTree(particlesDir.toPath(),
|
||||||
|
EnumSet.of(FileVisitOption.FOLLOW_LINKS),
|
||||||
|
ParticleConfig.MAX_DEPTH,
|
||||||
|
getJsonFileVistor(files));
|
||||||
|
|
||||||
} catch (IOException e) {
|
} 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;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileVisitor<? super @NotNull Path> getJsonFileVistor(List<File> files) {
|
private FileVisitor<? super @NotNull Path> getJsonFileVistor(List<File> files) {
|
||||||
return new SimpleFileVisitor<>() {
|
return new SimpleFileVisitor<>() {
|
||||||
private int depth = 0;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull FileVisitResult preVisitDirectory(@NotNull Path dir, @NotNull BasicFileAttributes attrs) {
|
public @NotNull FileVisitResult preVisitDirectory(@NotNull Path dir, @NotNull BasicFileAttributes attrs) {
|
||||||
if (depth > ParticleConfig.MAX_DEPTH) {
|
log.debug("preVisitDirectory: {}", dir.toAbsolutePath());
|
||||||
return FileVisitResult.SKIP_SUBTREE;
|
|
||||||
}
|
|
||||||
depth++;
|
|
||||||
return FileVisitResult.CONTINUE;
|
return FileVisitResult.CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull FileVisitResult visitFile(@NotNull Path file, @NotNull BasicFileAttributes attrs) {
|
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();
|
File physicalFile = file.toFile();
|
||||||
|
log.debug("visitFile: {} (isFile={}, canRead={}, name={})", physicalFile.getAbsolutePath(), physicalFile.isFile(), physicalFile.canRead(), physicalFile.getName());
|
||||||
if (isValidJsonFile(physicalFile)) {
|
if (isValidJsonFile(physicalFile)) {
|
||||||
|
log.debug("Found JSON file: {}", physicalFile.getAbsolutePath());
|
||||||
files.add(physicalFile);
|
files.add(physicalFile);
|
||||||
|
} else {
|
||||||
|
log.debug("Ignoring non-json or unreadable file: {}", physicalFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
return FileVisitResult.CONTINUE;
|
return FileVisitResult.CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull FileVisitResult postVisitDirectory(@NotNull Path dir, IOException exc) {
|
public @NotNull FileVisitResult postVisitDirectory(@NotNull Path dir, IOException exc) {
|
||||||
depth--;
|
log.debug("postVisitDirectory: {}", dir.toAbsolutePath());
|
||||||
return FileVisitResult.CONTINUE;
|
return FileVisitResult.CONTINUE;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -101,15 +116,17 @@ public class ParticleConfig {
|
||||||
*/
|
*/
|
||||||
private boolean ensureParticlesDirectoryExists() {
|
private boolean ensureParticlesDirectoryExists() {
|
||||||
if (!particlesDir.exists()) {
|
if (!particlesDir.exists()) {
|
||||||
|
log.info("Particles directory does not exist, attempting to create: {}", particlesDir.getAbsolutePath());
|
||||||
if (!particlesDir.mkdirs()) {
|
if (!particlesDir.mkdirs()) {
|
||||||
Logger.warning("Unable to create particles directory");
|
Logger.warning("Unable to create particles directory at {}", particlesDir.getAbsolutePath());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
log.info("Created particles directory at {}", particlesDir.getAbsolutePath());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!particlesDir.isDirectory()) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -218,6 +235,7 @@ public class ParticleConfig {
|
||||||
public static void reload() {
|
public static void reload() {
|
||||||
ParticleStorage.clear();
|
ParticleStorage.clear();
|
||||||
instance = getInstance();
|
instance = getInstance();
|
||||||
|
log.info("Reloading particles...");
|
||||||
|
|
||||||
for (File file : instance.getJsonFiles()) {
|
for (File file : instance.getJsonFiles()) {
|
||||||
loadParticleFromFile(file);
|
loadParticleFromFile(file);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user