Skip to content

Commit

Permalink
为进入游戏的玩家发送一条弹窗通知
Browse files Browse the repository at this point in the history
  • Loading branch information
亡灵暴龙大帝 committed Jul 2, 2024
1 parent 54dc64b commit 857025d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/main/java/emu/grasscutter/config/ConfigContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/emu/grasscutter/scripts/ScriptLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
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)
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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 857025d

Please sign in to comment.