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