style: 优化代码
This commit is contained in:
@@ -39,6 +39,7 @@ public abstract class BallAPI {
|
||||
/**
|
||||
* API 实例
|
||||
*/
|
||||
@Getter
|
||||
protected static BallAPI instance;
|
||||
@NotNull
|
||||
protected final Map<String, BallServerInfo> serverInfo;
|
||||
@@ -131,15 +132,6 @@ public abstract class BallAPI {
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 API 实例
|
||||
*
|
||||
* @return API 实例
|
||||
*/
|
||||
public static BallAPI getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
protected void enable() throws SQLException, InterruptedException {
|
||||
if (enabled) {
|
||||
return;
|
||||
|
@@ -10,10 +10,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class BallConfig {
|
||||
@NotNull
|
||||
private BallServerInfo localInfo;
|
||||
|
||||
@NotNull
|
||||
private String host;
|
||||
private int port;
|
||||
|
||||
private int eventLoopThread;
|
||||
}
|
||||
|
@@ -12,16 +12,19 @@ import org.jetbrains.annotations.NotNull;
|
||||
@AllArgsConstructor
|
||||
@SuppressWarnings("unused")
|
||||
public class BallBlockPos {
|
||||
@NotNull
|
||||
private String serverID;
|
||||
@NotNull
|
||||
private String worldName;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
public static BallBlockPos fromJson(String json) {
|
||||
public static BallBlockPos fromJson(@NotNull String json) {
|
||||
return CoreAPI.getInstance().getGson().fromJson(json, BallBlockPos.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JsonElement toJson() {
|
||||
return CoreAPI.getInstance().getGson().toJsonTree(this);
|
||||
}
|
||||
|
@@ -12,7 +12,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
@AllArgsConstructor
|
||||
@SuppressWarnings("unused")
|
||||
public class BallLocation {
|
||||
@NotNull
|
||||
private String serverID;
|
||||
@NotNull
|
||||
private String worldName;
|
||||
private double x;
|
||||
private double y;
|
||||
@@ -21,10 +23,11 @@ public class BallLocation {
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
|
||||
public static BallLocation fromJson(String json) {
|
||||
public static BallLocation fromJson(@NotNull String json) {
|
||||
return CoreAPI.getInstance().getGson().fromJson(json, BallLocation.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JsonElement toJson() {
|
||||
return CoreAPI.getInstance().getGson().toJsonTree(this);
|
||||
}
|
||||
|
@@ -113,6 +113,7 @@ public class BallMessageInfo {
|
||||
* @param <T> 对象类型
|
||||
* @return Java 对象
|
||||
*/
|
||||
@NotNull
|
||||
public <T> T getContentAs(@NotNull Class<T> clazz) {
|
||||
return CoreAPI.getInstance().getGson().fromJson(content, clazz);
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package cn.hamster3.mc.plugin.ball.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -10,7 +11,7 @@ import java.util.UUID;
|
||||
* 玩家信息
|
||||
*/
|
||||
@Data
|
||||
@NotNull
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BallPlayerInfo {
|
||||
/**
|
||||
|
Reference in New Issue
Block a user