feat: Custom prefixes and basic help command

This commit is contained in:
Matthew
2023-11-27 03:41:48 -05:00
parent 3c6067c8a6
commit 76ba7cb942
3 changed files with 14 additions and 1 deletions

View File

@@ -14,6 +14,7 @@
"ClientMode": "ZZ",
"QuestCacheExpiry": 300,
"ProxyPort": 0,
"CommandPrefix": "!",
"DevMode": true,
"DevModeOptions": {
"AutoCreateAccount": true,
@@ -78,6 +79,11 @@
"RealtimeChannelID": ""
},
"Commands": [
{
"Name": "Help",
"Enabled": true,
"Prefix": "help"
},
{
"Name": "Rights",
"Enabled": false,

View File

@@ -81,6 +81,7 @@ type Config struct {
RealClientMode Mode
QuestCacheExpiry int // Number of seconds to keep quest data cached
ProxyPort uint16 // Forces the game to connect to a channel server proxy
CommandPrefix string // The prefix for commands
DevMode bool
DevModeOptions DevModeOptions

View File

@@ -318,6 +318,12 @@ func parseChatCommand(s *Session, command string) {
} else {
sendDisabledCommandMessage(s, commands["Teleport"])
}
case commands["Help"].Prefix:
if commands["Help"].Enabled {
sendServerChatMessage(s, fmt.Sprintf(s.server.dict["commandTeleportSuccess"], x, y))
} else {
sendDisabledCommandMessage(s, commands["Help"])
}
}
}
@@ -391,7 +397,7 @@ func handleMsgSysCastBinary(s *Session, p mhfpacket.MHFPacket) {
bf.SetLE()
chatMessage := &binpacket.MsgBinChat{}
chatMessage.Parse(bf)
if strings.HasPrefix(chatMessage.Message, "!") {
if strings.HasPrefix(chatMessage.Message, s.server.erupeConfig.CommandPrefix) {
parseChatCommand(s, chatMessage.Message)
return
}