Browse Source

Cleaned up project and added JavaDoc

RadBuilder 6 years ago
parent
commit
63d2ce4aa5

+ 200 - 127
Plugin/src/main/java/de/Linus122/TimeIsMoney/ATM.java

@@ -1,9 +1,6 @@
 package de.Linus122.TimeIsMoney;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
+import com.google.common.primitives.Doubles;
 import org.bukkit.Bukkit;
 import org.bukkit.Material;
 import org.bukkit.OfflinePlayer;
@@ -28,88 +25,162 @@ import org.bukkit.inventory.ItemStack;
 import org.bukkit.inventory.meta.ItemMeta;
 import org.bukkit.plugin.Plugin;
 
-import com.google.common.primitives.Doubles;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
 
 import static de.Linus122.TimeIsMoney.tools.Utils.CC;
 
-
+/**
+ * ATM listener and command executor.
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
 public class ATM implements Listener, CommandExecutor {
-	private final Plugin pl;
-	
-	private static YamlConfiguration cfg;
-	private static final File fileBankAccounts = new File("plugins/TimeIsMoney/data.dat");
-	
+	/**
+	 * The {@link Plugin}.
+	 */
+	private final Plugin plugin;
+	/**
+	 * The bank accounts {@link java.io.File} that stores all data.
+	 */
+	private static final File bankAccountsFile = new File("plugins/TimeIsMoney/data.dat");
+	/**
+	 * The bank accounts {@link org.bukkit.configuration.file.YamlConfiguration} to manage the {@link #bankAccountsFile}.
+	 */
+	private static YamlConfiguration bankAccountsConfig;
+	/**
+	 * The different amounts of money shown in the atm to withdraw and deposit (atm_worth_gradation).
+	 */
 	private double[] worths = new double[4];
 	
-	public ATM(Main pl){
-		this.pl = pl;
-		pl.getServer().getPluginManager().registerEvents(this, pl);
-		pl.getCommand("atm").setExecutor(this);
-		if(!fileBankAccounts.exists()){
+	/**
+	 * Creates a new atm instance with the {@link de.Linus122.TimeIsMoney.Main} class.
+	 *
+	 * @param plugin The {@link de.Linus122.TimeIsMoney.Main} class that implements {@link org.bukkit.plugin.java.JavaPlugin}.
+	 */
+	public ATM(Main plugin) {
+		this.plugin = plugin;
+		plugin.getServer().getPluginManager().registerEvents(this, plugin);
+		plugin.getCommand("atm").setExecutor(this);
+		
+		if (!bankAccountsFile.exists()) {
 			try {
-				fileBankAccounts.createNewFile();
+				bankAccountsFile.createNewFile();
 			} catch (IOException e) {
 				e.printStackTrace();
-			}	
+			}
 		}
-		cfg = YamlConfiguration.loadConfiguration(fileBankAccounts);
+		bankAccountsConfig = YamlConfiguration.loadConfiguration(bankAccountsFile);
 		
 		worths = Doubles.toArray(Main.finalconfig.getDoubleList("atm_worth_gradation"));
 	}
-	private static void withdrawBank(Player p, double amount){
+	
+	/**
+	 * Withdraws the specified amount of money from the specified player's bank.
+	 *
+	 * @param p The player to withdraw money from.
+	 * @param amount The amount of money to withdraw.
+	 */
+	private static void withdrawBank(Player p, double amount) {
 		String bankString = getBankString(p);
-		if(!cfg.contains(bankString)) cfg.set(bankString, 0.0);
-		cfg.set(bankString, getBankBalance(p) - amount);
+		if (!bankAccountsConfig.contains(bankString)) bankAccountsConfig.set(bankString, 0.0);
+		bankAccountsConfig.set(bankString, getBankBalance(p) - amount);
 		saveBanks();
 	}
-	public static void depositBank(Player p, double amount){
+	
+	/**
+	 * Deposits the specified amount of money to the specified player's bank.
+	 *
+	 * @param p The player to deposit money to.
+	 * @param amount The amount of money to deposit.
+	 */
+	public static void depositBank(Player p, double amount) {
 		String bankString = getBankString(p);
-		if(!cfg.contains(bankString)) cfg.set(bankString, 0.0);
-		cfg.set(bankString, getBankBalance(p) + amount);
+		if (!bankAccountsConfig.contains(bankString)) bankAccountsConfig.set(bankString, 0.0);
+		bankAccountsConfig.set(bankString, getBankBalance(p) + amount);
 		saveBanks();
 	}
-	private static boolean bankHas(Player p, double amount){
+	
+	/**
+	 * Checks if the player has the specified amount of money in their bank.
+	 *
+	 * @param p The player to check the balance of.
+	 * @param amount The amount of money.
+	 * @return True if the player has the specified amount of money, false otherwise.
+	 */
+	private static boolean bankHas(Player p, double amount) {
 		String bankString = getBankString(p);
-		if(!cfg.contains(bankString)) cfg.set(bankString, 0.0);
+		if (!bankAccountsConfig.contains(bankString)) bankAccountsConfig.set(bankString, 0.0);
 		return getBankBalance(p) >= amount;
 		
 	}
-	//Doesn't support groups 
-	private static double getBankBalance(OfflinePlayer p){
-		String bankString =  p.getName() + "_TimBANK";
-		if(!cfg.contains(bankString)) cfg.set(bankString, 0.0);
-		return cfg.getDouble(bankString);
+	
+	/**
+	 * Gets the balance of the specified player's bank (doesn't support groups).
+	 *
+	 * @param p The offline player to get the balance of.
+	 * @return The offline player's balance in the bank.
+	 */
+	private static double getBankBalance(OfflinePlayer p) {
+		String bankString = p.getName() + "_TimBANK";
+		if (!bankAccountsConfig.contains(bankString)) bankAccountsConfig.set(bankString, 0.0);
+		return bankAccountsConfig.getDouble(bankString);
 	}
-	private static double getBankBalance(Player p){
+	
+	/**
+	 * Gets the balance of the specified player's bank.
+	 *
+	 * @param p The player to get the balance of.
+	 * @return The player's balance in the bank.
+	 */
+	private static double getBankBalance(Player p) {
 		String bankString = getBankString(p);
-		if(!cfg.contains(bankString)) cfg.set(bankString, 0.0);
-		return cfg.getDouble(bankString);
+		if (!bankAccountsConfig.contains(bankString)) bankAccountsConfig.set(bankString, 0.0);
+		return bankAccountsConfig.getDouble(bankString);
 	}
-	private static void saveBanks(){
+	
+	/**
+	 * Saves the banks.
+	 */
+	private static void saveBanks() {
 		try {
-			cfg.save(fileBankAccounts);
+			bankAccountsConfig.save(bankAccountsFile);
 		} catch (IOException e) {
 			e.printStackTrace();
 		}
 	}
-	//Converts old tim bank
-	private static void convertOldBank(Player p){
+	
+	/**
+	 * Converts the old TimeIsMoney bank data to the new format.
+	 *
+	 * @param p The player to convert data for.
+	 */
+	private static void convertOldBank(Player p) {
 		String bankString = getBankString(p);
-		if(Main.economy.hasAccount(bankString)){
-			if(Main.economy.getBalance(bankString) > 0){
+		if (Main.economy.hasAccount(bankString)) {
+			if (Main.economy.getBalance(bankString) > 0) {
 				p.sendMessage(CC("&aSuccessfully converted your old TIM-Bank to new version!"));
 				depositBank(p, Main.economy.getBalance(bankString));
-				Main.economy.withdrawPlayer(bankString, Main.economy.getBalance(bankString));	
+				Main.economy.withdrawPlayer(bankString, Main.economy.getBalance(bankString));
 			}
 		}
 	}
-	private static String getBankString(Player p){
-		if(!Main.finalconfig.getBoolean("group-atms")){
+	
+	/**
+	 * Gets the bank string for the specified player.
+	 *
+	 * @param p The player to get the bank string of.
+	 * @return The bank string of the specified player.
+	 */
+	private static String getBankString(Player p) {
+		if (!Main.finalconfig.getBoolean("group-atms")) {
 			return p.getName() + "_TimBANK";
-		}else{
-			for(String key : Main.finalconfig.getConfigurationSection("atm_groups").getKeys(false)){
+		} else {
+			for (String key : Main.finalconfig.getConfigurationSection("atm_groups").getKeys(false)) {
 				List<String> list = Main.finalconfig.getStringList("atm_groups." + key);
-				if(list.contains(p.getWorld().getName())){
+				if (list.contains(p.getWorld().getName())) {
 					return p.getName() + "_TimBANK_" + key;
 				}
 			}
@@ -127,67 +198,69 @@ public class ATM implements Listener, CommandExecutor {
 		}
 		return p.getName() + "_TimBANK";*/
 	}
+	
 	@EventHandler(priority = EventPriority.HIGHEST)
-	public void onInteract(PlayerInteractEvent e){
-		if(e.getClickedBlock() != null){
-			if(e.getClickedBlock().getType() == Material.WALL_SIGN || e.getClickedBlock().getType() == Material.SIGN || e.getClickedBlock().getType() == Material.SIGN_POST){
-				Sign sign = (Sign) e.getClickedBlock().getState();	
-				if(sign.getLine(0).equalsIgnoreCase(CC("&cATM"))){
-					if(!e.getPlayer().hasPermission("tim.atm.use")){
+	public void onInteract(PlayerInteractEvent e) {
+		if (e.getClickedBlock() != null) {
+			if (e.getClickedBlock().getType() == Material.WALL_SIGN || e.getClickedBlock().getType() == Material.SIGN || e.getClickedBlock().getType() == Material.SIGN_POST) {
+				Sign sign = (Sign) e.getClickedBlock().getState();
+				if (sign.getLine(0).equalsIgnoreCase(CC("&cATM"))) {
+					if (!e.getPlayer().hasPermission("tim.atm.use")) {
 						e.getPlayer().sendMessage(CC(Main.finalconfig.getString("message_atm_noperms")));
-					}else{
+					} else {
 						this.openGUI(e.getPlayer());
 					}
 				}
 			}
 		}
 	}
+	
 	@EventHandler
-	public void onMove(InventoryMoveItemEvent e){
-		if(e.getSource() == null) return;
-		if(e.getSource().getTitle() == null) return;
-		if(e.getSource().getTitle().equals(CC(Main.finalconfig.getString("atm_title")))) {
+	public void onMove(InventoryMoveItemEvent e) {
+		if (e.getSource() == null) return;
+		if (e.getSource().getTitle() == null) return;
+		if (e.getSource().getTitle().equals(CC(Main.finalconfig.getString("atm_title")))) {
 			e.setCancelled(true);
 		}
 	}
+	
 	@SuppressWarnings("deprecation")
 	@EventHandler
-	public void onClick(InventoryClickEvent e){
-		try{
-			if(e == null) return;
-			if(e.getInventory() == null) return;
-			if(e.getInventory().getTitle() == null) return;
-			if(e.getInventory().getTitle().equals(CC(Main.finalconfig.getString("atm_title")))){
+	public void onClick(InventoryClickEvent e) {
+		try {
+			if (e == null) return;
+			if (e.getInventory() == null) return;
+			if (e.getInventory().getTitle() == null) return;
+			if (e.getInventory().getTitle().equals(CC(Main.finalconfig.getString("atm_title")))) {
 				e.setResult(Result.DENY);
 				Player p = (Player) e.getWhoClicked();
 				//e.setCancelled(true);
-				if(e.getCurrentItem() != null){
+				if (e.getCurrentItem() != null) {
 					// left side
-					if(e.getSlot() < 4){
-	
+					if (e.getSlot() < 4) {
+						
 						double amount = worths[3 - e.getSlot()];
 						
-						if(ATM.bankHas(p, amount)){
+						if (ATM.bankHas(p, amount)) {
 							ATM.withdrawBank(p, amount);
 							Main.economy.depositPlayer(p, amount);
 							e.getWhoClicked().sendMessage(CC(Main.finalconfig.getString("atm_withdraw")) + " " + Main.economy.format(amount));
-						}else{
+						} else {
 							e.getWhoClicked().sendMessage(CC(Main.finalconfig.getString("message_atm_nomoneyinbank")));
 						}
-					}else
-					// right side
-					if(e.getSlot() > 4){
-						
-						double amount = worths[3 - (3 - (e.getSlot() - 5))];
-						
-						if(Main.economy.has((Player) e.getWhoClicked(), amount)){
-							ATM.depositBank(p, amount);
-							Main.economy.withdrawPlayer((Player) e.getWhoClicked(), amount);
-							e.getWhoClicked().sendMessage(CC(Main.finalconfig.getString("atm_deposit")) + " " + Main.economy.format(amount));
-						}else{
-							e.getWhoClicked().sendMessage(CC(Main.finalconfig.getString("message_atm_nomoney")));
+					} else
+						// right side
+						if (e.getSlot() > 4) {
+							double amount = worths[3 - (3 - (e.getSlot() - 5))];
+							
+							if (Main.economy.has((Player) e.getWhoClicked(), amount)) {
+								ATM.depositBank(p, amount);
+								Main.economy.withdrawPlayer((Player) e.getWhoClicked(), amount);
+								e.getWhoClicked().sendMessage(CC(Main.finalconfig.getString("atm_deposit")) + " " + Main.economy.format(amount));
+							} else {
+								e.getWhoClicked().sendMessage(CC(Main.finalconfig.getString("message_atm_nomoney")));
+							}
 						}
-					}
 					ItemStack is = new ItemStack(Material.GOLD_NUGGET, 1);
 					ItemMeta im = is.getItemMeta();
 					im.setDisplayName(CC(Main.finalconfig.getString("atm_balance")) + " " + Main.economy.format(ATM.getBankBalance(p)));
@@ -195,10 +268,15 @@ public class ATM implements Listener, CommandExecutor {
 					e.getInventory().setItem(4, is);
 				}
 			}
-		}catch(Exception ignored){
-			
+		} catch (Exception ignored) {
 		}
 	}
+	
+	/**
+	 * Opens the atm gui for the specified player.
+	 *
+	 * @param player The player to open the atm gui for.
+	 */
 	private void openGUI(Player player) {
 		convertOldBank(player);
 		Inventory atm_gui = Bukkit.createInventory(null, 9, CC(Main.finalconfig.getString("atm_title")));
@@ -210,7 +288,6 @@ public class ATM implements Listener, CommandExecutor {
 		is.setItemMeta(im);
 		atm_gui.setItem(4, is);
 		
-
 		//
 		is = new ItemStack(Material.CLAY_BRICK, 1);
 		im = is.getItemMeta();
@@ -221,7 +298,7 @@ public class ATM implements Listener, CommandExecutor {
 		//
 		is = new ItemStack(Material.IRON_INGOT, 1);
 		im = is.getItemMeta();
-		im.setDisplayName(CC(Main.finalconfig.getString("atm_withdraw") +  " &a") + Main.economy.format(worths[1]));
+		im.setDisplayName(CC(Main.finalconfig.getString("atm_withdraw") + " &a") + Main.economy.format(worths[1]));
 		is.setItemMeta(im);
 		atm_gui.setItem(2, is);
 		
@@ -239,7 +316,7 @@ public class ATM implements Listener, CommandExecutor {
 		is.setItemMeta(im);
 		atm_gui.setItem(0, is);
 		
-		//DEPOSITE
+		// DEPOSIT
 		//
 		is = new ItemStack(Material.CLAY_BRICK, 1);
 		im = is.getItemMeta();
@@ -257,7 +334,7 @@ public class ATM implements Listener, CommandExecutor {
 		//
 		is = new ItemStack(Material.GOLD_INGOT, 1);
 		im = is.getItemMeta();
-		im.setDisplayName(CC(Main.finalconfig.getString("atm_deposit") + " &4" )+ Main.economy.format(worths[2]));
+		im.setDisplayName(CC(Main.finalconfig.getString("atm_deposit") + " &4") + Main.economy.format(worths[2]));
 		is.setItemMeta(im);
 		atm_gui.setItem(7, is);
 		
@@ -269,76 +346,72 @@ public class ATM implements Listener, CommandExecutor {
 		atm_gui.setItem(8, is);
 		
 		player.openInventory(atm_gui);
-		
-	}
-	public static void changeMoney(Player p, double amount){
-		
 	}
+	
 	@EventHandler
-	public void onItem2(InventoryDragEvent e){
-		if(e == null) return;
-		if(e.getInventory() == null) return;
-		if(e.getInventory().getTitle() == null) return;
-		if(e.getInventory().getTitle().equals(CC(Main.finalconfig.getString("atm_title")))){
+	public void onInventoryDrag(InventoryDragEvent e) {
+		if (e == null) return;
+		if (e.getInventory() == null) return;
+		if (e.getInventory().getTitle() == null) return;
+		if (e.getInventory().getTitle().equals(CC(Main.finalconfig.getString("atm_title")))) {
 			e.setResult(Result.DENY);
 		}
 	}
+	
 	@EventHandler
-	public void onSign(final SignChangeEvent e){
+	public void onSignChange(final SignChangeEvent e) {
 		final Block b = e.getBlock();
-		if(b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN || b.getType() == Material.SIGN_POST){
-			pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, () -> {
-                if(b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN || b.getType() == Material.SIGN_POST){
-                    Sign sign = (Sign) e.getBlock().getState();
-                    if(sign.getLine(0).equalsIgnoreCase("[atm]")){
-                        if(!e.getPlayer().hasPermission("tim.atm.place")){
-                            e.getPlayer().sendMessage(CC("&cYou dont have permissions to build ATM's!"));
-                            sign.setLine(0, "");
-                        }else{
-                            sign.setLine(0, CC("&cATM"));
-                            sign.update();
-                            e.getPlayer().sendMessage(CC("&2ATM created! (You can also write something in the Lines 2-4)"));
-                        }
-                    }
-                }
-            }, 10L);
+		if (b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN || b.getType() == Material.SIGN_POST) {
+			plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
+				if (b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN || b.getType() == Material.SIGN_POST) {
+					Sign sign = (Sign) e.getBlock().getState();
+					if (sign.getLine(0).equalsIgnoreCase("[atm]")) {
+						if (!e.getPlayer().hasPermission("tim.atm.place")) {
+							e.getPlayer().sendMessage(CC("&cYou dont have permissions to build ATM's!"));
+							sign.setLine(0, "");
+						} else {
+							sign.setLine(0, CC("&cATM"));
+							sign.update();
+							e.getPlayer().sendMessage(CC("&2ATM created! (You can also write something in the Lines 2-4)"));
+						}
+					}
+				}
+			}, 10L);
 		}
 	}
-
+	
 	@Override
 	public boolean onCommand(CommandSender cs, Command arg1, String arg2, String[] args) {
-		if(args.length == 0){
-			if(cs.hasPermission("tim.use")){
+		if (args.length == 0) {
+			if (cs.hasPermission("tim.use")) {
 				openGUI((Player) cs);
 				return true;
 			}
 		}
-		if(cs.hasPermission("tim.admin")){
-			if(args.length > 0){
-				switch(args[0]){
+		if (cs.hasPermission("tim.admin")) {
+			if (args.length > 0) {
+				switch (args[0]) {
 					case "balance":
-						if(args.length > 1){		
+						if (args.length > 1) {
 							cs.sendMessage(CC("&2ATM-Balance of&c " + args[1] + "&2: &c") + getBankBalance(Bukkit.getOfflinePlayer(args[1])));
-						}else{
+						} else {
 							cs.sendMessage("/atm balance <player>");
 						}
 						break;
 					default:
 						@SuppressWarnings("deprecation")
 						OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]);
-						if(op == null){
+						if (op == null) {
 							cs.sendMessage("Player is offline");
 							return true;
 						}
-						if(op.isOnline()){
+						if (op.isOnline()) {
 							openGUI(op.getPlayer());
 							cs.sendMessage("opened!");
 						}
 						break;
-						
 				}
-			
-			}else{
+			} else {
 				cs.sendMessage(CC("&c/atm <player> &a- opens atm for player"));
 				cs.sendMessage(CC("&c/atm balance <player> &a- gets balance of player"));
 				return true;

+ 13 - 4
Plugin/src/main/java/de/Linus122/TimeIsMoney/Cmd.java

@@ -6,20 +6,29 @@ import org.bukkit.command.CommandSender;
 
 import static de.Linus122.TimeIsMoney.tools.Utils.CC;
 
+/**
+ * TimeIsMoney command listener.
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
 class Cmd implements CommandExecutor {
 	private final Main main;
+	
+	/**
+	 * Creates a new cmd instance with the {@link de.Linus122.TimeIsMoney.Main} class.
+	 * @param main The {@link de.Linus122.TimeIsMoney.Main} class.
+	 */
 	Cmd(Main main) {
 		this.main = main;
 	}
-
+	
 	@Override
 	public boolean onCommand(CommandSender cs, Command arg1, String arg2, String[] arg3) {
-		if(cs.hasPermission("tim.reload")){
+		if (cs.hasPermission("tim.reload")) {
 			main.reload();
 			cs.sendMessage(CC("&aTime is Money &cv" + Main.PL_VERSION + " &areloaded!"));
-			
 		}
 		return true;
 	}
-
 }

+ 577 - 468
Plugin/src/main/java/de/Linus122/TimeIsMoney/Main.java

@@ -1,5 +1,22 @@
 package de.Linus122.TimeIsMoney;
 
+import com.earth2me.essentials.Essentials;
+import de.Linus122.TimeIsMoney.tools.ActionBarUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Server;
+import org.bukkit.command.Command;
+import org.bukkit.command.ConsoleCommandSender;
+import org.bukkit.command.PluginCommand;
+import org.bukkit.command.SimpleCommandMap;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.PluginManager;
+import org.bukkit.plugin.RegisteredServiceProvider;
+import org.bukkit.plugin.SimplePluginManager;
+import org.bukkit.plugin.java.JavaPlugin;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -20,475 +37,567 @@ import java.util.Map;
 import java.util.Random;
 import java.util.UUID;
 
-import com.earth2me.essentials.Essentials;
-import de.Linus122.TimeIsMoney.tools.ActionBarUtils;
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.Server;
-import org.bukkit.command.Command;
-import org.bukkit.command.ConsoleCommandSender;
-import org.bukkit.command.PluginCommand;
-import org.bukkit.command.SimpleCommandMap;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.Plugin;
-import org.bukkit.plugin.PluginManager;
-import org.bukkit.plugin.RegisteredServiceProvider;
-import org.bukkit.plugin.SimplePluginManager;
-import org.bukkit.plugin.java.JavaPlugin;
-
 import static de.Linus122.TimeIsMoney.tools.Utils.CC;
 
+/**
+ * The main class for TimeIsMoney
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
 public class Main extends JavaPlugin {
-
-    public static net.milkbowl.vault.economy.Economy economy = null;
-    private static ActionBarUtils actionBarUtils = null;
-    private static final int CFG_VERSION = 12;
-    public static String PL_VERSION;
-    public static YamlConfiguration finalconfig;
-    private static List<String> disabledWorlds;
-    private static final HashMap<String, UUID> boundIPs = new HashMap<>();
-    private final List<Payout> payouts = new ArrayList<>();
-    private HashMap<String, Double> payedMoney = new HashMap<>();
-    private final HashMap<UUID, Integer> onlineSeconds = new HashMap<>();
-    private final HashMap<UUID, Location> lastLocation = new HashMap<>();
-    private String message;
-    private String messageActionbar;
-    private final ConsoleCommandSender clogger = this.getServer().getConsoleSender();
-    private int currentDay = 0;
-    private boolean use18Features = true;
-
-    @SuppressWarnings({"deprecation", "unchecked"})
-    @Override
-    public void onEnable() {
-        this.getCommand("timeismoney").setExecutor(new Cmd(this));
-        PL_VERSION = this.getDescription().getVersion();
-        currentDay = (new Date()).getDay();
-
-        File config = new File("plugins/TimeIsMoney/config.yml");
-        if (config.exists()) {
-            YamlConfiguration cfg = YamlConfiguration.loadConfiguration(config);
-            String old_config = "config_old " + cfg.getInt("configuration-version") + ".yml";
-            if (cfg.contains("configuration-version")) {
-                if (cfg.getInt("configuration-version") < CFG_VERSION) {
-                    clogger.sendMessage(CC("[TimeIsMoney] &cYOU ARE USING AN OLD CONFIG-VERSION. The plugin CANT work with this."));
-                    clogger.sendMessage(CC("[TimeIsMoney] &cI have created an new config for you. The old one is saved as config_old.yml."));
-                    config.renameTo(new File("plugins/TimeIsMoney/" + old_config));
-                }
-            }
-            this.saveDefaultConfig();
-            for (String key : cfg.getConfigurationSection("").getKeys(true)) {
-                if (!this.getConfig().contains(key)) {
-                    this.getConfig().set(key, cfg.get(key));
-                }
-            }
-        } else {
-            this.saveDefaultConfig();
-        }
-
-
-        finalconfig = YamlConfiguration.loadConfiguration(config);
-        disabledWorlds = getConfig().getStringList("disabled_in_worlds");
-
-        if (getConfig().getBoolean("enable_atm")) new ATM(this);
-
-        final int seconds = getConfig().getInt("give_money_every_second");
-        Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
-            try {
-                for (Player p : Bukkit.getOnlinePlayers()) {
-                    if (disabledWorlds.contains(p.getWorld().getName())) continue;
-                    if (!boundIPs.containsKey(p.getAddress().getHostName())) {
-                        boundIPs.put(p.getAddress().getHostName(), p.getUniqueId());
-                    }
-                    if (onlineSeconds.containsKey(p.getUniqueId())) {
-
-                        onlineSeconds.put(p.getUniqueId(), onlineSeconds.get(p.getUniqueId()) + 1);
-                    } else {
-                        onlineSeconds.put(p.getUniqueId(), 1);
-                    }
-                    if (onlineSeconds.get(p.getUniqueId()) > seconds) {
-                        pay(p);
-                        onlineSeconds.remove(p.getUniqueId());
-                    }
-                }
-            } catch (NullPointerException e) {
-                //
-            }
-        }, 20L, 20L);
-        Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
-            if (currentDay != new Date().getDay()) { //Next day, clear payouts!
-                log("Cleared all payouts");
-                payedMoney.clear();
-                currentDay = new Date().getDay();
-            }
-        }, 20L * 60, 20L * 60 * 15);
-        setupEconomy();
-
-        message = finalconfig.getString("message");
-        message = CC(message);
-        messageActionbar = finalconfig.getString("message_actionbar");
-        messageActionbar = CC(messageActionbar);
-
-        try {
-            FileInputStream fis = new FileInputStream(new File("plugins/TimeIsMoney/payed_today.data"));
-            ObjectInputStream ois = new ObjectInputStream(fis);
-            payedMoney = (HashMap<String, Double>) ((HashMap<String, Double>) ois.readObject()).clone();
-
-            ois.close();
-        } catch (Exception ignored) {
-
-        }
-
-        loadPayouts();
-
-
-        String packageName = this.getServer().getClass().getPackage().getName();
-        // Get full package string of CraftServer.
-        // org.bukkit.craftbukkit.version
-        String Bukkitversion = packageName.substring(packageName.lastIndexOf('.') + 1);
-        // Get the last element of the package
-        try {
-            final Class<?> clazz = Class.forName("de.Linus122.TimeIsMoney.version." + Bukkitversion + ".NBTUtils");
-            // Check if we have a NMSHandler class at that location.
-            if (ActionBarUtils.class.isAssignableFrom(clazz)) { // Make sure it actually implements NMS
-                actionBarUtils = (ActionBarUtils) clazz.getConstructor().newInstance(); // Set our handler
-            }
-
-        } catch (final Exception e) {
-            this.getLogger().severe("Actionbars are not supported on your spigot version, sorry.");
-            use18Features = false;
-            return;
-        }
-
-        if (Bukkit.getPluginManager().isPluginEnabled("Essentials")) {
-            clogger.sendMessage("Time is Money: Essentials found. Hook in it -> Will use Essentials's AFK feature if afk is enabled.");
-        }
-        new Metrics(this);
-        
-        clogger.sendMessage(CC("&aTime is Money &2v" + PL_VERSION + " &astarted."));
-    }
-
-    @Override
-    public void onDisable() {
-        FileOutputStream fos;
-        try {
-            fos = new FileOutputStream(new File("plugins/TimeIsMoney/payed_today.data"));
-            ObjectOutputStream oos = new ObjectOutputStream(fos);
-            oos.writeObject(payedMoney);
-            oos.close();
-        } catch (Exception ignored) {
-
-        }
-    }
-
-    public void reload() {
-        //File config = new File("plugins/TimeIsMoney/config.yml");
-        //finalconfig = YamlConfiguration.loadConfiguration(config);
-        Bukkit.getPluginManager().disablePlugin(this);
-        Bukkit.getPluginManager().enablePlugin(this);
-        //this.onDisable();
-        //this.onEnable();
-        //loadPayouts();
-    }
-
-    private void loadPayouts() {
-        try {
-            payouts.clear();
-            for (String key : finalconfig.getConfigurationSection("payouts").getKeys(false)) {
-                Payout payout = new Payout();
-                payout.max_payout_per_day = finalconfig.getDouble("payouts." + key + ".max_payout_per_day");
-                payout.payout_amount = finalconfig.getDouble("payouts." + key + ".payout_amount");
-                if (finalconfig.getString("payouts." + key + ".permission") != null) {
-                    payout.permission = finalconfig.getString("payouts." + key + ".permission");
-                }
-                if (finalconfig.getString("payouts." + key + ".commands") != null) {
-                    payout.commands = finalconfig.getStringList("payouts." + key + ".commands");
-                }
-
-                if (finalconfig.getString("payouts." + key + ".chance") != null) {
-                    payout.chance = finalconfig.getInt("payouts." + key + ".chance");
-                }
-                payouts.add(payout);
-            }
-            clogger.sendMessage(CC("[TimeIsMoney] &aLoaded " + finalconfig.getConfigurationSection("payouts").getKeys(false).size() + " Payouts!"));
-        } catch (Exception e) {
-            clogger.sendMessage(CC("[TimeIsMoney] &aFailed to load Payouts! (May made a mistake in config.yml?)"));
-        }
-    }
-
-    private boolean setupEconomy() {
-        RegisteredServiceProvider<net.milkbowl.vault.economy.Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
-        if (economyProvider != null) {
-            economy = economyProvider.getProvider();
-        }
-
-        return (economy != null);
-    }
-
-    private Payout getPayOutForPlayer(Player p) {
-        Payout finalpayout = null;
-        if (!this.getConfig().getBoolean("choose-payout-by-chance")) {
-            //by Permission
-            for (Payout payout : payouts) {
-                if (payout.permission.equalsIgnoreCase("")) finalpayout = payout;
-                if (p.hasPermission(payout.permission)) {
-                    finalpayout = payout;
-                }
-            }
-        } else {
-            //by Chance
-            Random rnd = new Random();
-            List<Payout> list = new ArrayList<>();
-            for (Payout payout : payouts) {
-                for (int i = 0; i < payout.chance; i++) list.add(payout);
-            }
-            finalpayout = list.get(rnd.nextInt(list.size() - 1));
-        }
-        return finalpayout;
-    }
-
-    @SuppressWarnings("deprecation")
-    private void pay(Player p) {
-        if (p == null) return;
-
-        //REACHED MAX PAYOUT CHECK
-        double payed = 0;
-        if (payedMoney.containsKey(p.getName())) {
-            payed = payedMoney.get(p.getName());
-        }
-        Payout payout = getPayOutForPlayer(p);
-        if (payout == null) return;
-        if (payout.max_payout_per_day != -1) {
-            if (payed >= payout.max_payout_per_day) { //Reached max payout
-                if (finalconfig.getBoolean("display-messages-in-chat")) {
-                    sendMessage(p, finalconfig.getString("message_payoutlimit_reached"));
-                }
-                if (finalconfig.getBoolean("display-messages-in-actionbar") && use18Features) {
-                    sendActionbar(p, finalconfig.getString("message_payoutlimit_reached_actionbar"));
-                }
-                return;
-            }
-        }
-
-        if (!finalconfig.getBoolean("allow-multiple-accounts")) {
-            if (boundIPs.containsKey(p.getAddress().getHostName())) {
-                if (!boundIPs.get(p.getAddress().getHostName()).equals(p.getUniqueId())) {
-                    sendMessage(p, finalconfig.getString("message_multiple_ips"));
-                    return;
-                }
-            }
-        }
-
-        //AFK CHECK
-        if (!finalconfig.getBoolean("afk_payout") && !p.hasPermission("tim.afkbypass")) {
-            //ESENTIALS_AFK_FEATURE
-            if (Bukkit.getServer().getPluginManager().isPluginEnabled("Essentials")) {
-                Essentials essentials = (com.earth2me.essentials.Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials");
-                if (essentials.getUser(p).isAfk()) {
-                    //AFK
-                    if (finalconfig.getBoolean("display-messages-in-chat")) {
-                        sendMessage(p, finalconfig.getString("message_afk"));
-                    }
-                    if (finalconfig.getBoolean("display-messages-in-actionbar") && use18Features) {
-                        sendActionbar(p, finalconfig.getString("message_afk_actionbar"));
-                    }
-                    return;
-                }
-            } else
-                //PLUGIN_AFK_FEATURE
-                if (lastLocation.containsKey(p.getUniqueId())) { //AntiAFK
-                    if (lastLocation.get(p.getUniqueId()).getX() == p.getLocation().getX() && lastLocation.get(p.getUniqueId()).getY() == p.getLocation().getY() && lastLocation.get(p.getUniqueId()).getZ() == p.getLocation().getZ() || lastLocation.get(p.getUniqueId()).getYaw() == p.getLocation().getYaw()) {
-                        //AFK
-                        if (finalconfig.getBoolean("display-messages-in-chat")) {
-                            sendMessage(p, finalconfig.getString("message_afk"));
-                        }
-                        if (finalconfig.getBoolean("display-messages-in-actionbar") && use18Features) {
-                            sendActionbar(p, finalconfig.getString("message_afk_actionbar"));
-                        }
-                        return;
-                    }
-                }
-        }
-
-        //DEPOSIT
-        if (finalconfig.getBoolean("store-money-in-bank")) {
-            ATM.depositBank(p, payout.payout_amount);
-        } else {
-            double before = 0;
-            if (economy.hasAccount(p)) {
-                before = economy.getBalance(p);
-            }
-
-            economy.depositPlayer(p, payout.payout_amount);
-            log(p.getName() + ": Deposited: " + payout.payout_amount + " Balance-before: " + before + " Balance-now: " + economy.getBalance(p));
-
-        }
-        if (finalconfig.getBoolean("display-messages-in-chat")) {
-            sendMessage(p, message.replace("%money%", economy.format(payout.payout_amount)));
-        }
-        if (finalconfig.getBoolean("display-messages-in-actionbar") && use18Features) {
-            sendActionbar(p, messageActionbar.replace("%money%", economy.format(payout.payout_amount)));
-        }
-        for (String cmd : payout.commands) {
-            dispatchCommandSync(cmd.replace("/", "").replaceAll("%player%", p.getName()));
-        }
-
-        //ADD PAYED MONEY
-        if (payedMoney.containsKey(p.getName())) {
-            payedMoney.put(p.getName(), payedMoney.get(p.getName()) + payout.payout_amount);
-        } else {
-            payedMoney.put(p.getName(), payout.payout_amount);
-        }
-
-        lastLocation.put(p.getUniqueId(), p.getLocation());
-
-    }
-
-    private void dispatchCommandSync(final String cmd) {
-        final Server server = this.getServer();
-
-        this.getServer().getScheduler().runTask(this, () -> server.dispatchCommand(server.getConsoleSender(), cmd));
-    }
-
-    @SuppressWarnings("deprecation")
-    private void log(String msg) {
-        if (!this.getConfig().getBoolean("debug-log")) {
-            return;
-        }
-        Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
-
-        File file = new File("plugins/TimeIsMoney/log.txt");
-        try {
-            if (!file.exists()) {
-                file.createNewFile();
-            }
-            FileReader pr = new FileReader(file);
-            int number;
-            StringBuffer text = new StringBuffer();
-            while ((number = pr.read()) != -1) {
-
-                text.append((char) number);
-            }
-            text.append(currentTimestamp.toGMTString()).append(":").append(msg).append("\n");
-            PrintWriter pw = new PrintWriter(file);
-            pw.print(text);
-
-            pw.close();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    private void sendMessage(Player p, String msg) {
-        if (msg == null) return;
-        if (msg.length() == 0) return;
-        p.sendMessage(CC(msg));
-    }
-
-    private void sendActionbar(final Player p, final String msg) {
-        if (msg.length() == 0) return;
-        int times = finalconfig.getInt("display-messages-in-actionbar-time");
-        if (times == 1) {
-            if (actionBarUtils != null) {
-                actionBarUtils.sendActionBarMessage(p, msg);
-            }
-        } else if (times > 1) {
-            if (actionBarUtils != null) {
-                actionBarUtils.sendActionBarMessage(p, msg);
-            }
-            times--;
-            for (int i = 0; i < times; i++) {
-                Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> actionBarUtils.sendActionBarMessage(p, CC(msg)), 20L * i);
-            }
-        }
-    }
-
-    private boolean unloadPlugin(String pluginName)
-            throws Exception {
-        PluginManager manager = getServer().getPluginManager();
-        SimplePluginManager spmanager = (SimplePluginManager) manager;
-        if (spmanager != null) {
-            Field pluginsField = spmanager.getClass().getDeclaredField("plugins");
-            pluginsField.setAccessible(true);
-            List<Plugin> plugins = (List) pluginsField.get(spmanager);
-
-            Field lookupNamesField = spmanager.getClass().getDeclaredField("lookupNames");
-            lookupNamesField.setAccessible(true);
-            Map<String, Plugin> lookupNames = (Map) lookupNamesField.get(spmanager);
-
-            Field commandMapField = spmanager.getClass().getDeclaredField("commandMap");
-            commandMapField.setAccessible(true);
-            SimpleCommandMap commandMap = (SimpleCommandMap) commandMapField.get(spmanager);
-
-            Field knownCommandsField;
-            Map<String, Command> knownCommands = null;
-            if (commandMap != null) {
-                knownCommandsField = commandMap.getClass().getDeclaredField("knownCommands");
-                knownCommandsField.setAccessible(true);
-                knownCommands = (Map) knownCommandsField.get(commandMap);
-            }
-            Plugin plugin;
-            Iterator<Map.Entry<String, Command>> it;
-            for (Plugin plugin1 : manager.getPlugins()) {
-                if (plugin1.getDescription().getName().equalsIgnoreCase(pluginName)) {
-                    manager.disablePlugin(plugin1);
-                    if ((plugins != null) && (plugins.contains(plugin1))) {
-                        plugins.remove(plugin1);
-                    }
-                    if ((lookupNames != null) && (lookupNames.containsKey(pluginName))) {
-                        lookupNames.remove(pluginName);
-                    }
-                    if (commandMap != null) {
-                        for (it = knownCommands.entrySet().iterator(); it.hasNext(); ) {
-                            Map.Entry<String, Command> entry = it.next();
-                            if ((entry.getValue() instanceof PluginCommand)) {
-                                PluginCommand command = (PluginCommand) entry.getValue();
-                                if (command.getPlugin() == plugin1) {
-                                    command.unregister(commandMap);
-                                    it.remove();
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        } else {
-
-            return true;
-        }
-
-
-        return true;
-    }
-
-    private boolean loadPlugin(String pluginName) {
-        try {
-            PluginManager manager = getServer().getPluginManager();
-            Plugin plugin = manager.loadPlugin(new File("plugins", pluginName + ".jar"));
-            if (plugin == null) {
-                return false;
-            }
-            plugin.onLoad();
-            manager.enablePlugin(plugin);
-        } catch (Exception e) {
-
-            return false;
-        }
-
-        return true;
-    }
-
-    private boolean reloadPlugin(String pluginName)
-            throws Exception {
-        boolean unload = unloadPlugin(pluginName);
-        boolean load = loadPlugin(pluginName);
-
-        if ((unload) && (load)) {
-
-        } else {
-
-            return false;
-        }
-        return true;
-    }
+	/**
+	 * The economy being used by vault.
+	 */
+	static net.milkbowl.vault.economy.Economy economy = null;
+	/**
+	 * The actionbar utils class, null if not using a supported server version.
+	 */
+	private static ActionBarUtils actionBarUtils = null;
+	/**
+	 * The config version number.
+	 */
+	private static final int CFG_VERSION = 12;
+	/**
+	 * The TimeIsMoney version.
+	 */
+	static String PL_VERSION;
+	/**
+	 * The TimeIsMoney config.
+	 */
+	static YamlConfiguration finalconfig;
+	/**
+	 * The list of worlds where the payout feature will be disabled.
+	 */
+	private static List<String> disabledWorlds;
+	/**
+	 * The IPs of each UUID.
+	 */
+	private static final HashMap<String, UUID> boundIPs = new HashMap<>();
+	/**
+	 * The payouts listed in the config.
+	 */
+	private final List<Payout> payouts = new ArrayList<>();
+	/**
+	 * The payouts for the day.
+	 */
+	private HashMap<String, Double> payedMoney = new HashMap<>();
+	/**
+	 * The time online in seconds of each player by UUID.
+	 */
+	private final HashMap<UUID, Integer> onlineSeconds = new HashMap<>();
+	/**
+	 * The last location of each player by UUID.
+	 */
+	private final HashMap<UUID, Location> lastLocation = new HashMap<>();
+	/**
+	 * The chat message.
+	 */
+	private String message;
+	/**
+	 * The actionbar message.
+	 */
+	private String messageActionbar;
+	/**
+	 * The console logger.
+	 */
+	private final ConsoleCommandSender clogger = this.getServer().getConsoleSender();
+	/**
+	 * The current day.
+	 */
+	private int currentDay = 0;
+	/**
+	 * If actionbars are supported for the server's version.
+	 */
+	private boolean useActionbars = true;
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	@SuppressWarnings({"deprecation", "unchecked"})
+	@Override
+	public void onEnable() {
+		this.getCommand("timeismoney").setExecutor(new Cmd(this));
+		PL_VERSION = this.getDescription().getVersion();
+		currentDay = (new Date()).getDay();
+		
+		File config = new File("plugins/TimeIsMoney/config.yml");
+		if (config.exists()) {
+			YamlConfiguration cfg = YamlConfiguration.loadConfiguration(config);
+			String old_config = "config_old " + cfg.getInt("configuration-version") + ".yml";
+			if (cfg.contains("configuration-version")) {
+				if (cfg.getInt("configuration-version") < CFG_VERSION) {
+					clogger.sendMessage(CC("[TimeIsMoney] &cYOU ARE USING AN OLD CONFIG-VERSION. The plugin CANT work with this."));
+					clogger.sendMessage(CC("[TimeIsMoney] &cI have created an new config for you. The old one is saved as config_old.yml."));
+					config.renameTo(new File("plugins/TimeIsMoney/" + old_config));
+				}
+			}
+			this.saveDefaultConfig();
+			for (String key : cfg.getConfigurationSection("").getKeys(true)) {
+				if (!this.getConfig().contains(key)) {
+					this.getConfig().set(key, cfg.get(key));
+				}
+			}
+		} else {
+			this.saveDefaultConfig();
+		}
+		
+		
+		finalconfig = YamlConfiguration.loadConfiguration(config);
+		disabledWorlds = getConfig().getStringList("disabled_in_worlds");
+		
+		if (getConfig().getBoolean("enable_atm")) new ATM(this);
+		
+		final int seconds = getConfig().getInt("give_money_every_second");
+		Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
+			try {
+				for (Player p : Bukkit.getOnlinePlayers()) {
+					if (disabledWorlds.contains(p.getWorld().getName())) continue;
+					if (!boundIPs.containsKey(p.getAddress().getHostName())) {
+						boundIPs.put(p.getAddress().getHostName(), p.getUniqueId());
+					}
+					if (onlineSeconds.containsKey(p.getUniqueId())) {
+						
+						onlineSeconds.put(p.getUniqueId(), onlineSeconds.get(p.getUniqueId()) + 1);
+					} else {
+						onlineSeconds.put(p.getUniqueId(), 1);
+					}
+					if (onlineSeconds.get(p.getUniqueId()) > seconds) {
+						pay(p);
+						onlineSeconds.remove(p.getUniqueId());
+					}
+				}
+			} catch (NullPointerException ignored) {
+			}
+		}, 20L, 20L);
+		Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
+			if (currentDay != new Date().getDay()) { //Next day, clear payouts!
+				log("Cleared all payouts");
+				payedMoney.clear();
+				currentDay = new Date().getDay();
+			}
+		}, 20L * 60, 20L * 60 * 15);
+		setupEconomy();
+		
+		message = finalconfig.getString("message");
+		message = CC(message);
+		messageActionbar = finalconfig.getString("message_actionbar");
+		messageActionbar = CC(messageActionbar);
+		
+		try {
+			FileInputStream fis = new FileInputStream(new File("plugins/TimeIsMoney/payed_today.data"));
+			ObjectInputStream ois = new ObjectInputStream(fis);
+			payedMoney = (HashMap<String, Double>) ((HashMap<String, Double>) ois.readObject()).clone();
+			
+			ois.close();
+		} catch (Exception ignored) {
+		
+		}
+		
+		loadPayouts();
+		
+		
+		String packageName = this.getServer().getClass().getPackage().getName();
+		// Get full package string of CraftServer.
+		// org.bukkit.craftbukkit.version
+		String Bukkitversion = packageName.substring(packageName.lastIndexOf('.') + 1);
+		// Get the last element of the package
+		try {
+			final Class<?> clazz = Class.forName("de.Linus122.TimeIsMoney.version." + Bukkitversion + ".NBTUtils");
+			// Check if we have a NMSHandler class at that location.
+			if (ActionBarUtils.class.isAssignableFrom(clazz)) { // Make sure it actually implements NMS
+				actionBarUtils = (ActionBarUtils) clazz.getConstructor().newInstance(); // Set our handler
+			}
+			
+		} catch (final Exception e) {
+			this.getLogger().severe("Actionbars are not supported on your spigot version, sorry.");
+			useActionbars = false;
+			return;
+		}
+		
+		if (Bukkit.getPluginManager().isPluginEnabled("Essentials")) {
+			clogger.sendMessage("Time is Money: Essentials found. Hook in it -> Will use Essentials's AFK feature if afk is enabled.");
+		}
+		new Metrics(this);
+		
+		clogger.sendMessage(CC("&aTime is Money &2v" + PL_VERSION + " &astarted."));
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void onDisable() {
+		FileOutputStream fos;
+		try {
+			fos = new FileOutputStream(new File("plugins/TimeIsMoney/payed_today.data"));
+			ObjectOutputStream oos = new ObjectOutputStream(fos);
+			oos.writeObject(payedMoney);
+			oos.close();
+		} catch (Exception ignored) {
+		}
+	}
+	
+	/**
+	 * Reloads TimeIsMoney.
+	 */
+	void reload() {
+		//File config = new File("plugins/TimeIsMoney/config.yml");
+		//finalconfig = YamlConfiguration.loadConfiguration(config);
+		Bukkit.getPluginManager().disablePlugin(this);
+		Bukkit.getPluginManager().enablePlugin(this);
+		//this.onDisable();
+		//this.onEnable();
+		//loadPayouts();
+	}
+	
+	/**
+	 * Loads the payouts.
+	 */
+	private void loadPayouts() {
+		try {
+			payouts.clear();
+			for (String key : finalconfig.getConfigurationSection("payouts").getKeys(false)) {
+				Payout payout = new Payout();
+				payout.max_payout_per_day = finalconfig.getDouble("payouts." + key + ".max_payout_per_day");
+				payout.payout_amount = finalconfig.getDouble("payouts." + key + ".payout_amount");
+				if (finalconfig.getString("payouts." + key + ".permission") != null) {
+					payout.permission = finalconfig.getString("payouts." + key + ".permission");
+				}
+				if (finalconfig.getString("payouts." + key + ".commands") != null) {
+					payout.commands = finalconfig.getStringList("payouts." + key + ".commands");
+				}
+				
+				if (finalconfig.getString("payouts." + key + ".chance") != null) {
+					payout.chance = finalconfig.getInt("payouts." + key + ".chance");
+				}
+				payouts.add(payout);
+			}
+			clogger.sendMessage(CC("[TimeIsMoney] &aLoaded " + finalconfig.getConfigurationSection("payouts").getKeys(false).size() + " Payouts!"));
+		} catch (Exception e) {
+			clogger.sendMessage(CC("[TimeIsMoney] &aFailed to load Payouts! (May made a mistake in config.yml?)"));
+		}
+	}
+	
+	/**
+	 * Sets up the vault economy.
+	 *
+	 * @return True if the economy was set up, false otherwise.
+	 */
+	private boolean setupEconomy() {
+		RegisteredServiceProvider<net.milkbowl.vault.economy.Economy> economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
+		if (economyProvider != null) {
+			economy = economyProvider.getProvider();
+		}
+		
+		return economy != null;
+	}
+	
+	/**
+	 * Gets the payout for the specified player.
+	 *
+	 * @param p The player to get the payout of.
+	 * @return The payout of the player.
+	 */
+	private Payout getPayOutForPlayer(Player p) {
+		Payout finalpayout = null;
+		if (!this.getConfig().getBoolean("choose-payout-by-chance")) {
+			//by Permission
+			for (Payout payout : payouts) {
+				if (payout.permission.equalsIgnoreCase("")) finalpayout = payout;
+				if (p.hasPermission(payout.permission)) {
+					finalpayout = payout;
+				}
+			}
+		} else {
+			//by Chance
+			Random rnd = new Random();
+			List<Payout> list = new ArrayList<>();
+			for (Payout payout : payouts) {
+				for (int i = 0; i < payout.chance; i++) list.add(payout);
+			}
+			finalpayout = list.get(rnd.nextInt(list.size() - 1));
+		}
+		return finalpayout;
+	}
+	
+	/**
+	 * Pays the specified player.
+	 *
+	 * @param p The player to pay.
+	 */
+	@SuppressWarnings("deprecation")
+	private void pay(Player p) {
+		if (p == null) return;
+		
+		//REACHED MAX PAYOUT CHECK
+		double payed = 0;
+		if (payedMoney.containsKey(p.getName())) {
+			payed = payedMoney.get(p.getName());
+		}
+		Payout payout = getPayOutForPlayer(p);
+		if (payout == null) return;
+		if (payout.max_payout_per_day != -1) {
+			if (payed >= payout.max_payout_per_day) { //Reached max payout
+				if (finalconfig.getBoolean("display-messages-in-chat")) {
+					sendMessage(p, finalconfig.getString("message_payoutlimit_reached"));
+				}
+				if (finalconfig.getBoolean("display-messages-in-actionbar") && useActionbars) {
+					sendActionbar(p, finalconfig.getString("message_payoutlimit_reached_actionbar"));
+				}
+				return;
+			}
+		}
+		
+		if (!finalconfig.getBoolean("allow-multiple-accounts")) {
+			if (boundIPs.containsKey(p.getAddress().getHostName())) {
+				if (!boundIPs.get(p.getAddress().getHostName()).equals(p.getUniqueId())) {
+					sendMessage(p, finalconfig.getString("message_multiple_ips"));
+					return;
+				}
+			}
+		}
+		
+		//AFK CHECK
+		if (!finalconfig.getBoolean("afk_payout") && !p.hasPermission("tim.afkbypass")) {
+			//ESENTIALS_AFK_FEATURE
+			if (Bukkit.getServer().getPluginManager().isPluginEnabled("Essentials")) {
+				Essentials essentials = (com.earth2me.essentials.Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials");
+				if (essentials.getUser(p).isAfk()) {
+					//AFK
+					if (finalconfig.getBoolean("display-messages-in-chat")) {
+						sendMessage(p, finalconfig.getString("message_afk"));
+					}
+					if (finalconfig.getBoolean("display-messages-in-actionbar") && useActionbars) {
+						sendActionbar(p, finalconfig.getString("message_afk_actionbar"));
+					}
+					return;
+				}
+			} else {
+				//PLUGIN_AFK_FEATURE
+				if (lastLocation.containsKey(p.getUniqueId())) { //AntiAFK
+					if (lastLocation.get(p.getUniqueId()).getX() == p.getLocation().getX() && lastLocation.get(p.getUniqueId()).getY() == p.getLocation().getY() && lastLocation.get(p.getUniqueId()).getZ() == p.getLocation().getZ() || lastLocation.get(p.getUniqueId()).getYaw() == p.getLocation().getYaw()) {
+						//AFK
+						if (finalconfig.getBoolean("display-messages-in-chat")) {
+							sendMessage(p, finalconfig.getString("message_afk"));
+						}
+						if (finalconfig.getBoolean("display-messages-in-actionbar") && useActionbars) {
+							sendActionbar(p, finalconfig.getString("message_afk_actionbar"));
+						}
+						return;
+					}
+				}
+			}
+		}
+		
+		//DEPOSIT
+		if (finalconfig.getBoolean("store-money-in-bank")) {
+			ATM.depositBank(p, payout.payout_amount);
+		} else {
+			double before = 0;
+			if (economy.hasAccount(p)) {
+				before = economy.getBalance(p);
+			}
+			
+			economy.depositPlayer(p, payout.payout_amount);
+			log(p.getName() + ": Deposited: " + payout.payout_amount + " Balance-before: " + before + " Balance-now: " + economy.getBalance(p));
+			
+		}
+		if (finalconfig.getBoolean("display-messages-in-chat")) {
+			sendMessage(p, message.replace("%money%", economy.format(payout.payout_amount)));
+		}
+		if (finalconfig.getBoolean("display-messages-in-actionbar") && useActionbars) {
+			sendActionbar(p, messageActionbar.replace("%money%", economy.format(payout.payout_amount)));
+		}
+		for (String cmd : payout.commands) {
+			dispatchCommandSync(cmd.replace("/", "").replaceAll("%player%", p.getName()));
+		}
+		
+		//ADD PAYED MONEY
+		if (payedMoney.containsKey(p.getName())) {
+			payedMoney.put(p.getName(), payedMoney.get(p.getName()) + payout.payout_amount);
+		} else {
+			payedMoney.put(p.getName(), payout.payout_amount);
+		}
+		
+		lastLocation.put(p.getUniqueId(), p.getLocation());
+	}
+	
+	/**
+	 * Dispatches a command as sync.
+	 *
+	 * @param cmd The command to dispatch sync.
+	 */
+	private void dispatchCommandSync(final String cmd) {
+		final Server server = this.getServer();
+		
+		this.getServer().getScheduler().runTask(this, () -> server.dispatchCommand(server.getConsoleSender(), cmd));
+	}
+	
+	/**
+	 * Logs debug information if enabled in the config.
+	 *
+	 * @param msg The debug message to log.
+	 */
+	@SuppressWarnings("deprecation")
+	private void log(String msg) {
+		if (!this.getConfig().getBoolean("debug-log")) {
+			return;
+		}
+		Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
+		
+		File file = new File("plugins/TimeIsMoney/log.txt");
+		try {
+			if (!file.exists()) {
+				file.createNewFile();
+			}
+			FileReader pr = new FileReader(file);
+			int number;
+			StringBuffer text = new StringBuffer();
+			while ((number = pr.read()) != -1) {
+				
+				text.append((char) number);
+			}
+			text.append(currentTimestamp.toGMTString()).append(":").append(msg).append("\n");
+			PrintWriter pw = new PrintWriter(file);
+			pw.print(text);
+			
+			pw.close();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+	
+	/**
+	 * Sends a chat message that supports color codes to the specified player.
+	 *
+	 * @param p The player to send the chat message to.
+	 * @param msg The message the chat should give the player.
+	 */
+	private void sendMessage(Player p, String msg) {
+		if (msg == null) return;
+		if (msg.length() == 0) return;
+		p.sendMessage(CC(msg));
+	}
+	
+	/**
+	 * Sends an actionbar message to the specified player.
+	 *
+	 * @param p The player to send the actionbar message to.
+	 * @param msg The message the actionbar should give to the player.
+	 */
+	private void sendActionbar(final Player p, final String msg) {
+		if (msg.length() == 0) return;
+		int times = finalconfig.getInt("display-messages-in-actionbar-time");
+		if (times == 1) {
+			if (actionBarUtils != null) {
+				actionBarUtils.sendActionBarMessage(p, msg);
+			}
+		} else if (times > 1) {
+			if (actionBarUtils != null) {
+				actionBarUtils.sendActionBarMessage(p, msg);
+			}
+			times--;
+			for (int i = 0; i < times; i++) {
+				Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> actionBarUtils.sendActionBarMessage(p, CC(msg)), 20L * i);
+			}
+		}
+	}
+	
+	/**
+	 * Unloads the specified plugin.
+	 *
+	 * @param pluginName The name of the plugin to unload.
+	 * @return True if the specified plugin was unloaded, false otherwise.
+	 */
+	private boolean unloadPlugin(String pluginName)
+			throws Exception {
+		PluginManager manager = getServer().getPluginManager();
+		SimplePluginManager spmanager = (SimplePluginManager) manager;
+		if (spmanager != null) {
+			Field pluginsField = spmanager.getClass().getDeclaredField("plugins");
+			pluginsField.setAccessible(true);
+			List<Plugin> plugins = (List) pluginsField.get(spmanager);
+			
+			Field lookupNamesField = spmanager.getClass().getDeclaredField("lookupNames");
+			lookupNamesField.setAccessible(true);
+			Map<String, Plugin> lookupNames = (Map) lookupNamesField.get(spmanager);
+			
+			Field commandMapField = spmanager.getClass().getDeclaredField("commandMap");
+			commandMapField.setAccessible(true);
+			SimpleCommandMap commandMap = (SimpleCommandMap) commandMapField.get(spmanager);
+			
+			Field knownCommandsField;
+			Map<String, Command> knownCommands = null;
+			if (commandMap != null) {
+				knownCommandsField = commandMap.getClass().getDeclaredField("knownCommands");
+				knownCommandsField.setAccessible(true);
+				knownCommands = (Map) knownCommandsField.get(commandMap);
+			}
+			Plugin plugin;
+			Iterator<Map.Entry<String, Command>> it;
+			for (Plugin plugin1 : manager.getPlugins()) {
+				if (plugin1.getDescription().getName().equalsIgnoreCase(pluginName)) {
+					manager.disablePlugin(plugin1);
+					if ((plugins != null) && (plugins.contains(plugin1))) {
+						plugins.remove(plugin1);
+					}
+					if ((lookupNames != null) && (lookupNames.containsKey(pluginName))) {
+						lookupNames.remove(pluginName);
+					}
+					if (commandMap != null) {
+						for (it = knownCommands.entrySet().iterator(); it.hasNext(); ) {
+							Map.Entry<String, Command> entry = it.next();
+							if ((entry.getValue() instanceof PluginCommand)) {
+								PluginCommand command = (PluginCommand) entry.getValue();
+								if (command.getPlugin() == plugin1) {
+									command.unregister(commandMap);
+									it.remove();
+								}
+							}
+						}
+					}
+				}
+			}
+		} else {
+			return true;
+		}
+		return true;
+	}
+	
+	/**
+	 * Loads the specified plugin.
+	 *
+	 * @param pluginName The name of the plugin to load.
+	 * @return True if the specified plugin was loaded, false otherwise.
+	 */
+	private boolean loadPlugin(String pluginName) {
+		try {
+			PluginManager manager = getServer().getPluginManager();
+			Plugin plugin = manager.loadPlugin(new File("plugins", pluginName + ".jar"));
+			if (plugin == null) {
+				return false;
+			}
+			plugin.onLoad();
+			manager.enablePlugin(plugin);
+		} catch (Exception e) {
+			return false;
+		}
+		return true;
+	}
+	
+	/**
+	 * Reloads the specified plugin.
+	 *
+	 * @param pluginName The name of the plugin to reload.
+	 * @return True if the plugin was reloaded, false otherwise.
+	 * @throws Exception If an error occurred while loading or unloading the specified plugin.
+	 */
+	private boolean reloadPlugin(String pluginName)
+			throws Exception {
+		boolean unload = unloadPlugin(pluginName);
+		boolean load = loadPlugin(pluginName);
+		
+		return unload && load;
+	}
 }

+ 64 - 55
Plugin/src/main/java/de/Linus122/TimeIsMoney/Metrics.java

@@ -1,5 +1,9 @@
 package de.Linus122.TimeIsMoney;
 
+import com.google.gson.Gson;
+import org.bukkit.plugin.Plugin;
+
+import javax.net.ssl.HttpsURLConnection;
 import java.io.BufferedReader;
 import java.io.DataOutputStream;
 import java.io.File;
@@ -11,16 +15,12 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 
-import javax.net.ssl.HttpsURLConnection;
-
-import org.bukkit.plugin.Plugin;
-
-import com.google.gson.Gson;
-
-/*
- * SpaceIOMetrics main class by Linus122
- * version: 0.03
- * 
+/**
+ * SpaceIOMetrics main class by
+ *
+ * @author Linus122
+ * @version 0.03
+ * @since 1.9.6.1
  */
 public class Metrics {
 	private Plugin pl;
@@ -30,44 +30,48 @@ public class Metrics {
 	private final String VERSION = "0.03";
 	private int REFRESH_INTERVAL = 600000;
 	
-	public Metrics(Plugin pl){
+	public Metrics(Plugin pl) {
 		this.pl = pl;
 		
 		// check if Metrics are disabled (checks if file "disablemetrics" is added to the plugins's folder
 		try {
 			Files.list(pl.getDataFolder().getParentFile().toPath()).filter(Files::isRegularFile).forEach(v -> {
-				if(v.getFileName().toString().equalsIgnoreCase("disablemetrics")){
+				if (v.getFileName().toString().equalsIgnoreCase("disablemetrics")) {
 					return;
 				}
 			});
 		} catch (IOException e1) {
 			e1.printStackTrace();
 		}
-
+		
 		URL = String.format(URL, pl.getName());
 		
 		// fetching refresh interval first
 		pl.getServer().getScheduler().runTaskLaterAsynchronously(pl, () -> {
 			String dataJson = collectData();
-			try{
+			try {
 				REFRESH_INTERVAL = sendData(dataJson);
-			}catch(Exception e){}
+			} catch (Exception ignored) {
+			}
 		}, 20L * 5);
 		
 		// executing repeating task, our main metrics updater
 		pl.getServer().getScheduler().runTaskTimerAsynchronously(pl, () -> {
 			String dataJson = collectData();
-			try{
+			try {
 				sendData(dataJson);
-			}catch(Exception e){}
+			} catch (Exception ignored) {
+			}
 			
 		}, 20L * (REFRESH_INTERVAL / 1000), 20L * (REFRESH_INTERVAL / 1000));
 	}
+	
 	private String collectData() {
 		Data data = new Data();
 		
 		// collect plugin list
-		for(Plugin plug : pl.getServer().getPluginManager().getPlugins()) data.plugs.put(plug.getName(), plug.getDescription().getVersion());
+		for (Plugin plug : pl.getServer().getPluginManager().getPlugins())
+			data.plugs.put(plug.getName(), plug.getDescription().getVersion());
 		
 		// fetch online players
 		data.onlinePlayers = pl.getServer().getOnlinePlayers().size();
@@ -89,7 +93,7 @@ public class Metrics {
 		
 		// online mode
 		data.onlineMode = pl.getServer().getOnlineMode();
-
+		
 		// software information
 		data.osName = System.getProperty("os.name");
 		data.osArch = System.getProperty("os.arch");
@@ -97,20 +101,21 @@ public class Metrics {
 		
 		data.diskSize = new File("/").getTotalSpace();
 		
-		if(data.osName.equals("Linux")){
+		if (data.osName.equals("Linux")) {
 			data.linuxDistro = getDistro();
 		}
 		
 		return gson.toJson(data);
 	}
-	private int sendData(String dataJson) throws Exception{
+	
+	private int sendData(String dataJson) throws Exception {
 		java.net.URL obj = new java.net.URL(URL);
 		HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
-
+		
 		con.setRequestMethod("POST");
 		con.setRequestProperty("User-Agent", "Java/Bukkit");
 		con.setRequestProperty("Metrics-Version", this.VERSION);
-
+		
 		con.setDoOutput(true);
 		DataOutputStream wr = new DataOutputStream(con.getOutputStream());
 		wr.writeBytes(dataJson);
@@ -119,42 +124,46 @@ public class Metrics {
 		
 		return Integer.parseInt(con.getHeaderField("interval-millis"));
 	}
-	private String getVersion(){
-        String packageName = pl.getServer().getClass().getPackage().getName();
-        return  packageName.substring(packageName.lastIndexOf('.') + 1);
+	
+	private String getVersion() {
+		String packageName = pl.getServer().getClass().getPackage().getName();
+		return packageName.substring(packageName.lastIndexOf('.') + 1);
 	}
+	
 	// method source: http://www.jcgonzalez.com/linux-get-distro-from-java-examples
-	private String getDistro(){
-		 //lists all the files ending with -release in the etc folder
-        File dir = new File("/etc/");
-        File fileList[] = new File[0];
-        if(dir.exists()){
-            fileList =  dir.listFiles(new FilenameFilter() {
-                public boolean accept(File dir, String filename) {
-                    return filename.endsWith("-release");
-                }
-            });
-        }
-        //looks for the version file (not all linux distros)
-        File fileVersion = new File("/proc/version");
-        if(fileVersion.exists()){
-            fileList = Arrays.copyOf(fileList,fileList.length+1);
-            fileList[fileList.length-1] = fileVersion;
-        }       
-        //prints first version-related file
-        for (File f : fileList) {
-            try {
-                BufferedReader br = new BufferedReader(new FileReader(f));
-                String strLine = null;
-                while ((strLine = br.readLine()) != null) {
-                    return strLine;
-                }
-                br.close();
-            } catch (Exception e) {}
-        }
-		return "unknown";    
+	private String getDistro() {
+		//lists all the files ending with -release in the etc folder
+		File dir = new File("/etc/");
+		File fileList[] = new File[0];
+		if (dir.exists()) {
+			fileList = dir.listFiles(new FilenameFilter() {
+				public boolean accept(File dir, String filename) {
+					return filename.endsWith("-release");
+				}
+			});
+		}
+		//looks for the version file (not all linux distros)
+		File fileVersion = new File("/proc/version");
+		if (fileVersion.exists()) {
+			fileList = Arrays.copyOf(fileList, fileList.length + 1);
+			fileList[fileList.length - 1] = fileVersion;
+		}
+		//prints first version-related file
+		for (File f : fileList) {
+			try {
+				BufferedReader br = new BufferedReader(new FileReader(f));
+				String strLine = null;
+				while ((strLine = br.readLine()) != null) {
+					return strLine;
+				}
+				br.close();
+			} catch (Exception ignored) {
+			}
+		}
+		return "unknown";
 	}
 }
+
 class Data {
 	HashMap<String, String> plugs = new HashMap<String, String>();
 	int onlinePlayers;

+ 22 - 1
Plugin/src/main/java/de/Linus122/TimeIsMoney/Payout.java

@@ -3,10 +3,31 @@ package de.Linus122.TimeIsMoney;
 import java.util.ArrayList;
 import java.util.List;
 
-public class Payout {
+/**
+ * Payout information.
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
+class Payout {
+	/**
+	 * The payout amount.
+	 */
 	double payout_amount = 0;
+	/**
+	 * The max payout per day.
+	 */
 	double max_payout_per_day = 0;
+	/**
+	 * The permission to require for the payout, blank if none.
+	 */
 	String permission = "";
+	/**
+	 * The chance of getting the payout.
+	 */
 	int chance = 0;
+	/**
+	 * The list of commands to execute if this payout is earned.
+	 */
 	List<String> commands = new ArrayList<>();
 }

+ 12 - 0
Tools/src/main/java/de/Linus122/TimeIsMoney/tools/ActionBarUtils.java

@@ -2,6 +2,18 @@ package de.Linus122.TimeIsMoney.tools;
 
 import org.bukkit.entity.Player;
 
+/**
+ * Interface that allows sending of actionbar messages for different versions of Spigot.
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
 public interface ActionBarUtils {
+	/**
+	 * Sends an actionbar message to the specified player.
+	 *
+	 * @param p The player to send the actionbar message to.
+	 * @param message The message the actionbar should give to the player.
+	 */
 	void sendActionBarMessage(Player p, String message);
 }

+ 13 - 4
Tools/src/main/java/de/Linus122/TimeIsMoney/tools/Utils.java

@@ -2,16 +2,25 @@ package de.Linus122.TimeIsMoney.tools;
 
 import org.bukkit.ChatColor;
 
+/**
+ * Utility class.
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
 public class Utils {
-	
+	/**
+	 * @throws RuntimeException utils class should not be instantiated.
+	 */
 	public Utils() {
 		throw new RuntimeException("Utils class should not be instantiated!");
 	}
 	
 	/**
-	 * Utility method which converts &<color> bukkit colors to real bukkit colors which correct symbol
-	 * @param s string to convert
-	 * @return converted string
+	 * Converts &color to {@link org.bukkit.ChatColor}.
+	 *
+	 * @param s The string to convert to {@link org.bukkit.ChatColor}.
+	 * @return The converted string with {@link org.bukkit.ChatColor}.
 	 */
 	public static String CC(String s) {
 		return ChatColor.translateAlternateColorCodes('&', s);

+ 17 - 9
v1_10_R1/src/main/java/de/Linus122/TimeIsMoney/version/v1_10_R1/NBTUtils.java

@@ -1,19 +1,27 @@
 package de.Linus122.TimeIsMoney.version.v1_10_R1;
 
 import de.Linus122.TimeIsMoney.tools.ActionBarUtils;
-import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
 import net.minecraft.server.v1_10_R1.IChatBaseComponent;
 import net.minecraft.server.v1_10_R1.PacketPlayOutChat;
+import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
+import org.bukkit.entity.Player;
 
 import static de.Linus122.TimeIsMoney.tools.Utils.CC;
 
+/**
+ * NBT Utils for v1_10_R1.
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
 public class NBTUtils implements ActionBarUtils {
-  public void sendActionBarMessage(Player p, String message)
-  {
-	    IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message)  + "\"}");
-	    PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte)2);
-	    ((CraftPlayer)p).getHandle().playerConnection.sendPacket(bar);
-  }
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void sendActionBarMessage(Player p, String message) {
+		IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message) + "\"}");
+		PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte) 2);
+		((CraftPlayer) p).getHandle().playerConnection.sendPacket(bar);
+	}
 }

+ 17 - 9
v1_11_R1/src/main/java/de/Linus122/TimeIsMoney/version/v1_11_R1/NBTUtils.java

@@ -1,19 +1,27 @@
 package de.Linus122.TimeIsMoney.version.v1_11_R1;
 
 import de.Linus122.TimeIsMoney.tools.ActionBarUtils;
-import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
 import net.minecraft.server.v1_11_R1.IChatBaseComponent;
 import net.minecraft.server.v1_11_R1.PacketPlayOutChat;
+import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
+import org.bukkit.entity.Player;
 
 import static de.Linus122.TimeIsMoney.tools.Utils.CC;
 
+/**
+ * NBT Utils for v1_11_R1.
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
 public class NBTUtils implements ActionBarUtils {
-  public void sendActionBarMessage(Player p, String message)
-  {
-	    IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message)  + "\"}");
-	    PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte)2);
-	    ((CraftPlayer)p).getHandle().playerConnection.sendPacket(bar);
-  }
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void sendActionBarMessage(Player p, String message) {
+		IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message) + "\"}");
+		PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte) 2);
+		((CraftPlayer) p).getHandle().playerConnection.sendPacket(bar);
+	}
 }

+ 16 - 7
v1_12_R1/src/main/java/de/Linus122/TimeIsMoney/version/v1_12_R1/NBTUtils.java

@@ -9,11 +9,20 @@ import org.bukkit.entity.Player;
 
 import static de.Linus122.TimeIsMoney.tools.Utils.CC;
 
-public class NBTUtils implements ActionBarUtils{
-  public void sendActionBarMessage(Player p, String message)
-  {
-	    IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message)  + "\"}");
-	    PacketPlayOutChat bar = new PacketPlayOutChat(icbc, ChatMessageType.GAME_INFO);
-	    ((CraftPlayer)p).getHandle().playerConnection.sendPacket(bar);
-  }
+/**
+ * NBT Utils for v1_12_R1.
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
+public class NBTUtils implements ActionBarUtils {
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void sendActionBarMessage(Player p, String message) {
+		IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message) + "\"}");
+		PacketPlayOutChat bar = new PacketPlayOutChat(icbc, ChatMessageType.GAME_INFO);
+		((CraftPlayer) p).getHandle().playerConnection.sendPacket(bar);
+	}
 }

+ 15 - 7
v1_8_R1/src/main/java/de/Linus122/TimeIsMoney/version/v1_8_R1/NBTUtils.java

@@ -9,12 +9,20 @@ import org.bukkit.entity.Player;
 
 import static de.Linus122.TimeIsMoney.tools.Utils.CC;
 
+/**
+ * NBT Utils for v1_8_R1.
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
 public class NBTUtils implements ActionBarUtils {
-  @Override
-  public void sendActionBarMessage(Player p, String message)
-  {
-	    IChatBaseComponent icbc = ChatSerializer.a("{\"text\": \"" + CC(message) + "\"}");
-	    PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte)2);
-	    ((CraftPlayer)p).getHandle().playerConnection.sendPacket(bar);
-  }
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void sendActionBarMessage(Player p, String message) {
+		IChatBaseComponent icbc = ChatSerializer.a("{\"text\": \"" + CC(message) + "\"}");
+		PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte) 2);
+		((CraftPlayer) p).getHandle().playerConnection.sendPacket(bar);
+	}
 }

+ 15 - 7
v1_8_R2/src/main/java/de/Linus122/TimeIsMoney/version/v1_8_R2/NBTUtils.java

@@ -8,12 +8,20 @@ import org.bukkit.entity.Player;
 
 import static de.Linus122.TimeIsMoney.tools.Utils.CC;
 
+/**
+ * NBT Utils for v1_8_R2.
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
 public class NBTUtils implements ActionBarUtils {
-  @Override
-  public void sendActionBarMessage(Player p, String message)
-  {
-	    IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message) + "\"}");
-	    PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte)2);
-	    ((CraftPlayer)p).getHandle().playerConnection.sendPacket(bar);
-  }
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void sendActionBarMessage(Player p, String message) {
+		IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message) + "\"}");
+		PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte) 2);
+		((CraftPlayer) p).getHandle().playerConnection.sendPacket(bar);
+	}
 }

+ 15 - 6
v1_8_R3/src/main/java/de/Linus122/TimeIsMoney/version/v1_8_R3/NBTUtils.java

@@ -8,11 +8,20 @@ import org.bukkit.entity.Player;
 
 import static de.Linus122.TimeIsMoney.tools.Utils.CC;
 
+/**
+ * NBT Utils for v1_8_R3.
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
 public class NBTUtils implements ActionBarUtils {
-  public void sendActionBarMessage(Player p, String message)
-  {
-	    IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message)  + "\"}");
-	    PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte)2);
-	    ((CraftPlayer)p).getHandle().playerConnection.sendPacket(bar);
-  }
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void sendActionBarMessage(Player p, String message) {
+		IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message) + "\"}");
+		PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte) 2);
+		((CraftPlayer) p).getHandle().playerConnection.sendPacket(bar);
+	}
 }

+ 15 - 6
v1_9_R1/src/main/java/de/Linus122/TimeIsMoney/version/v1_9_R1/NBTUtils.java

@@ -8,11 +8,20 @@ import org.bukkit.entity.Player;
 
 import static de.Linus122.TimeIsMoney.tools.Utils.CC;
 
+/**
+ * NBT Utils for v1_9_R1.
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
 public class NBTUtils implements ActionBarUtils {
-  public void sendActionBarMessage(Player p, String message)
-  {
-	    IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message) + "\"}");
-	    PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte)2);
-	    ((CraftPlayer)p).getHandle().playerConnection.sendPacket(bar);
-  }
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void sendActionBarMessage(Player p, String message) {
+		IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message) + "\"}");
+		PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte) 2);
+		((CraftPlayer) p).getHandle().playerConnection.sendPacket(bar);
+	}
 }

+ 17 - 9
v1_9_R2/src/main/java/de/Linus122/TimeIsMoney/version/v1_9_R2/NBTUtils.java

@@ -1,19 +1,27 @@
 package de.Linus122.TimeIsMoney.version.v1_9_R2;
 
 import de.Linus122.TimeIsMoney.tools.ActionBarUtils;
-import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
-import org.bukkit.entity.Player;
-
 import net.minecraft.server.v1_9_R2.IChatBaseComponent;
 import net.minecraft.server.v1_9_R2.PacketPlayOutChat;
+import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
+import org.bukkit.entity.Player;
 
 import static de.Linus122.TimeIsMoney.tools.Utils.CC;
 
+/**
+ * NBT Utils for v1_9_R2.
+ *
+ * @author Linus122
+ * @since 1.9.6.1
+ */
 public class NBTUtils implements ActionBarUtils {
-  public void sendActionBarMessage(Player p, String message)
-  {
-	    IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message)  + "\"}");
-	    PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte)2);
-	    ((CraftPlayer)p).getHandle().playerConnection.sendPacket(bar);
-  }
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void sendActionBarMessage(Player p, String message) {
+		IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + CC(message) + "\"}");
+		PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte) 2);
+		((CraftPlayer) p).getHandle().playerConnection.sendPacket(bar);
+	}
 }