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.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; }
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; } }