The AntiMacro timer now properly pauses for Administrators

Modified the ::revent command to unpause the AntiMacro timer for admins and display a chat message
This commit is contained in:
Zerken
2023-09-10 14:43:56 +00:00
committed by Ryan
parent 99e83a57e3
commit ac5c31747f
@@ -12,6 +12,7 @@ import core.game.system.timer.PersistTimer
import core.game.world.map.zone.ZoneRestriction import core.game.world.map.zone.ZoneRestriction
import core.game.world.repository.Repository import core.game.world.repository.Repository
import core.tools.RandomFunction import core.tools.RandomFunction
import core.tools.colorize
import org.json.simple.JSONObject import org.json.simple.JSONObject
class AntiMacro : PersistTimer(0, "antimacro", isAuto = true), Commands { class AntiMacro : PersistTimer(0, "antimacro", isAuto = true), Commands {
@@ -40,9 +41,8 @@ class AntiMacro : PersistTimer(0, "antimacro", isAuto = true), Commands {
override fun onRegister(entity: Entity) { override fun onRegister(entity: Entity) {
if (entity !is Player || entity.isArtificial) if (entity !is Player || entity.isArtificial)
entity.timers.removeTimer(this) entity.timers.removeTimer(this)
if (entity is Player && entity.rights == Rights.ADMINISTRATOR) { if (entity is Player && entity.rights == Rights.ADMINISTRATOR)
pause(entity) paused = true
}
if (runInterval == 0) if (runInterval == 0)
setNextExecution() setNextExecution()
@@ -106,6 +106,10 @@ class AntiMacro : PersistTimer(0, "antimacro", isAuto = true), Commands {
val target = Repository.getPlayerByName(arg.targetPlayer) val target = Repository.getPlayerByName(arg.targetPlayer)
if (target == null) if (target == null)
reject(player, "Unable to find user ${arg.targetPlayer}.") reject(player, "Unable to find user ${arg.targetPlayer}.")
if (target!!.rights == Rights.ADMINISTRATOR) {
unpause(target)
sendMessage(target, colorize("%RAntiMacro timer unpaused until next login."))
}
forceEvent(target!!, arg.targetEvent) forceEvent(target!!, arg.targetEvent)
} }