From f7de0d1da969733b2f846748d868d622fd1a2e74 Mon Sep 17 00:00:00 2001 From: Brianna O'Keefe Date: Fri, 23 Nov 2018 17:46:25 -0500 Subject: [PATCH] cleaned --- .../ultimaterepairing/UltimateRepairing.java | 14 ++++---- .../anvil/PlayerAnvilData.java | 32 +++++++++---------- .../command/AbstractCommand.java | 6 ++-- .../command/CommandManager.java | 15 +++++---- .../command/commands/CommandRPAnvil.java | 1 - .../ultimaterepairing/editor/Editor.java | 3 -- .../events/PlayerListeners.java | 3 +- .../handlers/ParticleHandler.java | 2 +- .../handlers/RepairHandler.java | 5 ++- .../utils/SettingsManager.java | 11 ++----- 10 files changed, 41 insertions(+), 51 deletions(-) diff --git a/src/main/java/com/songoda/ultimaterepairing/UltimateRepairing.java b/src/main/java/com/songoda/ultimaterepairing/UltimateRepairing.java index 81a9904..c2afb80 100644 --- a/src/main/java/com/songoda/ultimaterepairing/UltimateRepairing.java +++ b/src/main/java/com/songoda/ultimaterepairing/UltimateRepairing.java @@ -1,6 +1,5 @@ package com.songoda.ultimaterepairing; -import com.songoda.arconix.api.utils.ConfigWrapper; import com.songoda.arconix.plugin.Arconix; import com.songoda.ultimaterepairing.command.CommandManager; import com.songoda.ultimaterepairing.editor.Editor; @@ -13,7 +12,6 @@ import com.songoda.ultimaterepairing.handlers.ParticleHandler; import com.songoda.ultimaterepairing.handlers.RepairHandler; import com.songoda.ultimaterepairing.utils.Debugger; import com.songoda.ultimaterepairing.utils.SettingsManager; -import org.apache.commons.lang.ArrayUtils; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -36,6 +34,10 @@ public final class UltimateRepairing extends JavaPlugin implements Listener { private Editor editor; + public static UltimateRepairing getInstance() { + return INSTANCE; + } + private boolean checkVersion() { int workingVersion = 13; int currentVersion = Integer.parseInt(Bukkit.getServer().getClass() @@ -62,7 +64,7 @@ public final class UltimateRepairing extends JavaPlugin implements Listener { Arconix.pl().hook(this); console.sendMessage(Arconix.pl().getApi().format().formatText("&a=============================")); - console.sendMessage(Arconix.pl().getApi().format().formatText("&7UltimateRepairing " + this.getDescription().getVersion() + " by &5Brianna <3!")); + console.sendMessage(Arconix.pl().getApi().format().formatText("&7UltimateRepairing " + this.getDescription().getVersion() + " by &5Brianna <3!")); console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &aEnabling&7...")); Bukkit.getPluginManager().registerEvents(this, this); @@ -93,7 +95,7 @@ public final class UltimateRepairing extends JavaPlugin implements Listener { public void onDisable() { console.sendMessage(Arconix.pl().getApi().format().formatText("&a=============================")); - console.sendMessage(Arconix.pl().getApi().format().formatText("&7UltimateRepairing " + this.getDescription().getVersion() + " by &5Brianna <3!")); + console.sendMessage(Arconix.pl().getApi().format().formatText("&7UltimateRepairing " + this.getDescription().getVersion() + " by &5Brianna <3!")); console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &cDisabling&7...")); console.sendMessage(Arconix.pl().getApi().format().formatText("&a=============================")); saveConfig(); @@ -144,8 +146,4 @@ public final class UltimateRepairing extends JavaPlugin implements Listener { public CommandManager getCommandManager() { return commandManager; } - - public static UltimateRepairing getInstance() { - return INSTANCE; - } } \ 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 d2b6411..fa67b6b 100644 --- a/src/main/java/com/songoda/ultimaterepairing/anvil/PlayerAnvilData.java +++ b/src/main/java/com/songoda/ultimaterepairing/anvil/PlayerAnvilData.java @@ -6,8 +6,6 @@ import org.bukkit.inventory.ItemStack; public class PlayerAnvilData { - public enum RepairType { ECONOMY, ITEM, XP } - private Location location; private int price; private RepairType type; @@ -17,54 +15,54 @@ public class PlayerAnvilData { private boolean inRepair; private boolean beingRepaired; - public void setLocation(Location location) { - this.location = location; - } - public Location getLocation() { return location; } - public void setPrice(int price) { - this.price = price; + public void setLocation(Location location) { + this.location = location; } public int getPrice() { return price; } - public void setType(RepairType type) { - this.type = type; + public void setPrice(int price) { + this.price = price; } public RepairType getType() { return type; } - public void setItem(Item item) { - this.item = item; + public void setType(RepairType type) { + this.type = type; } public Item getItem() { return item; } - public void setToBeRepaired(ItemStack toBeRepaired) { - this.toBeRepaired = toBeRepaired; + public void setItem(Item item) { + this.item = item; } public ItemStack getToBeRepaired() { return toBeRepaired; } - public void setLocations(Location locations) { - this.locations = locations; + public void setToBeRepaired(ItemStack toBeRepaired) { + this.toBeRepaired = toBeRepaired; } public Location getLocations() { return locations; } + public void setLocations(Location locations) { + this.locations = locations; + } + public boolean getInRepair() { return inRepair; } @@ -80,4 +78,6 @@ 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/command/AbstractCommand.java b/src/main/java/com/songoda/ultimaterepairing/command/AbstractCommand.java index 7b00a1b..56257fe 100644 --- a/src/main/java/com/songoda/ultimaterepairing/command/AbstractCommand.java +++ b/src/main/java/com/songoda/ultimaterepairing/command/AbstractCommand.java @@ -5,12 +5,8 @@ import org.bukkit.command.CommandSender; public abstract class AbstractCommand { - public enum ReturnType { SUCCESS, FAILURE, SYNTAX_ERROR } - private final AbstractCommand parent; - private final String command; - private final boolean noConsole; protected AbstractCommand(String command, AbstractCommand parent, boolean noConsole) { @@ -38,4 +34,6 @@ public abstract class AbstractCommand { public abstract String getSyntax(); public abstract String getDescription(); + + public enum ReturnType {SUCCESS, FAILURE, SYNTAX_ERROR} } diff --git a/src/main/java/com/songoda/ultimaterepairing/command/CommandManager.java b/src/main/java/com/songoda/ultimaterepairing/command/CommandManager.java index f0828dc..56967da 100644 --- a/src/main/java/com/songoda/ultimaterepairing/command/CommandManager.java +++ b/src/main/java/com/songoda/ultimaterepairing/command/CommandManager.java @@ -2,7 +2,10 @@ package com.songoda.ultimaterepairing.command; import com.songoda.arconix.api.methods.formatting.TextComponent; import com.songoda.ultimaterepairing.UltimateRepairing; -import com.songoda.ultimaterepairing.command.commands.*; +import com.songoda.ultimaterepairing.command.commands.CommandRPAnvil; +import com.songoda.ultimaterepairing.command.commands.CommandReload; +import com.songoda.ultimaterepairing.command.commands.CommandSettings; +import com.songoda.ultimaterepairing.command.commands.CommandUltimateRepairing; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -62,11 +65,11 @@ public class CommandManager implements CommandExecutor { return; } if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) { - AbstractCommand.ReturnType returnType = command.runCommand(instance, sender, strings); - if (returnType == AbstractCommand.ReturnType.SYNTAX_ERROR) { - sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cInvalid Syntax!")); - sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&7The valid syntax is: &6" + command.getSyntax() + "&7.")); - } + AbstractCommand.ReturnType returnType = command.runCommand(instance, sender, strings); + if (returnType == AbstractCommand.ReturnType.SYNTAX_ERROR) { + sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&cInvalid Syntax!")); + sender.sendMessage(instance.references.getPrefix() + TextComponent.formatText("&7The valid syntax is: &6" + command.getSyntax() + "&7.")); + } return; } sender.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.general.nopermission")); diff --git a/src/main/java/com/songoda/ultimaterepairing/command/commands/CommandRPAnvil.java b/src/main/java/com/songoda/ultimaterepairing/command/commands/CommandRPAnvil.java index 045bac1..18074b4 100644 --- a/src/main/java/com/songoda/ultimaterepairing/command/commands/CommandRPAnvil.java +++ b/src/main/java/com/songoda/ultimaterepairing/command/commands/CommandRPAnvil.java @@ -1,6 +1,5 @@ package com.songoda.ultimaterepairing.command.commands; -import com.songoda.arconix.api.methods.formatting.TextComponent; import com.songoda.ultimaterepairing.UltimateRepairing; import com.songoda.ultimaterepairing.command.AbstractCommand; import org.bukkit.command.CommandSender; diff --git a/src/main/java/com/songoda/ultimaterepairing/editor/Editor.java b/src/main/java/com/songoda/ultimaterepairing/editor/Editor.java index 37568a9..4e97ab9 100644 --- a/src/main/java/com/songoda/ultimaterepairing/editor/Editor.java +++ b/src/main/java/com/songoda/ultimaterepairing/editor/Editor.java @@ -2,9 +2,7 @@ package com.songoda.ultimaterepairing.editor; import com.songoda.arconix.api.ArconixAPI; import com.songoda.arconix.api.methods.formatting.TextComponent; -import com.songoda.arconix.plugin.Arconix; import com.songoda.ultimaterepairing.UltimateRepairing; -import com.songoda.ultimaterepairing.anvil.PlayerAnvilData; import com.songoda.ultimaterepairing.utils.Methods; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -27,7 +25,6 @@ public class Editor { } - public void open(Player player, Block block) { editing.put(player.getUniqueId(), block); diff --git a/src/main/java/com/songoda/ultimaterepairing/events/PlayerListeners.java b/src/main/java/com/songoda/ultimaterepairing/events/PlayerListeners.java index 326f1a5..ba6ca01 100644 --- a/src/main/java/com/songoda/ultimaterepairing/events/PlayerListeners.java +++ b/src/main/java/com/songoda/ultimaterepairing/events/PlayerListeners.java @@ -18,7 +18,8 @@ public class PlayerListeners implements Listener { @EventHandler public void onLeave(PlayerQuitEvent event) { - if (!instance.getRepairHandler().hasInstance(event.getPlayer()) || !instance.getRepairHandler().getDataFor(event.getPlayer()).getInRepair()) return; + if (!instance.getRepairHandler().hasInstance(event.getPlayer()) || !instance.getRepairHandler().getDataFor(event.getPlayer()).getInRepair()) + return; PlayerAnvilData playerData = instance.getRepairHandler().getDataFor(event.getPlayer()); instance.getRepairHandler().removeItem(playerData, event.getPlayer()); diff --git a/src/main/java/com/songoda/ultimaterepairing/handlers/ParticleHandler.java b/src/main/java/com/songoda/ultimaterepairing/handlers/ParticleHandler.java index d853902..f8dea86 100644 --- a/src/main/java/com/songoda/ultimaterepairing/handlers/ParticleHandler.java +++ b/src/main/java/com/songoda/ultimaterepairing/handlers/ParticleHandler.java @@ -40,7 +40,7 @@ public class ParticleHandler implements Listener { World w = Bukkit.getServer().getWorld(str[1].substring(0, str[1].length() - 1)); Location location = Arconix.pl().getApi().serialize().unserializeLocation(loc); location.add(.5, 0, .5); - w.spawnParticle(org.bukkit.Particle.valueOf(type), location, amt, 0.25, 0.25, 0.25); + w.spawnParticle(org.bukkit.Particle.valueOf(type), location, amt, 0.25, 0.25, 0.25); } } catch (Exception ex) { Debugger.runReport(ex); diff --git a/src/main/java/com/songoda/ultimaterepairing/handlers/RepairHandler.java b/src/main/java/com/songoda/ultimaterepairing/handlers/RepairHandler.java index 2b38fa8..def0064 100644 --- a/src/main/java/com/songoda/ultimaterepairing/handlers/RepairHandler.java +++ b/src/main/java/com/songoda/ultimaterepairing/handlers/RepairHandler.java @@ -2,7 +2,6 @@ package com.songoda.ultimaterepairing.handlers; import com.songoda.arconix.api.methods.formatting.TextComponent; import com.songoda.arconix.plugin.Arconix; -import com.songoda.ultimaterepairing.Locale; import com.songoda.ultimaterepairing.UltimateRepairing; import com.songoda.ultimaterepairing.anvil.PlayerAnvilData; import com.songoda.ultimaterepairing.anvil.PlayerAnvilData.RepairType; @@ -40,7 +39,7 @@ public class RepairHandler { private void repairType(Player p) { try { if (getDataFor(p).getInRepair()) { - yesNo(p,getDataFor(p).getType(), getDataFor(p).getToBeRepaired()); + yesNo(p, getDataFor(p).getType(), getDataFor(p).getToBeRepaired()); return; } Inventory i = Bukkit.createInventory(null, 27, instance.getLocale().getMessage("interface.repair.title")); @@ -291,7 +290,7 @@ public class RepairHandler { playerData.setBeingRepaired(true); Effect effect = Effect.STEP_SOUND; - + Location location = playerData.getLocations(); player.getWorld().playEffect(location, effect, Material.REDSTONE_BLOCK); Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.getWorld().playEffect(location, effect, Material.REDSTONE_BLOCK), 5L); diff --git a/src/main/java/com/songoda/ultimaterepairing/utils/SettingsManager.java b/src/main/java/com/songoda/ultimaterepairing/utils/SettingsManager.java index 09d404c..224e168 100644 --- a/src/main/java/com/songoda/ultimaterepairing/utils/SettingsManager.java +++ b/src/main/java/com/songoda/ultimaterepairing/utils/SettingsManager.java @@ -25,15 +25,12 @@ import java.util.regex.Pattern; */ public class SettingsManager implements Listener { - private String pluginName = "UltimateRepairing"; - private static final Pattern SETTINGS_PATTERN = Pattern.compile("(.{1,28}(?:\\s|$))|(.{0,28})", Pattern.DOTALL); - private static ConfigWrapper defs; - - private Map cat = new HashMap<>(); - private final UltimateRepairing instance; + private String pluginName = "UltimateRepairing"; + private Map cat = new HashMap<>(); + private Map current = new HashMap<>(); public SettingsManager(UltimateRepairing plugin) { this.instance = plugin; @@ -44,8 +41,6 @@ public class SettingsManager implements Listener { Bukkit.getPluginManager().registerEvents(this, plugin); } - private Map current = new HashMap<>(); - @EventHandler public void onInventoryClick(InventoryClickEvent event) { ItemStack clickedItem = event.getCurrentItem();