Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36c77d81eb | ||
|
|
b6cd56ad15 | ||
|
|
1a524aea94 | ||
|
|
2ebab99a06 | ||
|
|
46663f7edb | ||
|
|
4fad66cd90 | ||
|
|
a9fafeec00 | ||
|
|
0d8308d6cd | ||
|
|
13772002e8 | ||
|
|
c9b84889e7 | ||
|
|
1513578266 |
@@ -29,7 +29,7 @@ and many more.
|
||||
|
||||
# For server owners
|
||||
- Requires ProtocolLib to be installed: get the latest version [here](https://www.spigotmc.org/resources/protocollib.1997/)
|
||||
- Supports 1.16.5+
|
||||
- Supports 1.17+
|
||||
|
||||
## Downloads
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ dependencies {
|
||||
implementation(project(":eco-core:core-plugin"))
|
||||
implementation(project(":eco-core:core-proxy"))
|
||||
implementation(project(":eco-core:core-backend"))
|
||||
implementation(project(":eco-core:core-nms:v1_16_R3"))
|
||||
implementation(project(path = ":eco-core:core-nms:v1_17_R1", configuration = "reobf"))
|
||||
implementation(project(path = ":eco-core:core-nms:v1_18_R1", configuration = "reobf"))
|
||||
}
|
||||
|
||||
@@ -51,7 +51,10 @@ public class Prerequisite {
|
||||
|
||||
/**
|
||||
* Requires the server to be running 1.17.
|
||||
*
|
||||
* @deprecated eco no longer supports versions before 1.17.
|
||||
*/
|
||||
@Deprecated(since = "6.25.2")
|
||||
public static final Prerequisite HAS_1_17 = new Prerequisite(
|
||||
() -> ProxyConstants.NMS_VERSION.contains("17") || HAS_1_18.isMet(),
|
||||
"Requires server to be running 1.17+"
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.willfp.eco.util;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.willfp.eco.core.Prerequisite;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -91,17 +90,15 @@ public final class TeamUtils {
|
||||
MATERIAL_COLORS.put(Material.EMERALD_ORE, ChatColor.GREEN);
|
||||
MATERIAL_COLORS.put(Material.ANCIENT_DEBRIS, ChatColor.DARK_RED);
|
||||
|
||||
if (Prerequisite.HAS_1_17.isMet()) {
|
||||
MATERIAL_COLORS.put(Material.COPPER_ORE, ChatColor.GOLD);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_COPPER_ORE, ChatColor.GOLD);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_COAL_ORE, ChatColor.BLACK);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_IRON_ORE, ChatColor.GRAY);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_GOLD_ORE, ChatColor.YELLOW);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_LAPIS_ORE, ChatColor.BLUE);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_REDSTONE_ORE, ChatColor.RED);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_DIAMOND_ORE, ChatColor.AQUA);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_EMERALD_ORE, ChatColor.GREEN);
|
||||
}
|
||||
MATERIAL_COLORS.put(Material.COPPER_ORE, ChatColor.GOLD);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_COPPER_ORE, ChatColor.GOLD);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_COAL_ORE, ChatColor.BLACK);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_IRON_ORE, ChatColor.GRAY);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_GOLD_ORE, ChatColor.YELLOW);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_LAPIS_ORE, ChatColor.BLUE);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_REDSTONE_ORE, ChatColor.RED);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_DIAMOND_ORE, ChatColor.AQUA);
|
||||
MATERIAL_COLORS.put(Material.DEEPSLATE_EMERALD_ORE, ChatColor.GREEN);
|
||||
}
|
||||
|
||||
private TeamUtils() {
|
||||
|
||||
@@ -77,7 +77,6 @@ class EcoProxyFactory(
|
||||
|
||||
companion object {
|
||||
val SUPPORTED_VERSIONS = listOf(
|
||||
"v1_16_R3",
|
||||
"v1_17_R1",
|
||||
"v1_18_R1"
|
||||
)
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
group 'com.willfp'
|
||||
version rootProject.version
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.spigotmc:spigot:1.16.5-R0.1-SNAPSHOT'
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.v1_16_R3
|
||||
import com.willfp.eco.internal.spigot.proxy.AutoCraftProxy
|
||||
import net.minecraft.server.v1_16_R3.MinecraftKey
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayOutAutoRecipe
|
||||
|
||||
class AutoCraft : AutoCraftProxy {
|
||||
override fun modifyPacket(packet: Any) {
|
||||
val recipePacket = packet as PacketPlayOutAutoRecipe
|
||||
val fKey = recipePacket.javaClass.getDeclaredField("b")
|
||||
fKey.isAccessible = true
|
||||
val key = fKey[recipePacket] as MinecraftKey
|
||||
fKey[recipePacket] = MinecraftKey(key.namespace, key.key + "_displayed")
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.v1_16_R3
|
||||
import com.willfp.eco.internal.spigot.proxy.BlockBreakProxy
|
||||
import net.minecraft.server.v1_16_R3.BlockPosition
|
||||
import org.bukkit.block.Block
|
||||
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class BlockBreak : BlockBreakProxy {
|
||||
override fun breakBlock(
|
||||
player: Player,
|
||||
block: Block
|
||||
) {
|
||||
if (player !is CraftPlayer) {
|
||||
return
|
||||
}
|
||||
player.handle.playerInteractManager.breakBlock(BlockPosition(block.x, block.y, block.z))
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.v1_16_R3
|
||||
|
||||
import com.willfp.eco.core.display.Display
|
||||
import com.willfp.eco.internal.spigot.proxy.ChatComponentProxy
|
||||
import net.kyori.adventure.nbt.api.BinaryTagHolder
|
||||
import net.kyori.adventure.text.BuildableComponent
|
||||
import net.kyori.adventure.text.Component
|
||||
import net.kyori.adventure.text.TranslatableComponent
|
||||
import net.kyori.adventure.text.event.HoverEvent
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer
|
||||
import net.minecraft.server.v1_16_R3.IChatBaseComponent
|
||||
import net.minecraft.server.v1_16_R3.MojangsonParser
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
class ChatComponent : ChatComponentProxy {
|
||||
private val gsonComponentSerializer = GsonComponentSerializer.gson()
|
||||
|
||||
override fun modifyComponent(obj: Any, player: Player): Any {
|
||||
if (obj !is IChatBaseComponent) {
|
||||
return obj
|
||||
}
|
||||
|
||||
val component = gsonComponentSerializer.deserialize(
|
||||
IChatBaseComponent.ChatSerializer.a(
|
||||
obj
|
||||
)
|
||||
).asComponent() as BuildableComponent<*, *>
|
||||
|
||||
val newComponent = modifyBaseComponent(component, player)
|
||||
|
||||
return IChatBaseComponent.ChatSerializer.a(
|
||||
gsonComponentSerializer.serialize(newComponent.asComponent())
|
||||
) ?: obj
|
||||
}
|
||||
|
||||
private fun modifyBaseComponent(baseComponent: Component, player: Player): Component {
|
||||
var component = baseComponent
|
||||
|
||||
if (component is TranslatableComponent) {
|
||||
val args = mutableListOf<Component>()
|
||||
for (arg in component.args()) {
|
||||
args.add(modifyBaseComponent(arg, player))
|
||||
}
|
||||
component = component.args(args)
|
||||
}
|
||||
|
||||
val children = mutableListOf<Component>()
|
||||
for (child in component.children()) {
|
||||
children.add(modifyBaseComponent(child, player))
|
||||
}
|
||||
component = component.children(children)
|
||||
|
||||
val hoverEvent: HoverEvent<Any> = component.style().hoverEvent() as HoverEvent<Any>? ?: return component
|
||||
|
||||
val showItem = hoverEvent.value()
|
||||
|
||||
if (showItem !is HoverEvent.ShowItem) {
|
||||
return component
|
||||
}
|
||||
|
||||
val newShowItem = showItem.nbt(
|
||||
BinaryTagHolder.of(
|
||||
CraftItemStack.asNMSCopy(
|
||||
Display.display(
|
||||
CraftItemStack.asBukkitCopy(
|
||||
CraftItemStack.asNMSCopy(
|
||||
org.bukkit.inventory.ItemStack(
|
||||
Material.matchMaterial(
|
||||
showItem.item()
|
||||
.toString()
|
||||
) ?: return component,
|
||||
showItem.count()
|
||||
)
|
||||
).apply {
|
||||
this.tag = MojangsonParser.parse(
|
||||
showItem.nbt()?.string() ?: return component
|
||||
) ?: return component
|
||||
}
|
||||
),
|
||||
player
|
||||
)
|
||||
).orCreateTag.toString()
|
||||
)
|
||||
)
|
||||
|
||||
val newHover = hoverEvent.value(newShowItem)
|
||||
val style = component.style().hoverEvent(newHover)
|
||||
return component.style(style)
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.v1_16_R3
|
||||
|
||||
import com.willfp.eco.internal.spigot.proxy.DummyEntityProxy
|
||||
import org.bukkit.Location
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld
|
||||
import org.bukkit.entity.Entity
|
||||
import org.bukkit.entity.EntityType
|
||||
|
||||
class DummyEntity : DummyEntityProxy {
|
||||
override fun createDummyEntity(location: Location): Entity {
|
||||
val world = location.world as CraftWorld
|
||||
@Suppress("UsePropertyAccessSyntax")
|
||||
return world.createEntity(location, EntityType.ZOMBIE.entityClass).getBukkitEntity()
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.v1_16_R3
|
||||
import com.willfp.eco.core.fast.FastItemStack
|
||||
import com.willfp.eco.internal.spigot.proxy.FastItemStackFactoryProxy
|
||||
import com.willfp.eco.internal.spigot.proxy.v1_16_R3.fast.NMSFastItemStack
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class FastItemStackFactory : FastItemStackFactoryProxy {
|
||||
override fun create(itemStack: ItemStack): FastItemStack {
|
||||
return NMSFastItemStack(itemStack)
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.v1_16_R3
|
||||
|
||||
import com.mojang.authlib.GameProfile
|
||||
import com.mojang.authlib.properties.Property
|
||||
import com.willfp.eco.internal.spigot.proxy.SkullProxy
|
||||
import org.bukkit.inventory.meta.SkullMeta
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Method
|
||||
import java.util.UUID
|
||||
|
||||
class Skull : SkullProxy {
|
||||
private lateinit var setProfile: Method
|
||||
private lateinit var profile: Field
|
||||
|
||||
override fun setSkullTexture(
|
||||
meta: SkullMeta,
|
||||
base64: String
|
||||
) {
|
||||
if (!this::setProfile.isInitialized) {
|
||||
setProfile = meta.javaClass.getDeclaredMethod("setProfile", GameProfile::class.java)
|
||||
setProfile.isAccessible = true
|
||||
}
|
||||
val uuid = UUID(
|
||||
base64.substring(base64.length - 20).hashCode().toLong(),
|
||||
base64.substring(base64.length - 10).hashCode().toLong()
|
||||
)
|
||||
val profile = GameProfile(uuid, "eco")
|
||||
profile.properties.put("textures", Property("textures", base64))
|
||||
setProfile.invoke(meta, profile)
|
||||
}
|
||||
|
||||
override fun getSkullTexture(
|
||||
meta: SkullMeta
|
||||
): String? {
|
||||
if (!this::profile.isInitialized) {
|
||||
profile = meta.javaClass.getDeclaredField("profile")
|
||||
profile.isAccessible = true
|
||||
}
|
||||
val profile = profile[meta] as GameProfile? ?: return null
|
||||
val properties = profile.properties ?: return null
|
||||
val prop = properties["textures"] ?: return null
|
||||
return prop.toMutableList().firstOrNull()?.name
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.v1_16_R3
|
||||
|
||||
import com.willfp.eco.internal.spigot.proxy.TPSProxy
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftServer
|
||||
|
||||
class TPS : TPSProxy {
|
||||
override fun getTPS(): Double {
|
||||
return (Bukkit.getServer() as CraftServer).handle.server.recentTps[0]
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.v1_16_R3
|
||||
|
||||
import com.willfp.eco.core.display.Display
|
||||
import com.willfp.eco.internal.spigot.proxy.VillagerTradeProxy
|
||||
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftMerchantRecipe
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.MerchantRecipe
|
||||
import java.lang.reflect.Field
|
||||
|
||||
class VillagerTrade : VillagerTradeProxy {
|
||||
private val handle: Field = CraftMerchantRecipe::class.java.getDeclaredField("handle")
|
||||
|
||||
override fun displayTrade(
|
||||
recipe: MerchantRecipe,
|
||||
player: Player
|
||||
): MerchantRecipe {
|
||||
val oldRecipe = recipe as CraftMerchantRecipe
|
||||
val newRecipe = CraftMerchantRecipe(
|
||||
Display.display(recipe.getResult().clone(), player),
|
||||
recipe.getUses(),
|
||||
recipe.getMaxUses(),
|
||||
recipe.hasExperienceReward(),
|
||||
recipe.getVillagerExperience(),
|
||||
recipe.getPriceMultiplier()
|
||||
)
|
||||
for (ingredient in recipe.getIngredients()) {
|
||||
newRecipe.addIngredient(Display.display(ingredient.clone(), player))
|
||||
}
|
||||
getHandle(newRecipe).specialPrice = getHandle(oldRecipe).specialPrice
|
||||
return newRecipe
|
||||
}
|
||||
|
||||
private fun getHandle(recipe: CraftMerchantRecipe): net.minecraft.server.v1_16_R3.MerchantRecipe {
|
||||
return handle[recipe] as net.minecraft.server.v1_16_R3.MerchantRecipe
|
||||
}
|
||||
|
||||
init {
|
||||
handle.isAccessible = true
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.v1_16_R3.fast
|
||||
|
||||
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import java.lang.reflect.Field
|
||||
|
||||
private val field: Field = CraftItemStack::class.java.getDeclaredField("handle").apply {
|
||||
isAccessible = true
|
||||
}
|
||||
|
||||
fun ItemStack.getNMSStack(): net.minecraft.server.v1_16_R3.ItemStack {
|
||||
return if (this !is CraftItemStack) {
|
||||
CraftItemStack.asNMSCopy(this)
|
||||
} else {
|
||||
field[this] as net.minecraft.server.v1_16_R3.ItemStack? ?: CraftItemStack.asNMSCopy(this)
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
package com.willfp.eco.internal.spigot.proxy.v1_16_R3.fast
|
||||
|
||||
import com.willfp.eco.internal.fast.EcoFastItemStack
|
||||
import com.willfp.eco.util.NamespacedKeyUtils
|
||||
import com.willfp.eco.util.StringUtils
|
||||
import net.minecraft.server.v1_16_R3.Item
|
||||
import net.minecraft.server.v1_16_R3.ItemEnchantedBook
|
||||
import net.minecraft.server.v1_16_R3.ItemStack
|
||||
import net.minecraft.server.v1_16_R3.Items
|
||||
import net.minecraft.server.v1_16_R3.NBTTagCompound
|
||||
import net.minecraft.server.v1_16_R3.NBTTagList
|
||||
import net.minecraft.server.v1_16_R3.NBTTagString
|
||||
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack
|
||||
import org.bukkit.craftbukkit.v1_16_R3.util.CraftMagicNumbers
|
||||
import org.bukkit.enchantments.Enchantment
|
||||
import org.bukkit.inventory.ItemFlag
|
||||
import kotlin.experimental.and
|
||||
|
||||
class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemStack<ItemStack>(
|
||||
itemStack.getNMSStack(), itemStack
|
||||
) {
|
||||
private var loreCache: List<String>? = null
|
||||
override fun getEnchants(checkStored: Boolean): Map<Enchantment, Int> {
|
||||
val enchantmentNBT = if (checkStored && handle.item === Items.ENCHANTED_BOOK) ItemEnchantedBook.d(
|
||||
handle
|
||||
) else handle.enchantments
|
||||
val foundEnchantments: MutableMap<Enchantment, Int> = HashMap()
|
||||
for (base in enchantmentNBT) {
|
||||
val compound = base as NBTTagCompound
|
||||
val key = compound.getString("id")
|
||||
val level: Int = ('\uffff'.code.toShort() and compound.getShort("lvl")).toInt()
|
||||
val found = Enchantment.getByKey(NamespacedKeyUtils.fromStringOrNull(key))
|
||||
if (found != null) {
|
||||
foundEnchantments[found] = level
|
||||
}
|
||||
}
|
||||
return foundEnchantments
|
||||
}
|
||||
|
||||
override fun getLevelOnItem(
|
||||
enchantment: Enchantment,
|
||||
checkStored: Boolean
|
||||
): Int {
|
||||
val enchantmentNBT = if (checkStored && handle.item === Items.ENCHANTED_BOOK) ItemEnchantedBook.d(
|
||||
handle
|
||||
) else handle.enchantments
|
||||
for (base in enchantmentNBT) {
|
||||
val compound = base as NBTTagCompound
|
||||
val key = compound.getString("id")
|
||||
if (key != enchantment.key.toString()) {
|
||||
continue
|
||||
}
|
||||
return ('\uffff'.code.toShort() and compound.getShort("lvl")).toInt()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun setLore(lore: List<String>?) {
|
||||
loreCache = null
|
||||
val jsonLore: MutableList<String> = ArrayList()
|
||||
if (lore != null) {
|
||||
for (s in lore) {
|
||||
jsonLore.add(StringUtils.legacyToJson(s))
|
||||
}
|
||||
}
|
||||
val displayTag = handle.a("display")
|
||||
if (!displayTag.hasKey("Lore")) {
|
||||
displayTag["Lore"] = NBTTagList()
|
||||
}
|
||||
val loreTag = displayTag.getList("Lore", CraftMagicNumbers.NBT.TAG_STRING)
|
||||
loreTag.clear()
|
||||
for (s in jsonLore) {
|
||||
loreTag.add(NBTTagString.a(s))
|
||||
}
|
||||
apply()
|
||||
}
|
||||
|
||||
override fun getLore(): List<String> {
|
||||
if (loreCache != null) {
|
||||
return loreCache as List<String>
|
||||
}
|
||||
val lore: MutableList<String> = ArrayList()
|
||||
for (s in getLoreJSON()) {
|
||||
lore.add(StringUtils.jsonToLegacy(s))
|
||||
}
|
||||
loreCache = lore
|
||||
return lore
|
||||
}
|
||||
|
||||
private fun getLoreJSON(): List<String> {
|
||||
val displayTag = handle.b("display") ?: return emptyList()
|
||||
return if (displayTag.hasKey("Lore")) {
|
||||
val loreTag = displayTag.getList("Lore", CraftMagicNumbers.NBT.TAG_STRING)
|
||||
val lore: MutableList<String> = ArrayList(loreTag.size)
|
||||
for (i in loreTag.indices) {
|
||||
lore.add(loreTag.getString(i))
|
||||
}
|
||||
lore
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
override fun addItemFlags(vararg hideFlags: ItemFlag) {
|
||||
for (flag in hideFlags) {
|
||||
this.flagBits = this.flagBits or getBitModifier(flag)
|
||||
}
|
||||
|
||||
apply()
|
||||
}
|
||||
|
||||
override fun removeItemFlags(vararg hideFlags: ItemFlag) {
|
||||
for (flag in hideFlags) {
|
||||
this.flagBits = this.flagBits and getBitModifier(flag)
|
||||
}
|
||||
|
||||
apply()
|
||||
}
|
||||
|
||||
override fun getItemFlags(): MutableSet<ItemFlag> {
|
||||
val flags = mutableSetOf<ItemFlag>()
|
||||
|
||||
var flagArr: Array<ItemFlag>
|
||||
val size = ItemFlag.values().also { flagArr = it }.size
|
||||
|
||||
for (i in 0 until size) {
|
||||
val flag = flagArr[i]
|
||||
if (this.hasItemFlag(flag)) {
|
||||
flags.add(flag)
|
||||
}
|
||||
}
|
||||
|
||||
return flags
|
||||
}
|
||||
|
||||
override fun hasItemFlag(flag: ItemFlag): Boolean {
|
||||
val bitModifier = getBitModifier(flag)
|
||||
return this.flagBits and bitModifier == bitModifier
|
||||
}
|
||||
|
||||
private var flagBits: Int
|
||||
get() =
|
||||
if (handle.hasTag() && handle.tag!!.hasKeyOfType(
|
||||
"HideFlags",
|
||||
99
|
||||
)
|
||||
) handle.tag!!.getInt("HideFlags") else 0
|
||||
set(value) =
|
||||
handle.orCreateTag.setInt("HideFlags", value)
|
||||
|
||||
override fun getRepairCost(): Int {
|
||||
return handle.repairCost
|
||||
}
|
||||
|
||||
override fun setRepairCost(cost: Int) {
|
||||
handle.repairCost = cost
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is NMSFastItemStack) {
|
||||
return false
|
||||
}
|
||||
|
||||
return other.hashCode() == this.hashCode()
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return handle.tag?.hashCode() ?: (0b00010101 * 31 + Item.getId(handle.item))
|
||||
}
|
||||
|
||||
private fun apply() {
|
||||
if (bukkit !is CraftItemStack) {
|
||||
bukkit.itemMeta = CraftItemStack.asCraftMirror(handle).itemMeta
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,9 +30,9 @@ dependencies {
|
||||
compileOnly 'com.github.brcdev-minecraft:shopgui-api:2.2.0'
|
||||
compileOnly 'com.github.LoneDev6:API-ItemsAdder:2.4.7'
|
||||
compileOnly 'com.arcaniax:HeadDatabase-API:1.3.0'
|
||||
compileOnly 'org.jetbrains.exposed:exposed-core:0.36.2'
|
||||
compileOnly 'org.jetbrains.exposed:exposed-dao:0.36.2'
|
||||
compileOnly 'org.jetbrains.exposed:exposed-jdbc:0.36.2'
|
||||
compileOnly 'org.jetbrains.exposed:exposed-core:0.37.3'
|
||||
compileOnly 'org.jetbrains.exposed:exposed-dao:0.37.3'
|
||||
compileOnly 'org.jetbrains.exposed:exposed-jdbc:0.37.3'
|
||||
compileOnly 'mysql:mysql-connector-java:8.0.25'
|
||||
compileOnly 'com.zaxxer:HikariCP:5.0.0'
|
||||
compileOnly 'com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0'
|
||||
|
||||
@@ -152,11 +152,11 @@ private class ImplementedMySQLHandler(
|
||||
private val knownKeys: Collection<PersistentDataKey<*>>
|
||||
) {
|
||||
private val columns = Caffeine.newBuilder()
|
||||
.expireAfterAccess(5, TimeUnit.SECONDS)
|
||||
.expireAfterWrite(3, TimeUnit.SECONDS)
|
||||
.build<String, Column<*>>()
|
||||
|
||||
private val rows = Caffeine.newBuilder()
|
||||
.expireAfterAccess(5, TimeUnit.SECONDS)
|
||||
.expireAfterWrite(3, TimeUnit.SECONDS)
|
||||
.build<UUID, ResultRow>()
|
||||
|
||||
private val threadFactory = ThreadFactoryBuilder().setNameFormat("eco-mysql-thread-%d").build()
|
||||
@@ -305,10 +305,14 @@ private class ImplementedMySQLHandler(
|
||||
}
|
||||
|
||||
private fun getOrCreateRow(uuid: UUID): ResultRow {
|
||||
return rows.get(uuid) {
|
||||
val row = transaction {
|
||||
fun select(uuid: UUID): ResultRow? {
|
||||
return transaction {
|
||||
table.select { table.id eq uuid }.limit(1).singleOrNull()
|
||||
}
|
||||
}
|
||||
|
||||
return rows.get(uuid) {
|
||||
val row = select(uuid)
|
||||
|
||||
return@get if (row != null) {
|
||||
row
|
||||
@@ -316,7 +320,7 @@ private class ImplementedMySQLHandler(
|
||||
transaction {
|
||||
table.insert { it[id] = uuid }
|
||||
}
|
||||
getOrCreateRow(uuid)
|
||||
select(uuid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,21 +5,17 @@ import com.comphenix.protocol.events.PacketContainer
|
||||
import com.comphenix.protocol.events.PacketEvent
|
||||
import com.willfp.eco.core.AbstractPacketAdapter
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.Prerequisite
|
||||
import com.willfp.eco.core.display.Display
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class PacketHeldWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, PacketType.Play.Server.WINDOW_ITEMS, false) {
|
||||
class PacketHeldWindowItems(plugin: EcoPlugin) :
|
||||
AbstractPacketAdapter(plugin, PacketType.Play.Server.WINDOW_ITEMS, false) {
|
||||
override fun onSend(
|
||||
packet: PacketContainer,
|
||||
player: Player,
|
||||
event: PacketEvent
|
||||
) {
|
||||
if (!Prerequisite.HAS_1_17.isMet) {
|
||||
return
|
||||
}
|
||||
|
||||
packet.itemModifier.modify(0) { item: ItemStack? ->
|
||||
Display.display(
|
||||
item!!, player
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: eco
|
||||
version: ${projectVersion}
|
||||
main: com.willfp.eco.internal.spigot.EcoHandler
|
||||
api-version: 1.16
|
||||
api-version: 1.17
|
||||
authors: [ Auxilor ]
|
||||
website: willfp.com
|
||||
load: STARTUP
|
||||
@@ -51,9 +51,9 @@ libraries:
|
||||
- 'net.kyori:adventure-api:4.9.3'
|
||||
- 'net.kyori:adventure-text-serializer-gson:4.9.3'
|
||||
- 'net.kyori:adventure-text-serializer-legacy:4.9.3'
|
||||
- 'org.jetbrains.exposed:exposed-core:0.36.2'
|
||||
- 'org.jetbrains.exposed:exposed-dao:0.36.2'
|
||||
- 'org.jetbrains.exposed:exposed-jdbc:0.36.2'
|
||||
- 'org.jetbrains.exposed:exposed-core:0.37.3'
|
||||
- 'org.jetbrains.exposed:exposed-dao:0.37.3'
|
||||
- 'org.jetbrains.exposed:exposed-jdbc:0.37.3'
|
||||
- 'mysql:mysql-connector-java:8.0.25'
|
||||
- 'com.google.guava:guava:31.0.1-jre'
|
||||
- 'com.zaxxer:HikariCP:5.0.0'
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version = 6.25.0
|
||||
version = 6.25.2
|
||||
plugin-name = eco
|
||||
kotlin.code.style = official
|
||||
@@ -11,7 +11,6 @@ rootProject.name = "eco"
|
||||
include(":eco-api")
|
||||
include(":eco-core")
|
||||
include(":eco-core:core-nms")
|
||||
include(":eco-core:core-nms:v1_16_R3")
|
||||
include(":eco-core:core-nms:v1_17_R1")
|
||||
include(":eco-core:core-nms:v1_18_R1")
|
||||
include(":eco-core:core-proxy")
|
||||
|
||||
Reference in New Issue
Block a user