Fix Config Value Regeneration

This commit is contained in:
LinsaFTW 2022-03-06 11:57:48 -03:00
parent df9937ce07
commit f06713e1d4
8 changed files with 87 additions and 127 deletions

View File

@ -1,4 +1,4 @@
From bd296fecf532bf07f59fb6a79acdbe7b888f004c Mon Sep 17 00:00:00 2001
From 64e6384ad6a59b910e932735b6d505038104ea72 Mon Sep 17 00:00:00 2001
From: Juan Cruz Linsalata <LinsaFTW@users.noreply.github.com>
Date: Mon, 12 Oct 2020 15:40:53 -0300
Subject: [PATCH] FlameCord General Patch
@ -45,12 +45,56 @@ index 00000000..252612a3
+ }
+}
\ No newline at end of file
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
new file mode 100644
index 00000000..cfbd55c3
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameConfig.java
@@ -0,0 +1,38 @@
+package dev._2lstudios.flamecord.configuration;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+
+import net.md_5.bungee.config.Configuration;
+
+public class FlameConfig {
+ int setIfUnexistant(final String arg1, final int arg2, final Configuration configuration) {
+ return (int) setIfUnexistant(arg1, (Object) arg2, configuration);
+ }
+
+ boolean setIfUnexistant(final String arg1, final boolean arg2, final Configuration configuration) {
+ return (boolean) setIfUnexistant(arg1, (Object) arg2, configuration);
+ }
+
+ Object setIfUnexistant(final String arg1, final Object arg2, final Configuration configuration) {
+ if (!configuration.contains(arg1)) {
+ configuration.set(arg1, arg2);
+
+ return arg2;
+ } else {
+ return configuration.get(arg1);
+ }
+ }
+
+ Collection<String> setIfUnexistant(final String arg1, final Collection<String> arg2,
+ final Configuration configuration) {
+ if (!configuration.contains(arg1)) {
+ configuration.set(arg1, new ArrayList<>(arg2));
+
+ return arg2;
+ } else {
+ return new HashSet<>(configuration.getStringList(arg1));
+ }
+ }
+}
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
new file mode 100644
index 00000000..81ded224
index 00000000..c8148e90
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -0,0 +1,64 @@
@@ -0,0 +1,33 @@
+package dev._2lstudios.flamecord.configuration;
+
+import java.io.File;
@ -64,7 +108,7 @@ index 00000000..81ded224
+import net.md_5.bungee.config.Configuration;
+import net.md_5.bungee.config.ConfigurationProvider;
+
+public class FlameCordConfiguration {
+public class FlameCordConfiguration extends FlameConfig {
+ public FlameCordConfiguration(final ConfigurationProvider configurationProvider) {
+ try {
+ final String fileName = "./flamecord.yml";
@ -78,42 +122,11 @@ index 00000000..81ded224
+ configuration = configurationProvider.load(configurationFile);
+ }
+
+ if (!configurationExists) {
+ configurationProvider.save(configuration, configurationFile);
+ }
+ configurationProvider.save(configuration, configurationFile);
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private int setIfUnexistant(final String arg1, final int arg2, final Configuration configuration) {
+ return (int) setIfUnexistant(arg1, (Object) arg2, configuration);
+ }
+
+ private boolean setIfUnexistant(final String arg1, final boolean arg2, final Configuration configuration) {
+ return (boolean) setIfUnexistant(arg1, (Object) arg2, configuration);
+ }
+
+ private Object setIfUnexistant(final String arg1, final Object arg2, final Configuration configuration) {
+ if (!configuration.contains(arg1)) {
+ configuration.set(arg1, arg2);
+
+ return arg2;
+ } else {
+ return configuration.get(arg1);
+ }
+ }
+
+ private Collection<String> setIfUnexistant(final String arg1, final Collection<String> arg2,
+ final Configuration configuration) {
+ if (!configuration.contains(arg1)) {
+ configuration.set(arg1, new ArrayList<>(arg2));
+
+ return arg2;
+ } else {
+ return new HashSet<>(configuration.getStringList(arg1));
+ }
+ }
+}
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
index 4b9b80b9..aa35f870 100644
@ -191,7 +204,7 @@ index 00000000..a323598e
+ }
+}
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index 1fe08b80..4902d4f3 100644
index 3ea5518f..2ca3e2b3 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -9,6 +9,8 @@ import com.google.common.collect.Sets;

View File

@ -1,4 +1,4 @@
From d67854d0c57edad3fc8a7ed3ffaf7f537c19c810 Mon Sep 17 00:00:00 2001
From e35251dcc5fc75498efeb2a829ff9cb76cac5620 Mon Sep 17 00:00:00 2001
From: linsaftw <25271111+linsaftw@users.noreply.github.com>
Date: Sat, 1 May 2021 14:17:48 -0300
Subject: [PATCH] FlameCord module system
@ -35,10 +35,10 @@ index 252612a3..2e317533 100644
\ No newline at end of file
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/ModulesConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/ModulesConfiguration.java
new file mode 100644
index 00000000..e82c4844
index 00000000..6c5bb961
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/ModulesConfiguration.java
@@ -0,0 +1,94 @@
@@ -0,0 +1,49 @@
+package dev._2lstudios.flamecord.configuration;
+
+import java.io.File;
@ -47,32 +47,15 @@ index 00000000..e82c4844
+import net.md_5.bungee.config.Configuration;
+import net.md_5.bungee.config.ConfigurationProvider;
+
+public class ModulesConfiguration {
+ // Reconnect Module
+public class ModulesConfiguration extends FlameConfig {
+ public boolean reconnectEnabled = false;
+
+ // Alert Module
+ public boolean alertEnabled = true;
+
+ // Find Module
+ public boolean findEnabled = true;
+
+ // IP Module
+ public boolean ipEnabled = true;
+
+ // List Module
+ public boolean listEnabled = true;
+
+ // Perms Module
+ public boolean permsEnabled = true;
+
+ // Reload Module
+ public boolean reloadEnabled = true;
+
+ // Send Module
+ public boolean sendEnabled = true;
+
+ // Server
+ public boolean serverEnabled = true;
+
+ public ModulesConfiguration(final ConfigurationProvider configurationProvider) {
@ -89,52 +72,24 @@ index 00000000..e82c4844
+ }
+
+ this.alertEnabled = setIfUnexistant("alert.enabled", this.alertEnabled, configuration);
+
+ this.findEnabled = setIfUnexistant("find.enabled", this.findEnabled, configuration);
+
+ this.ipEnabled = setIfUnexistant("ip.enabled", this.ipEnabled, configuration);
+
+ this.listEnabled = setIfUnexistant("list.enabled", this.listEnabled, configuration);
+
+ this.permsEnabled = setIfUnexistant("perms.enabled", this.permsEnabled, configuration);
+
+ this.reloadEnabled = setIfUnexistant("reload.enabled", this.reloadEnabled, configuration);
+
+ this.sendEnabled = setIfUnexistant("send.enabled", this.sendEnabled, configuration);
+
+ this.serverEnabled = setIfUnexistant("server.enabled", this.serverEnabled, configuration);
+
+ this.reconnectEnabled = setIfUnexistant("reconnect.enabled", this.reconnectEnabled,
+ configuration);
+
+ if (!configurationExists) {
+ configurationProvider.save(configuration, configurationFile);
+ }
+ configurationProvider.save(configuration, configurationFile);
+ } catch (final IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private String setIfUnexistant(final String arg1, final String arg2, final Configuration configuration) {
+ return (String) setIfUnexistant(arg1, (Object) arg2, configuration);
+ }
+
+ private boolean setIfUnexistant(final String arg1, final boolean arg2, final Configuration configuration) {
+ return (boolean) setIfUnexistant(arg1, (Object) arg2, configuration);
+ }
+
+ private Object setIfUnexistant(final String arg1, final Object arg2, final Configuration configuration) {
+ if (!configuration.contains(arg1)) {
+ configuration.set(arg1, arg2);
+
+ return arg2;
+ } else {
+ return configuration.get(arg1);
+ }
+ }
+}
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index 4902d4f3..82f5f65c 100644
index 2ca3e2b3..93f57747 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -11,6 +11,8 @@ import com.google.gson.Gson;

View File

@ -1,4 +1,4 @@
From db9dc55944664f345292846ab3e07189d26abc25 Mon Sep 17 00:00:00 2001
From 99d94a26237d95b60348c4de7feb9ff9c6744a9b Mon Sep 17 00:00:00 2001
From: linsaftw <25271111+linsaftw@users.noreply.github.com>
Date: Sat, 1 May 2021 13:40:39 -0300
Subject: [PATCH] FlameCord message configuration
@ -35,10 +35,10 @@ index 2e317533..8957c79a 100644
\ No newline at end of file
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
new file mode 100644
index 00000000..a32522fe
index 00000000..57462992
--- /dev/null
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
@@ -0,0 +1,121 @@
@@ -0,0 +1,113 @@
+package dev._2lstudios.flamecord.configuration;
+
+import java.io.File;
@ -52,7 +52,7 @@ index 00000000..a32522fe
+import net.md_5.bungee.config.Configuration;
+import net.md_5.bungee.config.ConfigurationProvider;
+
+public class MessagesConfiguration {
+public class MessagesConfiguration extends FlameConfig {
+ private final Logger logger;
+ private final Map<String, String> messages = new HashMap<>();
+
@ -129,9 +129,7 @@ index 00000000..a32522fe
+ configuration);
+ setIfUnexistant("flamecord_nopermission", "&cYou don't have permission to do this!", configuration);
+
+ if (!configurationExists) {
+ configurationProvider.save(configuration, configurationFile);
+ }
+ configurationProvider.save(configuration, configurationFile);
+
+ for (final String key : configuration.getKeys()) {
+ final Object value = configuration.get(key);
@ -153,12 +151,6 @@ index 00000000..a32522fe
+
+ return MessageFormat.format(messages.getOrDefault(name, "<translation '" + name + "' missing>"), args);
+ }
+
+ private void setIfUnexistant(final String arg1, final Object arg2, final Configuration configuration) {
+ if (!configuration.contains(arg1)) {
+ configuration.set(arg1, arg2);
+ }
+ }
+}
\ No newline at end of file
diff --git a/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
@ -209,7 +201,7 @@ index a323598e..bf6f8538 100644
}
}
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index 82f5f65c..23cb8839 100644
index 93f57747..29475584 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -597,14 +597,8 @@ public class BungeeCord extends ProxyServer

View File

@ -1,17 +1,17 @@
From 141ff1f306aa26df898e33629e23fdb14621bb16 Mon Sep 17 00:00:00 2001
From d49ffb31a988bab4c7b0d2e2b652f65ce240c087 Mon Sep 17 00:00:00 2001
From: linsaftw <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 30 Apr 2021 23:51:51 -0300
Subject: [PATCH] FlameCord logger options
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
index 81ded224..70d0fb61 100644
index c8148e90..701db67c 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -12,6 +12,15 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration {
public class FlameCordConfiguration extends FlameConfig {
+ @Getter
+ private boolean loggerInitialhandler = false;
+ @Getter
@ -24,7 +24,7 @@ index 81ded224..70d0fb61 100644
public FlameCordConfiguration(final ConfigurationProvider configurationProvider) {
try {
final String fileName = "./flamecord.yml";
@@ -25,6 +34,11 @@ public class FlameCordConfiguration {
@@ -25,6 +34,11 @@ public class FlameCordConfiguration extends FlameConfig {
configuration = configurationProvider.load(configurationFile);
}
@ -33,9 +33,9 @@ index 81ded224..70d0fb61 100644
+ this.loggerDump = setIfUnexistant("logger.dump", this.loggerDump, configuration);
+ this.loggerHaProxy = setIfUnexistant("logger.haproxy", this.loggerHaProxy, configuration);
+
if (!configurationExists) {
configurationProvider.save(configuration, configurationFile);
}
configurationProvider.save(configuration, configurationFile);
} catch (final IOException e) {
e.printStackTrace();
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
index 39c54cf1..cfd6249e 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java

View File

@ -1,11 +1,11 @@
From 4c4837561bfbec01a8d9e671bc40d262b78f48df Mon Sep 17 00:00:00 2001
From 608e7343216c313476d8c0d09a8b94c9f85a8519 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Thu, 7 Oct 2021 21:37:24 -0300
Subject: [PATCH] Custom motd system
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
index 70d0fb61..b3491271 100644
index 701db67c..48deace6 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -6,12 +6,33 @@ import java.util.ArrayList;
@ -20,7 +20,7 @@ index 70d0fb61..b3491271 100644
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration {
public class FlameCordConfiguration extends FlameConfig {
+ private List<String> colors(final List<String> strings) {
+ for (int i = 0; i < strings.size(); i++) {
+ strings.set(i, ChatColor.translateAlternateColorCodes('&', strings.get(i)));
@ -42,7 +42,7 @@ index 70d0fb61..b3491271 100644
@Getter
private boolean loggerInitialhandler = false;
@Getter
@@ -34,6 +55,9 @@ public class FlameCordConfiguration {
@@ -34,6 +55,9 @@ public class FlameCordConfiguration extends FlameConfig {
configuration = configurationProvider.load(configurationFile);
}

View File

@ -1,17 +1,17 @@
From a4b23efe724a4a64f8004583cb9667b8dcae62d6 Mon Sep 17 00:00:00 2001
From 216628c6de6f3697ed82a84be11d73301705e170 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Thu, 24 Feb 2022 23:41:57 -0300
Subject: [PATCH] TCP Fast Open
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
index b3491271..3bf73d9e 100644
index 48deace6..d972fcea 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -15,6 +15,10 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration {
public class FlameCordConfiguration extends FlameConfig {
+ // FlameCord - TCP Fast Open
+ @Getter
+ private int tcpFastOpen = 3;
@ -19,7 +19,7 @@ index b3491271..3bf73d9e 100644
private List<String> colors(final List<String> strings) {
for (int i = 0; i < strings.size(); i++) {
strings.set(i, ChatColor.translateAlternateColorCodes('&', strings.get(i)));
@@ -55,6 +59,8 @@ public class FlameCordConfiguration {
@@ -55,6 +59,8 @@ public class FlameCordConfiguration extends FlameConfig {
configuration = configurationProvider.load(configurationFile);
}

View File

@ -1,4 +1,4 @@
From b47344c51a3e6387263877d9ce93932f873d08df Mon Sep 17 00:00:00 2001
From bced3b6f79614a6580b98f1d2935ab0bbaba75d6 Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 4 Mar 2022 13:35:53 -0300
Subject: [PATCH] Antibot System
@ -569,13 +569,13 @@ index 8957c79a..53148d68 100644
this.modulesConfiguration = new ModulesConfiguration(configurationProvider);
this.messagesConfiguration = new MessagesConfiguration(logger, configurationProvider);
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
index 3bf73d9e..1a445ec8 100644
index d972fcea..df8c90e6 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -15,6 +15,81 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration {
public class FlameCordConfiguration extends FlameConfig {
+ // FlameCord start - Antibot System
+ @Getter
+ private boolean antibotAccountsEnabled = true;
@ -654,7 +654,7 @@ index 3bf73d9e..1a445ec8 100644
// FlameCord - TCP Fast Open
@Getter
private int tcpFastOpen = 3;
@@ -59,6 +134,8 @@ public class FlameCordConfiguration {
@@ -59,6 +134,8 @@ public class FlameCordConfiguration extends FlameConfig {
configuration = configurationProvider.load(configurationFile);
}
@ -664,10 +664,10 @@ index 3bf73d9e..1a445ec8 100644
this.customMotdEnabled = setIfUnexistant("custom-motd.enabled", this.customMotdEnabled, configuration);
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
index a32522fe..9b628ad5 100644
index 57462992..0490b7f6 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
@@ -81,6 +81,16 @@ public class MessagesConfiguration {
@@ -81,6 +81,16 @@ public class MessagesConfiguration extends FlameConfig {
setIfUnexistant("command_ip", "&9IP of {0} is {1}", configuration);
setIfUnexistant("illegal_chat_characters", "&cIllegal characters in chat ({0})", configuration);

View File

@ -1,17 +1,17 @@
From 0b4b916937b76ef836e07d55d2654757a1390246 Mon Sep 17 00:00:00 2001
From 17e051173143aa7d903059ba7acedab551dcbcdd Mon Sep 17 00:00:00 2001
From: LinsaFTW <25271111+linsaftw@users.noreply.github.com>
Date: Fri, 4 Mar 2022 14:09:35 -0300
Subject: [PATCH] Allow Invalid Names
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
index 1a445ec8..25cfc0bd 100644
index df8c90e6..2385ae93 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
@@ -15,6 +15,10 @@ import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
public class FlameCordConfiguration {
public class FlameCordConfiguration extends FlameConfig {
+ // FlameCord - Allow Invalid Names
+ @Getter
+ private boolean allowInvalidNames = false;
@ -19,7 +19,7 @@ index 1a445ec8..25cfc0bd 100644
// FlameCord start - Antibot System
@Getter
private boolean antibotAccountsEnabled = true;
@@ -134,6 +138,8 @@ public class FlameCordConfiguration {
@@ -134,6 +138,8 @@ public class FlameCordConfiguration extends FlameConfig {
configuration = configurationProvider.load(configurationFile);
}