Merge branch 'development'

This commit is contained in:
Brianna 2020-10-16 13:29:12 -05:00
commit 302407f935
6 changed files with 19 additions and 21 deletions

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId>
<artifactId>UltimateRepairing</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>1.4.4</version>
<version>1.4.5</version>
<build>
<defaultGoal>clean install</defaultGoal>
<finalName>UltimateRepairing-${project.version}</finalName>

View File

@ -12,12 +12,6 @@ public class AnvilSettingsGui extends Gui {
private final UAnvil anvil;
public AnvilSettingsGui(UAnvil anvil, Gui gui) {
super(gui);
this.anvil = anvil;
init();
}
public AnvilSettingsGui(UAnvil anvil) {
this.anvil = anvil;
init();

View File

@ -18,25 +18,23 @@ public class RepairGui extends Gui {
private final Location anvil;
private final Player player;
private final UltimateRepairing plugin = UltimateRepairing.getInstance();
private final ItemStack item;
private static final UltimateRepairing plugin = UltimateRepairing.getInstance();
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);
plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(player);
return;
}
UltimateRepairing.getInstance().getGuiManager().showGUI(player, new RepairGui(player, anvil, null, type));
plugin.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());
@ -98,16 +96,19 @@ public class RepairGui extends Gui {
int finalplayerslot = playerslot;
setButton(i, item, (event) -> {
exit();
UltimateRepairing.getInstance().getRepairHandler().preRepair(toRepair, finalplayerslot, player, type, anvil);
if (!player.getInventory().contains(toRepair)) {
plugin.getLocale().getMessage("event.repair.notfound").sendPrefixedMessage(player);
return;
}
plugin.getRepairHandler().preRepair(toRepair, finalplayerslot, player, type, anvil);
});
i++;
}
if (Settings.RAINBOW.getBoolean()) {
for (int cell = 0; cell < rows * 9; ++cell) {
if (getItem(cell) == null) {
if (getItem(cell) == null)
setItem(cell, GuiUtils.getBorderItem(Methods.getRainbowGlass()));
}
}
}
}

View File

@ -8,6 +8,7 @@ import com.songoda.ultimaterepairing.gui.RepairGui;
import com.songoda.ultimaterepairing.settings.Settings;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -34,17 +35,18 @@ public class InteractListeners implements Listener {
boolean ourRepair = false;
boolean vanillaRepair = false;
Player player = event.getPlayer();
if (event.getClickedBlock() == null) return;
Block block = event.getClickedBlock();
if (block == null) return;
UAnvil anvil1 = null;
if (!event.getClickedBlock().getType().name().contains("ANVIL") // don't pay attention if it's not an anvil
if (!block.getType().name().contains("ANVIL") // don't pay attention if it's not an anvil
// also don't handle if we don't have perms to use this repair anvil
|| (Settings.PERMISSION_ANVIL_PLACE.getBoolean()
&& !(anvil1 = plugin.getAnvilManager().getAnvil(event.getClickedBlock())).isPermPlaced())) {
&& !(anvil1 = plugin.getAnvilManager().getAnvil(block)).isPermPlaced())) {
return;
}
anvil1 = anvil1 != null ? anvil1 : plugin.getAnvilManager().getAnvil(event.getClickedBlock());
anvil1 = anvil1 != null ? anvil1 : plugin.getAnvilManager().getAnvil(block);
// check if we should process this as a right click
boolean rightClick = (event.getAction() == Action.RIGHT_CLICK_BLOCK) ^ (Settings.SWAP_LEFT_RIGHT.getBoolean());
// admin interface?

View File

@ -41,9 +41,9 @@ public enum RepairType {
}
public RepairType getNext(Player player) {
for (int i = 0; i < values().length; i++) {
for (int i = 1; i < values().length + 1; i++) {
int index = ordinal();
int nextIndex = index + 1;
int nextIndex = index + i;
RepairType[] cars = RepairType.values();
nextIndex %= cars.length;
RepairType type = cars[nextIndex];

View File

@ -40,3 +40,4 @@ event:
notenough: '&cYou don''t have enough %type% &cto repair this item!'
success: '&aYour item has been successfully repaired!'
cancelled: '&cCancelled repairing.'
notfound: '&cThe item you attempted to repair has disappeared.'