mirror of
https://github.com/Artillex-Studios/AxTrade.git
synced 2025-01-06 19:09:20 +01:00
1.10.1
This commit is contained in:
parent
f71a500f01
commit
993b9a01cd
4
pom.xml
4
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.artillexstudios</groupId>
|
<groupId>com.artillexstudios</groupId>
|
||||||
<artifactId>AxTrade</artifactId>
|
<artifactId>AxTrade</artifactId>
|
||||||
<version>1.10.0</version>
|
<version>1.10.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>AxTrade</name>
|
<name>AxTrade</name>
|
||||||
@ -116,7 +116,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.artillexstudios.axapi</groupId>
|
<groupId>com.artillexstudios.axapi</groupId>
|
||||||
<artifactId>axapi</artifactId>
|
<artifactId>axapi</artifactId>
|
||||||
<version>1.4.396</version>
|
<version>1.4.403</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<classifier>all</classifier>
|
<classifier>all</classifier>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -12,7 +12,6 @@ import com.artillexstudios.axapi.utils.FeatureFlags;
|
|||||||
import com.artillexstudios.axapi.utils.MessageUtils;
|
import com.artillexstudios.axapi.utils.MessageUtils;
|
||||||
import com.artillexstudios.axapi.utils.StringUtils;
|
import com.artillexstudios.axapi.utils.StringUtils;
|
||||||
import com.artillexstudios.axtrade.commands.Commands;
|
import com.artillexstudios.axtrade.commands.Commands;
|
||||||
import com.artillexstudios.axtrade.currencyconverter.CurrencyConverter;
|
|
||||||
import com.artillexstudios.axtrade.hooks.HookManager;
|
import com.artillexstudios.axtrade.hooks.HookManager;
|
||||||
import com.artillexstudios.axtrade.lang.LanguageManager;
|
import com.artillexstudios.axtrade.lang.LanguageManager;
|
||||||
import com.artillexstudios.axtrade.listeners.EntityInteractListener;
|
import com.artillexstudios.axtrade.listeners.EntityInteractListener;
|
||||||
@ -54,7 +53,6 @@ public final class AxTrade extends AxPlugin {
|
|||||||
CONFIG = new Config(new File(getDataFolder(), "config.yml"), getResource("config.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setKeepAll(true).setVersioning(new BasicVersioning("version")).build());
|
CONFIG = new Config(new File(getDataFolder(), "config.yml"), getResource("config.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setKeepAll(true).setVersioning(new BasicVersioning("version")).build());
|
||||||
GUIS = new Config(new File(getDataFolder(), "guis.yml"), getResource("guis.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setKeepAll(true).setVersioning(new BasicVersioning("version")).build());
|
GUIS = new Config(new File(getDataFolder(), "guis.yml"), getResource("guis.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setKeepAll(true).setVersioning(new BasicVersioning("version")).build());
|
||||||
LANG = new Config(new File(getDataFolder(), "lang.yml"), getResource("lang.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setKeepAll(true).setVersioning(new BasicVersioning("version")).build());
|
LANG = new Config(new File(getDataFolder(), "lang.yml"), getResource("lang.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setKeepAll(true).setVersioning(new BasicVersioning("version")).build());
|
||||||
new CurrencyConverter(new Config(new File(getDataFolder(), "currencies.yml")));
|
|
||||||
HOOKS = new Config(new File(getDataFolder(), "currencies.yml"), getResource("currencies.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setKeepAll(true).setVersioning(new BasicVersioning("version")).build());
|
HOOKS = new Config(new File(getDataFolder(), "currencies.yml"), getResource("currencies.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setKeepAll(true).setVersioning(new BasicVersioning("version")).build());
|
||||||
TOGGLED = new Config(new File(getDataFolder(), "toggled.yml"), getResource("toggled.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.DEFAULT, DumperSettings.DEFAULT, UpdaterSettings.DEFAULT);
|
TOGGLED = new Config(new File(getDataFolder(), "toggled.yml"), getResource("toggled.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.DEFAULT, DumperSettings.DEFAULT, UpdaterSettings.DEFAULT);
|
||||||
|
|
||||||
@ -69,10 +67,10 @@ public final class AxTrade extends AxPlugin {
|
|||||||
getServer().getPluginManager().registerEvents(new EntityInteractListener(), this);
|
getServer().getPluginManager().registerEvents(new EntityInteractListener(), this);
|
||||||
getServer().getPluginManager().registerEvents(new TradeListeners(), this);
|
getServer().getPluginManager().registerEvents(new TradeListeners(), this);
|
||||||
|
|
||||||
new HookManager().setupHooks();
|
HookManager.setupHooks();
|
||||||
NumberUtils.reload();
|
NumberUtils.reload();
|
||||||
|
|
||||||
new TradeTicker().start();
|
TradeTicker.start();
|
||||||
|
|
||||||
Commands.registerCommand();
|
Commands.registerCommand();
|
||||||
|
|
||||||
|
@ -1,4 +1,13 @@
|
|||||||
package com.artillexstudios.axtrade.api;
|
package com.artillexstudios.axtrade.api;
|
||||||
|
|
||||||
|
import com.artillexstudios.axtrade.hooks.HookManager;
|
||||||
|
import com.artillexstudios.axtrade.hooks.currency.CurrencyHook;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class AxTradeAPI {
|
public class AxTradeAPI {
|
||||||
|
|
||||||
|
public static void registerCurrencyHook(@NotNull Plugin plugin, @NotNull CurrencyHook currencyHook) {
|
||||||
|
HookManager.registerCurrencyHook(plugin, currencyHook);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,5 +44,4 @@ public class AxTradeRequestEvent extends Event implements Cancellable {
|
|||||||
public Player getReceiver() {
|
public Player getReceiver() {
|
||||||
return receiver;
|
return receiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,40 +0,0 @@
|
|||||||
package com.artillexstudios.axtrade.currencyconverter;
|
|
||||||
|
|
||||||
import com.artillexstudios.axapi.config.Config;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CurrencyConverter {
|
|
||||||
|
|
||||||
public CurrencyConverter(Config config) {
|
|
||||||
if (config.getString("currencies.CoinsEngine.currency-name", null) == null) return;
|
|
||||||
|
|
||||||
final List<Map<String, String>> coinsEngine = new ArrayList<>();
|
|
||||||
|
|
||||||
coinsEngine.add(Map.of(
|
|
||||||
"currency-name", config.getString("currencies.CoinsEngine.currency-name", "coins"),
|
|
||||||
"name", config.getString("currencies.CoinsEngine.name", "coins")
|
|
||||||
));
|
|
||||||
|
|
||||||
config.set("currencies.CoinsEngine.enabled", coinsEngine);
|
|
||||||
|
|
||||||
config.getBackingDocument().remove("currencies.CoinsEngine.currency-name");
|
|
||||||
config.getBackingDocument().remove("currencies.CoinsEngine.name");
|
|
||||||
|
|
||||||
final List<Map<String, String>> ultraEconomy = new ArrayList<>();
|
|
||||||
|
|
||||||
ultraEconomy.add(Map.of(
|
|
||||||
"currency-name", config.getString("currencies.UltraEconomy.currency-name", "coins"),
|
|
||||||
"name", config.getString("currencies.UltraEconomy.name", "coins")
|
|
||||||
));
|
|
||||||
|
|
||||||
config.set("currencies.UltraEconomy.enabled", ultraEconomy);
|
|
||||||
|
|
||||||
config.getBackingDocument().remove("currencies.UltraEconomy.currency-name");
|
|
||||||
config.getBackingDocument().remove("currencies.UltraEconomy.name");
|
|
||||||
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
}
|
|
@ -31,11 +31,11 @@ import static com.artillexstudios.axtrade.AxTrade.HOOKS;
|
|||||||
public class HookManager {
|
public class HookManager {
|
||||||
private static final ArrayList<CurrencyHook> currency = new ArrayList<>();
|
private static final ArrayList<CurrencyHook> currency = new ArrayList<>();
|
||||||
|
|
||||||
public void setupHooks() {
|
public static void setupHooks() {
|
||||||
updateHooks();
|
updateHooks();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateHooks() {
|
public static void updateHooks() {
|
||||||
currency.removeIf(currencyHook -> !currencyHook.isPersistent());
|
currency.removeIf(currencyHook -> !currencyHook.isPersistent());
|
||||||
|
|
||||||
if (HOOKS.getBoolean("currencies.Experience.register", true))
|
if (HOOKS.getBoolean("currencies.Experience.register", true))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.artillexstudios.axtrade.listeners;
|
package com.artillexstudios.axtrade.listeners;
|
||||||
|
|
||||||
import com.artillexstudios.axtrade.commands.Commands;
|
import com.artillexstudios.axtrade.request.Requests;
|
||||||
import org.bukkit.entity.Player;
|
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;
|
||||||
@ -15,7 +15,7 @@ public class EntityInteractListener implements Listener {
|
|||||||
private static final HashMap<Player, Long> cd = new HashMap<>();
|
private static final HashMap<Player, Long> cd = new HashMap<>();
|
||||||
|
|
||||||
@EventHandler (ignoreCancelled = true)
|
@EventHandler (ignoreCancelled = true)
|
||||||
public void onClick(@NotNull PlayerInteractEntityEvent event) {
|
public void onInteract(@NotNull PlayerInteractEntityEvent event) {
|
||||||
if (!CONFIG.getBoolean("shift-click-send-request", true)) return;
|
if (!CONFIG.getBoolean("shift-click-send-request", true)) return;
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (!player.hasPermission("axtrade.trade")) return;
|
if (!player.hasPermission("axtrade.trade")) return;
|
||||||
@ -28,7 +28,7 @@ public class EntityInteractListener implements Listener {
|
|||||||
cd.put(player, System.currentTimeMillis());
|
cd.put(player, System.currentTimeMillis());
|
||||||
if (!sendTo.isOnline()) return;
|
if (!sendTo.isOnline()) return;
|
||||||
|
|
||||||
new Commands().trade(player, sendTo);
|
Requests.addRequest(player, sendTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onQuit(Player player) {
|
public static void onQuit(Player player) {
|
||||||
|
@ -20,7 +20,7 @@ import static com.artillexstudios.axtrade.AxTrade.MESSAGEUTILS;
|
|||||||
public class Trade {
|
public class Trade {
|
||||||
protected final TradePlayer player1;
|
protected final TradePlayer player1;
|
||||||
protected final TradePlayer player2;
|
protected final TradePlayer player2;
|
||||||
protected boolean ended = false;
|
private boolean ended = false;
|
||||||
protected long prepTime = System.currentTimeMillis();
|
protected long prepTime = System.currentTimeMillis();
|
||||||
|
|
||||||
public Trade(Player p1, Player p2) {
|
public Trade(Player p1, Player p2) {
|
||||||
@ -163,4 +163,8 @@ public class Trade {
|
|||||||
public Player getOtherPlayer(Player player) {
|
public Player getOtherPlayer(Player player) {
|
||||||
return player1.getPlayer().equals(player) ? player2.getPlayer() : player1.getPlayer();
|
return player1.getPlayer().equals(player) ? player2.getPlayer() : player1.getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEnded() {
|
||||||
|
return ended;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package com.artillexstudios.axtrade.trade;
|
|||||||
|
|
||||||
import com.artillexstudios.axapi.gui.SignInput;
|
import com.artillexstudios.axapi.gui.SignInput;
|
||||||
import com.artillexstudios.axapi.nms.NMSHandlers;
|
import com.artillexstudios.axapi.nms.NMSHandlers;
|
||||||
import com.artillexstudios.axapi.scheduler.ScheduledTask;
|
|
||||||
import com.artillexstudios.axapi.scheduler.Scheduler;
|
import com.artillexstudios.axapi.scheduler.Scheduler;
|
||||||
import com.artillexstudios.axapi.utils.StringUtils;
|
import com.artillexstudios.axapi.utils.StringUtils;
|
||||||
import com.artillexstudios.axtrade.utils.BlackListUtils;
|
import com.artillexstudios.axtrade.utils.BlackListUtils;
|
||||||
@ -25,7 +24,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import static com.artillexstudios.axtrade.AxTrade.GUIS;
|
import static com.artillexstudios.axtrade.AxTrade.GUIS;
|
||||||
import static com.artillexstudios.axtrade.AxTrade.LANG;
|
import static com.artillexstudios.axtrade.AxTrade.LANG;
|
||||||
@ -76,16 +74,13 @@ public class TradeGui extends GuiFrame {
|
|||||||
|
|
||||||
final BaseGui shulkerGui = Gui.storage().rows(3).title(StringUtils.format(Utils.getFormattedItemName(event.getCurrentItem()))).disableAllInteractions().create();
|
final BaseGui shulkerGui = Gui.storage().rows(3).title(StringUtils.format(Utils.getFormattedItemName(event.getCurrentItem()))).disableAllInteractions().create();
|
||||||
shulkerGui.getInventory().setContents(ShulkerUtils.getShulkerContents(event.getCurrentItem()));
|
shulkerGui.getInventory().setContents(ShulkerUtils.getShulkerContents(event.getCurrentItem()));
|
||||||
shulkerGui.setCloseGuiAction(shulkerEvent -> Scheduler.get().run(new Consumer<>() {
|
shulkerGui.setCloseGuiAction(e -> Scheduler.get().run(t -> {
|
||||||
@Override
|
if (trade.isEnded()) return;
|
||||||
public void accept(ScheduledTask scheduledTask) {
|
trade.prepTime = System.currentTimeMillis();
|
||||||
if (trade.ended) return;
|
gui.open(player.getPlayer());
|
||||||
trade.prepTime = System.currentTimeMillis();
|
inSign = false;
|
||||||
gui.open(player.getPlayer());
|
trade.update();
|
||||||
inSign = false;
|
updateTitle();
|
||||||
trade.update();
|
|
||||||
updateTitle();
|
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
shulkerGui.open(player.getPlayer());
|
shulkerGui.open(player.getPlayer());
|
||||||
return;
|
return;
|
||||||
@ -150,7 +145,7 @@ public class TradeGui extends GuiFrame {
|
|||||||
trade.abort();
|
trade.abort();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (trade.ended) return;
|
if (trade.isEnded()) return;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
gui.open(player.getPlayer());
|
gui.open(player.getPlayer());
|
||||||
@ -200,7 +195,7 @@ public class TradeGui extends GuiFrame {
|
|||||||
lines.set(0, Component.empty());
|
lines.set(0, Component.empty());
|
||||||
|
|
||||||
var sign = new SignInput.Builder().setLines(lines).setHandler((player1, result) -> {
|
var sign = new SignInput.Builder().setLines(lines).setHandler((player1, result) -> {
|
||||||
if (trade.ended) return;
|
if (trade.isEnded()) return;
|
||||||
trade.prepTime = System.currentTimeMillis();
|
trade.prepTime = System.currentTimeMillis();
|
||||||
String am = PlainTextComponentSerializer.plainText().serialize(result[0]);
|
String am = PlainTextComponentSerializer.plainText().serialize(result[0]);
|
||||||
TradePlayer.Result addResult = player.setCurrency(currencyStr, am);
|
TradePlayer.Result addResult = player.setCurrency(currencyStr, am);
|
||||||
@ -217,6 +212,7 @@ public class TradeGui extends GuiFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Scheduler.get().run(scheduledTask -> {
|
Scheduler.get().run(scheduledTask -> {
|
||||||
|
if (trade.isEnded()) return;
|
||||||
gui.open(player.getPlayer());
|
gui.open(player.getPlayer());
|
||||||
inSign = false;
|
inSign = false;
|
||||||
trade.update();
|
trade.update();
|
||||||
|
@ -12,7 +12,7 @@ import static com.artillexstudios.axtrade.AxTrade.MESSAGEUTILS;
|
|||||||
|
|
||||||
public class TradeTicker {
|
public class TradeTicker {
|
||||||
|
|
||||||
public void start() {
|
public static void start() {
|
||||||
Scheduler.get().runTimer(scheduledTask -> {
|
Scheduler.get().runTimer(scheduledTask -> {
|
||||||
for (Trade trade : Trades.getTrades()) {
|
for (Trade trade : Trades.getTrades()) {
|
||||||
if (!(trade.player1.hasConfirmed() && trade.player2.hasConfirmed())) continue;
|
if (!(trade.player1.hasConfirmed() && trade.player2.hasConfirmed())) continue;
|
||||||
|
@ -13,6 +13,7 @@ public class ShulkerUtils {
|
|||||||
public static ItemStack[] getShulkerContents(@NotNull ItemStack item) {
|
public static ItemStack[] getShulkerContents(@NotNull ItemStack item) {
|
||||||
if (!(item.getItemMeta() instanceof BlockStateMeta meta)) return new ItemStack[0];
|
if (!(item.getItemMeta() instanceof BlockStateMeta meta)) return new ItemStack[0];
|
||||||
if (meta.getBlockState() instanceof ShulkerBox shulker) {
|
if (meta.getBlockState() instanceof ShulkerBox shulker) {
|
||||||
|
// axshulkers viewer compatibility
|
||||||
if (ClassUtils.INSTANCE.classExists("com.artillexstudios.axshulkers.utils.ShulkerUtils") && com.artillexstudios.axshulkers.utils.ShulkerUtils.getShulkerUUID(item) != null) {
|
if (ClassUtils.INSTANCE.classExists("com.artillexstudios.axshulkers.utils.ShulkerUtils") && com.artillexstudios.axshulkers.utils.ShulkerUtils.getShulkerUUID(item) != null) {
|
||||||
return com.artillexstudios.axshulkers.AxShulkers.getDB().getShulker(com.artillexstudios.axshulkers.utils.ShulkerUtils.getShulkerUUID(item));
|
return com.artillexstudios.axshulkers.AxShulkers.getDB().getShulker(com.artillexstudios.axshulkers.utils.ShulkerUtils.getShulkerUUID(item));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user