mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-21 08:11:06 +00:00
Remove dump-resources and allow for ignoring specific resources
This commit is contained in:
@@ -9,12 +9,12 @@ package com.dfsek.terra.api.config;
|
|||||||
|
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public interface PluginConfig {
|
public interface PluginConfig {
|
||||||
void load(Platform platform);
|
void load(Platform platform);
|
||||||
|
|
||||||
boolean dumpDefaultConfig();
|
|
||||||
|
|
||||||
boolean isDebugCommands();
|
boolean isDebugCommands();
|
||||||
|
|
||||||
boolean isDebugProfiler();
|
boolean isDebugProfiler();
|
||||||
@@ -31,5 +31,7 @@ public interface PluginConfig {
|
|||||||
|
|
||||||
int getMaxRecursion();
|
int getMaxRecursion();
|
||||||
|
|
||||||
|
List<String> getIgnoredResources();
|
||||||
|
|
||||||
int getProviderCache();
|
int getProviderCache();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,11 +143,8 @@ public abstract class AbstractPlatform implements Platform {
|
|||||||
|
|
||||||
config.load(this); // load config.yml
|
config.load(this); // load config.yml
|
||||||
|
|
||||||
if(config.dumpDefaultConfig()) {
|
|
||||||
dumpResources();
|
dumpResources(config.getIgnoredResources());
|
||||||
} else {
|
|
||||||
logger.info("Skipping resource dumping.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(config.isDebugProfiler()) { // if debug.profiler is enabled, start profiling
|
if(config.isDebugProfiler()) { // if debug.profiler is enabled, start profiling
|
||||||
profiler.start();
|
profiler.start();
|
||||||
@@ -259,7 +256,7 @@ public abstract class AbstractPlatform implements Platform {
|
|||||||
return internalAddon;
|
return internalAddon;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void dumpResources() {
|
protected void dumpResources(List<String> ignoredResources) {
|
||||||
try(InputStream resourcesConfig = getClass().getResourceAsStream("/resources.yml")) {
|
try(InputStream resourcesConfig = getClass().getResourceAsStream("/resources.yml")) {
|
||||||
if(resourcesConfig == null) {
|
if(resourcesConfig == null) {
|
||||||
logger.info("No resources config found. Skipping resource dumping.");
|
logger.info("No resources config found. Skipping resource dumping.");
|
||||||
@@ -301,6 +298,9 @@ public abstract class AbstractPlatform implements Platform {
|
|||||||
Map<String, List<String>> resources = new Yaml().load(resourceYaml);
|
Map<String, List<String>> resources = new Yaml().load(resourceYaml);
|
||||||
resources.forEach((dir, entries) -> entries.forEach(entry -> {
|
resources.forEach((dir, entries) -> entries.forEach(entry -> {
|
||||||
String resourceClassPath = dir + "/" + entry;
|
String resourceClassPath = dir + "/" + entry;
|
||||||
|
if (ignoredResources.contains(dir) || ignoredResources.contains(entry) || ignoredResources.contains(resourceClassPath)) {
|
||||||
|
logger.info("Not dumping resource {} because it is ignored.", resourceClassPath);
|
||||||
|
} else {
|
||||||
String resourcePath = resourceClassPath.replace('/', File.separatorChar);
|
String resourcePath = resourceClassPath.replace('/', File.separatorChar);
|
||||||
File resource = new File(getDataFolder(), resourcePath);
|
File resource = new File(getDataFolder(), resourcePath);
|
||||||
if(resource.exists())
|
if(resource.exists())
|
||||||
@@ -338,7 +338,7 @@ public abstract class AbstractPlatform implements Platform {
|
|||||||
resourcePath);
|
resourcePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("Dumping resource {}...", resource.getAbsolutePath());
|
logger.info("Dumping resource {}.", resource.getAbsolutePath());
|
||||||
resource.getParentFile().mkdirs();
|
resource.getParentFile().mkdirs();
|
||||||
resource.createNewFile();
|
resource.createNewFile();
|
||||||
try(OutputStream os = new FileOutputStream(resource)) {
|
try(OutputStream os = new FileOutputStream(resource)) {
|
||||||
@@ -347,6 +347,7 @@ public abstract class AbstractPlatform implements Platform {
|
|||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
throw new UncheckedIOException(e);
|
throw new UncheckedIOException(e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
logger.error("Error while dumping resources...", e);
|
logger.error("Error while dumping resources...", e);
|
||||||
|
|||||||
+9
-7
@@ -30,6 +30,8 @@ import java.io.File;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.dfsek.terra.api.Platform;
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.config.PluginConfig;
|
import com.dfsek.terra.api.config.PluginConfig;
|
||||||
@@ -71,9 +73,9 @@ public class PluginConfigImpl implements ConfigTemplate, PluginConfig {
|
|||||||
@Default
|
@Default
|
||||||
private int providerCache = 32;
|
private int providerCache = 32;
|
||||||
|
|
||||||
@Value("dump-default")
|
@Value("ignored-resources")
|
||||||
@Default
|
@Default
|
||||||
private boolean dumpDefaultData = true;
|
private List<String> ignoredResources = Collections.emptyList();
|
||||||
|
|
||||||
@Value("script.max-recursion")
|
@Value("script.max-recursion")
|
||||||
@Default
|
@Default
|
||||||
@@ -99,11 +101,6 @@ public class PluginConfigImpl implements ConfigTemplate, PluginConfig {
|
|||||||
logger.info("Debug logging enabled.");
|
logger.info("Debug logging enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean dumpDefaultConfig() {
|
|
||||||
return dumpDefaultData;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebugCommands() {
|
public boolean isDebugCommands() {
|
||||||
return debugCommands;
|
return debugCommands;
|
||||||
@@ -139,6 +136,11 @@ public class PluginConfigImpl implements ConfigTemplate, PluginConfig {
|
|||||||
return samplerCache;
|
return samplerCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getIgnoredResources() {
|
||||||
|
return ignoredResources;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxRecursion() {
|
public int getMaxRecursion() {
|
||||||
return maxRecursion;
|
return maxRecursion;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ debug:
|
|||||||
log: false
|
log: false
|
||||||
profiler: false
|
profiler: false
|
||||||
script: false
|
script: false
|
||||||
dump-default: true
|
|
||||||
biome-search-resolution: 4
|
biome-search-resolution: 4
|
||||||
cache:
|
cache:
|
||||||
structure: 32
|
structure: 32
|
||||||
@@ -18,3 +17,6 @@ cache:
|
|||||||
biome-provider: 32
|
biome-provider: 32
|
||||||
script:
|
script:
|
||||||
max-recursion: 1000
|
max-recursion: 1000
|
||||||
|
ignored-resources:
|
||||||
|
# - "addons"
|
||||||
|
# - "packs"
|
||||||
Reference in New Issue
Block a user