public ActionResult execute(User user, String[] args) { ActionResult res = new ActionResult(); if (!user.isAdmin()) { res.setMess(new String[] {prefix + ErrorMessages.E101.Mess(null, null)}); return res; } if (args[0].equals("")) { res.setMess(new String[] {prefix + ErrorMessages.E103.Mess(null, null)}); return res; } String theUser = match(user.getMisc(), args[0]); if (!DCoProperties.getDS().AccountExists(AccountType.BANK, theUser)) { res.setMess(new String[] {prefix + ErrorMessages.E104.Mess(theUser, "Bank")}); return res; } DCoProperties.getDS().setBalance(AccountType.BANK, theUser, 0); res.setMess(new String[] {prefix + AdminMessages.A301.Mess(theUser, "Account", 0)}); log(LoggingMessages.L622.Mess(user.getName(), theUser, 0, null)); return res; }
public ActionResult execute(User user, String[] args) { ActionResult res = new ActionResult(); if (!user.canRank()) { res.setMess(new String[] {prefix + ErrorMessages.E101.Mess(null, null)}); return res; } int rank = 1, amount = 20; Map<String, Double> sorted = DCoProperties.getDS().getRankMap(AccountType.BANK); if (sorted.size() < 1) { res.setMess(new String[] {AccountMessages.A223.Mess(null, "Bank", 0, 0)}); return res; } if (!args[0].equals("")) { try { amount = Integer.parseInt(args[0]); } catch (NumberFormatException nfe) { amount = 20; } } if (amount > sorted.size()) { amount = sorted.size(); } String[] ranking = new String[amount + 1]; ranking[0] = AccountMessages.A223.Mess(null, "Bank", 0, amount); for (String name : sorted.keySet()) { double balance = sorted.get(name); if (rank <= amount) { ranking[rank] = AccountMessages.A224.Mess(null, name, balance, rank); } else { break; } rank++; } log(LoggingMessages.L614.Mess(user.getName(), null, amount, null)); res.setMess(ranking); return res; }
public ActionResult execute(User user, String[] args) { int rank = -1; ActionResult res = new ActionResult(); if (!user.canRank()) { res.setMess(new String[] {prefix + ErrorMessages.E101.Mess(null, null)}); return res; } boolean self = true; String theUser = match(user.getMisc(), args[0]); if (!args[0].equals("")) { if (!DCoProperties.getDS().AccountExists(AccountType.BANK, theUser)) { res.setMess(new String[] {prefix + ErrorMessages.E104.Mess(theUser, "Bank")}); return res; } self = false; } String ranked = null; Map<String, Double> sorted = DCoProperties.getDS().getRankMap(AccountType.BANK); if (sorted != null) { for (String name : sorted.keySet()) { if (self) { if (name.equalsIgnoreCase(user.getName())) { ranked = AccountMessages.A222.Mess(null, null, 0, rank); log(LoggingMessages.L639.Mess(user.getName(), null, 0, null)); break; } } else { if (name.equalsIgnoreCase(theUser)) { ranked = AccountMessages.A221.Mess(theUser, null, 0, rank); log(LoggingMessages.L638.Mess(user.getName(), theUser, 0, null)); break; } } rank++; } } res.setMess( new String[] {ranked != null ? prefix + ranked : prefix + "Unable to retrieve rank..."}); return res; }
public ActionResult execute(User user, String[] args) { ActionResult res = new ActionResult(); res.setMess( new String[] { HelpMessages.H402.Mess(), HelpMessages.H404.Mess(), HelpMessages.H405.Mess(), HelpMessages.H410.Mess(), HelpMessages.H417.Mess(), HelpMessages.H418.Mess(), (user.canRank() ? HelpMessages.H412.Mess() : null), (user.canRank() ? HelpMessages.H413.Mess() : null), (user.isAdmin() ? HelpMessages.H431.Mess() : null), (user.isAdmin() ? HelpMessages.H432.Mess() : null), (user.isAdmin() ? HelpMessages.H433.Mess() : null), (user.isAdmin() ? HelpMessages.H434.Mess() : null), (user.useMoney() ? HelpMessages.H406.Mess() : null), (user.useJoint() ? HelpMessages.H408.Mess() : null) }); return res; }
public ActionResult execute(User user, String[] args) { ActionResult res = new ActionResult(); if (!args[0].equals("") && !DCoProperties.getAOC()) { String theUser = match(user.getMisc(), args[0]); if (theUser != null) { if (!DCoProperties.getDS().AccountExists(AccountType.BANK, theUser)) { res.setMess(new String[] {prefix + ErrorMessages.E104.Mess(theUser, "Bank")}); return res; } } res.setMess( new String[] { prefix + AccountMessages.A203.Mess( theUser, "Bank", DCoProperties.getDS().getBalance(AccountType.BANK, theUser), -1) }); return res; } else { if (!DCoProperties.getDS().AccountExists(AccountType.BANK, user.getName())) { DCoProperties.getDS().setInitialBalance(AccountType.BANK, user.getName()); } res.setMess( new String[] { prefix + AccountMessages.A201.Mess( null, "Bank", DCoProperties.getDS().getBalance(AccountType.BANK, user.getName()), -1) }); return res; } }
public ActionResult execute(User user, String[] args) { ActionResult res = new ActionResult(); if (!user.isAdmin()) { res.setMess(new String[] {prefix + ErrorMessages.E101.Mess(null, null)}); return res; } if (!argcheck(2, args)) { res.setMess(new String[] {prefix + ErrorMessages.E103.Mess(null, null)}); return res; } String theUser = match(user.getMisc(), args[0]); if (!DCoProperties.getDS().AccountExists(AccountType.BANK, theUser)) { res.setMess(new String[] {prefix + ErrorMessages.E104.Mess(theUser, "Bank")}); return res; } double deduct = 0; try { deduct = Double.parseDouble(args[1]); } catch (NumberFormatException nfe) { res.setMess(new String[] {prefix + ErrorMessages.E102.Mess(null, null)}); return res; } if (deduct < 0.01) { res.setMess(new String[] {prefix + ErrorMessages.E102.Mess(null, null)}); return res; } double newbal = DCoProperties.getDS().getBalance(AccountType.BANK, theUser) - deduct; if (newbal < 0) { res.setMess(new String[] {prefix + ErrorMessages.E102.Mess(null, null)}); return res; } DCoProperties.getDS().setBalance(AccountType.BANK, theUser, newbal); res.setMess(new String[] {prefix + AdminMessages.A303.Mess(theUser, "Bank", newbal)}); log(LoggingMessages.L623.Mess(user.getName(), theUser, newbal, null)); return res; }
public ActionResult execute(User user, String[] args) { ActionResult res = new ActionResult(); if (user.getName().equals("SERVER")) { res.setMess(new String[] {"You cannot use that command from the console!"}); return res; } if (args[0].equals("")) { res.setMess(new String[] {prefix + ErrorMessages.E103.Mess(null, null)}); return res; } double withdraw = 0; try { withdraw = Double.parseDouble(args[0]); } catch (NumberFormatException nfe) { res.setMess(new String[] {prefix + ErrorMessages.E102.Mess(null, null)}); return res; } if (withdraw < 0.01) { res.setMess(new String[] {prefix + ErrorMessages.E102.Mess(null, null)}); return res; } double newBank = DCoProperties.getDS().getBalance(AccountType.BANK, user.getName()) - withdraw; if (newBank < 0) { res.setMess(new String[] {prefix + ErrorMessages.E116.Mess(null, null)}); return res; } double newAcc = DCoProperties.getDS().getBalance(AccountType.ACCOUNT, user.getName()) + withdraw; DCoProperties.getDS().setBalance(AccountType.BANK, user.getName(), newBank); DCoProperties.getDS().setBalance(AccountType.ACCOUNT, user.getName(), newAcc); res.setMess( new String[] { prefix + AccountMessages.A205.Mess(null, null, withdraw, -1), prefix + AccountMessages.A202.Mess(null, "Account", newAcc, -1), prefix + AccountMessages.A202.Mess(null, "Bank", newBank, -1) }); log(LoggingMessages.L603.Mess(user.getName(), null, withdraw, null)); return res; }