feat: 适配Core更新

This commit is contained in:
2023-05-30 04:31:19 +08:00
parent 1a59268a7d
commit 537c6eb0a7
10 changed files with 73 additions and 65 deletions

View File

@@ -2,7 +2,7 @@ package cn.hamster3.mc.plugin.ball.bukkit.data;
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
import cn.hamster3.mc.plugin.ball.common.data.BallBlockPos;
import cn.hamster3.mc.plugin.core.common.constant.CoreConstantObjects;
import cn.hamster3.mc.plugin.core.common.util.CoreUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
@@ -51,7 +51,7 @@ public class BukkitBlockPos extends BallBlockPos {
}
public static BukkitBlockPos fromJson(String json) {
return CoreConstantObjects.GSON.fromJson(json, BukkitBlockPos.class);
return CoreUtils.GSON.fromJson(json, BukkitBlockPos.class);
}
@NotNull

View File

@@ -2,7 +2,7 @@ package cn.hamster3.mc.plugin.ball.bukkit.data;
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
import cn.hamster3.mc.plugin.ball.common.data.BallLocation;
import cn.hamster3.mc.plugin.core.common.constant.CoreConstantObjects;
import cn.hamster3.mc.plugin.core.common.util.CoreUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
@@ -53,7 +53,7 @@ public class BukkitLocation extends BallLocation {
}
public static BukkitLocation fromJson(String json) {
return CoreConstantObjects.GSON.fromJson(json, BukkitLocation.class);
return CoreUtils.GSON.fromJson(json, BukkitLocation.class);
}
@NotNull

View File

@@ -9,8 +9,8 @@ import cn.hamster3.mc.plugin.ball.common.event.operate.*;
import cn.hamster3.mc.plugin.ball.common.listener.BallListener;
import cn.hamster3.mc.plugin.core.bukkit.api.CoreBukkitAPI;
import cn.hamster3.mc.plugin.core.common.api.CoreAPI;
import cn.hamster3.mc.plugin.core.common.constant.CoreConstantObjects;
import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
import cn.hamster3.mc.plugin.core.common.util.CoreUtils;
import cn.hamster3.mc.plugin.core.common.util.Pair;
import net.kyori.adventure.audience.Audience;
import org.bukkit.Bukkit;
@@ -43,14 +43,14 @@ public class BallBukkitListener implements Listener, BallListener {
public void onMessageReceived(@NotNull BallMessageInfo info) {
switch (info.getAction()) {
case BroadcastPlayerMessageEvent.ACTION: {
BroadcastPlayerMessageEvent event = CoreConstantObjects.GSON.fromJson(info.getContent(), BroadcastPlayerMessageEvent.class);
BroadcastPlayerMessageEvent event = CoreUtils.GSON.fromJson(info.getContent(), BroadcastPlayerMessageEvent.class);
DisplayMessage message = event.getMessage();
Audience audience = CoreAPI.getInstance().getAudienceProvider().all();
message.show(audience);
break;
}
case DispatchConsoleCommandEvent.ACTION: {
DispatchConsoleCommandEvent event = CoreConstantObjects.GSON.fromJson(info.getContent(), DispatchConsoleCommandEvent.class);
DispatchConsoleCommandEvent event = CoreUtils.GSON.fromJson(info.getContent(), DispatchConsoleCommandEvent.class);
if (event.getType() != null && event.getType() != BallServerType.GAME) {
return;
}
@@ -61,7 +61,7 @@ public class BallBukkitListener implements Listener, BallListener {
break;
}
case DispatchPlayerCommandEvent.ACTION: {
DispatchPlayerCommandEvent event = CoreConstantObjects.GSON.fromJson(info.getContent(), DispatchPlayerCommandEvent.class);
DispatchPlayerCommandEvent event = CoreUtils.GSON.fromJson(info.getContent(), DispatchPlayerCommandEvent.class);
if (event.getType() != null && event.getType() != BallServerType.GAME) {
return;
}
@@ -79,7 +79,7 @@ public class BallBukkitListener implements Listener, BallListener {
break;
}
case SendPlayerToLocationEvent.ACTION: {
SendPlayerToLocationEvent event = CoreConstantObjects.GSON.fromJson(info.getContent(), SendPlayerToLocationEvent.class);
SendPlayerToLocationEvent event = CoreUtils.GSON.fromJson(info.getContent(), SendPlayerToLocationEvent.class);
BukkitLocation location = new BukkitLocation(event.getLocation());
if (BallAPI.getInstance().isLocalServer(location.getServerID())) {
for (UUID uuid : event.getSendPlayerUUID()) {
@@ -100,7 +100,7 @@ public class BallBukkitListener implements Listener, BallListener {
break;
}
case SendPlayerToPlayerEvent.ACTION: {
SendPlayerToPlayerEvent event = CoreConstantObjects.GSON.fromJson(info.getContent(), SendPlayerToPlayerEvent.class);
SendPlayerToPlayerEvent event = CoreUtils.GSON.fromJson(info.getContent(), SendPlayerToPlayerEvent.class);
Player toPlayer = Bukkit.getPlayer(event.getToPlayerUUID());
if (toPlayer == null) {
return;