fix: 适配 core 升级

This commit is contained in:
2022-10-29 06:42:34 +08:00
parent 750dbc7055
commit 29305a6aab
6 changed files with 23 additions and 23 deletions

View File

@@ -10,7 +10,7 @@ import cn.hamster3.mc.plugin.ball.common.listener.BallListener;
import cn.hamster3.mc.plugin.core.bungee.util.BallBungeeCordUtils; import cn.hamster3.mc.plugin.core.bungee.util.BallBungeeCordUtils;
import cn.hamster3.mc.plugin.core.common.api.CoreAPI; 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.constant.CoreConstantObjects;
import cn.hamster3.mc.plugin.core.common.data.Message; import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer; import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
@@ -40,7 +40,7 @@ public final class BallBungeeCordListener extends BallListener implements Listen
switch (info.getAction()) { switch (info.getAction()) {
case BroadcastPlayerMessageEvent.ACTION: { case BroadcastPlayerMessageEvent.ACTION: {
BroadcastPlayerMessageEvent event = CoreConstantObjects.GSON.fromJson(info.getContent(), BroadcastPlayerMessageEvent.class); BroadcastPlayerMessageEvent event = CoreConstantObjects.GSON.fromJson(info.getContent(), BroadcastPlayerMessageEvent.class);
Message message = event.getMessage(); DisplayMessage message = event.getMessage();
Audience audience = CoreAPI.getInstance().getAudienceProvider().all(); Audience audience = CoreAPI.getInstance().getAudienceProvider().all();
message.show(audience); message.show(audience);
break; break;

View File

@@ -16,7 +16,7 @@ import cn.hamster3.mc.plugin.ball.common.listener.BallListener;
import cn.hamster3.mc.plugin.ball.common.listener.ListenerPriority; import cn.hamster3.mc.plugin.ball.common.listener.ListenerPriority;
import cn.hamster3.mc.plugin.core.common.api.CoreAPI; 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.constant.CoreConstantObjects;
import cn.hamster3.mc.plugin.core.common.data.Message; import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive; import com.google.gson.JsonPrimitive;
@@ -323,7 +323,7 @@ public abstract class BallAPI {
* @param message 消息 * @param message 消息
*/ */
public void broadcastPlayerMessage(@NotNull String message) { public void broadcastPlayerMessage(@NotNull String message) {
broadcastPlayerMessage(new Message().message(message)); broadcastPlayerMessage(DisplayMessage.message(message));
} }
/** /**
@@ -331,7 +331,7 @@ public abstract class BallAPI {
* *
* @param message 消息 * @param message 消息
*/ */
public void broadcastPlayerMessage(@NotNull Message message) { public void broadcastPlayerMessage(@NotNull DisplayMessage message) {
sendBallMessage( sendBallMessage(
BALL_CHANNEL, BALL_CHANNEL,
BallServerType.PROXY, BallServerType.PROXY,
@@ -407,7 +407,7 @@ public abstract class BallAPI {
* @param message 消息 * @param message 消息
* @param cache 当玩家不在线时,是否缓存消息等待玩家上线再发送 * @param cache 当玩家不在线时,是否缓存消息等待玩家上线再发送
*/ */
public void sendMessageToPlayer(@NotNull UUID uuid, @NotNull Message message, boolean cache) { public void sendMessageToPlayer(@NotNull UUID uuid, @NotNull DisplayMessage message, boolean cache) {
BallPlayerInfo info = getPlayerInfo(uuid); BallPlayerInfo info = getPlayerInfo(uuid);
if (info == null || !info.isOnline()) { if (info == null || !info.isOnline()) {
if (!cache) { if (!cache) {
@@ -440,7 +440,7 @@ public abstract class BallAPI {
* @param message 消息 * @param message 消息
* @param cache 当玩家不在线时,是否缓存消息等待玩家上线再发送 * @param cache 当玩家不在线时,是否缓存消息等待玩家上线再发送
*/ */
public void sendMessageToPlayer(@NotNull Set<UUID> receiver, @NotNull Message message, boolean cache) { public void sendMessageToPlayer(@NotNull Set<UUID> receiver, @NotNull DisplayMessage message, boolean cache) {
for (UUID uuid : receiver) { for (UUID uuid : receiver) {
BallPlayerInfo info = getPlayerInfo(uuid); BallPlayerInfo info = getPlayerInfo(uuid);
if (info == null || !info.isOnline()) { if (info == null || !info.isOnline()) {
@@ -478,7 +478,7 @@ public abstract class BallAPI {
* @param location 坐标 * @param location 坐标
* @param doneMessage 传送完成后显示的消息 * @param doneMessage 传送完成后显示的消息
*/ */
public void sendPlayerToLocation(@NotNull UUID sendPlayerUUID, @NotNull BallLocation location, @Nullable Message doneMessage) { public void sendPlayerToLocation(@NotNull UUID sendPlayerUUID, @NotNull BallLocation location, @Nullable DisplayMessage doneMessage) {
sendBallMessage( sendBallMessage(
BALL_CHANNEL, BALL_CHANNEL,
SendPlayerToLocationEvent.ACTION, SendPlayerToLocationEvent.ACTION,
@@ -497,7 +497,7 @@ public abstract class BallAPI {
* @param location 坐标 * @param location 坐标
* @param doneMessage 传送完成后显示的消息 * @param doneMessage 传送完成后显示的消息
*/ */
public void sendPlayerToLocation(@NotNull HashSet<UUID> sendPlayerUUID, @NotNull BallLocation location, @Nullable Message doneMessage) { public void sendPlayerToLocation(@NotNull HashSet<UUID> sendPlayerUUID, @NotNull BallLocation location, @Nullable DisplayMessage doneMessage) {
sendBallMessage( sendBallMessage(
BALL_CHANNEL, BALL_CHANNEL,
SendPlayerToLocationEvent.ACTION, SendPlayerToLocationEvent.ACTION,
@@ -513,7 +513,7 @@ public abstract class BallAPI {
* @param sendPlayerUUID 被传送的玩家 * @param sendPlayerUUID 被传送的玩家
* @param toPlayerUUID 传送的目标玩家 * @param toPlayerUUID 传送的目标玩家
*/ */
public void sendPlayerToPlayer(@NotNull UUID sendPlayerUUID, @NotNull UUID toPlayerUUID, @Nullable Message doneMessage, @Nullable Message doneTargetMessage) { public void sendPlayerToPlayer(@NotNull UUID sendPlayerUUID, @NotNull UUID toPlayerUUID, @Nullable DisplayMessage doneMessage, @Nullable DisplayMessage doneTargetMessage) {
sendBallMessage( sendBallMessage(
BALL_CHANNEL, BALL_CHANNEL,
SendPlayerToPlayerEvent.ACTION, SendPlayerToPlayerEvent.ACTION,
@@ -530,7 +530,7 @@ public abstract class BallAPI {
* @param toPlayerUUID 传送的目标玩家 * @param toPlayerUUID 传送的目标玩家
* @param doneMessage 传送完成后显示的消息 * @param doneMessage 传送完成后显示的消息
*/ */
public void sendPlayerToPlayer(@NotNull HashSet<UUID> sendPlayerUUID, @NotNull UUID toPlayerUUID, @Nullable Message doneMessage, @Nullable Message doneTargetMessage) { public void sendPlayerToPlayer(@NotNull HashSet<UUID> sendPlayerUUID, @NotNull UUID toPlayerUUID, @Nullable DisplayMessage doneMessage, @Nullable DisplayMessage doneTargetMessage) {
sendBallMessage( sendBallMessage(
BALL_CHANNEL, BALL_CHANNEL,
SendPlayerToPlayerEvent.ACTION, SendPlayerToPlayerEvent.ACTION,
@@ -640,15 +640,15 @@ public abstract class BallAPI {
} }
@NotNull @NotNull
public List<Message> getCachedPlayerMessage(@NotNull UUID uuid) throws SQLException { public List<DisplayMessage> getCachedPlayerMessage(@NotNull UUID uuid) throws SQLException {
ArrayList<Message> list = new ArrayList<>(); ArrayList<DisplayMessage> list = new ArrayList<>();
try (Connection connection = CoreAPI.getInstance().getConnection()) { try (Connection connection = CoreAPI.getInstance().getConnection()) {
PreparedStatement statement = connection.prepareStatement("SELECT message FROM " + BallCommonConstants.SQL.CACHED_MESSAGE_TABLE + " WHERE `uuid`=?;"); PreparedStatement statement = connection.prepareStatement("SELECT message FROM " + BallCommonConstants.SQL.CACHED_MESSAGE_TABLE + " WHERE `uuid`=?;");
statement.setString(1, uuid.toString()); statement.setString(1, uuid.toString());
ResultSet set = statement.executeQuery(); ResultSet set = statement.executeQuery();
while (set.next()) { while (set.next()) {
JsonObject object = CoreConstantObjects.JSON_PARSER.parse(set.getString("msg")).getAsJsonObject(); JsonObject object = CoreConstantObjects.JSON_PARSER.parse(set.getString("msg")).getAsJsonObject();
list.add(new Message().json(object)); list.add(new DisplayMessage().fromJson(object));
} }
statement.close(); statement.close();
} }

View File

@@ -1,6 +1,6 @@
package cn.hamster3.mc.plugin.ball.common.event.operate; package cn.hamster3.mc.plugin.ball.common.event.operate;
import cn.hamster3.mc.plugin.core.common.data.Message; import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -11,6 +11,6 @@ public class BroadcastPlayerMessageEvent {
public static final String ACTION = "BroadcastPlayerMessage"; public static final String ACTION = "BroadcastPlayerMessage";
@NotNull @NotNull
private final Message message; private final DisplayMessage message;
} }

View File

@@ -1,6 +1,6 @@
package cn.hamster3.mc.plugin.ball.common.event.operate; package cn.hamster3.mc.plugin.ball.common.event.operate;
import cn.hamster3.mc.plugin.core.common.data.Message; import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -16,5 +16,5 @@ public class SendMessageToPlayerEvent {
@NotNull @NotNull
private final Set<UUID> receiver; private final Set<UUID> receiver;
@NotNull @NotNull
private final Message message; private final DisplayMessage message;
} }

View File

@@ -1,7 +1,7 @@
package cn.hamster3.mc.plugin.ball.common.event.operate; package cn.hamster3.mc.plugin.ball.common.event.operate;
import cn.hamster3.mc.plugin.ball.common.data.BallLocation; import cn.hamster3.mc.plugin.ball.common.data.BallLocation;
import cn.hamster3.mc.plugin.core.common.data.Message; import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -20,6 +20,6 @@ public class SendPlayerToLocationEvent {
@NotNull @NotNull
private final BallLocation location; private final BallLocation location;
@Nullable @Nullable
private final Message doneMessage; private final DisplayMessage doneMessage;
} }

View File

@@ -1,6 +1,6 @@
package cn.hamster3.mc.plugin.ball.common.event.operate; package cn.hamster3.mc.plugin.ball.common.event.operate;
import cn.hamster3.mc.plugin.core.common.data.Message; import cn.hamster3.mc.plugin.core.common.data.DisplayMessage;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -19,8 +19,8 @@ public class SendPlayerToPlayerEvent {
@NotNull @NotNull
private final UUID toPlayerUUID; private final UUID toPlayerUUID;
@Nullable @Nullable
private final Message doneMessage; private final DisplayMessage doneMessage;
@Nullable @Nullable
private final Message doneTargetMessage; private final DisplayMessage doneTargetMessage;
} }