Compare commits

..

9 Commits

Author SHA1 Message Date
Will FP
35496c60fc Updated to 6.68.6 2024-01-23 14:48:40 +00:00
Will FP
9b4af3eeab Fixed SCore 2024-01-23 14:48:19 +00:00
Will FP
67981b4f9a Updated to 6.68.5 2024-01-15 23:17:27 +00:00
Will FP
03eb2f5d0a Fixed DeluxeCombat 2024-01-15 23:17:17 +00:00
Will FP
2df60bffee Updated to 6.68.4 2024-01-14 16:44:31 +00:00
Will FP
b97506ae70 Fixed bugs on spigot and old paper versions 2024-01-14 16:44:09 +00:00
Will FP
75afe1f2b0 Moved CMI to loadbefore 2024-01-07 14:31:22 +00:00
Will FP
4464d3bf75 Updated to 6.68.3 2024-01-07 12:41:16 +00:00
Will FP
75f217b141 Added math expression parsing to placeholders, {{expr}} and {^{expr}} (to format values nicely) 2024-01-07 12:41:06 +00:00
8 changed files with 45 additions and 11 deletions

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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)
}

View File

@@ -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")

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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

View File

@@ -1,2 +1,2 @@
version = 6.68.2
version = 6.68.6
kotlin.incremental.useClasspathSnapshot=false