@Override public void onEnable() { final long startTime = System.nanoTime(); final long endTime; try { // call RegisterListener registerListener(); // Localize locale to prevent issues Locale.setDefault(Locale.US); // Get general plugin information info = getDescription(); // Plugin directory setup directory = getDataFolder(); if (!directory.exists()) directory.mkdir(); // Create instance this.createInstances(); createFiles.createConfigFile(); createFiles.createReadmeFile(); createFiles.createPlayerTable(); this.createWebserver(); database.createAccountsDBTable(); database.createCookiesDBTable(); } catch (Exception e) { e.printStackTrace(); } }
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { File configDir = new File(XConomy.directory + "/config/"); File configFile = new File(configDir + "/config.yml"); YamlConfiguration yamlFile = YamlConfiguration.loadConfiguration(configFile); if (label.equalsIgnoreCase("money")) { if (!(sender instanceof Player)) { logger.info("xConomy - INFO - The console can't do this!"); if (args[0].equalsIgnoreCase("add")) { accountActions.depositMoney( Bukkit.getOfflinePlayer(args[1]), Double.parseDouble(args[2])); System.out.println("blaa"); } return true; } Player playerSender = null; Player player = null; Location pLoc = null; playerSender = (Player) sender; OfflinePlayer offPlayer = this.getServer().getOfflinePlayer(playerSender.getUniqueId()); String CurrencySingular = yamlFile.getString("Currency.Name.Singular"); String CurrencyPlural = yamlFile.getString("Currency.Name.Plural"); player = offPlayer.getPlayer(); if (args.length == 0) { Double balance = accountActions.getPlayerBalance(player); if (balance <= 1) { player.sendMessage("[BALANCE] " + balance + " " + CurrencySingular); return true; } else { player.sendMessage("[BALANCE] " + balance + " " + CurrencyPlural); return true; } } if (args.length == 3) { if (args[0].equalsIgnoreCase("add")) { System.out.println(this.getServer().getOfflinePlayers()); OfflinePlayer targetPlayer = null; for (int i = 0; i < Bukkit.getOfflinePlayers().length; i++) { System.out.println("OfflinePlayer = " + Bukkit.getOfflinePlayers()[i]); if (Bukkit.getOfflinePlayers()[i].getPlayer().getName().equalsIgnoreCase(args[1])) { targetPlayer = Bukkit.getOfflinePlayer(Bukkit.getOfflinePlayers()[i].getPlayer().getUniqueId()); accountActions.depositMoney(targetPlayer, Double.parseDouble(args[2])); return true; } } if (targetPlayer == null) { player.sendMessage("The player " + args[1] + " was not found!"); return true; } } if (args[0].equalsIgnoreCase("send")) { OfflinePlayer targetPlayer = null; for (int i = 0; i < Bukkit.getOfflinePlayers().length; i++) { if (!Bukkit.getOfflinePlayers()[i].isOnline()) { player.sendMessage("The Player is Offline, sorry!"); return true; } if (Bukkit.getOfflinePlayers()[i].getPlayer().getName().equalsIgnoreCase(args[1])) { if (accountActions.getPlayerBalance(player) < Double.parseDouble(args[2])) { player.sendMessage("Sorry, but you haven't enough money to do this"); return true; } else { targetPlayer = Bukkit.getOfflinePlayer( Bukkit.getOfflinePlayers()[i].getPlayer().getUniqueId()); accountActions.depositMoney(targetPlayer, Double.parseDouble(args[2])); accountActions.withdrawMoney(player, Double.parseDouble(args[2])); if (targetPlayer.isOnline()) { if (Double.parseDouble(args[2]) < 1) { targetPlayer .getPlayer() .sendMessage( "You received " + args[2] + " " + CurrencySingular + " from " + player.getDisplayName()); } else { targetPlayer .getPlayer() .sendMessage( "You received " + args[2] + " " + CurrencyPlural + " from " + player.getDisplayName()); } } if (Double.parseDouble(args[2]) < 1) { player.sendMessage( "You have send " + args[2] + " " + CurrencySingular + " to " + targetPlayer.getPlayer().getDisplayName()); } else { player.sendMessage( "You have send " + args[2] + " " + CurrencyPlural + " to " + targetPlayer.getPlayer().getDisplayName()); } return true; } } } if (targetPlayer == null) { player.sendMessage("The player " + args[1] + " was not found!"); return true; } } } } if (label.equalsIgnoreCase("ecweb")) { if (!(sender instanceof Player)) { logger.info("xConomy - INFO - The console can't do this!"); } Player playerSender = null; Player player = null; Location pLoc = null; playerSender = (Player) sender; OfflinePlayer offPlayer = this.getServer().getOfflinePlayer(playerSender.getUniqueId()); player = offPlayer.getPlayer(); if (args.length == 0) { player.sendMessage( "Nicht genug Parameter, benutze /ecweb help um weitere hilfe zu erhalten!"); return true; } if (args[0].equalsIgnoreCase("register")) { if (args.length == 3) { if (database.createNewPlayer(offPlayer, args[1], args[2])) { player.sendMessage("Dein Account wurde im Webinterface angelegt"); } else { player.sendMessage("Du hast bereits ein Account!"); } return true; } else { player.sendMessage( "Um einen Account im Webinterface anlegen zu können, musst du den folgenden Befehlt nutzen"); player.sendMessage("/ecweb register Username Password"); return true; } } } return false; }