mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-23 04:28:01 +00:00
fixed the config for velocity, revert
This commit is contained in:
parent
bdda99bc81
commit
afac7a3d51
@ -11,7 +11,7 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class AbstractRedisBungeeListener<LE, PLE, PD, SC, PP, PM, PS, CN> {
|
public abstract class AbstractRedisBungeeListener<LE, PLE, PD, SC, PP, PM, PS> {
|
||||||
|
|
||||||
protected static final String ALREADY_LOGGED_IN = "§cYou are already logged on to this server. \n\nIt may help to try logging in again in a few minutes.\nIf this does not resolve your issue, please contact staff.";
|
protected static final String ALREADY_LOGGED_IN = "§cYou are already logged on to this server. \n\nIt may help to try logging in again in a few minutes.\nIf this does not resolve your issue, please contact staff.";
|
||||||
|
|
||||||
@ -28,9 +28,6 @@ public abstract class AbstractRedisBungeeListener<LE, PLE, PD, SC, PP, PM, PS, C
|
|||||||
|
|
||||||
public void onLogin(LE event) {}
|
public void onLogin(LE event) {}
|
||||||
|
|
||||||
|
|
||||||
public void onLogin(LE event, CN continuation) {}
|
|
||||||
|
|
||||||
public abstract void onPostLogin(PLE event);
|
public abstract void onPostLogin(PLE event);
|
||||||
|
|
||||||
public abstract void onPlayerDisconnect(PD event);
|
public abstract void onPlayerDisconnect(PD event);
|
||||||
|
@ -581,7 +581,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
|
|||||||
long value = Long.parseLong(rsc.hget("heartbeats", serverId));
|
long value = Long.parseLong(rsc.hget("heartbeats", serverId));
|
||||||
long redisTime = getRedisTime(rsc.time());
|
long redisTime = getRedisTime(rsc.time());
|
||||||
if (redisTime < value + 20) {
|
if (redisTime < value + 20) {
|
||||||
getLogger().severe("You have launched a possible impostor BungeeCord instance. Another instance is already running.");
|
getLogger().severe("You have launched a possible impostor Velocity / Bungeecord instance. Another instance is already running.");
|
||||||
getLogger().severe("For data consistency reasons, RedisBungee will now disable itself.");
|
getLogger().severe("For data consistency reasons, RedisBungee will now disable itself.");
|
||||||
getLogger().severe("If this instance is coming up from a crash, create a file in your RedisBungee plugins directory with the name 'restarted_from_crash.txt' and RedisBungee will not perform this check.");
|
getLogger().severe("If this instance is coming up from a crash, create a file in your RedisBungee plugins directory with the name 'restarted_from_crash.txt' and RedisBungee will not perform this check.");
|
||||||
throw new RuntimeException("Possible impostor instance!");
|
throw new RuntimeException("Possible impostor instance!");
|
||||||
|
@ -27,7 +27,7 @@ import redis.clients.jedis.Pipeline;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class RedisBungeeListener extends AbstractRedisBungeeListener<LoginEvent, PostLoginEvent, PlayerDisconnectEvent, ServerConnectedEvent, ProxyPingEvent, PluginMessageEvent, PubSubMessageEvent, Object> implements Listener {
|
public class RedisBungeeListener extends AbstractRedisBungeeListener<LoginEvent, PostLoginEvent, PlayerDisconnectEvent, ServerConnectedEvent, ProxyPingEvent, PluginMessageEvent, PubSubMessageEvent> implements Listener {
|
||||||
|
|
||||||
|
|
||||||
public RedisBungeeListener(RedisBungeePlugin<?> plugin, List<InetAddress> exemptAddresses) {
|
public RedisBungeeListener(RedisBungeePlugin<?> plugin, List<InetAddress> exemptAddresses) {
|
||||||
|
@ -13,6 +13,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public class RBUtils {
|
public class RBUtils {
|
||||||
|
|
||||||
|
public static final String VERSION = "0.8.x-idk-how";
|
||||||
private static final Gson gson = new Gson();
|
private static final Gson gson = new Gson();
|
||||||
|
|
||||||
protected static void createPlayer(Player player, Pipeline pipeline, boolean fireEvent) {
|
protected static void createPlayer(Player player, Pipeline pipeline, boolean fireEvent) {
|
||||||
|
@ -26,14 +26,13 @@ import redis.clients.jedis.Pipeline;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class RedisBungeeListener extends AbstractRedisBungeeListener<LoginEvent, PostLoginEvent, DisconnectEvent, ServerConnectedEvent, ProxyPingEvent, PluginMessageEvent, PubSubMessageEvent, Continuation> {
|
public class RedisBungeeListener extends AbstractRedisBungeeListener<LoginEvent, PostLoginEvent, DisconnectEvent, ServerConnectedEvent, ProxyPingEvent, PluginMessageEvent, PubSubMessageEvent> {
|
||||||
|
|
||||||
|
|
||||||
public RedisBungeeListener(RedisBungeePlugin<?> plugin, List<InetAddress> exemptAddresses) {
|
public RedisBungeeListener(RedisBungeePlugin<?> plugin, List<InetAddress> exemptAddresses) {
|
||||||
super(plugin, exemptAddresses);
|
super(plugin, exemptAddresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onLogin(LoginEvent event, Continuation continuation) {
|
public void onLogin(LoginEvent event, Continuation continuation) {
|
||||||
plugin.executeAsync(new RedisCallable<Void>(plugin) {
|
plugin.executeAsync(new RedisCallable<Void>(plugin) {
|
||||||
|
@ -7,9 +7,9 @@ import com.google.common.collect.ImmutableMultimap;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.imaginarycode.minecraft.redisbungee.commands.RedisBungeeCommands;
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent;
|
||||||
@ -26,16 +26,21 @@ import com.squareup.okhttp.OkHttpClient;
|
|||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||||
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||||
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import com.velocitypowered.api.scheduler.ScheduledTask;
|
import com.velocitypowered.api.scheduler.ScheduledTask;
|
||||||
|
import ninja.leaping.configurate.ConfigurationNode;
|
||||||
|
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||||
|
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import redis.clients.jedis.Jedis;
|
import redis.clients.jedis.Jedis;
|
||||||
import redis.clients.jedis.JedisPool;
|
import redis.clients.jedis.JedisPool;
|
||||||
import redis.clients.jedis.JedisPoolConfig;
|
import redis.clients.jedis.JedisPoolConfig;
|
||||||
import redis.clients.jedis.Pipeline;
|
import redis.clients.jedis.Pipeline;
|
||||||
import redis.clients.jedis.exceptions.JedisConnectionException;
|
import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
@ -44,10 +49,8 @@ import java.nio.file.Path;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
|
||||||
|
|
||||||
|
@Plugin(id = "redisbungee", name = "RedisBungee", version = RBUtils.VERSION, url = "https://github.com/ProxioDev/RedisBungee", authors = "ProxioDev")
|
||||||
public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
||||||
|
|
||||||
private static final Gson gson = new Gson();
|
private static final Gson gson = new Gson();
|
||||||
@ -408,7 +411,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
|||||||
getProxy().getEventManager().register(this, dataManager);
|
getProxy().getEventManager().register(this, dataManager);
|
||||||
psl = new PubSubListener(this);
|
psl = new PubSubListener(this);
|
||||||
getProxy().getScheduler().buildTask(this, psl).schedule();
|
getProxy().getScheduler().buildTask(this, psl).schedule();
|
||||||
integrityCheck = getProxy().getScheduler().buildTask(null,new Runnable() {
|
integrityCheck = getProxy().getScheduler().buildTask(this,new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try (Jedis tmpRsc = requestJedis()) {
|
try (Jedis tmpRsc = requestJedis()) {
|
||||||
@ -526,9 +529,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
|||||||
if (!getDataFolder().exists()) {
|
if (!getDataFolder().exists()) {
|
||||||
getDataFolder().mkdir();
|
getDataFolder().mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(getDataFolder(), "config.yml");
|
File file = new File(getDataFolder(), "config.yml");
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
try (InputStream in = getResourceAsStream("example_config.yml");
|
try (InputStream in = getResourceAsStream("example_config.yml");
|
||||||
@ -537,21 +538,22 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Configuration yamlConfiguration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
|
final YAMLConfigurationLoader yamlConfiguration = YAMLConfigurationLoader.builder().setFile(file).build();
|
||||||
|
|
||||||
final String redisServer = yamlConfiguration.getString("redis-server", "localhost");
|
ConfigurationNode node = yamlConfiguration.load();
|
||||||
final int redisPort = yamlConfiguration.getInt("redis-port", 6379);
|
final String redisServer = node.getNode("redis-server").getString();
|
||||||
final boolean useSSL = yamlConfiguration.getBoolean("useSSL", false);
|
final int redisPort = node.getNode("redis-port").getInt();
|
||||||
String redisPassword = yamlConfiguration.getString("redis-password", "");
|
final boolean useSSL = node.getNode("useSSL").getBoolean();
|
||||||
String serverId = yamlConfiguration.getString("server-id");
|
String redisPassword = node.getNode("redis-password").getString();
|
||||||
|
String serverId = node.getNode("server-id").getString();
|
||||||
|
|
||||||
// check redis password
|
// check redis password
|
||||||
if (redisPassword != null && (redisPassword.isEmpty() || redisPassword.equals("none"))) {
|
if (redisPassword != null && (redisPassword.isEmpty() || redisPassword.equals("none"))) {
|
||||||
redisPassword = null;
|
redisPassword = null;
|
||||||
getLogger().warning("INSECURE setup was detected Please set password for your redis instance.");
|
getLogger().warn("INSECURE setup was detected Please set password for your redis instance.");
|
||||||
}
|
}
|
||||||
if (!useSSL) {
|
if (!useSSL) {
|
||||||
getLogger().warning("INSECURE setup was detected Please setup ssl for your redis instance.");
|
getLogger().warn("INSECURE setup was detected Please setup ssl for your redis instance.");
|
||||||
}
|
}
|
||||||
// Configuration sanity checks.
|
// Configuration sanity checks.
|
||||||
if (serverId == null || serverId.isEmpty()) {
|
if (serverId == null || serverId.isEmpty()) {
|
||||||
@ -561,18 +563,22 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
|||||||
*/
|
*/
|
||||||
String genId = UUID.randomUUID().toString();
|
String genId = UUID.randomUUID().toString();
|
||||||
getLogger().info("Generated server id " + genId + " and saving it to config.");
|
getLogger().info("Generated server id " + genId + " and saving it to config.");
|
||||||
yamlConfiguration.set("server-id", genId);
|
node.getNode("server-id").setValue(genId);
|
||||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(yamlConfiguration, new File(getDataFolder(), "config.yml"));
|
yamlConfiguration.save(node);
|
||||||
getLogger().info("Server id was generated: " + serverId);
|
getLogger().info("Server id was generated: " + serverId);
|
||||||
} else {
|
} else {
|
||||||
getLogger().info("Loaded server id " + serverId + '.');
|
getLogger().info("Loaded server id " + serverId + '.');
|
||||||
}
|
}
|
||||||
this.configuration = new RedisBungeeConfiguration(serverId, yamlConfiguration.getStringList("exempt-ip-addresses"), yamlConfiguration.getBoolean("register-bungee-commands", true));
|
try {
|
||||||
|
this.configuration = new RedisBungeeConfiguration(serverId, node.getNode("exempt-ip-addresses").getList(TypeToken.of(String.class)), node.getNode("register-bungee-commands").getBoolean());
|
||||||
|
} catch (ObjectMappingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
if (redisServer != null && !redisServer.isEmpty()) {
|
if (redisServer != null && !redisServer.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
JedisPoolConfig config = new JedisPoolConfig();
|
JedisPoolConfig config = new JedisPoolConfig();
|
||||||
config.setMaxTotal(yamlConfiguration.getInt("max-redis-connections", 8));
|
config.setMaxTotal(node.getNode("max-redis-connections").getInt());
|
||||||
this.jedisSummoner = new SinglePoolJedisSummoner(new JedisPool(config, redisServer, redisPort, 0, redisPassword, useSSL));
|
this.jedisSummoner = new SinglePoolJedisSummoner(new JedisPool(config, redisServer, redisPort, 0, redisPassword, useSSL));
|
||||||
|
|
||||||
} catch (JedisConnectionException e) {
|
} catch (JedisConnectionException e) {
|
||||||
@ -591,7 +597,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
|||||||
long value = Long.parseLong(rsc.hget("heartbeats", serverId));
|
long value = Long.parseLong(rsc.hget("heartbeats", serverId));
|
||||||
long redisTime = getRedisTime(rsc.time());
|
long redisTime = getRedisTime(rsc.time());
|
||||||
if (redisTime < value + 20) {
|
if (redisTime < value + 20) {
|
||||||
getLogger().error("You have launched a possible impostor BungeeCord instance. Another instance is already running.");
|
getLogger().error("You have launched a possible impostor Velocity / Bungeecord instance. Another instance is already running.");
|
||||||
getLogger().error("For data consistency reasons, RedisBungee will now disable itself.");
|
getLogger().error("For data consistency reasons, RedisBungee will now disable itself.");
|
||||||
getLogger().error("If this instance is coming up from a crash, create a file in your RedisBungee plugins directory with the name 'restarted_from_crash.txt' and RedisBungee will not perform this check.");
|
getLogger().error("If this instance is coming up from a crash, create a file in your RedisBungee plugins directory with the name 'restarted_from_crash.txt' and RedisBungee will not perform this check.");
|
||||||
throw new RuntimeException("Possible impostor instance!");
|
throw new RuntimeException("Possible impostor instance!");
|
||||||
|
Loading…
Reference in New Issue
Block a user