mirror of
https://github.com/songoda/EpicEnchants.git
synced 2024-11-13 06:07:41 +01:00
Fixed compatibility issues on 1.12
This commit is contained in:
parent
03b514551e
commit
bba08bc0fe
@ -81,7 +81,7 @@ public class FileManager extends Manager<String, FileConfiguration> {
|
||||
|
||||
public FileManager(EpicEnchants instance) {
|
||||
super(instance);
|
||||
directory = instance.isServerVersionAtLeast(ServerVersion.V1_12) ? "master" : "legacy";
|
||||
directory = instance.isServerVersionAtLeast(ServerVersion.V1_13) ? "master" : "legacy";
|
||||
Bukkit.getConsoleSender().sendMessage("Using the " + directory + " configurations because version is " + instance.getServerVersion().name());
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,9 @@ public class EnchanterMenu extends FastInv {
|
||||
int expCost = section.getInt("exp-cost");
|
||||
int ecoCost = section.getInt("eco-cost");
|
||||
int xpLeft = Math.max(expCost - player.getLevel(), 0);
|
||||
double ecoLeft = ecoCost - instance.getEconomy().getBalance(player) < 0 ? 0 : ecoCost - instance.getEconomy().getBalance(player);
|
||||
double ecoLeft = 0.0d;
|
||||
if (instance.getEconomy() != null)
|
||||
ecoLeft = ecoCost - instance.getEconomy().getBalance(player) < 0 ? 0 : ecoCost - instance.getEconomy().getBalance(player);
|
||||
Group group = instance.getGroupManager().getValue(section.getString("group").toUpperCase())
|
||||
.orElseThrow(() -> new IllegalArgumentException("Invalid group set in enchanter: " + section.getString("group")));
|
||||
ItemStack itemStack = new ItemBuilder(section,
|
||||
@ -50,18 +52,20 @@ public class EnchanterMenu extends FastInv {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!instance.getEconomy().hasBalance((player), ecoCost) || getExp(player) < expCost) {
|
||||
if (instance.getEconomy() != null && !instance.getEconomy().hasBalance((player), ecoCost) || getExp(player) < expCost) {
|
||||
instance.getLocale().getMessage("enchanter.cannotafford").sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
|
||||
instance.getEconomy().withdrawBalance(player, ecoCost);
|
||||
instance.getLocale().getMessage("enchanter.success")
|
||||
.processPlaceholder("group_name", group.getName())
|
||||
.processPlaceholder("group_color", group.getColor())
|
||||
.processPlaceholder("eco_cost", ecoCost)
|
||||
.processPlaceholder("exp_cost", expCost)
|
||||
.sendPrefixedMessage(player);
|
||||
if (instance.getEconomy() != null) {
|
||||
instance.getEconomy().withdrawBalance(player, ecoCost);
|
||||
instance.getLocale().getMessage("enchanter.success")
|
||||
.processPlaceholder("group_name", group.getName())
|
||||
.processPlaceholder("group_color", group.getColor())
|
||||
.processPlaceholder("eco_cost", ecoCost)
|
||||
.processPlaceholder("exp_cost", expCost)
|
||||
.sendPrefixedMessage(player);
|
||||
}
|
||||
|
||||
changeExp(player, -expCost);
|
||||
player.getInventory().addItem(instance.getSpecialItems().getMysteryBook(group));
|
||||
|
@ -19,7 +19,7 @@ public class ItemGroup {
|
||||
|
||||
public ItemGroup(EpicEnchants instance) {
|
||||
groupMap = HashMultimap.create();
|
||||
if (instance.isServerVersionAtLeast(ServerVersion.V1_12)) setupMaster();
|
||||
if (instance.isServerVersionAtLeast(ServerVersion.V1_13)) setupMaster();
|
||||
else setupLegacy();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user