Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
591800dba8 | ||
|
|
46673e8d24 | ||
|
|
a526f51780 | ||
|
|
dd14fc666a | ||
|
|
ae0150f012 | ||
|
|
04418fa038 | ||
|
|
bcb9523315 | ||
|
|
43e7972ca3 | ||
|
|
7ea61eb393 | ||
|
|
5245a9b1d8 | ||
|
|
195932463c | ||
|
|
3cf60a7e2c | ||
|
|
0f9f57fca2 | ||
|
|
fe21616dd5 | ||
|
|
396144abaa | ||
|
|
50b4fa59ab | ||
|
|
a6754379e8 | ||
|
|
bbd0182c2a | ||
|
|
0370e9f454 | ||
|
|
8d585b58cb | ||
|
|
0bfbd4c036 | ||
|
|
881839955e | ||
|
|
8ffc5f9c0f |
@@ -39,7 +39,7 @@ and many more.
|
|||||||
# For developers
|
# For developers
|
||||||
|
|
||||||
## Javadoc
|
## Javadoc
|
||||||
The 6.27.2 Javadoc can be found [here](https://javadoc.jitpack.io/com/willfp/eco/6.27.2/javadoc/)
|
The 6.38.2 Javadoc can be found [here](https://javadoc.jitpack.io/com/willfp/eco/6.38.2/javadoc/)
|
||||||
|
|
||||||
## Plugin Information
|
## Plugin Information
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ plugins {
|
|||||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
id("java")
|
id("java")
|
||||||
kotlin("jvm") version "1.6.21"
|
kotlin("jvm") version "1.7.10"
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -81,8 +81,8 @@ allprojects {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Kotlin
|
// Kotlin
|
||||||
implementation(kotlin("stdlib", version = "1.6.21"))
|
implementation(kotlin("stdlib", version = "1.7.10"))
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1")
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.2")
|
||||||
|
|
||||||
// Included in spigot jar, no need to move to implementation
|
// Included in spigot jar, no need to move to implementation
|
||||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||||
@@ -129,8 +129,6 @@ allprojects {
|
|||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "17"
|
jvmTarget = "17"
|
||||||
}
|
}
|
||||||
targetCompatibility = "17"
|
|
||||||
sourceCompatibility = "17"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
|
|||||||
@@ -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+"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,21 @@ public abstract class DisplayModule extends PluginDependent<EcoPlugin> {
|
|||||||
// Technically optional.
|
// Technically optional.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display an item.
|
||||||
|
*
|
||||||
|
* @param itemStack The item.
|
||||||
|
* @param player The player.
|
||||||
|
* @param properties The properties.
|
||||||
|
* @param args Optional args for display.
|
||||||
|
*/
|
||||||
|
public void display(@NotNull final ItemStack itemStack,
|
||||||
|
@Nullable final Player player,
|
||||||
|
@NotNull final DisplayProperties properties,
|
||||||
|
@NotNull final Object... args) {
|
||||||
|
// Technically optional.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Revert an item.
|
* Revert an item.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.willfp.eco.core.display;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extra properties passed into {@link DisplayModule}.
|
||||||
|
*
|
||||||
|
* @param inInventory If the item was in an inventory.
|
||||||
|
* @param inGui If the item is assumed to be in a gui. (Not perfectly accurate).
|
||||||
|
* @param originalItem The original item, not to be modified.
|
||||||
|
*/
|
||||||
|
public record DisplayProperties(
|
||||||
|
boolean inInventory,
|
||||||
|
boolean inGui,
|
||||||
|
@NotNull ItemStack originalItem
|
||||||
|
) {
|
||||||
|
}
|
||||||
@@ -68,6 +68,14 @@ public interface MenuBuilder {
|
|||||||
*/
|
*/
|
||||||
MenuBuilder onClose(@NotNull CloseHandler action);
|
MenuBuilder onClose(@NotNull CloseHandler action);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the menu open handler.
|
||||||
|
*
|
||||||
|
* @param action The handler.
|
||||||
|
* @return The builder.
|
||||||
|
*/
|
||||||
|
MenuBuilder onOpen(@NotNull OpenHandler action);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the action to run on render.
|
* Set the action to run on render.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.willfp.eco.core.gui.menu;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface to run on menu open.
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface OpenHandler {
|
||||||
|
/**
|
||||||
|
* Performs this operation on the given arguments.
|
||||||
|
*
|
||||||
|
* @param player The player.
|
||||||
|
* @param menu The menu.
|
||||||
|
*/
|
||||||
|
void handle(@NotNull Player player,
|
||||||
|
@NotNull Menu menu);
|
||||||
|
}
|
||||||
@@ -1,12 +1,24 @@
|
|||||||
package com.willfp.eco.util;
|
package com.willfp.eco.util;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.gui.menu.Menu;
|
||||||
import com.willfp.eco.core.tuples.Pair;
|
import com.willfp.eco.core.tuples.Pair;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities / API methods for menus.
|
* Utilities / API methods for menus.
|
||||||
*/
|
*/
|
||||||
public final class MenuUtils {
|
public final class MenuUtils {
|
||||||
|
/**
|
||||||
|
* The menu supplier.
|
||||||
|
*/
|
||||||
|
private static Function<Player, Menu> menuGetter = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert 0-53 slot to row and column pair.
|
* Convert 0-53 slot to row and column pair.
|
||||||
*
|
*
|
||||||
@@ -31,6 +43,29 @@ public final class MenuUtils {
|
|||||||
return (column - 1) + ((row - 1) * 9);
|
return (column - 1) + ((row - 1) * 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a player's open menu.
|
||||||
|
*
|
||||||
|
* @param player The player.
|
||||||
|
* @return The menu, or null if none open.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public static Menu getOpenMenu(@NotNull final Player player) {
|
||||||
|
return menuGetter.apply(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the tps supplier function.
|
||||||
|
*
|
||||||
|
* @param function The function.
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public static void initialize(@NotNull final Function<Player, Menu> function) {
|
||||||
|
Validate.isTrue(menuGetter == null, "Already initialized!");
|
||||||
|
|
||||||
|
menuGetter = function;
|
||||||
|
}
|
||||||
|
|
||||||
private MenuUtils() {
|
private MenuUtils() {
|
||||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,6 +152,20 @@ public final class VectorUtils {
|
|||||||
return vectors.toArray(new Vector[0]);
|
return vectors.toArray(new Vector[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get if a vector is a safe velocity.
|
||||||
|
*
|
||||||
|
* @param vec The vector to check.
|
||||||
|
* @return If safe.
|
||||||
|
*/
|
||||||
|
public static boolean isSafeVelocity(@NotNull final Vector vec) {
|
||||||
|
double x = Math.abs(vec.getX());
|
||||||
|
double y = Math.abs(vec.getY());
|
||||||
|
double z = Math.abs(vec.getZ());
|
||||||
|
|
||||||
|
return x < 4 && y < 4 && z < 4;
|
||||||
|
}
|
||||||
|
|
||||||
private VectorUtils() {
|
private VectorUtils() {
|
||||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,10 @@ fun slot(
|
|||||||
fun MenuBuilder.onClose(action: (InventoryCloseEvent, Menu) -> Unit): MenuBuilder =
|
fun MenuBuilder.onClose(action: (InventoryCloseEvent, Menu) -> Unit): MenuBuilder =
|
||||||
this.onClose { a, b -> action(a, b) }
|
this.onClose { a, b -> action(a, b) }
|
||||||
|
|
||||||
|
/** @see MenuBuilder.onOpen */
|
||||||
|
fun MenuBuilder.onOpen(action: (Player, Menu) -> Unit): MenuBuilder =
|
||||||
|
this.onOpen { a, b -> action(a, b) }
|
||||||
|
|
||||||
/** @see MenuBuilder.modify */
|
/** @see MenuBuilder.modify */
|
||||||
fun MenuBuilder.modify(modifier: (MenuBuilder) -> Unit): MenuBuilder =
|
fun MenuBuilder.modify(modifier: (MenuBuilder) -> Unit): MenuBuilder =
|
||||||
this.modfiy { modifier(it) }
|
this.modfiy { modifier(it) }
|
||||||
|
|||||||
10
eco-api/src/main/kotlin/com/willfp/eco/util/MenuUtils.kt
Normal file
10
eco-api/src/main/kotlin/com/willfp/eco/util/MenuUtils.kt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
@file:JvmName("MenuUtilsExtensions")
|
||||||
|
|
||||||
|
package com.willfp.eco.util
|
||||||
|
|
||||||
|
import com.willfp.eco.core.gui.menu.Menu
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
|
/** @see MenuUtils.getOpenMenu */
|
||||||
|
val Player.openMenu: Menu?
|
||||||
|
get() = MenuUtils.getOpenMenu(this)
|
||||||
@@ -11,3 +11,7 @@ val Vector.isFinite: Boolean
|
|||||||
/** @see VectorUtils.simplifyVector */
|
/** @see VectorUtils.simplifyVector */
|
||||||
fun Vector.simplify(): Vector =
|
fun Vector.simplify(): Vector =
|
||||||
VectorUtils.simplifyVector(this)
|
VectorUtils.simplifyVector(this)
|
||||||
|
|
||||||
|
/** @see VectorUtils.isSafeVelocity */
|
||||||
|
val Vector.isSafeVelocity: Boolean
|
||||||
|
get() = VectorUtils.isSafeVelocity(this)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.willfp.eco.core.EcoPlugin
|
|||||||
import com.willfp.eco.core.display.Display
|
import com.willfp.eco.core.display.Display
|
||||||
import com.willfp.eco.core.display.DisplayHandler
|
import com.willfp.eco.core.display.DisplayHandler
|
||||||
import com.willfp.eco.core.display.DisplayModule
|
import com.willfp.eco.core.display.DisplayModule
|
||||||
|
import com.willfp.eco.core.display.DisplayProperties
|
||||||
import com.willfp.eco.core.fast.fast
|
import com.willfp.eco.core.fast.fast
|
||||||
import org.bukkit.NamespacedKey
|
import org.bukkit.NamespacedKey
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
@@ -32,13 +33,21 @@ class EcoDisplayHandler(plugin: EcoPlugin) : DisplayHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Display.revert(itemStack)
|
Display.revert(itemStack)
|
||||||
|
|
||||||
if (!itemStack.hasItemMeta()) {
|
if (!itemStack.hasItemMeta()) {
|
||||||
return itemStack
|
return itemStack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val original = itemStack.clone()
|
||||||
|
val inventory = player?.openInventory?.topInventory
|
||||||
|
val inInventory = inventory?.contains(original) ?: false
|
||||||
|
|
||||||
|
val props = DisplayProperties(
|
||||||
|
inInventory,
|
||||||
|
inInventory && inventory?.holder == null,
|
||||||
|
original
|
||||||
|
)
|
||||||
|
|
||||||
for ((_, modules) in registeredModules) {
|
for ((_, modules) in registeredModules) {
|
||||||
for (module in modules) {
|
for (module in modules) {
|
||||||
@@ -48,6 +57,7 @@ class EcoDisplayHandler(plugin: EcoPlugin) : DisplayHandler {
|
|||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
module.display(itemStack, player as Player?, *varargs)
|
module.display(itemStack, player as Player?, *varargs)
|
||||||
|
module.display(itemStack, player as Player?, props, *varargs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.willfp.eco.internal.gui.menu
|
|||||||
|
|
||||||
import com.willfp.eco.core.gui.menu.CloseHandler
|
import com.willfp.eco.core.gui.menu.CloseHandler
|
||||||
import com.willfp.eco.core.gui.menu.Menu
|
import com.willfp.eco.core.gui.menu.Menu
|
||||||
|
import com.willfp.eco.core.gui.menu.OpenHandler
|
||||||
import com.willfp.eco.core.gui.slot.Slot
|
import com.willfp.eco.core.gui.slot.Slot
|
||||||
import com.willfp.eco.internal.gui.slot.EcoSlot
|
import com.willfp.eco.internal.gui.slot.EcoSlot
|
||||||
import com.willfp.eco.util.NamespacedKeyUtils
|
import com.willfp.eco.util.NamespacedKeyUtils
|
||||||
@@ -19,7 +20,8 @@ class EcoMenu(
|
|||||||
val slots: List<MutableList<EcoSlot>>,
|
val slots: List<MutableList<EcoSlot>>,
|
||||||
private val title: String,
|
private val title: String,
|
||||||
private val onClose: CloseHandler,
|
private val onClose: CloseHandler,
|
||||||
private val onRender: (Player, Menu) -> Unit
|
private val onRender: (Player, Menu) -> Unit,
|
||||||
|
private val onOpen: OpenHandler
|
||||||
) : Menu {
|
) : Menu {
|
||||||
override fun getSlot(row: Int, column: Int): Slot {
|
override fun getSlot(row: Int, column: Int): Slot {
|
||||||
if (row < 1 || row > this.rows) {
|
if (row < 1 || row > this.rows) {
|
||||||
@@ -49,6 +51,7 @@ class EcoMenu(
|
|||||||
|
|
||||||
player.openInventory(inventory)
|
player.openInventory(inventory)
|
||||||
MenuHandler.registerInventory(inventory, this, player)
|
MenuHandler.registerInventory(inventory, this, player)
|
||||||
|
onOpen.handle(player, this)
|
||||||
inventory.asRenderedInventory()?.generateCaptive()
|
inventory.asRenderedInventory()?.generateCaptive()
|
||||||
return inventory
|
return inventory
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.willfp.eco.internal.gui.menu
|
|||||||
import com.willfp.eco.core.gui.menu.CloseHandler
|
import com.willfp.eco.core.gui.menu.CloseHandler
|
||||||
import com.willfp.eco.core.gui.menu.Menu
|
import com.willfp.eco.core.gui.menu.Menu
|
||||||
import com.willfp.eco.core.gui.menu.MenuBuilder
|
import com.willfp.eco.core.gui.menu.MenuBuilder
|
||||||
|
import com.willfp.eco.core.gui.menu.OpenHandler
|
||||||
import com.willfp.eco.core.gui.slot.FillerMask
|
import com.willfp.eco.core.gui.slot.FillerMask
|
||||||
import com.willfp.eco.core.gui.slot.FillerSlot
|
import com.willfp.eco.core.gui.slot.FillerSlot
|
||||||
import com.willfp.eco.core.gui.slot.Slot
|
import com.willfp.eco.core.gui.slot.Slot
|
||||||
@@ -21,6 +22,7 @@ class EcoMenuBuilder(private val rows: Int ) : MenuBuilder {
|
|||||||
private var maskSlots: List<MutableList<Slot?>>
|
private var maskSlots: List<MutableList<Slot?>>
|
||||||
private val slots: List<MutableList<Slot?>> = ListUtils.create2DList(rows, 9)
|
private val slots: List<MutableList<Slot?>> = ListUtils.create2DList(rows, 9)
|
||||||
private var onClose = CloseHandler { _, _ -> }
|
private var onClose = CloseHandler { _, _ -> }
|
||||||
|
private var onOpen = OpenHandler { _, _ -> }
|
||||||
private var onRender: (Player, Menu) -> Unit = { _, _ -> }
|
private var onRender: (Player, Menu) -> Unit = { _, _ -> }
|
||||||
|
|
||||||
override fun setTitle(title: String): MenuBuilder {
|
override fun setTitle(title: String): MenuBuilder {
|
||||||
@@ -54,6 +56,11 @@ class EcoMenuBuilder(private val rows: Int ) : MenuBuilder {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onOpen(action: OpenHandler): MenuBuilder {
|
||||||
|
onOpen = action
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
override fun onRender(action: BiConsumer<Player, Menu>): MenuBuilder {
|
override fun onRender(action: BiConsumer<Player, Menu>): MenuBuilder {
|
||||||
onRender = { a, b -> action.accept(a, b) }
|
onRender = { a, b -> action.accept(a, b) }
|
||||||
return this
|
return this
|
||||||
@@ -83,7 +90,7 @@ class EcoMenuBuilder(private val rows: Int ) : MenuBuilder {
|
|||||||
finalSlots.add(tempRow)
|
finalSlots.add(tempRow)
|
||||||
}
|
}
|
||||||
|
|
||||||
return EcoMenu(rows, finalSlots, title, onClose, onRender)
|
return EcoMenu(rows, finalSlots, title, onClose, onRender, onOpen)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ open class EcoSlot(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemStack(player: Player): ItemStack {
|
override fun getItemStack(player: Player): ItemStack {
|
||||||
val menu = player.openInventory.topInventory.getMenu()!!
|
val menu = player.openInventory.topInventory.getMenu() ?: return ItemStack(Material.AIR)
|
||||||
val prev = provider.provide(player, menu)
|
val prev = provider.provide(player, menu)
|
||||||
return updater.update(player, menu, prev) ?: ItemStack(Material.AIR)
|
return updater.update(player, menu, prev) ?: ItemStack(Material.AIR)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,11 @@ class SNBTConverter : SNBTConverterProxy {
|
|||||||
|
|
||||||
nbt.remove("Count")
|
nbt.remove("Count")
|
||||||
|
|
||||||
return SNBTTestableItem(nbt)
|
return SNBTTestableItem(CraftItemStack.asBukkitCopy(nms), nbt)
|
||||||
}
|
}
|
||||||
|
|
||||||
class SNBTTestableItem(
|
class SNBTTestableItem(
|
||||||
|
private val item: ItemStack,
|
||||||
private val tag: CompoundTag
|
private val tag: CompoundTag
|
||||||
) : TestableItem {
|
) : TestableItem {
|
||||||
override fun matches(itemStack: ItemStack?): Boolean {
|
override fun matches(itemStack: ItemStack?): Boolean {
|
||||||
@@ -47,8 +48,6 @@ class SNBTConverter : SNBTConverterProxy {
|
|||||||
return tag.copy().merge(nmsTag) == nmsTag
|
return tag.copy().merge(nmsTag) == nmsTag
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItem(): ItemStack {
|
override fun getItem(): ItemStack = item
|
||||||
return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.of(tag))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,10 +30,11 @@ class SNBTConverter : SNBTConverterProxy {
|
|||||||
|
|
||||||
nbt.remove("Count")
|
nbt.remove("Count")
|
||||||
|
|
||||||
return SNBTTestableItem(nbt)
|
return SNBTTestableItem(CraftItemStack.asBukkitCopy(nms), nbt)
|
||||||
}
|
}
|
||||||
|
|
||||||
class SNBTTestableItem(
|
class SNBTTestableItem(
|
||||||
|
private val item: ItemStack,
|
||||||
private val tag: CompoundTag
|
private val tag: CompoundTag
|
||||||
) : TestableItem {
|
) : TestableItem {
|
||||||
override fun matches(itemStack: ItemStack?): Boolean {
|
override fun matches(itemStack: ItemStack?): Boolean {
|
||||||
@@ -47,8 +48,6 @@ class SNBTConverter : SNBTConverterProxy {
|
|||||||
return tag.copy().merge(nmsTag) == nmsTag
|
return tag.copy().merge(nmsTag) == nmsTag
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItem(): ItemStack {
|
override fun getItem(): ItemStack = item
|
||||||
return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.of(tag))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,10 +30,11 @@ class SNBTConverter : SNBTConverterProxy {
|
|||||||
|
|
||||||
nbt.remove("Count")
|
nbt.remove("Count")
|
||||||
|
|
||||||
return SNBTTestableItem(nbt)
|
return SNBTTestableItem(CraftItemStack.asBukkitCopy(nms), nbt)
|
||||||
}
|
}
|
||||||
|
|
||||||
class SNBTTestableItem(
|
class SNBTTestableItem(
|
||||||
|
private val item: ItemStack,
|
||||||
private val tag: CompoundTag
|
private val tag: CompoundTag
|
||||||
) : TestableItem {
|
) : TestableItem {
|
||||||
override fun matches(itemStack: ItemStack?): Boolean {
|
override fun matches(itemStack: ItemStack?): Boolean {
|
||||||
@@ -47,8 +48,6 @@ class SNBTConverter : SNBTConverterProxy {
|
|||||||
return tag.copy().merge(nmsTag) == nmsTag
|
return tag.copy().merge(nmsTag) == nmsTag
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItem(): ItemStack {
|
override fun getItem(): ItemStack = item
|
||||||
return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.of(tag))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,11 +29,11 @@ class SNBTConverter : SNBTConverterProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nbt.remove("Count")
|
nbt.remove("Count")
|
||||||
|
return SNBTTestableItem(CraftItemStack.asBukkitCopy(nms), nbt)
|
||||||
return SNBTTestableItem(nbt)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class SNBTTestableItem(
|
class SNBTTestableItem(
|
||||||
|
private val item: ItemStack,
|
||||||
private val tag: CompoundTag
|
private val tag: CompoundTag
|
||||||
) : TestableItem {
|
) : TestableItem {
|
||||||
override fun matches(itemStack: ItemStack?): Boolean {
|
override fun matches(itemStack: ItemStack?): Boolean {
|
||||||
@@ -47,8 +47,6 @@ class SNBTConverter : SNBTConverterProxy {
|
|||||||
return tag.copy().merge(nmsTag) == nmsTag
|
return tag.copy().merge(nmsTag) == nmsTag
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItem(): ItemStack {
|
override fun getItem(): ItemStack = item
|
||||||
return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.of(tag))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ dependencies {
|
|||||||
compileOnly 'io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT'
|
compileOnly 'io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT'
|
||||||
|
|
||||||
// Plugin dependencies
|
// Plugin dependencies
|
||||||
compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.1-SNAPSHOT'
|
compileOnly 'com.comphenix.protocol:ProtocolLib:5.0.0-SNAPSHOT'
|
||||||
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.7-SNAPSHOT'
|
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.7-SNAPSHOT'
|
||||||
compileOnly 'com.github.TechFortress:GriefPrevention:16.17.1'
|
compileOnly 'com.github.TechFortress:GriefPrevention:16.17.1'
|
||||||
compileOnly 'com.massivecraft:Factions:1.6.9.5-U0.5.10'
|
compileOnly 'com.massivecraft:Factions:1.6.9.5-U0.5.10'
|
||||||
@@ -36,7 +36,7 @@ dependencies {
|
|||||||
compileOnly 'com.gmail.nossr50.mcMMO:mcMMO:2.1.202'
|
compileOnly 'com.gmail.nossr50.mcMMO:mcMMO:2.1.202'
|
||||||
compileOnly 'me.clip:placeholderapi:2.10.10'
|
compileOnly 'me.clip:placeholderapi:2.10.10'
|
||||||
compileOnly 'com.github.oraxen:oraxen:bd81ace154'
|
compileOnly 'com.github.oraxen:oraxen:bd81ace154'
|
||||||
compileOnly 'com.github.brcdev-minecraft:shopgui-api:2.2.0'
|
compileOnly 'com.github.brcdev-minecraft:shopgui-api:3.0.0'
|
||||||
compileOnly 'com.github.LoneDev6:API-ItemsAdder:2.4.7'
|
compileOnly 'com.github.LoneDev6:API-ItemsAdder:2.4.7'
|
||||||
compileOnly 'com.arcaniax:HeadDatabase-API:1.3.0'
|
compileOnly 'com.arcaniax:HeadDatabase-API:1.3.0'
|
||||||
compileOnly 'com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0'
|
compileOnly 'com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0'
|
||||||
|
|||||||
@@ -16,7 +16,11 @@ object ConflictFinder {
|
|||||||
continue
|
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) {
|
if (conflict != null) {
|
||||||
conflicts.add(conflict)
|
conflicts.add(conflict)
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import com.willfp.eco.internal.entities.EntityArgParserSilent
|
|||||||
import com.willfp.eco.internal.entities.EntityArgParserSize
|
import com.willfp.eco.internal.entities.EntityArgParserSize
|
||||||
import com.willfp.eco.internal.entities.EntityArgParserSpawnReinforcements
|
import com.willfp.eco.internal.entities.EntityArgParserSpawnReinforcements
|
||||||
import com.willfp.eco.internal.entities.EntityArgParserSpeed
|
import com.willfp.eco.internal.entities.EntityArgParserSpeed
|
||||||
|
import com.willfp.eco.internal.gui.menu.getMenu
|
||||||
import com.willfp.eco.internal.items.ArgParserColor
|
import com.willfp.eco.internal.items.ArgParserColor
|
||||||
import com.willfp.eco.internal.items.ArgParserCustomModelData
|
import com.willfp.eco.internal.items.ArgParserCustomModelData
|
||||||
import com.willfp.eco.internal.items.ArgParserEnchantment
|
import com.willfp.eco.internal.items.ArgParserEnchantment
|
||||||
@@ -111,6 +112,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
|
||||||
@@ -120,6 +122,7 @@ import com.willfp.eco.internal.spigot.recipes.listeners.ComplexInComplex
|
|||||||
import com.willfp.eco.internal.spigot.recipes.listeners.ComplexInVanilla
|
import com.willfp.eco.internal.spigot.recipes.listeners.ComplexInVanilla
|
||||||
import com.willfp.eco.internal.spigot.recipes.stackhandlers.ShapedCraftingRecipeStackHandler
|
import com.willfp.eco.internal.spigot.recipes.stackhandlers.ShapedCraftingRecipeStackHandler
|
||||||
import com.willfp.eco.internal.spigot.recipes.stackhandlers.ShapelessCraftingRecipeStackHandler
|
import com.willfp.eco.internal.spigot.recipes.stackhandlers.ShapelessCraftingRecipeStackHandler
|
||||||
|
import com.willfp.eco.util.MenuUtils
|
||||||
import com.willfp.eco.util.NumberUtils
|
import com.willfp.eco.util.NumberUtils
|
||||||
import com.willfp.eco.util.ServerUtils
|
import com.willfp.eco.util.ServerUtils
|
||||||
import com.willfp.eco.util.SkullUtils
|
import com.willfp.eco.util.SkullUtils
|
||||||
@@ -182,6 +185,8 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
|||||||
|
|
||||||
NumberUtils.initCrunch { expression, player, context -> evaluateExpression(expression, player, context) }
|
NumberUtils.initCrunch { expression, player, context -> evaluateExpression(expression, player, context) }
|
||||||
|
|
||||||
|
MenuUtils.initialize { it.openInventory.topInventory.getMenu() }
|
||||||
|
|
||||||
CustomItemsManager.registerProviders()
|
CustomItemsManager.registerProviders()
|
||||||
|
|
||||||
postInit()
|
postInit()
|
||||||
@@ -358,7 +363,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) {
|
||||||
|
|||||||
@@ -17,11 +17,13 @@ class PacketSetSlot(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, PacketTyp
|
|||||||
player: Player,
|
player: Player,
|
||||||
event: PacketEvent
|
event: PacketEvent
|
||||||
) {
|
) {
|
||||||
packet.itemModifier.modify(0) { item: ItemStack? ->
|
packet.itemModifier.modify(0, object : VersionCompatiblePLibFunction<ItemStack> {
|
||||||
Display.display(
|
override fun apply(item: ItemStack) =
|
||||||
item!!, player
|
Display.display(
|
||||||
)
|
item,
|
||||||
}
|
player
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
player.lastDisplayFrame = DisplayFrame.EMPTY
|
player.lastDisplayFrame = DisplayFrame.EMPTY
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.willfp.eco.internal.spigot.display
|
||||||
|
|
||||||
|
import com.google.common.base.Function
|
||||||
|
import java.util.function.UnaryOperator
|
||||||
|
|
||||||
|
interface VersionCompatiblePLibFunction<T> : Function<T, T>, UnaryOperator<T> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import org.bukkit.event.EventPriority
|
|||||||
import org.bukkit.event.Listener
|
import org.bukkit.event.Listener
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent
|
import org.bukkit.event.inventory.InventoryClickEvent
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent
|
import org.bukkit.event.inventory.InventoryCloseEvent
|
||||||
|
import org.bukkit.event.player.PlayerItemHeldEvent
|
||||||
|
|
||||||
class GUIListener(private val plugin: EcoPlugin) : Listener {
|
class GUIListener(private val plugin: EcoPlugin) : Listener {
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
@@ -45,7 +46,6 @@ class GUIListener(private val plugin: EcoPlugin) : Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val menu = inv.getMenu() ?: return
|
val menu = inv.getMenu() ?: return
|
||||||
val rendered = inv.asRenderedInventory() ?: return
|
|
||||||
|
|
||||||
val (row, column) = MenuUtils.convertSlotToRowColumn(inv.firstEmpty())
|
val (row, column) = MenuUtils.convertSlotToRowColumn(inv.firstEmpty())
|
||||||
|
|
||||||
@@ -54,8 +54,6 @@ class GUIListener(private val plugin: EcoPlugin) : Listener {
|
|||||||
if (!slot.isCaptive) {
|
if (!slot.isCaptive) {
|
||||||
event.isCancelled = true
|
event.isCancelled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.scheduler.run { rendered.render() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
@@ -66,4 +64,25 @@ class GUIListener(private val plugin: EcoPlugin) : Listener {
|
|||||||
|
|
||||||
plugin.scheduler.run { MenuHandler.unregisterInventory(event.inventory) }
|
plugin.scheduler.run { MenuHandler.unregisterInventory(event.inventory) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
fun forceRender(event: InventoryClickEvent) {
|
||||||
|
val player = event.whoClicked as? Player ?: return
|
||||||
|
player.renderActiveMenu()
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
fun forceRender(event: PlayerItemHeldEvent) {
|
||||||
|
val player = event.player
|
||||||
|
player.renderActiveMenu()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Player.renderActiveMenu() {
|
||||||
|
val inv = this.openInventory.topInventory
|
||||||
|
|
||||||
|
val rendered = inv.asRenderedInventory() ?: return
|
||||||
|
|
||||||
|
rendered.render()
|
||||||
|
plugin.scheduler.run { rendered.render() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ import com.willfp.eco.core.EcoPlugin
|
|||||||
import com.willfp.eco.core.integrations.customitems.CustomItemsIntegration
|
import com.willfp.eco.core.integrations.customitems.CustomItemsIntegration
|
||||||
import com.willfp.eco.core.items.Items
|
import com.willfp.eco.core.items.Items
|
||||||
import com.willfp.eco.core.recipe.parts.EmptyTestableItem
|
import com.willfp.eco.core.recipe.parts.EmptyTestableItem
|
||||||
|
import io.lumine.mythic.api.adapters.AbstractItemStack
|
||||||
import io.lumine.mythic.api.config.MythicLineConfig
|
import io.lumine.mythic.api.config.MythicLineConfig
|
||||||
import io.lumine.mythic.api.drops.DropMetadata
|
import io.lumine.mythic.api.drops.DropMetadata
|
||||||
import io.lumine.mythic.api.drops.IMultiDrop
|
import io.lumine.mythic.api.drops.IItemDrop
|
||||||
import io.lumine.mythic.bukkit.adapters.BukkitItemStack
|
import io.lumine.mythic.bukkit.adapters.BukkitItemStack
|
||||||
import io.lumine.mythic.bukkit.events.MythicDropLoadEvent
|
import io.lumine.mythic.bukkit.events.MythicDropLoadEvent
|
||||||
import io.lumine.mythic.core.drops.Drop
|
import org.bukkit.Material
|
||||||
import io.lumine.mythic.core.drops.LootBag
|
|
||||||
import io.lumine.mythic.core.drops.droppables.ItemDrop
|
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
import org.bukkit.event.Listener
|
import org.bukkit.event.Listener
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
|
||||||
class CustomItemsMythicMobs(
|
class CustomItemsMythicMobs(
|
||||||
private val plugin: EcoPlugin
|
private val plugin: EcoPlugin
|
||||||
@@ -39,19 +39,16 @@ class CustomItemsMythicMobs(
|
|||||||
private class MythicMobsDrop(
|
private class MythicMobsDrop(
|
||||||
private val plugin: EcoPlugin,
|
private val plugin: EcoPlugin,
|
||||||
itemConfig: MythicLineConfig
|
itemConfig: MythicLineConfig
|
||||||
) : Drop(itemConfig.line, itemConfig), IMultiDrop {
|
) : IItemDrop {
|
||||||
private val id = itemConfig.getString(arrayOf("type", "t", "item", "i"), this.dropVar)
|
private val id = itemConfig.getString(arrayOf("type", "t", "item", "i"), "eco")
|
||||||
|
|
||||||
override fun get(data: DropMetadata): LootBag {
|
|
||||||
val bag = LootBag(data)
|
|
||||||
|
|
||||||
|
override fun getDrop(data: DropMetadata, v: Double): AbstractItemStack {
|
||||||
val item = Items.lookup(id)
|
val item = Items.lookup(id)
|
||||||
if (item is EmptyTestableItem) {
|
if (item is EmptyTestableItem) {
|
||||||
plugin.logger.warning("Item with ID $id is invalid, check your configs!")
|
plugin.logger.warning("Item with ID $id is invalid, check your configs!")
|
||||||
return bag
|
return BukkitItemStack(ItemStack(Material.AIR))
|
||||||
}
|
}
|
||||||
bag.add(data, ItemDrop(this.line, this.config, BukkitItemStack(item.item)))
|
return BukkitItemStack(item.item.apply { amount = v.toInt() })
|
||||||
return bag
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.38.3
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
269
gradlew
vendored
269
gradlew
vendored
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2015 the original author or authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -17,67 +17,101 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
#
|
||||||
## Gradle start up script for UN*X
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
##
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
PRG="$0"
|
app_path=$0
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
# Need this for daisy-chained symlinks.
|
||||||
ls=`ls -ld "$PRG"`
|
while
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
[ -h "$app_path" ]
|
||||||
PRG="$link"
|
do
|
||||||
else
|
ls=$( ls -ld "$app_path" )
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
link=${ls#*' -> '}
|
||||||
fi
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=${0##*/}
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD="java"
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
@@ -106,80 +140,95 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
warn "Could not query maximum file descriptor limit"
|
||||||
fi
|
esac
|
||||||
ulimit -n $MAX_FD
|
case $MAX_FD in #(
|
||||||
if [ $? -ne 0 ] ; then
|
'' | soft) :;; #(
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
*)
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
else
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=`expr $i + 1`
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
0) set -- ;;
|
|
||||||
1) set -- "$args0" ;;
|
|
||||||
2) set -- "$args0" "$args1" ;;
|
|
||||||
3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
save () {
|
# * args from the command line
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
# * the main class name
|
||||||
echo " "
|
# * -classpath
|
||||||
}
|
# * -D...appname settings
|
||||||
APP_ARGS=`save "$@"`
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
# double quotes to make sure that they get re-expanded; and
|
||||||
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user