refactor: 重构部分代码

This commit is contained in:
2023-01-20 11:05:12 +08:00
parent 48adbfe73d
commit a44f0be762
4 changed files with 21 additions and 21 deletions

View File

@@ -28,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID; import java.util.UUID;
public class BallBukkitListener extends BallListener implements Listener { public class BallBukkitListener implements Listener, BallListener {
public static final BallBukkitListener INSTANCE = new BallBukkitListener(); public static final BallBukkitListener INSTANCE = new BallBukkitListener();
private final HashMap<UUID, Pair<Location, DisplayMessage>> playerToLocation = new HashMap<>(); private final HashMap<UUID, Pair<Location, DisplayMessage>> playerToLocation = new HashMap<>();

View File

@@ -31,7 +31,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
public final class BallBungeeCordListener extends BallListener implements Listener { public final class BallBungeeCordListener implements Listener, BallListener {
public static final BallBungeeCordListener INSTANCE = new BallBungeeCordListener(); public static final BallBungeeCordListener INSTANCE = new BallBungeeCordListener();
private BallBungeeCordListener() { private BallBungeeCordListener() {

View File

@@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.logging.Level; import java.util.logging.Level;
public final class BallDebugListener extends BallListener { public final class BallDebugListener implements BallListener {
public static final BallDebugListener INSTANCE = new BallDebugListener(); public static final BallDebugListener INSTANCE = new BallDebugListener();
private BallDebugListener() { private BallDebugListener() {

View File

@@ -6,62 +6,62 @@ import cn.hamster3.mc.plugin.ball.common.event.server.ServerOfflineEvent;
import cn.hamster3.mc.plugin.ball.common.event.server.ServerOnlineEvent; import cn.hamster3.mc.plugin.ball.common.event.server.ServerOnlineEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public abstract class BallListener { public interface BallListener {
/** /**
* 该监听器的执行优先级 * 该监听器的执行优先级
* *
* @return 优先级 * @return 优先级
*/ */
public ListenerPriority getPriority() { default ListenerPriority getPriority() {
return ListenerPriority.NORMAL; return ListenerPriority.NORMAL;
} }
public void onConnectActive() { default void onConnectActive() {
} }
public void onMessageReceived(@NotNull BallMessageInfo event) { default void onMessageReceived(@NotNull BallMessageInfo event) {
} }
public void onMessageSend(@NotNull BallMessageInfo event) { default void onMessageSend(@NotNull BallMessageInfo event) {
} }
public void onConnectException(Throwable throwable) { default void onConnectException(Throwable throwable) {
} }
public void onServiceDead() { default void onServiceDead() {
} }
public void onBallPlayerPreLogin(@NotNull BallPlayerPreLoginEvent event) { default void onBallPlayerPreLogin(@NotNull BallPlayerPreLoginEvent event) {
} }
public void onBallPlayerLogin(@NotNull BallPlayerLoginEvent event) { default void onBallPlayerLogin(@NotNull BallPlayerLoginEvent event) {
} }
public void onBallPlayerPostLogin(@NotNull BallPlayerPostLoginEvent event) { default void onBallPlayerPostLogin(@NotNull BallPlayerPostLoginEvent event) {
} }
public void onBallPlayerPreConnectServer(@NotNull BallPlayerPreConnectServerEvent event) { default void onBallPlayerPreConnectServer(@NotNull BallPlayerPreConnectServerEvent event) {
} }
public void onBallPlayerConnectServer(@NotNull BallPlayerConnectServerEvent event) { default void onBallPlayerConnectServer(@NotNull BallPlayerConnectServerEvent event) {
} }
public void onBallPlayerPostConnectServer(@NotNull BallPlayerPostConnectServerEvent event) { default void onBallPlayerPostConnectServer(@NotNull BallPlayerPostConnectServerEvent event) {
} }
public void onBallPlayerLogout(@NotNull BallPlayerLogoutEvent event) { default void onBallPlayerLogout(@NotNull BallPlayerLogoutEvent event) {
} }
public void onBallPlayerInfoUpdate(@NotNull BallPlayerInfoUpdateEvent event) { default void onBallPlayerInfoUpdate(@NotNull BallPlayerInfoUpdateEvent event) {
} }
public void onBallPlayerChat(@NotNull BallPlayerChatEvent event) { default void onBallPlayerChat(@NotNull BallPlayerChatEvent event) {
} }
public void onServerOnline(@NotNull ServerOnlineEvent event) { default void onServerOnline(@NotNull ServerOnlineEvent event) {
} }
public void onServerOffline(@NotNull ServerOfflineEvent event) { default void onServerOffline(@NotNull ServerOfflineEvent event) {
} }
} }