mirror of
https://github.com/Crazy-Crew/CrazyAuctions.git
synced 2024-11-10 10:10:22 +01:00
Code cleanup
This commit is contained in:
parent
7223f2fe15
commit
c85e99a181
4
pom.xml
4
pom.xml
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -26,13 +26,6 @@ public enum Category {
|
||||
this.Items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the type name as a string.
|
||||
*/
|
||||
public String getName() {
|
||||
return Name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name Name of the Type you want.
|
||||
* @return Returns the Type as a Enum.
|
||||
@ -46,10 +39,6 @@ public enum Category {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<Material> getItems() {
|
||||
return Items;
|
||||
}
|
||||
|
||||
private static ArrayList<Material> getArmor() {
|
||||
ArrayList<Material> ma = new ArrayList<>();
|
||||
if(Version.getCurrentVersion().isNewer(Version.v1_12_R1)) {
|
||||
@ -186,4 +175,15 @@ public enum Category {
|
||||
return ma;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the type name as a string.
|
||||
*/
|
||||
public String getName() {
|
||||
return Name;
|
||||
}
|
||||
|
||||
public ArrayList<Material> getItems() {
|
||||
return Items;
|
||||
}
|
||||
|
||||
}
|
@ -19,6 +19,7 @@ import java.util.HashMap;
|
||||
*/
|
||||
public class FileManager {
|
||||
|
||||
private static FileManager instance = new FileManager();
|
||||
private Plugin plugin;
|
||||
private String prefix = "";
|
||||
private Boolean log = false;
|
||||
@ -28,8 +29,6 @@ public class FileManager {
|
||||
private HashMap<String, String> autoGenerateFiles = new HashMap<>();
|
||||
private HashMap<Files, FileConfiguration> configurations = new HashMap<>();
|
||||
|
||||
private static FileManager instance = new FileManager();
|
||||
|
||||
public static FileManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
@ -54,10 +54,10 @@ public enum Messages {
|
||||
"&9/Ah Listed - &eView and manage the items you are selling.",
|
||||
"&9/Ah Help - &eView this help menu."));
|
||||
|
||||
private static FileManager fileManager = FileManager.getInstance();
|
||||
private String path;
|
||||
private String defaultMessage;
|
||||
private List<String> defaultListMessage;
|
||||
private static FileManager fileManager = FileManager.getInstance();
|
||||
|
||||
private Messages(String path, String defaultMessage) {
|
||||
this.path = path;
|
||||
@ -69,6 +69,43 @@ public enum Messages {
|
||||
this.defaultListMessage = defaultListMessage;
|
||||
}
|
||||
|
||||
public static String convertList(List<String> list) {
|
||||
String message = "";
|
||||
for(String m : list) {
|
||||
message += Methods.color(m) + "\n";
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String convertList(List<String> list, HashMap<String, String> placeholders) {
|
||||
String message = "";
|
||||
for(String m : list) {
|
||||
message += Methods.color(m) + "\n";
|
||||
}
|
||||
for(String ph : placeholders.keySet()) {
|
||||
message = Methods.color(message.replaceAll(ph, placeholders.get(ph))).replaceAll(ph, placeholders.get(ph).toLowerCase());
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static void addMissingMessages() {
|
||||
FileConfiguration messages = Files.MESSAGES.getFile();
|
||||
boolean saveFile = false;
|
||||
for(Messages message : values()) {
|
||||
if(!messages.contains("Messages." + message.getPath())) {
|
||||
saveFile = true;
|
||||
if(message.getDefaultMessage() != null) {
|
||||
messages.set("Messages." + message.getPath(), message.getDefaultMessage());
|
||||
}else {
|
||||
messages.set("Messages." + message.getPath(), message.getDefaultListMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(saveFile) {
|
||||
Files.MESSAGES.saveFile();
|
||||
}
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
if(isList()) {
|
||||
if(exists()) {
|
||||
@ -147,43 +184,6 @@ public enum Messages {
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String convertList(List<String> list) {
|
||||
String message = "";
|
||||
for(String m : list) {
|
||||
message += Methods.color(m) + "\n";
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String convertList(List<String> list, HashMap<String, String> placeholders) {
|
||||
String message = "";
|
||||
for(String m : list) {
|
||||
message += Methods.color(m) + "\n";
|
||||
}
|
||||
for(String ph : placeholders.keySet()) {
|
||||
message = Methods.color(message.replaceAll(ph, placeholders.get(ph))).replaceAll(ph, placeholders.get(ph).toLowerCase());
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static void addMissingMessages() {
|
||||
FileConfiguration messages = Files.MESSAGES.getFile();
|
||||
Boolean saveFile = false;
|
||||
for(Messages message : values()) {
|
||||
if(!messages.contains("Messages." + message.getPath())) {
|
||||
saveFile = true;
|
||||
if(message.getDefaultMessage() != null) {
|
||||
messages.set("Messages." + message.getPath(), message.getDefaultMessage());
|
||||
}else {
|
||||
messages.set("Messages." + message.getPath(), message.getDefaultListMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(saveFile) {
|
||||
Files.MESSAGES.saveFile();
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean exists() {
|
||||
return Files.MESSAGES.getFile().contains("Messages." + path);
|
||||
}
|
||||
|
@ -13,13 +13,6 @@ public enum ShopType {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the type name as a string.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name name of the Type you want.
|
||||
* @return Returns the Type as a Enum.
|
||||
@ -33,4 +26,11 @@ public enum ShopType {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the type name as a string.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,9 +15,9 @@ public enum Version {
|
||||
v1_14_R1(1141),
|
||||
TOO_NEW(-2);
|
||||
|
||||
public static Version currentVersion;
|
||||
private static Version latest;
|
||||
private Integer versionInteger;
|
||||
public static Version currentVersion;
|
||||
|
||||
private Version(int versionInteger) {
|
||||
this.versionInteger = versionInteger;
|
||||
@ -47,14 +47,6 @@ public enum Version {
|
||||
return currentVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The server's minecraft version as an integer.
|
||||
*/
|
||||
public Integer getVersionInteger() {
|
||||
return this.versionInteger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest version allowed by the Version class.
|
||||
* @return The latest version.
|
||||
@ -73,6 +65,14 @@ public enum Version {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return The server's minecraft version as an integer.
|
||||
*/
|
||||
public Integer getVersionInteger() {
|
||||
return this.versionInteger;
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks if the current version is older, newer, or is the checked version.
|
||||
* @param version The version you are checking.
|
||||
|
@ -14,10 +14,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class AuctionBuyEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player player;
|
||||
private long price;
|
||||
private ItemStack item;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
*
|
||||
@ -31,11 +31,11 @@ public class AuctionBuyEvent extends Event {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
@ -16,12 +16,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class AuctionCancelledEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private OfflinePlayer offlinePlayer;
|
||||
private Player onlinePlayer;
|
||||
private boolean isOnline;
|
||||
private ItemStack item;
|
||||
private CancelledReason reason;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
*
|
||||
@ -47,11 +47,11 @@ public class AuctionCancelledEvent extends Event {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class AuctionExpireEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private OfflinePlayer offlinePlayer;
|
||||
private Player onlinePlayer;
|
||||
private boolean isOnline;
|
||||
private ItemStack item;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
*
|
||||
@ -43,11 +43,11 @@ public class AuctionExpireEvent extends Event {
|
||||
this.isOnline = true;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class AuctionListEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player player;
|
||||
private long price;
|
||||
private ShopType shop;
|
||||
private ItemStack item;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
*
|
||||
@ -35,11 +35,11 @@ public class AuctionListEvent extends Event {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class AuctionNewBidEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player player;
|
||||
private long bid;
|
||||
private ItemStack item;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
*
|
||||
@ -31,11 +31,11 @@ public class AuctionNewBidEvent extends Event {
|
||||
this.bid = bid;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,10 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class AuctionWinBidEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player player;
|
||||
private long bid;
|
||||
private ItemStack item;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
*
|
||||
@ -31,11 +31,11 @@ public class AuctionWinBidEvent extends Event {
|
||||
this.bid = bid;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
@ -439,6 +439,30 @@ public class GUI implements Listener {
|
||||
return Methods.addLore(item.clone(), lore);
|
||||
}
|
||||
|
||||
private static void playClick(Player player) {
|
||||
if(Files.CONFIG.getFile().contains("Settings.Sounds.Toggle")) {
|
||||
if(Files.CONFIG.getFile().getBoolean("Settings.Sounds.Toggle")) {
|
||||
String sound = Files.CONFIG.getFile().getString("Settings.Sounds.Sound");
|
||||
try {
|
||||
player.playSound(player.getLocation(), Sound.valueOf(sound), 1, 1);
|
||||
}catch(Exception e) {
|
||||
if(Methods.getVersion() >= 191) {
|
||||
player.playSound(player.getLocation(), Sound.valueOf("UI_BUTTON_CLICK"), 1, 1);
|
||||
}else {
|
||||
player.playSound(player.getLocation(), Sound.valueOf("CLICK"), 1, 1);
|
||||
}
|
||||
Bukkit.getLogger().log(Level.WARNING, "[Crazy Auctions]>> You set the sound to " + sound + " and this is not a sound for your minecraft version. " + "Please go to the config and set a correct sound or turn the sound off in the toggle setting.");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(Methods.getVersion() >= 191) {
|
||||
player.playSound(player.getLocation(), Sound.valueOf("UI_BUTTON_CLICK"), 1, 1);
|
||||
}else {
|
||||
player.playSound(player.getLocation(), Sound.valueOf("CLICK"), 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInvClose(InventoryCloseEvent e) {
|
||||
FileConfiguration config = Files.CONFIG.getFile();
|
||||
@ -926,28 +950,4 @@ public class GUI implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private static void playClick(Player player) {
|
||||
if(Files.CONFIG.getFile().contains("Settings.Sounds.Toggle")) {
|
||||
if(Files.CONFIG.getFile().getBoolean("Settings.Sounds.Toggle")) {
|
||||
String sound = Files.CONFIG.getFile().getString("Settings.Sounds.Sound");
|
||||
try {
|
||||
player.playSound(player.getLocation(), Sound.valueOf(sound), 1, 1);
|
||||
}catch(Exception e) {
|
||||
if(Methods.getVersion() >= 191) {
|
||||
player.playSound(player.getLocation(), Sound.valueOf("UI_BUTTON_CLICK"), 1, 1);
|
||||
}else {
|
||||
player.playSound(player.getLocation(), Sound.valueOf("CLICK"), 1, 1);
|
||||
}
|
||||
Bukkit.getLogger().log(Level.WARNING, "[Crazy Auctions]>> You set the sound to " + sound + " and this is not a sound for your minecraft version. " + "Please go to the config and set a correct sound or turn the sound off in the toggle setting.");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(Methods.getVersion() >= 191) {
|
||||
player.playSound(player.getLocation(), Sound.valueOf("UI_BUTTON_CLICK"), 1, 1);
|
||||
}else {
|
||||
player.playSound(player.getLocation(), Sound.valueOf("CLICK"), 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -22,20 +22,6 @@ public enum CurrencyManager { // Currency Manager
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the Currency name as a string.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the Currency name as a string.
|
||||
*/
|
||||
public String getPluginName() {
|
||||
return pluginName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* name of the Type you want.
|
||||
@ -50,17 +36,6 @@ public enum CurrencyManager { // Currency Manager
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Returns true if the server has the plugin.
|
||||
*/
|
||||
public Boolean hasPlugin() {
|
||||
if(Bukkit.getServer().getPluginManager().getPlugin(pluginName) != null) {
|
||||
return Files.CONFIG.getFile().getBoolean("Settings.Currencies." + pluginName + ".Enabled");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
@ -115,4 +90,29 @@ public enum CurrencyManager { // Currency Manager
|
||||
Vault.addMoney(player, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the Currency name as a string.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the Currency name as a string.
|
||||
*/
|
||||
public String getPluginName() {
|
||||
return pluginName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Returns true if the server has the plugin.
|
||||
*/
|
||||
public Boolean hasPlugin() {
|
||||
if(Bukkit.getServer().getPluginManager().getPlugin(pluginName) != null) {
|
||||
return Files.CONFIG.getFile().getBoolean("Settings.Currencies." + pluginName + ".Enabled");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user