mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-05 04:48:02 +00:00
remove lang system for commands
commands will be included in seperate plugins for each platforms. NOTE: because of this commands `Modules` will be used as example to access the API
This commit is contained in:
parent
c56a64bbc2
commit
1c36aa5418
@ -121,74 +121,6 @@ public class LangConfiguration {
|
||||
|
||||
}
|
||||
|
||||
public static class CommandMessages implements RegistrableMessages {
|
||||
|
||||
private final Locale defaultLocale;
|
||||
|
||||
// Common
|
||||
private final Map<Locale, Component> COMMON_PLAYER_NOT_FOUND;
|
||||
private final Map<Locale, Component> COMMON_PLAYER_NOT_SPECIFIED;
|
||||
private final Map<Locale, Component> COMMON_COMMAND_NOT_SPECIFIED;
|
||||
|
||||
public CommandMessages(Locale defaultLocale) {
|
||||
this.defaultLocale = defaultLocale;
|
||||
COMMON_PLAYER_NOT_FOUND = new HashMap<>();
|
||||
COMMON_COMMAND_NOT_SPECIFIED = new HashMap<>();
|
||||
COMMON_PLAYER_NOT_SPECIFIED = new HashMap<>();
|
||||
}
|
||||
|
||||
// probably split using :
|
||||
@Override
|
||||
public void register(String id, Locale locale, String miniMessage) {
|
||||
String[] splitId = id.split(":");
|
||||
//System.out.println(Arrays.toString(splitId) + " " + locale + miniMessage);
|
||||
switch (splitId[0]) {
|
||||
case "commands-common" -> {
|
||||
switch (splitId[1]) {
|
||||
case "player-not-found" -> COMMON_PLAYER_NOT_FOUND.put(locale, MiniMessage.miniMessage().deserialize(miniMessage));
|
||||
case "player-not-specified" -> COMMON_PLAYER_NOT_SPECIFIED.put(locale, MiniMessage.miniMessage().deserialize(miniMessage));
|
||||
case "command-not-specified" -> COMMON_COMMAND_NOT_SPECIFIED.put(locale, MiniMessage.miniMessage().deserialize(miniMessage));
|
||||
}
|
||||
}
|
||||
case "commands" -> {
|
||||
switch (splitId[1]) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Component playerNotFound(Locale locale) {
|
||||
if (COMMON_PLAYER_NOT_FOUND.containsKey(locale)) return COMMON_PLAYER_NOT_FOUND.get(locale);
|
||||
return COMMON_PLAYER_NOT_FOUND.get(defaultLocale);
|
||||
}
|
||||
public Component playerNotFound() {
|
||||
return playerNotFound(this.defaultLocale);
|
||||
}
|
||||
public Component commandNotSpecified(Locale locale) {
|
||||
if (COMMON_COMMAND_NOT_SPECIFIED.containsKey(locale)) return COMMON_COMMAND_NOT_SPECIFIED.get(locale);
|
||||
return COMMON_COMMAND_NOT_SPECIFIED.get(defaultLocale);
|
||||
}
|
||||
public Component commandNotSpecified() {
|
||||
return commandNotSpecified(this.defaultLocale);
|
||||
}
|
||||
public Component playerNotSpecified(Locale locale) {
|
||||
if (COMMON_PLAYER_NOT_SPECIFIED.containsKey(locale)) return COMMON_PLAYER_NOT_SPECIFIED.get(locale);
|
||||
return COMMON_PLAYER_NOT_SPECIFIED.get(defaultLocale);
|
||||
}
|
||||
public Component playerNotSpecified() {
|
||||
return playerNotSpecified(this.defaultLocale);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void test(Locale locale) {
|
||||
if (!(this.COMMON_PLAYER_NOT_FOUND.containsKey(locale) && this.COMMON_PLAYER_NOT_SPECIFIED.containsKey(locale) && this.COMMON_COMMAND_NOT_SPECIFIED.containsKey(locale))) {
|
||||
throwError(locale, "commands messages");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final Component redisBungeePrefix;
|
||||
|
||||
private final Locale defaultLanguage;
|
||||
@ -197,15 +129,11 @@ public class LangConfiguration {
|
||||
|
||||
private final Messages messages;
|
||||
|
||||
private final CommandMessages commandMessages;
|
||||
|
||||
|
||||
public LangConfiguration(Component redisBungeePrefix, Locale defaultLanguage, boolean useClientLanguage, Messages messages, CommandMessages commandMessages) {
|
||||
public LangConfiguration(Component redisBungeePrefix, Locale defaultLanguage, boolean useClientLanguage, Messages messages) {
|
||||
this.redisBungeePrefix = redisBungeePrefix;
|
||||
this.defaultLanguage = defaultLanguage;
|
||||
this.useClientLanguage = useClientLanguage;
|
||||
this.messages = messages;
|
||||
this.commandMessages = commandMessages;
|
||||
}
|
||||
|
||||
public Component redisBungeePrefix() {
|
||||
@ -224,7 +152,4 @@ public class LangConfiguration {
|
||||
return messages;
|
||||
}
|
||||
|
||||
public CommandMessages commandMessages() {
|
||||
return commandMessages;
|
||||
}
|
||||
}
|
||||
|
@ -20,23 +20,19 @@ public class RedisBungeeConfiguration {
|
||||
|
||||
private final String proxyId;
|
||||
private final List<InetAddress> exemptAddresses;
|
||||
private final boolean registerCommands;
|
||||
private final boolean overrideBungeeCommands;
|
||||
private final boolean kickWhenOnline;
|
||||
|
||||
private final boolean handleReconnectToLastServer;
|
||||
private final boolean handleMotd;
|
||||
|
||||
|
||||
public RedisBungeeConfiguration(String proxyId, List<String> exemptAddresses, boolean registerCommands, boolean overrideBungeeCommands, boolean kickWhenOnline, boolean handleReconnectToLastServer, boolean handleMotd) {
|
||||
public RedisBungeeConfiguration(String proxyId, List<String> exemptAddresses, boolean kickWhenOnline, boolean handleReconnectToLastServer, boolean handleMotd) {
|
||||
this.proxyId = proxyId;
|
||||
ImmutableList.Builder<InetAddress> addressBuilder = ImmutableList.builder();
|
||||
for (String s : exemptAddresses) {
|
||||
addressBuilder.add(InetAddresses.forString(s));
|
||||
}
|
||||
this.exemptAddresses = addressBuilder.build();
|
||||
this.registerCommands = registerCommands;
|
||||
this.overrideBungeeCommands = overrideBungeeCommands;
|
||||
this.kickWhenOnline = kickWhenOnline;
|
||||
this.handleReconnectToLastServer = handleReconnectToLastServer;
|
||||
this.handleMotd = handleMotd;
|
||||
@ -50,14 +46,6 @@ public class RedisBungeeConfiguration {
|
||||
return exemptAddresses;
|
||||
}
|
||||
|
||||
public boolean doRegisterCommands() {
|
||||
return registerCommands;
|
||||
}
|
||||
|
||||
public boolean doOverrideBungeeCommands() {
|
||||
return overrideBungeeCommands;
|
||||
}
|
||||
|
||||
public boolean kickWhenOnline() {
|
||||
return kickWhenOnline;
|
||||
}
|
||||
|
@ -43,8 +43,6 @@ public interface ConfigLoader extends GenericConfigLoader {
|
||||
node = yamlConfigurationFileLoader.load();
|
||||
}
|
||||
final boolean useSSL = node.getNode("useSSL").getBoolean(false);
|
||||
final boolean overrideBungeeCommands = node.getNode("override-bungee-commands").getBoolean(false);
|
||||
final boolean registerCommands = node.getNode("register-commands").getBoolean(false);
|
||||
final boolean kickWhenOnline = node.getNode("kick-when-online").getBoolean(true);
|
||||
String redisPassword = node.getNode("redis-password").getString("");
|
||||
String redisUsername = node.getNode("redis-username").getString("");
|
||||
@ -88,7 +86,7 @@ public interface ConfigLoader extends GenericConfigLoader {
|
||||
plugin.logInfo("handle reconnect to last server: {}", reconnectToLastServer);
|
||||
plugin.logInfo("handle motd: {}", handleMotd);
|
||||
|
||||
RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, registerCommands, overrideBungeeCommands, kickWhenOnline, reconnectToLastServer, handleMotd);
|
||||
RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, kickWhenOnline, reconnectToLastServer, handleMotd);
|
||||
Summoner<?> summoner;
|
||||
RedisBungeeMode redisBungeeMode;
|
||||
if (useSSL) {
|
||||
|
@ -44,16 +44,8 @@ public interface LangConfigLoader extends GenericConfigLoader {
|
||||
messages.register(key.toString(), Locale.forLanguageTag(childKey.toString()), childChildNode.getString());
|
||||
}));
|
||||
messages.test(defaultLocale);
|
||||
LangConfiguration.CommandMessages commandMessages = new LangConfiguration.CommandMessages(defaultLocale);
|
||||
|
||||
node.getNode("commands-common").getChildrenMap().forEach((key, childNode) -> childNode.getChildrenMap().forEach((childKey, childChildNode) -> {
|
||||
commandMessages.register("commands-common:" + key.toString(), Locale.forLanguageTag(childKey.toString()), childChildNode.getString());
|
||||
}));
|
||||
node.getNode("commands").getChildrenMap().forEach((key, childNode) -> childNode.getChildrenMap().forEach((childKey, childChildNode) -> childChildNode.getChildrenMap().forEach((childChildKey, childChildChildNode) -> {
|
||||
commandMessages.register("commands:" + key.toString() + ":" + childKey.toString(), Locale.forLanguageTag(childChildKey.toString()), childChildChildNode.getString());
|
||||
})));
|
||||
commandMessages.test(defaultLocale);
|
||||
onLangConfigLoad(new LangConfiguration(prefix, defaultLocale, useClientLocale, messages, commandMessages));
|
||||
onLangConfigLoad(new LangConfiguration(prefix, defaultLocale, useClientLocale, messages));
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,23 +56,6 @@ enable-jedis-pool-compatibility: false
|
||||
# max connections for the compatibility pool
|
||||
compatibility-max-connections: 3
|
||||
|
||||
# Register RedisBungee commands
|
||||
# if this disabled override-bungee-commands will be also disabled automatically.
|
||||
register-commands: false
|
||||
|
||||
# THIS IS BUNGEECORD ONLY OPTION!
|
||||
# Whether RedisBungee should install its version of regular BungeeCord commands.
|
||||
# Often, the RedisBungee commands are desired, but in some cases someone may wish to
|
||||
# override the commands using another plugin.
|
||||
#
|
||||
# If you are just denying access to the commands, RedisBungee uses the default BungeeCord
|
||||
# permissions - just deny them and access will be denied.
|
||||
#
|
||||
# Please note that with build 787+, most commands overridden by RedisBungee were moved to
|
||||
# modules, and these must be disabled or overridden yourself.
|
||||
# not used on velocity
|
||||
override-bungee-commands: false
|
||||
|
||||
# restore old login behavior before 0.9.0 update
|
||||
# enabled by default
|
||||
# when true: when player login and there is old player with same uuid it will get disconnected as result and new player will log in
|
||||
@ -94,4 +77,4 @@ exempt-ip-addresses: []
|
||||
reconnect-to-last-server: false
|
||||
|
||||
# Config version DO NOT CHANGE!!!!
|
||||
config-version: 2
|
||||
config-version: 3
|
||||
|
@ -47,61 +47,5 @@ messages:
|
||||
# placeholder <server> displays server name in the message.
|
||||
en-us: "<color:green>Connecting you to <server>..."
|
||||
|
||||
|
||||
# commands common messages
|
||||
commands-common:
|
||||
player-not-found:
|
||||
en-us: "<color:red>Player not found."
|
||||
player-not-specified:
|
||||
en-us: "<color:red>You must specify a player name."
|
||||
command-not-specified:
|
||||
en-us: "<color:red>You must specify a command to be run."
|
||||
|
||||
# commands
|
||||
commands:
|
||||
glist:
|
||||
single-player:
|
||||
en-us: "<color:yellow>1 player is currently online."
|
||||
players:
|
||||
en-us: "<color:yellow><players> players are currently online."
|
||||
notice:
|
||||
en-us: "<color:yellow>To see all players online, use /glist showall."
|
||||
find:
|
||||
found:
|
||||
en-us: "<color:blue><player> is on <server>."
|
||||
last-seen:
|
||||
online:
|
||||
en-us: "<color:green><player> is currently online."
|
||||
last-seen:
|
||||
en-us: "<color:blue><player> last seen on <date>."
|
||||
never-seen:
|
||||
en-us: "<color:red><player> has never been online."
|
||||
ip:
|
||||
connected-from:
|
||||
en-us: "<color:green><player> is connected from <ip>."
|
||||
proxy:
|
||||
connected-to:
|
||||
en-us: "<color:green><player> is connected to <proxy>."
|
||||
send-to-all:
|
||||
sent:
|
||||
en-us: "<color:green>Sent the command /<command> to all proxies."
|
||||
# note: server here means a proxy.
|
||||
server-id:
|
||||
message:
|
||||
en-us: "<color:yellow>You are on <color:blue><proxy>."
|
||||
# Same here too
|
||||
server-ids:
|
||||
message:
|
||||
en-us: "<color:yellow>All server IDs: <proxies>"
|
||||
plist:
|
||||
notice:
|
||||
en-us: "<color:yellow>To see all players online, use /plist <proxy> showall."
|
||||
not-valid-proxy:
|
||||
en-us: "<color:red><proxy> is not valid proxy. use /serverids for valid proxies"
|
||||
single-player:
|
||||
en-us: "<color:yellow>1 player is currently online on <proxy>."
|
||||
players:
|
||||
en-us: "<color:yellow><players> players are currently online on <proxy>."
|
||||
|
||||
# DO NOT CHANGE!!!!!
|
||||
config-version: 1
|
@ -249,12 +249,7 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
|
||||
// register plugin messages channel.
|
||||
getProxy().registerChannel("legacy:redisbungee");
|
||||
getProxy().registerChannel("RedisBungee");
|
||||
if (configuration.doRegisterCommands()) {
|
||||
// register commands
|
||||
if (configuration.doOverrideBungeeCommands()) {
|
||||
|
||||
}
|
||||
}
|
||||
// init the api
|
||||
this.api = new RedisBungeeAPI(this);
|
||||
apiStatic = (RedisBungeeAPI) this.api;
|
||||
|
@ -279,10 +279,6 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
||||
// register plugin messages
|
||||
IDENTIFIERS.forEach(getProxy().getChannelRegistrar()::register);
|
||||
|
||||
// register commands
|
||||
if (configuration.doRegisterCommands()) {
|
||||
|
||||
}
|
||||
logInfo("RedisBungee initialized successfully ");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user