Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35496c60fc | ||
|
|
9b4af3eeab | ||
|
|
67981b4f9a | ||
|
|
03eb2f5d0a | ||
|
|
2df60bffee | ||
|
|
b97506ae70 | ||
|
|
75afe1f2b0 | ||
|
|
4464d3bf75 | ||
|
|
75f217b141 |
@@ -37,9 +37,14 @@ fun ItemStack.toSNBT() =
|
||||
Items.toSNBT(this)
|
||||
|
||||
/** @see Items.isEmpty */
|
||||
@Deprecated("Use ItemStack.isEcoEmpty", ReplaceWith("Items.isEmpty(this)"))
|
||||
val ItemStack?.isEmpty: Boolean
|
||||
get() = Items.isEmpty(this)
|
||||
|
||||
/** @see Items.isEmpty */
|
||||
val ItemStack?.isEcoEmpty: Boolean
|
||||
get() = Items.isEmpty(this)
|
||||
|
||||
/** @see Items.matchesAny */
|
||||
fun Collection<TestableItem>.matches(item: ItemStack): Boolean =
|
||||
Items.matchesAny(item, this)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.willfp.eco.internal.gui.menu
|
||||
|
||||
import com.willfp.eco.core.gui.menu.events.CaptiveItemChangeEvent
|
||||
import com.willfp.eco.core.items.isEcoEmpty
|
||||
import com.willfp.eco.core.recipe.parts.EmptyTestableItem
|
||||
import com.willfp.eco.util.MenuUtils
|
||||
import com.willfp.eco.util.openMenu
|
||||
@@ -54,7 +55,7 @@ class RenderedInventory(
|
||||
val actualItem = inventory.getItem(bukkit) ?: continue
|
||||
|
||||
if (slot.isCaptiveFromEmpty) {
|
||||
if (!actualItem.isEmpty) {
|
||||
if (!actualItem.isEcoEmpty) {
|
||||
newCaptive[position] = actualItem
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -7,6 +7,8 @@ import com.willfp.eco.core.placeholder.InjectablePlaceholder
|
||||
import com.willfp.eco.core.placeholder.Placeholder
|
||||
import com.willfp.eco.core.placeholder.context.PlaceholderContext
|
||||
import com.willfp.eco.util.StringUtils
|
||||
import com.willfp.eco.util.evaluateExpression
|
||||
import com.willfp.eco.util.toNiceString
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/*
|
||||
@@ -19,6 +21,8 @@ but it's still best to minimise the memory overhead.
|
||||
|
||||
class PlaceholderParser {
|
||||
private val placeholderRegex = Regex("%([^% ]+)%")
|
||||
private val prettyMathExpressionRegex = Regex("(\\{\\^\\{)(.)+(}})")
|
||||
private val mathExpressionRegex = Regex("(\\{\\{)(.)+(}})")
|
||||
|
||||
private val placeholderLookupCache = Caffeine.newBuilder()
|
||||
.expireAfterWrite(1, TimeUnit.SECONDS)
|
||||
@@ -34,6 +38,29 @@ class PlaceholderParser {
|
||||
injections: Collection<InjectablePlaceholder>,
|
||||
translateEcoPlaceholders: Boolean = true
|
||||
): String {
|
||||
var processed = text
|
||||
|
||||
// Only evaluate math expressions if there might be any
|
||||
// Checking { as a char is faster than checking a string sequence,
|
||||
// even if it might lead to false positives.
|
||||
if ('{' in processed) {
|
||||
if ('^' in processed) {
|
||||
// Evaluate pretty math expressions
|
||||
processed = prettyMathExpressionRegex.findAll(processed).fold(processed) { acc, matchResult ->
|
||||
val expression = matchResult.value.substring(3, matchResult.value.length - 2)
|
||||
val result = evaluateExpression(expression, context)
|
||||
acc.replace(matchResult.value, result.toNiceString())
|
||||
}
|
||||
}
|
||||
|
||||
// Evaluate math expressions
|
||||
processed = mathExpressionRegex.findAll(processed).fold(processed) { acc, matchResult ->
|
||||
val expression = matchResult.value.substring(2, matchResult.value.length - 2)
|
||||
val result = evaluateExpression(expression, context)
|
||||
acc.replace(matchResult.value, result.toString())
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Why am I doing injections at the start, and again at the end?
|
||||
@@ -55,7 +82,7 @@ class PlaceholderParser {
|
||||
*/
|
||||
|
||||
// Apply injections first
|
||||
var processed = injections.fold(text) { acc, injection ->
|
||||
processed = injections.fold(processed) { acc, injection ->
|
||||
injection.tryTranslateQuickly(acc, context)
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ dependencies {
|
||||
|
||||
// Included in spigot jar
|
||||
compileOnly("com.google.code.gson:gson:2.8.8")
|
||||
compileOnly("io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")
|
||||
|
||||
// Plugin dependencies
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.willfp.eco.internal.spigot.arrows
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.items.isEmpty
|
||||
import com.willfp.eco.core.items.isEcoEmpty
|
||||
import org.bukkit.entity.Arrow
|
||||
import org.bukkit.entity.LivingEntity
|
||||
import org.bukkit.event.EventHandler
|
||||
@@ -29,7 +29,7 @@ class ArrowDataListener(
|
||||
|
||||
val item = entity.equipment?.itemInMainHand
|
||||
|
||||
if (item.isEmpty || item == null) {
|
||||
if (item.isEcoEmpty || item == null) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.willfp.eco.internal.spigot.recipes
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.items.TestableItem
|
||||
import com.willfp.eco.core.items.isEmpty
|
||||
import com.willfp.eco.core.items.isEcoEmpty
|
||||
import com.willfp.eco.core.recipe.Recipes
|
||||
import com.willfp.eco.core.recipe.parts.GroupedTestableItems
|
||||
import com.willfp.eco.core.recipe.parts.TestableStack
|
||||
@@ -33,7 +33,7 @@ class StackedRecipeListener(
|
||||
}
|
||||
|
||||
// Just in case
|
||||
if (inventory.getItem(event.slot).isEmpty) {
|
||||
if (inventory.getItem(event.slot).isEcoEmpty) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,10 @@ loadbefore:
|
||||
- Lands
|
||||
- EconomyShopGUI
|
||||
- EconomyShopGUI-Premium
|
||||
- CMI
|
||||
- DeluxeCombat
|
||||
- SCore
|
||||
- ExecutableItems
|
||||
softdepend:
|
||||
- ProtocolLib
|
||||
- WorldGuard
|
||||
@@ -35,18 +39,15 @@ softdepend:
|
||||
- Alice
|
||||
- HolographicDisplays
|
||||
- GHolo
|
||||
- CMI
|
||||
- Essentials
|
||||
- Vault
|
||||
- BentoBox
|
||||
- DeluxeCombat
|
||||
- IridiumSkyblock
|
||||
- SuperiorSkyblock2
|
||||
- FabledSkyBlock
|
||||
- CrashClaim
|
||||
- DecentHolograms
|
||||
- MythicMobs
|
||||
- ExecutableItems
|
||||
- RPGHorses
|
||||
- zShop
|
||||
- DeluxeSellwands
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version = 6.68.2
|
||||
version = 6.68.6
|
||||
kotlin.incremental.useClasspathSnapshot=false
|
||||
Reference in New Issue
Block a user