@Override public void run() { for (District district : Mafiacraft.getDistrictList()) { double pay = ((int) district.getLandCost()) >> 4; for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { LandOwner owner = district.getOwner(i, j); switch (owner.getOwnerType()) { case PLAYER: MPlayer player = (MPlayer) owner; player.addMoney(pay); break; case GOVERNMENT: Government gov = (Government) owner; gov.addMoney(pay); break; case DIVISION: Division div = (Division) owner; div.addMoney(pay); break; } } } } }
public String doSetManager(MPlayer player, String division, String target) { if (!player.hasPermission("mafiacraft.citizen")) { return "You must be a citizen to use this command. " + "Apply for citizen on the website at " + MsgColor.URL + "http://voxton.net/" + "."; } Government gov = player.getGovernment(); if (gov == null) { return "You are not in a government!"; } MPlayer manager = Mafiacraft.getOnlinePlayer(target); if (manager == null) { return "That player is either not online or doesn't exist."; } Division div = gov.getDivisionByName(division); if (div == null) { return "A " + gov.getType().getLocale("division") + " with the name '" + division + "' does not exist in your " + gov.getType().getName() + "."; } div.setManager(manager); player.sendMessage(MsgColor.SUCCESS + "The capo for the regime "); return null; }
public String doCreateDivision(MPlayer player, String name) { if (!player.hasPermission("mafiacraft.citizen")) { return "You must be a citizen to use this command. " + "Apply for citizen on the website at " + MsgColor.URL + "http://voxton.net/" + "."; } Government gov = player.getGovernment(); if (gov == null) { return "You are not in a government!"; } if (!player.getPosition().isAtLeast(Position.VICE_LEADER)) { return "You do not have the proper rank to do this."; } name = name.trim(); if (!ValidationUtils.validateName(name)) { return "invalid name"; } if (!gov.canHaveMoreDivisions()) { return "The " + gov.getType().getName() + " has too many " + gov.getType().getLocale("divisions") + ". Make sure all of your " + gov.getType().getLocale("divisions") + " have greater than 5 players each."; } Division div = gov.createDivision().setManager(player.getName()).setName(name); gov.subtractMoney(Config.getDouble("prices.mafia.regimefound")); div.addMoney(Config.getDouble("mafia.regimestartup")); player.sendMessage( MsgColor.SUCCESS + "You have founded a " + gov.getType().getLocale("division") + " successfully."); return null; }
public String doGrant(MPlayer player, String division, String amt) { double amount; try { amount = Double.parseDouble(amt); } catch (NumberFormatException ex) { return "The amount you specified is an invalid number."; } if (!player.getPosition().isAtLeast(Position.OFFICER)) { return "You must be an officer or higher to do this."; } Government gov = player.getGovernment(); if (gov == null) { return "You aren't in a government."; } Division div = gov.getDivisionByName(division); if (div == null) { return "That division does not exist within your " + gov.getType().getName() + "."; } if (!gov.transferWithCheck(div, amount)) { return "Your " + gov.getType().getName() + " doesn't have enough money to perform this transaction."; } player.sendMessage( MsgColor.SUCCESS + amount + " " + Config.getString("currency.namepl") + " have been granted to the " + gov.getType().getLocale("division") + " " + div.getName() + "."); return null; }