2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2026-04-08 16:10:26 +00:00

remove all old messages code, new lang file

This commit is contained in:
2023-09-10 20:39:45 +04:00
parent f6e1ca65bf
commit e897a60976
7 changed files with 45 additions and 48 deletions

View File

@@ -352,7 +352,7 @@ public abstract class AbstractRedisBungeeAPI {
* @since 0.8.0
* @deprecated
*/
@Deprecated
public void kickPlayer(String playerName, String message) {
kickPlayer(getUuidFromName(playerName), message);
}

View File

@@ -89,7 +89,7 @@ public interface ConfigLoader {
boolean reconnectToLastServer = node.getNode("reconnect-to-last-server").getBoolean();
boolean handleMotd = node.getNode("handle-motd").getBoolean(true);
RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, registerLegacyCommands, overrideBungeeCommands, getMessagesFromPath(createMessagesFile(dataFolder)), kickWhenOnline, reconnectToLastServer, handleMotd);
RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, registerLegacyCommands, overrideBungeeCommands, kickWhenOnline, reconnectToLastServer, handleMotd);
Summoner<?> summoner;
RedisBungeeMode redisBungeeMode;
if (node.getNode("cluster-mode-enabled").getBoolean(false)) {
@@ -137,30 +137,6 @@ public interface ConfigLoader {
void onConfigLoad(RedisBungeeConfiguration configuration, Summoner<?> summoner, RedisBungeeMode mode);
default ImmutableMap<RedisBungeeConfiguration.MessageType, String> getMessagesFromPath(Path path) throws IOException {
final YAMLConfigurationLoader yamlConfigurationFileLoader = YAMLConfigurationLoader.builder().setPath(path).build();
ConfigurationNode node = yamlConfigurationFileLoader.load();
HashMap<RedisBungeeConfiguration.MessageType, String> messages = new HashMap<>();
messages.put(RedisBungeeConfiguration.MessageType.LOGGED_IN_OTHER_LOCATION, node.getNode("logged-in-other-location").getString("§cLogged in from another location."));
messages.put(RedisBungeeConfiguration.MessageType.ALREADY_LOGGED_IN, node.getNode("already-logged-in").getString("§cYou are already logged in!"));
return ImmutableMap.copyOf(messages);
}
default Path createMessagesFile(Path dataFolder) throws IOException {
if (Files.notExists(dataFolder)) {
Files.createDirectory(dataFolder);
}
Path file = dataFolder.resolve("messages.yml");
if (Files.notExists(file)) {
try (InputStream in = getClass().getClassLoader().getResourceAsStream("messages.yml")) {
Files.createFile(file);
assert in != null;
Files.copy(in, file, StandardCopyOption.REPLACE_EXISTING);
}
}
return file;
}
default Path createConfigFile(Path dataFolder) throws IOException {
if (Files.notExists(dataFolder)) {
Files.createDirectory(dataFolder);

View File

@@ -13,18 +13,13 @@ package com.imaginarycode.minecraft.redisbungee.api.config;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.net.InetAddresses;
import net.kyori.adventure.text.Component;
import java.net.InetAddress;
import java.util.List;
public class RedisBungeeConfiguration {
public enum MessageType {
LOGGED_IN_OTHER_LOCATION,
ALREADY_LOGGED_IN
}
private final ImmutableMap<MessageType, String> messages;
public static final int CONFIG_VERSION = 2;
private final String proxyId;
private final List<InetAddress> exemptAddresses;
@@ -36,9 +31,8 @@ public class RedisBungeeConfiguration {
private final boolean handleMotd;
public RedisBungeeConfiguration(String proxyId, List<String> exemptAddresses, boolean registerLegacyCommands, boolean overrideBungeeCommands, ImmutableMap<MessageType, String> messages, boolean kickWhenOnline, boolean handleReconnectToLastServer, boolean handleMotd) {
public RedisBungeeConfiguration(String proxyId, List<String> exemptAddresses, boolean registerLegacyCommands, boolean overrideBungeeCommands, boolean kickWhenOnline, boolean handleReconnectToLastServer, boolean handleMotd) {
this.proxyId = proxyId;
this.messages = messages;
ImmutableList.Builder<InetAddress> addressBuilder = ImmutableList.builder();
for (String s : exemptAddresses) {
addressBuilder.add(InetAddresses.forString(s));
@@ -67,10 +61,6 @@ public class RedisBungeeConfiguration {
return overrideBungeeCommands;
}
public String getMessage(MessageType messageType) {
return this.messages.get(messageType);
}
public boolean kickWhenOnline() {
return kickWhenOnline;
}

View File

@@ -0,0 +1,34 @@
# this config file is for messages / Languages
# Note 1: use MiniMessage format https://docs.advntr.dev/minimessage/format.html for colors etc... Legacy chat color is not supported.
# Mote 2: Language codes that are used is ISO 639-1, here is full list https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
# example:
# Format:
# message_id:
# <2 char language code>: "MiniMessage color and your text."
# lets assume we want to add arabic language.
# logged-in-other-location:
# en: "<color:red>You logged in from another location!"
# ar: "<color:red>لقد اتصلت من مكان اخر"
# Prefix if ever used.
redis-bungee-prefix: "<color:red>[<color:yellow>Redis<color:red>Bungee]"
# en is English, Which is the default language used when a language for a message isn't defined.
# Warning: if en or set default language wasn't defined in the config for all messages, plugin will not load.
# set the default language
default-language: en
# send language based on client sent settings
# https://minecraft.fandom.com/wiki/Language
use-client-language: true
logged-in-other-location:
en: "<color:red>You logged in from another location!"
already-logged-in:
en: "<color:red>You are already logged in!"

View File

@@ -1,5 +0,0 @@
# this config file is for messages for players and command messages
# Note this uses MiniMessage format https://docs.advntr.dev/minimessage/format.html
logged-in-other-location: "<color:red>You logged in from another location!"
already-logged-in: "<color:red>You are already logged in!"