-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change config options & Add game listener and handler
- Loading branch information
Showing
16 changed files
with
277 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
common/src/main/kotlin/me/regadpole/plumbot/event/GDeathEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package me.regadpole.plumbot.event | ||
|
||
import me.regadpole.plumbot.util.GPlayer | ||
|
||
class GDeathEvent(val player: GPlayer) |
7 changes: 7 additions & 0 deletions
7
common/src/main/kotlin/me/regadpole/plumbot/event/GJoinEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package me.regadpole.plumbot.event | ||
|
||
import me.regadpole.plumbot.util.GPlayer | ||
|
||
abstract class GJoinEvent(val player: GPlayer) { | ||
abstract fun kick(message: String) | ||
} |
5 changes: 5 additions & 0 deletions
5
common/src/main/kotlin/me/regadpole/plumbot/event/GPlayerChatEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package me.regadpole.plumbot.event | ||
|
||
import me.regadpole.plumbot.util.GPlayer | ||
|
||
class GPlayerChatEvent(val message: String, val player: GPlayer) |
5 changes: 5 additions & 0 deletions
5
common/src/main/kotlin/me/regadpole/plumbot/event/GQuitEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package me.regadpole.plumbot.event | ||
|
||
import me.regadpole.plumbot.util.GPlayer | ||
|
||
class GQuitEvent(val player: GPlayer) |
70 changes: 70 additions & 0 deletions
70
common/src/main/kotlin/me/regadpole/plumbot/listener/game/GameListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package me.regadpole.plumbot.listener.game | ||
|
||
import me.regadpole.plumbot.PlumBot | ||
import me.regadpole.plumbot.event.GDeathEvent | ||
import me.regadpole.plumbot.event.GJoinEvent | ||
import me.regadpole.plumbot.event.GPlayerChatEvent | ||
import me.regadpole.plumbot.event.GQuitEvent | ||
import taboolib.common5.util.replace | ||
|
||
class GameListener { | ||
fun onChat(event: GPlayerChatEvent) { | ||
if (PlumBot.getConfig().getConfig().groups.forwarding.message.enable) { | ||
if (PlumBot.getConfig().getConfig().groups.forwarding.message.mode == 1 && !event.message.startsWith( | ||
PlumBot.getConfig().getConfig().groups.forwarding.message.prefix?: "")) { | ||
return | ||
} | ||
var message: String = PlumBot.getLangConfig().getLangConf().forwarding.toPlatform?: return | ||
message = message.replace("%server_name%", event.player.server) | ||
.replace("%world_name%", event.player.position.world) | ||
.replace("%message%", event.message) | ||
PlumBot.getConfig().getConfig().groups.enableGroups.forEach { | ||
PlumBot.getBot().sendGroupMsg(it, message) | ||
} | ||
} | ||
} | ||
|
||
fun onDie(event: GDeathEvent) { | ||
if (PlumBot.getConfig().getConfig().groups.forwarding.dieMessage) { | ||
var message: String = PlumBot.getLangConfig().getLangConf().messageOnDie?: return | ||
message = message.replace("%player_name%", event.player.name) | ||
.replace("%world_name%", event.player.position.world) | ||
.replace("%pos%", event.player.position.toXYZ("/")) | ||
PlumBot.getConfig().getConfig().groups.enableGroups.forEach { | ||
PlumBot.getBot().sendGroupMsg(it, message) | ||
} | ||
} | ||
} | ||
|
||
fun onJoin(event: GJoinEvent) { | ||
if (PlumBot.getDatabase().getBindByName(event.player.name) == null) { | ||
var message: String = PlumBot.getLangConfig().getLangConf().whitelist.kickServer?: return | ||
message = message.replace("%enable_groups%", PlumBot.getConfig().getConfig().groups.enableGroups.joinToString("/")) | ||
event.kick(message) | ||
message = PlumBot.getLangConfig().getLangConf().whitelist.kickPlatform?: return | ||
message = message.replace("%player_name%", event.player.name) | ||
.replace("%server_name%", event.player.server) | ||
PlumBot.getConfig().getConfig().groups.enableGroups.forEach { | ||
PlumBot.getBot().sendGroupMsg(it, message) | ||
} | ||
} else if (PlumBot.getConfig().getConfig().groups.forwarding.joinAndLeave) { | ||
var message: String = PlumBot.getLangConfig().getLangConf().playerJoinMsg?: return | ||
message = message.replace("%player_name%", event.player.name) | ||
.replace("%server_name%", event.player.server) | ||
PlumBot.getConfig().getConfig().groups.enableGroups.forEach { | ||
PlumBot.getBot().sendGroupMsg(it, message) | ||
} | ||
} | ||
} | ||
|
||
fun onQuit(event: GQuitEvent) { | ||
if (PlumBot.getConfig().getConfig().groups.forwarding.joinAndLeave) { | ||
var message: String = PlumBot.getLangConfig().getLangConf().playerLeaveMsg?: return | ||
message = message.replace("%player_name%", event.player.name) | ||
.replace("%server_name%", event.player.server) | ||
PlumBot.getConfig().getConfig().groups.enableGroups.forEach { | ||
PlumBot.getBot().sendGroupMsg(it, message) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package me.regadpole.plumbot.util | ||
|
||
abstract class GPlayer(val name: String, var position: GPosition, val server: String, val isAdmin: Boolean) { | ||
abstract fun teleport() | ||
abstract fun sendMessage(message: String) | ||
} |
Oops, something went wrong.