feat: better config completer system
This commit is contained in:
@@ -6,10 +6,10 @@ Subject: [PATCH] Fix off region thrown egg new entity creating
|
||||
should set pos before so that we could correctly modify the entity's other attribute on-region without triggering the async catchers
|
||||
|
||||
diff --git a/net/minecraft/world/entity/projectile/ThrownEgg.java b/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
index 73ec34b43f3fb2aa3edc3f1cb48a923d1fa32036..5d2f80c4dd8cb6726b0f42891d4ddbc85bf153a7 100644
|
||||
index 73ec34b43f3fb2aa3edc3f1cb48a923d1fa32036..5760ae39e8c452b8291353ed59ce7f8ef4d43dc1 100644
|
||||
--- a/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
+++ b/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
@@ -97,17 +97,18 @@ public class ThrownEgg extends ThrowableItemProjectile {
|
||||
@@ -97,12 +97,13 @@ public class ThrownEgg extends ThrowableItemProjectile {
|
||||
for (int i1 = 0; i1 < i; i1++) {
|
||||
net.minecraft.world.entity.Entity chicken = newEntityType.create(this.level(), net.minecraft.world.entity.EntitySpawnReason.TRIGGERED); // CraftBukkit
|
||||
if (chicken != null) {
|
||||
@@ -24,10 +24,3 @@ index 73ec34b43f3fb2aa3edc3f1cb48a923d1fa32036..5d2f80c4dd8cb6726b0f42891d4ddbc8
|
||||
// CraftBukkit start
|
||||
if (chicken instanceof Chicken realChicken) {
|
||||
Optional.ofNullable(this.getItem().get(DataComponents.CHICKEN_VARIANT))
|
||||
- .flatMap(eitherHolder -> eitherHolder.unwrap(this.registryAccess()))
|
||||
- .ifPresent(realChicken::setVariant);
|
||||
+ .flatMap(eitherHolder -> eitherHolder.unwrap(this.registryAccess()))
|
||||
+ .ifPresent(realChicken::setVariant);
|
||||
}
|
||||
// CraftBukkit end
|
||||
if (!chicken.fudgePositionAfterSizeChange(ZERO_SIZED_DIMENSIONS)) {
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
+ result.add("set");
|
||||
+ result.add("reset");
|
||||
+ result.add("reload");
|
||||
+ } else if (args.length == 2 && args[0] != "reload") {
|
||||
+ result.addAll(LuminolConfig.getAllConfigPaths(args[1]));
|
||||
+ } else if (args.length == 2 && (args[0].equals("query") || args[0].equals("set") || args[0].equals("reset"))) {
|
||||
+ result.addAll(LuminolConfig.completeConfigPath(args[1]));
|
||||
+ }
|
||||
+ return result;
|
||||
+ }
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
@@ -1,0 +_,378 @@
|
||||
+package me.earthme.luminol.config;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.CommentedConfig;
|
||||
+import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import io.papermc.paper.threadedregions.RegionizedServer;
|
||||
@@ -275,29 +274,30 @@
|
||||
+ return configFileInstance.get(key).toString();
|
||||
+ }
|
||||
+
|
||||
+ public static List<String> getAllConfigPaths(String prefix) {
|
||||
+ List<String> configPaths = getAllConfigPaths();
|
||||
+ return configPaths.stream().filter(path -> path.startsWith(prefix)).toList();
|
||||
+ }
|
||||
+ public static List<String> completeConfigPath(String partialPath) {
|
||||
+ List<String> allPaths = getAllConfigPaths(partialPath);
|
||||
+ List<String> result = new ArrayList<>();
|
||||
+
|
||||
+ public static List<String> getAllConfigPaths() {
|
||||
+ List<String> configPaths = new ArrayList<>();
|
||||
+ getAllConfigPathsRecursive(configFileInstance, "", configPaths);
|
||||
+ return configPaths;
|
||||
+ }
|
||||
+ for (String path : allPaths) {
|
||||
+ String remaining = path.substring(partialPath.length());
|
||||
+ if (remaining.isEmpty()) continue;
|
||||
+
|
||||
+ private static void getAllConfigPathsRecursive(CommentedConfig config, String currentPath, List<String> configPaths) {
|
||||
+ for (CommentedConfig.Entry entry : config.entrySet()) {
|
||||
+ String key = entry.getKey();
|
||||
+ Object value = entry.getValue();
|
||||
+ String fullPath = currentPath.isEmpty() ? key : currentPath + "." + key;
|
||||
+ int dotIndex = remaining.indexOf('.');
|
||||
+ String suggestion = (dotIndex == -1)
|
||||
+ ? path
|
||||
+ : partialPath + remaining.substring(0, dotIndex);
|
||||
+
|
||||
+ if (value instanceof CommentedConfig) {
|
||||
+ getAllConfigPathsRecursive((CommentedConfig) value, fullPath, configPaths);
|
||||
+ } else {
|
||||
+ configPaths.add(fullPath);
|
||||
+ if (!result.contains(suggestion)) {
|
||||
+ result.add(suggestion);
|
||||
+ }
|
||||
+ }
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ private static List<String> getAllConfigPaths(String currentPath) {
|
||||
+ return defaultvalueMap.keySet().stream()
|
||||
+ .filter(k -> k.startsWith(currentPath))
|
||||
+ .toList();
|
||||
+ }
|
||||
+
|
||||
+ public static @NotNull Set<Class<?>> getClasses(String pack) {
|
||||
|
||||
Reference in New Issue
Block a user