Improve proposed extensions
This commit is contained in:
@@ -52,5 +52,4 @@ fun pluginKey(key: String) = NamespacedKey(PluginInstance, key)
|
|||||||
/**
|
/**
|
||||||
* Shortcut to get a collection of all worlds
|
* Shortcut to get a collection of all worlds
|
||||||
*/
|
*/
|
||||||
val worlds: Collection<World> get() = Bukkit.getWorlds()
|
val worlds: List<World> get() = Bukkit.getWorlds()
|
||||||
|
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package net.axay.kspigot.extensions.bukkit
|
package net.axay.kspigot.extensions.bukkit
|
||||||
|
|
||||||
import net.axay.kspigot.extensions.console
|
|
||||||
import net.axay.kspigot.main.PluginInstance
|
import net.axay.kspigot.main.PluginInstance
|
||||||
import net.md_5.bungee.api.ChatColor
|
import net.md_5.bungee.api.ChatColor
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
@@ -34,7 +33,9 @@ fun CommandSender.printColoredPrefix(text: String, textColor: ChatColor, prefix:
|
|||||||
sendMessage("${prefixColor}[${prefix}]${textColor} $text")
|
sendMessage("${prefixColor}[${prefix}]${textColor} $text")
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatches a command sent by Console
|
* Dispatches the command given by [commandLine].
|
||||||
|
*
|
||||||
|
* @param commandLine the command without a leading /
|
||||||
*/
|
*/
|
||||||
fun dispatchCommand(commandLine: String) = Bukkit.dispatchCommand(console, commandLine)
|
fun CommandSender.dispatchCommand(commandLine: String) =
|
||||||
|
Bukkit.dispatchCommand(this, commandLine)
|
||||||
|
@@ -30,10 +30,9 @@ val Entity.isFeetInWater: Boolean get() = this.location.block.type == Material.W
|
|||||||
val Entity.isGroundSolid: Boolean get() = this.location.add(0.0, -0.01, 0.0).block.type.isSolid
|
val Entity.isGroundSolid: Boolean get() = this.location.add(0.0, -0.01, 0.0).block.type.isSolid
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the entity stands on a specific material.
|
* Returns the material that is present under the feet of this entity.
|
||||||
* @param material the material you are looking for
|
|
||||||
*/
|
*/
|
||||||
fun Entity.isOnMaterial(material: Material): Boolean = location.block.type == material
|
val Entity.groundMaterial get() = this.location.add(0.0, -0.01, 0.0).block.type
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kills the damageable.
|
* Kills the damageable.
|
||||||
|
@@ -40,5 +40,8 @@ fun SimpleLocation3D.withWorld(world: World) = Location(world, x, y, z).apply {
|
|||||||
fun SimpleChunkLocation.withWorld(world: World) = world.getChunkAt(x, z)
|
fun SimpleChunkLocation.withWorld(world: World) = world.getChunkAt(x, z)
|
||||||
fun Vector.toSimpleLoc() = SimpleLocation3D(x, y, z)
|
fun Vector.toSimpleLoc() = SimpleLocation3D(x, y, z)
|
||||||
fun SimpleLocation3D.toVector() = Vector(x, y, z)
|
fun SimpleLocation3D.toVector() = Vector(x, y, z)
|
||||||
fun Location.printSimple(): String = "[$x, $y, $z]"
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a simple string in the format of `[x, y, z]`.
|
||||||
|
*/
|
||||||
|
fun Location.toSimpleString() = "[$x, $y, $z]"
|
||||||
|
Reference in New Issue
Block a user