Revert "style: 优化代码"

This reverts commit 68f7aef28f.
This commit is contained in:
2023-11-20 15:56:12 +08:00
parent 68f7aef28f
commit cd151470df
2 changed files with 14 additions and 10 deletions

View File

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

View File

@@ -22,17 +22,21 @@ public class BallDebugLogListener implements RedisPubSubListener<String, BallMes
@Override
public void subscribed(String channel, long count) {
BallAPI.getInstance().getLogger().info("已订阅 redis 频道: " + channel);
}
@Override
public void psubscribed(String pattern, long count) {
BallAPI.getInstance().getLogger().info("已订阅 redis 频道(正则): " + pattern);
}
@Override
public void unsubscribed(String channel, long count) {
BallAPI.getInstance().getLogger().info("已取消订阅 redis 频道: " + channel);
}
@Override
public void punsubscribed(String pattern, long count) {
BallAPI.getInstance().getLogger().info("已取消订阅 redis 频道(正则): " + pattern);
}
}