Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ef8dcfd64 | ||
|
|
5bedf88b4c | ||
|
|
1d241651b5 | ||
|
|
3ff2bfa412 | ||
|
|
3a508c693b | ||
|
|
a4c5ff921e | ||
|
|
137e9dc7d6 | ||
|
|
710cec4bc1 | ||
|
|
fa0ec7d6b0 | ||
|
|
5093799775 | ||
|
|
8535f23ede | ||
|
|
8e09ae7f4c | ||
|
|
bbc2513b40 | ||
|
|
c7f8063a3a | ||
|
|
14b0f1be0c | ||
|
|
af20bb315b | ||
|
|
6645e216d5 | ||
|
|
eddf240f0c | ||
|
|
4f406353ba | ||
|
|
095494dd2e | ||
|
|
fd92645500 | ||
|
|
1a6ac29083 |
@@ -401,15 +401,6 @@ public interface Eco {
|
|||||||
@NotNull
|
@NotNull
|
||||||
ServerProfile getServerProfile();
|
ServerProfile getServerProfile();
|
||||||
|
|
||||||
/**
|
|
||||||
* Unload a player profile from memory.
|
|
||||||
* <p>
|
|
||||||
* This will not save the profile first.
|
|
||||||
*
|
|
||||||
* @param uuid The uuid.
|
|
||||||
*/
|
|
||||||
void unloadPlayerProfile(@NotNull UUID uuid);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create dummy entity - never spawned, exists purely in code.
|
* Create dummy entity - never spawned, exists purely in code.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -9,6 +9,14 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* Profiles save automatically, so there is no need to save after changes.
|
* Profiles save automatically, so there is no need to save after changes.
|
||||||
*/
|
*/
|
||||||
public interface ServerProfile extends Profile {
|
public interface ServerProfile extends Profile {
|
||||||
|
/**
|
||||||
|
* Get the server ID.
|
||||||
|
*
|
||||||
|
* @return The server ID.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
String getServerID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the server profile.
|
* Load the server profile.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -17,6 +17,13 @@ import java.util.function.Supplier;
|
|||||||
* @param <T> The type of integration.
|
* @param <T> The type of integration.
|
||||||
*/
|
*/
|
||||||
public class IntegrationRegistry<T extends Integration> extends Registry<T> {
|
public class IntegrationRegistry<T extends Integration> extends Registry<T> {
|
||||||
|
/**
|
||||||
|
* Create a new integration registry.
|
||||||
|
*/
|
||||||
|
public IntegrationRegistry() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull T register(@NotNull final T element) {
|
public @NotNull T register(@NotNull final T element) {
|
||||||
return executeSafely(() -> super.register(element), element);
|
return executeSafely(() -> super.register(element), element);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.willfp.eco.core.price;
|
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.config.interfaces.Config;
|
||||||
import com.willfp.eco.core.placeholder.context.PlaceholderContext;
|
import com.willfp.eco.core.placeholder.context.PlaceholderContext;
|
||||||
import com.willfp.eco.core.price.impl.PriceFree;
|
import com.willfp.eco.core.price.impl.PriceFree;
|
||||||
@@ -158,12 +159,27 @@ public final class ConfiguredPrice implements Price {
|
|||||||
if (!(
|
if (!(
|
||||||
config.has("value")
|
config.has("value")
|
||||||
&& config.has("type")
|
&& config.has("type")
|
||||||
&& config.has("display")
|
|
||||||
)) {
|
)) {
|
||||||
return null;
|
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(
|
Price price = Prices.create(
|
||||||
config.getString("value"),
|
config.getString("value"),
|
||||||
|
|||||||
@@ -286,9 +286,6 @@ class EcoImpl : EcoSpigotPlugin(), Eco {
|
|||||||
override fun loadPlayerProfile(uuid: UUID) =
|
override fun loadPlayerProfile(uuid: UUID) =
|
||||||
profileHandler.load(uuid)
|
profileHandler.load(uuid)
|
||||||
|
|
||||||
override fun unloadPlayerProfile(uuid: UUID) =
|
|
||||||
profileHandler.unloadPlayer(uuid)
|
|
||||||
|
|
||||||
override fun createDummyEntity(location: Location): Entity =
|
override fun createDummyEntity(location: Location): Entity =
|
||||||
getProxy(DummyEntityFactoryProxy::class.java).createDummyEntity(location)
|
getProxy(DummyEntityFactoryProxy::class.java).createDummyEntity(location)
|
||||||
|
|
||||||
|
|||||||
@@ -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.multiverseinventories.MultiverseInventoriesIntegration
|
||||||
import com.willfp.eco.internal.spigot.integrations.placeholder.PlaceholderIntegrationPAPI
|
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.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.price.PriceFactoryUltraEconomy
|
||||||
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
|
||||||
import com.willfp.eco.internal.spigot.integrations.shop.ShopZShop
|
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.FastItemStackFactoryProxy
|
||||||
import com.willfp.eco.internal.spigot.proxy.PacketHandlerProxy
|
import com.willfp.eco.internal.spigot.proxy.PacketHandlerProxy
|
||||||
import com.willfp.eco.internal.spigot.recipes.CraftingRecipeListener
|
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.internal.spigot.recipes.stackhandlers.ShapelessCraftingRecipeStackHandler
|
||||||
import com.willfp.eco.util.ClassUtils
|
import com.willfp.eco.util.ClassUtils
|
||||||
import me.TechsCode.UltraEconomy.UltraEconomy
|
import me.TechsCode.UltraEconomy.UltraEconomy
|
||||||
|
import me.qKing12.RoyaleEconomy.MultiCurrency.MultiCurrencyHandler
|
||||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences
|
||||||
import net.milkbowl.vault.economy.Economy
|
import net.milkbowl.vault.economy.Economy
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
@@ -219,8 +222,6 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
|||||||
this.logger.info("No conflicts found!")
|
this.logger.info("No conflicts found!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CollatedRunnable(this)
|
|
||||||
CustomItemsManager.registerProviders() // Do it again here
|
CustomItemsManager.registerProviders() // Do it again here
|
||||||
|
|
||||||
// Register events for ShopSellEvent
|
// Register events for ShopSellEvent
|
||||||
@@ -251,7 +252,7 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
|||||||
Eco.get().adventure?.close()
|
Eco.get().adventure?.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleReload() {
|
override fun createTasks() {
|
||||||
CollatedRunnable(this)
|
CollatedRunnable(this)
|
||||||
|
|
||||||
this.scheduler.runLater(3) {
|
this.scheduler.runLater(3) {
|
||||||
@@ -261,10 +262,13 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
|||||||
ProfileSaver(this, profileHandler).startTicking()
|
ProfileSaver(this, profileHandler).startTicking()
|
||||||
|
|
||||||
this.scheduler.runTimer(
|
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()
|
this.configYml.getInt("display-frame-ttl").toLong(),
|
||||||
)
|
) { getProxy(PacketHandlerProxy::class.java).clearDisplayFrames() }
|
||||||
|
|
||||||
|
if (this.configYml.getBool("playerflow")) {
|
||||||
|
PlayerflowHandler(this.scheduler).startTicking()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleAfterLoad() {
|
override fun handleAfterLoad() {
|
||||||
@@ -360,6 +364,11 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
IntegrationLoader("PlayerPoints") { Prices.registerPriceFactory(PriceFactoryPlayerPoints()) },
|
IntegrationLoader("PlayerPoints") { Prices.registerPriceFactory(PriceFactoryPlayerPoints()) },
|
||||||
|
IntegrationLoader("RoyaleEconomy") {
|
||||||
|
for (currency in MultiCurrencyHandler.getCurrencies()) {
|
||||||
|
Prices.registerPriceFactory(PriceFactoryRoyaleEconomy(currency))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// Placeholder
|
// Placeholder
|
||||||
IntegrationLoader("PlaceholderAPI") { PlaceholderManager.addIntegration(PlaceholderIntegrationPAPI()) },
|
IntegrationLoader("PlaceholderAPI") { PlaceholderManager.addIntegration(PlaceholderIntegrationPAPI()) },
|
||||||
@@ -384,7 +393,7 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
|||||||
GUIListener(this),
|
GUIListener(this),
|
||||||
ArrowDataListener(this),
|
ArrowDataListener(this),
|
||||||
ArmorChangeEventListeners(this),
|
ArmorChangeEventListeners(this),
|
||||||
DataListener(this),
|
DataListener(this, profileHandler),
|
||||||
PlayerBlockListener(this),
|
PlayerBlockListener(this),
|
||||||
ServerLocking
|
ServerLocking
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.willfp.eco.internal.spigot.data
|
package com.willfp.eco.internal.spigot.data
|
||||||
|
|
||||||
import com.willfp.eco.core.Eco
|
|
||||||
import com.willfp.eco.core.EcoPlugin
|
import com.willfp.eco.core.EcoPlugin
|
||||||
import com.willfp.eco.util.PlayerUtils
|
import com.willfp.eco.util.PlayerUtils
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
@@ -11,11 +10,14 @@ import org.bukkit.event.player.PlayerLoginEvent
|
|||||||
import org.bukkit.event.player.PlayerQuitEvent
|
import org.bukkit.event.player.PlayerQuitEvent
|
||||||
|
|
||||||
class DataListener(
|
class DataListener(
|
||||||
private val plugin: EcoPlugin
|
private val plugin: EcoPlugin,
|
||||||
|
private val handler: ProfileHandler
|
||||||
) : Listener {
|
) : Listener {
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
fun onLeave(event: PlayerQuitEvent) {
|
fun onLeave(event: PlayerQuitEvent) {
|
||||||
Eco.get().unloadPlayerProfile(event.player.uniqueId)
|
val profile = handler.accessLoadedProfile(event.player.uniqueId) ?: return
|
||||||
|
handler.saveKeysFor(event.player.uniqueId, profile.data.keys)
|
||||||
|
handler.unloadPlayer(event.player.uniqueId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -27,6 +29,6 @@ class DataListener(
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
fun onLogin(event: PlayerLoginEvent) {
|
fun onLogin(event: PlayerLoginEvent) {
|
||||||
Eco.get().unloadPlayerProfile(event.player.uniqueId)
|
handler.unloadPlayer(event.player.uniqueId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import com.willfp.eco.core.data.PlayerProfile
|
|||||||
import com.willfp.eco.core.data.Profile
|
import com.willfp.eco.core.data.Profile
|
||||||
import com.willfp.eco.core.data.ServerProfile
|
import com.willfp.eco.core.data.ServerProfile
|
||||||
import com.willfp.eco.core.data.keys.PersistentDataKey
|
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.internal.spigot.data.storage.DataHandler
|
||||||
|
import com.willfp.eco.util.namespacedKeyOf
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
@@ -64,11 +66,25 @@ class EcoPlayerProfile(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val serverIDKey = PersistentDataKey(
|
||||||
|
namespacedKeyOf("eco", "server_id"),
|
||||||
|
PersistentDataKeyType.STRING,
|
||||||
|
""
|
||||||
|
)
|
||||||
|
|
||||||
class EcoServerProfile(
|
class EcoServerProfile(
|
||||||
data: MutableMap<PersistentDataKey<*>, Any>,
|
data: MutableMap<PersistentDataKey<*>, Any>,
|
||||||
handler: DataHandler,
|
handler: DataHandler,
|
||||||
localHandler: DataHandler
|
localHandler: DataHandler
|
||||||
) : EcoProfile(data, serverProfileUUID, handler, localHandler), ServerProfile {
|
) : 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 toString(): String {
|
override fun toString(): String {
|
||||||
return "EcoServerProfile"
|
return "EcoServerProfile"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.willfp.eco.core.config.interfaces.Config
|
|||||||
import com.willfp.eco.core.data.keys.PersistentDataKey
|
import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||||
import com.willfp.eco.core.data.keys.PersistentDataKeyType
|
import com.willfp.eco.core.data.keys.PersistentDataKeyType
|
||||||
import org.bukkit.NamespacedKey
|
import org.bukkit.NamespacedKey
|
||||||
|
import java.math.BigDecimal
|
||||||
|
|
||||||
object KeyRegistry {
|
object KeyRegistry {
|
||||||
private val registry = mutableMapOf<NamespacedKey, PersistentDataKey<*>>()
|
private val registry = mutableMapOf<NamespacedKey, PersistentDataKey<*>>()
|
||||||
@@ -44,6 +45,9 @@ object KeyRegistry {
|
|||||||
PersistentDataKeyType.CONFIG -> if (default !is Config) {
|
PersistentDataKeyType.CONFIG -> if (default !is Config) {
|
||||||
throw IllegalArgumentException("Invalid Data Type! Should be Config")
|
throw IllegalArgumentException("Invalid Data Type! Should be Config")
|
||||||
}
|
}
|
||||||
|
PersistentDataKeyType.BIG_DECIMAL -> if (default !is BigDecimal) {
|
||||||
|
throw IllegalArgumentException("Invalid Data Type! Should be BigDecimal")
|
||||||
|
}
|
||||||
|
|
||||||
else -> throw NullPointerException("Null value found!")
|
else -> throw NullPointerException("Null value found!")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,11 +58,18 @@ class ProfileHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun saveKeysFor(uuid: UUID, keys: Set<PersistentDataKey<*>>) {
|
fun saveKeysFor(uuid: UUID, keys: Set<PersistentDataKey<*>>) {
|
||||||
handler.saveKeysFor(uuid, keys)
|
val profile = accessLoadedProfile(uuid) ?: return
|
||||||
|
val map = mutableMapOf<PersistentDataKey<*>, Any>()
|
||||||
|
|
||||||
|
for (key in keys) {
|
||||||
|
map[key] = profile.data[key] ?: continue
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.saveKeysFor(uuid, map)
|
||||||
|
|
||||||
// Don't save to local handler if it's the same handler.
|
// Don't save to local handler if it's the same handler.
|
||||||
if (localHandler != handler) {
|
if (localHandler != handler) {
|
||||||
localHandler.saveKeysFor(uuid, keys)
|
localHandler.saveKeysFor(uuid, map)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ abstract class DataHandler(
|
|||||||
/**
|
/**
|
||||||
* Save a set of keys for a given UUID.
|
* Save a set of keys for a given UUID.
|
||||||
*/
|
*/
|
||||||
abstract fun saveKeysFor(uuid: UUID, keys: Set<PersistentDataKey<*>>)
|
abstract fun saveKeysFor(uuid: UUID, keys: Map<PersistentDataKey<*>, Any>)
|
||||||
|
|
||||||
// Everything below this are methods that are only needed for certain implementations.
|
// Everything below this are methods that are only needed for certain implementations.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.willfp.eco.internal.spigot.data.storage
|
package com.willfp.eco.internal.spigot.data.storage
|
||||||
|
|
||||||
import com.willfp.eco.core.data.Profile
|
|
||||||
import com.willfp.eco.core.data.keys.PersistentDataKey
|
import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||||
import com.willfp.eco.internal.spigot.EcoSpigotPlugin
|
import com.willfp.eco.internal.spigot.EcoSpigotPlugin
|
||||||
import com.willfp.eco.internal.spigot.data.ProfileHandler
|
import com.willfp.eco.internal.spigot.data.ProfileHandler
|
||||||
@@ -51,18 +50,16 @@ class MongoDataHandler(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveKeysFor(uuid: UUID, keys: Set<PersistentDataKey<*>>) {
|
override fun saveKeysFor(uuid: UUID, keys: Map<PersistentDataKey<*>, Any>) {
|
||||||
val profile = handler.loadGenericProfile(uuid)
|
|
||||||
|
|
||||||
scope.launch {
|
scope.launch {
|
||||||
for (key in keys) {
|
for ((key, value) in keys) {
|
||||||
saveKey(profile, uuid, key)
|
saveKey(uuid, key, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun <T : Any> saveKey(profile: Profile, uuid: UUID, key: PersistentDataKey<T>) {
|
private suspend fun <T : Any> saveKey(uuid: UUID, key: PersistentDataKey<T>, value: Any) {
|
||||||
val data = profile.read(key)
|
val data = value as T
|
||||||
doWrite(uuid, key, data)
|
doWrite(uuid, key, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,16 +101,15 @@ class MySQLDataHandler(
|
|||||||
setData(uuid, data)
|
setData(uuid, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveKeysFor(uuid: UUID, keys: Set<PersistentDataKey<*>>) {
|
override fun saveKeysFor(uuid: UUID, keys: Map<PersistentDataKey<*>, Any>) {
|
||||||
val profile = handler.loadGenericProfile(uuid)
|
|
||||||
|
|
||||||
executor.submit {
|
executor.submit {
|
||||||
val data = getData(uuid)
|
val data = getData(uuid)
|
||||||
for (key in keys) {
|
|
||||||
data.set(key.key.toString(), profile.read(key))
|
for ((key, value) in keys) {
|
||||||
|
data.set(key.key.toString(), value)
|
||||||
}
|
}
|
||||||
|
|
||||||
setData(uuid, data)
|
doSetData(uuid, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,10 +139,14 @@ class MySQLDataHandler(
|
|||||||
|
|
||||||
private fun setData(uuid: UUID, config: Config) {
|
private fun setData(uuid: UUID, config: Config) {
|
||||||
executor.submit {
|
executor.submit {
|
||||||
transaction(database) {
|
doSetData(uuid, config)
|
||||||
table.update({ table.id eq uuid }) {
|
}
|
||||||
it[dataColumn] = config.toPlaintext()
|
}
|
||||||
}
|
|
||||||
|
private fun doSetData(uuid: UUID, config: Config) {
|
||||||
|
transaction(database) {
|
||||||
|
table.update({ table.id eq uuid }) {
|
||||||
|
it[dataColumn] = config.toPlaintext()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,11 +41,9 @@ class YamlDataHandler(
|
|||||||
doWrite(uuid, key.key, value)
|
doWrite(uuid, key.key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun saveKeysFor(uuid: UUID, keys: Set<PersistentDataKey<*>>) {
|
override fun saveKeysFor(uuid: UUID, keys: Map<PersistentDataKey<*>, Any>) {
|
||||||
val profile = handler.loadGenericProfile(uuid)
|
for ((key, value) in keys) {
|
||||||
|
doWrite(uuid, key.key, value)
|
||||||
for (key in keys) {
|
|
||||||
doWrite(uuid, key.key, profile.read(key))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ class AntigriefPvPManager: AntigriefIntegration {
|
|||||||
override fun canInjure(player: Player, victim: LivingEntity): Boolean {
|
override fun canInjure(player: Player, victim: LivingEntity): Boolean {
|
||||||
return when(victim) {
|
return when(victim) {
|
||||||
is Player -> {
|
is Player -> {
|
||||||
(PvPlayer.get(victim).isInCombat)}
|
val defender = PvPlayer.get(victim)
|
||||||
|
(defender.hasPvPEnabled() && !defender.isNewbie || defender.isInCombat)}
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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().serverID
|
||||||
|
"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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
# faster evaluation times (less CPU usage) at the expense of slightly more memory usage and
|
||||||
# less reactive values.
|
# less reactive values.
|
||||||
math-cache-ttl: 200
|
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
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -194,5 +194,9 @@ dependencies:
|
|||||||
bootstrap: false
|
bootstrap: false
|
||||||
|
|
||||||
- name: Denizen
|
- name: Denizen
|
||||||
|
required: false
|
||||||
|
bootstrap: false
|
||||||
|
|
||||||
|
- name: RoyaleEconomy
|
||||||
required: false
|
required: false
|
||||||
bootstrap: false
|
bootstrap: false
|
||||||
@@ -54,3 +54,4 @@ softdepend:
|
|||||||
- UltraEconomy
|
- UltraEconomy
|
||||||
- PlayerPoints
|
- PlayerPoints
|
||||||
- Denizen
|
- Denizen
|
||||||
|
- RoyaleEconomy
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
version = 6.60.0
|
version = 6.61.0
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
BIN
lib/RoyaleEconomyAPI.jar
Normal file
BIN
lib/RoyaleEconomyAPI.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user