Skip to content

Commit

Permalink
- Update jedis
Browse files Browse the repository at this point in the history
- Fix command TX hang
  • Loading branch information
Tig3r98 committed Aug 8, 2024
1 parent 6d7d376 commit 4890730
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>5.1.2</version>
<version>5.1.4</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import redis.clients.jedis.Jedis;

import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -51,7 +52,13 @@ public void execute(CommandSender commandSender, String[] args) {
return;
}
ForestRedisBungee.getInstance().logger().info("[TX] Redis command: " + args[1] + " -> '" + cmd + "'");
RedisManager.getAPI().getJedis().publish(args[1], cmd);
ForestRedisBungee.getInstance().runAsync(() -> {
try (Jedis jedis = RedisManager.getAPI().getJedis()) {
jedis.publish(args[1], cmd);
} catch (Exception e) {
ForestRedisBungee.getInstance().logger().warning("Could not send message to the Redis server!");
}
});
} else {
commandSender.sendMessage("§2["+ForestRedisBungee.getInstance().getDescription().getName()+"] §7Channel '"+args[1]+"' is not whitelisted for sending commands!");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package cz.foresttech.forestredis.spigot.commands;

import cz.foresttech.forestredis.bungee.ForestRedisBungee;
import cz.foresttech.forestredis.shared.RedisManager;
import cz.foresttech.forestredis.shared.adapter.CommandChannel;
import cz.foresttech.forestredis.spigot.ForestRedisSpigot;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import redis.clients.jedis.Jedis;

import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -48,7 +50,13 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
return true;
}
ForestRedisSpigot.getInstance().logger().info("[TX] Redis command: " + args[1] + " -> '" + cmd + "'");
RedisManager.getAPI().getJedis().publish(args[1], cmd);
ForestRedisSpigot.getInstance().runAsync(() -> {
try (Jedis jedis = RedisManager.getAPI().getJedis()) {
jedis.publish(args[1], cmd);
} catch (Exception e) {
ForestRedisSpigot.getInstance().logger().warning("Could not send message to the Redis server!");
}
});
} else {
commandSender.sendMessage("§2["+ForestRedisSpigot.getInstance().getDescription().getName()+"] §7Channel '"+args[1]+"' is not whitelisted for sending commands!");
}
Expand Down

0 comments on commit 4890730

Please sign in to comment.