mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-02 16:49:12 +00:00
Fix kotlin code style issues
This commit is contained in:
-1
@@ -4,7 +4,6 @@ import io.mockk.MockKVerificationScope
|
||||
import io.mockk.verify
|
||||
import org.apollo.game.plugin.testing.junit.api.ActionCaptureCallbackRegistration
|
||||
|
||||
|
||||
/**
|
||||
* Verify some expectations on a [mock] after a delayed event (specified by [DelayMode]).
|
||||
*/
|
||||
|
||||
+1
-1
@@ -3,6 +3,7 @@ package org.apollo.game.plugin.testing.junit
|
||||
import io.mockk.every
|
||||
import io.mockk.slot
|
||||
import io.mockk.spyk
|
||||
import kotlin.reflect.KClass
|
||||
import org.apollo.game.action.Action
|
||||
import org.apollo.game.message.handler.MessageHandlerChainSet
|
||||
import org.apollo.game.model.World
|
||||
@@ -12,7 +13,6 @@ import org.apollo.game.plugin.testing.junit.mocking.StubPrototype
|
||||
import org.apollo.game.plugin.testing.junit.stubs.PlayerStubInfo
|
||||
import org.apollo.net.message.Message
|
||||
import org.apollo.util.security.PlayerCredentials
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
data class ApolloTestState(val handlers: MessageHandlerChainSet, val world: World) {
|
||||
val players = mutableListOf<Player>()
|
||||
|
||||
+15
-18
@@ -4,6 +4,14 @@ import io.mockk.every
|
||||
import io.mockk.slot
|
||||
import io.mockk.spyk
|
||||
import io.mockk.staticMockk
|
||||
import kotlin.reflect.KCallable
|
||||
import kotlin.reflect.KMutableProperty
|
||||
import kotlin.reflect.full.companionObject
|
||||
import kotlin.reflect.full.createType
|
||||
import kotlin.reflect.full.declaredMemberFunctions
|
||||
import kotlin.reflect.full.declaredMemberProperties
|
||||
import kotlin.reflect.jvm.isAccessible
|
||||
import kotlin.reflect.jvm.jvmErasure
|
||||
import org.apollo.cache.def.ItemDefinition
|
||||
import org.apollo.cache.def.NpcDefinition
|
||||
import org.apollo.cache.def.ObjectDefinition
|
||||
@@ -20,22 +28,6 @@ import org.apollo.game.plugin.testing.junit.api.annotations.NpcDefinitions
|
||||
import org.apollo.game.plugin.testing.junit.api.annotations.ObjectDefinitions
|
||||
import org.apollo.game.plugin.testing.junit.mocking.StubPrototype
|
||||
import org.junit.jupiter.api.extension.*
|
||||
import kotlin.reflect.KCallable
|
||||
import kotlin.reflect.KMutableProperty
|
||||
import kotlin.reflect.full.companionObject
|
||||
import kotlin.reflect.full.createType
|
||||
import kotlin.reflect.full.declaredMemberFunctions
|
||||
import kotlin.reflect.full.declaredMemberProperties
|
||||
import kotlin.reflect.jvm.isAccessible
|
||||
import kotlin.reflect.jvm.jvmErasure
|
||||
|
||||
internal val supportedTestDoubleTypes = setOf(
|
||||
Player::class.createType(),
|
||||
Npc::class.createType(),
|
||||
GameObject::class.createType(),
|
||||
World::class.createType(),
|
||||
ActionCapture::class.createType()
|
||||
)
|
||||
|
||||
class ApolloTestingExtension :
|
||||
AfterTestExecutionCallback,
|
||||
@@ -168,6 +160,13 @@ class ApolloTestingExtension :
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal val supportedTestDoubleTypes = setOf(
|
||||
Player::class.createType(),
|
||||
Npc::class.createType(),
|
||||
GameObject::class.createType(),
|
||||
World::class.createType(),
|
||||
ActionCapture::class.createType()
|
||||
)
|
||||
|
||||
inline fun <reified D : Any, reified A : Annotation> findTestDefinitions(
|
||||
callables: Collection<KCallable<*>>,
|
||||
@@ -185,7 +184,5 @@ class ApolloTestingExtension :
|
||||
method.call(companionObjectInstance)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+2
-3
@@ -1,10 +1,10 @@
|
||||
package org.apollo.game.plugin.testing.junit.api
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.isSuperclassOf
|
||||
import org.apollo.game.action.Action
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.isSuperclassOf
|
||||
|
||||
class ActionCapture(val type: KClass<out Action<*>>) {
|
||||
private var action: Action<*>? = null
|
||||
@@ -62,7 +62,6 @@ class ActionCapture(val type: KClass<out Action<*>>) {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a callback registration that triggers after exactly [count] ticks.
|
||||
*/
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
package org.apollo.game.plugin.testing.junit.api.annotations
|
||||
|
||||
import org.apollo.game.action.Action
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class ActionTest(val value: KClass<out Action<*>> = Action::class)
|
||||
-1
@@ -18,7 +18,6 @@ fun World.spawnObject(id: Int, position: Position): GameObject {
|
||||
return obj
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Spawns a new NPC with the minimum set of dependencies required to function correctly in the world.
|
||||
*/
|
||||
|
||||
+5
-8
@@ -1,5 +1,10 @@
|
||||
package org.apollo.game.plugin.testing.junit.params
|
||||
|
||||
import java.util.stream.Stream
|
||||
import kotlin.reflect.KCallable
|
||||
import kotlin.reflect.full.companionObject
|
||||
import kotlin.reflect.full.declaredMemberFunctions
|
||||
import kotlin.reflect.full.declaredMemberProperties
|
||||
import org.apollo.cache.def.ItemDefinition
|
||||
import org.apollo.cache.def.NpcDefinition
|
||||
import org.apollo.cache.def.ObjectDefinition
|
||||
@@ -11,11 +16,6 @@ import org.junit.jupiter.api.extension.ExtensionContext
|
||||
import org.junit.jupiter.params.provider.Arguments
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider
|
||||
import org.junit.jupiter.params.support.AnnotationConsumer
|
||||
import java.util.stream.Stream
|
||||
import kotlin.reflect.KCallable
|
||||
import kotlin.reflect.full.companionObject
|
||||
import kotlin.reflect.full.declaredMemberFunctions
|
||||
import kotlin.reflect.full.declaredMemberProperties
|
||||
|
||||
/**
|
||||
* An [ArgumentsProvider] for a definition of type `D`.
|
||||
@@ -64,7 +64,6 @@ object ItemDefinitionsProvider : DefinitionsProvider<ItemDefinition>(
|
||||
override fun accept(source: ItemDefinitionSource) {
|
||||
sourceNames = source.sourceNames.toHashSet()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +79,6 @@ object NpcDefinitionsProvider : DefinitionsProvider<NpcDefinition>(
|
||||
override fun accept(source: NpcDefinitionSource) {
|
||||
sourceNames = source.sourceNames.toHashSet()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,5 +94,4 @@ object ObjectDefinitionsProvider : DefinitionsProvider<ObjectDefinition>(
|
||||
override fun accept(source: ObjectDefinitionSource) {
|
||||
sourceNames = source.sourceNames.toHashSet()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-1
@@ -1,2 +1 @@
|
||||
package org.apollo.game.plugin.testing.junit.stubs
|
||||
|
||||
|
||||
-1
@@ -1,2 +1 @@
|
||||
package org.apollo.game.plugin.testing.junit.stubs
|
||||
|
||||
|
||||
-2
@@ -18,10 +18,8 @@ class PlayerStubInfo {
|
||||
|
||||
return info
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var position = Position(3222, 3222)
|
||||
var name = "test"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.apollo.game.plugin.api
|
||||
|
||||
import java.lang.IllegalArgumentException
|
||||
import org.apollo.cache.def.ItemDefinition
|
||||
import org.apollo.cache.def.NpcDefinition
|
||||
import org.apollo.cache.def.ObjectDefinition
|
||||
import java.lang.IllegalArgumentException
|
||||
|
||||
/**
|
||||
* Provides plugins with access to item, npc, and object definitions
|
||||
@@ -101,5 +101,4 @@ object Definitions {
|
||||
val normalizedName = name.replace('_', ' ')
|
||||
return definitions.firstOrNull { it.nameSupplier().equals(normalizedName, ignoreCase = true) }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -86,5 +86,4 @@ class SkillProxy(private val skills: SkillSet, private val skill: Int) {
|
||||
val new = Math.min(current + amount, maximum)
|
||||
skills.setCurrentLevel(skill, new)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -100,5 +100,4 @@ private class ExpireObjectTask(
|
||||
stop()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -88,7 +88,5 @@ class DefinitionsTests {
|
||||
@ObjectDefinitions
|
||||
val objs = listOf("obj zero", "obj one", "obj two", "obj duplicate name", "obj duplicate name")
|
||||
.mapIndexed { id, name -> ObjectDefinition(id).also { it.name = name } }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -119,5 +119,4 @@ class PlayerTests {
|
||||
assertEquals(10, hitpoints.maximum)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,5 +22,4 @@ class PositionTests {
|
||||
assertEquals(y, y2) { "y coordinate mismatch in Position destructuring." }
|
||||
assertEquals(z, z2) { "z coordinate mismatch in Position destructuring." }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,6 @@ interface Area {
|
||||
* Returns whether or not the specified [Position] is inside this [Area].
|
||||
*/
|
||||
operator fun contains(position: Position): Boolean
|
||||
|
||||
}
|
||||
|
||||
internal class RectangularArea(private val x: IntRange, private val y: IntRange, private val height: Int) : Area {
|
||||
@@ -23,5 +22,4 @@ internal class RectangularArea(private val x: IntRange, private val y: IntRange,
|
||||
val (x, y, z) = position
|
||||
return x in this.x && y in this.y && z == height
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,5 +38,4 @@ class AreaActionBuilder internal constructor(val name: String, val area: Area) {
|
||||
fun exit(listener: AreaListener) {
|
||||
this.exit = listener
|
||||
}
|
||||
|
||||
}
|
||||
@@ -55,5 +55,4 @@ class AreaActionTests {
|
||||
|
||||
assertTrue(triggered) { "exit_test_action was not triggered." }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import org.apollo.net.message.Message
|
||||
|
||||
val BANK_BOOTH_ID = 2213
|
||||
|
||||
|
||||
/**
|
||||
* Hook into the [ObjectActionMessage] and listen for when a bank booth's second action ("Open Bank") is selected.
|
||||
*/
|
||||
@@ -56,7 +55,6 @@ class BankAction(player: Player, position: Position) : DistancedAction<Player>(0
|
||||
player.startAction(BankAction(player, position))
|
||||
message.terminate()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun executeAction() {
|
||||
@@ -72,5 +70,4 @@ class BankAction(player: Player, position: Position) : DistancedAction<Player>(0
|
||||
override fun hashCode(): Int {
|
||||
return position.hashCode()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,5 +49,4 @@ class OpenBankTest {
|
||||
|
||||
verifyAfter(action.complete()) { player.openBank() }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,139 +1,138 @@
|
||||
|
||||
import com.google.common.primitives.Ints
|
||||
import org.apollo.game.model.Position
|
||||
import org.apollo.game.model.entity.setting.PrivilegeLevel
|
||||
import org.apollo.game.plugin.api.Position.component1
|
||||
import org.apollo.game.plugin.api.Position.component2
|
||||
import org.apollo.game.plugin.api.Position.component3
|
||||
|
||||
/**
|
||||
* Sends the player's position.
|
||||
*/
|
||||
on_command("pos", PrivilegeLevel.MODERATOR)
|
||||
.then { player ->
|
||||
val (x, y, z) = player.position
|
||||
val region = player.position.regionCoordinates
|
||||
|
||||
player.sendMessage("You are at: ($x, $y, $z) in region (${region.x}, ${region.y}).")
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleports the player to the specified position.
|
||||
*/
|
||||
on_command("tele", PrivilegeLevel.ADMINISTRATOR)
|
||||
.then { player ->
|
||||
val invalidSyntax = "Invalid syntax - ::tele [x] [y] [optional-z] or ::tele [place name]"
|
||||
|
||||
if (arguments.size == 1) {
|
||||
val query = arguments[0]
|
||||
val results = TELEPORT_DESTINATIONS.filter { (name) -> name.startsWith(query) }
|
||||
|
||||
if (results.isEmpty()) {
|
||||
player.sendMessage("No destinations matching '$query'.")
|
||||
player.sendMessage(invalidSyntax)
|
||||
return@then
|
||||
} else if (results.size > 1) {
|
||||
player.sendMessage("Ambiguous query '$query' (could be $results). Please disambiguate.")
|
||||
return@then
|
||||
}
|
||||
|
||||
val (name, dest) = results[0]
|
||||
player.sendMessage("Teleporting to $name.")
|
||||
player.teleport(dest)
|
||||
|
||||
return@then
|
||||
}
|
||||
|
||||
if (arguments.size !in 2..3) {
|
||||
player.sendMessage(invalidSyntax)
|
||||
return@then
|
||||
}
|
||||
|
||||
val x = Ints.tryParse(arguments[0])
|
||||
if (x == null) {
|
||||
player.sendMessage(invalidSyntax)
|
||||
return@then
|
||||
}
|
||||
|
||||
val y = Ints.tryParse(arguments[1])
|
||||
if (y == null) {
|
||||
player.sendMessage(invalidSyntax)
|
||||
return@then
|
||||
}
|
||||
|
||||
var z = player.position.height
|
||||
if (arguments.size == 3) {
|
||||
val plane = Ints.tryParse(arguments[2])
|
||||
if (plane == null) {
|
||||
player.sendMessage(invalidSyntax)
|
||||
return@then
|
||||
}
|
||||
z = plane
|
||||
}
|
||||
|
||||
if (z in 0..4) {
|
||||
player.teleport(Position(x, y, z))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleports the player to another player.
|
||||
*/
|
||||
on_command("teleto", PrivilegeLevel.ADMINISTRATOR)
|
||||
.then { player ->
|
||||
val invalidSyntax = "Invalid syntax - ::teleto [player name]"
|
||||
|
||||
if (arguments.size == 1) {
|
||||
val playerName = arguments[0]
|
||||
try {
|
||||
val foundPlayer = player.world.getPlayer(playerName)
|
||||
|
||||
if (foundPlayer == null) {
|
||||
player.sendMessage("Player $playerName is currently offline or does not exist.")
|
||||
return@then
|
||||
}
|
||||
|
||||
player.teleport(foundPlayer.position)
|
||||
player.sendMessage("You have teleported to player $playerName.")
|
||||
} catch (_: Exception) {
|
||||
// Invalid player name syntax
|
||||
player.sendMessage(invalidSyntax)
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(invalidSyntax)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal val TELEPORT_DESTINATIONS = listOf(
|
||||
"alkharid" to Position(3292, 3171),
|
||||
"ardougne" to Position(2662, 3304),
|
||||
"barrows" to Position(3565, 3314),
|
||||
"brimhaven" to Position(2802, 3179),
|
||||
"burthorpe" to Position(2898, 3545),
|
||||
"camelot" to Position(2757, 3478),
|
||||
"canifis" to Position(3493, 3489),
|
||||
"cw" to Position(2442, 3090),
|
||||
"draynor" to Position(3082, 3249),
|
||||
"duelarena" to Position(3370, 3267),
|
||||
"edgeville" to Position(3087, 3504),
|
||||
"entrana" to Position(2827, 3343),
|
||||
"falador" to Position(2965, 3379),
|
||||
"ge" to Position(3164, 3476),
|
||||
"kbd" to Position(2273, 4680),
|
||||
"keldagrim" to Position(2845, 10210),
|
||||
"kq" to Position(3507, 9494),
|
||||
"lumbridge" to Position(3222, 3219),
|
||||
"lunar" to Position(2113, 3915),
|
||||
"misc" to Position(2515, 3866),
|
||||
"neit" to Position(2332, 3804),
|
||||
"pc" to Position(2658, 2660),
|
||||
"rellekka" to Position(2660, 3657),
|
||||
"shilo" to Position(2852, 2955),
|
||||
"taverley" to Position(2895, 3443),
|
||||
"tutorial" to Position(3094, 3107),
|
||||
"tzhaar" to Position(2480, 5175),
|
||||
"varrock" to Position(3212, 3423),
|
||||
"yanille" to Position(2605, 3096),
|
||||
"zanaris" to Position(2452, 4473)
|
||||
|
||||
import com.google.common.primitives.Ints
|
||||
import org.apollo.game.model.Position
|
||||
import org.apollo.game.model.entity.setting.PrivilegeLevel
|
||||
import org.apollo.game.plugin.api.Position.component1
|
||||
import org.apollo.game.plugin.api.Position.component2
|
||||
import org.apollo.game.plugin.api.Position.component3
|
||||
|
||||
/**
|
||||
* Sends the player's position.
|
||||
*/
|
||||
on_command("pos", PrivilegeLevel.MODERATOR)
|
||||
.then { player ->
|
||||
val (x, y, z) = player.position
|
||||
val region = player.position.regionCoordinates
|
||||
|
||||
player.sendMessage("You are at: ($x, $y, $z) in region (${region.x}, ${region.y}).")
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleports the player to the specified position.
|
||||
*/
|
||||
on_command("tele", PrivilegeLevel.ADMINISTRATOR)
|
||||
.then { player ->
|
||||
val invalidSyntax = "Invalid syntax - ::tele [x] [y] [optional-z] or ::tele [place name]"
|
||||
|
||||
if (arguments.size == 1) {
|
||||
val query = arguments[0]
|
||||
val results = TELEPORT_DESTINATIONS.filter { (name) -> name.startsWith(query) }
|
||||
|
||||
if (results.isEmpty()) {
|
||||
player.sendMessage("No destinations matching '$query'.")
|
||||
player.sendMessage(invalidSyntax)
|
||||
return@then
|
||||
} else if (results.size > 1) {
|
||||
player.sendMessage("Ambiguous query '$query' (could be $results). Please disambiguate.")
|
||||
return@then
|
||||
}
|
||||
|
||||
val (name, dest) = results[0]
|
||||
player.sendMessage("Teleporting to $name.")
|
||||
player.teleport(dest)
|
||||
|
||||
return@then
|
||||
}
|
||||
|
||||
if (arguments.size !in 2..3) {
|
||||
player.sendMessage(invalidSyntax)
|
||||
return@then
|
||||
}
|
||||
|
||||
val x = Ints.tryParse(arguments[0])
|
||||
if (x == null) {
|
||||
player.sendMessage(invalidSyntax)
|
||||
return@then
|
||||
}
|
||||
|
||||
val y = Ints.tryParse(arguments[1])
|
||||
if (y == null) {
|
||||
player.sendMessage(invalidSyntax)
|
||||
return@then
|
||||
}
|
||||
|
||||
var z = player.position.height
|
||||
if (arguments.size == 3) {
|
||||
val plane = Ints.tryParse(arguments[2])
|
||||
if (plane == null) {
|
||||
player.sendMessage(invalidSyntax)
|
||||
return@then
|
||||
}
|
||||
z = plane
|
||||
}
|
||||
|
||||
if (z in 0..4) {
|
||||
player.teleport(Position(x, y, z))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Teleports the player to another player.
|
||||
*/
|
||||
on_command("teleto", PrivilegeLevel.ADMINISTRATOR)
|
||||
.then { player ->
|
||||
val invalidSyntax = "Invalid syntax - ::teleto [player name]"
|
||||
|
||||
if (arguments.size == 1) {
|
||||
val playerName = arguments[0]
|
||||
try {
|
||||
val foundPlayer = player.world.getPlayer(playerName)
|
||||
|
||||
if (foundPlayer == null) {
|
||||
player.sendMessage("Player $playerName is currently offline or does not exist.")
|
||||
return@then
|
||||
}
|
||||
|
||||
player.teleport(foundPlayer.position)
|
||||
player.sendMessage("You have teleported to player $playerName.")
|
||||
} catch (_: Exception) {
|
||||
// Invalid player name syntax
|
||||
player.sendMessage(invalidSyntax)
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(invalidSyntax)
|
||||
}
|
||||
}
|
||||
|
||||
internal val TELEPORT_DESTINATIONS = listOf(
|
||||
"alkharid" to Position(3292, 3171),
|
||||
"ardougne" to Position(2662, 3304),
|
||||
"barrows" to Position(3565, 3314),
|
||||
"brimhaven" to Position(2802, 3179),
|
||||
"burthorpe" to Position(2898, 3545),
|
||||
"camelot" to Position(2757, 3478),
|
||||
"canifis" to Position(3493, 3489),
|
||||
"cw" to Position(2442, 3090),
|
||||
"draynor" to Position(3082, 3249),
|
||||
"duelarena" to Position(3370, 3267),
|
||||
"edgeville" to Position(3087, 3504),
|
||||
"entrana" to Position(2827, 3343),
|
||||
"falador" to Position(2965, 3379),
|
||||
"ge" to Position(3164, 3476),
|
||||
"kbd" to Position(2273, 4680),
|
||||
"keldagrim" to Position(2845, 10210),
|
||||
"kq" to Position(3507, 9494),
|
||||
"lumbridge" to Position(3222, 3219),
|
||||
"lunar" to Position(2113, 3915),
|
||||
"misc" to Position(2515, 3866),
|
||||
"neit" to Position(2332, 3804),
|
||||
"pc" to Position(2658, 2660),
|
||||
"rellekka" to Position(2660, 3657),
|
||||
"shilo" to Position(2852, 2955),
|
||||
"taverley" to Position(2895, 3443),
|
||||
"tutorial" to Position(3094, 3107),
|
||||
"tzhaar" to Position(2480, 5175),
|
||||
"varrock" to Position(3212, 3423),
|
||||
"yanille" to Position(2605, 3096),
|
||||
"zanaris" to Position(2452, 4473)
|
||||
)
|
||||
@@ -36,5 +36,4 @@ class AnimateCommandTests {
|
||||
player.sendMessage(contains("Invalid syntax"))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -93,5 +93,4 @@ class LookupCommandTests {
|
||||
length = 1
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,7 +37,7 @@ class SpawnCommandTests {
|
||||
|
||||
verify {
|
||||
world.register(match<Npc> {
|
||||
it.id == 1 && it.position == Position(3, 3,0)
|
||||
it.id == 1 && it.position == Position(3, 3, 0)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,5 +49,4 @@ class TeleportToPlayerCommandTests {
|
||||
player.sendMessage(contains("Invalid syntax"))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,6 @@ abstract class Consumable(val name: String, val id: Int, val sound: Int, val del
|
||||
player.inventory.add(replacement)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private val consumables = mutableMapOf<Int, Consumable>()
|
||||
@@ -41,12 +40,12 @@ class FoodOrDrink : Consumable {
|
||||
val type: FoodOrDrinkType
|
||||
|
||||
constructor(
|
||||
name: String,
|
||||
id: Int,
|
||||
delay: Int,
|
||||
type: FoodOrDrinkType,
|
||||
restoration: Int,
|
||||
replacement: Int? = null
|
||||
name: String,
|
||||
id: Int,
|
||||
delay: Int,
|
||||
type: FoodOrDrinkType,
|
||||
restoration: Int,
|
||||
replacement: Int? = null
|
||||
) : super(name, id, EAT_FOOD_SOUND, delay, replacement) {
|
||||
this.type = type
|
||||
this.restoration = restoration
|
||||
@@ -64,7 +63,6 @@ class FoodOrDrink : Consumable {
|
||||
|
||||
player.skillSet.setCurrentLevel(Skill.HITPOINTS, newHitpointsLevel)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,5 +34,4 @@ class ConsumeAction(val consumable: Consumable, player: Player, val slot: Int) :
|
||||
wait(consumable.delay)
|
||||
stop()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import org.apollo.plugin.consumables.drink
|
||||
|
||||
//# Wine
|
||||
// # Wine
|
||||
drink(name = "jug_of_wine", id = 1993, restoration = 11)
|
||||
|
||||
//# Hot Drinks
|
||||
// # Hot Drinks
|
||||
drink(name = "nettle_tea", id = 4239, restoration = 3)
|
||||
drink(name = "nettle_tea", id = 4240, restoration = 3)
|
||||
|
||||
//# Gnome Cocktails
|
||||
// # Gnome Cocktails
|
||||
drink(name = "fruit_blast", id = 2034, restoration = 9)
|
||||
drink(name = "fruit_blast", id = 2084, restoration = 9)
|
||||
drink(name = "pineapple_punch", id = 2036, restoration = 9)
|
||||
|
||||
@@ -32,12 +32,12 @@ food(name = "shark", id = 385, restoration = 20)
|
||||
food(name = "sea_turtle", id = 397, restoration = 21)
|
||||
food(name = "manta_ray", id = 391, restoration = 22)
|
||||
|
||||
//# Breads/Wraps
|
||||
// # Breads/Wraps
|
||||
food(name = "bread", id = 2309, restoration = 5)
|
||||
food(name = "oomlie_wrap", id = 2343, restoration = 14)
|
||||
food(name = "ugthanki_kebab", id = 1883, restoration = 19)
|
||||
|
||||
//# Fruits
|
||||
// # Fruits
|
||||
food(name = "banana", id = 1963, restoration = 2)
|
||||
food(name = "sliced_banana", id = 3162, restoration = 2)
|
||||
food(name = "lemon", id = 2102, restoration = 2)
|
||||
@@ -54,8 +54,8 @@ food(name = "orange", id = 2108, restoration = 2)
|
||||
food(name = "orange_rings", id = 2110, restoration = 2)
|
||||
food(name = "orange_slices", id = 2112, restoration = 2)
|
||||
|
||||
//# Pies
|
||||
//# TODO: pie special effects (e.g. fish pie raises fishing level)
|
||||
// # Pies
|
||||
// # TODO: pie special effects (e.g. fish pie raises fishing level)
|
||||
food(name = "redberry_pie", id = 2325, restoration = 5, replacement = 2333, delay = 1)
|
||||
food(name = "redberry_pie", id = 2333, restoration = 5, delay = 1)
|
||||
|
||||
@@ -77,12 +77,12 @@ food(name = "wild_pie", id = 7210, restoration = 11, delay = 1)
|
||||
food(name = "summer_pie", id = 7218, restoration = 11, replacement = 7220, delay = 1)
|
||||
food(name = "summer_pie", id = 7220, restoration = 11, delay = 1)
|
||||
|
||||
//# Stews
|
||||
// # Stews
|
||||
food(name = "stew", id = 2003, restoration = 11)
|
||||
food(name = "banana_stew", id = 4016, restoration = 11)
|
||||
food(name = "curry", id = 2011, restoration = 19)
|
||||
|
||||
//# Pizzas
|
||||
// # Pizzas
|
||||
food(name = "plain_pizza", id = 2289, restoration = 7, replacement = 2291)
|
||||
food(name = "plain_pizza", id = 2291, restoration = 7)
|
||||
|
||||
@@ -95,7 +95,7 @@ food(name = "anchovy_pizza", id = 2299, restoration = 9)
|
||||
food(name = "pineapple_pizza", id = 2301, restoration = 11, replacement = 2303)
|
||||
food(name = "pineapple_pizza", id = 2303, restoration = 11)
|
||||
|
||||
//# Cakes
|
||||
// # Cakes
|
||||
food(name = "fishcake", id = 7530, restoration = 11)
|
||||
|
||||
food(name = "cake", id = 1891, restoration = 4, replacement = 1893)
|
||||
@@ -106,7 +106,7 @@ food(name = "chocolate_cake", id = 1897, restoration = 5, replacement = 1899)
|
||||
food(name = "chocolate_cake", id = 1899, restoration = 5, replacement = 1901)
|
||||
food(name = "chocolate_cake", id = 1901, restoration = 5)
|
||||
|
||||
//# Vegetables
|
||||
// # Vegetables
|
||||
food(name = "potato", id = 1942, restoration = 1)
|
||||
food(name = "spinach_roll", id = 1969, restoration = 2)
|
||||
food(name = "baked_potato", id = 6701, restoration = 4)
|
||||
@@ -119,14 +119,14 @@ food(name = "egg_potato", id = 7056, restoration = 16)
|
||||
food(name = "mushroom_potato", id = 7058, restoration = 20)
|
||||
food(name = "tuna_potato", id = 7060, restoration = 22)
|
||||
|
||||
//# Dairy
|
||||
// # Dairy
|
||||
food(name = "cheese", id = 1985, restoration = 2)
|
||||
food(name = "pot_of_cream", id = 2130, restoration = 1)
|
||||
|
||||
//# Gnome Food
|
||||
// # Gnome Food
|
||||
food(name = "toads_legs", id = 2152, restoration = 3)
|
||||
|
||||
//# Gnome Bowls
|
||||
// # Gnome Bowls
|
||||
food(name = "worm_hole", id = 2191, restoration = 12)
|
||||
food(name = "worm_hole", id = 2233, restoration = 12)
|
||||
food(name = "vegetable_ball", id = 2195, restoration = 12)
|
||||
@@ -136,7 +136,7 @@ food(name = "tangled_toads_legs", id = 2231, restoration = 15)
|
||||
food(name = "chocolate_bomb", id = 2185, restoration = 15)
|
||||
food(name = "chocolate_bomb", id = 2229, restoration = 15)
|
||||
|
||||
//# Gnome Crunchies
|
||||
// # Gnome Crunchies
|
||||
food(name = "toad_crunchies", id = 2217, restoration = 7)
|
||||
food(name = "toad_crunchies", id = 2243, restoration = 7)
|
||||
food(name = "spicy_crunchies", id = 2213, restoration = 7)
|
||||
@@ -146,7 +146,7 @@ food(name = "worm_crunchies", id = 2237, restoration = 8)
|
||||
food(name = "chocchip_crunchies", id = 2209, restoration = 7)
|
||||
food(name = "chocchip_crunchies", id = 2239, restoration = 7)
|
||||
|
||||
//# Gnome Battas
|
||||
// # Gnome Battas
|
||||
food(name = "fruit_batta", id = 2225, restoration = 11)
|
||||
food(name = "fruit_batta", id = 2277, restoration = 11)
|
||||
food(name = "toad_batta", id = 2221, restoration = 11)
|
||||
|
||||
@@ -3,8 +3,8 @@ package org.apollo.plugin.consumables
|
||||
import io.mockk.verify
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.model.entity.Skill
|
||||
import org.apollo.game.plugin.testing.assertions.contains
|
||||
import org.apollo.game.plugin.testing.assertions.after
|
||||
import org.apollo.game.plugin.testing.assertions.contains
|
||||
import org.apollo.game.plugin.testing.assertions.verifyAfter
|
||||
import org.apollo.game.plugin.testing.junit.ApolloTestingExtension
|
||||
import org.apollo.game.plugin.testing.junit.api.ActionCapture
|
||||
@@ -81,15 +81,13 @@ class FoodOrDrinkTests {
|
||||
fun `A message should be sent saying the player has drank an item when consuming a drink`() {
|
||||
player.interactWithItem(TEST_DRINK_ID, option = 1, slot = 1)
|
||||
|
||||
verifyAfter(action.complete()) { player.sendMessage("You drink the ${TEST_DRINK_NAME}.") }
|
||||
|
||||
verifyAfter(action.complete()) { player.sendMessage("You drink the $TEST_DRINK_NAME.") }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `A message should be sent saying the player has eaten an item when consuming food`() {
|
||||
player.interactWithItem(TEST_FOOD_ID, option = 1, slot = 1)
|
||||
|
||||
verifyAfter(action.complete()) { player.sendMessage("You eat the ${TEST_FOOD_NAME}.") }
|
||||
verifyAfter(action.complete()) { player.sendMessage("You eat the $TEST_FOOD_NAME.") }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
import kotlinx.coroutines.experimental.*
|
||||
import kotlinx.coroutines.experimental.channels.Channel
|
||||
import kotlinx.coroutines.experimental.selects.select
|
||||
import org.apollo.game.action.ActionBlock
|
||||
import org.apollo.game.action.AsyncDistancedAction
|
||||
import org.apollo.game.action.DistancedAction
|
||||
import org.apollo.game.message.impl.ObjectActionMessage
|
||||
import org.apollo.game.model.Animation
|
||||
import org.apollo.game.model.Position
|
||||
@@ -50,10 +47,8 @@ class DummyAction(val player: Player, position: Position) : AsyncDistancedAction
|
||||
player.startAction(DummyAction(player, position))
|
||||
message.terminate()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun action(): ActionBlock = {
|
||||
mob.sendMessage("You hit the dummy.")
|
||||
mob.turnTo(position)
|
||||
@@ -68,5 +63,4 @@ class DummyAction(val player: Player, position: Position) : AsyncDistancedAction
|
||||
skills.addExperience(Skill.ATTACK, EXP_PER_HIT)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ import org.apollo.game.model.World
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.model.entity.Skill
|
||||
import org.apollo.game.plugin.testing.assertions.after
|
||||
import org.apollo.game.plugin.testing.assertions.contains
|
||||
import org.apollo.game.plugin.testing.junit.ApolloTestingExtension
|
||||
import org.apollo.game.plugin.testing.junit.api.ActionCapture
|
||||
import org.apollo.game.plugin.testing.junit.api.annotations.TestMock
|
||||
import org.apollo.game.plugin.testing.junit.api.interactions.interactWith
|
||||
import org.apollo.game.plugin.testing.junit.api.interactions.spawnObject
|
||||
import org.apollo.game.plugin.testing.assertions.contains
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
@@ -60,5 +60,4 @@ class TrainingDummyTest {
|
||||
assertEquals(beforeExp, skills.getExperience(Skill.ATTACK))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.apollo.game.plugin.entity.actions
|
||||
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.model.event.PlayerEvent
|
||||
|
||||
class PlayerActionEvent(player: Player, val target: Player, val action: PlayerActionType) : PlayerEvent(player)
|
||||
+1
-4
@@ -1,11 +1,8 @@
|
||||
package org.apollo.game.plugin.entity.actions
|
||||
|
||||
import java.util.*
|
||||
import org.apollo.game.message.impl.SetPlayerActionMessage
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.model.event.PlayerEvent
|
||||
import java.util.*
|
||||
|
||||
class PlayerActionEvent(player: Player, val target: Player, val action: PlayerActionType) : PlayerEvent(player)
|
||||
|
||||
fun Player.enableAction(action: PlayerActionType) {
|
||||
send(SetPlayerActionMessage(action.displayName, action.slot, action.primary))
|
||||
@@ -30,5 +30,4 @@ class PlayerActionTests {
|
||||
verify { player.send(eq(SetPlayerActionMessage("null", type.slot, type.primary))) }
|
||||
assertFalse(player.actionEnabled(type)) { "Action $type should not have been enabled, but was." }
|
||||
}
|
||||
|
||||
}
|
||||
-1
@@ -46,5 +46,4 @@ class FollowAction(player: Player, private val target: Player) : Action<Player>(
|
||||
lastPosition = target.position
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-1
@@ -2,7 +2,6 @@ package org.apollo.plugin.entity.following
|
||||
|
||||
import org.apollo.game.plugin.entity.actions.PlayerActionEvent
|
||||
import org.apollo.game.plugin.entity.actions.PlayerActionType
|
||||
import org.apollo.plugin.entity.following.FollowAction
|
||||
|
||||
on_player_event { PlayerActionEvent::class }
|
||||
.where { action == PlayerActionType.FOLLOW }
|
||||
|
||||
@@ -139,5 +139,4 @@ class SpawnTests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@ spawnNpc("oziach", x = 3067, y = 3518, facing = Direction.EAST)
|
||||
spawnNpc("shop_keeper", id = 528, x = 3079, y = 3509)
|
||||
spawnNpc("shop_assistant", id = 529, x = 3082, y = 3513)
|
||||
|
||||
|
||||
spawnNpc("banker", x = 3096, y = 3489, facing = Direction.WEST)
|
||||
spawnNpc("banker", x = 3096, y = 3491, facing = Direction.WEST)
|
||||
spawnNpc("banker", x = 3096, y = 3492)
|
||||
|
||||
@@ -56,7 +56,6 @@ spawnNpc("woman", x = 3221, y = 3396)
|
||||
spawnNpc("woman", id = 5, x = 3279, y = 3497)
|
||||
spawnNpc("woman", id = 25, x = 3278, y = 3492)
|
||||
|
||||
|
||||
spawnNpc("thief", x = 3285, y = 3500)
|
||||
spawnNpc("thief", x = 3234, y = 3389)
|
||||
spawnNpc("thief", x = 3188, y = 3383)
|
||||
@@ -130,7 +129,6 @@ spawnNpc("warrior_woman", x = 3205, y = 3493)
|
||||
spawnNpc("swan", x = 3261, y = 3354)
|
||||
spawnNpc("swan", x = 3260, y = 3356)
|
||||
|
||||
|
||||
spawnNpc("ram", id = 3673, x = 3238, y = 3346)
|
||||
spawnNpc("ram", id = 3673, x = 3248, y = 3352)
|
||||
spawnNpc("ram", id = 3673, x = 3260, y = 3348)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
val LOGOUT_BUTTON_ID = 2458
|
||||
|
||||
on_button(LOGOUT_BUTTON_ID)
|
||||
.where { widgetId == LOGOUT_BUTTON_ID }
|
||||
.then { it.logout() }
|
||||
.where { widgetId == LOGOUT_BUTTON_ID }
|
||||
.then { it.logout() }
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import io.mockk.verify
|
||||
import org.apollo.game.message.impl.ButtonMessage
|
||||
import org.apollo.game.model.entity.Player
|
||||
@@ -8,20 +7,19 @@ import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
|
||||
@ExtendWith(ApolloTestingExtension::class)
|
||||
class LogoutTests {
|
||||
class LogoutTests {
|
||||
|
||||
companion object {
|
||||
const val LOGOUT_BUTTON_ID = 2458
|
||||
}
|
||||
companion object {
|
||||
const val LOGOUT_BUTTON_ID = 2458
|
||||
}
|
||||
|
||||
@TestMock
|
||||
lateinit var player: Player
|
||||
|
||||
@Test
|
||||
@Test
|
||||
fun `The player should be logged out when they click the logout button`() {
|
||||
player.send(ButtonMessage(LOGOUT_BUTTON_ID))
|
||||
player.send(ButtonMessage(LOGOUT_BUTTON_ID))
|
||||
|
||||
verify { player.logout() }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.apollo.plugin.navigation.door
|
||||
|
||||
import java.util.*
|
||||
import org.apollo.game.action.DistancedAction
|
||||
import org.apollo.game.model.Direction
|
||||
import org.apollo.game.model.Position
|
||||
@@ -10,7 +11,6 @@ import org.apollo.game.model.entity.obj.GameObject
|
||||
import org.apollo.game.model.event.PlayerEvent
|
||||
import org.apollo.game.plugin.api.findObject
|
||||
import org.apollo.net.message.Message
|
||||
import java.util.*
|
||||
|
||||
enum class DoorType {
|
||||
LEFT, RIGHT, NOT_SUPPORTED
|
||||
@@ -59,7 +59,6 @@ class Door(private val gameObject: GameObject) {
|
||||
return type() !== DoorType.NOT_SUPPORTED
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Computes the given door type by which id exists in
|
||||
* the supported left and right hinged doors
|
||||
@@ -97,7 +96,6 @@ class Door(private val gameObject: GameObject) {
|
||||
toggledDoors.remove(gameObject)
|
||||
regionRepository.fromPosition(originalDoor.position).addEntity(originalDoor)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +118,6 @@ class Door(private val gameObject: GameObject) {
|
||||
DoorType.NOT_SUPPORTED -> null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class OpenDoorAction(private val player: Player, private val door: Door, position: Position) : DistancedAction<Player>(
|
||||
@@ -140,7 +137,6 @@ class OpenDoorAction(private val player: Player, private val door: Door, positio
|
||||
player.startAction(OpenDoorAction(player, door, position))
|
||||
message.terminate()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun executeAction() {
|
||||
@@ -156,7 +152,6 @@ class OpenDoorAction(private val player: Player, private val door: Door, positio
|
||||
}
|
||||
|
||||
override fun hashCode(): Int = Objects.hash(position, player)
|
||||
|
||||
}
|
||||
|
||||
class OpenDoorEvent(player: Player) : PlayerEvent(player)
|
||||
|
||||
@@ -4,7 +4,7 @@ val WALK_BUTTON_ID = 152
|
||||
val RUN_BUTTON_ID = 153
|
||||
|
||||
on { ButtonMessage::class }
|
||||
.where { widgetId == WALK_BUTTON_ID || widgetId == RUN_BUTTON_ID }
|
||||
.then {
|
||||
it.toggleRunning()
|
||||
}
|
||||
.where { widgetId == WALK_BUTTON_ID || widgetId == RUN_BUTTON_ID }
|
||||
.then {
|
||||
it.toggleRunning()
|
||||
}
|
||||
@@ -50,7 +50,6 @@ class OpenShopAction(
|
||||
shop.removeListener(shopListener)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,5 +63,4 @@ class PlayerInventorySupplier : InventorySupplier {
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,8 +45,12 @@ class ShopBuilder(val name: String) {
|
||||
* @param depluralise Whether or not the category name should have the "s".
|
||||
* @param builder The builder used to add items to the category.
|
||||
*/
|
||||
fun category(name: String, affix: Affix = Affix.Suffix, depluralise: Boolean = true,
|
||||
builder: CategoryWrapper.() -> Unit) {
|
||||
fun category(
|
||||
name: String,
|
||||
affix: Affix = Affix.Suffix,
|
||||
depluralise: Boolean = true,
|
||||
builder: CategoryWrapper.() -> Unit
|
||||
) {
|
||||
val items = mutableListOf<Pair<String, Int>>()
|
||||
builder.invoke(CategoryWrapper(items))
|
||||
|
||||
@@ -118,7 +122,6 @@ class ShopBuilder(val name: String) {
|
||||
* Gets the [List] of shop operator ids.
|
||||
*/
|
||||
internal fun operators(): MutableList<Int> = operated.operators
|
||||
|
||||
}
|
||||
|
||||
@ShopDslMarker
|
||||
@@ -148,14 +151,12 @@ class CategoryWrapper(private val items: MutableList<Pair<String, Int>>) {
|
||||
* Joins the item and category name in the expected manner.
|
||||
*/
|
||||
fun join(item: String, category: String): String = joiner(item, category)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a [SellBuilder] with the specified [amount].
|
||||
*/
|
||||
fun sell(amount: Int): SellBuilder = SellBuilder(amount, items)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,7 +211,6 @@ class OperatorBuilder internal constructor() {
|
||||
* `"Shopkeeper"(500) vs `"Shopkeeper"(501)`). Use [by(String][by] if the npc name is unambiguous.
|
||||
*/
|
||||
operator fun plus(pair: Pair<String, Int>): OperatorBuilder = by(pair)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,7 +270,6 @@ class ActionBuilder {
|
||||
*/
|
||||
override fun hashCode(): Int = throw UnsupportedOperationException("ActionBuilder is a utility class for a DSL " +
|
||||
"and improperly implements equals() - it should not be used anywhere outside of the DSL.")
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,7 +287,6 @@ class CurrencyBuilder {
|
||||
builder.currency = this
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,7 +310,6 @@ class PurchasesBuilder {
|
||||
infix fun any(@Suppress("UNUSED_PARAMETER") items: Unit) {
|
||||
policy = Shop.PurchasePolicy.ANY
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -348,5 +345,4 @@ class SellBuilder(val amount: Int, val items: MutableList<Pair<String, Int>>) {
|
||||
* Overloads function invokation on Strings to map `"ambiguous_npc_name"(id)` to a [Pair].
|
||||
*/
|
||||
operator fun String.invoke(id: Int): Pair<String, Int> = Pair(this, id)
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ object Interfaces {
|
||||
* The id of the text widget that displays a shop's name.
|
||||
*/
|
||||
const val SHOP_NAME = 3901
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +68,6 @@ data class Currency(val id: Int, val plural: Boolean = false) {
|
||||
else -> name
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +122,6 @@ class Shop(
|
||||
else -> throw IllegalArgumentException("Option must be 1-4")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -331,5 +328,4 @@ class Shop(
|
||||
* @param id The id of the [Item] to sell.
|
||||
*/
|
||||
private fun sells(id: Int): Boolean = sells.containsKey(id)
|
||||
|
||||
}
|
||||
@@ -27,5 +27,4 @@ enum class Fish(val id: Int, val level: Int, val experience: Double, catchSuffix
|
||||
val catchMessage by lazy { "You catch ${catchSuffix ?: "a $catchName."}" }
|
||||
|
||||
private val catchName by lazy { Definitions.item(id).name.toLowerCase().removePrefix("raw ") }
|
||||
|
||||
}
|
||||
|
||||
+1
-3
@@ -1,10 +1,10 @@
|
||||
package org.apollo.game.plugin.skills.fishing
|
||||
|
||||
import java.util.Objects
|
||||
import org.apollo.game.action.ActionBlock
|
||||
import org.apollo.game.action.AsyncDistancedAction
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.plugin.api.fishing
|
||||
import java.util.Objects
|
||||
|
||||
class FishingAction(
|
||||
player: Player,
|
||||
@@ -82,7 +82,5 @@ class FishingAction(
|
||||
internal fun hasTool(player: Player, tool: FishingTool): Boolean {
|
||||
return tool.id in player.equipment || tool.id in player.inventory
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -106,9 +106,7 @@ enum class FishingSpot(val npc: Int, private val first: Option, private val seco
|
||||
else -> Pair(tool, secondary, primary)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -119,5 +117,4 @@ enum class FishingSpot(val npc: Int, private val first: Option, private val seco
|
||||
*/
|
||||
fun lookup(id: Int): FishingSpot? = FISHING_SPOTS[id]
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,5 +35,4 @@ data class FishingTarget(val position: Position, val option: FishingSpot.Option)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,5 +29,4 @@ enum class FishingTool(
|
||||
* The name of this tool, formatted so it can be inserted into a message.
|
||||
*/
|
||||
val formattedName by lazy { Definitions.item(id).name.toLowerCase() }
|
||||
|
||||
}
|
||||
-1
@@ -89,5 +89,4 @@ class FishingActionTests {
|
||||
private val spots = FishingSpot.values()
|
||||
.map { NpcDefinition(it.npc).apply { name = "<fishing_spot>" } }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import java.util.Objects
|
||||
import org.apollo.game.action.ActionBlock
|
||||
import org.apollo.game.action.AsyncAction
|
||||
import org.apollo.game.model.Animation
|
||||
import org.apollo.game.model.entity.Player
|
||||
import java.util.Objects
|
||||
|
||||
class CrushIngredientAction(
|
||||
player: Player,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
|
||||
import java.util.Objects
|
||||
import org.apollo.game.action.ActionBlock
|
||||
import org.apollo.game.action.AsyncAction
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.plugin.api.herblore
|
||||
import org.apollo.util.LanguageUtil
|
||||
import java.util.Objects
|
||||
|
||||
class IdentifyHerbAction(
|
||||
player: Player,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import java.util.*
|
||||
import org.apollo.game.action.ActionBlock
|
||||
import org.apollo.game.action.AsyncAction
|
||||
import org.apollo.game.model.Animation
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.model.entity.Skill
|
||||
import org.apollo.game.plugin.api.herblore
|
||||
import java.util.*
|
||||
|
||||
abstract class MakePotionAction(
|
||||
player: Player,
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import java.util.*
|
||||
import org.apollo.game.action.DistancedAction
|
||||
import org.apollo.game.message.impl.ObjectActionMessage
|
||||
import org.apollo.game.model.Position
|
||||
import org.apollo.game.model.entity.Player
|
||||
|
||||
class ExpiredProspectingAction(
|
||||
mob: Player,
|
||||
position: Position
|
||||
) : DistancedAction<Player>(DELAY, true, mob, position, ORE_SIZE) {
|
||||
|
||||
companion object {
|
||||
private const val DELAY = 0
|
||||
private const val ORE_SIZE = 1
|
||||
|
||||
/**
|
||||
* Starts a [ExpiredProspectingAction] for the specified [Player], terminating the [Message] that triggered it.
|
||||
*/
|
||||
fun start(message: ObjectActionMessage, player: Player) {
|
||||
val action = ExpiredProspectingAction(player, message.position)
|
||||
player.startAction(action)
|
||||
|
||||
message.terminate()
|
||||
}
|
||||
}
|
||||
|
||||
override fun executeAction() {
|
||||
mob.sendMessage("There is currently no ore available in this rock.")
|
||||
stop()
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as ExpiredProspectingAction
|
||||
return mob == other.mob && position == other.position
|
||||
}
|
||||
|
||||
override fun hashCode(): Int = Objects.hash(mob, position)
|
||||
}
|
||||
+1
-56
@@ -1,14 +1,12 @@
|
||||
import java.util.*
|
||||
import org.apollo.game.action.ActionBlock
|
||||
import org.apollo.game.action.AsyncDistancedAction
|
||||
import org.apollo.game.message.impl.ObjectActionMessage
|
||||
import org.apollo.game.model.Position
|
||||
import org.apollo.game.model.World
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.plugin.api.*
|
||||
import org.apollo.game.plugin.skills.mining.Ore
|
||||
import org.apollo.game.plugin.skills.mining.Pickaxe
|
||||
import org.apollo.net.message.Message
|
||||
import java.util.*
|
||||
|
||||
class MiningAction(
|
||||
player: Player,
|
||||
@@ -82,57 +80,4 @@ class MiningAction(
|
||||
}
|
||||
|
||||
override fun hashCode(): Int = Objects.hash(mob, target)
|
||||
|
||||
}
|
||||
|
||||
data class MiningTarget(val objectId: Int, val position: Position, val ore: Ore) {
|
||||
|
||||
/**
|
||||
* Deplete this mining resource from the [World], and schedule it to be respawned
|
||||
* in a number of ticks specified by the [Ore].
|
||||
*/
|
||||
fun deplete(world: World) {
|
||||
val obj = world.findObject(position, objectId)!!
|
||||
|
||||
world.replaceObject(obj, ore.objects[objectId]!!, ore.respawn)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the [Player] was successful in mining this ore with a random success [chance] value between 0 and 100.
|
||||
*/
|
||||
fun isSuccessful(mob: Player, chance: Int): Boolean {
|
||||
val percent = (ore.chance * mob.mining.current + ore.chanceOffset) * 100
|
||||
return chance < percent
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this target is still valid in the [World] (i.e. has not been [deplete]d).
|
||||
*/
|
||||
fun isValid(world: World) = world.findObject(position, objectId) != null
|
||||
|
||||
/**
|
||||
* Get the normalized name of the [Ore] represented by this target.
|
||||
*/
|
||||
fun oreName() = Definitions.item(ore.id).name.toLowerCase()
|
||||
|
||||
/**
|
||||
* Reward a [player] with experience and ore if they have the inventory capacity to take a new ore.
|
||||
*/
|
||||
fun reward(player: Player): Boolean {
|
||||
val hasInventorySpace = player.inventory.add(ore.id)
|
||||
|
||||
if (hasInventorySpace) {
|
||||
player.mining.experience += ore.exp
|
||||
}
|
||||
|
||||
return hasInventorySpace
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the [mob] has met the skill requirements to mine te [Ore] represented by
|
||||
* this [MiningTarget].
|
||||
*/
|
||||
fun skillRequirementsMet(mob: Player) = mob.mining.current < ore.level
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import org.apollo.game.model.Position
|
||||
import org.apollo.game.model.World
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.plugin.api.Definitions
|
||||
import org.apollo.game.plugin.api.findObject
|
||||
import org.apollo.game.plugin.api.mining
|
||||
import org.apollo.game.plugin.api.replaceObject
|
||||
import org.apollo.game.plugin.skills.mining.Ore
|
||||
|
||||
data class MiningTarget(val objectId: Int, val position: Position, val ore: Ore) {
|
||||
|
||||
/**
|
||||
* Deplete this mining resource from the [World], and schedule it to be respawned
|
||||
* in a number of ticks specified by the [Ore].
|
||||
*/
|
||||
fun deplete(world: World) {
|
||||
val obj = world.findObject(position, objectId)!!
|
||||
|
||||
world.replaceObject(obj, ore.objects[objectId]!!, ore.respawn)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the [Player] was successful in mining this ore with a random success [chance] value between 0 and 100.
|
||||
*/
|
||||
fun isSuccessful(mob: Player, chance: Int): Boolean {
|
||||
val percent = (ore.chance * mob.mining.current + ore.chanceOffset) * 100
|
||||
return chance < percent
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this target is still valid in the [World] (i.e. has not been [deplete]d).
|
||||
*/
|
||||
fun isValid(world: World) = world.findObject(position, objectId) != null
|
||||
|
||||
/**
|
||||
* Get the normalized name of the [Ore] represented by this target.
|
||||
*/
|
||||
fun oreName() = Definitions.item(ore.id).name.toLowerCase()
|
||||
|
||||
/**
|
||||
* Reward a [player] with experience and ore if they have the inventory capacity to take a new ore.
|
||||
*/
|
||||
fun reward(player: Player): Boolean {
|
||||
val hasInventorySpace = player.inventory.add(ore.id)
|
||||
|
||||
if (hasInventorySpace) {
|
||||
player.mining.experience += ore.exp
|
||||
}
|
||||
|
||||
return hasInventorySpace
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the [mob] has met the skill requirements to mine te [Ore] represented by
|
||||
* this [MiningTarget].
|
||||
*/
|
||||
fun skillRequirementsMet(mob: Player) = mob.mining.current < ore.level
|
||||
}
|
||||
@@ -36,7 +36,6 @@ enum class Ore(
|
||||
|
||||
fun fromRock(id: Int): Ore? = ORE_ROCKS[id]
|
||||
fun fromExpiredRock(id: Int): Ore? = EXPIRED_ORE[id]
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-40
@@ -1,13 +1,12 @@
|
||||
import java.util.Objects
|
||||
import org.apollo.game.action.ActionBlock
|
||||
import org.apollo.game.action.AsyncDistancedAction
|
||||
import org.apollo.game.action.DistancedAction
|
||||
import org.apollo.game.message.impl.ObjectActionMessage
|
||||
import org.apollo.game.model.Position
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.plugin.api.Definitions
|
||||
import org.apollo.game.plugin.skills.mining.Ore
|
||||
import org.apollo.net.message.Message
|
||||
import java.util.Objects
|
||||
|
||||
class ProspectingAction(
|
||||
player: Player,
|
||||
@@ -51,42 +50,4 @@ class ProspectingAction(
|
||||
}
|
||||
|
||||
override fun hashCode(): Int = Objects.hash(mob, position, ore)
|
||||
|
||||
}
|
||||
|
||||
class ExpiredProspectingAction(
|
||||
mob: Player,
|
||||
position: Position
|
||||
) : DistancedAction<Player>(DELAY, true, mob, position, ORE_SIZE) {
|
||||
|
||||
companion object {
|
||||
private const val DELAY = 0
|
||||
private const val ORE_SIZE = 1
|
||||
|
||||
/**
|
||||
* Starts a [ExpiredProspectingAction] for the specified [Player], terminating the [Message] that triggered it.
|
||||
*/
|
||||
fun start(message: ObjectActionMessage, player: Player) {
|
||||
val action = ExpiredProspectingAction(player, message.position)
|
||||
player.startAction(action)
|
||||
|
||||
message.terminate()
|
||||
}
|
||||
}
|
||||
|
||||
override fun executeAction() {
|
||||
mob.sendMessage("There is currently no ore available in this rock.")
|
||||
stop()
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as ExpiredProspectingAction
|
||||
return mob == other.mob && position == other.position
|
||||
}
|
||||
|
||||
override fun hashCode(): Int = Objects.hash(mob, position)
|
||||
|
||||
}
|
||||
@@ -87,5 +87,4 @@ class MiningActionTests {
|
||||
@ItemDefinitions
|
||||
fun pickaxes() = listOf(ItemDefinition(Pickaxe.BRONZE.id))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,6 @@ class PickaxeTests {
|
||||
assertEquals(null, Pickaxe.bestFor(player))
|
||||
}
|
||||
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(Pickaxe::class)
|
||||
fun `The highest level pickaxe is chosen when available`(pickaxe: Pickaxe) {
|
||||
@@ -43,7 +42,6 @@ class PickaxeTests {
|
||||
assertEquals(Pickaxe.BRONZE, Pickaxe.bestFor(player))
|
||||
}
|
||||
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(value = Pickaxe::class)
|
||||
fun `Pickaxes can be chosen from equipment as well as inventory`(pickaxe: Pickaxe) {
|
||||
@@ -53,7 +51,6 @@ class PickaxeTests {
|
||||
assertEquals(pickaxe, Pickaxe.bestFor(player))
|
||||
}
|
||||
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(value = Pickaxe::class)
|
||||
fun `Pickaxes with a level requirement higher than the player's are ignored`(pickaxe: Pickaxe) {
|
||||
@@ -73,5 +70,4 @@ class PickaxeTests {
|
||||
ItemDefinition(it.id).apply { isStackable = false }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,5 +45,4 @@ class ProspectingTests {
|
||||
ItemDefinition(it.id).also { it.name = "<ore_type>" }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import java.util.stream.Stream
|
||||
import org.apollo.game.plugin.skills.mining.Ore
|
||||
import org.junit.jupiter.api.extension.ExtensionContext
|
||||
import org.junit.jupiter.params.provider.Arguments
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider
|
||||
import java.util.stream.Stream
|
||||
|
||||
data class MiningTestData(val rockId: Int, val expiredRockId: Int, val ore: Ore)
|
||||
|
||||
|
||||
-1
@@ -28,5 +28,4 @@ class BuryBoneAction(
|
||||
public val BURY_BONE_ANIMATION = Animation(827)
|
||||
internal const val BURY_OPTION = 1
|
||||
}
|
||||
|
||||
}
|
||||
@@ -70,5 +70,4 @@ class BuryBoneTests {
|
||||
return Bone.values().map { ItemDefinition(it.id) }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package org.apollo.game.plugin.skill.runecrafting
|
||||
|
||||
import org.apollo.game.plugin.skill.runecrafting.Altar.*
|
||||
|
||||
|
||||
interface Rune {
|
||||
/**
|
||||
* The item id of the rune.
|
||||
@@ -29,7 +28,7 @@ interface Rune {
|
||||
*
|
||||
* [playerLevel] - The players current runecrafting level.
|
||||
*/
|
||||
fun getBonusMultiplier(playerLevel: Int) : Double
|
||||
fun getBonusMultiplier(playerLevel: Int): Double
|
||||
}
|
||||
|
||||
enum class DefaultRune(
|
||||
|
||||
@@ -8,11 +8,10 @@ private val changeAltarObjectConfigId = 491
|
||||
|
||||
internal val RUNES = mutableListOf<Rune>()
|
||||
|
||||
fun List<Rune>.findById(id: Int) : Rune? {
|
||||
fun List<Rune>.findById(id: Int): Rune? {
|
||||
return find { rune -> rune.id == id }
|
||||
}
|
||||
|
||||
|
||||
start {
|
||||
RUNES.addAll(DefaultRune.values())
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class RunecraftingAction(val player: Player, val rune: Rune, altar: Altar) : Asy
|
||||
|
||||
wait(1)
|
||||
|
||||
val name = Definitions.item(rune.id).name;
|
||||
val name = Definitions.item(rune.id).name
|
||||
val nameArticle = LanguageUtil.getIndefiniteArticle(name)
|
||||
val essenceAmount = player.inventory.removeAll(runeEssenceId)
|
||||
val runeAmount = essenceAmount * rune.getBonusMultiplier(player.runecraft.current)
|
||||
|
||||
@@ -27,7 +27,6 @@ class RunecraftingActionTests {
|
||||
fun setupPlayer() {
|
||||
player.position = TEST_ALTAR.center
|
||||
player.inventory.add(runeEssenceId, 25)
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-3
@@ -1,4 +1,5 @@
|
||||
|
||||
import java.util.concurrent.TimeUnit
|
||||
import org.apollo.game.GameConstants
|
||||
import org.apollo.game.action.ActionBlock
|
||||
import org.apollo.game.action.AsyncDistancedAction
|
||||
@@ -10,7 +11,6 @@ import org.apollo.game.model.entity.obj.GameObject
|
||||
import org.apollo.game.plugin.api.*
|
||||
import org.apollo.game.plugin.skills.woodcutting.Axe
|
||||
import org.apollo.game.plugin.skills.woodcutting.Tree
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
// TODO Accurate chopping rates, e.g. https://twitter.com/JagexKieren/status/713403124464107520
|
||||
|
||||
@@ -33,7 +33,6 @@ class WoodcuttingTarget(private val objectId: Int, val position: Position, val t
|
||||
* Returns whether or not the tree was cut down.
|
||||
*/
|
||||
fun isCutDown(): Boolean = rand(100) <= tree.chance * 100
|
||||
|
||||
}
|
||||
|
||||
class WoodcuttingAction(
|
||||
@@ -102,5 +101,4 @@ class WoodcuttingAction(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.EnumSource
|
||||
|
||||
@ExtendWith(ApolloTestingExtension::class)
|
||||
class AxeTests {
|
||||
class AxeTests {
|
||||
|
||||
@TestMock
|
||||
lateinit var player: Player
|
||||
@@ -70,5 +70,4 @@ class AxeTests {
|
||||
ItemDefinition(it.id).apply { isStackable = false }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import java.util.stream.Stream
|
||||
import org.apollo.game.plugin.skills.woodcutting.Tree
|
||||
import org.junit.jupiter.api.extension.ExtensionContext
|
||||
import org.junit.jupiter.params.provider.Arguments
|
||||
import org.junit.jupiter.params.provider.ArgumentsProvider
|
||||
import java.util.stream.Stream
|
||||
|
||||
data class WoodcuttingTestData(val treeId: Int, val stumpId: Int, val tree: Tree)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import java.util.Random
|
||||
import org.apollo.cache.def.ItemDefinition
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.model.entity.Skill
|
||||
@@ -20,7 +21,6 @@ import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.ArgumentsSource
|
||||
import java.util.Random
|
||||
|
||||
@ExtendWith(ApolloTestingExtension::class)
|
||||
class WoodcuttingTests {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.apollo.game.action
|
||||
|
||||
import kotlinx.coroutines.experimental.suspendCancellableCoroutine
|
||||
import java.util.concurrent.CancellationException
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
@@ -11,6 +10,7 @@ import kotlin.coroutines.experimental.RestrictsSuspension
|
||||
import kotlin.coroutines.experimental.intrinsics.COROUTINE_SUSPENDED
|
||||
import kotlin.coroutines.experimental.intrinsics.createCoroutineUnchecked
|
||||
import kotlin.coroutines.experimental.intrinsics.suspendCoroutineOrReturn
|
||||
import kotlinx.coroutines.experimental.suspendCancellableCoroutine
|
||||
|
||||
typealias ActionPredicate = () -> Boolean
|
||||
typealias ActionBlock = suspend ActionCoroutine.() -> Unit
|
||||
|
||||
@@ -25,5 +25,5 @@ interface AsyncActionTrait {
|
||||
/**
|
||||
* Create a new `ActionBlock` to execute.
|
||||
*/
|
||||
fun action() : ActionBlock
|
||||
fun action(): ActionBlock
|
||||
}
|
||||
@@ -19,4 +19,3 @@ abstract class AsyncDistancedAction<T : Mob> : DistancedAction<T>, AsyncActionTr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package org.apollo.game.plugin.kotlin
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.script.experimental.annotations.KotlinScript
|
||||
import kotlin.script.experimental.annotations.KotlinScriptFileExtension
|
||||
import org.apollo.game.command.Command
|
||||
import org.apollo.game.command.CommandListener
|
||||
import org.apollo.game.message.handler.MessageHandler
|
||||
@@ -12,9 +15,6 @@ import org.apollo.game.model.event.EventListener
|
||||
import org.apollo.game.model.event.PlayerEvent
|
||||
import org.apollo.game.plugin.PluginContext
|
||||
import org.apollo.net.message.Message
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.script.experimental.annotations.KotlinScript
|
||||
import kotlin.script.experimental.annotations.KotlinScriptFileExtension
|
||||
|
||||
@KotlinScript("Apollo Plugin Script")
|
||||
@KotlinScriptFileExtension("plugin.kts")
|
||||
@@ -63,7 +63,6 @@ abstract class KotlinPluginScript(private var world: World, val context: PluginC
|
||||
fun doStop(world: World) {
|
||||
this.stopListener.invoke(world)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,13 +85,11 @@ interface KotlinPlayerHandlerProxyTrait<S : Any> {
|
||||
this.register()
|
||||
}
|
||||
|
||||
|
||||
fun handleProxy(player: Player, subject: S) {
|
||||
if (subject.predicate()) {
|
||||
subject.callback(player)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +103,6 @@ class KotlinPlayerEventHandler<T : PlayerEvent>(val world: World, val type: KCla
|
||||
|
||||
override fun handle(event: T) = handleProxy(event.player, event)
|
||||
override fun register() = world.listenFor(type.java, this)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +130,6 @@ class KotlinEventHandler<S : Event>(val world: World, val type: KClass<S>) : Eve
|
||||
}
|
||||
|
||||
fun register() = world.listenFor(type.java, this)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,7 +143,6 @@ class KotlinMessageHandler<T : Message>(val world: World, val context: PluginCon
|
||||
|
||||
override fun handle(player: Player, message: T) = handleProxy(player, message)
|
||||
override fun register() = context.addMessageHandler(type.java, this)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,5 +156,4 @@ class KotlinCommandHandler(val world: World, val command: String, privileges: Pr
|
||||
|
||||
override fun execute(player: Player, command: Command) = handleProxy(player, command)
|
||||
override fun register() = world.commandDispatcher.register(command, this)
|
||||
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ formatting:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
NoWildcardImports:
|
||||
active: true
|
||||
active: false
|
||||
autoCorrect: true
|
||||
ParameterListWrapping:
|
||||
active: true
|
||||
@@ -304,10 +304,11 @@ naming:
|
||||
minimumFunctionNameLength: 3
|
||||
FunctionNaming:
|
||||
active: true
|
||||
functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
|
||||
functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)|(on_[a-zA-Z_$0-9]*)$'
|
||||
excludeClassPattern: '$^'
|
||||
MatchingDeclarationName:
|
||||
active: true
|
||||
autoCorrect: true
|
||||
MemberNameEqualsClassName:
|
||||
active: false
|
||||
ignoreOverriddenFunction: true
|
||||
@@ -317,7 +318,7 @@ naming:
|
||||
constantPattern: '[A-Za-z][_A-Za-z0-9]*'
|
||||
PackageNaming:
|
||||
active: true
|
||||
packagePattern: '^[a-z]+(\.[a-z][a-z0-9]*)*$'
|
||||
packagePattern: '^[a-z]+(\.[a-z][a-zA-Z0-9]*)*$'
|
||||
TopLevelPropertyNaming:
|
||||
active: false
|
||||
constantPattern: '[A-Z][_A-Z0-9]*'
|
||||
@@ -470,5 +471,5 @@ style:
|
||||
VarCouldBeVal:
|
||||
active: false
|
||||
WildcardImport:
|
||||
active: true
|
||||
active: false
|
||||
excludeImports: 'java.util.*,kotlinx.android.synthetic.*'
|
||||
|
||||
Reference in New Issue
Block a user