aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0601-Allow-skipping-writing-of-comments-to-server.propert.patch
diff options
context:
space:
mode:
authormaxcom1 <[email protected]>2024-03-23 22:26:17 +0100
committerGitHub <[email protected]>2024-03-23 17:26:17 -0400
commitb6001403e9703cadaa6e8c8558e732b91c3c6d6e (patch)
treea8c57bbc334a8ad48d4ad2b43db335667b142bee /patches/server/0601-Allow-skipping-writing-of-comments-to-server.propert.patch
parent9ec7dfcbc41c6e625de0050b6997160a75df9f44 (diff)
downloadPaper-b6001403e9703cadaa6e8c8558e732b91c3c6d6e.tar.gz
Paper-b6001403e9703cadaa6e8c8558e732b91c3c6d6e.zip
Add methods to change entity physics (#10334)
Diffstat (limited to 'patches/server/0601-Allow-skipping-writing-of-comments-to-server.propert.patch')
-rw-r--r--patches/server/0601-Allow-skipping-writing-of-comments-to-server.propert.patch69
1 files changed, 69 insertions, 0 deletions
diff --git a/patches/server/0601-Allow-skipping-writing-of-comments-to-server.propert.patch b/patches/server/0601-Allow-skipping-writing-of-comments-to-server.propert.patch
new file mode 100644
index 0000000000..5edf383235
--- /dev/null
+++ b/patches/server/0601-Allow-skipping-writing-of-comments-to-server.propert.patch
@@ -0,0 +1,69 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Professor Bloodstone <[email protected]>
+Date: Fri, 23 Jul 2021 02:32:04 +0200
+Subject: [PATCH] Allow skipping writing of comments to server.properties
+
+Makes less git noise, as it won't update the date every single time
+
+Use -DPaper.skipServerPropertiesComments=true flag to disable writing it
+
+diff --git a/src/main/java/net/minecraft/server/dedicated/Settings.java b/src/main/java/net/minecraft/server/dedicated/Settings.java
+index fc45c2c4ecdf3906df6bceaf3e019c462fe62186..61bf3ccf998bcb9ebd80e983566e7181a73f0e30 100644
+--- a/src/main/java/net/minecraft/server/dedicated/Settings.java
++++ b/src/main/java/net/minecraft/server/dedicated/Settings.java
+@@ -29,6 +29,7 @@ public abstract class Settings<T extends Settings<T>> {
+
+ private static final Logger LOGGER = LogUtils.getLogger();
+ public final Properties properties;
++ private static final boolean skipComments = Boolean.getBoolean("Paper.skipServerPropertiesComments"); // Paper - allow skipping server.properties comments
+ // CraftBukkit start
+ private OptionSet options = null;
+
+@@ -123,7 +124,46 @@ public abstract class Settings<T extends Settings<T>> {
+ return;
+ }
+ // CraftBukkit end
+- BufferedWriter bufferedwriter = Files.newBufferedWriter(path, StandardCharsets.UTF_8);
++ // Paper start - allow skipping server.properties comments
++ java.io.OutputStream outputstream = Files.newOutputStream(path);
++ java.io.BufferedOutputStream bufferedOutputStream = !skipComments ? new java.io.BufferedOutputStream(outputstream) : new java.io.BufferedOutputStream(outputstream) {
++ private boolean isRightAfterNewline = true; // If last written char was newline
++ private boolean isComment = false; // Are we writing comment currently?
++
++ @Override
++ public void write(@org.jetbrains.annotations.NotNull byte[] b) throws IOException {
++ this.write(b, 0, b.length);
++ }
++
++ @Override
++ public void write(@org.jetbrains.annotations.NotNull byte[] bbuf, int off, int len) throws IOException {
++ int latest_offset = off; // The latest offset, updated when comment ends
++ for (int index = off; index < off + len; ++index ) {
++ byte c = bbuf[index];
++ boolean isNewline = (c == '\n' || c == '\r');
++ if (isNewline && this.isComment) {
++ // Comment has ended
++ this.isComment = false;
++ latest_offset = index+1;
++ }
++ if (c == '#' && this.isRightAfterNewline) {
++ this.isComment = true;
++ if (index != latest_offset) {
++ // We got some non-comment data earlier
++ super.write(bbuf, latest_offset, index-latest_offset);
++ }
++ }
++ this.isRightAfterNewline = isNewline; // Store for next iteration
++
++ }
++ if (latest_offset < off+len && !this.isComment) {
++ // We have some unwritten data, that isn't part of a comment
++ super.write(bbuf, latest_offset, (off + len) - latest_offset);
++ }
++ }
++ };
++ BufferedWriter bufferedwriter = new BufferedWriter(new java.io.OutputStreamWriter(bufferedOutputStream, java.nio.charset.StandardCharsets.UTF_8.newEncoder()));
++ // Paper end - allow skipping server.properties comments
+
+ try {
+ this.properties.store(bufferedwriter, "Minecraft server properties");