diff --git a/pom.xml b/pom.xml
index a262cd7..e632caf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.craftaro
EpicEnchants
- 2.0.0
+ 2.0.1
EpicEnchants
Unlock the potential of your weapons, tools and armor by making your own custom enchants.
diff --git a/src/main/java/com/craftaro/epicenchants/menus/AlchemistMenu.java b/src/main/java/com/craftaro/epicenchants/menus/AlchemistMenu.java
index ffa16da..2224a19 100644
--- a/src/main/java/com/craftaro/epicenchants/menus/AlchemistMenu.java
+++ b/src/main/java/com/craftaro/epicenchants/menus/AlchemistMenu.java
@@ -8,6 +8,7 @@ import com.craftaro.epicenchants.objects.Group;
import com.craftaro.epicenchants.objects.Placeholder;
import com.craftaro.epicenchants.utils.objects.FastInv;
import com.craftaro.epicenchants.utils.objects.ItemBuilder;
+import com.craftaro.epicenchants.utils.settings.Settings;
import com.craftaro.epicenchants.utils.single.GeneralUtils;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
@@ -202,7 +203,7 @@ public class AlchemistMenu extends FastInv {
NBTItem rightItem = new NBTItem(getInventory().getItem(this.RIGHT_SLOT));
int ecoCost;
int expCost;
-
+ String Mode = Settings.MODE.getString();
if (leftItem.hasTag("book-item")) {
int level = leftItem.getInteger("level");
Enchant enchant = this.instance.getEnchantManager().getValue(leftItem.getString("enchant")).orElseThrow(() -> new IllegalStateException("Book without enchant!"));
@@ -268,18 +269,33 @@ public class AlchemistMenu extends FastInv {
Placeholder.of("eco_cost", ecoCost),
Placeholder.of("exp_cost", expCost)
).build(), event -> {
- if (!EconomyManager.hasBalance(event.getPlayer(), ecoCost) || getExp(event.getPlayer()) < expCost) {
+
+ if (EconomyManager.isEnabled() && Mode.equalsIgnoreCase("ECO") && EconomyManager.getBalance(event.getPlayer()) < ecoCost){
+ this.instance.getLocale().getMessage("alchemist.cannotafford").sendPrefixedMessage(event.getPlayer());
+ return;
+ }
+ if (Mode.equalsIgnoreCase("EXP") && getExp(event.getPlayer()) < expCost) {
this.instance.getLocale().getMessage("alchemist.cannotafford").sendPrefixedMessage(event.getPlayer());
return;
}
- EconomyManager.withdrawBalance(event.getPlayer(), ecoCost);
- changeExp(event.getPlayer(), -expCost);
- this.instance.getLocale().getMessage("alchemist.success")
- .processPlaceholder("eco_cost", ecoCost)
- .processPlaceholder("exp_cost", expCost)
- .sendPrefixedMessage(event.getPlayer());
-
+ switch (Mode.toUpperCase()) {
+ case "ECO":
+ EconomyManager.withdrawBalance(event.getPlayer(), ecoCost);
+ this.instance.getLocale().getMessage("alchemist.successeco")
+ .processPlaceholder("eco_cost", ecoCost)
+ .sendPrefixedMessage(event.getPlayer());
+ break;
+ case "EXP":
+ changeExp(event.getPlayer(), -expCost);
+ this.instance.getLocale().getMessage("alchemist.successexp")
+ .processPlaceholder("exp_cost", expCost)
+ .sendPrefixedMessage(event.getPlayer());
+ break;
+ default:
+ System.out.println("Wrong MODE value detected. Use ECO or EXP.");
+ break;
+ }
event.getPlayer().getInventory().addItem(getInventory().getItem(this.PREVIEW_SLOT));
clear(this.RIGHT_SLOT);
clear(this.LEFT_SLOT);
diff --git a/src/main/java/com/craftaro/epicenchants/menus/EnchanterMenu.java b/src/main/java/com/craftaro/epicenchants/menus/EnchanterMenu.java
index b0a466f..01b9175 100644
--- a/src/main/java/com/craftaro/epicenchants/menus/EnchanterMenu.java
+++ b/src/main/java/com/craftaro/epicenchants/menus/EnchanterMenu.java
@@ -1,11 +1,14 @@
package com.craftaro.epicenchants.menus;
+import com.craftaro.core.configuration.Config;
import com.craftaro.core.hooks.EconomyManager;
import com.craftaro.epicenchants.EpicEnchants;
import com.craftaro.epicenchants.objects.Group;
import com.craftaro.epicenchants.objects.Placeholder;
import com.craftaro.epicenchants.utils.objects.FastInv;
import com.craftaro.epicenchants.utils.objects.ItemBuilder;
+import com.craftaro.epicenchants.utils.settings.Settings;
+import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -28,7 +31,7 @@ public class EnchanterMenu extends FastInv {
if (config.isConfigurationSection("fill")) {
fill(new ItemBuilder(config.getConfigurationSection("fill")).build());
}
-
+ String Mode = Settings.MODE.getString();
config.getConfigurationSection("contents").getKeys(false)
.stream()
.map(s -> "contents." + s)
@@ -39,7 +42,7 @@ public class EnchanterMenu extends FastInv {
int ecoCost = section.getInt("eco-cost");
int xpLeft = Math.max(expCost - player.getLevel(), 0);
double ecoLeft = 0.0d;
- if (EconomyManager.isEnabled())
+ if (EconomyManager.isEnabled() && Mode.equalsIgnoreCase("ECO"))
ecoLeft = ecoCost - EconomyManager.getBalance(player) < 0 ? 0 : ecoCost - EconomyManager.getBalance(player);
Group group = instance.getGroupManager().getValue(section.getString("group").toUpperCase())
.orElseThrow(() -> new IllegalArgumentException("Invalid group set in enchanter: " + section.getString("group")));
@@ -50,27 +53,40 @@ public class EnchanterMenu extends FastInv {
Placeholder.of("eco_left", ecoLeft)).build();
addItem(getSlots(section.getString("slot")), itemStack, event -> {
- // Todo: wanna change this
if (this.delay.getOrDefault(player.getUniqueId(), 0L) > System.currentTimeMillis()) {
return;
}
- if (EconomyManager.isEnabled() && !EconomyManager.hasBalance((player), ecoCost) || getExp(player) < expCost) {
+ if (EconomyManager.isEnabled() && Mode.equalsIgnoreCase("ECO") && EconomyManager.getBalance(player) < ecoCost) {
instance.getLocale().getMessage("enchanter.cannotafford").sendPrefixedMessage(player);
return;
}
- if (EconomyManager.isEnabled()) {
- EconomyManager.withdrawBalance(player, ecoCost);
- event.getPlayer().sendMessage(instance.getLocale().getMessage("enchanter.success")
- .processPlaceholder("group_name", group.getName())
- .processPlaceholder("group_color", group.getColor())
- .processPlaceholder("eco_cost", ecoCost)
- .processPlaceholder("exp_cost", expCost)
- .getPrefixedMessage());
+ if (Mode.equalsIgnoreCase("EXP") && getExp(player) < expCost) {
+ instance.getLocale().getMessage("enchanter.cannotafford").sendPrefixedMessage(player);
+ return;
+ }
+ switch (Mode.toUpperCase()) {
+ case "ECO":
+ EconomyManager.withdrawBalance(player, ecoCost);
+ event.getPlayer().sendMessage(instance.getLocale().getMessage("enchanter.successeco")
+ .processPlaceholder("group_name", group.getName())
+ .processPlaceholder("group_color", group.getColor())
+ .processPlaceholder("eco_cost", ecoCost)
+ .getPrefixedMessage());
+ break;
+ case "EXP":
+ changeExp(player, -expCost);
+ event.getPlayer().sendMessage(instance.getLocale().getMessage("enchanter.successexp")
+ .processPlaceholder("group_name", group.getName())
+ .processPlaceholder("group_color", group.getColor())
+ .processPlaceholder("exp_cost", expCost)
+ .getPrefixedMessage());
+ break;
+ default:
+ System.out.println("Wrong MODE value detected. Use ECO or EXP.");
+ break;
}
-
- changeExp(player, -expCost);
player.getInventory().addItem(instance.getSpecialItems().getMysteryBook(group));
this.delay.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + 120);
});
diff --git a/src/main/java/com/craftaro/epicenchants/utils/settings/Settings.java b/src/main/java/com/craftaro/epicenchants/utils/settings/Settings.java
index b48ea7d..70be061 100644
--- a/src/main/java/com/craftaro/epicenchants/utils/settings/Settings.java
+++ b/src/main/java/com/craftaro/epicenchants/utils/settings/Settings.java
@@ -14,6 +14,7 @@ public class Settings {
public static final ConfigSetting BLACK_MIN = new ConfigSetting(CONFIG, "Main.Black Scroll Min", 20);
public static final ConfigSetting BLACK_MAX = new ConfigSetting(CONFIG, "Main.Black Scroll Max", 100);
+ public static final ConfigSetting MODE = new ConfigSetting(CONFIG, "Main.Mode", "EXP", "Can be ECO or EXP");
public static final ConfigSetting ECONOMY_PLUGIN = new ConfigSetting(CONFIG, "Main.Economy", EconomyManager.getEconomy() == null ? "Vault" : EconomyManager.getEconomy().getName(),
"Which economy plugin should be used?",
diff --git a/src/main/resources/en_US.lang b/src/main/resources/en_US.lang
index af71e39..74420bb 100644
--- a/src/main/resources/en_US.lang
+++ b/src/main/resources/en_US.lang
@@ -39,7 +39,8 @@ whitescroll:
applied: '&7This item is now protected!'
enchanter:
cannotafford: '&cYou cannot afford this purchase.'
- success: '&7Purchased &6{group_color}{group_name} &7book for &6{exp_cost} experience&7.'
+ successexp: '&7Purchased &6{group_color}{group_name} &7book for &6{exp_cost} experience&7.'
+ successeco: '&7Purchased &6{group_color}{group_name} &7book for &6${eco_cost}&7.'
tinkerer:
open: '&7Trading with the tinkerer.'
cancelled: '&cCancelled.'
@@ -56,7 +57,8 @@ alchemist:
differentlevels: '&cThe alchemist can only combine books of the same level...'
differentgroups: '&cThe alchemist can only combine dust of the same group...'
cannotafford: '&cYou cannot afford this exchange...'
- success: '&7Exchanged for &6{exp_cost} &7experience.'
+ successeco: '&7Exchanged for &6${eco_cost}.'
+ successexp: '&7Exchanged for &6{exp_cost} &7experience.'
enchants:
invalidmaterial: '&cYou can not apply &4{enchant}&r &cto that item...'
failure: '&4{enchant}&r &cfailed to apply...'
diff --git a/src/main/resources/version-dependent/legacy/menus/alchemist-menu.yml b/src/main/resources/version-dependent/legacy/menus/alchemist-menu.yml
index 1e50b6b..ca7a8c8 100644
--- a/src/main/resources/version-dependent/legacy/menus/alchemist-menu.yml
+++ b/src/main/resources/version-dependent/legacy/menus/alchemist-menu.yml
@@ -14,12 +14,12 @@ accept-slot: 31
book:
success-rate-formula: "({left_success_rate} + {right_success_rate}) / 4"
destroy-rate-formula: "({left_destroy_rate} + {right_destroy_rate}) / 4 + {max_destroy_rate}"
- eco-cost-formula: "0"
+ eco-cost-formula: "({group_order_index} + 1) * {final_success_rate} * 4"
exp-cost-formula: "({group_order_index} + 1) * {final_success_rate}"
dust:
percentage-formula: "({left_percentage} + {right_percentage}) / 2"
- eco-cost-formula: "0"
+ eco-cost-formula: "({group_order_index} + 1) * {final_success_rate} * 4"
exp-cost-formula: "({group_order_index} + 1) * {final_success_rate}"
contents:
@@ -37,14 +37,14 @@ contents:
display-name: "&cWaiting for you..."
lore:
- "&7The alchemist is waiting"
- - "&7for your enchange..."
+ - "&7for your exchange..."
accept-after:
material: INK_SACK
data: 10
display-name: "&eClick to confirm"
lore:
- "&cCost: {exp_cost} EXP"
- - ""
+ - "&cCost: ${eco_cost}"
- "&7Click to confirm the exchange"
- "&7after which you will receive"
- "&7the item displayed above."
@@ -73,4 +73,4 @@ contents:
material: STAINED_GLASS_PANE
data: 3
display-name: "&r"
- slot: "2,3,5,6,18,26,38,39,40,41,42"
\ No newline at end of file
+ slot: "2,3,5,6,18,26,38,39,40,41,42"
diff --git a/src/main/resources/version-dependent/legacy/menus/enchanter-menu.yml b/src/main/resources/version-dependent/legacy/menus/enchanter-menu.yml
index 6727e3d..c808ba4 100644
--- a/src/main/resources/version-dependent/legacy/menus/enchanter-menu.yml
+++ b/src/main/resources/version-dependent/legacy/menus/enchanter-menu.yml
@@ -19,6 +19,7 @@ contents:
- "&fof possible enchants you could unlock!"
- ""
- "&b&lCOST &r&f{exp_cost} EXP"
+ - "&b&lCOST &r&f${eco_cost}"
group: SIMPLE
exp-cost: 400
eco-cost: 0
@@ -35,6 +36,7 @@ contents:
- "&fof possible enchants you could unlock!"
- ""
- "&b&lCOST &r&f{exp_cost} EXP"
+ - "&b&lCOST &r&f${eco_cost}"
group: UNIQUE
exp-cost: 800
eco-cost: 0
@@ -51,6 +53,7 @@ contents:
- "&fof possible enchants you could unlock!"
- ""
- "&b&lCOST &r&f{exp_cost} EXP"
+ - "&b&lCOST &r&f${eco_cost}"
group: ELITE
exp-cost: 2500
eco-cost: 0
@@ -67,6 +70,7 @@ contents:
- "&fof possible enchants you could unlock!"
- ""
- "&b&lCOST &r&f{exp_cost} EXP"
+ - "&b&lCOST &r&f${eco_cost}"
group: ULTIMATE
exp-cost: 5000
eco-cost: 0
@@ -83,6 +87,7 @@ contents:
- "&fof possible enchants you could unlock!"
- ""
- "&b&lCOST &r&f{exp_cost} EXP"
+ - "&b&lCOST &r&f${eco_cost}"
group: LEGENDARY
exp-cost: 25000
eco-cost: 0