Fix AutoTPA not splitting name from String correctly & close #798

This commit is contained in:
Bella 2020-05-10 20:49:37 -04:00
parent 848ada0fb2
commit 12fcf79225
No known key found for this signature in database
GPG Key ID: DBD4A6030080C8B3
1 changed files with 9 additions and 8 deletions

View File

@ -28,16 +28,17 @@ class AutoTPA : Module() {
var receiveListener = Listener(EventHook { event: PacketEvent.Receive ->
if (event.packet is SPacketChat && MessageDetectionHelper.isTPA(true, (event.packet as SPacketChat).getChatComponent().unformattedText)) {
/* I tested that getting the first word is compatible with chat timestamp, and it as, as this is Receive and chat timestamp is after Receive */
val firstWord = (event.packet as SPacketChat).getChatComponent().unformattedText.split("\\s+").toTypedArray()[0]
if (friends.value && Friends.isFriend(firstWord)) {
MessageSendHelper.sendServerMessage("/tpaccept")
return@EventHook
}
val name = (event.packet as SPacketChat).getChatComponent().unformattedText.split(" ").toTypedArray()[0]
when (mode.value) {
Mode.ACCEPT -> MessageSendHelper.sendServerMessage("/tpaccept")
Mode.DENY -> MessageSendHelper.sendServerMessage("/tpdeny")
Mode.ACCEPT -> MessageSendHelper.sendServerMessage("/tpaccept $name")
Mode.DENY -> {
if (friends.value && Friends.isFriend(name)) {
MessageSendHelper.sendServerMessage("/tpaccept $name")
} else {
MessageSendHelper.sendServerMessage("/tpdeny $name")
}
}
}
}
})