Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28b268e175 | ||
|
|
33937d1ce7 | ||
|
|
e971778cc3 | ||
|
|
f99612ded3 | ||
|
|
50272bbbcf | ||
|
|
9a703f6190 | ||
|
|
f8fec7eec4 | ||
|
|
f6aadda4ed | ||
|
|
d8fca0f348 | ||
|
|
65ff4c4a31 | ||
|
|
90702bc7aa | ||
|
|
e81b788a1b | ||
|
|
ebc0ee7940 | ||
|
|
82d269daf1 | ||
|
|
9d5300d6ae | ||
|
|
8870e4d6fb | ||
|
|
d826a9f71f | ||
|
|
7ec3355237 | ||
|
|
e59a8cc2e6 | ||
|
|
88f974fd10 | ||
|
|
dfe2f1361b | ||
|
|
3826f9f713 | ||
|
|
c2d2303c91 | ||
|
|
b1158ceb3d |
@@ -77,9 +77,6 @@ allprojects {
|
|||||||
|
|
||||||
// LibsDisguises
|
// LibsDisguises
|
||||||
maven("https://repo.md-5.net/content/groups/public/")
|
maven("https://repo.md-5.net/content/groups/public/")
|
||||||
|
|
||||||
// FabledSkyblock
|
|
||||||
maven("https://repo.songoda.com/repository/public/")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.willfp.eco.core.gui.component;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.gui.slot.Slot;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A GUI Component is a 2-dimensional set of slots that can be
|
||||||
|
* placed in a menu.
|
||||||
|
*/
|
||||||
|
public interface GUIComponent {
|
||||||
|
/**
|
||||||
|
* Get the amount of rows in the component.
|
||||||
|
*
|
||||||
|
* @return The rows.
|
||||||
|
*/
|
||||||
|
int getRows();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amount of columns in the component.
|
||||||
|
*
|
||||||
|
* @return The columns.
|
||||||
|
*/
|
||||||
|
int getColumns();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the slot at a certain position in the component.
|
||||||
|
*
|
||||||
|
* @param row The row (1-indexed).
|
||||||
|
* @param column The column (1-indexed).
|
||||||
|
* @return The slot, or null if no slot at the location.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
Slot getSlotAt(final int row,
|
||||||
|
final int column);
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.willfp.eco.core.gui.menu;
|
package com.willfp.eco.core.gui.menu;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.gui.component.GUIComponent;
|
||||||
import com.willfp.eco.core.gui.slot.FillerMask;
|
import com.willfp.eco.core.gui.slot.FillerMask;
|
||||||
import com.willfp.eco.core.gui.slot.Slot;
|
import com.willfp.eco.core.gui.slot.Slot;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -13,6 +15,13 @@ import java.util.function.Consumer;
|
|||||||
* Builder to create menus.
|
* Builder to create menus.
|
||||||
*/
|
*/
|
||||||
public interface MenuBuilder {
|
public interface MenuBuilder {
|
||||||
|
/**
|
||||||
|
* Get the amount of rows.
|
||||||
|
*
|
||||||
|
* @return The amount of rows.
|
||||||
|
*/
|
||||||
|
int getRows();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the menu title.
|
* Set the menu title.
|
||||||
*
|
*
|
||||||
@@ -33,6 +42,32 @@ public interface MenuBuilder {
|
|||||||
int column,
|
int column,
|
||||||
@NotNull Slot slot);
|
@NotNull Slot slot);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a component.
|
||||||
|
*
|
||||||
|
* @param row The row of the top left corner.
|
||||||
|
* @param column The column of the top left corner.
|
||||||
|
* @param component The component.
|
||||||
|
* @return The builder.
|
||||||
|
*/
|
||||||
|
default MenuBuilder addComponent(final int row,
|
||||||
|
final int column,
|
||||||
|
@NotNull GUIComponent component) {
|
||||||
|
Validate.isTrue(column + component.getColumns() - 1 <= 9, "Component is too large to be placed here!");
|
||||||
|
Validate.isTrue(row + component.getRows() - 1 <= this.getRows(), "Component is too large to be placed here!");
|
||||||
|
|
||||||
|
for (int currentRow = row; currentRow < row + component.getRows(); currentRow++) {
|
||||||
|
for (int currentCol = column; currentCol < column + component.getColumns(); currentCol++) {
|
||||||
|
Slot slot = component.getSlotAt(currentRow, currentCol);
|
||||||
|
if (slot != null) {
|
||||||
|
setSlot(currentRow, currentCol, slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run function to modify the builder.
|
* Run function to modify the builder.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package com.willfp.eco.core.gui.slot;
|
||||||
|
|
||||||
|
import com.willfp.eco.core.config.interfaces.Config;
|
||||||
|
import com.willfp.eco.core.gui.slot.functional.SlotHandler;
|
||||||
|
import com.willfp.eco.core.items.Items;
|
||||||
|
import com.willfp.eco.util.StringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A slot loaded in from config.
|
||||||
|
*/
|
||||||
|
public class ConfigSlot extends CustomSlot {
|
||||||
|
/**
|
||||||
|
* The config of the slot.
|
||||||
|
*/
|
||||||
|
private final Config config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cached handlers, for performance.
|
||||||
|
*/
|
||||||
|
private final Map<String, List<CommandToDispatch>> handlers = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new config slot.
|
||||||
|
*
|
||||||
|
* @param config The config.
|
||||||
|
*/
|
||||||
|
public ConfigSlot(@NotNull final Config config) {
|
||||||
|
this.config = config;
|
||||||
|
|
||||||
|
init(
|
||||||
|
Slot.builder(Items.lookup(config.getString("item")))
|
||||||
|
.onLeftClick(dispatchCommandHandler("left-click"))
|
||||||
|
.onRightClick(dispatchCommandHandler("right-click"))
|
||||||
|
.onShiftLeftClick(dispatchCommandHandler("shift-left-click"))
|
||||||
|
.onShiftRightClick(dispatchCommandHandler("shift-right-click"))
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a slot handler for dispatching commands.
|
||||||
|
*
|
||||||
|
* @param configKey The config key.
|
||||||
|
* @return The handler.
|
||||||
|
*/
|
||||||
|
private SlotHandler dispatchCommandHandler(@NotNull final String configKey) {
|
||||||
|
if (!handlers.containsKey(configKey)) {
|
||||||
|
List<CommandToDispatch> commands = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String command : config.getStrings(configKey)) {
|
||||||
|
if (command.startsWith("console:")) {
|
||||||
|
commands.add(new CommandToDispatch(
|
||||||
|
StringUtils.removePrefix("console:", command),
|
||||||
|
true
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
commands.add(new CommandToDispatch(
|
||||||
|
command,
|
||||||
|
false
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handlers.put(configKey, commands);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<CommandToDispatch> toDispatch = handlers.get(configKey);
|
||||||
|
|
||||||
|
return (event, slot, menu) -> {
|
||||||
|
Player player = (Player) event.getWhoClicked();
|
||||||
|
|
||||||
|
for (CommandToDispatch dispatch : toDispatch) {
|
||||||
|
dispatch.dispatch(player);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signifies a command to dispatch.
|
||||||
|
*
|
||||||
|
* @param command The command.
|
||||||
|
* @param console If the command should be run as console.
|
||||||
|
*/
|
||||||
|
private record CommandToDispatch(
|
||||||
|
@NotNull String command,
|
||||||
|
boolean console
|
||||||
|
) {
|
||||||
|
/**
|
||||||
|
* Dispatch command.
|
||||||
|
*
|
||||||
|
* @param player The player.
|
||||||
|
*/
|
||||||
|
void dispatch(@NotNull final Player player) {
|
||||||
|
if (console()) {
|
||||||
|
Bukkit.dispatchCommand(
|
||||||
|
Bukkit.getConsoleSender(),
|
||||||
|
command().replace("%player%", player.getName())
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Bukkit.dispatchCommand(
|
||||||
|
player,
|
||||||
|
command().replace("%player%", player.getName())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package com.willfp.eco.core.gui.slot;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for custom slot implementations.
|
||||||
|
*/
|
||||||
|
public abstract class CustomSlot implements Slot {
|
||||||
|
/**
|
||||||
|
* The internal slot to delegate to.
|
||||||
|
*/
|
||||||
|
private Slot delegate = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new custom slot.
|
||||||
|
*/
|
||||||
|
protected CustomSlot() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the slot with the delegate.
|
||||||
|
*
|
||||||
|
* @param slot The slot to delegate to.
|
||||||
|
*/
|
||||||
|
protected void init(@NotNull final Slot slot) {
|
||||||
|
if (delegate == null) {
|
||||||
|
throw new IllegalStateException("Custom Slot was not initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.delegate = slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the delegate slot.
|
||||||
|
* <p>
|
||||||
|
* This is not required to add the slot to a menu, but is instead used internally.
|
||||||
|
*
|
||||||
|
* @return The slot.
|
||||||
|
*/
|
||||||
|
public Slot getDelegate() {
|
||||||
|
return this.delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getItemStack(@NotNull final Player player) {
|
||||||
|
if (delegate == null) {
|
||||||
|
throw new IllegalStateException("Custom Slot was not initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return delegate.getItemStack(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCaptive() {
|
||||||
|
if (delegate == null) {
|
||||||
|
throw new IllegalStateException("Custom Slot was not initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return delegate.isCaptive();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNotCaptiveFor(@NotNull final Player player) {
|
||||||
|
if (delegate == null) {
|
||||||
|
throw new IllegalStateException("Custom Slot was not initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return delegate.isNotCaptiveFor(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCaptiveFromEmpty() {
|
||||||
|
if (delegate == null) {
|
||||||
|
throw new IllegalStateException("Custom Slot was not initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return delegate.isCaptiveFromEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final int getRows() {
|
||||||
|
return Slot.super.getRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final int getColumns() {
|
||||||
|
return Slot.super.getColumns();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final Slot getSlotAt(int row, int column) {
|
||||||
|
return Slot.super.getSlotAt(row, column);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.willfp.eco.core.gui.slot;
|
package com.willfp.eco.core.gui.slot;
|
||||||
|
|
||||||
import com.willfp.eco.core.Eco;
|
import com.willfp.eco.core.Eco;
|
||||||
|
import com.willfp.eco.core.gui.component.GUIComponent;
|
||||||
import com.willfp.eco.core.gui.slot.functional.SlotProvider;
|
import com.willfp.eco.core.gui.slot.functional.SlotProvider;
|
||||||
|
import com.willfp.eco.core.items.TestableItem;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -11,8 +13,11 @@ import java.util.function.Function;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A slot is an item in a GUI that can handle clicks.
|
* A slot is an item in a GUI that can handle clicks.
|
||||||
|
* <p>
|
||||||
|
* Don't create custom Slot implementations directly from this class,
|
||||||
|
* rather extend {@link CustomSlot}.
|
||||||
*/
|
*/
|
||||||
public interface Slot {
|
public interface Slot extends GUIComponent {
|
||||||
/**
|
/**
|
||||||
* Get the ItemStack that would be shown to a player.
|
* Get the ItemStack that would be shown to a player.
|
||||||
*
|
*
|
||||||
@@ -48,6 +53,22 @@ public interface Slot {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default int getRows() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default int getColumns() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default Slot getSlotAt(final int row,
|
||||||
|
final int column) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a builder for an ItemStack.
|
* Create a builder for an ItemStack.
|
||||||
*
|
*
|
||||||
@@ -67,6 +88,16 @@ public interface Slot {
|
|||||||
return Eco.getHandler().getGUIFactory().createSlotBuilder((player, menu) -> itemStack);
|
return Eco.getHandler().getGUIFactory().createSlotBuilder((player, menu) -> itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a builder for a TestableItem.
|
||||||
|
*
|
||||||
|
* @param item The item.
|
||||||
|
* @return The builder.
|
||||||
|
*/
|
||||||
|
static SlotBuilder builder(@NotNull final TestableItem item) {
|
||||||
|
return Eco.getHandler().getGUIFactory().createSlotBuilder((player, menu) -> item.getItem());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a builder for a player-specific ItemStack.
|
* Create a builder for a player-specific ItemStack.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.willfp.eco.core.integrations.Integration;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper class for economy integrations.
|
* Wrapper class for economy integrations.
|
||||||
*/
|
*/
|
||||||
@@ -45,4 +47,14 @@ public interface EconomyIntegration extends Integration {
|
|||||||
* @return The balance.
|
* @return The balance.
|
||||||
*/
|
*/
|
||||||
double getBalance(@NotNull OfflinePlayer player);
|
double getBalance(@NotNull OfflinePlayer player);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the balance of a player.
|
||||||
|
*
|
||||||
|
* @param player The player.
|
||||||
|
* @return The balance.
|
||||||
|
*/
|
||||||
|
default BigDecimal getExactBalance(@NotNull OfflinePlayer player) {
|
||||||
|
return BigDecimal.valueOf(getBalance(player));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.willfp.eco.core.integrations.economy;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -96,6 +97,20 @@ public final class EconomyManager {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the balance of a player.
|
||||||
|
*
|
||||||
|
* @param player The player.
|
||||||
|
* @return The balance.
|
||||||
|
*/
|
||||||
|
public static BigDecimal getExactBalance(@NotNull final OfflinePlayer player) {
|
||||||
|
for (EconomyIntegration integration : REGISTERED) {
|
||||||
|
return integration.getExactBalance(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
private EconomyManager() {
|
private EconomyManager() {
|
||||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.willfp.eco.core.integrations.shop;
|
package com.willfp.eco.core.integrations.shop;
|
||||||
|
|
||||||
import com.willfp.eco.core.integrations.Integration;
|
import com.willfp.eco.core.integrations.Integration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,4 +28,27 @@ public interface ShopIntegration extends Integration {
|
|||||||
// Do nothing unless overridden.
|
// Do nothing unless overridden.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the price of an item.
|
||||||
|
*
|
||||||
|
* @param itemStack The item.
|
||||||
|
* @return The price.
|
||||||
|
*/
|
||||||
|
default double getPrice(@NotNull final ItemStack itemStack) {
|
||||||
|
// Do nothing unless overridden.
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the price of an item.
|
||||||
|
*
|
||||||
|
* @param itemStack The item.
|
||||||
|
* @param player The player.
|
||||||
|
* @return The price.
|
||||||
|
*/
|
||||||
|
default double getPrice(@NotNull final ItemStack itemStack,
|
||||||
|
@NotNull final Player player) {
|
||||||
|
return getPrice(itemStack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package com.willfp.eco.core.integrations.shop;
|
package com.willfp.eco.core.integrations.shop;
|
||||||
|
|
||||||
import com.willfp.eco.core.EcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -52,6 +55,40 @@ public final class ShopManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the price of an item.
|
||||||
|
*
|
||||||
|
* @param itemStack The item.
|
||||||
|
* @return The price.
|
||||||
|
*/
|
||||||
|
public static double getItemPrice(@Nullable final ItemStack itemStack) {
|
||||||
|
return getItemPrice(itemStack, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the price of an item.
|
||||||
|
*
|
||||||
|
* @param itemStack The item.
|
||||||
|
* @param player The player.
|
||||||
|
* @return The price.
|
||||||
|
*/
|
||||||
|
public static double getItemPrice(@Nullable final ItemStack itemStack,
|
||||||
|
@Nullable final Player player) {
|
||||||
|
if (itemStack == null) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ShopIntegration shopIntegration : REGISTERED) {
|
||||||
|
if (player == null) {
|
||||||
|
return shopIntegration.getPrice(itemStack);
|
||||||
|
} else {
|
||||||
|
return shopIntegration.getPrice(itemStack, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
private ShopManager() {
|
private ShopManager() {
|
||||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,11 +230,11 @@ public final class Items {
|
|||||||
|
|
||||||
String reformattedKey = keyID.replace("__", ":");
|
String reformattedKey = keyID.replace("__", ":");
|
||||||
|
|
||||||
item = provider.provideForKey(reformattedKey);
|
part = provider.provideForKey(reformattedKey);
|
||||||
if (item instanceof EmptyTestableItem || item == null) {
|
if (part instanceof EmptyTestableItem || part == null) {
|
||||||
return new EmptyTestableItem();
|
return new EmptyTestableItem();
|
||||||
}
|
}
|
||||||
registerCustomItem(namespacedKey, item);
|
registerCustomItem(namespacedKey, part);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -25,13 +25,30 @@ public class Paste {
|
|||||||
*/
|
*/
|
||||||
private final String contents;
|
private final String contents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The host.
|
||||||
|
*/
|
||||||
|
private final String host;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new paste.
|
* Create a new paste.
|
||||||
*
|
*
|
||||||
* @param contents The contents.
|
* @param contents The contents.
|
||||||
*/
|
*/
|
||||||
public Paste(@NotNull final String contents) {
|
public Paste(@NotNull final String contents) {
|
||||||
|
this(contents, "https://paste.willfp.com");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new paste.
|
||||||
|
*
|
||||||
|
* @param contents The contents.
|
||||||
|
* @param host The host.
|
||||||
|
*/
|
||||||
|
public Paste(@NotNull final String contents,
|
||||||
|
@NotNull final String host) {
|
||||||
this.contents = contents;
|
this.contents = contents;
|
||||||
|
this.host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,7 +64,7 @@ public class Paste {
|
|||||||
byte[] postData = URLEncoder.encode(contents, StandardCharsets.UTF_8).getBytes(StandardCharsets.UTF_8);
|
byte[] postData = URLEncoder.encode(contents, StandardCharsets.UTF_8).getBytes(StandardCharsets.UTF_8);
|
||||||
int postDataLength = postData.length;
|
int postDataLength = postData.length;
|
||||||
|
|
||||||
String requestURL = "https://paste.willfp.com/documents";
|
String requestURL = this.host + "/documents";
|
||||||
URL url = new URL(requestURL);
|
URL url = new URL(requestURL);
|
||||||
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
|
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
|
||||||
conn.setDoOutput(true);
|
conn.setDoOutput(true);
|
||||||
@@ -85,14 +102,26 @@ public class Paste {
|
|||||||
* @return The paste.
|
* @return The paste.
|
||||||
*/
|
*/
|
||||||
public static Paste getFromHastebin(@NotNull final String token) {
|
public static Paste getFromHastebin(@NotNull final String token) {
|
||||||
|
return getFromHastebin(token, "https://paste.willfp.com");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get paste from hastebin.
|
||||||
|
*
|
||||||
|
* @param token The token.
|
||||||
|
* @param host The host.
|
||||||
|
* @return The paste.
|
||||||
|
*/
|
||||||
|
public static Paste getFromHastebin(@NotNull final String token,
|
||||||
|
@NotNull final String host) {
|
||||||
try {
|
try {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
URL url = new URL("https://paste.willfp.com/raw/" + token);
|
URL url = new URL(host + "/raw/" + token);
|
||||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
conn.setRequestMethod("GET");
|
conn.setRequestMethod("GET");
|
||||||
try (var reader = new BufferedReader(
|
try (var reader = new BufferedReader(
|
||||||
new InputStreamReader(conn.getInputStream()))) {
|
new InputStreamReader(conn.getInputStream()))) {
|
||||||
for (String line; (line = reader.readLine()) != null;) {
|
for (String line; (line = reader.readLine()) != null; ) {
|
||||||
result.append(line);
|
result.append(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,16 @@ fun slot(
|
|||||||
item: ItemStack
|
item: ItemStack
|
||||||
): Slot = Slot.builder(item).build()
|
): Slot = Slot.builder(item).build()
|
||||||
|
|
||||||
|
/** Kotlin builder for slots. */
|
||||||
|
fun slot(
|
||||||
|
item: TestableItem,
|
||||||
|
init: SlotBuilder.() -> Unit
|
||||||
|
): Slot {
|
||||||
|
val builder = Slot.builder(item)
|
||||||
|
init(builder)
|
||||||
|
return builder.build()
|
||||||
|
}
|
||||||
|
|
||||||
/** Kotlin builder for slots. */
|
/** Kotlin builder for slots. */
|
||||||
fun slot(
|
fun slot(
|
||||||
item: TestableItem
|
item: TestableItem
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
package com.willfp.eco.core.integrations.economy
|
package com.willfp.eco.core.integrations.economy
|
||||||
|
|
||||||
import org.bukkit.OfflinePlayer
|
import org.bukkit.OfflinePlayer
|
||||||
|
import java.math.BigDecimal
|
||||||
|
|
||||||
/** @see EconomyManager */
|
/** @see EconomyManager */
|
||||||
var OfflinePlayer.balance: Double
|
var OfflinePlayer.balance: Double
|
||||||
@@ -21,3 +22,21 @@ var OfflinePlayer.balance: Double
|
|||||||
EconomyManager.giveMoney(this, -diff)
|
EconomyManager.giveMoney(this, -diff)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @see EconomyManager */
|
||||||
|
var OfflinePlayer.exactBalance: BigDecimal
|
||||||
|
get() = EconomyManager.getBalance(this).toBigDecimal()
|
||||||
|
set(value) {
|
||||||
|
if (value <= BigDecimal.ZERO) {
|
||||||
|
EconomyManager.removeMoney(this, this.balance)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val diff = this.exactBalance - value
|
||||||
|
|
||||||
|
if (diff > BigDecimal.ZERO) {
|
||||||
|
EconomyManager.removeMoney(this, diff.toDouble())
|
||||||
|
} else if (diff < BigDecimal.ZERO) {
|
||||||
|
EconomyManager.giveMoney(this, -diff.toDouble())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
@file:JvmName("ShopExtensions")
|
||||||
|
|
||||||
|
package com.willfp.eco.core.integrations.shop
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.inventory.ItemStack
|
||||||
|
|
||||||
|
/** @see ShopManager.getItemPrice **/
|
||||||
|
val ItemStack.price: Double
|
||||||
|
get() = ShopManager.getItemPrice(this)
|
||||||
|
|
||||||
|
/** @see ShopManager.getItemPrice **/
|
||||||
|
fun ItemStack.getPrice(player: Player): Double =
|
||||||
|
ShopManager.getItemPrice(this, player)
|
||||||
@@ -17,7 +17,7 @@ import org.bukkit.inventory.ItemStack
|
|||||||
import java.util.function.BiConsumer
|
import java.util.function.BiConsumer
|
||||||
import java.util.function.Consumer
|
import java.util.function.Consumer
|
||||||
|
|
||||||
class EcoMenuBuilder(private val rows: Int ) : MenuBuilder {
|
class EcoMenuBuilder(private val rows: Int) : MenuBuilder {
|
||||||
private var title = "Menu"
|
private var title = "Menu"
|
||||||
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)
|
||||||
@@ -25,6 +25,8 @@ class EcoMenuBuilder(private val rows: Int ) : MenuBuilder {
|
|||||||
private var onOpen = OpenHandler { _, _ -> }
|
private var onOpen = OpenHandler { _, _ -> }
|
||||||
private var onRender: (Player, Menu) -> Unit = { _, _ -> }
|
private var onRender: (Player, Menu) -> Unit = { _, _ -> }
|
||||||
|
|
||||||
|
override fun getRows() = rows
|
||||||
|
|
||||||
override fun setTitle(title: String): MenuBuilder {
|
override fun setTitle(title: String): MenuBuilder {
|
||||||
this.title = StringUtils.format(title)
|
this.title = StringUtils.format(title)
|
||||||
return this
|
return this
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.willfp.eco.internal.spigot.proxy.common
|
||||||
|
|
||||||
|
import com.mojang.authlib.GameProfile
|
||||||
|
import com.mojang.authlib.properties.Property
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta
|
||||||
|
import java.lang.reflect.Field
|
||||||
|
import java.lang.reflect.Method
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
private lateinit var setProfile: Method
|
||||||
|
private lateinit var profile: Field
|
||||||
|
|
||||||
|
var SkullMeta.texture: String?
|
||||||
|
get() {
|
||||||
|
if (!::profile.isInitialized) {
|
||||||
|
// Assumes instance of CraftMetaSkull; package-private class so can't do manual type check
|
||||||
|
profile = this.javaClass.getDeclaredField("profile")
|
||||||
|
profile.isAccessible = true
|
||||||
|
}
|
||||||
|
val profile = profile[this] as GameProfile? ?: return null
|
||||||
|
val properties = profile.properties ?: return null
|
||||||
|
val prop = properties["textures"] ?: return null
|
||||||
|
return prop.toMutableList().firstOrNull()?.value
|
||||||
|
}
|
||||||
|
set(base64) {
|
||||||
|
if (!::setProfile.isInitialized) {
|
||||||
|
// Same here; that's why I can't delegate to a lazy initializer
|
||||||
|
setProfile = this.javaClass.getDeclaredMethod("setProfile", GameProfile::class.java)
|
||||||
|
setProfile.isAccessible = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (base64 == null) {
|
||||||
|
setProfile.invoke(this, null)
|
||||||
|
} else {
|
||||||
|
val uuid = UUID(
|
||||||
|
base64.substring(base64.length - 20).hashCode().toLong(),
|
||||||
|
base64.substring(base64.length - 10).hashCode().toLong()
|
||||||
|
)
|
||||||
|
val profile = GameProfile(uuid, "eco")
|
||||||
|
profile.properties.put("textures", Property("textures", base64))
|
||||||
|
setProfile.invoke(this, profile)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,48 +1,18 @@
|
|||||||
package com.willfp.eco.internal.spigot.proxy.v1_17_R1
|
package com.willfp.eco.internal.spigot.proxy.v1_17_R1
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile
|
|
||||||
import com.mojang.authlib.properties.Property
|
|
||||||
import com.willfp.eco.internal.spigot.proxy.SkullProxy
|
import com.willfp.eco.internal.spigot.proxy.SkullProxy
|
||||||
|
import com.willfp.eco.internal.spigot.proxy.common.texture
|
||||||
import org.bukkit.inventory.meta.SkullMeta
|
import org.bukkit.inventory.meta.SkullMeta
|
||||||
import java.lang.reflect.Field
|
|
||||||
import java.lang.reflect.Method
|
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
class Skull : SkullProxy {
|
class Skull : SkullProxy {
|
||||||
private lateinit var setProfile: Method
|
|
||||||
private lateinit var profile: Field
|
|
||||||
|
|
||||||
override fun setSkullTexture(
|
override fun setSkullTexture(
|
||||||
meta: SkullMeta,
|
meta: SkullMeta,
|
||||||
base64: String
|
base64: String
|
||||||
) {
|
) {
|
||||||
if (!this::setProfile.isInitialized) {
|
meta.texture = base64
|
||||||
setProfile = meta.javaClass.getDeclaredMethod("setProfile", GameProfile::class.java)
|
|
||||||
setProfile.isAccessible = true
|
|
||||||
}
|
|
||||||
if (base64.length < 20) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val uuid = UUID(
|
|
||||||
base64.substring(base64.length - 20).hashCode().toLong(),
|
|
||||||
base64.substring(base64.length - 10).hashCode().toLong()
|
|
||||||
)
|
|
||||||
val profile = GameProfile(uuid, "eco")
|
|
||||||
profile.properties.put("textures", Property("textures", base64))
|
|
||||||
setProfile.invoke(meta, profile)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSkullTexture(
|
override fun getSkullTexture(
|
||||||
meta: SkullMeta
|
meta: SkullMeta
|
||||||
): String? {
|
): String? = meta.texture
|
||||||
if (!this::profile.isInitialized) {
|
|
||||||
profile = meta.javaClass.getDeclaredField("profile")
|
|
||||||
profile.isAccessible = true
|
|
||||||
}
|
|
||||||
val profile = profile[meta] as GameProfile? ?: return null
|
|
||||||
val properties = profile.properties ?: return null
|
|
||||||
val prop = properties["textures"] ?: return null
|
|
||||||
return prop.toMutableList().firstOrNull()?.name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,48 +1,18 @@
|
|||||||
package com.willfp.eco.internal.spigot.proxy.v1_18_R1
|
package com.willfp.eco.internal.spigot.proxy.v1_18_R1
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile
|
|
||||||
import com.mojang.authlib.properties.Property
|
|
||||||
import com.willfp.eco.internal.spigot.proxy.SkullProxy
|
import com.willfp.eco.internal.spigot.proxy.SkullProxy
|
||||||
|
import com.willfp.eco.internal.spigot.proxy.common.texture
|
||||||
import org.bukkit.inventory.meta.SkullMeta
|
import org.bukkit.inventory.meta.SkullMeta
|
||||||
import java.lang.reflect.Field
|
|
||||||
import java.lang.reflect.Method
|
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
class Skull : SkullProxy {
|
class Skull : SkullProxy {
|
||||||
private lateinit var setProfile: Method
|
|
||||||
private lateinit var profile: Field
|
|
||||||
|
|
||||||
override fun setSkullTexture(
|
override fun setSkullTexture(
|
||||||
meta: SkullMeta,
|
meta: SkullMeta,
|
||||||
base64: String
|
base64: String
|
||||||
) {
|
) {
|
||||||
if (!this::setProfile.isInitialized) {
|
meta.texture = base64
|
||||||
setProfile = meta.javaClass.getDeclaredMethod("setProfile", GameProfile::class.java)
|
|
||||||
setProfile.isAccessible = true
|
|
||||||
}
|
|
||||||
if (base64.length < 20) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val uuid = UUID(
|
|
||||||
base64.substring(base64.length - 20).hashCode().toLong(),
|
|
||||||
base64.substring(base64.length - 10).hashCode().toLong()
|
|
||||||
)
|
|
||||||
val profile = GameProfile(uuid, "eco")
|
|
||||||
profile.properties.put("textures", Property("textures", base64))
|
|
||||||
setProfile.invoke(meta, profile)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSkullTexture(
|
override fun getSkullTexture(
|
||||||
meta: SkullMeta
|
meta: SkullMeta
|
||||||
): String? {
|
): String? = meta.texture
|
||||||
if (!this::profile.isInitialized) {
|
|
||||||
profile = meta.javaClass.getDeclaredField("profile")
|
|
||||||
profile.isAccessible = true
|
|
||||||
}
|
|
||||||
val profile = profile[meta] as GameProfile? ?: return null
|
|
||||||
val properties = profile.properties ?: return null
|
|
||||||
val prop = properties["textures"] ?: return null
|
|
||||||
return prop.toMutableList().firstOrNull()?.name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,48 +1,18 @@
|
|||||||
package com.willfp.eco.internal.spigot.proxy.v1_18_R2
|
package com.willfp.eco.internal.spigot.proxy.v1_18_R2
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile
|
|
||||||
import com.mojang.authlib.properties.Property
|
|
||||||
import com.willfp.eco.internal.spigot.proxy.SkullProxy
|
import com.willfp.eco.internal.spigot.proxy.SkullProxy
|
||||||
|
import com.willfp.eco.internal.spigot.proxy.common.texture
|
||||||
import org.bukkit.inventory.meta.SkullMeta
|
import org.bukkit.inventory.meta.SkullMeta
|
||||||
import java.lang.reflect.Field
|
|
||||||
import java.lang.reflect.Method
|
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
class Skull : SkullProxy {
|
class Skull : SkullProxy {
|
||||||
private lateinit var setProfile: Method
|
|
||||||
private lateinit var profile: Field
|
|
||||||
|
|
||||||
override fun setSkullTexture(
|
override fun setSkullTexture(
|
||||||
meta: SkullMeta,
|
meta: SkullMeta,
|
||||||
base64: String
|
base64: String
|
||||||
) {
|
) {
|
||||||
if (!this::setProfile.isInitialized) {
|
meta.texture = base64
|
||||||
setProfile = meta.javaClass.getDeclaredMethod("setProfile", GameProfile::class.java)
|
|
||||||
setProfile.isAccessible = true
|
|
||||||
}
|
|
||||||
if (base64.length < 20) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val uuid = UUID(
|
|
||||||
base64.substring(base64.length - 20).hashCode().toLong(),
|
|
||||||
base64.substring(base64.length - 10).hashCode().toLong()
|
|
||||||
)
|
|
||||||
val profile = GameProfile(uuid, "eco")
|
|
||||||
profile.properties.put("textures", Property("textures", base64))
|
|
||||||
setProfile.invoke(meta, profile)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSkullTexture(
|
override fun getSkullTexture(
|
||||||
meta: SkullMeta
|
meta: SkullMeta
|
||||||
): String? {
|
): String? = meta.texture
|
||||||
if (!this::profile.isInitialized) {
|
|
||||||
profile = meta.javaClass.getDeclaredField("profile")
|
|
||||||
profile.isAccessible = true
|
|
||||||
}
|
|
||||||
val profile = profile[meta] as GameProfile? ?: return null
|
|
||||||
val properties = profile.properties ?: return null
|
|
||||||
val prop = properties["textures"] ?: return null
|
|
||||||
return prop.toMutableList().firstOrNull()?.name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,48 +1,18 @@
|
|||||||
package com.willfp.eco.internal.spigot.proxy.v1_19_R1
|
package com.willfp.eco.internal.spigot.proxy.v1_19_R1
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile
|
|
||||||
import com.mojang.authlib.properties.Property
|
|
||||||
import com.willfp.eco.internal.spigot.proxy.SkullProxy
|
import com.willfp.eco.internal.spigot.proxy.SkullProxy
|
||||||
|
import com.willfp.eco.internal.spigot.proxy.common.texture
|
||||||
import org.bukkit.inventory.meta.SkullMeta
|
import org.bukkit.inventory.meta.SkullMeta
|
||||||
import java.lang.reflect.Field
|
|
||||||
import java.lang.reflect.Method
|
|
||||||
import java.util.UUID
|
|
||||||
|
|
||||||
class Skull : SkullProxy {
|
class Skull : SkullProxy {
|
||||||
private lateinit var setProfile: Method
|
|
||||||
private lateinit var profile: Field
|
|
||||||
|
|
||||||
override fun setSkullTexture(
|
override fun setSkullTexture(
|
||||||
meta: SkullMeta,
|
meta: SkullMeta,
|
||||||
base64: String
|
base64: String
|
||||||
) {
|
) {
|
||||||
if (!this::setProfile.isInitialized) {
|
meta.texture = base64
|
||||||
setProfile = meta.javaClass.getDeclaredMethod("setProfile", GameProfile::class.java)
|
|
||||||
setProfile.isAccessible = true
|
|
||||||
}
|
|
||||||
if (base64.length < 20) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val uuid = UUID(
|
|
||||||
base64.substring(base64.length - 20).hashCode().toLong(),
|
|
||||||
base64.substring(base64.length - 10).hashCode().toLong()
|
|
||||||
)
|
|
||||||
val profile = GameProfile(uuid, "eco")
|
|
||||||
profile.properties.put("textures", Property("textures", base64))
|
|
||||||
setProfile.invoke(meta, profile)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSkullTexture(
|
override fun getSkullTexture(
|
||||||
meta: SkullMeta
|
meta: SkullMeta
|
||||||
): String? {
|
): String? = meta.texture
|
||||||
if (!this::profile.isInitialized) {
|
|
||||||
profile = meta.javaClass.getDeclaredField("profile")
|
|
||||||
profile.isAccessible = true
|
|
||||||
}
|
|
||||||
val profile = profile[meta] as GameProfile? ?: return null
|
|
||||||
val properties = profile.properties ?: return null
|
|
||||||
val prop = properties["textures"] ?: return null
|
|
||||||
return prop.toMutableList().firstOrNull()?.name
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ dependencies {
|
|||||||
compileOnly project(":eco-core:core-backend")
|
compileOnly project(":eco-core:core-backend")
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
implementation 'com.github.Redempt:Crunch:master-SNAPSHOT'
|
implementation 'com.github.WillFP:Crunch:1.1.3'
|
||||||
implementation 'mysql:mysql-connector-java:8.0.25'
|
implementation 'mysql:mysql-connector-java:8.0.25'
|
||||||
implementation 'org.jetbrains.exposed:exposed-core:0.37.3'
|
implementation 'org.jetbrains.exposed:exposed-core:0.37.3'
|
||||||
implementation 'org.jetbrains.exposed:exposed-dao:0.37.3'
|
implementation 'org.jetbrains.exposed:exposed-dao:0.37.3'
|
||||||
@@ -25,7 +25,6 @@ dependencies {
|
|||||||
compileOnly 'com.comphenix.protocol:ProtocolLib:5.0.0-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.github.cryptomorin:kingdoms:1.12.3'
|
|
||||||
compileOnly('com.github.TownyAdvanced:Towny:0.97.2.6') {
|
compileOnly('com.github.TownyAdvanced:Towny:0.97.2.6') {
|
||||||
exclude group: 'com.zaxxer', module: 'HikariCP'
|
exclude group: 'com.zaxxer', module: 'HikariCP'
|
||||||
}
|
}
|
||||||
@@ -41,12 +40,12 @@ dependencies {
|
|||||||
compileOnly 'com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0'
|
compileOnly 'com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0'
|
||||||
compileOnly 'com.github.EssentialsX:Essentials:2.18.2'
|
compileOnly 'com.github.EssentialsX:Essentials:2.18.2'
|
||||||
compileOnly 'com.bgsoftware:SuperiorSkyblockAPI:1.8.3'
|
compileOnly 'com.bgsoftware:SuperiorSkyblockAPI:1.8.3'
|
||||||
compileOnly 'com.songoda:skyblock:2.3.30'
|
|
||||||
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
|
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
|
||||||
compileOnly 'com.github.WhipDevelopment:CrashClaim:f9cd7d92eb'
|
compileOnly 'com.github.WhipDevelopment:CrashClaim:f9cd7d92eb'
|
||||||
compileOnly 'com.wolfyscript.wolfyutilities:wolfyutilities:3.16.0.0'
|
compileOnly 'com.wolfyscript.wolfyutilities:wolfyutilities:3.16.0.0'
|
||||||
compileOnly 'com.github.decentsoftware-eu:decentholograms:2.1.2'
|
compileOnly 'com.github.decentsoftware-eu:decentholograms:2.1.2'
|
||||||
compileOnly 'com.github.Gypopo:EconomyShopGUI-API:1.1.0'
|
compileOnly 'com.github.Gypopo:EconomyShopGUI-API:1.1.0'
|
||||||
|
compileOnly 'com.github.N0RSKA:ScytherAPI:55a'
|
||||||
|
|
||||||
// MythicMobs
|
// MythicMobs
|
||||||
compileOnly 'io.lumine:Mythic:5.0.1'
|
compileOnly 'io.lumine:Mythic:5.0.1'
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ import com.willfp.eco.internal.spigot.data.PlayerBlockListener
|
|||||||
import com.willfp.eco.internal.spigot.data.storage.ProfileSaver
|
import com.willfp.eco.internal.spigot.data.storage.ProfileSaver
|
||||||
import com.willfp.eco.internal.spigot.display.PacketAutoRecipe
|
import com.willfp.eco.internal.spigot.display.PacketAutoRecipe
|
||||||
import com.willfp.eco.internal.spigot.display.PacketChat
|
import com.willfp.eco.internal.spigot.display.PacketChat
|
||||||
import com.willfp.eco.internal.spigot.display.PacketHeldWindowItems
|
import com.willfp.eco.internal.spigot.display.PacketHeldItemSlot
|
||||||
import com.willfp.eco.internal.spigot.display.PacketOpenWindowMerchant
|
import com.willfp.eco.internal.spigot.display.PacketOpenWindowMerchant
|
||||||
import com.willfp.eco.internal.spigot.display.PacketSetCreativeSlot
|
import com.willfp.eco.internal.spigot.display.PacketSetCreativeSlot
|
||||||
import com.willfp.eco.internal.spigot.display.PacketSetSlot
|
import com.willfp.eco.internal.spigot.display.PacketSetSlot
|
||||||
@@ -101,6 +101,7 @@ import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsHeadDa
|
|||||||
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsItemsAdder
|
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsItemsAdder
|
||||||
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsMythicMobs
|
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsMythicMobs
|
||||||
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsOraxen
|
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsOraxen
|
||||||
|
import com.willfp.eco.internal.spigot.integrations.customitems.CustomItemsScyther
|
||||||
import com.willfp.eco.internal.spigot.integrations.customrecipes.CustomRecipeCustomCrafting
|
import com.willfp.eco.internal.spigot.integrations.customrecipes.CustomRecipeCustomCrafting
|
||||||
import com.willfp.eco.internal.spigot.integrations.economy.EconomyVault
|
import com.willfp.eco.internal.spigot.integrations.economy.EconomyVault
|
||||||
import com.willfp.eco.internal.spigot.integrations.hologram.HologramCMI
|
import com.willfp.eco.internal.spigot.integrations.hologram.HologramCMI
|
||||||
@@ -313,6 +314,7 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
|||||||
CraftingRecipeListener.registerValidator(CustomRecipeCustomCrafting())
|
CraftingRecipeListener.registerValidator(CustomRecipeCustomCrafting())
|
||||||
},
|
},
|
||||||
IntegrationLoader("MythicMobs") { CustomItemsManager.register(CustomItemsMythicMobs(this)) },
|
IntegrationLoader("MythicMobs") { CustomItemsManager.register(CustomItemsMythicMobs(this)) },
|
||||||
|
IntegrationLoader("Scyther") { CustomItemsManager.register(CustomItemsScyther()) },
|
||||||
|
|
||||||
// Shop
|
// Shop
|
||||||
IntegrationLoader("ShopGUIPlus") { ShopManager.register(ShopShopGuiPlus()) },
|
IntegrationLoader("ShopGUIPlus") { ShopManager.register(ShopShopGuiPlus()) },
|
||||||
@@ -355,7 +357,7 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
|
|||||||
PacketSetCreativeSlot(this),
|
PacketSetCreativeSlot(this),
|
||||||
PacketSetSlot(this),
|
PacketSetSlot(this),
|
||||||
PacketWindowItems(this),
|
PacketWindowItems(this),
|
||||||
PacketHeldWindowItems(this),
|
PacketHeldItemSlot(this),
|
||||||
PacketOpenWindowMerchant(this)
|
PacketOpenWindowMerchant(this)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.willfp.eco.internal.spigot.display
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType
|
||||||
|
import com.comphenix.protocol.events.PacketContainer
|
||||||
|
import com.comphenix.protocol.events.PacketEvent
|
||||||
|
import com.willfp.eco.core.AbstractPacketAdapter
|
||||||
|
import com.willfp.eco.core.EcoPlugin
|
||||||
|
import com.willfp.eco.internal.spigot.display.frame.DisplayFrame
|
||||||
|
import com.willfp.eco.internal.spigot.display.frame.lastDisplayFrame
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
|
class PacketHeldItemSlot(plugin: EcoPlugin) :
|
||||||
|
AbstractPacketAdapter(plugin, PacketType.Play.Server.HELD_ITEM_SLOT, false) {
|
||||||
|
override fun onSend(
|
||||||
|
packet: PacketContainer,
|
||||||
|
player: Player,
|
||||||
|
event: PacketEvent
|
||||||
|
) {
|
||||||
|
player.lastDisplayFrame = DisplayFrame.EMPTY
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onReceive(
|
||||||
|
packet: PacketContainer,
|
||||||
|
player: Player,
|
||||||
|
event: PacketEvent
|
||||||
|
) {
|
||||||
|
player.lastDisplayFrame = DisplayFrame.EMPTY
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package com.willfp.eco.internal.spigot.display
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType
|
|
||||||
import com.comphenix.protocol.events.PacketContainer
|
|
||||||
import com.comphenix.protocol.events.PacketEvent
|
|
||||||
import com.willfp.eco.core.AbstractPacketAdapter
|
|
||||||
import com.willfp.eco.core.EcoPlugin
|
|
||||||
import com.willfp.eco.core.display.Display
|
|
||||||
import org.bukkit.entity.Player
|
|
||||||
import org.bukkit.inventory.ItemStack
|
|
||||||
|
|
||||||
class PacketHeldWindowItems(plugin: EcoPlugin) :
|
|
||||||
AbstractPacketAdapter(plugin, PacketType.Play.Server.WINDOW_ITEMS, false) {
|
|
||||||
override fun onSend(
|
|
||||||
packet: PacketContainer,
|
|
||||||
player: Player,
|
|
||||||
event: PacketEvent
|
|
||||||
) {
|
|
||||||
packet.itemModifier.modify(0) { item: ItemStack? ->
|
|
||||||
Display.display(
|
|
||||||
item!!, player
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,6 @@ import com.willfp.eco.core.display.Display
|
|||||||
import com.willfp.eco.internal.spigot.display.frame.DisplayFrame
|
import com.willfp.eco.internal.spigot.display.frame.DisplayFrame
|
||||||
import com.willfp.eco.internal.spigot.display.frame.lastDisplayFrame
|
import com.willfp.eco.internal.spigot.display.frame.lastDisplayFrame
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.inventory.ItemStack
|
|
||||||
|
|
||||||
class PacketSetSlot(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, PacketType.Play.Server.SET_SLOT, false) {
|
class PacketSetSlot(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, PacketType.Play.Server.SET_SLOT, false) {
|
||||||
override fun onSend(
|
override fun onSend(
|
||||||
@@ -17,13 +16,12 @@ class PacketSetSlot(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, PacketTyp
|
|||||||
player: Player,
|
player: Player,
|
||||||
event: PacketEvent
|
event: PacketEvent
|
||||||
) {
|
) {
|
||||||
packet.itemModifier.modify(0, object : VersionCompatiblePLibFunction<ItemStack> {
|
packet.itemModifier.modify(0) {
|
||||||
override fun apply(item: ItemStack) =
|
Display.display(
|
||||||
Display.display(
|
it,
|
||||||
item,
|
player
|
||||||
player
|
)
|
||||||
)
|
}
|
||||||
})
|
|
||||||
|
|
||||||
player.lastDisplayFrame = DisplayFrame.EMPTY
|
player.lastDisplayFrame = DisplayFrame.EMPTY
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,21 +14,32 @@ import org.bukkit.inventory.ItemStack
|
|||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, PacketType.Play.Server.WINDOW_ITEMS, false) {
|
class PacketWindowItems(plugin: EcoPlugin) : AbstractPacketAdapter(plugin, PacketType.Play.Server.WINDOW_ITEMS, false) {
|
||||||
private val ignorePacketList = ConcurrentHashMap.newKeySet<String>()
|
private val lastKnownWindowIDs = ConcurrentHashMap<String, Int>()
|
||||||
|
|
||||||
override fun onSend(
|
override fun onSend(
|
||||||
packet: PacketContainer,
|
packet: PacketContainer,
|
||||||
player: Player,
|
player: Player,
|
||||||
event: PacketEvent
|
event: PacketEvent
|
||||||
) {
|
) {
|
||||||
if (ignorePacketList.contains(player.name)) {
|
packet.itemModifier.modify(0) {
|
||||||
ignorePacketList.remove(player.name)
|
Display.display(
|
||||||
return
|
it, player
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val windowId = packet.integers.read(0)
|
val windowId = packet.integers.read(0)
|
||||||
|
|
||||||
if (windowId != 0) {
|
// Using name because UUID is unreliable with ProtocolLib players.
|
||||||
|
val name = player.name
|
||||||
|
|
||||||
|
val lastKnownID = lastKnownWindowIDs[name]
|
||||||
|
lastKnownWindowIDs[name] = windowId
|
||||||
|
|
||||||
|
// If there is any change in window ID at any point,
|
||||||
|
// Remove the last display frame to prevent any potential conflicts.
|
||||||
|
// If the window ID is not zero (not a player inventory), then remove too,
|
||||||
|
// as GUIs are not player inventories.
|
||||||
|
if (lastKnownID != windowId || windowId != 0) {
|
||||||
player.lastDisplayFrame = DisplayFrame.EMPTY
|
player.lastDisplayFrame = DisplayFrame.EMPTY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
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> {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.willfp.eco.internal.spigot.gui
|
package com.willfp.eco.internal.spigot.gui
|
||||||
|
|
||||||
import com.willfp.eco.core.EcoPlugin
|
import com.willfp.eco.core.EcoPlugin
|
||||||
|
import com.willfp.eco.core.gui.slot.CustomSlot
|
||||||
|
import com.willfp.eco.core.gui.slot.Slot
|
||||||
import com.willfp.eco.internal.gui.menu.EcoMenu
|
import com.willfp.eco.internal.gui.menu.EcoMenu
|
||||||
import com.willfp.eco.internal.gui.menu.MenuHandler
|
import com.willfp.eco.internal.gui.menu.MenuHandler
|
||||||
import com.willfp.eco.internal.gui.menu.asRenderedInventory
|
import com.willfp.eco.internal.gui.menu.asRenderedInventory
|
||||||
@@ -16,6 +18,13 @@ import org.bukkit.event.inventory.InventoryCloseEvent
|
|||||||
import org.bukkit.event.player.PlayerItemHeldEvent
|
import org.bukkit.event.player.PlayerItemHeldEvent
|
||||||
|
|
||||||
class GUIListener(private val plugin: EcoPlugin) : Listener {
|
class GUIListener(private val plugin: EcoPlugin) : Listener {
|
||||||
|
private fun Slot.handle(event: InventoryClickEvent, menu: EcoMenu) {
|
||||||
|
when (this) {
|
||||||
|
is EcoSlot -> this.handleInventoryClick(event, menu)
|
||||||
|
is CustomSlot -> this.delegate.handle(event, menu)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
fun handleSlotClick(event: InventoryClickEvent) {
|
fun handleSlotClick(event: InventoryClickEvent) {
|
||||||
val rendered = event.clickedInventory?.asRenderedInventory() ?: return
|
val rendered = event.clickedInventory?.asRenderedInventory() ?: return
|
||||||
@@ -24,9 +33,7 @@ class GUIListener(private val plugin: EcoPlugin) : Listener {
|
|||||||
|
|
||||||
val (row, column) = MenuUtils.convertSlotToRowColumn(event.slot)
|
val (row, column) = MenuUtils.convertSlotToRowColumn(event.slot)
|
||||||
|
|
||||||
val slot = menu.getSlot(row, column) as? EcoSlot ?: return
|
menu.getSlot(row, column).handle(event, menu)
|
||||||
|
|
||||||
slot.handleInventoryClick(event, menu)
|
|
||||||
|
|
||||||
plugin.scheduler.run { rendered.render() }
|
plugin.scheduler.run { rendered.render() }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import org.bukkit.block.Block
|
|||||||
import org.bukkit.entity.LivingEntity
|
import org.bukkit.entity.LivingEntity
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.kingdoms.constants.group.Kingdom
|
import org.kingdoms.constants.group.Kingdom
|
||||||
import org.kingdoms.constants.group.model.KingdomRelation
|
import org.kingdoms.constants.group.model.relationships.StandardRelationAttribute
|
||||||
import org.kingdoms.constants.land.Land
|
import org.kingdoms.constants.land.Land
|
||||||
import org.kingdoms.constants.player.DefaultKingdomPermission
|
|
||||||
import org.kingdoms.constants.player.KingdomPlayer
|
import org.kingdoms.constants.player.KingdomPlayer
|
||||||
|
import org.kingdoms.constants.player.StandardKingdomPermission
|
||||||
import org.kingdoms.managers.PvPManager
|
import org.kingdoms.managers.PvPManager
|
||||||
|
|
||||||
class AntigriefKingdoms : AntigriefIntegration {
|
class AntigriefKingdoms : AntigriefIntegration {
|
||||||
@@ -23,11 +23,13 @@ class AntigriefKingdoms : AntigriefIntegration {
|
|||||||
}
|
}
|
||||||
val kingdom: Kingdom = kp.kingdom ?: return false
|
val kingdom: Kingdom = kp.kingdom ?: return false
|
||||||
val land = Land.getLand(block) ?: return true
|
val land = Land.getLand(block) ?: return true
|
||||||
val permission: DefaultKingdomPermission =
|
val permission = if (land.isNexusLand) {
|
||||||
if (land.isNexusLand) DefaultKingdomPermission.NEXUS_BUILD else DefaultKingdomPermission.BUILD
|
StandardKingdomPermission.NEXUS_BUILD
|
||||||
|
} else StandardKingdomPermission.BUILD
|
||||||
|
|
||||||
return if (!kp.hasPermission(permission)) {
|
return if (!kp.hasPermission(permission)) {
|
||||||
false
|
false
|
||||||
} else kingdom.hasAttribute(land.kingdom, KingdomRelation.Attribute.BUILD)
|
} else kingdom.hasAttribute(land.kingdom, StandardRelationAttribute.BUILD)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun canCreateExplosion(
|
override fun canCreateExplosion(
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.willfp.eco.internal.spigot.integrations.customitems
|
||||||
|
|
||||||
|
import com.willfp.eco.core.integrations.customitems.CustomItemsIntegration
|
||||||
|
import com.willfp.eco.core.items.CustomItem
|
||||||
|
import com.willfp.eco.core.items.Items
|
||||||
|
import com.willfp.eco.core.items.TestableItem
|
||||||
|
import com.willfp.eco.core.items.provider.ItemProvider
|
||||||
|
import com.willfp.eco.util.NamespacedKeyUtils
|
||||||
|
import dev.norska.scyther.Scyther
|
||||||
|
import dev.norska.scyther.api.ScytherAPI
|
||||||
|
import org.bukkit.Material
|
||||||
|
|
||||||
|
class CustomItemsScyther : CustomItemsIntegration {
|
||||||
|
override fun registerProvider() {
|
||||||
|
Items.registerItemProvider(ScytherProvider())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getPluginName(): String {
|
||||||
|
return "Scyther"
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ScytherProvider : ItemProvider("scyther") {
|
||||||
|
override fun provideForKey(key: String): TestableItem? {
|
||||||
|
val material = Material.matchMaterial(key.uppercase()) ?: Material.WOODEN_HOE
|
||||||
|
|
||||||
|
val hoe = ScytherAPI.createHarvesterHoe(
|
||||||
|
Scyther.getInstance(),
|
||||||
|
material,
|
||||||
|
0,
|
||||||
|
1.0,
|
||||||
|
1,
|
||||||
|
Int.MAX_VALUE,
|
||||||
|
"AUTOSELL",
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
|
val namespacedKey = NamespacedKeyUtils.create("scyther", key)
|
||||||
|
|
||||||
|
return CustomItem(
|
||||||
|
namespacedKey,
|
||||||
|
{
|
||||||
|
ScytherAPI.isHarvesterItem(it) && it.type == material
|
||||||
|
},
|
||||||
|
hoe
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,16 +2,27 @@ package com.willfp.eco.internal.spigot.integrations.shop
|
|||||||
|
|
||||||
import com.willfp.eco.core.integrations.shop.ShopIntegration
|
import com.willfp.eco.core.integrations.shop.ShopIntegration
|
||||||
import com.willfp.eco.core.integrations.shop.ShopSellEvent
|
import com.willfp.eco.core.integrations.shop.ShopSellEvent
|
||||||
|
import me.gypopo.economyshopgui.api.EconomyShopGUIHook
|
||||||
import me.gypopo.economyshopgui.api.events.PreTransactionEvent
|
import me.gypopo.economyshopgui.api.events.PreTransactionEvent
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.entity.Player
|
||||||
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 ShopEconomyShopGUI : ShopIntegration {
|
class ShopEconomyShopGUI : ShopIntegration {
|
||||||
override fun getSellEventAdapter(): Listener {
|
override fun getSellEventAdapter(): Listener {
|
||||||
return EconomyShopGUISellEventListeners
|
return EconomyShopGUISellEventListeners
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getPrice(itemStack: ItemStack, player: Player): Double {
|
||||||
|
return EconomyShopGUIHook.getItemSellPrice(player, itemStack)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getPrice(itemStack: ItemStack): Double {
|
||||||
|
return EconomyShopGUIHook.getItemSellPrice(itemStack)
|
||||||
|
}
|
||||||
|
|
||||||
object EconomyShopGUISellEventListeners : Listener {
|
object EconomyShopGUISellEventListeners : Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
fun shopEventToEcoEvent(event: PreTransactionEvent) {
|
fun shopEventToEcoEvent(event: PreTransactionEvent) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.brcdev.shopgui.provider.item.ItemProvider
|
|||||||
import net.brcdev.shopgui.shop.ShopManager
|
import net.brcdev.shopgui.shop.ShopManager
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
import org.bukkit.configuration.ConfigurationSection
|
import org.bukkit.configuration.ConfigurationSection
|
||||||
|
import org.bukkit.entity.Player
|
||||||
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
|
import org.bukkit.inventory.ItemStack
|
||||||
@@ -22,6 +23,14 @@ class ShopShopGuiPlus : ShopIntegration {
|
|||||||
return ShopGuiPlusSellEventListeners
|
return ShopGuiPlusSellEventListeners
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getPrice(itemStack: ItemStack): Double {
|
||||||
|
return ShopGuiPlusApi.getItemStackPriceSell(itemStack)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getPrice(itemStack: ItemStack, player: Player): Double {
|
||||||
|
return ShopGuiPlusApi.getItemStackPriceSell(player, itemStack)
|
||||||
|
}
|
||||||
|
|
||||||
class EcoShopGuiPlusProvider : ItemProvider("eco") {
|
class EcoShopGuiPlusProvider : ItemProvider("eco") {
|
||||||
override fun isValidItem(itemStack: ItemStack?): Boolean {
|
override fun isValidItem(itemStack: ItemStack?): Boolean {
|
||||||
itemStack ?: return false
|
itemStack ?: return false
|
||||||
|
|||||||
@@ -47,3 +47,4 @@ softdepend:
|
|||||||
- EconomyShopGUI
|
- EconomyShopGUI
|
||||||
- zShop
|
- zShop
|
||||||
- DeluxeSellwands
|
- DeluxeSellwands
|
||||||
|
- Scyther
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
version = 6.40.2
|
version = 6.42.0
|
||||||
plugin-name = eco
|
plugin-name = eco
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
BIN
lib/FabledSkyblock-2.5.0.jar
Normal file
BIN
lib/FabledSkyblock-2.5.0.jar
Normal file
Binary file not shown.
BIN
lib/KingdomsX-1.14.13-BETA.jar
Normal file
BIN
lib/KingdomsX-1.14.13-BETA.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user