Compare commits
3 Commits
1.21.4-741
...
1.21.4-5b6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b6d1ee061 | ||
|
|
1eba4e1a05 | ||
|
|
b1e3a300a2 |
@@ -7,7 +7,6 @@ Co-authored by: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
As part of: Leaves (https://github.com/LeavesMC/Leaves/blob/master/leaves-api/paper-patches/features/0008-Fix-SculkCatalyst-exp-skip.patch)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
|
||||
index ab7584873e46020148bceecbd42a43055684e6a0..f33ab20313310a113d6c88e0fc1fe1666218061e 100644
|
||||
--- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/BasicTransferLogic.java
|
||||
@@ -1,0 +_,7 @@
|
||||
+package me.earthme.luminol.config;
|
||||
+
|
||||
+public class BasicTransferLogic {
|
||||
+ public Object transform(Object obj) {
|
||||
+ return obj;
|
||||
+ }
|
||||
+}
|
||||
@@ -1,8 +1,9 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/LuminolConfig.java
|
||||
@@ -1,0 +_,226 @@
|
||||
@@ -1,0 +_,268 @@
|
||||
+package me.earthme.luminol.config;
|
||||
+
|
||||
+import com.electronwill.nightconfig.core.UnmodifiableConfig;
|
||||
+import com.electronwill.nightconfig.core.file.CommentedFileConfig;
|
||||
+import io.papermc.paper.threadedregions.RegionizedServer;
|
||||
+import me.earthme.luminol.commands.LuminolConfigCommand;
|
||||
@@ -128,6 +129,33 @@
|
||||
+ final Object currentValue = field.get(null);
|
||||
+
|
||||
+ if (!configFileInstance.contains(fullConfigKeyName)){
|
||||
+ for (TransferringConfig transferringConfig : field.getAnnotationsByType(TransferringConfig.class)) {
|
||||
+ final String oldConfigKeyName = String.join(".", transferringConfig.category()) + "." + transferringConfig.name();
|
||||
+ Object oldValue = configFileInstance.get(oldConfigKeyName);
|
||||
+ if (oldValue != null) {
|
||||
+ boolean success = true;
|
||||
+ if (transferringConfig.transfer()) {
|
||||
+ try {
|
||||
+ Object oldValueTransferred = ((BasicTransferLogic) transferringConfig.transferLogic().getDeclaredConstructor().newInstance()).transform(oldValue);
|
||||
+ configFileInstance.add(fullConfigKeyName, oldValueTransferred);
|
||||
+ } catch (Exception e) {
|
||||
+ success = false;
|
||||
+ logger.error("Failed to transfer removed config {}!", transferringConfig.name());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (success) {
|
||||
+ removeConfig(oldConfigKeyName, transferringConfig.category());
|
||||
+ }
|
||||
+ final String comments = configInfo.comments();
|
||||
+
|
||||
+ if (!comments.isBlank()){
|
||||
+ configFileInstance.setComment(fullConfigKeyName,comments);
|
||||
+ }
|
||||
+ if (configFileInstance.get(fullConfigKeyName) != null) break;
|
||||
+ }
|
||||
+ }
|
||||
+ if (configFileInstance.get(fullConfigKeyName) != null) continue;
|
||||
+ if (currentValue == null){
|
||||
+ throw new UnsupportedOperationException("Config " + singleConfigModule.getBaseName() + "tried to add an null default value!");
|
||||
+ }
|
||||
@@ -148,6 +176,20 @@
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void removeConfig(String name,String[] keys) {
|
||||
+ configFileInstance.remove(name);
|
||||
+ if (configFileInstance.get(String.join(".", keys)) instanceof UnmodifiableConfig) {
|
||||
+ removeConfig(keys);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void removeConfig(String[] keys) {
|
||||
+ configFileInstance.remove(String.join(".", keys));
|
||||
+ if (configFileInstance.get(String.join(".", Arrays.copyOfRange(keys, 1, keys.length))) instanceof UnmodifiableConfig) {
|
||||
+ removeConfig(Arrays.copyOfRange(keys, 1, keys.length));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static @NotNull Set<Class<?>> getClasses(String pack) {
|
||||
+ Set<Class<?>> classes = new LinkedHashSet<>();
|
||||
+ String packageDirName = pack.replace('.', '/');
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/luminol/config/TransferringConfig.java
|
||||
@@ -1,0 +_,20 @@
|
||||
+package me.earthme.luminol.config;
|
||||
+
|
||||
+import java.lang.annotation.*;
|
||||
+
|
||||
+@Retention(RetentionPolicy.RUNTIME)
|
||||
+@Repeatable(TransferringConfig.List.class)
|
||||
+public @interface TransferringConfig {
|
||||
+ String name() default "";
|
||||
+
|
||||
+ String[] category() default "";
|
||||
+
|
||||
+ boolean transfer() default true;
|
||||
+
|
||||
+ Class<?> transferLogic() default BasicTransferLogic.class;
|
||||
+
|
||||
+ @Retention(RetentionPolicy.RUNTIME)
|
||||
+ @interface List {
|
||||
+ TransferringConfig[] value();
|
||||
+ }
|
||||
+}
|
||||
Reference in New Issue
Block a user