diff --git a/pom.xml b/pom.xml
index 5781038..13b5f53 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.artillexstudios
AxTrade
- 1.9.0
+ 1.10.0
jar
AxTrade
diff --git a/src/main/java/com/artillexstudios/axtrade/AxTrade.java b/src/main/java/com/artillexstudios/axtrade/AxTrade.java
index d852bcf..08a007e 100644
--- a/src/main/java/com/artillexstudios/axtrade/AxTrade.java
+++ b/src/main/java/com/artillexstudios/axtrade/AxTrade.java
@@ -31,6 +31,7 @@ public final class AxTrade extends AxPlugin {
public static Config LANG;
public static Config GUIS;
public static Config HOOKS;
+ public static Config TOGGLED;
public static MessageUtils MESSAGEUTILS;
private static AxPlugin instance;
private static ThreadedQueue threadedQueue;
@@ -55,6 +56,7 @@ public final class AxTrade extends AxPlugin {
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());
+ TOGGLED = new Config(new File(getDataFolder(), "toggled.yml"), getResource("toggled.yml"), GeneralSettings.builder().setUseDefaults(false).build(), LoaderSettings.DEFAULT, DumperSettings.DEFAULT, UpdaterSettings.DEFAULT);
LanguageManager.reload();
diff --git a/src/main/java/com/artillexstudios/axtrade/commands/Commands.java b/src/main/java/com/artillexstudios/axtrade/commands/Commands.java
index 140538a..7c07e83 100644
--- a/src/main/java/com/artillexstudios/axtrade/commands/Commands.java
+++ b/src/main/java/com/artillexstudios/axtrade/commands/Commands.java
@@ -35,6 +35,7 @@ import static com.artillexstudios.axtrade.AxTrade.GUIS;
import static com.artillexstudios.axtrade.AxTrade.HOOKS;
import static com.artillexstudios.axtrade.AxTrade.LANG;
import static com.artillexstudios.axtrade.AxTrade.MESSAGEUTILS;
+import static com.artillexstudios.axtrade.AxTrade.TOGGLED;
@CommandPermission(value = "axtrade.trade")
public class Commands implements OrphanCommand {
@@ -87,6 +88,20 @@ public class Commands implements OrphanCommand {
SoundUtils.playSound(request.getReceiver(), "deny");
}
+ @CommandPermission("axtrade.toggle")
+ @Subcommand("toggle")
+ public void toggle(@NotNull Player sender) {
+ boolean toggled = TOGGLED.getBoolean("toggled." + sender.getUniqueId(), false);
+ if (toggled) {
+ TOGGLED.getBackingDocument().remove("toggled." + sender.getUniqueId());
+ MESSAGEUTILS.sendLang(sender, "toggle.enabled");
+ } else {
+ TOGGLED.set("toggled." + sender.getUniqueId(), true);
+ MESSAGEUTILS.sendLang(sender, "toggle.disabled");
+ }
+ TOGGLED.save();
+ }
+
@Subcommand("reload")
@CommandPermission(value = "axtrade.admin")
public void reload(@NotNull CommandSender sender) {
diff --git a/src/main/java/com/artillexstudios/axtrade/hooks/currency/CoinsEngineHook.java b/src/main/java/com/artillexstudios/axtrade/hooks/currency/CoinsEngineHook.java
index a841626..f51a749 100644
--- a/src/main/java/com/artillexstudios/axtrade/hooks/currency/CoinsEngineHook.java
+++ b/src/main/java/com/artillexstudios/axtrade/hooks/currency/CoinsEngineHook.java
@@ -22,7 +22,7 @@ public class CoinsEngineHook implements CurrencyHook {
public void setup() {
currency = CoinsEngineAPI.getCurrency(internal);
if (currency == null) {
- Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("FF0000[AxAuctions] CoinsEngine currency named DD0000" + internal + " FF0000not found! Change the currency-name or disable the hook to get rid of this warning!"));
+ Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("FF0000[AxTrade] CoinsEngine currency named DD0000" + internal + " FF0000not found! Change the currency-name or disable the hook to get rid of this warning!"));
}
}
diff --git a/src/main/java/com/artillexstudios/axtrade/hooks/currency/EcoBitsHook.java b/src/main/java/com/artillexstudios/axtrade/hooks/currency/EcoBitsHook.java
index cc84bdb..d500482 100644
--- a/src/main/java/com/artillexstudios/axtrade/hooks/currency/EcoBitsHook.java
+++ b/src/main/java/com/artillexstudios/axtrade/hooks/currency/EcoBitsHook.java
@@ -24,7 +24,7 @@ public class EcoBitsHook implements CurrencyHook {
public void setup() {
currency = Currencies.getByID(internal);
if (currency == null) {
- Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("FF0000[AxAuctions] EcoBits currency named DD0000" + internal + " FF0000not found! Change the currency-name or disable the hook to get rid of this warning!"));
+ Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("FF0000[AxTrade] EcoBits currency named DD0000" + internal + " FF0000not found! Change the currency-name or disable the hook to get rid of this warning!"));
}
}
diff --git a/src/main/java/com/artillexstudios/axtrade/hooks/currency/RedisEconomyHook.java b/src/main/java/com/artillexstudios/axtrade/hooks/currency/RedisEconomyHook.java
index e5842e4..a54d32e 100644
--- a/src/main/java/com/artillexstudios/axtrade/hooks/currency/RedisEconomyHook.java
+++ b/src/main/java/com/artillexstudios/axtrade/hooks/currency/RedisEconomyHook.java
@@ -23,7 +23,7 @@ public class RedisEconomyHook implements CurrencyHook {
RedisEconomyAPI api = RedisEconomyAPI.getAPI();
currency = api.getCurrencyByName(internal);
if (currency == null) {
- Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("FF0000[AxAuctions] RedisEconomy currency named DD0000" + internal + " FF0000not found! Change the currency-name or disable the hook to get rid of this warning!"));
+ Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("FF0000[AxTrade] RedisEconomy currency named DD0000" + internal + " FF0000not found! Change the currency-name or disable the hook to get rid of this warning!"));
}
}
diff --git a/src/main/java/com/artillexstudios/axtrade/hooks/currency/UltraEconomyHook.java b/src/main/java/com/artillexstudios/axtrade/hooks/currency/UltraEconomyHook.java
index 18c7d0c..6dda1ca 100644
--- a/src/main/java/com/artillexstudios/axtrade/hooks/currency/UltraEconomyHook.java
+++ b/src/main/java/com/artillexstudios/axtrade/hooks/currency/UltraEconomyHook.java
@@ -24,7 +24,7 @@ public class UltraEconomyHook implements CurrencyHook {
public void setup() {
final Optional currencyOptional = UltraEconomy.getAPI().getCurrencies().name(internal);
if (currencyOptional.isEmpty()) {
- Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("FF0000[AxAuctions] UltraEconomy currency named DD0000" + internal + " FF0000not found! Change the currency-name or disable the hook to get rid of this warning!"));
+ Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("FF0000[AxTrade] UltraEconomy currency named DD0000" + internal + " FF0000not found! Change the currency-name or disable the hook to get rid of this warning!"));
return;
}
currency = currencyOptional.get();
diff --git a/src/main/java/com/artillexstudios/axtrade/request/Requests.java b/src/main/java/com/artillexstudios/axtrade/request/Requests.java
index b1b0f0b..6794ba7 100644
--- a/src/main/java/com/artillexstudios/axtrade/request/Requests.java
+++ b/src/main/java/com/artillexstudios/axtrade/request/Requests.java
@@ -18,6 +18,7 @@ import java.util.Map;
import static com.artillexstudios.axtrade.AxTrade.CONFIG;
import static com.artillexstudios.axtrade.AxTrade.LANG;
import static com.artillexstudios.axtrade.AxTrade.MESSAGEUTILS;
+import static com.artillexstudios.axtrade.AxTrade.TOGGLED;
public class Requests {
private static final ArrayList requests = new ArrayList<>();
@@ -42,6 +43,16 @@ public class Requests {
return;
}
+ if (TOGGLED.getBoolean("toggled." + receiver.getUniqueId())) {
+ MESSAGEUTILS.sendLang(sender, "request.not-accepting", replacements);
+ return;
+ }
+
+ if (TOGGLED.getBoolean("toggled." + sender.getUniqueId())) {
+ MESSAGEUTILS.sendLang(sender, "request.disabled-trading", replacements);
+ return;
+ }
+
if (sender.equals(receiver)) {
MESSAGEUTILS.sendLang(sender, "request.cant-trade-self", replacements);
return;
diff --git a/src/main/java/com/artillexstudios/axtrade/trade/TradeGui.java b/src/main/java/com/artillexstudios/axtrade/trade/TradeGui.java
index 5fc3f9d..cd76242 100644
--- a/src/main/java/com/artillexstudios/axtrade/trade/TradeGui.java
+++ b/src/main/java/com/artillexstudios/axtrade/trade/TradeGui.java
@@ -4,7 +4,6 @@ import com.artillexstudios.axapi.gui.SignInput;
import com.artillexstudios.axapi.nms.NMSHandlers;
import com.artillexstudios.axapi.scheduler.ScheduledTask;
import com.artillexstudios.axapi.scheduler.Scheduler;
-import com.artillexstudios.axapi.utils.Pair;
import com.artillexstudios.axapi.utils.StringUtils;
import com.artillexstudios.axtrade.utils.BlackListUtils;
import com.artillexstudios.axtrade.utils.NumberUtils;
@@ -151,6 +150,8 @@ public class TradeGui extends GuiFrame {
trade.abort();
});
+ if (trade.ended) return;
+
update();
gui.open(player.getPlayer());
updateTitle();
diff --git a/src/main/resources/lang.yml b/src/main/resources/lang.yml
index 8e418c0..35a4521 100644
--- a/src/main/resources/lang.yml
+++ b/src/main/resources/lang.yml
@@ -28,6 +28,10 @@ trade:
aborted: "CCFFEEYour trade with FFDD%player% CCFFEEwas aborted!"
blacklisted-item: "CCFFEEThis item is blacklisted!"
+toggle:
+ enabled: "CCFFEEYou have enabled trade requests!"
+ disabled: "CCFFEEYou have disabled trade requests!"
+
# summary after a successful trade
summary:
get:
@@ -59,10 +63,11 @@ request:
already-in-trade: "CCFFEEThe player is already trading with someone!"
already-sent: "CCFFEEYou have already sent a trade request to FFDD%player% CCFFEErecently!"
too-far: "CCFFEEYou are too far from FFDD%player% CCFFEEto send a trade request!"
- not-accepting: "CCFFEEThis player is not accepting trades right now!"
+ not-accepting: "CCFFEEThis player is not accepting trades!"
disallowed-gamemode: "CCFFEEEither you or the other player is in a disallowed gamemode!"
blacklisted-world: "CCFFEETrades are disabled in this world!"
expired: "CCFFEEYour trade request to FFDD%player% CCFFEEhas expired!"
+ disabled-trading: "CCFFEEYou have disabled trades! Use FFDD/trade toggle CCFFEEto enable."
# this must be 4 lines
# note: currently the first line must be left empty
@@ -105,4 +110,4 @@ commands:
update-notifier: "AAFFCCThere is a new version of the plugin available! DDDDDD(FFFFFFcurrent: FF0000%current% DDDDDD| FFFFFFlatest: FF00%latest%DDDDDD)"
# do not change this
-version: 5
\ No newline at end of file
+version: 6
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 067f18a..82b27b9 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -9,6 +9,8 @@ permissions:
default: op
axtrade.trade:
default: true
+ axtrade.toggle:
+ default: true
softdepend:
- AxQuestBoard
diff --git a/src/main/resources/toggled.yml b/src/main/resources/toggled.yml
new file mode 100644
index 0000000..d309f94
--- /dev/null
+++ b/src/main/resources/toggled.yml
@@ -0,0 +1 @@
+toggled: []
\ No newline at end of file