This repository has been archived by the owner on Jun 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Upstream and Sidestream(s) (Tuinity/AirplaneLite/Purpur)
Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Tuinity Changes: 06ce05b Fix broken chunk loading while under high block update stress AirplaneLite Changes: 1b05468 Always reset comment list adbefaa DEAR merged! (fix comment) 6e86873 Merge branch 'perf/activation-ranges' 12c221c Merge pull request #2 from Encode42/master 6095a90 Fix webhook build status 9ec74d9 Fix compile error b0adfa5 Hoglin support 829a3a2 Rebuild patches 553e5c4 Merge branch 'master' into perf/activation-ranges 95fb8ac Merge branch 'master' into perf/activation-ranges 4444971 ok 767e9e1 DEAR for piglins ce074ea Merge branch 'master' into perf/activation-ranges f12fce4 lower bound on activation prio d9962ce Add villager dynamic EAR ticking 10929cc Spelling 21d241c Merge branch 'master' into perf/activation-ranges 8f0039a Add configuration to activation ranges c758dfa Merge branch 'master' into perf/activation-ranges 17605f8 Raise lowest tick amount to 1s 1b604ca Fix Paper inactive tick, finish our range impl 72f27b7 Merge master dafa5a9 Merge branch 'master' into perf/activation-ranges 55c051f Tuning, still needs config 089d995 First pass at dynamic activation range Purpur Changes: d72b228 Updated Upstream (Paper & Tuinity)
- Loading branch information
1 parent
18c2464
commit 34bef7d
Showing
20 changed files
with
509 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
286 changes: 286 additions & 0 deletions
286
patches/AirplaneLite/patches/server/0002-Airplane-Configuration.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,286 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Paul Sauve <[email protected]> | ||
Date: Wed, 20 Jan 2021 13:08:53 -0600 | ||
Subject: [PATCH] Airplane Configuration | ||
|
||
|
||
diff --git a/src/main/java/gg/airplane/AirplaneConfig.java b/src/main/java/gg/airplane/AirplaneConfig.java | ||
new file mode 100644 | ||
index 0000000000000000000000000000000000000000..4feb9686f45ce4ae9f474447496b8e0f6fcb7e31 | ||
--- /dev/null | ||
+++ b/src/main/java/gg/airplane/AirplaneConfig.java | ||
@@ -0,0 +1,46 @@ | ||
+package gg.airplane; | ||
+ | ||
+import gg.airplane.manual.ManualParser; | ||
+import net.minecraft.server.MinecraftServer; | ||
+import org.apache.logging.log4j.Level; | ||
+ | ||
+import java.io.File; | ||
+import java.io.IOException; | ||
+import java.lang.reflect.Method; | ||
+import java.lang.reflect.Modifier; | ||
+ | ||
+public class AirplaneConfig { | ||
+ | ||
+ private static ManualParser manual; | ||
+ | ||
+ public static void load() { | ||
+ try { | ||
+ manual = new ManualParser(new File("airplane.air")); | ||
+ } catch (IOException e) { | ||
+ e.printStackTrace(); | ||
+ } | ||
+ | ||
+ manual.get("info.version", "1.0"); | ||
+ manual.setComment("info", | ||
+ " Airplane Configuration", | ||
+ " Please see https://airplane.gg/config for help."); | ||
+ | ||
+ for (Method method : AirplaneConfig.class.getDeclaredMethods()) { | ||
+ if (Modifier.isStatic(method.getModifiers()) && Modifier.isPrivate(method.getModifiers())) { | ||
+ method.setAccessible(true); | ||
+ try { | ||
+ method.invoke(null); | ||
+ } catch (Throwable t) { | ||
+ MinecraftServer.LOGGER.log(Level.WARN, "Failed to load configuration option from " + method.getName(), t); | ||
+ } | ||
+ } | ||
+ } | ||
+ | ||
+ try { | ||
+ manual.save(); | ||
+ } catch (IOException e) { | ||
+ e.printStackTrace(); | ||
+ } | ||
+ } | ||
+ | ||
+} | ||
diff --git a/src/main/java/gg/airplane/manual/ManualParser.java b/src/main/java/gg/airplane/manual/ManualParser.java | ||
new file mode 100644 | ||
index 0000000000000000000000000000000000000000..ace29adb0f140d99a8d85ac824654beded4bf5b8 | ||
--- /dev/null | ||
+++ b/src/main/java/gg/airplane/manual/ManualParser.java | ||
@@ -0,0 +1,210 @@ | ||
+package gg.airplane.manual; | ||
+ | ||
+import java.io.BufferedReader; | ||
+import java.io.BufferedWriter; | ||
+import java.io.File; | ||
+import java.io.FileReader; | ||
+import java.io.FileWriter; | ||
+import java.io.IOException; | ||
+import java.util.ArrayList; | ||
+import java.util.Arrays; | ||
+import java.util.LinkedHashMap; | ||
+import java.util.List; | ||
+import java.util.Map; | ||
+import java.util.TreeMap; | ||
+ | ||
+// todo make this cleaner and more ergonomic to use | ||
+// also probably needs lists eventually | ||
+public class ManualParser { | ||
+ | ||
+ private final File file; | ||
+ private final Map<String, Section> sections = new LinkedHashMap<>(); | ||
+ | ||
+ private static class ManualObject { | ||
+ public final String key; | ||
+ public final List<String> comments; | ||
+ | ||
+ private ManualObject(String key, List<String> comments) { | ||
+ this.key = key; | ||
+ this.comments = comments == null ? new ArrayList<>() : comments; | ||
+ } | ||
+ } | ||
+ | ||
+ private static class Section extends ManualObject { | ||
+ public final Map<String, Value> values; | ||
+ | ||
+ private Section(String key, List<String> comments) { | ||
+ super(key, comments); | ||
+ this.values = new LinkedHashMap<>(); | ||
+ } | ||
+ | ||
+ public void add(String key, Value value) { | ||
+ this.values.put(key, value); | ||
+ value.parent = this; | ||
+ } | ||
+ | ||
+ public Value get(String key) { | ||
+ return this.values.computeIfAbsent(key, k -> { | ||
+ Value value = new Value(k, null, null); | ||
+ value.parent = this; | ||
+ return value; | ||
+ }); | ||
+ } | ||
+ } | ||
+ | ||
+ private static class Value extends ManualObject { | ||
+ public Object value; | ||
+ public Section parent; | ||
+ | ||
+ private Value(String key, Object value, List<String> comments) { | ||
+ super(key, comments); | ||
+ this.value = value; | ||
+ } | ||
+ } | ||
+ | ||
+ public ManualParser(File file) throws IOException { | ||
+ this.file = file; | ||
+ | ||
+ if (!file.exists()) { | ||
+ return; | ||
+ } | ||
+ | ||
+ try (BufferedReader reader = new BufferedReader(new FileReader(file))) { | ||
+ Section currentSection = null; | ||
+ List<String> currentComment = new ArrayList<>(); | ||
+ | ||
+ String line; | ||
+ while ((line = reader.readLine()) != null) { | ||
+ line = line.trim(); | ||
+ | ||
+ if (line.length() == 0) { | ||
+ continue; // empty line | ||
+ } | ||
+ | ||
+ if (line.startsWith("#")) { | ||
+ currentComment.add(line.substring(1).trim()); | ||
+ } else if (line.startsWith("[")) { | ||
+ if (!line.endsWith("]")) { | ||
+ throw new IllegalArgumentException("Invalid configuration, section '" + line + "' does not end with ]"); | ||
+ } | ||
+ if (line.length() < 3) { | ||
+ throw new IllegalArgumentException("Invalid configuration, section '" + line + "' does not have a name"); | ||
+ } | ||
+ String sectionName = line.substring(1, line.length() - 1); | ||
+ Section newSection = new Section(sectionName, currentComment); | ||
+ currentComment = new ArrayList<>(); | ||
+ currentSection = newSection; | ||
+ this.sections.put(sectionName, newSection); | ||
+ } else { | ||
+ if (currentSection == null) { | ||
+ throw new IllegalArgumentException("Invalid configuration, found value outside of section " + line); | ||
+ } | ||
+ int equals = line.indexOf("="); | ||
+ if (equals <= 1 || equals == line.length() - 1) { | ||
+ throw new IllegalArgumentException("Invalid configuration, assignment invalid " + line); | ||
+ } | ||
+ | ||
+ String key = line.substring(0, equals).trim(); | ||
+ | ||
+ String value = line.substring(equals + 1).trim(); | ||
+ if (value.length() == 0) { | ||
+ throw new IllegalArgumentException("Invalid configuration, value does not exist " + line); | ||
+ } | ||
+ if (value.startsWith("\"")) { | ||
+ if (!value.endsWith("\"")) { | ||
+ throw new IllegalArgumentException("Invalid configuration, value has no ending quote " + line); | ||
+ } | ||
+ String stringValue = value.substring(1, value.length() - 1); | ||
+ currentSection.add(key, new Value(key, stringValue, currentComment)); | ||
+ } else if (Character.isDigit(value.charAt(0))) { | ||
+ if (value.contains(".")) { | ||
+ double doubleValue = Double.parseDouble(value); | ||
+ currentSection.add(key, new Value(key, doubleValue, currentComment)); | ||
+ } else { | ||
+ int intValue = Integer.parseInt(value); | ||
+ currentSection.add(key, new Value(key, intValue, currentComment)); | ||
+ } | ||
+ } else if (value.equals("true") || value.equals("false")) { | ||
+ boolean boolValue = Boolean.parseBoolean(value); | ||
+ currentSection.add(key, new Value(key, boolValue, currentComment)); | ||
+ } else { | ||
+ throw new IllegalArgumentException("Invalid configuration, unknown type for " + line); | ||
+ } | ||
+ currentComment = new ArrayList<>(); | ||
+ } | ||
+ } | ||
+ } | ||
+ } | ||
+ | ||
+ public void save() throws IOException { | ||
+ try (BufferedWriter writer = new BufferedWriter(new FileWriter(this.file))) { | ||
+ for (Map.Entry<String, Section> entry : this.sections.entrySet()) { | ||
+ Section section = entry.getValue(); | ||
+ if (section.comments != null) { | ||
+ for (String comment : section.comments) { | ||
+ writer.write("# " + comment + "\n"); | ||
+ } | ||
+ } | ||
+ writer.write("[" + section.key + "]" + "\n"); | ||
+ for (Value value : section.values.values()) { | ||
+ if (value.comments != null) { | ||
+ for (String comment : value.comments) { | ||
+ writer.write(" # " + comment + "\n"); | ||
+ } | ||
+ } | ||
+ writer.write(" " + value.key + " = " + serialize(value.value) + "\n"); | ||
+ } | ||
+ writer.write("\n"); | ||
+ } | ||
+ } | ||
+ } | ||
+ | ||
+ private ManualObject getObject(String key) { | ||
+ String[] split = key.split("\\.", 2); | ||
+ if (split.length == 1) { | ||
+ return this.sections.computeIfAbsent(key, k -> new Section(k, null)); | ||
+ } | ||
+ return this.sections.computeIfAbsent(split[0], k -> new Section(k, null)).get(split[1]); | ||
+ } | ||
+ | ||
+ public void setComment(String key, String... comment) { | ||
+ ManualObject object = this.getObject(key); | ||
+ object.comments.clear(); | ||
+ object.comments.addAll(Arrays.asList(comment)); | ||
+ } | ||
+ | ||
+ public <T> T get(String key, T defaultValue, String... comment) { | ||
+ String[] split = key.split("\\.", 2); | ||
+ if (split.length == 1) { | ||
+ throw new IllegalArgumentException("Key " + key + " does not include section"); | ||
+ } | ||
+ Section section = this.sections.computeIfAbsent(split[0], k -> new Section(k, null)); | ||
+ if (!section.values.containsKey(split[1])) { | ||
+ Value value = section.get(split[1]); | ||
+ value.value = defaultValue; | ||
+ value.comments.addAll(Arrays.asList(comment)); | ||
+ return defaultValue; | ||
+ } | ||
+ Value value = section.get(split[1]); | ||
+ if (value.comments.isEmpty()) { | ||
+ value.comments.addAll(Arrays.asList(comment)); | ||
+ } | ||
+ return (T) value.value; | ||
+ } | ||
+ | ||
+ public void set(String key, Object value) { | ||
+ ManualObject object = getObject(key); | ||
+ if (!(object instanceof Value)) { | ||
+ throw new IllegalArgumentException("Invalid key for value " + key); | ||
+ } | ||
+ ((Value) object).value = value; | ||
+ } | ||
+ | ||
+ private String serialize(Object object) { | ||
+ if (object instanceof String) { | ||
+ return "\"" + object + "\""; | ||
+ } | ||
+ return String.valueOf(object); | ||
+ } | ||
+ | ||
+} | ||
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java | ||
index 3ee8d31c453105eca7b96bede39a9ebbf40e1c2c..ca3d9dbcbeeb5059a942cae1a5020f0bcc59ac9c 100644 | ||
--- a/src/main/java/net/minecraft/server/DedicatedServer.java | ||
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java | ||
@@ -179,6 +179,7 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer | ||
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now | ||
// Paper end | ||
com.tuinity.tuinity.config.TuinityConfig.init((java.io.File) options.valueOf("tuinity-settings")); // Tuinity - Server Config | ||
+ gg.airplane.AirplaneConfig.load(); // Airplane - config | ||
|
||
this.setPVP(dedicatedserverproperties.pvp); | ||
this.setAllowFlight(dedicatedserverproperties.allowFlight); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.