mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-26 01:59:20 +00:00
Merge remote-tracking branch 'origin/master' into future/nms
This commit is contained in:
@@ -341,8 +341,9 @@ public class DataManager {
|
||||
// Remove the old data if it exists
|
||||
PlayerData oldData = null;
|
||||
for (PlayerData data : playerData) {
|
||||
if (data.getPlayerUUID() == newData.getPlayerUUID()) {
|
||||
if (data.getPlayerUUID().equals(newData.getPlayerUUID())) {
|
||||
oldData = data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (oldData != null) {
|
||||
@@ -361,7 +362,7 @@ public class DataManager {
|
||||
*/
|
||||
public PlayerData getPlayer(UUID playerUUID) {
|
||||
for (PlayerData data : playerData) {
|
||||
if (data.getPlayerUUID() == playerUUID) {
|
||||
if (data.getPlayerUUID().equals(playerUUID)) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +77,9 @@ public class MySQL extends Database {
|
||||
dataSource.setUsername(username);
|
||||
dataSource.setPassword(password);
|
||||
|
||||
// Set data source driver path
|
||||
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
|
||||
|
||||
// Set various additional parameters
|
||||
dataSource.setMaximumPoolSize(hikariMaximumPoolSize);
|
||||
dataSource.setMinimumIdle(hikariMinimumIdle);
|
||||
|
||||
@@ -2,6 +2,7 @@ package me.william278.husksync.redis;
|
||||
|
||||
import me.william278.husksync.Settings;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisClientConfig;
|
||||
import redis.clients.jedis.JedisPubSub;
|
||||
import redis.clients.jedis.exceptions.JedisException;
|
||||
|
||||
@@ -17,13 +18,15 @@ public abstract class RedisListener {
|
||||
|
||||
/**
|
||||
* Handle an incoming {@link RedisMessage}
|
||||
*
|
||||
* @param message The {@link RedisMessage} to handle
|
||||
*/
|
||||
public abstract void handleMessage(RedisMessage message);
|
||||
|
||||
/**
|
||||
* Log to console
|
||||
* @param level The {@link Level} to log
|
||||
*
|
||||
* @param level The {@link Level} to log
|
||||
* @param message Message to log
|
||||
*/
|
||||
public abstract void log(Level level, String message);
|
||||
@@ -32,15 +35,15 @@ public abstract class RedisListener {
|
||||
* Start the Redis listener
|
||||
*/
|
||||
public final void listen() {
|
||||
try(Jedis jedis = new Jedis(Settings.redisHost, Settings.redisPort)) {
|
||||
try (Jedis jedis = new Jedis(Settings.redisHost, Settings.redisPort)) {
|
||||
final String jedisPassword = Settings.redisPassword;
|
||||
if (!jedisPassword.equals("")) {
|
||||
jedis.auth(jedisPassword);
|
||||
}
|
||||
jedis.connect();
|
||||
if (jedis.isConnected()) {
|
||||
if (!jedisPassword.equals("")) {
|
||||
jedis.auth(jedisPassword);
|
||||
}
|
||||
isActiveAndEnabled = true;
|
||||
log(Level.INFO,"Enabled Redis listener successfully!");
|
||||
log(Level.INFO, "Enabled Redis listener successfully!");
|
||||
new Thread(() -> jedis.subscribe(new JedisPubSub() {
|
||||
@Override
|
||||
public void onMessage(String channel, String message) {
|
||||
|
||||
@@ -63,10 +63,10 @@ public class RedisMessage {
|
||||
public void send() throws IOException {
|
||||
try (Jedis publisher = new Jedis(Settings.redisHost, Settings.redisPort)) {
|
||||
final String jedisPassword = Settings.redisPassword;
|
||||
publisher.connect();
|
||||
if (!jedisPassword.equals("")) {
|
||||
publisher.auth(jedisPassword);
|
||||
}
|
||||
publisher.connect();
|
||||
publisher.publish(REDIS_CHANNEL, getFullMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user