From 857025d9d57cc489af879f29563fccfeb4276596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=A1=E7=81=B5=E6=9A=B4=E9=BE=99=E5=A4=A7=E5=B8=9D?= Date: Tue, 2 Jul 2024 16:18:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E8=BF=9B=E5=85=A5=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E7=9A=84=E7=8E=A9=E5=AE=B6=E5=8F=91=E9=80=81=E4=B8=80=E6=9D=A1?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/emu/grasscutter/config/ConfigContainer.java | 4 +++- src/main/java/emu/grasscutter/scripts/ScriptLib.java | 6 +++--- .../server/packet/recv/HandlerTowerAllDataReq.java | 3 +++ .../server/packet/send/PacketAntiAddictNotify.java | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/emu/grasscutter/config/ConfigContainer.java b/src/main/java/emu/grasscutter/config/ConfigContainer.java index 1be3c942814..e80b51a0afe 100644 --- a/src/main/java/emu/grasscutter/config/ConfigContainer.java +++ b/src/main/java/emu/grasscutter/config/ConfigContainer.java @@ -35,9 +35,10 @@ public class ConfigContainer { * HTTP server should start immediately. * Version 13 - 'game.useUniquePacketKey' was added to control whether the * encryption key used for packets is a constant or randomly generated. + * Version 14 - 添加热更新配置 添加弹窗信息配置 */ private static int version() { - return 13; + return 14; } /** @@ -418,6 +419,7 @@ public VisionOptions(String name, int visionRange, int gridWidth) { } public static class JoinOptions { + public static String noticeMessage = "Welcome to a Grasscutter server."; public int[] welcomeEmotes = {2007, 1002, 4010}; public String welcomeMessage = "Welcome to a Grasscutter server."; public JoinOptions.Mail welcomeMail = new JoinOptions.Mail(); diff --git a/src/main/java/emu/grasscutter/scripts/ScriptLib.java b/src/main/java/emu/grasscutter/scripts/ScriptLib.java index 48f35986aa3..356c2072707 100644 --- a/src/main/java/emu/grasscutter/scripts/ScriptLib.java +++ b/src/main/java/emu/grasscutter/scripts/ScriptLib.java @@ -2015,9 +2015,9 @@ public int[] GetGatherConfigIdList() { * 对原版 lua 不支持 * */ - //弹窗alert 用法: ScriptLib.alert(context, 1, "hello world 666") then - public int alert(int MsgType, String msg) { - sceneScriptManager.get().getScene().broadcastPacket(new PacketAntiAddictNotify(MsgType, msg)); + //弹窗 Notice 用法: ScriptLib.alert(context, 1, "hello world 666") then + public int Notice(int MsgType, String Msg) { + sceneScriptManager.get().getScene().broadcastPacket(new PacketAntiAddictNotify(MsgType, Msg)); return 0; } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTowerAllDataReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTowerAllDataReq.java index 231304997af..aaf410a5322 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTowerAllDataReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTowerAllDataReq.java @@ -1,7 +1,9 @@ package emu.grasscutter.server.packet.recv; import emu.grasscutter.net.packet.*; +import emu. grasscutter.config.ConfigContainer.JoinOptions; import emu.grasscutter.server.game.GameSession; +import emu.grasscutter.server.packet.send.PacketAntiAddictNotify; import emu.grasscutter.server.packet.send.PacketTowerAllDataRsp; @Opcodes(PacketOpcodes.TowerAllDataReq) @@ -9,6 +11,7 @@ public class HandlerTowerAllDataReq extends PacketHandler { @Override public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { + session.send(new PacketAntiAddictNotify(1, JoinOptions.noticeMessage)); session.send( new PacketTowerAllDataRsp( session.getServer().getTowerSystem(), session.getPlayer().getTowerManager())); diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketAntiAddictNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketAntiAddictNotify.java index 284fe9fa978..4630b57bb70 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketAntiAddictNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketAntiAddictNotify.java @@ -5,12 +5,12 @@ import emu.grasscutter.net.proto.AntiAddictNotifyOuterClass.AntiAddictNotify; public class PacketAntiAddictNotify extends BasePacket { - public PacketAntiAddictNotify(int MsgType, String msg) { + public PacketAntiAddictNotify(int MsgType, String Msg) { super(PacketOpcodes.AntiAddictNotify); AntiAddictNotify proto = AntiAddictNotify.newBuilder() .setMsgType(MsgType) - .setMsg(msg) + .setMsg(Msg) .build(); this.setData(proto);