Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0ed083a5c | ||
|
|
04f04bb7a6 | ||
|
|
b8a3806ff9 | ||
|
|
ae49d41542 | ||
|
|
5f2255a3bc | ||
|
|
065ccfbe67 | ||
|
|
17727c9015 | ||
|
|
ea64e69b4d | ||
|
|
07ca6c2359 | ||
|
|
162558b1c2 | ||
|
|
10f9e8dce0 | ||
|
|
b02943d7ff | ||
|
|
1cf08955a0 |
@@ -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.
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -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)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ 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
|
||||||
@@ -114,8 +114,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
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -311,6 +313,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") {
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
version = 6.43.2
|
version = 6.43.5
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
Reference in New Issue
Block a user