Compare commits
1 Commits
6.68.3
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5f38b59340 |
@@ -120,12 +120,8 @@ public final class ConfiguredPrice implements Price {
|
|||||||
*/
|
*/
|
||||||
public String getDisplay(@NotNull final Player player,
|
public String getDisplay(@NotNull final Player player,
|
||||||
final double multiplier) {
|
final double multiplier) {
|
||||||
double value = this.getPrice().getValue(player, multiplier);
|
|
||||||
|
|
||||||
return StringUtils.format(
|
return StringUtils.format(
|
||||||
formatString
|
formatString.replace("%value%", NumberUtils.format(this.getPrice().getValue(player, multiplier))),
|
||||||
.replace("%value%", NumberUtils.format(value))
|
|
||||||
.replace("%value_commas%", NumberUtils.formatWithCommas(value)),
|
|
||||||
player,
|
player,
|
||||||
StringUtils.FormatOption.WITH_PLACEHOLDERS
|
StringUtils.FormatOption.WITH_PLACEHOLDERS
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -203,20 +203,6 @@ public final class NumberUtils {
|
|||||||
return formatted.endsWith("00") ? String.valueOf((int) toFormat) : formatted;
|
return formatted.endsWith("00") ? String.valueOf((int) toFormat) : formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Format double to string with commas.
|
|
||||||
*
|
|
||||||
* @param toFormat The number to format.
|
|
||||||
* @return Formatted.
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
public static String formatWithCommas(final double toFormat) {
|
|
||||||
DecimalFormat df = new DecimalFormat("#,##0.00");
|
|
||||||
String formatted = df.format(toFormat);
|
|
||||||
|
|
||||||
return formatted.endsWith(".00") ? formatted.substring(0, formatted.length() - 3) : formatted;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Evaluate an expression.
|
* Evaluate an expression.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,10 +8,6 @@ import com.willfp.eco.core.placeholder.context.PlaceholderContext
|
|||||||
fun Number.toNumeral(): String =
|
fun Number.toNumeral(): String =
|
||||||
NumberUtils.toNumeral(this.toInt())
|
NumberUtils.toNumeral(this.toInt())
|
||||||
|
|
||||||
/** @see NumberUtils.formatWithCommas */
|
|
||||||
fun Number.formatWithCommas(): String =
|
|
||||||
NumberUtils.formatWithCommas(this.toDouble())
|
|
||||||
|
|
||||||
/** @see NumberUtils.fromNumeral */
|
/** @see NumberUtils.fromNumeral */
|
||||||
fun String.parseNumeral(): Int =
|
fun String.parseNumeral(): Int =
|
||||||
NumberUtils.fromNumeral(this)
|
NumberUtils.fromNumeral(this)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ dependencies {
|
|||||||
implementation("org.reflections:reflections:0.9.12")
|
implementation("org.reflections:reflections:0.9.12")
|
||||||
implementation("org.objenesis:objenesis:3.2")
|
implementation("org.objenesis:objenesis:3.2")
|
||||||
|
|
||||||
compileOnly("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.4")
|
compileOnly("me.clip:placeholderapi:2.11.4")
|
||||||
compileOnly("net.kyori:adventure-text-minimessage:4.10.0")
|
compileOnly("net.kyori:adventure-text-minimessage:4.10.0")
|
||||||
compileOnly("net.kyori:adventure-platform-bukkit:4.1.0")
|
compileOnly("net.kyori:adventure-platform-bukkit:4.1.0")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.willfp.eco.internal.command
|
|||||||
import com.willfp.eco.core.EcoPlugin
|
import com.willfp.eco.core.EcoPlugin
|
||||||
import com.willfp.eco.core.command.CommandBase
|
import com.willfp.eco.core.command.CommandBase
|
||||||
import com.willfp.eco.core.command.NotificationException
|
import com.willfp.eco.core.command.NotificationException
|
||||||
|
import com.willfp.eco.core.config.base.LangYml
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
import org.bukkit.command.Command
|
import org.bukkit.command.Command
|
||||||
import org.bukkit.command.CommandExecutor
|
import org.bukkit.command.CommandExecutor
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.willfp.eco.internal.config
|
|||||||
|
|
||||||
import com.willfp.eco.core.config.ConfigType
|
import com.willfp.eco.core.config.ConfigType
|
||||||
import com.willfp.eco.core.placeholder.InjectablePlaceholder
|
import com.willfp.eco.core.placeholder.InjectablePlaceholder
|
||||||
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
class EcoConfigSection(
|
class EcoConfigSection(
|
||||||
type: ConfigType,
|
type: ConfigType,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import java.nio.channels.AsynchronousFileChannel
|
|||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.StandardOpenOption
|
import java.nio.file.StandardOpenOption
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
open class EcoLoadableConfig(
|
open class EcoLoadableConfig(
|
||||||
type: ConfigType,
|
type: ConfigType,
|
||||||
configName: String,
|
configName: String,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.willfp.eco.internal.drops
|
package com.willfp.eco.internal.drops
|
||||||
|
|
||||||
import com.willfp.eco.core.Prerequisite
|
|
||||||
import com.willfp.eco.core.drops.DropQueue
|
import com.willfp.eco.core.drops.DropQueue
|
||||||
import com.willfp.eco.core.events.DropQueuePushEvent
|
import com.willfp.eco.core.events.DropQueuePushEvent
|
||||||
import com.willfp.eco.core.integrations.antigrief.AntigriefManager
|
import com.willfp.eco.core.integrations.antigrief.AntigriefManager
|
||||||
@@ -73,17 +72,10 @@ open class EcoDropQueue(val player: Player) : DropQueue() {
|
|||||||
world.dropItem(location, drop!!).velocity = Vector()
|
world.dropItem(location, drop!!).velocity = Vector()
|
||||||
}
|
}
|
||||||
if (xp > 0) {
|
if (xp > 0) {
|
||||||
if (Prerequisite.HAS_PAPER.isMet) {
|
val orb =
|
||||||
player.giveExp(xp, true)
|
world.spawnEntity(player.location.add(0.0, 0.2, 0.0), EntityType.EXPERIENCE_ORB) as ExperienceOrb
|
||||||
} else {
|
orb.velocity = Vector(0, 0, 0)
|
||||||
val orb =
|
orb.experience = xp
|
||||||
world.spawnEntity(
|
|
||||||
player.location.add(0.0, 0.2, 0.0),
|
|
||||||
EntityType.EXPERIENCE_ORB
|
|
||||||
) as ExperienceOrb
|
|
||||||
orb.velocity = Vector(0, 0, 0)
|
|
||||||
orb.experience = xp
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (drop in items) {
|
for (drop in items) {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ object EntityArgParserName : EntityArgParser {
|
|||||||
|
|
||||||
val formatted = StringUtils.format(name)
|
val formatted = StringUtils.format(name)
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
return EntityArgParseResult(
|
return EntityArgParseResult(
|
||||||
{ it.customName == formatted },
|
{ it.customName == formatted },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ class EcoExtensionLoader(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
@Throws(MalformedExtensionException::class)
|
@Throws(MalformedExtensionException::class)
|
||||||
private fun loadExtension(extensionJar: File) {
|
private fun loadExtension(extensionJar: File) {
|
||||||
val url = extensionJar.toURI().toURL()
|
val url = extensionJar.toURI().toURL()
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ import org.bukkit.NamespacedKey
|
|||||||
|
|
||||||
class EcoNamespacedKeyFactory(private val plugin: EcoPlugin) : NamespacedKeyFactory {
|
class EcoNamespacedKeyFactory(private val plugin: EcoPlugin) : NamespacedKeyFactory {
|
||||||
override fun create(key: String): NamespacedKey {
|
override fun create(key: String): NamespacedKey {
|
||||||
return NamespacedKeyUtils.create(plugin.id, key)
|
return NamespacedKeyUtils.create(plugin.name, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@ class FastInternalNamespacedKeyFactory : InternalNamespacedKeyFactory {
|
|||||||
|
|
||||||
class SafeInternalNamespacedKeyFactory : InternalNamespacedKeyFactory {
|
class SafeInternalNamespacedKeyFactory : InternalNamespacedKeyFactory {
|
||||||
override fun create(namespace: String, key: String): NamespacedKey {
|
override fun create(namespace: String, key: String): NamespacedKey {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
return NamespacedKey(namespace, key)
|
return NamespacedKey(namespace, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ class EcoMenu(
|
|||||||
getPossiblyReactiveSlot(row, column, player)
|
getPossiblyReactiveSlot(row, column, player)
|
||||||
|
|
||||||
override fun open(player: Player): Inventory {
|
override fun open(player: Player): Inventory {
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
val inventory = if (columns == 9) {
|
val inventory = if (columns == 9) {
|
||||||
Bukkit.createInventory(null, rows * columns, title)
|
Bukkit.createInventory(null, rows * columns, title)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.willfp.eco.internal.gui.menu
|
package com.willfp.eco.internal.gui.menu
|
||||||
|
|
||||||
import com.willfp.eco.core.gui.menu.events.CaptiveItemChangeEvent
|
import com.willfp.eco.core.gui.menu.events.CaptiveItemChangeEvent
|
||||||
|
import com.willfp.eco.core.items.isEmpty
|
||||||
import com.willfp.eco.core.recipe.parts.EmptyTestableItem
|
import com.willfp.eco.core.recipe.parts.EmptyTestableItem
|
||||||
import com.willfp.eco.util.MenuUtils
|
import com.willfp.eco.util.MenuUtils
|
||||||
import com.willfp.eco.util.openMenu
|
import com.willfp.eco.util.openMenu
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.willfp.eco.core.placeholder.context.placeholderContext
|
|||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
class PAPIExpansion(private val plugin: EcoPlugin) : PlaceholderExpansion() {
|
class PAPIExpansion(private val plugin: EcoPlugin) : PlaceholderExpansion() {
|
||||||
init {
|
init {
|
||||||
register()
|
register()
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ object ArgParserHead : LookupArgParser {
|
|||||||
|
|
||||||
playerName ?: return null
|
playerName ?: return null
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
val player = Bukkit.getOfflinePlayer(playerName)
|
val player = Bukkit.getOfflinePlayer(playerName)
|
||||||
|
|
||||||
meta.owningPlayer = player
|
meta.owningPlayer = player
|
||||||
|
|||||||
@@ -22,13 +22,12 @@ object ArgParserName : LookupArgParser {
|
|||||||
val formatted = StringUtils.format(name)
|
val formatted = StringUtils.format(name)
|
||||||
|
|
||||||
// I don't know why it says it's redundant, the compiler yells at me
|
// I don't know why it says it's redundant, the compiler yells at me
|
||||||
@Suppress("UsePropertyAccessSyntax", "RedundantSuppression", "DEPRECATION")
|
@Suppress("UsePropertyAccessSyntax", "RedundantSuppression")
|
||||||
meta.setDisplayName(formatted)
|
meta.setDisplayName(formatted)
|
||||||
|
|
||||||
return Predicate {
|
return Predicate {
|
||||||
val testMeta = it.itemMeta ?: return@Predicate false
|
val testMeta = it.itemMeta ?: return@Predicate false
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
testMeta.displayName == formatted
|
testMeta.displayName == formatted
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,7 +37,6 @@ object ArgParserName : LookupArgParser {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
return "name:\"${meta.displayName}\""
|
return "name:\"${meta.displayName}\""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
package com.willfp.eco.internal.items
|
package com.willfp.eco.internal.items
|
||||||
|
|
||||||
import com.willfp.eco.core.items.args.LookupArgParser
|
import com.willfp.eco.core.items.args.LookupArgParser
|
||||||
|
import org.bukkit.Color
|
||||||
import org.bukkit.NamespacedKey
|
import org.bukkit.NamespacedKey
|
||||||
import org.bukkit.Registry
|
import org.bukkit.Registry
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.inventory.meta.ArmorMeta
|
import org.bukkit.inventory.meta.ArmorMeta
|
||||||
import org.bukkit.inventory.meta.ItemMeta
|
import org.bukkit.inventory.meta.ItemMeta
|
||||||
|
import org.bukkit.inventory.meta.LeatherArmorMeta
|
||||||
import org.bukkit.inventory.meta.trim.ArmorTrim
|
import org.bukkit.inventory.meta.trim.ArmorTrim
|
||||||
import org.bukkit.inventory.meta.trim.TrimMaterial
|
import org.bukkit.inventory.meta.trim.TrimMaterial
|
||||||
import org.bukkit.inventory.meta.trim.TrimPattern
|
import org.bukkit.inventory.meta.trim.TrimPattern
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import com.willfp.eco.core.placeholder.InjectablePlaceholder
|
|||||||
import com.willfp.eco.core.placeholder.Placeholder
|
import com.willfp.eco.core.placeholder.Placeholder
|
||||||
import com.willfp.eco.core.placeholder.context.PlaceholderContext
|
import com.willfp.eco.core.placeholder.context.PlaceholderContext
|
||||||
import com.willfp.eco.util.StringUtils
|
import com.willfp.eco.util.StringUtils
|
||||||
import com.willfp.eco.util.evaluateExpression
|
|
||||||
import com.willfp.eco.util.toNiceString
|
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -21,8 +19,6 @@ but it's still best to minimise the memory overhead.
|
|||||||
|
|
||||||
class PlaceholderParser {
|
class PlaceholderParser {
|
||||||
private val placeholderRegex = Regex("%([^% ]+)%")
|
private val placeholderRegex = Regex("%([^% ]+)%")
|
||||||
private val prettyMathExpressionRegex = Regex("(\\{\\^\\{)(.)+(}})")
|
|
||||||
private val mathExpressionRegex = Regex("(\\{\\{)(.)+(}})")
|
|
||||||
|
|
||||||
private val placeholderLookupCache = Caffeine.newBuilder()
|
private val placeholderLookupCache = Caffeine.newBuilder()
|
||||||
.expireAfterWrite(1, TimeUnit.SECONDS)
|
.expireAfterWrite(1, TimeUnit.SECONDS)
|
||||||
@@ -38,29 +34,6 @@ class PlaceholderParser {
|
|||||||
injections: Collection<InjectablePlaceholder>,
|
injections: Collection<InjectablePlaceholder>,
|
||||||
translateEcoPlaceholders: Boolean = true
|
translateEcoPlaceholders: Boolean = true
|
||||||
): String {
|
): 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?
|
Why am I doing injections at the start, and again at the end?
|
||||||
@@ -82,7 +55,7 @@ class PlaceholderParser {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Apply injections first
|
// Apply injections first
|
||||||
processed = injections.fold(processed) { acc, injection ->
|
var processed = injections.fold(text) { acc, injection ->
|
||||||
injection.tryTranslateQuickly(acc, context)
|
injection.tryTranslateQuickly(acc, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ dependencies {
|
|||||||
|
|
||||||
// Included in spigot jar
|
// Included in spigot jar
|
||||||
compileOnly("com.google.code.gson:gson:2.8.8")
|
compileOnly("com.google.code.gson:gson:2.8.8")
|
||||||
compileOnly("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT")
|
||||||
|
|
||||||
// Plugin dependencies
|
// Plugin dependencies
|
||||||
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
compileOnly("com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT")
|
||||||
@@ -49,7 +49,7 @@ dependencies {
|
|||||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
|
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
|
||||||
compileOnly("com.github.WhipDevelopment:CrashClaim:f9cd7d92eb")
|
compileOnly("com.github.WhipDevelopment:CrashClaim:f9cd7d92eb")
|
||||||
compileOnly("com.github.decentsoftware-eu:decentholograms:2.8.5")
|
compileOnly("com.github.decentsoftware-eu:decentholograms:2.8.5")
|
||||||
compileOnly("com.github.Gypopo:EconomyShopGUI-API:1.4.6")
|
compileOnly("com.github.Gypopo:EconomyShopGUI-API:1.7.0")
|
||||||
compileOnly("com.github.N0RSKA:ScytherAPI:55a")
|
compileOnly("com.github.N0RSKA:ScytherAPI:55a")
|
||||||
compileOnly("org.black_ixx:playerpoints:3.2.5")
|
compileOnly("org.black_ixx:playerpoints:3.2.5")
|
||||||
compileOnly("com.github.Ssomar-Developement:SCore:3.4.7")
|
compileOnly("com.github.Ssomar-Developement:SCore:3.4.7")
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ multiple-in-craft: '&l&c! &fThis recipe requires &a%amount%&f of this item.'
|
|||||||
|
|
||||||
# Specify default display names for prices made through ConfiguredPrice#create
|
# Specify default display names for prices made through ConfiguredPrice#create
|
||||||
# These will override any custom configured price display names.
|
# These will override any custom configured price display names.
|
||||||
# You can use %value% and %value_commas% as placeholders.
|
|
||||||
price-display:
|
price-display:
|
||||||
- type: example_type
|
- type: example_type
|
||||||
display: "&e%value% Price"
|
display: "&e%value% Price"
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
version = 6.68.3
|
version = 6.68.0
|
||||||
kotlin.incremental.useClasspathSnapshot=false
|
kotlin.incremental.useClasspathSnapshot=false
|
||||||
Reference in New Issue
Block a user