Compare commits

...

19 Commits

Author SHA1 Message Date
Auxilor
960f62cc8b Updated to 6.43.7 2022-10-16 21:48:14 +01:00
Auxilor
28ceb83eb5 Fixed ExtendedPersistentDataContainerFactory.kt 2022-10-16 21:47:46 +01:00
Auxilor
6f748b6b8a Updated to 6.43.6 2022-10-07 17:28:39 +01:00
Auxilor
190ea5d49f Refactor + Fix 2022-10-07 17:28:28 +01:00
Auxilor
c0ed083a5c Fixed PAPI 2022-10-04 11:58:15 +01:00
Auxilor
04f04bb7a6 Fixed custom model data parser 2022-10-04 11:48:06 +01:00
Auxilor
b8a3806ff9 Updated to 6.43.5 2022-10-04 11:44:17 +01:00
Auxilor
ae49d41542 Fixes to placeholders and integrations 2022-10-04 11:43:10 +01:00
Auxilor
5f2255a3bc Fixed initial render 2022-10-03 23:33:39 +01:00
Auxilor
065ccfbe67 Updated to 6.43.4 2022-10-03 22:30:27 +01:00
Auxilor
17727c9015 Optimized second render for captive changes 2022-10-03 22:30:20 +01:00
Auxilor
ea64e69b4d Fixed GUI bug 2022-10-03 22:25:03 +01:00
Auxilor
07ca6c2359 Fixed 2 more GUI bugs 2022-10-03 21:58:53 +01:00
Auxilor
162558b1c2 Updated to 6.43.3 2022-10-03 13:44:28 +01:00
Auxilor
10f9e8dce0 Fixed Skull 2022-10-03 13:44:17 +01:00
Will FP
b02943d7ff Merge pull request #204
Fix: Skull texture out of bounds error
2022-10-03 13:42:39 +01:00
Auxilor
40ad970ffa Updated to 6.43.2 2022-10-03 13:00:02 +01:00
Auxilor
aefdfa786d Fixed menu rendering bugs 2022-10-03 12:59:54 +01:00
MillionthOdin16
1cf08955a0 Additional check for bounds error
explanation in comment
2022-10-02 19:33:37 -04:00
27 changed files with 268 additions and 128 deletions

View File

@@ -21,7 +21,6 @@ import com.willfp.eco.core.gui.menu.MenuBuilder;
import com.willfp.eco.core.gui.menu.MenuType; import com.willfp.eco.core.gui.menu.MenuType;
import com.willfp.eco.core.gui.slot.SlotBuilder; import com.willfp.eco.core.gui.slot.SlotBuilder;
import com.willfp.eco.core.gui.slot.functional.SlotProvider; import com.willfp.eco.core.gui.slot.functional.SlotProvider;
import com.willfp.eco.core.integrations.placeholder.PlaceholderIntegration;
import com.willfp.eco.core.items.TestableItem; import com.willfp.eco.core.items.TestableItem;
import com.willfp.eco.core.placeholder.AdditionalPlayer; import com.willfp.eco.core.placeholder.AdditionalPlayer;
import com.willfp.eco.core.placeholder.PlaceholderInjectable; import com.willfp.eco.core.placeholder.PlaceholderInjectable;
@@ -138,10 +137,9 @@ public interface Eco {
* Create a PAPI integration. * Create a PAPI integration.
* *
* @param plugin The plugin. * @param plugin The plugin.
* @return The integration.
*/ */
@NotNull @NotNull
PlaceholderIntegration createPAPIIntegration(@NotNull EcoPlugin plugin); void createPAPIIntegration(@NotNull EcoPlugin plugin);
/** /**
* Create a proxy factory. * Create a proxy factory.

View File

@@ -13,7 +13,6 @@ import com.willfp.eco.core.factory.MetadataValueFactory;
import com.willfp.eco.core.factory.NamespacedKeyFactory; import com.willfp.eco.core.factory.NamespacedKeyFactory;
import com.willfp.eco.core.factory.RunnableFactory; import com.willfp.eco.core.factory.RunnableFactory;
import com.willfp.eco.core.integrations.IntegrationLoader; import com.willfp.eco.core.integrations.IntegrationLoader;
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager;
import com.willfp.eco.core.proxy.ProxyFactory; import com.willfp.eco.core.proxy.ProxyFactory;
import com.willfp.eco.core.scheduling.Scheduler; import com.willfp.eco.core.scheduling.Scheduler;
import com.willfp.eco.core.web.UpdateChecker; import com.willfp.eco.core.web.UpdateChecker;
@@ -375,8 +374,7 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike {
.collect(Collectors.toSet()); .collect(Collectors.toSet());
if (enabledPlugins.contains("PlaceholderAPI".toLowerCase())) { if (enabledPlugins.contains("PlaceholderAPI".toLowerCase())) {
this.loadedIntegrations.add("PlaceholderAPI"); Eco.get().createPAPIIntegration(this);
PlaceholderManager.addIntegration(Eco.get().createPAPIIntegration(this));
} }
this.loadIntegrationLoaders().forEach(integrationLoader -> { this.loadIntegrationLoaders().forEach(integrationLoader -> {
@@ -386,6 +384,8 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike {
} }
}); });
this.loadedIntegrations.removeIf(pl -> pl.equalsIgnoreCase(this.getName()));
this.getLogger().info("Loaded integrations: " + String.join(", ", this.getLoadedIntegrations())); this.getLogger().info("Loaded integrations: " + String.join(", ", this.getLoadedIntegrations()));
Prerequisite.update(); Prerequisite.update();

View File

@@ -107,7 +107,7 @@ public interface MenuBuilder extends PageBuilder {
* @return The builder. * @return The builder.
*/ */
default MenuBuilder addPage(@NotNull final Page page) { default MenuBuilder addPage(@NotNull final Page page) {
return this.addComponent(MenuLayer.TOP, 1, 1, page); return this.addComponent(MenuLayer.UPPER, 1, 1, page);
} }
/** /**
@@ -139,7 +139,7 @@ public interface MenuBuilder extends PageBuilder {
* @return The builder. * @return The builder.
*/ */
default MenuBuilder maxPages(@NotNull final Function<Player, Integer> pages) { default MenuBuilder maxPages(@NotNull final Function<Player, Integer> pages) {
return onOpen((player, menu) -> menu.addState(player, Page.MAX_PAGE_KEY, pages.apply(player))); return onRender((player, menu) -> menu.addState(player, Page.MAX_PAGE_KEY, pages.apply(player)));
} }
/** /**

View File

@@ -79,7 +79,7 @@ public final class PageChanger implements GUIComponent {
return null; return null;
} }
if (page >= maxPage - 1 && this.direction == Direction.FORWARDS) { if (page >= maxPage && this.direction == Direction.FORWARDS) {
return null; return null;
} }

View File

@@ -70,7 +70,7 @@ public final class PlaceholderManager {
/** /**
* The default PlaceholderAPI pattern; brought in for compatibility. * The default PlaceholderAPI pattern; brought in for compatibility.
*/ */
private static final Pattern PATTERN = Pattern.compile("[%]([^%]+)[%]"); private static final Pattern PATTERN = Pattern.compile("[%]([^% ]+)[%]");
/** /**
* Register a new placeholder integration. * Register a new placeholder integration.

View File

@@ -20,7 +20,7 @@ import org.bukkit.inventory.ItemStack
class EcoMenu( class EcoMenu(
private val rows: Int, private val rows: Int,
private val columns: Int, private val columns: Int,
private val componentsAtPoints: Map<GUIPosition, List<OffsetComponent>>, private val components: LayeredComponents,
private val title: String, private val title: String,
private val onClose: List<CloseHandler>, private val onClose: List<CloseHandler>,
private val onRender: List<(Player, Menu) -> Unit>, private val onRender: List<(Player, Menu) -> Unit>,
@@ -28,38 +28,19 @@ class EcoMenu(
private val menuEventHandlers: List<MenuEventHandler<*>>, private val menuEventHandlers: List<MenuEventHandler<*>>,
private val allowsChangingHeldItem: Boolean private val allowsChangingHeldItem: Boolean
) : Menu { ) : Menu {
private fun getPossiblyReactiveSlot(row: Int, column: Int, player: Player?, menu: Menu?): Slot { private fun getPossiblyReactiveSlot(row: Int, column: Int, player: Player?): Slot {
if (row < 1 || row > this.rows || column < 1 || column > this.columns) { if (row < 1 || row > this.rows || column < 1 || column > this.columns) {
return emptyFillerSlot return emptyFillerSlot
} }
val guiPosition = GUIPosition(row, column) return components.getSlotAt(row, column, player, this)
val components = componentsAtPoints[guiPosition] ?: return emptyFillerSlot
for (component in components) {
val found = if (player != null && menu != null) component.component.getSlotAt(
component.rowOffset,
component.columnOffset,
player,
menu
) else component.component.getSlotAt(
component.rowOffset,
component.columnOffset
)
if (found != null) {
return found
}
}
return emptyFillerSlot
} }
override fun getSlot(row: Int, column: Int): Slot = override fun getSlot(row: Int, column: Int): Slot =
getPossiblyReactiveSlot(row, column, null, null) getPossiblyReactiveSlot(row, column, null)
override fun getSlot(row: Int, column: Int, player: Player, menu: Menu): Slot = override fun getSlot(row: Int, column: Int, player: Player, menu: Menu): Slot =
getPossiblyReactiveSlot(row, column, player, menu) getPossiblyReactiveSlot(row, column, player)
override fun open(player: Player): Inventory { override fun open(player: Player): Inventory {
val inventory = if (columns == 9) { val inventory = if (columns == 9) {

View File

@@ -86,7 +86,7 @@ class EcoMenuBuilder(
} }
override fun build(): Menu { override fun build(): Menu {
val layeredComponents = mutableMapOf<MenuLayer, MutableMap<GUIPosition, MutableList<OffsetComponent>>>() val layeredComponents = LayeredComponents()
// 5 nested for loops? Shut up. Silence. Quiet. // 5 nested for loops? Shut up. Silence. Quiet.
for (layer in MenuLayer.values()) { for (layer in MenuLayer.values()) {
@@ -107,11 +107,14 @@ class EcoMenuBuilder(
val point = GUIPosition(row, column) val point = GUIPosition(row, column)
layeredComponents.computeIfAbsent(layer) { mutableMapOf() } layeredComponents.addOffsetComponent(
.computeIfAbsent(point) { mutableListOf() } += OffsetComponent( layer,
component, point,
rowOffset, OffsetComponent(
columnOffset component,
rowOffset,
columnOffset
)
) )
} }
} }
@@ -119,18 +122,10 @@ class EcoMenuBuilder(
} }
} }
val componentsAtPoints = mutableMapOf<GUIPosition, MutableList<OffsetComponent>>()
for (menuLayer in MenuLayer.values()) {
for ((anchor, offsetComponents) in layeredComponents[menuLayer] ?: emptyMap()) {
componentsAtPoints[anchor] = offsetComponents
}
}
return EcoMenu( return EcoMenu(
rows, rows,
columns, columns,
componentsAtPoints, layeredComponents,
title, title,
onClose, onClose,
onRender, onRender,

View File

@@ -0,0 +1,46 @@
package com.willfp.eco.internal.gui.menu
import com.willfp.eco.core.gui.menu.Menu
import com.willfp.eco.core.gui.menu.MenuLayer
import com.willfp.eco.core.gui.slot.Slot
import org.bukkit.entity.Player
class LayeredComponents {
private val layers = mutableMapOf<MenuLayer, Map<GUIPosition, List<OffsetComponent>>>()
fun getSlotAt(row: Int, column: Int, player: Player?, menu: Menu): Slot {
val guiPosition = GUIPosition(row, column)
for (layer in MenuLayer.values().reversed()) {
val componentsAtPoints = layers[layer] ?: continue
val components = componentsAtPoints[guiPosition] ?: continue
for (component in components) {
val found = if (player != null) component.component.getSlotAt(
component.rowOffset,
component.columnOffset,
player,
menu
) else component.component.getSlotAt(
component.rowOffset,
component.columnOffset
)
if (found != null) {
return found
}
}
}
return emptyFillerSlot
}
fun addOffsetComponent(layer: MenuLayer, position: GUIPosition, component: OffsetComponent) {
val inLayer = layers[layer]?.toMutableMap() ?: mutableMapOf()
val atPosition = inLayer[position]?.toMutableList() ?: mutableListOf()
atPosition.add(component)
inLayer[position] = atPosition
layers[layer] = inLayer
}
}

View File

@@ -31,6 +31,8 @@ class RenderedInventory(
val state = mutableMapOf<String, Any?>() val state = mutableMapOf<String, Any?>()
fun render() { fun render() {
val previousCaptive = captiveItems.toMap()
captiveItems.clear() captiveItems.clear()
for (row in (1..menu.rows)) { for (row in (1..menu.rows)) {
@@ -60,9 +62,27 @@ class RenderedInventory(
} }
menu.runOnRender(player) menu.runOnRender(player)
// Run second render if captive items changed
if (captiveItems != previousCaptive) {
for (row in (1..menu.rows)) {
for (column in (1..menu.columns)) {
val bukkit = MenuUtils.rowColumnToSlot(row, column, menu.columns)
val slot = menu.getSlot(row, column, player, menu)
val renderedItem = slot.getItemStack(player)
if (!slot.isCaptive(player, menu)) {
inventory.setItem(bukkit, renderedItem)
}
}
}
}
} }
fun renderDefaultCaptiveItems() { fun renderDefaultCaptiveItems() {
menu.runOnRender(player)
for (row in (1..menu.rows)) { for (row in (1..menu.rows)) {
for (column in (1..menu.columns)) { for (column in (1..menu.columns)) {
val bukkit = MenuUtils.rowColumnToSlot(row, column, menu.columns) val bukkit = MenuUtils.rowColumnToSlot(row, column, menu.columns)

View File

@@ -1,13 +1,15 @@
package com.willfp.eco.internal.integrations package com.willfp.eco.internal.integrations
import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.integrations.placeholder.PlaceholderIntegration
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager import com.willfp.eco.core.integrations.placeholder.PlaceholderManager
import me.clip.placeholderapi.PlaceholderAPI
import me.clip.placeholderapi.expansion.PlaceholderExpansion import me.clip.placeholderapi.expansion.PlaceholderExpansion
import org.bukkit.entity.Player import org.bukkit.entity.Player
class PlaceholderIntegrationPAPI(private val plugin: EcoPlugin) : PlaceholderExpansion(), PlaceholderIntegration { class PAPIExpansion(private val plugin: EcoPlugin) : PlaceholderExpansion() {
init {
register()
}
override fun persist(): Boolean { override fun persist(): Boolean {
return true return true
} }
@@ -34,29 +36,4 @@ class PlaceholderIntegrationPAPI(private val plugin: EcoPlugin) : PlaceholderExp
): String { ): String {
return PlaceholderManager.getResult(player, identifier, plugin) return PlaceholderManager.getResult(player, identifier, plugin)
} }
}
override fun registerIntegration() {
register()
}
override fun getPluginName(): String {
return "PlaceholderAPI"
}
override fun translate(
text: String,
player: Player?
): String {
return PlaceholderAPI.setPlaceholders(player, text)
}
override fun findPlaceholdersIn(text: String): MutableList<String> {
val placeholders = mutableListOf<String>()
val matcher = PlaceholderAPI.getPlaceholderPattern().matcher(text)
while (matcher.find()) {
placeholders.add(matcher.group())
}
return placeholders
}
}

View File

@@ -27,6 +27,10 @@ object ArgParserCustomModelData : LookupArgParser {
return Predicate { return Predicate {
val testMeta = it.itemMeta ?: return@Predicate false val testMeta = it.itemMeta ?: return@Predicate false
if (!testMeta.hasCustomModelData()) {
return@Predicate false
}
testMeta.customModelData == modelData testMeta.customModelData == modelData
} }
} }

View File

@@ -29,7 +29,27 @@ var SkullMeta.texture: String?
setProfile.isAccessible = true setProfile.isAccessible = true
} }
if (base64 == null) { /* This length check below was lost in the conversion. For some reason the base64
* string is length 8 when this is called pretty frequently, causing an
* out of bounds exception.
*
* Could not pass event EntityPotionEffectEvent to Talismans v5.116.0
* java.lang.StringIndexOutOfBoundsException: begin -12, end 8, length 8
* at java.lang.String.checkBoundsBeginEnd(String.java:4604) ~[?:?]
* at java.lang.String.substring(String.java:2707) ~[?:?]
* at java.lang.String.substring(String.java:2680) ~[?:?]
* at com.willfp.eco.internal.spigot.proxy.v1_19_R1.common.SkullKt.setTexture(Skull.kt:36)
*
if (base64.length < 20) {
return
}
*
* ^ Update to this comment: a length 8 string ("textures") was being sent
* because the get() method wasn't working right. This has been fixed, but the
* check needs to remain implemented.
*/
if (base64 == null || base64.length < 20) {
setProfile.invoke(this, null) setProfile.invoke(this, null)
} else { } else {
val uuid = UUID( val uuid = UUID(

View File

@@ -3,16 +3,28 @@ package com.willfp.eco.internal.spigot.proxy.v1_17_R1
import com.willfp.eco.core.data.ExtendedPersistentDataContainer import com.willfp.eco.core.data.ExtendedPersistentDataContainer
import com.willfp.eco.internal.spigot.proxy.ExtendedPersistentDataContainerFactoryProxy import com.willfp.eco.internal.spigot.proxy.ExtendedPersistentDataContainerFactoryProxy
import net.minecraft.nbt.Tag import net.minecraft.nbt.Tag
import org.bukkit.Material
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack
import org.bukkit.craftbukkit.v1_17_R1.persistence.CraftPersistentDataContainer import org.bukkit.craftbukkit.v1_17_R1.persistence.CraftPersistentDataContainer
import org.bukkit.craftbukkit.v1_17_R1.persistence.CraftPersistentDataTypeRegistry import org.bukkit.craftbukkit.v1_17_R1.persistence.CraftPersistentDataTypeRegistry
import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataContainer import org.bukkit.persistence.PersistentDataContainer
import org.bukkit.persistence.PersistentDataType import org.bukkit.persistence.PersistentDataType
class ExtendedPersistentDataContainerFactory: ExtendedPersistentDataContainerFactoryProxy { class ExtendedPersistentDataContainerFactory : ExtendedPersistentDataContainerFactoryProxy {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
private val registry: CraftPersistentDataTypeRegistry = private val registry: CraftPersistentDataTypeRegistry
CraftPersistentDataContainer::class.java.getDeclaredField("registry")
.apply { isAccessible = true }.get(null) as CraftPersistentDataTypeRegistry init {
/*
Can't grab actual instance since it's in CraftMetaItem (which is package-private)
And getting it would mean more janky reflection
*/
val item = CraftItemStack.asCraftCopy(ItemStack(Material.STONE))
val pdc = item.itemMeta!!.persistentDataContainer
this.registry = CraftPersistentDataContainer::class.java.getDeclaredField("registry")
.apply { isAccessible = true }.get(pdc) as CraftPersistentDataTypeRegistry
}
override fun adapt(pdc: PersistentDataContainer): ExtendedPersistentDataContainer { override fun adapt(pdc: PersistentDataContainer): ExtendedPersistentDataContainer {
return when (pdc) { return when (pdc) {
@@ -34,7 +46,8 @@ class ExtendedPersistentDataContainerFactory: ExtendedPersistentDataContainerFac
.apply { isAccessible = true }.get(handle) as MutableMap<String, Tag> .apply { isAccessible = true }.get(handle) as MutableMap<String, Tag>
override fun <T : Any, Z : Any> set(key: String, dataType: PersistentDataType<T, Z>, value: Z) { override fun <T : Any, Z : Any> set(key: String, dataType: PersistentDataType<T, Z>, value: Z) {
customDataTags[key] = registry.wrap(dataType.primitiveType, dataType.toPrimitive(value, handle.adapterContext)) customDataTags[key] =
registry.wrap(dataType.primitiveType, dataType.toPrimitive(value, handle.adapterContext))
} }
override fun <T : Any, Z : Any> has(key: String, dataType: PersistentDataType<T, Z>): Boolean { override fun <T : Any, Z : Any> has(key: String, dataType: PersistentDataType<T, Z>): Boolean {

View File

@@ -3,16 +3,28 @@ package com.willfp.eco.internal.spigot.proxy.v1_18_R1
import com.willfp.eco.core.data.ExtendedPersistentDataContainer import com.willfp.eco.core.data.ExtendedPersistentDataContainer
import com.willfp.eco.internal.spigot.proxy.ExtendedPersistentDataContainerFactoryProxy import com.willfp.eco.internal.spigot.proxy.ExtendedPersistentDataContainerFactoryProxy
import net.minecraft.nbt.Tag import net.minecraft.nbt.Tag
import org.bukkit.Material
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack
import org.bukkit.craftbukkit.v1_18_R1.persistence.CraftPersistentDataContainer import org.bukkit.craftbukkit.v1_18_R1.persistence.CraftPersistentDataContainer
import org.bukkit.craftbukkit.v1_18_R1.persistence.CraftPersistentDataTypeRegistry import org.bukkit.craftbukkit.v1_18_R1.persistence.CraftPersistentDataTypeRegistry
import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataContainer import org.bukkit.persistence.PersistentDataContainer
import org.bukkit.persistence.PersistentDataType import org.bukkit.persistence.PersistentDataType
class ExtendedPersistentDataContainerFactory : ExtendedPersistentDataContainerFactoryProxy { class ExtendedPersistentDataContainerFactory : ExtendedPersistentDataContainerFactoryProxy {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
private val registry: CraftPersistentDataTypeRegistry = private val registry: CraftPersistentDataTypeRegistry
CraftPersistentDataContainer::class.java.getDeclaredField("registry")
.apply { isAccessible = true }.get(null) as CraftPersistentDataTypeRegistry init {
/*
Can't grab actual instance since it's in CraftMetaItem (which is package-private)
And getting it would mean more janky reflection
*/
val item = CraftItemStack.asCraftCopy(ItemStack(Material.STONE))
val pdc = item.itemMeta!!.persistentDataContainer
this.registry = CraftPersistentDataContainer::class.java.getDeclaredField("registry")
.apply { isAccessible = true }.get(pdc) as CraftPersistentDataTypeRegistry
}
override fun adapt(pdc: PersistentDataContainer): ExtendedPersistentDataContainer { override fun adapt(pdc: PersistentDataContainer): ExtendedPersistentDataContainer {
return when (pdc) { return when (pdc) {

View File

@@ -3,16 +3,28 @@ package com.willfp.eco.internal.spigot.proxy.v1_18_R2
import com.willfp.eco.core.data.ExtendedPersistentDataContainer import com.willfp.eco.core.data.ExtendedPersistentDataContainer
import com.willfp.eco.internal.spigot.proxy.ExtendedPersistentDataContainerFactoryProxy import com.willfp.eco.internal.spigot.proxy.ExtendedPersistentDataContainerFactoryProxy
import net.minecraft.nbt.Tag import net.minecraft.nbt.Tag
import org.bukkit.Material
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack
import org.bukkit.craftbukkit.v1_18_R2.persistence.CraftPersistentDataContainer import org.bukkit.craftbukkit.v1_18_R2.persistence.CraftPersistentDataContainer
import org.bukkit.craftbukkit.v1_18_R2.persistence.CraftPersistentDataTypeRegistry import org.bukkit.craftbukkit.v1_18_R2.persistence.CraftPersistentDataTypeRegistry
import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataContainer import org.bukkit.persistence.PersistentDataContainer
import org.bukkit.persistence.PersistentDataType import org.bukkit.persistence.PersistentDataType
class ExtendedPersistentDataContainerFactory: ExtendedPersistentDataContainerFactoryProxy { class ExtendedPersistentDataContainerFactory : ExtendedPersistentDataContainerFactoryProxy {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
private val registry: CraftPersistentDataTypeRegistry = private val registry: CraftPersistentDataTypeRegistry
CraftPersistentDataContainer::class.java.getDeclaredField("registry")
.apply { isAccessible = true }.get(null) as CraftPersistentDataTypeRegistry init {
/*
Can't grab actual instance since it's in CraftMetaItem (which is package-private)
And getting it would mean more janky reflection
*/
val item = CraftItemStack.asCraftCopy(ItemStack(Material.STONE))
val pdc = item.itemMeta!!.persistentDataContainer
this.registry = CraftPersistentDataContainer::class.java.getDeclaredField("registry")
.apply { isAccessible = true }.get(pdc) as CraftPersistentDataTypeRegistry
}
override fun adapt(pdc: PersistentDataContainer): ExtendedPersistentDataContainer { override fun adapt(pdc: PersistentDataContainer): ExtendedPersistentDataContainer {
return when (pdc) { return when (pdc) {
@@ -34,7 +46,8 @@ class ExtendedPersistentDataContainerFactory: ExtendedPersistentDataContainerFac
.apply { isAccessible = true }.get(handle) as MutableMap<String, Tag> .apply { isAccessible = true }.get(handle) as MutableMap<String, Tag>
override fun <T : Any, Z : Any> set(key: String, dataType: PersistentDataType<T, Z>, value: Z) { override fun <T : Any, Z : Any> set(key: String, dataType: PersistentDataType<T, Z>, value: Z) {
customDataTags[key] = registry.wrap(dataType.primitiveType, dataType.toPrimitive(value, handle.adapterContext)) customDataTags[key] =
registry.wrap(dataType.primitiveType, dataType.toPrimitive(value, handle.adapterContext))
} }
override fun <T : Any, Z : Any> has(key: String, dataType: PersistentDataType<T, Z>): Boolean { override fun <T : Any, Z : Any> has(key: String, dataType: PersistentDataType<T, Z>): Boolean {

View File

@@ -3,21 +3,33 @@ package com.willfp.eco.internal.spigot.proxy.v1_19_R1
import com.willfp.eco.core.data.ExtendedPersistentDataContainer import com.willfp.eco.core.data.ExtendedPersistentDataContainer
import com.willfp.eco.internal.spigot.proxy.ExtendedPersistentDataContainerFactoryProxy import com.willfp.eco.internal.spigot.proxy.ExtendedPersistentDataContainerFactoryProxy
import net.minecraft.nbt.Tag import net.minecraft.nbt.Tag
import org.bukkit.Material
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack
import org.bukkit.craftbukkit.v1_19_R1.persistence.CraftPersistentDataContainer import org.bukkit.craftbukkit.v1_19_R1.persistence.CraftPersistentDataContainer
import org.bukkit.craftbukkit.v1_19_R1.persistence.CraftPersistentDataTypeRegistry import org.bukkit.craftbukkit.v1_19_R1.persistence.CraftPersistentDataTypeRegistry
import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataContainer import org.bukkit.persistence.PersistentDataContainer
import org.bukkit.persistence.PersistentDataType import org.bukkit.persistence.PersistentDataType
class ExtendedPersistentDataContainerFactory: ExtendedPersistentDataContainerFactoryProxy { class ExtendedPersistentDataContainerFactory : ExtendedPersistentDataContainerFactoryProxy {
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
private val registry: CraftPersistentDataTypeRegistry = private val registry: CraftPersistentDataTypeRegistry
CraftPersistentDataContainer::class.java.getDeclaredField("registry")
.apply { isAccessible = true }.get(null) as CraftPersistentDataTypeRegistry init {
/*
Can't grab actual instance since it's in CraftMetaItem (which is package-private)
And getting it would mean more janky reflection
*/
val item = CraftItemStack.asCraftCopy(ItemStack(Material.STONE))
val pdc = item.itemMeta!!.persistentDataContainer
this.registry = CraftPersistentDataContainer::class.java.getDeclaredField("registry")
.apply { isAccessible = true }.get(pdc) as CraftPersistentDataTypeRegistry
}
override fun adapt(pdc: PersistentDataContainer): ExtendedPersistentDataContainer { override fun adapt(pdc: PersistentDataContainer): ExtendedPersistentDataContainer {
return when (pdc) { return when (pdc) {
is CraftPersistentDataContainer -> EcoPersistentDataContainer(pdc) is CraftPersistentDataContainer -> EcoPersistentDataContainer(pdc)
else -> throw IllegalArgumentException("Custom PDC instance is not supported!") else -> throw IllegalArgumentException("Custom PDC instance ims not supported!")
} }
} }
@@ -34,7 +46,8 @@ class ExtendedPersistentDataContainerFactory: ExtendedPersistentDataContainerFac
.apply { isAccessible = true }.get(handle) as MutableMap<String, Tag> .apply { isAccessible = true }.get(handle) as MutableMap<String, Tag>
override fun <T : Any, Z : Any> set(key: String, dataType: PersistentDataType<T, Z>, value: Z) { override fun <T : Any, Z : Any> set(key: String, dataType: PersistentDataType<T, Z>, value: Z) {
customDataTags[key] = registry.wrap(dataType.primitiveType, dataType.toPrimitive(value, handle.adapterContext)) customDataTags[key] =
registry.wrap(dataType.primitiveType, dataType.toPrimitive(value, handle.adapterContext))
} }
override fun <T : Any, Z : Any> has(key: String, dataType: PersistentDataType<T, Z>): Boolean { override fun <T : Any, Z : Any> has(key: String, dataType: PersistentDataType<T, Z>): Boolean {

View File

@@ -4,7 +4,6 @@ import com.willfp.eco.core.Eco
import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.PluginLike import com.willfp.eco.core.PluginLike
import com.willfp.eco.core.PluginProps import com.willfp.eco.core.PluginProps
import com.willfp.eco.core.Prerequisite
import com.willfp.eco.core.config.ConfigType import com.willfp.eco.core.config.ConfigType
import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.config.interfaces.Config
import com.willfp.eco.core.data.keys.PersistentDataKey import com.willfp.eco.core.data.keys.PersistentDataKey
@@ -34,12 +33,12 @@ import com.willfp.eco.internal.gui.MergedStateMenu
import com.willfp.eco.internal.gui.menu.EcoMenuBuilder import com.willfp.eco.internal.gui.menu.EcoMenuBuilder
import com.willfp.eco.internal.gui.menu.renderedInventory import com.willfp.eco.internal.gui.menu.renderedInventory
import com.willfp.eco.internal.gui.slot.EcoSlotBuilder import com.willfp.eco.internal.gui.slot.EcoSlotBuilder
import com.willfp.eco.internal.integrations.PlaceholderIntegrationPAPI import com.willfp.eco.internal.integrations.PAPIExpansion
import com.willfp.eco.internal.logging.EcoLogger import com.willfp.eco.internal.logging.EcoLogger
import com.willfp.eco.internal.proxy.EcoProxyFactory import com.willfp.eco.internal.proxy.EcoProxyFactory
import com.willfp.eco.internal.scheduling.EcoScheduler import com.willfp.eco.internal.scheduling.EcoScheduler
import com.willfp.eco.internal.spigot.data.DataYml import com.willfp.eco.internal.spigot.data.DataYml
import com.willfp.eco.internal.spigot.data.EcoProfileHandler import com.willfp.eco.internal.spigot.data.ProfileHandler
import com.willfp.eco.internal.spigot.data.KeyRegistry import com.willfp.eco.internal.spigot.data.KeyRegistry
import com.willfp.eco.internal.spigot.data.storage.HandlerType import com.willfp.eco.internal.spigot.data.storage.HandlerType
import com.willfp.eco.internal.spigot.integrations.bstats.MetricHandler import com.willfp.eco.internal.spigot.integrations.bstats.MetricHandler
@@ -53,7 +52,6 @@ import com.willfp.eco.internal.spigot.proxy.MiniMessageTranslatorProxy
import com.willfp.eco.internal.spigot.proxy.SNBTConverterProxy import com.willfp.eco.internal.spigot.proxy.SNBTConverterProxy
import com.willfp.eco.internal.spigot.proxy.SkullProxy import com.willfp.eco.internal.spigot.proxy.SkullProxy
import com.willfp.eco.internal.spigot.proxy.TPSProxy import com.willfp.eco.internal.spigot.proxy.TPSProxy
import net.kyori.adventure.platform.bukkit.BukkitAudiences
import org.bukkit.Location import org.bukkit.Location
import org.bukkit.NamespacedKey import org.bukkit.NamespacedKey
import org.bukkit.configuration.ConfigurationSection import org.bukkit.configuration.ConfigurationSection
@@ -72,7 +70,7 @@ private val loadedEcoPlugins = mutableMapOf<String, EcoPlugin>()
class EcoImpl : EcoSpigotPlugin(), Eco { class EcoImpl : EcoSpigotPlugin(), Eco {
override val dataYml = DataYml(this) override val dataYml = DataYml(this)
override val profileHandler = EcoProfileHandler( override val profileHandler = ProfileHandler(
HandlerType.valueOf(this.configYml.getString("data-handler").uppercase()), HandlerType.valueOf(this.configYml.getString("data-handler").uppercase()),
this this
) )
@@ -81,10 +79,6 @@ class EcoImpl : EcoSpigotPlugin(), Eco {
getProxy(CommonsInitializerProxy::class.java).init() getProxy(CommonsInitializerProxy::class.java).init()
} }
private var adventure: BukkitAudiences? = if (!Prerequisite.HAS_PAPER.isMet) {
BukkitAudiences.create(this)
} else null
@Suppress("RedundantNullableReturnType") @Suppress("RedundantNullableReturnType")
private val keyFactory: InternalNamespacedKeyFactory? = private val keyFactory: InternalNamespacedKeyFactory? =
if (this.configYml.getBool("use-safer-namespacedkey-creation")) if (this.configYml.getBool("use-safer-namespacedkey-creation"))
@@ -114,8 +108,9 @@ class EcoImpl : EcoSpigotPlugin(), Eco {
override fun createLogger(plugin: EcoPlugin) = override fun createLogger(plugin: EcoPlugin) =
EcoLogger(plugin) EcoLogger(plugin)
override fun createPAPIIntegration(plugin: EcoPlugin) = override fun createPAPIIntegration(plugin: EcoPlugin) {
PlaceholderIntegrationPAPI(plugin) PAPIExpansion(plugin)
}
override fun getEcoPlugin(): EcoPlugin = override fun getEcoPlugin(): EcoPlugin =
this this
@@ -235,7 +230,7 @@ class EcoImpl : EcoSpigotPlugin(), Eco {
MetricHandler.createMetrics(plugin) MetricHandler.createMetrics(plugin)
override fun getAdventure() = override fun getAdventure() =
adventure bukkitAudiences
override fun getServerProfile() = override fun getServerProfile() =
profileHandler.loadServerProfile() profileHandler.loadServerProfile()

View File

@@ -14,6 +14,7 @@ import com.willfp.eco.core.integrations.customitems.CustomItemsManager
import com.willfp.eco.core.integrations.economy.EconomyManager import com.willfp.eco.core.integrations.economy.EconomyManager
import com.willfp.eco.core.integrations.hologram.HologramManager import com.willfp.eco.core.integrations.hologram.HologramManager
import com.willfp.eco.core.integrations.mcmmo.McmmoManager import com.willfp.eco.core.integrations.mcmmo.McmmoManager
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager
import com.willfp.eco.core.integrations.shop.ShopManager import com.willfp.eco.core.integrations.shop.ShopManager
import com.willfp.eco.core.items.Items import com.willfp.eco.core.items.Items
import com.willfp.eco.internal.entities.EntityArgParserAdult import com.willfp.eco.internal.entities.EntityArgParserAdult
@@ -47,7 +48,7 @@ import com.willfp.eco.internal.lookup.SegmentParserUseIfPresent
import com.willfp.eco.internal.spigot.arrows.ArrowDataListener import com.willfp.eco.internal.spigot.arrows.ArrowDataListener
import com.willfp.eco.internal.spigot.data.DataListener import com.willfp.eco.internal.spigot.data.DataListener
import com.willfp.eco.internal.spigot.data.DataYml import com.willfp.eco.internal.spigot.data.DataYml
import com.willfp.eco.internal.spigot.data.EcoProfileHandler import com.willfp.eco.internal.spigot.data.ProfileHandler
import com.willfp.eco.internal.spigot.data.PlayerBlockListener import com.willfp.eco.internal.spigot.data.PlayerBlockListener
import com.willfp.eco.internal.spigot.data.storage.ProfileSaver import com.willfp.eco.internal.spigot.data.storage.ProfileSaver
import com.willfp.eco.internal.spigot.display.PacketAutoRecipe import com.willfp.eco.internal.spigot.display.PacketAutoRecipe
@@ -106,6 +107,7 @@ import com.willfp.eco.internal.spigot.integrations.hologram.HologramDecentHologr
import com.willfp.eco.internal.spigot.integrations.hologram.HologramHolographicDisplays import com.willfp.eco.internal.spigot.integrations.hologram.HologramHolographicDisplays
import com.willfp.eco.internal.spigot.integrations.mcmmo.McmmoIntegrationImpl import com.willfp.eco.internal.spigot.integrations.mcmmo.McmmoIntegrationImpl
import com.willfp.eco.internal.spigot.integrations.multiverseinventories.MultiverseInventoriesIntegration import com.willfp.eco.internal.spigot.integrations.multiverseinventories.MultiverseInventoriesIntegration
import com.willfp.eco.internal.spigot.integrations.placeholder.PlaceholderIntegrationPAPI
import com.willfp.eco.internal.spigot.integrations.shop.ShopDeluxeSellwands import com.willfp.eco.internal.spigot.integrations.shop.ShopDeluxeSellwands
import com.willfp.eco.internal.spigot.integrations.shop.ShopEconomyShopGUI import com.willfp.eco.internal.spigot.integrations.shop.ShopEconomyShopGUI
import com.willfp.eco.internal.spigot.integrations.shop.ShopShopGuiPlus import com.willfp.eco.internal.spigot.integrations.shop.ShopShopGuiPlus
@@ -118,6 +120,7 @@ import com.willfp.eco.internal.spigot.recipes.listeners.ComplexInComplex
import com.willfp.eco.internal.spigot.recipes.listeners.ComplexInVanilla import com.willfp.eco.internal.spigot.recipes.listeners.ComplexInVanilla
import com.willfp.eco.internal.spigot.recipes.stackhandlers.ShapedCraftingRecipeStackHandler import com.willfp.eco.internal.spigot.recipes.stackhandlers.ShapedCraftingRecipeStackHandler
import com.willfp.eco.internal.spigot.recipes.stackhandlers.ShapelessCraftingRecipeStackHandler import com.willfp.eco.internal.spigot.recipes.stackhandlers.ShapelessCraftingRecipeStackHandler
import net.kyori.adventure.platform.bukkit.BukkitAudiences
import net.milkbowl.vault.economy.Economy import net.milkbowl.vault.economy.Economy
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.Material import org.bukkit.Material
@@ -126,7 +129,8 @@ import org.bukkit.inventory.ItemStack
abstract class EcoSpigotPlugin : EcoPlugin() { abstract class EcoSpigotPlugin : EcoPlugin() {
abstract val dataYml: DataYml abstract val dataYml: DataYml
protected abstract val profileHandler: EcoProfileHandler protected abstract val profileHandler: ProfileHandler
protected var bukkitAudiences: BukkitAudiences? = null
init { init {
Items.registerArgParser(ArgParserEnchantment) Items.registerArgParser(ArgParserEnchantment)
@@ -205,6 +209,11 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
// Preload categorized persistent data keys // Preload categorized persistent data keys
profileHandler.initialize() profileHandler.initialize()
// Init adventure
if (!Prerequisite.HAS_PAPER.isMet) {
bukkitAudiences = BukkitAudiences.create(this)
}
} }
override fun handleDisable() { override fun handleDisable() {
@@ -311,6 +320,9 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
} }
}, },
// Placeholder
IntegrationLoader("PlaceholderAPI") { PlaceholderManager.addIntegration(PlaceholderIntegrationPAPI()) },
// Misc // Misc
IntegrationLoader("mcMMO") { McmmoManager.register(McmmoIntegrationImpl()) }, IntegrationLoader("mcMMO") { McmmoManager.register(McmmoIntegrationImpl()) },
IntegrationLoader("Multiverse-Inventories") { IntegrationLoader("Multiverse-Inventories") {

View File

@@ -18,7 +18,7 @@ import java.util.UUID
val serverProfileUUID = UUID(0, 0) val serverProfileUUID = UUID(0, 0)
class EcoProfileHandler( class ProfileHandler(
private val type: HandlerType, private val type: HandlerType,
private val plugin: EcoSpigotPlugin private val plugin: EcoSpigotPlugin
) { ) {

View File

@@ -7,7 +7,7 @@ import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.data.keys.PersistentDataKey import com.willfp.eco.core.data.keys.PersistentDataKey
import com.willfp.eco.core.data.keys.PersistentDataKeyType import com.willfp.eco.core.data.keys.PersistentDataKeyType
import com.willfp.eco.internal.spigot.EcoSpigotPlugin import com.willfp.eco.internal.spigot.EcoSpigotPlugin
import com.willfp.eco.internal.spigot.data.EcoProfileHandler import com.willfp.eco.internal.spigot.data.ProfileHandler
import com.willfp.eco.internal.spigot.data.serverProfileUUID import com.willfp.eco.internal.spigot.data.serverProfileUUID
import com.zaxxer.hikari.HikariConfig import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource import com.zaxxer.hikari.HikariDataSource
@@ -49,7 +49,7 @@ the worst bodge I've shipped in production.
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
class LegacyMySQLDataHandler( class LegacyMySQLDataHandler(
plugin: EcoSpigotPlugin, plugin: EcoSpigotPlugin,
handler: EcoProfileHandler handler: ProfileHandler
) : DataHandler(HandlerType.LEGACY_MYSQL) { ) : DataHandler(HandlerType.LEGACY_MYSQL) {
private val playerHandler: ImplementedMySQLHandler private val playerHandler: ImplementedMySQLHandler
private val serverHandler: ImplementedMySQLHandler private val serverHandler: ImplementedMySQLHandler
@@ -114,7 +114,7 @@ class LegacyMySQLDataHandler(
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
private class ImplementedMySQLHandler( private class ImplementedMySQLHandler(
private val handler: EcoProfileHandler, private val handler: ProfileHandler,
private val table: UUIDTable, private val table: UUIDTable,
private val plugin: EcoPlugin private val plugin: EcoPlugin
) { ) {

View File

@@ -3,7 +3,7 @@ package com.willfp.eco.internal.spigot.data.storage
import com.willfp.eco.core.data.Profile import com.willfp.eco.core.data.Profile
import com.willfp.eco.core.data.keys.PersistentDataKey import com.willfp.eco.core.data.keys.PersistentDataKey
import com.willfp.eco.internal.spigot.EcoSpigotPlugin import com.willfp.eco.internal.spigot.EcoSpigotPlugin
import com.willfp.eco.internal.spigot.data.EcoProfileHandler import com.willfp.eco.internal.spigot.data.ProfileHandler
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -20,7 +20,7 @@ import java.util.UUID
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
class MongoDataHandler( class MongoDataHandler(
plugin: EcoSpigotPlugin, plugin: EcoSpigotPlugin,
private val handler: EcoProfileHandler private val handler: ProfileHandler
) : DataHandler(HandlerType.MONGO) { ) : DataHandler(HandlerType.MONGO) {
private val client: CoroutineClient private val client: CoroutineClient
private val collection: CoroutineCollection<UUIDProfile> private val collection: CoroutineCollection<UUIDProfile>

View File

@@ -8,7 +8,7 @@ import com.willfp.eco.core.config.interfaces.Config
import com.willfp.eco.core.data.keys.PersistentDataKey import com.willfp.eco.core.data.keys.PersistentDataKey
import com.willfp.eco.core.data.keys.PersistentDataKeyType import com.willfp.eco.core.data.keys.PersistentDataKeyType
import com.willfp.eco.internal.spigot.EcoSpigotPlugin import com.willfp.eco.internal.spigot.EcoSpigotPlugin
import com.willfp.eco.internal.spigot.data.EcoProfileHandler import com.willfp.eco.internal.spigot.data.ProfileHandler
import com.zaxxer.hikari.HikariConfig import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource import com.zaxxer.hikari.HikariDataSource
import org.jetbrains.exposed.dao.id.UUIDTable import org.jetbrains.exposed.dao.id.UUIDTable
@@ -35,7 +35,7 @@ Whatever. At least it works.
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
class MySQLDataHandler( class MySQLDataHandler(
private val plugin: EcoSpigotPlugin, private val plugin: EcoSpigotPlugin,
private val handler: EcoProfileHandler private val handler: ProfileHandler
) : DataHandler(HandlerType.MYSQL) { ) : DataHandler(HandlerType.MYSQL) {
private val table = UUIDTable("eco_data") private val table = UUIDTable("eco_data")

View File

@@ -2,11 +2,11 @@ package com.willfp.eco.internal.spigot.data.storage
import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.internal.spigot.data.EcoProfile import com.willfp.eco.internal.spigot.data.EcoProfile
import com.willfp.eco.internal.spigot.data.EcoProfileHandler import com.willfp.eco.internal.spigot.data.ProfileHandler
class ProfileSaver( class ProfileSaver(
plugin: EcoPlugin, plugin: EcoPlugin,
handler: EcoProfileHandler handler: ProfileHandler
) { ) {
init { init {
plugin.scheduler.runTimer(1, 1) { plugin.scheduler.runTimer(1, 1) {

View File

@@ -3,14 +3,14 @@ package com.willfp.eco.internal.spigot.data.storage
import com.willfp.eco.core.data.keys.PersistentDataKey import com.willfp.eco.core.data.keys.PersistentDataKey
import com.willfp.eco.core.data.keys.PersistentDataKeyType import com.willfp.eco.core.data.keys.PersistentDataKeyType
import com.willfp.eco.internal.spigot.EcoSpigotPlugin import com.willfp.eco.internal.spigot.EcoSpigotPlugin
import com.willfp.eco.internal.spigot.data.EcoProfileHandler import com.willfp.eco.internal.spigot.data.ProfileHandler
import org.bukkit.NamespacedKey import org.bukkit.NamespacedKey
import java.util.UUID import java.util.UUID
@Suppress("UNCHECKED_CAST") @Suppress("UNCHECKED_CAST")
class YamlDataHandler( class YamlDataHandler(
plugin: EcoSpigotPlugin, plugin: EcoSpigotPlugin,
private val handler: EcoProfileHandler private val handler: ProfileHandler
) : DataHandler(HandlerType.YAML) { ) : DataHandler(HandlerType.YAML) {
private val dataYml = plugin.dataYml private val dataYml = plugin.dataYml

View File

@@ -50,6 +50,14 @@ class GUIListener(private val plugin: EcoPlugin) : Listener {
} }
} }
@EventHandler(
priority = EventPriority.HIGHEST
)
fun handleRender(event: InventoryClickEvent) {
val player = event.whoClicked as? Player ?: return
player.renderActiveMenu()
}
@EventHandler( @EventHandler(
priority = EventPriority.HIGH priority = EventPriority.HIGH
) )
@@ -63,8 +71,6 @@ class GUIListener(private val plugin: EcoPlugin) : Listener {
val (row, column) = MenuUtils.convertSlotToRowColumn(event.slot, menu.columns) val (row, column) = MenuUtils.convertSlotToRowColumn(event.slot, menu.columns)
menu.getSlot(row, column, player, menu).handle(player, event, menu) menu.getSlot(row, column, player, menu).handle(player, event, menu)
plugin.scheduler.run { rendered.render() }
} }
@EventHandler( @EventHandler(
@@ -172,7 +178,6 @@ class GUIListener(private val plugin: EcoPlugin) : Listener {
val rendered = player.renderedInventory ?: return val rendered = player.renderedInventory ?: return
if (rendered.menu.allowsChangingHeldItem()) { if (rendered.menu.allowsChangingHeldItem()) {
player.renderActiveMenu()
return return
} }

View File

@@ -0,0 +1,36 @@
package com.willfp.eco.internal.spigot.integrations.placeholder
import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.integrations.placeholder.PlaceholderIntegration
import me.clip.placeholderapi.PlaceholderAPI
import org.bukkit.entity.Player
import java.util.regex.Pattern
class PlaceholderIntegrationPAPI : PlaceholderIntegration {
private val pattern = Pattern.compile("[%]([^% ]+)[%]")
override fun registerIntegration() {
// Do nothing.
}
override fun getPluginName(): String {
return "PlaceholderAPI"
}
override fun translate(
text: String,
player: Player?
): String {
return PlaceholderAPI.setPlaceholders(player, text)
}
override fun findPlaceholdersIn(text: String): MutableList<String> {
val placeholders = mutableListOf<String>()
val matcher = pattern.matcher(text)
while (matcher.find()) {
placeholders.add(matcher.group())
}
return placeholders
}
}

View File

@@ -1,3 +1,3 @@
version = 6.43.1 version = 6.43.7
plugin-name = eco plugin-name = eco
kotlin.code.style = official kotlin.code.style = official