mirror of
https://github.com/songoda/UltimateRepairing.git
synced 2024-11-26 04:25:17 +01:00
cleaned
This commit is contained in:
parent
cacc94db40
commit
f7de0d1da9
@ -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;
|
||||
}
|
||||
}
|
@ -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}
|
||||
}
|
@ -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}
|
||||
}
|
||||
|
@ -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"));
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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<Player, String> cat = new HashMap<>();
|
||||
|
||||
private final UltimateRepairing instance;
|
||||
private String pluginName = "UltimateRepairing";
|
||||
private Map<Player, String> cat = new HashMap<>();
|
||||
private Map<Player, String> 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<Player, String> current = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
ItemStack clickedItem = event.getCurrentItem();
|
||||
|
Loading…
Reference in New Issue
Block a user