Compare commits

...

17 Commits

Author SHA1 Message Date
Auxilor
c1ed771eb3 Updated to 6.61.1 2023-05-22 13:22:03 +01:00
Auxilor
08a4d9d6b1 Changed playerflow to use local server ID 2023-05-22 01:35:23 +01:00
Auxilor
7ef8dcfd64 Merge branch 'develop' 2023-05-21 19:07:56 +01:00
Auxilor
5bedf88b4c Updated lang.yml 2023-05-21 19:03:47 +01:00
Auxilor
1d241651b5 Added config option for playerflow 2023-05-21 17:01:13 +01:00
Auxilor
3ff2bfa412 Updated playerflow URL 2023-05-21 16:58:21 +01:00
Auxilor
3a508c693b Updated to 6.61.0 2023-05-21 16:38:35 +01:00
Auxilor
a4c5ff921e Added playerflow 2023-05-21 16:38:17 +01:00
Auxilor
137e9dc7d6 Added global price display names 2023-05-20 18:01:45 +01:00
Auxilor
710cec4bc1 Merge branch 'develop' 2023-05-19 13:17:05 +01:00
Auxilor
fa0ec7d6b0 Updated to 6.60.4 2023-05-19 13:16:20 +01:00
Auxilor
5093799775 Merge remote-tracking branch 'origin/develop' into develop 2023-05-19 13:15:34 +01:00
Will FP
8535f23ede Merge pull request #274
Fix PvPManager integration
2023-05-19 13:15:24 +01:00
Will FP
8e09ae7f4c Merge pull request #275
Add RoyaleEconomy to prices system
2023-05-19 13:14:54 +01:00
Sen2000
bbc2513b40 Fix RoyaleEconomy integration 2023-05-19 16:54:05 +07:00
Sen2000
c7f8063a3a Add RoyaleEconomy to prices system 2023-05-19 09:11:17 +07:00
ChanceSD
14b0f1be0c Fix PvPManager integration 2023-05-18 22:42:49 +01:00
13 changed files with 199 additions and 9 deletions

View File

@@ -9,6 +9,22 @@ import org.jetbrains.annotations.NotNull;
* Profiles save automatically, so there is no need to save after changes.
*/
public interface ServerProfile extends Profile {
/**
* Get the server ID.
*
* @return The server ID.
*/
@NotNull
String getServerID();
/**
* Get the local server ID.
*
* @return The local server ID.
*/
@NotNull
String getLocalServerID();
/**
* Load the server profile.
*

View File

@@ -1,5 +1,6 @@
package com.willfp.eco.core.price;
import com.willfp.eco.core.Eco;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.placeholder.context.PlaceholderContext;
import com.willfp.eco.core.price.impl.PriceFree;
@@ -158,12 +159,27 @@ public final class ConfiguredPrice implements Price {
if (!(
config.has("value")
&& config.has("type")
&& config.has("display")
)) {
return null;
}
String formatString = config.getString("display");
String formatString;
String langConfig = Eco.get().getEcoPlugin().getLangYml()
.getSubsections("price-display")
.stream()
.filter(section -> section.getString("type").equalsIgnoreCase(config.getString("type")))
.findFirst()
.map(section -> section.getString("display"))
.orElse(null);
if (langConfig != null) {
formatString = langConfig;
} else if (config.has("display")) {
formatString = config.getString("display");
} else {
return null;
}
Price price = Prices.create(
config.getString("value"),

View File

@@ -112,11 +112,13 @@ 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.placeholder.PlaceholderIntegrationPAPI
import com.willfp.eco.internal.spigot.integrations.price.PriceFactoryPlayerPoints
import com.willfp.eco.internal.spigot.integrations.price.PriceFactoryRoyaleEconomy
import com.willfp.eco.internal.spigot.integrations.price.PriceFactoryUltraEconomy
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.ShopShopGuiPlus
import com.willfp.eco.internal.spigot.integrations.shop.ShopZShop
import com.willfp.eco.internal.spigot.metrics.PlayerflowHandler
import com.willfp.eco.internal.spigot.proxy.FastItemStackFactoryProxy
import com.willfp.eco.internal.spigot.proxy.PacketHandlerProxy
import com.willfp.eco.internal.spigot.recipes.CraftingRecipeListener
@@ -127,6 +129,7 @@ import com.willfp.eco.internal.spigot.recipes.stackhandlers.ShapedCraftingRecipe
import com.willfp.eco.internal.spigot.recipes.stackhandlers.ShapelessCraftingRecipeStackHandler
import com.willfp.eco.util.ClassUtils
import me.TechsCode.UltraEconomy.UltraEconomy
import me.qKing12.RoyaleEconomy.MultiCurrency.MultiCurrencyHandler
import net.kyori.adventure.platform.bukkit.BukkitAudiences
import net.milkbowl.vault.economy.Economy
import org.bukkit.Bukkit
@@ -259,10 +262,13 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
ProfileSaver(this, profileHandler).startTicking()
this.scheduler.runTimer(
{ getProxy(PacketHandlerProxy::class.java).clearDisplayFrames() },
this.configYml.getInt("display-frame-ttl").toLong(),
this.configYml.getInt("display-frame-ttl").toLong()
)
this.configYml.getInt("display-frame-ttl").toLong(),
) { getProxy(PacketHandlerProxy::class.java).clearDisplayFrames() }
if (this.configYml.getBool("playerflow")) {
PlayerflowHandler(this.scheduler).startTicking()
}
}
override fun handleAfterLoad() {
@@ -358,6 +364,11 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
}
},
IntegrationLoader("PlayerPoints") { Prices.registerPriceFactory(PriceFactoryPlayerPoints()) },
IntegrationLoader("RoyaleEconomy") {
for (currency in MultiCurrencyHandler.getCurrencies()) {
Prices.registerPriceFactory(PriceFactoryRoyaleEconomy(currency))
}
},
// Placeholder
IntegrationLoader("PlaceholderAPI") { PlaceholderManager.addIntegration(PlaceholderIntegrationPAPI()) },

View File

@@ -5,7 +5,9 @@ import com.willfp.eco.core.data.PlayerProfile
import com.willfp.eco.core.data.Profile
import com.willfp.eco.core.data.ServerProfile
import com.willfp.eco.core.data.keys.PersistentDataKey
import com.willfp.eco.core.data.keys.PersistentDataKeyType
import com.willfp.eco.internal.spigot.data.storage.DataHandler
import com.willfp.eco.util.namespacedKeyOf
import java.util.UUID
import java.util.concurrent.ConcurrentHashMap
@@ -64,15 +66,43 @@ class EcoPlayerProfile(
}
}
private val serverIDKey = PersistentDataKey(
namespacedKeyOf("eco", "server_id"),
PersistentDataKeyType.STRING,
""
)
private val localServerIDKey = PersistentDataKey(
namespacedKeyOf("eco", "local_server_id"),
PersistentDataKeyType.STRING,
""
)
class EcoServerProfile(
data: MutableMap<PersistentDataKey<*>, Any>,
handler: DataHandler,
localHandler: DataHandler
) : EcoProfile(data, serverProfileUUID, handler, localHandler), ServerProfile {
override fun getServerID(): String {
if (this.read(serverIDKey).isBlank()) {
this.write(serverIDKey, UUID.randomUUID().toString())
}
return this.read(serverIDKey)
}
override fun getLocalServerID(): String {
if (this.read(localServerIDKey).isBlank()) {
this.write(localServerIDKey, UUID.randomUUID().toString())
}
return this.read(localServerIDKey)
}
override fun toString(): String {
return "EcoServerProfile"
}
}
private val PersistentDataKey<*>.isLocal: Boolean
get() = EcoPlugin.getPlugin(this.key.namespace)?.isUsingLocalStorage == true
get() = this == localServerIDKey || EcoPlugin.getPlugin(this.key.namespace)?.isUsingLocalStorage == true

View File

@@ -27,7 +27,8 @@ class AntigriefPvPManager: AntigriefIntegration {
override fun canInjure(player: Player, victim: LivingEntity): Boolean {
return when(victim) {
is Player -> {
(PvPlayer.get(victim).isInCombat)}
val defender = PvPlayer.get(victim)
(defender.hasPvPEnabled() && !defender.isNewbie || defender.isInCombat)}
else -> true
}
}

View File

@@ -0,0 +1,54 @@
package com.willfp.eco.internal.spigot.integrations.price
import com.willfp.eco.core.placeholder.context.PlaceholderContext
import com.willfp.eco.core.placeholder.context.PlaceholderContextSupplier
import com.willfp.eco.core.price.Price
import com.willfp.eco.core.price.PriceFactory
import com.willfp.eco.util.toSingletonList
import me.qKing12.RoyaleEconomy.MultiCurrency.Currency
import org.bukkit.entity.Player
import java.util.*
class PriceFactoryRoyaleEconomy(private val currency: Currency) : PriceFactory {
override fun getNames(): List<String> {
return currency.currencyId.lowercase().toSingletonList()
}
override fun create(baseContext: PlaceholderContext, function: PlaceholderContextSupplier<Double>): Price {
return PriceRoyaleEconomy(currency, baseContext) { function.get(it) }
}
private class PriceRoyaleEconomy(
private val currency: Currency,
private val baseContext: PlaceholderContext,
private val function: (PlaceholderContext) -> Double
) : Price {
private val multipliers = mutableMapOf<UUID, Double>()
override fun canAfford(player: Player, multiplier: Double): Boolean {
return currency.getAmount(player.uniqueId.toString()) >= getValue(player, multiplier)
}
override fun pay(player: Player, multiplier: Double) {
currency.removeAmount(player.uniqueId.toString(), getValue(player, multiplier))
}
override fun giveTo(player: Player, multiplier: Double) {
currency.addAmount(player.uniqueId.toString(), getValue(player, multiplier))
}
override fun getValue(player: Player, multiplier: Double): Double {
return function(baseContext.copyWithPlayer(player)) * getMultiplier(player) * multiplier
}
override fun getMultiplier(player: Player): Double {
return multipliers[player.uniqueId] ?: 1.0
}
override fun setMultiplier(player: Player, multiplier: Double) {
multipliers[player.uniqueId] = multiplier
}
}
}

View File

@@ -0,0 +1,45 @@
package com.willfp.eco.internal.spigot.metrics
import com.willfp.eco.core.Eco
import com.willfp.eco.core.config.json
import com.willfp.eco.core.data.ServerProfile
import com.willfp.eco.core.scheduling.Scheduler
import org.bukkit.Bukkit
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
private const val PLAYERFLOW_URL = "https://playerflow.auxilor.io/api/v1/ping"
private val client = HttpClient.newBuilder().build()
class PlayerflowHandler(
private val scheduler: Scheduler
) {
internal fun startTicking() {
scheduler.runAsyncTimer(1200L, 1200L) {
makeRequest()
}
}
private fun makeRequest() {
val body = json {
"uuid" to ServerProfile.load().localServerID
"players" to Bukkit.getOnlinePlayers().size
"plugins" to Eco.get().loadedPlugins
}.toPlaintext()
val request = HttpRequest.newBuilder()
.uri(URI.create(PLAYERFLOW_URL))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build()
try {
client.send(request, HttpResponse.BodyHandlers.ofString())
} catch (e: Exception) {
// Silently fail
}
}
}

View File

@@ -91,3 +91,9 @@ use-immediate-placeholder-translation-for-math: false
# faster evaluation times (less CPU usage) at the expense of slightly more memory usage and
# less reactive values.
math-cache-ttl: 200
# If anonymous usage statistics should be tracked. This is very valuable information as it
# helps understand how eco and other plugins are being used by logging player and server
# counts. This is completely anonymous and no personal information is logged. This data
# is primarily used for optimisation and server insights.
playerflow: true

View File

@@ -1 +1,7 @@
multiple-in-craft: '&l&c! &fThis recipe requires &a%amount%&f of this item.'
multiple-in-craft: '&l&c! &fThis recipe requires &a%amount%&f of this item.'
# Specify default display names for prices made through ConfiguredPrice#create
# These will override any custom configured price display names.
price-display:
- type: example_type
display: "&e%value% Price"

View File

@@ -194,5 +194,9 @@ dependencies:
bootstrap: false
- name: Denizen
required: false
bootstrap: false
- name: RoyaleEconomy
required: false
bootstrap: false

View File

@@ -54,3 +54,4 @@ softdepend:
- UltraEconomy
- PlayerPoints
- Denizen
- RoyaleEconomy

View File

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

BIN
lib/RoyaleEconomyAPI.jar Normal file

Binary file not shown.