Compare commits

..

6 Commits

Author SHA1 Message Date
Auxilor
a6754379e8 Updated to 6.37.3 2022-07-07 22:55:03 +01:00
Auxilor
bbd0182c2a Fixed weird bug 2022-07-07 22:54:54 +01:00
Auxilor
0370e9f454 Fixed startup order 2022-07-03 16:49:26 +01:00
Auxilor
8d585b58cb Fixed initializing text 2022-07-03 16:45:44 +01:00
Auxilor
0bfbd4c036 Updated to 6.37.2 2022-07-03 16:38:32 +01:00
Auxilor
881839955e Added player health fixer 2022-07-03 16:38:21 +01:00
7 changed files with 69 additions and 9 deletions

View File

@@ -304,6 +304,11 @@ public abstract class EcoPlugin extends JavaPlugin implements PluginLike {
this.color = props.getColor();
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.eventManager = Eco.getHandler().createEventManager(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.extensionLoader = Eco.getHandler().createExtensionLoader(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.configYml = this.createConfigYml();
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
to add a lot of code in the constructor of plugins; meaning that the plugin

View File

@@ -41,11 +41,19 @@ public class Prerequisite {
"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.
*/
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+"
);

View File

@@ -16,7 +16,11 @@ object ConflictFinder {
continue
}
val conflict = plugin.getConflict()
val conflict = try {
plugin.getConflict()
} catch (e: Exception) {
continue
} // Really can't be fucked to do this properly.
if (conflict != null) {
conflicts.add(conflict)

View File

@@ -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.ShopZShop
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.SkullProxy
import com.willfp.eco.internal.spigot.proxy.TPSProxy
@@ -358,7 +359,8 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
ArrowDataListener(this),
ArmorChangeEventListeners(this),
DataListener(this),
PlayerBlockListener(this)
PlayerBlockListener(this),
PlayerHealthFixer(this)
)
if (Prerequisite.HAS_PAPER.isMet) {

View File

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

View File

@@ -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
# 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.
displayed-recipes: true
displayed-recipes: true
# Save health on leave and set it back on join - works around attribute modifiers.
health-fixer: false

View File

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