diff --git a/Server/src/main/core/game/system/timer/impl/AntiMacro.kt b/Server/src/main/core/game/system/timer/impl/AntiMacro.kt index 482c5dc54..c5ce00636 100644 --- a/Server/src/main/core/game/system/timer/impl/AntiMacro.kt +++ b/Server/src/main/core/game/system/timer/impl/AntiMacro.kt @@ -37,7 +37,7 @@ class AntiMacro : PersistTimer(0, "antimacro", isAuto = true), Commands { } override fun onRegister(entity: Entity) { - if (entity !is Player) + if (entity !is Player || entity.isArtificial) entity.timers.removeTimer(this) if (runInterval == 0) diff --git a/Server/src/test/kotlin/TestUtils.kt b/Server/src/test/kotlin/TestUtils.kt index aca7838ed..9d7b750bf 100644 --- a/Server/src/test/kotlin/TestUtils.kt +++ b/Server/src/test/kotlin/TestUtils.kt @@ -45,8 +45,8 @@ object TestUtils { var uidCounter = 0 const val PLAYER_DEATH_TICKS = 14 - fun getMockPlayer(name: String, ironman: IronmanMode = IronmanMode.NONE, rights: Rights = Rights.ADMINISTRATOR): MockPlayer { - val p = MockPlayer(name) + fun getMockPlayer(name: String, ironman: IronmanMode = IronmanMode.NONE, rights: Rights = Rights.ADMINISTRATOR, isBot: Boolean = false): MockPlayer { + val p = MockPlayer(name, isBot) p.ironmanManager.mode = ironman p.details.accountInfo.uid = uidCounter++ p.setPlaying(true); @@ -114,7 +114,7 @@ object TestUtils { } } -class MockPlayer(name: String) : Player(PlayerDetails(name)), AutoCloseable { +class MockPlayer(name: String, val isBot: Boolean) : Player(PlayerDetails(name)), AutoCloseable { var hasInit = false init { configureBasicProperties(); flagTutComplete(false); init(); flagTutComplete(true) } @@ -122,6 +122,7 @@ class MockPlayer(name: String) : Player(PlayerDetails(name)), AutoCloseable { this.details.session = MockSession() this.location = ServerConstants.HOME_LOCATION this.properties.attackStyle = WeaponInterface.AttackStyle(0, WeaponInterface.BONUS_CRUSH) + this.artificial = isBot } fun flagTutComplete(complete: Boolean) { diff --git a/Server/src/test/kotlin/content/RandomEventTests.kt b/Server/src/test/kotlin/content/RandomEventTests.kt index efd98a335..05d82630f 100644 --- a/Server/src/test/kotlin/content/RandomEventTests.kt +++ b/Server/src/test/kotlin/content/RandomEventTests.kt @@ -63,6 +63,13 @@ class RandomEventTests { } } + @Test fun shouldNotSpawnForArtificialPlayer() { + TestUtils.getMockPlayer("antimacroshouldspawnrandom", isBot = true).use {p -> + val timer = getTimer(p) + Assertions.assertEquals(null, timer) + } + } + @Test fun teleportAndNotePunishmentShouldNotAffectAlreadyNotedItems() { TestUtils.getMockPlayer("teleportpunishment1").use {p -> val timer = getTimer(p) ?: Assertions.fail("AntiMacro timer is null!")