Compare commits
No commits in common. "d7c744c20b4691eb46c30b92ea2c147aac6de504" and "42c9530348d7ef5ff2e1d6293a5cb3d64ddc4a45" have entirely different histories.
d7c744c20b
...
42c9530348
|
|
@ -37,7 +37,7 @@ tasks {
|
|||
|
||||
dependencies {
|
||||
// Cosmos
|
||||
compileOnly("com.alttd.cosmos:cosmos-api:1.21.10-R0.1-SNAPSHOT") {
|
||||
compileOnly("com.alttd.cosmos:cosmos-api:1.21.6-R0.1-SNAPSHOT") {
|
||||
isChanging = true
|
||||
}
|
||||
// Lombok
|
||||
|
|
|
|||
|
|
@ -1,21 +1,9 @@
|
|||
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("https://repo.destro.xyz/snapshots") // Galaxy
|
||||
maven("https://papermc.io/repo/repository/maven-public/") // Paper
|
||||
maven("https://jitpack.io") //PremiumVanish
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ 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;
|
||||
|
|
@ -24,10 +23,9 @@ import java.nio.file.*;
|
|||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
public class ParticleConfig {
|
||||
|
||||
private static final int MAX_DEPTH = 2;
|
||||
private static final int MAX_DEPTH = 1;
|
||||
private static final File particlesDir = new File(File.separator + "mnt" + File.separator + "configs"
|
||||
+ File.separator + "AltitudeParticles" + File.separator + "particles");
|
||||
private static ParticleConfig instance = null;
|
||||
|
|
@ -52,58 +50,45 @@ 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(),
|
||||
EnumSet.of(FileVisitOption.FOLLOW_LINKS),
|
||||
ParticleConfig.MAX_DEPTH,
|
||||
getJsonFileVistor(files));
|
||||
|
||||
Files.walkFileTree(particlesDir.toPath(), getJsonFileVistor(files));
|
||||
} catch (IOException e) {
|
||||
log.error("Error while traversing directory: {}", e.getMessage(), e);
|
||||
Logger.warning("Error while traversing directory: " + e.getMessage());
|
||||
}
|
||||
|
||||
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) {
|
||||
log.debug("preVisitDirectory: {}", dir.toAbsolutePath());
|
||||
if (depth > ParticleConfig.MAX_DEPTH) {
|
||||
return FileVisitResult.SKIP_SUBTREE;
|
||||
}
|
||||
depth++;
|
||||
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) {
|
||||
log.debug("postVisitDirectory: {}", dir.toAbsolutePath());
|
||||
depth--;
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
};
|
||||
|
|
@ -116,17 +101,15 @@ 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 at {}", particlesDir.getAbsolutePath());
|
||||
Logger.warning("Unable to create particles directory");
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +218,6 @@ public class ParticleConfig {
|
|||
public static void reload() {
|
||||
ParticleStorage.clear();
|
||||
instance = getInstance();
|
||||
log.info("Reloading particles...");
|
||||
|
||||
for (File file : instance.getJsonFiles()) {
|
||||
loadParticleFromFile(file);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user