diff --git a/pom.xml b/pom.xml
index af4dd77..91babab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -97,7 +97,7 @@
org.spigotmc
spigot
- 1.15
+ 1.16.1
provided
diff --git a/src/main/java/com/songoda/ultimaterepairing/UltimateRepairing.java b/src/main/java/com/songoda/ultimaterepairing/UltimateRepairing.java
index 9519be9..707e46d 100644
--- a/src/main/java/com/songoda/ultimaterepairing/UltimateRepairing.java
+++ b/src/main/java/com/songoda/ultimaterepairing/UltimateRepairing.java
@@ -13,7 +13,6 @@ import com.songoda.ultimaterepairing.anvil.UAnvil;
import com.songoda.ultimaterepairing.commands.CommandReload;
import com.songoda.ultimaterepairing.commands.CommandSettings;
import com.songoda.ultimaterepairing.commands.CommandURAnvil;
-import com.songoda.ultimaterepairing.commands.CommandUltimateRepairing;
import com.songoda.ultimaterepairing.handlers.ParticleTask;
import com.songoda.ultimaterepairing.handlers.RepairHandler;
import com.songoda.ultimaterepairing.listeners.BlockListeners;
@@ -73,7 +72,7 @@ public class UltimateRepairing extends SongodaPlugin {
this.repairHandler = new RepairHandler(this, guiManager);
this.commandManager = new CommandManager(this);
- this.commandManager.addCommand(new CommandUltimateRepairing())
+ this.commandManager.addMainCommand("ur")
.addSubCommands(
new CommandReload(),
new CommandSettings(guiManager));
@@ -160,4 +159,8 @@ public class UltimateRepairing extends SongodaPlugin {
public AnvilManager getAnvilManager() {
return anvilManager;
}
+
+ public GuiManager getGuiManager() {
+ return guiManager;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/songoda/ultimaterepairing/anvil/PlayerAnvilData.java b/src/main/java/com/songoda/ultimaterepairing/anvil/PlayerAnvilData.java
index fa67b6b..eba0b09 100644
--- a/src/main/java/com/songoda/ultimaterepairing/anvil/PlayerAnvilData.java
+++ b/src/main/java/com/songoda/ultimaterepairing/anvil/PlayerAnvilData.java
@@ -1,5 +1,6 @@
package com.songoda.ultimaterepairing.anvil;
+import com.songoda.ultimaterepairing.repair.RepairType;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
@@ -78,6 +79,4 @@ public class PlayerAnvilData {
public void setBeingRepaired(boolean beingRepaired) {
this.beingRepaired = beingRepaired;
}
-
- public enum RepairType {ECONOMY, ITEM, XP}
}
\ No newline at end of file
diff --git a/src/main/java/com/songoda/ultimaterepairing/commands/CommandReload.java b/src/main/java/com/songoda/ultimaterepairing/commands/CommandReload.java
index 93e73b9..73cd009 100644
--- a/src/main/java/com/songoda/ultimaterepairing/commands/CommandReload.java
+++ b/src/main/java/com/songoda/ultimaterepairing/commands/CommandReload.java
@@ -30,7 +30,7 @@ public class CommandReload extends AbstractCommand {
@Override
public String getSyntax() {
- return "/ur reload";
+ return "reload";
}
@Override
diff --git a/src/main/java/com/songoda/ultimaterepairing/commands/CommandSettings.java b/src/main/java/com/songoda/ultimaterepairing/commands/CommandSettings.java
index 567874c..76caf54 100644
--- a/src/main/java/com/songoda/ultimaterepairing/commands/CommandSettings.java
+++ b/src/main/java/com/songoda/ultimaterepairing/commands/CommandSettings.java
@@ -35,7 +35,7 @@ public class CommandSettings extends AbstractCommand {
@Override
public String getSyntax() {
- return "/ur settings";
+ return "settings";
}
@Override
diff --git a/src/main/java/com/songoda/ultimaterepairing/commands/CommandUltimateRepairing.java b/src/main/java/com/songoda/ultimaterepairing/commands/CommandUltimateRepairing.java
deleted file mode 100644
index da8619a..0000000
--- a/src/main/java/com/songoda/ultimaterepairing/commands/CommandUltimateRepairing.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.songoda.ultimaterepairing.commands;
-
-import com.songoda.core.commands.AbstractCommand;
-import com.songoda.ultimaterepairing.UltimateRepairing;
-import com.songoda.ultimaterepairing.utils.Methods;
-import java.util.List;
-import org.bukkit.command.CommandSender;
-
-public class CommandUltimateRepairing extends AbstractCommand {
-
- public CommandUltimateRepairing() {
- super(false, "UltimateRepairing");
- }
-
- @Override
- protected ReturnType runCommand(CommandSender sender, String... args) {
- sender.sendMessage("");
- UltimateRepairing instance = UltimateRepairing.getInstance();
- instance.getLocale().newMessage("&7Version " + instance.getDescription().getVersion()
- + " Created with <3 by &5&l&oSongoda").sendPrefixedMessage(sender);
-
- for (AbstractCommand command : instance.getCommandManager().getAllCommands()) {
- if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
- sender.sendMessage(Methods.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
- }
- }
- sender.sendMessage("");
-
- return ReturnType.SUCCESS;
- }
-
- @Override
- protected List onTab(CommandSender cs, String... strings) {
- return null;
- }
-
- @Override
- public String getPermissionNode() {
- return null;
- }
-
- @Override
- public String getSyntax() {
- return "/UltimateRepairing";
- }
-
- @Override
- public String getDescription() {
- return "Displays this page.";
- }
-}
diff --git a/src/main/java/com/songoda/ultimaterepairing/gui/RepairGui.java b/src/main/java/com/songoda/ultimaterepairing/gui/RepairGui.java
new file mode 100644
index 0000000..596199a
--- /dev/null
+++ b/src/main/java/com/songoda/ultimaterepairing/gui/RepairGui.java
@@ -0,0 +1,115 @@
+package com.songoda.ultimaterepairing.gui;
+
+import com.songoda.core.compatibility.CompatibleMaterial;
+import com.songoda.core.gui.Gui;
+import com.songoda.core.gui.GuiUtils;
+import com.songoda.core.utils.ItemUtils;
+import com.songoda.core.utils.TextUtils;
+import com.songoda.ultimaterepairing.UltimateRepairing;
+import com.songoda.ultimaterepairing.repair.RepairType;
+import com.songoda.ultimaterepairing.settings.Settings;
+import com.songoda.ultimaterepairing.utils.Methods;
+import org.bukkit.Location;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+import java.util.Arrays;
+
+public class RepairGui extends Gui {
+
+ final Location anvil;
+ final Player player;
+ final UltimateRepairing plugin = UltimateRepairing.getInstance();
+ final ItemStack item;
+
+ public static void newGui(Player player, Location anvil) {
+ RepairType type = RepairType.EXPERIENCE;
+ if (!type.hasPermission(player))
+ type = type.getNext(player);
+ if (type == null) {
+ UltimateRepairing.getInstance().getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(player);
+ return;
+ }
+ UltimateRepairing.getInstance().getGuiManager().showGUI(player, new RepairGui(player, anvil, null, type));
+ }
+
+ private RepairGui(Player player, Location anvil, Gui gui, RepairType type) {
+ super(gui);
+ this.anvil = anvil;
+ this.player = player;
+ this.item = player.getItemInHand();
+
+ setRows(6);
+ setTitle(plugin.getLocale().getMessage("interface.repair.title").getMessage());
+
+ init(type);
+ }
+
+ protected void init(RepairType type) {
+ if (inventory != null)
+ inventory.clear();
+ setActionForRange(0, 53, null);
+
+ ItemStack glass1 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_1.getMaterial());
+ ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial());
+ ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial());
+
+ setDefaultItem(glass1);
+
+ GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
+ GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
+ GuiUtils.mirrorFill(this, 0, 2, true, true, glass3);
+
+
+ if (Arrays.stream(RepairType.values()).filter(p -> p.hasPermission(player)).count() > 1)
+ setButton(4, GuiUtils.createButtonItem(type.getMaterial(),
+ type.getTitle(),
+ plugin.getLocale().getMessage("interface.repair.swap").getMessage()), (event) ->
+ init(type.getNext(player)));
+
+ int i = 9;
+ for (ItemStack item : player.getInventory().getContents()) {
+ if (item == null || item.getDurability() <= 0 || item.getMaxStackSize() != 1) continue;
+
+ ItemStack toRepair = item;
+
+ short durability = item.getDurability();
+
+ final String itemName = TextUtils.formatText(ItemUtils.getItemName(item).replace("_", " "), true);
+ if (type == RepairType.ECONOMY) {
+ item = GuiUtils.createButtonItem(CompatibleMaterial.getMaterial(item),
+ plugin.getLocale().getMessage("interface.repair.item")
+ .processPlaceholder("ITEM", itemName).getMessage(),
+ plugin.getLocale().getMessage("interface.repair.ecolore").getMessage());
+ } else if (type == RepairType.ITEM) {
+ item = GuiUtils.createButtonItem(CompatibleMaterial.getMaterial(item),
+ plugin.getLocale().getMessage("interface.repair.item")
+ .processPlaceholder("ITEM", itemName).getMessage(),
+ plugin.getLocale().getMessage("interface.repair.itemlore")
+ .processPlaceholder("item", itemName).getMessage());
+ } else if (type == RepairType.EXPERIENCE) {
+ item = GuiUtils.createButtonItem(CompatibleMaterial.getMaterial(item),
+ plugin.getLocale().getMessage("interface.repair.item")
+ .processPlaceholder("ITEM", itemName).getMessage(),
+ plugin.getLocale().getMessage("interface.repair.xplore").getMessage());
+ }
+ item.setDurability(durability);
+
+ setButton(i, item, (event) -> {
+ exit();
+ UltimateRepairing.getInstance().getRepairHandler().preRepair(toRepair, player, type, anvil);
+ });
+ i++;
+ }
+
+ if (Settings.RAINBOW.getBoolean()) {
+ for (int cell = 0; cell < rows * 9; ++cell) {
+ if (getItem(cell) == null) {
+ setItem(cell, GuiUtils.getBorderItem(Methods.getRainbowGlass()));
+ }
+ }
+ }
+ }
+
+
+}
diff --git a/src/main/java/com/songoda/ultimaterepairing/gui/RepairTypeGui.java b/src/main/java/com/songoda/ultimaterepairing/gui/RepairTypeGui.java
deleted file mode 100644
index 1207de4..0000000
--- a/src/main/java/com/songoda/ultimaterepairing/gui/RepairTypeGui.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package com.songoda.ultimaterepairing.gui;
-
-import com.songoda.core.compatibility.CompatibleMaterial;
-import com.songoda.core.gui.Gui;
-import com.songoda.core.gui.GuiUtils;
-import com.songoda.core.utils.ItemUtils;
-import com.songoda.core.utils.TextUtils;
-import com.songoda.ultimaterepairing.UltimateRepairing;
-import com.songoda.ultimaterepairing.anvil.PlayerAnvilData;
-import com.songoda.ultimaterepairing.settings.Settings;
-import com.songoda.ultimaterepairing.utils.Methods;
-import org.bukkit.Location;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
-public class RepairTypeGui extends Gui {
-
- final Location anvil;
- final Player player;
- final UltimateRepairing instance = UltimateRepairing.getInstance();
- final ItemStack item;
-
- public RepairTypeGui(Player player, Location anvil) {
- this(player, anvil, null);
- }
-
- public RepairTypeGui(Player player, Location anvil, Gui gui) {
- super(gui);
- this.anvil = anvil;
- this.player = player;
- this.item = player.getItemInHand();
- init();
- }
-
- protected void init() {
- setRows(3);
- setTitle(instance.getLocale().getMessage("interface.repair.title").getMessage());
-
- ItemStack glass1 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_1.getMaterial());
- ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial());
- ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial());
-
- setDefaultItem(glass1);
-
- GuiUtils.mirrorFill(this, 0, 0, true, true, glass2);
- GuiUtils.mirrorFill(this, 0, 1, true, true, glass2);
- GuiUtils.mirrorFill(this, 0, 2, true, true, glass3);
- GuiUtils.mirrorFill(this, 1, 0, false, true, glass2);
- GuiUtils.mirrorFill(this, 1, 1, false, true, glass3);
-
- if(player.hasPermission("ultimaterepairing.use.ECO")) {
- setButton(11, GuiUtils.createButtonItem(Settings.ECO_ICON.getMaterial(CompatibleMaterial.SUNFLOWER),
- instance.getLocale().getMessage("interface.repair.eco").getMessage(),
- instance.getLocale().getMessage("interface.repair.ecolore").getMessage()),
- (event) -> {
- exit();
- instance.getRepairHandler().preRepair(player, PlayerAnvilData.RepairType.ECONOMY, anvil);
- });
- }
-
- // Settings.ITEM_ICON.getMaterial(CompatibleMaterial.DIAMOND)
- if(player.hasPermission("ultimaterepairing.use.ITEM")) {
- final String itemName = TextUtils.formatText(ItemUtils.getItemName(item).replace("_", " "), true);
- setButton(15, GuiUtils.createButtonItem(CompatibleMaterial.getMaterial(item),
- instance.getLocale().getMessage("interface.repair.item")
- .processPlaceholder("ITEM", itemName).getMessage(),
- instance.getLocale().getMessage("interface.repair.itemlore")
- .processPlaceholder("item", itemName).getMessage()),
- (event) -> {
- exit();
- instance.getRepairHandler().preRepair(player, PlayerAnvilData.RepairType.ITEM, anvil);
- });
- }
-
- if(player.hasPermission("ultimaterepairing.use.XP")) {
- setButton(13, GuiUtils.createButtonItem(Settings.XP_ICON.getMaterial(CompatibleMaterial.EXPERIENCE_BOTTLE),
- instance.getLocale().getMessage("interface.repair.xp").getMessage(),
- instance.getLocale().getMessage("interface.repair.xplore").getMessage()),
- (event) -> {
- exit();
- instance.getRepairHandler().preRepair(player, PlayerAnvilData.RepairType.XP, anvil);
- });
- }
-
- if(Settings.RAINBOW.getBoolean()) {
- for(int cell = 0; cell < rows * 9; ++cell) {
- if(getItem(cell) == null) {
- setItem(cell, GuiUtils.getBorderItem(Methods.getRainbowGlass()));
- }
- }
- }
- }
-}
diff --git a/src/main/java/com/songoda/ultimaterepairing/gui/StartConfirmGui.java b/src/main/java/com/songoda/ultimaterepairing/gui/StartConfirmGui.java
index 537eed4..936af19 100644
--- a/src/main/java/com/songoda/ultimaterepairing/gui/StartConfirmGui.java
+++ b/src/main/java/com/songoda/ultimaterepairing/gui/StartConfirmGui.java
@@ -7,6 +7,7 @@ import com.songoda.core.utils.ItemUtils;
import com.songoda.core.utils.TextUtils;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.anvil.PlayerAnvilData;
+import com.songoda.ultimaterepairing.repair.RepairType;
import com.songoda.ultimaterepairing.settings.Settings;
import com.songoda.ultimaterepairing.utils.Methods;
import org.bukkit.Location;
@@ -19,14 +20,14 @@ public class StartConfirmGui extends Gui {
final Player player;
final UltimateRepairing instance = UltimateRepairing.getInstance();
final ItemStack item;
- final PlayerAnvilData.RepairType type;
+ final RepairType type;
boolean isYes = false;
- public StartConfirmGui(Location anvil, PlayerAnvilData.RepairType type, Player player, ItemStack item) {
+ public StartConfirmGui(Location anvil, RepairType type, Player player, ItemStack item) {
this(anvil, type, player, item, null);
}
- public StartConfirmGui(Location anvil, PlayerAnvilData.RepairType type, Player player, ItemStack item, Gui gui) {
+ public StartConfirmGui(Location anvil, RepairType type, Player player, ItemStack item, Gui gui) {
super(gui);
this.anvil = anvil;
this.player = player;
@@ -41,11 +42,11 @@ public class StartConfirmGui extends Gui {
String cost = "0";
PlayerAnvilData playerData = instance.getRepairHandler().getDataFor(player);
- if (type == PlayerAnvilData.RepairType.XP) {
+ if (type == RepairType.EXPERIENCE) {
cost = playerData.getPrice() + " XP";
- } else if (type == PlayerAnvilData.RepairType.ECONOMY) {
+ } else if (type == RepairType.ECONOMY) {
cost = "$" + playerData.getPrice();
- } else if (type == PlayerAnvilData.RepairType.ITEM) {
+ } else if (type == RepairType.ITEM) {
cost = playerData.getPrice() + " " + Methods.formatText(Methods.getType(item).name(), true);
}
diff --git a/src/main/java/com/songoda/ultimaterepairing/handlers/RepairHandler.java b/src/main/java/com/songoda/ultimaterepairing/handlers/RepairHandler.java
index e7359ef..e68bc97 100644
--- a/src/main/java/com/songoda/ultimaterepairing/handlers/RepairHandler.java
+++ b/src/main/java/com/songoda/ultimaterepairing/handlers/RepairHandler.java
@@ -7,9 +7,9 @@ import com.songoda.core.hooks.EconomyManager;
import com.songoda.core.utils.PlayerUtils;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.anvil.PlayerAnvilData;
-import com.songoda.ultimaterepairing.anvil.PlayerAnvilData.RepairType;
-import com.songoda.ultimaterepairing.gui.RepairTypeGui;
+import com.songoda.ultimaterepairing.gui.RepairGui;
import com.songoda.ultimaterepairing.gui.StartConfirmGui;
+import com.songoda.ultimaterepairing.repair.RepairType;
import com.songoda.ultimaterepairing.utils.Methods;
import org.bukkit.*;
import org.bukkit.entity.Item;
@@ -18,7 +18,9 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.Vector;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
/**
* Created by songoda on 2/25/2017.
@@ -39,14 +41,13 @@ public class RepairHandler {
if (getDataFor(p).getInRepair()) {
yesNo(p, getDataFor(p).getType(), getDataFor(p).getToBeRepaired());
} else {
- guiManager.showGUI(p, new RepairTypeGui(p, l));
+ RepairGui.newGui(p, l);
}
}
- public void preRepair(Player player, RepairType type, Location anvil) {
- ItemStack itemStack = player.getItemInHand();
- player.setItemInHand(null);
+ public void preRepair(ItemStack itemStack, Player player, RepairType type, Location anvil) {
+ player.getInventory().removeItem(itemStack);
Item item = player.getWorld().dropItem(anvil.add(0.5, 2, 0.5), itemStack);
// Support for EpicHoppers suction.
@@ -85,33 +86,8 @@ public class RepairHandler {
instance.getLocale().getMessage("event.repair.needspace").sendPrefixedMessage(player);
return;
}
- if (player.getItemInHand().getDurability() <= 0) {
- instance.getLocale().getMessage("event.repair.notdamaged").sendPrefixedMessage(player);
- return;
- }
- if (player.getItemInHand().getMaxStackSize() != 1) {
- instance.getLocale().getMessage("event.repair.cantrepair").sendPrefixedMessage(player);
- return;
- }
- int num = 0;
- if (player.hasPermission("ultimaterepairing.use.ECO"))
- num++;
- if (player.hasPermission("ultimaterepairing.use.XP"))
- num++;
- if (num != 2 && player.hasPermission("ultimaterepairing.use.ITEM"))
- num++;
-
-
- if (num >= 2 || player.hasPermission("ultimaterepairing.use.*")) {
- repairType(player, anvil);
- getDataFor(player).setLocation(anvil);
- } else if (player.hasPermission("ultimaterepairing.use.eco"))
- instance.getRepairHandler().preRepair(player, RepairType.ECONOMY, anvil);
- else if (player.hasPermission("ultimaterepairing.use.XP"))
- instance.getRepairHandler().preRepair(player, RepairType.XP, anvil);
- else if (player.hasPermission("ultimaterepairing.use.ITEM"))
- instance.getRepairHandler().preRepair(player, RepairType.ITEM, anvil);
+ repairType(player, anvil);
}
private void yesNo(Player p, RepairType type, ItemStack item) {
@@ -158,7 +134,7 @@ public class RepairHandler {
sold = true;
}
- if (type == RepairType.XP && player.getLevel() >= playerData.getPrice() || sold || player.getGameMode() == GameMode.CREATIVE) {
+ if (type == RepairType.ECONOMY && player.getLevel() >= playerData.getPrice() || sold || player.getGameMode() == GameMode.CREATIVE) {
playerData.setBeingRepaired(true);
Effect effect = Effect.STEP_SOUND;
@@ -206,7 +182,7 @@ public class RepairHandler {
playerData.getItem().remove();
if (player.getGameMode() != GameMode.CREATIVE &&
- type == RepairType.XP) {
+ type == RepairType.EXPERIENCE) {
player.setLevel(player.getLevel() - playerData.getPrice());
}
this.playerAnvilData.remove(player.getUniqueId());
@@ -219,7 +195,7 @@ public class RepairHandler {
instance.getLocale().getMessage("event.repair.notenough")
.processPlaceholder("type", instance.getLocale().getMessage("interface.repair.eco").getMessage())
.sendPrefixedMessage(player);
- } else if (type == RepairType.XP)
+ } else if (type == RepairType.EXPERIENCE)
instance.getLocale().getMessage("event.repair.notenough")
.processPlaceholder("type", instance.getLocale().getMessage("interface.repair.xp").getMessage())
.sendPrefixedMessage(player);
diff --git a/src/main/java/com/songoda/ultimaterepairing/listeners/InteractListeners.java b/src/main/java/com/songoda/ultimaterepairing/listeners/InteractListeners.java
index 32fdc57..4503af7 100644
--- a/src/main/java/com/songoda/ultimaterepairing/listeners/InteractListeners.java
+++ b/src/main/java/com/songoda/ultimaterepairing/listeners/InteractListeners.java
@@ -4,6 +4,7 @@ import com.songoda.core.gui.GuiManager;
import com.songoda.ultimaterepairing.UltimateRepairing;
import com.songoda.ultimaterepairing.anvil.UAnvil;
import com.songoda.ultimaterepairing.gui.AnvilSettingsGui;
+import com.songoda.ultimaterepairing.gui.RepairGui;
import com.songoda.ultimaterepairing.settings.Settings;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -73,7 +74,7 @@ public class InteractListeners implements Listener {
}
if (ourRepair) {
- instance.getRepairHandler().initRepair(player, event.getClickedBlock().getLocation());
+ RepairGui.newGui(player, anvil1.getLocation());
event.setCancelled(true);
} else if (vanillaRepair && anvil1.isInfinity()) {
player.openInventory(Bukkit.createInventory(null, InventoryType.ANVIL, ChatColor.DARK_GRAY + "Repair & Name"));
diff --git a/src/main/java/com/songoda/ultimaterepairing/repair/RepairType.java b/src/main/java/com/songoda/ultimaterepairing/repair/RepairType.java
new file mode 100644
index 0000000..4d00f9b
--- /dev/null
+++ b/src/main/java/com/songoda/ultimaterepairing/repair/RepairType.java
@@ -0,0 +1,56 @@
+package com.songoda.ultimaterepairing.repair;
+
+import com.songoda.core.compatibility.CompatibleMaterial;
+import com.songoda.ultimaterepairing.UltimateRepairing;
+import org.bukkit.entity.Player;
+
+public enum RepairType {
+
+ ECONOMY(CompatibleMaterial.SUNFLOWER,
+ "ultimaterepairing.use.ECO",
+ "interface.repair.ecoTitle"),
+
+ ITEM(CompatibleMaterial.DIAMOND,
+ "ultimaterepairing.use.ITEM",
+ "interface.repair.itemTitle"),
+
+ EXPERIENCE(CompatibleMaterial.EXPERIENCE_BOTTLE,
+ "ultimaterepairing.use.XP",
+ "interface.repair.xpTitle");
+
+ private final CompatibleMaterial material;
+ private final String permission;
+ private final String title;
+
+ RepairType(CompatibleMaterial material, String permission, String titleLang) {
+ this.material = material;
+ this.permission = permission;
+ this.title = UltimateRepairing.getInstance().getLocale().getMessage(titleLang).getMessage();
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public CompatibleMaterial getMaterial() {
+ return material;
+ }
+
+ public boolean hasPermission(Player player) {
+ return player.hasPermission(permission);
+ }
+
+ public RepairType getNext(Player player) {
+ for (int i = 0; i < values().length; i++) {
+ int index = ordinal();
+ int nextIndex = index + 1;
+ RepairType[] cars = RepairType.values();
+ nextIndex %= cars.length;
+ RepairType type = cars[nextIndex];
+ if (!type.hasPermission(player))
+ continue;
+ return type;
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/com/songoda/ultimaterepairing/utils/Methods.java b/src/main/java/com/songoda/ultimaterepairing/utils/Methods.java
index 6e67b60..f8b183f 100644
--- a/src/main/java/com/songoda/ultimaterepairing/utils/Methods.java
+++ b/src/main/java/com/songoda/ultimaterepairing/utils/Methods.java
@@ -2,7 +2,7 @@ package com.songoda.ultimaterepairing.utils;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.ultimaterepairing.UltimateRepairing;
-import com.songoda.ultimaterepairing.anvil.PlayerAnvilData.RepairType;
+import com.songoda.ultimaterepairing.repair.RepairType;
import com.songoda.ultimaterepairing.settings.Settings;
import org.bukkit.*;
import org.bukkit.block.Block;
@@ -20,6 +20,7 @@ import java.util.*;
public class Methods {
static Random rand = new Random();
+
public static CompatibleMaterial getRainbowGlass() {
return CompatibleMaterial.getGlassPaneColor(rand.nextInt(16));
}
@@ -58,7 +59,7 @@ public class Methods {
ITEMCost = ITEMCost * multi;
}
- if (type == RepairType.XP)
+ if (type == RepairType.EXPERIENCE)
return XPCost;
else if (type == RepairType.ITEM)
return ITEMCost;
@@ -72,6 +73,8 @@ public class Methods {
public static Material getType(ItemStack item) {
if (Settings.REPAIR_ONLY_SAME_TYPE.getBoolean()) {
+ if (item.getType().name().contains("NETHERITE"))
+ return CompatibleMaterial.NETHERITE_BLOCK.getMaterial();
if (item.getType().name().contains("DIAMOND"))
return CompatibleMaterial.DIAMOND.getMaterial();
if (item.getType().name().contains("IRON"))
diff --git a/src/main/resources/en_US.lang b/src/main/resources/en_US.lang
index 8b029bf..d746f5d 100644
--- a/src/main/resources/en_US.lang
+++ b/src/main/resources/en_US.lang
@@ -14,12 +14,16 @@ general:
interface:
repair:
title: '&9How do you want to repair?'
+ xpTitle: '&9XP'
xp: '&9XP'
xplore: '&7Click to repair with XP.'
+ ecoTitle: '&9Economy'
eco: '&9Economy'
ecolore: '&7Click to repair with Economy.'
+ itemTitle: '&9Item'
item: '&9%ITEM%'
itemlore: '&7Click to repair with %item%.'
+ swap: '&7Click to swap repair type.'
yesno:
title: '&9Repair for &a%cost%&9?'
'yes': '&a&lYes'
@@ -32,9 +36,7 @@ event:
nopermission: '&cYou do not have permission to do that.'
repair:
timeout: '&cYour repair timed out...'
- notdamaged: '&aThis item is not damaged.'
needspace: '&cYou need to have free space above the anvil!'
- cantrepair: '&cYou can''t repair this!'
notenough: '&cYou don''t have enough %type% &cto repair this item!'
success: '&aYour item has been successfully repaired!'
cancelled: '&cCancelled repairing.'
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 9894d4b..9d9a6e3 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -6,10 +6,10 @@ version: maven-version-number
author: Songoda
api-version: 1.13
commands:
- ultimaterepairing:
+ ur:
description: View information on this plugin.
default: true
- aliases: [ur]
+ aliases: [UltimateRepairing]
usage: /ur
uranvil:
description: View information on this plugin.