@@ -70,7 +70,7 @@ public abstract class BallAPI {
|
|||||||
protected void enable() throws SQLException, InterruptedException {
|
protected void enable() throws SQLException, InterruptedException {
|
||||||
BallServerInfo localInfo = getLocalServerInfo();
|
BallServerInfo localInfo = getLocalServerInfo();
|
||||||
|
|
||||||
try (Connection connection = getDatasource().getConnection()) {
|
try (Connection connection = BallAPI.getInstance().getDatasource().getConnection()) {
|
||||||
try (Statement statement = connection.createStatement()) {
|
try (Statement statement = connection.createStatement()) {
|
||||||
statement.execute("CREATE TABLE IF NOT EXISTS `hamster_ball_player_info`(" +
|
statement.execute("CREATE TABLE IF NOT EXISTS `hamster_ball_player_info`(" +
|
||||||
"`uuid` CHAR(36) PRIMARY KEY," +
|
"`uuid` CHAR(36) PRIMARY KEY," +
|
||||||
@@ -143,7 +143,7 @@ public abstract class BallAPI {
|
|||||||
protected void disable() throws SQLException, InterruptedException {
|
protected void disable() throws SQLException, InterruptedException {
|
||||||
sendBallMessage(BALL_CHANNEL, new BallMessage(BallActions.ServerOffline.name(), new ServerOffline(getLocalServerInfo())), true);
|
sendBallMessage(BALL_CHANNEL, new BallMessage(BallActions.ServerOffline.name(), new ServerOffline(getLocalServerInfo())), true);
|
||||||
|
|
||||||
try (Connection connection = getDatasource().getConnection()) {
|
try (Connection connection = BallAPI.getInstance().getDatasource().getConnection()) {
|
||||||
try (PreparedStatement statement = connection.prepareStatement(
|
try (PreparedStatement statement = connection.prepareStatement(
|
||||||
"DELETE FROM `hamster_ball_server_info` WHERE `id`=?;"
|
"DELETE FROM `hamster_ball_server_info` WHERE `id`=?;"
|
||||||
)) {
|
)) {
|
||||||
@@ -288,7 +288,7 @@ public abstract class BallAPI {
|
|||||||
if (!cache) {
|
if (!cache) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try (Connection connection = getDatasource().getConnection()) {
|
try (Connection connection = BallAPI.getInstance().getDatasource().getConnection()) {
|
||||||
try (PreparedStatement statement = connection.prepareStatement(
|
try (PreparedStatement statement = connection.prepareStatement(
|
||||||
"INSERT INTO `hamster_ball_cached_message` VALUES(?, ?);"
|
"INSERT INTO `hamster_ball_cached_message` VALUES(?, ?);"
|
||||||
)) {
|
)) {
|
||||||
@@ -326,7 +326,7 @@ public abstract class BallAPI {
|
|||||||
if (info != null && info.isOnline()) {
|
if (info != null && info.isOnline()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try (Connection connection = getDatasource().getConnection()) {
|
try (Connection connection = BallAPI.getInstance().getDatasource().getConnection()) {
|
||||||
try (PreparedStatement statement = connection.prepareStatement(
|
try (PreparedStatement statement = connection.prepareStatement(
|
||||||
"INSERT INTO `hamster_ball_cached_message` VALUES(?, ?);"
|
"INSERT INTO `hamster_ball_cached_message` VALUES(?, ?);"
|
||||||
)) {
|
)) {
|
||||||
@@ -646,27 +646,27 @@ public abstract class BallAPI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void message(String pattern, String channel, BallMessage message) {
|
public void message(String pattern, String channel, BallMessage message) {
|
||||||
onMessage(channel, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribed(String channel, long count) {
|
public void subscribed(String channel, long count) {
|
||||||
getLogger().info("已订阅 redis 频道: " + channel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void psubscribed(String pattern, long count) {
|
public void psubscribed(String pattern, long count) {
|
||||||
getLogger().info("已订阅 redis 频道(正则): " + pattern);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unsubscribed(String channel, long count) {
|
public void unsubscribed(String channel, long count) {
|
||||||
getLogger().info("已取消订阅 redis 频道: " + channel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void punsubscribed(String pattern, long count) {
|
public void punsubscribed(String pattern, long count) {
|
||||||
getLogger().info("已取消订阅 redis 频道(正则): " + pattern);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,17 +22,21 @@ public class BallDebugLogListener implements RedisPubSubListener<String, BallMes
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void subscribed(String channel, long count) {
|
public void subscribed(String channel, long count) {
|
||||||
|
BallAPI.getInstance().getLogger().info("已订阅 redis 频道: " + channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void psubscribed(String pattern, long count) {
|
public void psubscribed(String pattern, long count) {
|
||||||
|
BallAPI.getInstance().getLogger().info("已订阅 redis 频道(正则): " + pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unsubscribed(String channel, long count) {
|
public void unsubscribed(String channel, long count) {
|
||||||
|
BallAPI.getInstance().getLogger().info("已取消订阅 redis 频道: " + channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void punsubscribed(String pattern, long count) {
|
public void punsubscribed(String pattern, long count) {
|
||||||
|
BallAPI.getInstance().getLogger().info("已取消订阅 redis 频道(正则): " + pattern);
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user