mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-11-06 02:31:46 +01:00
Split flamecord message config
This commit is contained in:
parent
5a71278434
commit
7a3cc7852f
@ -1,4 +1,4 @@
|
||||
From 55134b87570446f86306234e3868d73785efe804 Mon Sep 17 00:00:00 2001
|
||||
From 83cf5e25ec01e1fd7b0b05c3c7ef041d86f75727 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
|
||||
@ -6,17 +6,16 @@ Subject: [PATCH] FlameCord General Patch
|
||||
|
||||
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
|
||||
new file mode 100644
|
||||
index 000000000..8957c79ac
|
||||
index 00000000..2e317533
|
||||
--- /dev/null
|
||||
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
|
||||
@@ -0,0 +1,42 @@
|
||||
@@ -0,0 +1,38 @@
|
||||
+package dev._2lstudios.flamecord;
|
||||
+
|
||||
+import java.util.Collection;
|
||||
+import java.util.logging.Logger;
|
||||
+
|
||||
+import dev._2lstudios.flamecord.configuration.FlameCordConfiguration;
|
||||
+import dev._2lstudios.flamecord.configuration.MessagesConfiguration;
|
||||
+import dev._2lstudios.flamecord.configuration.ModulesConfiguration;
|
||||
+import lombok.Getter;
|
||||
+import net.md_5.bungee.config.ConfigurationProvider;
|
||||
@ -30,8 +29,6 @@ index 000000000..8957c79ac
|
||||
+ @Getter
|
||||
+ private final ModulesConfiguration modulesConfiguration;
|
||||
+ @Getter
|
||||
+ private final MessagesConfiguration messagesConfiguration;
|
||||
+ @Getter
|
||||
+ private boolean running = true;
|
||||
+
|
||||
+ public static void renew(final Logger logger, final Collection<String> whitelistedAddresses) {
|
||||
@ -49,13 +46,12 @@ index 000000000..8957c79ac
|
||||
+
|
||||
+ this.flameCordConfiguration = new FlameCordConfiguration(configurationProvider);
|
||||
+ this.modulesConfiguration = new ModulesConfiguration(configurationProvider);
|
||||
+ this.messagesConfiguration = new MessagesConfiguration(logger, configurationProvider);
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
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 000000000..81ded2243
|
||||
index 00000000..81ded224
|
||||
--- /dev/null
|
||||
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/FlameCordConfiguration.java
|
||||
@@ -0,0 +1,64 @@
|
||||
@ -123,137 +119,9 @@ index 000000000..81ded2243
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
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 000000000..ebfaa761c
|
||||
--- /dev/null
|
||||
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
|
||||
@@ -0,0 +1,121 @@
|
||||
+package dev._2lstudios.flamecord.configuration;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.text.MessageFormat;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Map;
|
||||
+import java.util.logging.Logger;
|
||||
+
|
||||
+import net.md_5.bungee.api.ChatColor;
|
||||
+import net.md_5.bungee.config.Configuration;
|
||||
+import net.md_5.bungee.config.ConfigurationProvider;
|
||||
+
|
||||
+public class MessagesConfiguration {
|
||||
+ private final Logger logger;
|
||||
+ private final Map<String, String> messages = new HashMap<>();
|
||||
+
|
||||
+ public MessagesConfiguration(final Logger logger, final ConfigurationProvider configurationProvider) {
|
||||
+ this.logger = logger;
|
||||
+
|
||||
+ try {
|
||||
+ final String fileName = "./messages.yml";
|
||||
+ final File configurationFile = new File(fileName);
|
||||
+ final Configuration configuration;
|
||||
+ final boolean configurationExists = configurationFile.exists();
|
||||
+
|
||||
+ if (!configurationExists) {
|
||||
+ configuration = new Configuration();
|
||||
+ } else {
|
||||
+ configuration = configurationProvider.load(configurationFile);
|
||||
+ }
|
||||
+
|
||||
+ // BungeeCord
|
||||
+ setIfUnexistant("alert", "&8[&4Alert&8]&r ", configuration);
|
||||
+ setIfUnexistant("already_connected", "&cYou are already connected to this server!", configuration);
|
||||
+ setIfUnexistant("already_connected_proxy", "&cYou are already connected to this proxy!", configuration);
|
||||
+ setIfUnexistant("already_connecting", "&cAlready connecting to this server!", configuration);
|
||||
+ setIfUnexistant("command_list", "&a[{0}] &e({1}): &r{2}", configuration);
|
||||
+ setIfUnexistant("connect_kick", "&cKicked whilst connecting to {0}: {1}", configuration);
|
||||
+ setIfUnexistant("current_server", "&6You are currently connected to {0}.", configuration);
|
||||
+ setIfUnexistant("fallback_kick",
|
||||
+ "&cCould not connect to a default or fallback server, please try again later: {0}", configuration);
|
||||
+ setIfUnexistant("fallback_lobby",
|
||||
+ "&cCould not connect to target server, you have been moved to a fallback server.", configuration);
|
||||
+ setIfUnexistant("lost_connection", "[Proxy] Lost connection to server.", configuration);
|
||||
+ setIfUnexistant("mojang_fail", "Error occurred while contacting login servers, are they down?",
|
||||
+ configuration);
|
||||
+ setIfUnexistant("no_permission", "&cYou do not have permission to execute this command!", configuration);
|
||||
+ setIfUnexistant("no_server", "&cThe specified server does not exist.", configuration);
|
||||
+ setIfUnexistant("no_server_permission", "&cYou don't have permission to access this server.",
|
||||
+ configuration);
|
||||
+ setIfUnexistant("outdated_client", "Outdated client! Please use {0}", configuration);
|
||||
+ setIfUnexistant("outdated_server", "Outdated server! I'm still on {0}", configuration);
|
||||
+ setIfUnexistant("proxy_full", "Server is full!", configuration);
|
||||
+ setIfUnexistant("restart", "[Proxy] Proxy restarting.", configuration);
|
||||
+ setIfUnexistant("server_kick", "[Kicked] ", configuration);
|
||||
+ setIfUnexistant("server_list", "&6You may connect to the following servers at this time: ", configuration);
|
||||
+ setIfUnexistant("server_went_down",
|
||||
+ "&cThe server you were previously on went down, you have been connected to a fallback server",
|
||||
+ configuration);
|
||||
+ setIfUnexistant("total_players", "Total players online: {0}", configuration);
|
||||
+ setIfUnexistant("name_too_long", "Cannot have username longer than 16 characters", configuration);
|
||||
+ setIfUnexistant("name_invalid", "Username contains invalid characters.", configuration);
|
||||
+ setIfUnexistant("ping_cannot_connect", "&c[Bungee] Can't connect to server.", configuration);
|
||||
+ setIfUnexistant("offline_mode_player", "Not authenticated with Minecraft.net", configuration);
|
||||
+ setIfUnexistant("message_needed", "&cYou must supply a message.", configuration);
|
||||
+ setIfUnexistant("error_occurred_player",
|
||||
+ "&cAn error occurred while parsing your message. (Hover for details)", configuration);
|
||||
+ setIfUnexistant("error_occurred_console", "&cAn error occurred while parsing your message: {0}",
|
||||
+ configuration);
|
||||
+ setIfUnexistant("click_to_connect", "Click to connect to the server", configuration);
|
||||
+ setIfUnexistant("username_needed", "&cPlease follow this command by a user name.", configuration);
|
||||
+ setIfUnexistant("user_not_online", "&cThat user is not online.", configuration);
|
||||
+ setIfUnexistant("user_online_at", "&a{0} &ris online at {1}", configuration);
|
||||
+ setIfUnexistant("send_cmd_usage",
|
||||
+ "&cNot enough arguments, usage: /send <server|player|all|current> <target>", configuration);
|
||||
+ setIfUnexistant("player_only", "&cOnly in game players can use this command", configuration);
|
||||
+ setIfUnexistant("successfully_summoned", "&aSuccessfully summoned player(s)", configuration);
|
||||
+ setIfUnexistant("you_got_summoned", "&6Summoned to {0} by {1}", configuration);
|
||||
+ setIfUnexistant("command_perms_groups", "&6You have the following groups: {0}", configuration);
|
||||
+ setIfUnexistant("command_perms_permission", "&9- {0}", configuration);
|
||||
+ setIfUnexistant("command_ip", "&9IP of {0} is {1}", configuration);
|
||||
+
|
||||
+ // FlameCord
|
||||
+ setIfUnexistant("flamecord_reload", "&aAll files had been successfully reloaded!", configuration);
|
||||
+ setIfUnexistant("flamecord_help",
|
||||
+ "&aFlameCord&b {0}&a by&b LinsaFTW&a &&b Sammwy&r\n&e /flamecord reload&7 >&b Reloads FlameCord files!\n&e /flamecord help&7 >&b Shows this message!",
|
||||
+ configuration);
|
||||
+ setIfUnexistant("flamecord_nopermission", "&cYou don't have permission to do this!", configuration);
|
||||
+
|
||||
+ if (!configurationExists) {
|
||||
+ configurationProvider.save(configuration, configurationFile);
|
||||
+ }
|
||||
+
|
||||
+ for (final String key : configuration.getKeys()) {
|
||||
+ final Object value = configuration.get(key);
|
||||
+
|
||||
+ if (value instanceof String) {
|
||||
+ this.messages.put(key, ChatColor.translateAlternateColorCodes('&', (String) value));
|
||||
+ }
|
||||
+ }
|
||||
+ } catch (final IOException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public String getTranslation(final String name, final Object... args) {
|
||||
+ if (!messages.containsKey(name)) {
|
||||
+ logger.warning("[FlameCord] Tried to get translation '" + name
|
||||
+ + "' from messages.yml file but wasn't found. Please try resetting this file or report to a developer.");
|
||||
+ }
|
||||
+
|
||||
+ 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/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 000000000..e82c4844b
|
||||
index 00000000..e82c4844
|
||||
--- /dev/null
|
||||
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/ModulesConfiguration.java
|
||||
@@ -0,0 +1,94 @@
|
||||
@ -352,7 +220,7 @@ index 000000000..e82c4844b
|
||||
+ }
|
||||
+}
|
||||
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 bb39d31b8..28edad1a7 100644
|
||||
index bb39d31b..28edad1a 100644
|
||||
--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
|
||||
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
|
||||
@@ -1,5 +1,6 @@
|
||||
@ -364,17 +232,16 @@ index bb39d31b8..28edad1a7 100644
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
diff --git a/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
|
||||
new file mode 100644
|
||||
index 000000000..bf6f85386
|
||||
index 00000000..a323598e
|
||||
--- /dev/null
|
||||
+++ b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
|
||||
@@ -0,0 +1,61 @@
|
||||
@@ -0,0 +1,58 @@
|
||||
+package dev._2lstudios.flamecord.commands;
|
||||
+
|
||||
+import java.util.Collection;
|
||||
+import java.util.HashSet;
|
||||
+
|
||||
+import dev._2lstudios.flamecord.FlameCord;
|
||||
+import dev._2lstudios.flamecord.configuration.MessagesConfiguration;
|
||||
+import net.md_5.bungee.BungeeCord;
|
||||
+import net.md_5.bungee.api.CommandSender;
|
||||
+import net.md_5.bungee.api.chat.TextComponent;
|
||||
@ -393,7 +260,6 @@ index 000000000..bf6f85386
|
||||
+ @Override
|
||||
+ public void execute(final CommandSender sender, final String[] args) {
|
||||
+ final FlameCord flameCord = FlameCord.getInstance();
|
||||
+ final MessagesConfiguration messagesConfiguration = flameCord.getMessagesConfiguration();
|
||||
+
|
||||
+ if (sender.hasPermission("flamecord.usage")) {
|
||||
+ if (args.length > 0) {
|
||||
@ -410,27 +276,26 @@ index 000000000..bf6f85386
|
||||
+
|
||||
+ FlameCord.renew(bungeeCord.getLogger(), whitelistedAddresses);
|
||||
+ sender.sendMessage(TextComponent
|
||||
+ .fromLegacyText(messagesConfiguration.getTranslation("flamecord_reload")));
|
||||
+ .fromLegacyText("flamecord_reload"));
|
||||
+ break;
|
||||
+ }
|
||||
+ default: {
|
||||
+ sender.sendMessage(TextComponent.fromLegacyText(
|
||||
+ messagesConfiguration.getTranslation("flamecord_help", bungeeCord.getVersion())));
|
||||
+ sender.sendMessage(TextComponent.fromLegacyText("flamecord_help"));
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ sender.sendMessage(TextComponent
|
||||
+ .fromLegacyText(messagesConfiguration.getTranslation("flamecord_help", bungeeCord.getVersion())));
|
||||
+ .fromLegacyText("flamecord_help"));
|
||||
+ }
|
||||
+ } else {
|
||||
+ sender.sendMessage(TextComponent
|
||||
+ .fromLegacyText(messagesConfiguration.getTranslation("flamecord_nopermission")));
|
||||
+ .fromLegacyText("flamecord_nopermission"));
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
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 5d3857060..83d3e9edd 100644
|
||||
index 5d385706..ed3e3e12 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,10 @@ import com.google.common.collect.Sets;
|
||||
@ -505,26 +370,18 @@ index 5d3857060..83d3e9edd 100644
|
||||
if ( config.isForgeSupport() )
|
||||
{
|
||||
registerChannel( ForgeConstants.FML_TAG );
|
||||
@@ -573,16 +595,8 @@ public class BungeeCord extends ProxyServer
|
||||
@Override
|
||||
public String getTranslation(String name, Object... args)
|
||||
@@ -576,9 +598,7 @@ public class BungeeCord extends ProxyServer
|
||||
String translation = "<translation '" + name + "' missing>";
|
||||
try
|
||||
{
|
||||
- String translation = "<translation '" + name + "' missing>";
|
||||
- try
|
||||
- {
|
||||
- final String string = customBundle != null && customBundle.containsKey( name ) ? customBundle.getString( name ) : baseBundle.getString( name );
|
||||
-
|
||||
- translation = ( args.length == 0 ) ? string : MessageFormat.format( string, args );
|
||||
- } catch ( MissingResourceException ex )
|
||||
- {
|
||||
- }
|
||||
- return translation;
|
||||
+ // FlameCord - Use own translation system
|
||||
+ return FlameCord.getInstance().getMessagesConfiguration().getTranslation(name, args);
|
||||
+ translation = MessageFormat.format( customBundle != null && customBundle.containsKey( name ) ? customBundle.getString( name ) : baseBundle.getString( name ), args );
|
||||
} catch ( MissingResourceException ex )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -815,4 +829,56 @@ public class BungeeCord extends ProxyServer
|
||||
@@ -815,4 +835,56 @@ public class BungeeCord extends ProxyServer
|
||||
{
|
||||
return new BungeeTitle();
|
||||
}
|
||||
@ -582,7 +439,7 @@ index 5d3857060..83d3e9edd 100644
|
||||
+ }
|
||||
}
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
||||
index 7b99c466d..522bd93da 100644
|
||||
index 7b99c466..522bd93d 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
||||
@@ -1,6 +1,8 @@
|
||||
@ -604,7 +461,7 @@ index 7b99c466d..522bd93da 100644
|
||||
}
|
||||
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
||||
index 159119c13..7c4c8f8a0 100644
|
||||
index 159119c1..7c4c8f8a 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
|
||||
@@ -35,6 +35,7 @@ import net.md_5.bungee.api.SkinConfiguration;
|
||||
@ -638,7 +495,7 @@ index 159119c13..7c4c8f8a0 100644
|
||||
b.connect().addListener( listener );
|
||||
}
|
||||
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 e7542b1c1..deee607dc 100644
|
||||
index e7542b1c..deee607d 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
|
||||
@@ -16,6 +16,8 @@ import java.util.logging.Level;
|
||||
@ -660,7 +517,7 @@ index e7542b1c1..deee607dc 100644
|
||||
}
|
||||
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
|
||||
index 6cd71071e..423af854f 100644
|
||||
index 6cd71071..423af854 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/connection/PingHandler.java
|
||||
@@ -1,6 +1,7 @@
|
||||
@ -672,7 +529,7 @@ index 6cd71071e..423af854f 100644
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
|
||||
index b8e508552..7f18b5646 100644
|
||||
index b8e50855..7f18b564 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
|
||||
@@ -1,6 +1,8 @@
|
||||
@ -685,7 +542,7 @@ index b8e508552..7f18b5646 100644
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.handler.codec.CorruptedFrameException;
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
||||
index 4996a7b44..1d86aa63c 100644
|
||||
index 4996a7b4..1d86aa63 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
||||
@@ -1,6 +1,8 @@
|
||||
|
@ -0,0 +1,234 @@
|
||||
From b981e4156166237c90d6df9aa7dfda64c136ee36 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
|
||||
|
||||
|
||||
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
|
||||
index 2e317533..8957c79a 100644
|
||||
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
|
||||
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
|
||||
@@ -4,6 +4,7 @@ import java.util.Collection;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import dev._2lstudios.flamecord.configuration.FlameCordConfiguration;
|
||||
+import dev._2lstudios.flamecord.configuration.MessagesConfiguration;
|
||||
import dev._2lstudios.flamecord.configuration.ModulesConfiguration;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
@@ -17,6 +18,8 @@ public class FlameCord {
|
||||
@Getter
|
||||
private final ModulesConfiguration modulesConfiguration;
|
||||
@Getter
|
||||
+ private final MessagesConfiguration messagesConfiguration;
|
||||
+ @Getter
|
||||
private boolean running = true;
|
||||
|
||||
public static void renew(final Logger logger, final Collection<String> whitelistedAddresses) {
|
||||
@@ -34,5 +37,6 @@ public class FlameCord {
|
||||
|
||||
this.flameCordConfiguration = new FlameCordConfiguration(configurationProvider);
|
||||
this.modulesConfiguration = new ModulesConfiguration(configurationProvider);
|
||||
+ this.messagesConfiguration = new MessagesConfiguration(logger, configurationProvider);
|
||||
}
|
||||
}
|
||||
\ 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..ebfaa761
|
||||
--- /dev/null
|
||||
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/configuration/MessagesConfiguration.java
|
||||
@@ -0,0 +1,121 @@
|
||||
+package dev._2lstudios.flamecord.configuration;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.text.MessageFormat;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Map;
|
||||
+import java.util.logging.Logger;
|
||||
+
|
||||
+import net.md_5.bungee.api.ChatColor;
|
||||
+import net.md_5.bungee.config.Configuration;
|
||||
+import net.md_5.bungee.config.ConfigurationProvider;
|
||||
+
|
||||
+public class MessagesConfiguration {
|
||||
+ private final Logger logger;
|
||||
+ private final Map<String, String> messages = new HashMap<>();
|
||||
+
|
||||
+ public MessagesConfiguration(final Logger logger, final ConfigurationProvider configurationProvider) {
|
||||
+ this.logger = logger;
|
||||
+
|
||||
+ try {
|
||||
+ final String fileName = "./messages.yml";
|
||||
+ final File configurationFile = new File(fileName);
|
||||
+ final Configuration configuration;
|
||||
+ final boolean configurationExists = configurationFile.exists();
|
||||
+
|
||||
+ if (!configurationExists) {
|
||||
+ configuration = new Configuration();
|
||||
+ } else {
|
||||
+ configuration = configurationProvider.load(configurationFile);
|
||||
+ }
|
||||
+
|
||||
+ // BungeeCord
|
||||
+ setIfUnexistant("alert", "&8[&4Alert&8]&r ", configuration);
|
||||
+ setIfUnexistant("already_connected", "&cYou are already connected to this server!", configuration);
|
||||
+ setIfUnexistant("already_connected_proxy", "&cYou are already connected to this proxy!", configuration);
|
||||
+ setIfUnexistant("already_connecting", "&cAlready connecting to this server!", configuration);
|
||||
+ setIfUnexistant("command_list", "&a[{0}] &e({1}): &r{2}", configuration);
|
||||
+ setIfUnexistant("connect_kick", "&cKicked whilst connecting to {0}: {1}", configuration);
|
||||
+ setIfUnexistant("current_server", "&6You are currently connected to {0}.", configuration);
|
||||
+ setIfUnexistant("fallback_kick",
|
||||
+ "&cCould not connect to a default or fallback server, please try again later: {0}", configuration);
|
||||
+ setIfUnexistant("fallback_lobby",
|
||||
+ "&cCould not connect to target server, you have been moved to a fallback server.", configuration);
|
||||
+ setIfUnexistant("lost_connection", "[Proxy] Lost connection to server.", configuration);
|
||||
+ setIfUnexistant("mojang_fail", "Error occurred while contacting login servers, are they down?",
|
||||
+ configuration);
|
||||
+ setIfUnexistant("no_permission", "&cYou do not have permission to execute this command!", configuration);
|
||||
+ setIfUnexistant("no_server", "&cThe specified server does not exist.", configuration);
|
||||
+ setIfUnexistant("no_server_permission", "&cYou don't have permission to access this server.",
|
||||
+ configuration);
|
||||
+ setIfUnexistant("outdated_client", "Outdated client! Please use {0}", configuration);
|
||||
+ setIfUnexistant("outdated_server", "Outdated server! I'm still on {0}", configuration);
|
||||
+ setIfUnexistant("proxy_full", "Server is full!", configuration);
|
||||
+ setIfUnexistant("restart", "[Proxy] Proxy restarting.", configuration);
|
||||
+ setIfUnexistant("server_kick", "[Kicked] ", configuration);
|
||||
+ setIfUnexistant("server_list", "&6You may connect to the following servers at this time: ", configuration);
|
||||
+ setIfUnexistant("server_went_down",
|
||||
+ "&cThe server you were previously on went down, you have been connected to a fallback server",
|
||||
+ configuration);
|
||||
+ setIfUnexistant("total_players", "Total players online: {0}", configuration);
|
||||
+ setIfUnexistant("name_too_long", "Cannot have username longer than 16 characters", configuration);
|
||||
+ setIfUnexistant("name_invalid", "Username contains invalid characters.", configuration);
|
||||
+ setIfUnexistant("ping_cannot_connect", "&c[Bungee] Can't connect to server.", configuration);
|
||||
+ setIfUnexistant("offline_mode_player", "Not authenticated with Minecraft.net", configuration);
|
||||
+ setIfUnexistant("message_needed", "&cYou must supply a message.", configuration);
|
||||
+ setIfUnexistant("error_occurred_player",
|
||||
+ "&cAn error occurred while parsing your message. (Hover for details)", configuration);
|
||||
+ setIfUnexistant("error_occurred_console", "&cAn error occurred while parsing your message: {0}",
|
||||
+ configuration);
|
||||
+ setIfUnexistant("click_to_connect", "Click to connect to the server", configuration);
|
||||
+ setIfUnexistant("username_needed", "&cPlease follow this command by a user name.", configuration);
|
||||
+ setIfUnexistant("user_not_online", "&cThat user is not online.", configuration);
|
||||
+ setIfUnexistant("user_online_at", "&a{0} &ris online at {1}", configuration);
|
||||
+ setIfUnexistant("send_cmd_usage",
|
||||
+ "&cNot enough arguments, usage: /send <server|player|all|current> <target>", configuration);
|
||||
+ setIfUnexistant("player_only", "&cOnly in game players can use this command", configuration);
|
||||
+ setIfUnexistant("successfully_summoned", "&aSuccessfully summoned player(s)", configuration);
|
||||
+ setIfUnexistant("you_got_summoned", "&6Summoned to {0} by {1}", configuration);
|
||||
+ setIfUnexistant("command_perms_groups", "&6You have the following groups: {0}", configuration);
|
||||
+ setIfUnexistant("command_perms_permission", "&9- {0}", configuration);
|
||||
+ setIfUnexistant("command_ip", "&9IP of {0} is {1}", configuration);
|
||||
+
|
||||
+ // FlameCord
|
||||
+ setIfUnexistant("flamecord_reload", "&aAll files had been successfully reloaded!", configuration);
|
||||
+ setIfUnexistant("flamecord_help",
|
||||
+ "&aFlameCord&b {0}&a by&b LinsaFTW&a &&b Sammwy&r\n&e /flamecord reload&7 >&b Reloads FlameCord files!\n&e /flamecord help&7 >&b Shows this message!",
|
||||
+ configuration);
|
||||
+ setIfUnexistant("flamecord_nopermission", "&cYou don't have permission to do this!", configuration);
|
||||
+
|
||||
+ if (!configurationExists) {
|
||||
+ configurationProvider.save(configuration, configurationFile);
|
||||
+ }
|
||||
+
|
||||
+ for (final String key : configuration.getKeys()) {
|
||||
+ final Object value = configuration.get(key);
|
||||
+
|
||||
+ if (value instanceof String) {
|
||||
+ this.messages.put(key, ChatColor.translateAlternateColorCodes('&', (String) value));
|
||||
+ }
|
||||
+ }
|
||||
+ } catch (final IOException e) {
|
||||
+ e.printStackTrace();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public String getTranslation(final String name, final Object... args) {
|
||||
+ if (!messages.containsKey(name)) {
|
||||
+ logger.warning("[FlameCord] Tried to get translation '" + name
|
||||
+ + "' from messages.yml file but wasn't found. Please try resetting this file or report to a developer.");
|
||||
+ }
|
||||
+
|
||||
+ 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
|
||||
index a323598e..bf6f8538 100644
|
||||
--- a/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
|
||||
+++ b/proxy/src/main/java/dev/_2lstudios/flamecord/commands/FlameCordCommand.java
|
||||
@@ -4,6 +4,7 @@ import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
||||
import dev._2lstudios.flamecord.FlameCord;
|
||||
+import dev._2lstudios.flamecord.configuration.MessagesConfiguration;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@@ -22,6 +23,7 @@ private final BungeeCord bungeeCord;
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final String[] args) {
|
||||
final FlameCord flameCord = FlameCord.getInstance();
|
||||
+ final MessagesConfiguration messagesConfiguration = flameCord.getMessagesConfiguration();
|
||||
|
||||
if (sender.hasPermission("flamecord.usage")) {
|
||||
if (args.length > 0) {
|
||||
@@ -38,21 +40,22 @@ private final BungeeCord bungeeCord;
|
||||
|
||||
FlameCord.renew(bungeeCord.getLogger(), whitelistedAddresses);
|
||||
sender.sendMessage(TextComponent
|
||||
- .fromLegacyText("flamecord_reload"));
|
||||
+ .fromLegacyText(messagesConfiguration.getTranslation("flamecord_reload")));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
- sender.sendMessage(TextComponent.fromLegacyText("flamecord_help"));
|
||||
+ sender.sendMessage(TextComponent.fromLegacyText(
|
||||
+ messagesConfiguration.getTranslation("flamecord_help", bungeeCord.getVersion())));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(TextComponent
|
||||
- .fromLegacyText("flamecord_help"));
|
||||
+ .fromLegacyText(messagesConfiguration.getTranslation("flamecord_help", bungeeCord.getVersion())));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(TextComponent
|
||||
- .fromLegacyText("flamecord_nopermission"));
|
||||
+ .fromLegacyText(messagesConfiguration.getTranslation("flamecord_nopermission")));
|
||||
}
|
||||
}
|
||||
}
|
||||
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 ed3e3e12..83d3e9ed 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
@@ -595,14 +595,8 @@ public class BungeeCord extends ProxyServer
|
||||
@Override
|
||||
public String getTranslation(String name, Object... args)
|
||||
{
|
||||
- String translation = "<translation '" + name + "' missing>";
|
||||
- try
|
||||
- {
|
||||
- translation = MessageFormat.format( customBundle != null && customBundle.containsKey( name ) ? customBundle.getString( name ) : baseBundle.getString( name ), args );
|
||||
- } catch ( MissingResourceException ex )
|
||||
- {
|
||||
- }
|
||||
- return translation;
|
||||
+ // FlameCord - Use own translation system
|
||||
+ return FlameCord.getInstance().getMessagesConfiguration().getTranslation(name, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
--
|
||||
2.31.1
|
||||
|
@ -1,11 +1,11 @@
|
||||
From be41c59b3d676632710f10a1c88d655e12cbf48c Mon Sep 17 00:00:00 2001
|
||||
From 72f7c8263253c704f24a8cc7634a9760b7aa9717 Mon Sep 17 00:00:00 2001
|
||||
From: linsaftw <linsaftw@users.noreply.github.com>
|
||||
Date: Sat, 20 Mar 2021 12:36:25 -0300
|
||||
Subject: [PATCH] Fix ByteBuf memory leaks
|
||||
|
||||
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
||||
index 522bd93da..494375cd6 100644
|
||||
index 522bd93d..494375cd 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java
|
||||
@@ -284,9 +284,15 @@ public class ServerConnector extends PacketHandler
|
||||
@ -28,7 +28,7 @@ index 522bd93da..494375cd6 100644
|
||||
// Travertine end
|
||||
}
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
||||
index 474551d3e..8716d0c85 100644
|
||||
index 474551d3..8716d0c8 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
||||
@@ -294,12 +294,21 @@ public class DownstreamBridge extends PacketHandler
|
||||
@ -60,7 +60,7 @@ index 474551d3e..8716d0c85 100644
|
||||
{
|
||||
return;
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
||||
index a3a12e19b..214a1fd04 100644
|
||||
index a3a12e19..214a1fd0 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap.java
|
||||
@@ -143,11 +143,17 @@ public abstract class EntityMap
|
||||
@ -87,7 +87,7 @@ index a3a12e19b..214a1fd04 100644
|
||||
}
|
||||
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java
|
||||
index 6755fe845..21871d14a 100644
|
||||
index 6755fe84..21871d14 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/entitymap/EntityMap_1_7_6.java
|
||||
@@ -39,19 +39,27 @@ class EntityMap_1_7_6 extends EntityMap_1_7_2
|
||||
@ -130,7 +130,7 @@ index 6755fe845..21871d14a 100644
|
||||
}
|
||||
}
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java b/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java
|
||||
index cefa0206e..2cd5740ca 100644
|
||||
index cefa0206..2cd5740c 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/forge/ForgeUtils.java
|
||||
@@ -38,15 +38,27 @@ public class ForgeUtils
|
@ -1,11 +1,11 @@
|
||||
From e4a35d4d710e5781cb384e3ad08309f43c0f4b44 Mon Sep 17 00:00:00 2001
|
||||
From 47605cd0eafb06be49ce04bccfe2005790ac560d Mon Sep 17 00:00:00 2001
|
||||
From: PermisosDev <55111245+PermisosDev@users.noreply.github.com>
|
||||
Date: Thu, 15 Apr 2021 08:34:57 -0300
|
||||
Subject: [PATCH] Check if packetID is invalid.
|
||||
|
||||
|
||||
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 dd089abd..b3de7a7b 100644
|
||||
index 28edad1a..107855b8 100644
|
||||
--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
|
||||
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
|
||||
@@ -65,7 +65,10 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
||||
@ -21,5 +21,5 @@ index dd089abd..b3de7a7b 100644
|
||||
if ( packet != null )
|
||||
{
|
||||
--
|
||||
2.29.2.windows.3
|
||||
2.31.1
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 8ed0fb5643c225133bedd5b8336e736be07d0b48 Mon Sep 17 00:00:00 2001
|
||||
From c88d6b641bccb2dd9d22425723c59c64e17c6b4e Mon Sep 17 00:00:00 2001
|
||||
From: linsaftw <25271111+linsaftw@users.noreply.github.com>
|
||||
Date: Fri, 30 Apr 2021 22:54:44 -0300
|
||||
Subject: [PATCH] Firewall System
|
@ -1,4 +1,4 @@
|
||||
From a16eb2112438585594f672a6a310a3a7594374a5 Mon Sep 17 00:00:00 2001
|
||||
From bf23394fd07a8dddff698836be75d8744cb35e94 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
|
Loading…
Reference in New Issue
Block a user