Add unit tests for areas plugin

This commit is contained in:
Major
2018-08-20 21:46:15 +01:00
committed by Major-
parent 50d7e86302
commit 71158b3b5e
7 changed files with 179 additions and 112 deletions
@@ -0,0 +1,42 @@
package org.apollo.game.plugins.area
/**
* A builder for ([Area], [AreaAction]) [Pair]s.
*/
class AreaActionBuilder internal constructor(val name: String, val area: Area) {
private var entrance: AreaListener = { }
private var inside: AreaListener = { }
private var exit: AreaListener = { }
/**
* Places the contents of this builder into an ([Area], [AreaAction]) [Pair].
*/
internal fun build(): Pair<Area, AreaAction> {
return Pair(area, AreaAction(entrance, inside, exit))
}
/**
* The [listener] to execute when a player enters the associated [Area].
*/
fun entrance(listener: AreaListener) {
this.entrance = listener
}
/**
* The [listener] to execute when a player moves around inside the associated [Area].
*/
fun inside(listener: AreaListener) {
this.inside = listener
}
/**
* The [listener] to execute when a player moves exits the associated [Area].
*/
fun exit(listener: AreaListener) {
this.exit = listener
}
}