public List<Resident> getValidatedResidents(Object sender, String[] names) { List<Resident> invited = new ArrayList<Resident>(); for (String name : names) { List<Player> matches = plugin.getServer().matchPlayer(name); if (matches.size() > 1) { String line = "Multiple players selected"; for (Player p : matches) line += ", " + p.getName(); TownyMessaging.sendErrorMsg(sender, line); } else if (matches.size() == 1) { // Match found online try { Resident target = getDataSource().getResident(matches.get(0).getName()); invited.add(target); } catch (TownyException x) { TownyMessaging.sendErrorMsg(sender, x.getMessage()); } } else { // No online matches so test for offline. Resident target; try { target = getDataSource().getResident(name); invited.add(target); } catch (NotRegisteredException x) { TownyMessaging.sendErrorMsg(sender, x.getMessage()); } } } return invited; }
public void requestTeleport(Player player, Town town, double cost) { try { TeleportWarmupTimerTask.requestTeleport( getDataSource().getResident(player.getName().toLowerCase()), town, cost); } catch (TownyException x) { TownyMessaging.sendErrorMsg(player, x.getMessage()); } setChangedNotify(TELEPORT_REQUEST); }
public void start() { warTime = true; // Announce // Seed spoils of war try { warSpoils.pay(TownySettings.getBaseSpoilsOfWar(), "Start of War - Base Spoils"); TownyMessaging.sendMsg( "[War] Seeding spoils of war with " + TownySettings.getBaseSpoilsOfWar()); } catch (EconomyException e) { TownyMessaging.sendErrorMsg("[War] Could not seed spoils of war."); } // Gather all nations at war for (Nation nation : TownyUniverse.getDataSource().getNations()) { if (!nation.isNeutral()) { add(nation); TownyMessaging.sendGlobalMessage( String.format(TownySettings.getLangString("msg_war_join_nation"), nation.getName())); } else if (!TownySettings.isDeclaringNeutral()) { try { nation.setNeutral(false); add(nation); TownyMessaging.sendGlobalMessage( String.format(TownySettings.getLangString("msg_war_join_forced"), nation.getName())); } catch (TownyException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } // warTimer.scheduleAtFixedRate(new WarTimerTask(this), 0, 1000); int id = plugin .getServer() .getScheduler() .scheduleAsyncRepeatingTask( getPlugin(), new WarTimerTask(this), 0, TimeTools.convertToTicks(5)); if (id == -1) { TownyMessaging.sendErrorMsg("Could not schedule war event loop."); end(); } else addTaskId(id); checkEnd(); }
public List<Resident> getOnlineResidents(Player player, String[] names) { List<Resident> invited = new ArrayList<Resident>(); for (String name : names) { List<Player> matches = plugin.getServer().matchPlayer(name); if (matches.size() > 1) { String line = "Multiple players selected"; for (Player p : matches) line += ", " + p.getName(); TownyMessaging.sendErrorMsg(player, line); } else if (matches.size() == 1) try { Resident target = getDataSource().getResident(matches.get(0).getName()); invited.add(target); } catch (TownyException x) { TownyMessaging.sendErrorMsg(player, x.getMessage()); } } return invited; }