perf: 优化代码
This commit is contained in:
@@ -32,10 +32,11 @@ import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Getter
|
||||
@SuppressWarnings({"unused", "CallToPrintStackTrace"})
|
||||
public abstract class BallAPI {
|
||||
/**
|
||||
* API 使用的通信频道
|
||||
@@ -336,7 +337,7 @@ public abstract class BallAPI {
|
||||
statement.executeUpdate();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
BallAPI.getInstance().getLogger().log(Level.SEVERE, "更新玩家缓存消息时遇到了一个异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,7 +13,6 @@ public enum BallActions {
|
||||
BallPlayerLogin,
|
||||
BallPlayerPostLogin,
|
||||
BallPlayerPreConnectServer,
|
||||
BallPlayerConnectServer,
|
||||
BallPlayerPostConnectServer,
|
||||
BallPlayerLogout,
|
||||
|
||||
|
@@ -1,27 +0,0 @@
|
||||
package cn.hamster3.mc.plugin.ball.common.event.player;
|
||||
|
||||
import cn.hamster3.mc.plugin.ball.common.entity.BallPlayerInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* 玩家进入子服
|
||||
* <p>
|
||||
* 仅在使用 velocity 代理端时才会触发这个事件
|
||||
*
|
||||
* @see BallPlayerPreConnectServerEvent 玩家准备进入子服
|
||||
* @see BallPlayerConnectServerEvent 玩家进入子服
|
||||
* @see BallPlayerPostConnectServerEvent 玩家已经进入子服
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class BallPlayerConnectServerEvent {
|
||||
@NotNull
|
||||
private final BallPlayerInfo playerInfo;
|
||||
@Nullable
|
||||
private final String from;
|
||||
@NotNull
|
||||
private final String to;
|
||||
}
|
@@ -9,7 +9,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
* 玩家已经进入子服
|
||||
*
|
||||
* @see BallPlayerPreConnectServerEvent 玩家准备进入子服
|
||||
* @see BallPlayerConnectServerEvent 玩家进入子服
|
||||
* @see BallPlayerPostConnectServerEvent 玩家已经进入子服
|
||||
*/
|
||||
@Data
|
||||
|
@@ -10,7 +10,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
* 玩家准备进入子服
|
||||
*
|
||||
* @see BallPlayerPreConnectServerEvent 玩家准备进入子服
|
||||
* @see BallPlayerConnectServerEvent 玩家进入子服
|
||||
* @see BallPlayerPostConnectServerEvent 玩家已经进入子服
|
||||
*/
|
||||
@Data
|
||||
|
@@ -83,11 +83,6 @@ public class BallCommonListener {
|
||||
BallAPI.getInstance().getEventBus().post(event);
|
||||
break;
|
||||
}
|
||||
case BallPlayerConnectServer: {
|
||||
BallPlayerConnectServerEvent event = CoreAPI.getInstance().getGson().fromJson(message.getContent(), BallPlayerConnectServerEvent.class);
|
||||
BallAPI.getInstance().getEventBus().post(event);
|
||||
break;
|
||||
}
|
||||
case BallPlayerPostConnectServer: {
|
||||
BallPlayerPostConnectServerEvent event = CoreAPI.getInstance().getGson().fromJson(message.getContent(), BallPlayerPostConnectServerEvent.class);
|
||||
BallAPI.getInstance().getEventBus().post(event);
|
||||
@@ -125,12 +120,6 @@ public class BallCommonListener {
|
||||
BallAPI.getInstance().getEventBus().post(event);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onBallPlayerConnectServer(BallPlayerConnectServerEvent event) {
|
||||
BallPlayerInfo info = event.getPlayerInfo();
|
||||
BallAPI.getInstance().getAllPlayerInfo().put(info.getUuid(), info);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onBallPlayerInfoUpdate(BallPlayerInfoUpdateEvent event) {
|
||||
BallPlayerInfo info = event.getPlayerInfo();
|
||||
|
Reference in New Issue
Block a user