update to 1.18.2
This commit is contained in:
@@ -33,7 +33,7 @@ object BrigardierSupport {
|
||||
}
|
||||
|
||||
@Suppress("HasPlatformType")
|
||||
fun resolveCommandManager() = (server as org.bukkit.craftbukkit.v1_18_R1.CraftServer)
|
||||
fun resolveCommandManager() = (server as org.bukkit.craftbukkit.v1_18_R2.CraftServer)
|
||||
.server.vanillaCommandDispatcher
|
||||
|
||||
internal fun registerAll() {
|
||||
@@ -52,7 +52,7 @@ object BrigardierSupport {
|
||||
fun updateCommandTree() {
|
||||
onlinePlayers.forEach {
|
||||
// send the command tree
|
||||
resolveCommandManager().sendCommands((it as org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer).handle)
|
||||
resolveCommandManager().sendCommands((it as org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer).handle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,11 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package net.axay.kspigot.data
|
||||
|
||||
import net.axay.kspigot.annotations.NMS_General
|
||||
import net.minecraft.nbt.CompoundTag
|
||||
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity
|
||||
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity
|
||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack
|
||||
import org.bukkit.entity.Entity
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
|
@@ -1,64 +1,50 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package net.axay.kspigot.extensions.bukkit
|
||||
|
||||
// FROM BUNGEE COLOR
|
||||
import net.kyori.adventure.text.format.TextColor
|
||||
import org.bukkit.Color as BukkitColor
|
||||
import java.awt.Color as JavaColor
|
||||
|
||||
// FROM ADVENTURE TEXTCOLOR
|
||||
|
||||
/**
|
||||
* Returns the corresponding Bukkit Color object.
|
||||
*/
|
||||
val net.md_5.bungee.api.ChatColor.bukkitColor
|
||||
get() = org.bukkit.Color.fromRGB(color.rgb)
|
||||
val TextColor.bukkitColor
|
||||
get() = BukkitColor.fromRGB(value())
|
||||
|
||||
/**
|
||||
* Returns the corresponding Java Color object.
|
||||
* @see net.md_5.bungee.api.ChatColor.color
|
||||
*/
|
||||
val net.md_5.bungee.api.ChatColor.javaAwtColor: java.awt.Color
|
||||
get() = color
|
||||
val TextColor.javaAwtColor: JavaColor
|
||||
get() = JavaColor(value())
|
||||
|
||||
// FROM BUKKIT COLOR
|
||||
|
||||
/**
|
||||
* Returns the corresponding Bungee Color object.
|
||||
*/
|
||||
val org.bukkit.Color.bungeeColor: net.md_5.bungee.api.ChatColor
|
||||
get() = net.md_5.bungee.api.ChatColor.of(java.awt.Color(asRGB()))
|
||||
val BukkitColor.textColor: TextColor
|
||||
get() = TextColor.color(asRGB())
|
||||
|
||||
/**
|
||||
* Returns the corresponding Java Color object.
|
||||
*/
|
||||
val org.bukkit.Color.javaAwtColor: java.awt.Color
|
||||
get() = java.awt.Color(asRGB())
|
||||
val BukkitColor.javaAwtColor: JavaColor
|
||||
get() = JavaColor(asRGB())
|
||||
|
||||
// FROM JAVA AWT COLOR
|
||||
|
||||
/**
|
||||
* Returns the corresponding Bukkit Color object.
|
||||
*/
|
||||
val java.awt.Color.bukkitColor
|
||||
get() = org.bukkit.Color.fromRGB(rgb)
|
||||
val JavaColor.bukkitColor
|
||||
get() = BukkitColor.fromRGB(rgb)
|
||||
|
||||
/**
|
||||
* Returns the corresponding Bungee Color object.
|
||||
*/
|
||||
val java.awt.Color.bungeeColor: net.md_5.bungee.api.ChatColor
|
||||
get() = net.md_5.bungee.api.ChatColor.of(this)
|
||||
|
||||
// FROM BUKKIT CHAT COLOR
|
||||
|
||||
/**
|
||||
* Returns the corresponding Bukkit Color object.
|
||||
*/
|
||||
val org.bukkit.ChatColor.bukkitColor
|
||||
get() = bungeeColor.bukkitColor
|
||||
|
||||
/**
|
||||
* Returns the corresponding Bungee Color object.
|
||||
*/
|
||||
val org.bukkit.ChatColor.bungeeColor: net.md_5.bungee.api.ChatColor
|
||||
get() = net.md_5.bungee.api.ChatColor.of(name)
|
||||
|
||||
/**
|
||||
* Returns the corresponding Java Color object.
|
||||
*/
|
||||
val org.bukkit.ChatColor.javaAwtColor: java.awt.Color
|
||||
get() = bungeeColor.javaAwtColor
|
||||
val JavaColor.textColor: TextColor
|
||||
get() = TextColor.color(rgb)
|
||||
|
@@ -1,36 +1,40 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package net.axay.kspigot.extensions.bukkit
|
||||
|
||||
import net.axay.kspigot.chat.KColors
|
||||
import net.axay.kspigot.main.PluginInstance
|
||||
import net.md_5.bungee.api.ChatColor
|
||||
import net.kyori.adventure.text.Component
|
||||
import net.kyori.adventure.text.format.TextColor
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.plugin.Plugin
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.print(text: String, plugin: Plugin? = PluginInstance) =
|
||||
printColoredPrefix(text, ChatColor.RESET, plugin?.name ?: "INFO", ChatColor.GRAY)
|
||||
printColoredPrefix(text, KColors.WHITE, plugin?.name ?: "INFO", KColors.GRAY)
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.info(text: String, plugin: Plugin? = PluginInstance) =
|
||||
printColoredPrefix(text, ChatColor.WHITE, plugin?.name ?: "INFO", ChatColor.DARK_AQUA)
|
||||
printColoredPrefix(text, KColors.WHITE, plugin?.name ?: "INFO", KColors.DARKAQUA)
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.success(text: String, plugin: Plugin? = PluginInstance) =
|
||||
printColoredPrefix(text, ChatColor.GREEN, plugin?.name ?: "SUCCESS", ChatColor.DARK_AQUA)
|
||||
printColoredPrefix(text, KColors.GREEN, plugin?.name ?: "SUCCESS", KColors.DARKAQUA)
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.warn(text: String, plugin: Plugin? = PluginInstance) =
|
||||
printColoredPrefix(text, ChatColor.WHITE, plugin?.name?.plus(" - WARN") ?: "WARN", ChatColor.YELLOW)
|
||||
printColoredPrefix(text, KColors.WHITE, plugin?.name?.plus(" - WARN") ?: "WARN", KColors.YELLOW)
|
||||
|
||||
/** @see printColoredPrefix */
|
||||
fun CommandSender.error(text: String, plugin: Plugin? = PluginInstance) =
|
||||
printColoredPrefix(text, ChatColor.RED, plugin?.name?.plus(" - ERROR") ?: "ERROR", ChatColor.DARK_RED)
|
||||
printColoredPrefix(text, KColors.RED, plugin?.name?.plus(" - ERROR") ?: "ERROR", KColors.DARKRED)
|
||||
|
||||
/**
|
||||
* Sends the given message and adds the given prefix with the given color to it.
|
||||
*/
|
||||
fun CommandSender.printColoredPrefix(text: String, textColor: ChatColor, prefix: String, prefixColor: ChatColor) =
|
||||
sendMessage("${prefixColor}[${prefix}]${textColor} $text")
|
||||
fun CommandSender.printColoredPrefix(text: String, textColor: TextColor, prefix: String, prefixColor: TextColor) =
|
||||
sendMessage(Component.text(prefix).color(prefixColor).append(Component.text(text).color(textColor)))
|
||||
|
||||
/**
|
||||
* Dispatches the command given by [commandLine].
|
||||
|
@@ -108,7 +108,7 @@ fun Player.showOnlinePlayers() {
|
||||
@Deprecated("This function is unstable and it cannot be guaranteed that it will work at any time in the future.")
|
||||
@NMS_General
|
||||
fun Location.spawnCleanEntity(entityType: EntityType): Entity? {
|
||||
val craftWorld = world as? org.bukkit.craftbukkit.v1_18_R1.CraftWorld ?: return null
|
||||
val craftWorld = world as? org.bukkit.craftbukkit.v1_18_R2.CraftWorld ?: return null
|
||||
return craftWorld.createEntity(this, entityType.entityClass)?.let {
|
||||
craftWorld.handle.addFreshEntity(it)
|
||||
return@let it.bukkitEntity
|
||||
|
@@ -1,18 +1,21 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package net.axay.kspigot.items
|
||||
|
||||
import net.axay.kspigot.chat.KColors
|
||||
import net.md_5.bungee.api.ChatColor
|
||||
import net.kyori.adventure.text.Component
|
||||
import net.kyori.adventure.text.format.TextColor
|
||||
import net.kyori.adventure.text.format.TextDecoration
|
||||
|
||||
/**
|
||||
* Converts this string into a list of strings, which
|
||||
* Converts this string into a list of components, which
|
||||
* can be used for minecraft lorelists.
|
||||
*/
|
||||
fun String.toLoreList(vararg lineColors: ChatColor = arrayOf(KColors.RESET), lineLength: Int = 40): List<String> {
|
||||
val lineColor = lineColors.joinToString(separator = "")
|
||||
val loreList = ArrayList<String>()
|
||||
fun String.toLoreList(lineColor: TextColor = KColors.WHITE, vararg lineDecorations: TextDecoration = arrayOf(), lineLength: Int = 40): List<Component> {
|
||||
val loreList = ArrayList<Component>()
|
||||
val lineBuilder = StringBuilder()
|
||||
fun submitLine() {
|
||||
loreList += "$lineColor$lineBuilder"
|
||||
loreList += Component.text(lineBuilder.toString()).color(lineColor).decorations(lineDecorations.toMutableSet(), true)
|
||||
lineBuilder.clear()
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,7 @@ import org.bukkit.Location
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.block.Block
|
||||
import org.bukkit.block.data.BlockData
|
||||
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity
|
||||
import org.bukkit.entity.Entity
|
||||
import org.bukkit.entity.EntityType
|
||||
|
||||
@@ -60,6 +60,7 @@ data class StructureDataEntity(
|
||||
constructor(entity: Entity) : this(entity.type, entity.nbtData)
|
||||
constructor(entityType: EntityType) : this(entityType, CompoundTag())
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun createAt(loc: Location) {
|
||||
(loc.spawnCleanEntity(entityType) as CraftEntity).handle.load(nbtData)
|
||||
}
|
||||
|
Reference in New Issue
Block a user