Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0370e9f454 | ||
|
|
8d585b58cb | ||
|
|
0bfbd4c036 | ||
|
|
881839955e |
@@ -304,6 +304,11 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike {
|
|||||||
this.color = props.getColor();
|
this.color = props.getColor();
|
||||||
this.supportingExtensions = props.isSupportingExtensions();
|
this.supportingExtensions = props.isSupportingExtensions();
|
||||||
|
|
||||||
|
this.proxyFactory = this.proxyPackage.equalsIgnoreCase("") ? null : Eco.getHandler().createProxyFactory(this);
|
||||||
|
this.logger = Eco.getHandler().createLogger(this);
|
||||||
|
|
||||||
|
this.getLogger().info("Initializing " + this.getColor() + this.getName());
|
||||||
|
|
||||||
this.scheduler = Eco.getHandler().createScheduler(this);
|
this.scheduler = Eco.getHandler().createScheduler(this);
|
||||||
this.eventManager = Eco.getHandler().createEventManager(this);
|
this.eventManager = Eco.getHandler().createEventManager(this);
|
||||||
this.namespacedKeyFactory = Eco.getHandler().createNamespacedKeyFactory(this);
|
this.namespacedKeyFactory = Eco.getHandler().createNamespacedKeyFactory(this);
|
||||||
@@ -311,16 +316,12 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike {
|
|||||||
this.runnableFactory = Eco.getHandler().createRunnableFactory(this);
|
this.runnableFactory = Eco.getHandler().createRunnableFactory(this);
|
||||||
this.extensionLoader = Eco.getHandler().createExtensionLoader(this);
|
this.extensionLoader = Eco.getHandler().createExtensionLoader(this);
|
||||||
this.configHandler = Eco.getHandler().createConfigHandler(this);
|
this.configHandler = Eco.getHandler().createConfigHandler(this);
|
||||||
this.logger = Eco.getHandler().createLogger(this);
|
|
||||||
this.proxyFactory = this.proxyPackage.equalsIgnoreCase("") ? null : Eco.getHandler().createProxyFactory(this);
|
|
||||||
|
|
||||||
this.langYml = this.createLangYml();
|
this.langYml = this.createLangYml();
|
||||||
this.configYml = this.createConfigYml();
|
this.configYml = this.createConfigYml();
|
||||||
|
|
||||||
Eco.getHandler().addNewPlugin(this);
|
Eco.getHandler().addNewPlugin(this);
|
||||||
|
|
||||||
this.getLogger().info("Initializing " + this.getColor() + this.getName());
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The minimum eco version check was moved here because it's very common
|
The minimum eco version check was moved here because it's very common
|
||||||
to add a lot of code in the constructor of plugins; meaning that the plugin
|
to add a lot of code in the constructor of plugins; meaning that the plugin
|
||||||
|
|||||||
@@ -41,11 +41,19 @@ public class Prerequisite {
|
|||||||
"Requires server to have vault"
|
"Requires server to have vault"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requires the server to be running 1.19.
|
||||||
|
*/
|
||||||
|
public static final Prerequisite HAS_1_19 = new Prerequisite(
|
||||||
|
() -> ProxyConstants.NMS_VERSION.contains("19"),
|
||||||
|
"Requires server to be running 1.19+"
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires the server to be running 1.18.
|
* Requires the server to be running 1.18.
|
||||||
*/
|
*/
|
||||||
public static final Prerequisite HAS_1_18 = new Prerequisite(
|
public static final Prerequisite HAS_1_18 = new Prerequisite(
|
||||||
() -> ProxyConstants.NMS_VERSION.contains("18"),
|
() -> ProxyConstants.NMS_VERSION.contains("18") || HAS_1_19.isMet(),
|
||||||
"Requires server to be running 1.18+"
|
"Requires server to be running 1.18+"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ 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.math.evaluateExpression
|
import com.willfp.eco.internal.spigot.math.evaluateExpression
|
||||||
|
import com.willfp.eco.internal.spigot.player.PlayerHealthFixer
|
||||||
import com.willfp.eco.internal.spigot.proxy.FastItemStackFactoryProxy
|
import com.willfp.eco.internal.spigot.proxy.FastItemStackFactoryProxy
|
||||||
import com.willfp.eco.internal.spigot.proxy.SkullProxy
|
import com.willfp.eco.internal.spigot.proxy.SkullProxy
|
||||||
import com.willfp.eco.internal.spigot.proxy.TPSProxy
|
import com.willfp.eco.internal.spigot.proxy.TPSProxy
|
||||||
@@ -358,7 +359,8 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
|||||||
ArrowDataListener(this),
|
ArrowDataListener(this),
|
||||||
ArmorChangeEventListeners(this),
|
ArmorChangeEventListeners(this),
|
||||||
DataListener(this),
|
DataListener(this),
|
||||||
PlayerBlockListener(this)
|
PlayerBlockListener(this),
|
||||||
|
PlayerHealthFixer(this)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (Prerequisite.HAS_PAPER.isMet) {
|
if (Prerequisite.HAS_PAPER.isMet) {
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.willfp.eco.internal.spigot.player
|
||||||
|
|
||||||
|
import com.willfp.eco.core.EcoPlugin
|
||||||
|
import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||||
|
import com.willfp.eco.core.data.keys.PersistentDataKeyType
|
||||||
|
import com.willfp.eco.core.data.profile
|
||||||
|
import org.bukkit.event.EventHandler
|
||||||
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent
|
||||||
|
|
||||||
|
class PlayerHealthFixer(
|
||||||
|
private val plugin: EcoPlugin
|
||||||
|
): Listener {
|
||||||
|
private val lastHealthKey = PersistentDataKey(
|
||||||
|
plugin.namespacedKeyFactory.create("last_health"),
|
||||||
|
PersistentDataKeyType.DOUBLE,
|
||||||
|
0.0
|
||||||
|
)
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
fun onLeave(event: PlayerQuitEvent) {
|
||||||
|
if (!plugin.configYml.getBool("health-fixer")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val player = event.player
|
||||||
|
player.profile.write(lastHealthKey, player.health)
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
fun onJoin(event: PlayerJoinEvent) {
|
||||||
|
if (!plugin.configYml.getBool("health-fixer")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val player = event.player
|
||||||
|
plugin.scheduler.runLater(2) {
|
||||||
|
player.health = player.profile.read(lastHealthKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -76,4 +76,7 @@ log-full-extension-errors: false
|
|||||||
# disable this option. Bear in mind that this means the auto-craft preview will fail to
|
# disable this option. Bear in mind that this means the auto-craft preview will fail to
|
||||||
# render items nicely, which may degrade the user experience on your server. If you use
|
# render items nicely, which may degrade the user experience on your server. If you use
|
||||||
# a custom crafting table, though, this won't affect anything, and you should disable the option.
|
# a custom crafting table, though, this won't affect anything, and you should disable the option.
|
||||||
displayed-recipes: true
|
displayed-recipes: true
|
||||||
|
|
||||||
|
# Save health on leave and set it back on join - works around attribute modifiers.
|
||||||
|
health-fixer: false
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
version = 6.37.1
|
version = 6.37.2
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
Reference in New Issue
Block a user