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) { 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) { 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; }