// class name, not given name public Member makeAvailable(String className, FactionManager fManager) { Member toMakeAvailable = removeFromAvailable(className); if (toMakeAvailable == null) return null; if (team != null) toMakeAvailable.setColor(team.getColor()); sortedAdd(toMakeAvailable); if (members.size() == 2) { Faction randFac = fManager.getFaction(Constants.A_RANDOM); ArrayList<RoleTemplate> list = new ArrayList<>(); randomMember = new RandomMember(getName() + " Random", getColor()); for (RoleTemplate m : members) { if (!m.isRandom()) { randomMember.addMember((Member) m); } } list.add(randomMember); randFac.add(list); } else if (members.size() > 2) { randomMember.addMember(toMakeAvailable); } return toMakeAvailable; }
public static boolean canPlayerEnderPerlHere(UPlayer up, Location from, Location to) { Faction host = FactionManager.getFactionAt(to.getBlock()); if (host.getName().equalsIgnoreCase("SafeZone")) { up.sendMessage(ChatColor.RED + "You are unable to enderpearl into the " + host.getName(up)); return false; } else if (host.isNone() || host.getName().equalsIgnoreCase("WarZone") || host.getRelationTo(up).isAtLeast(Rel.TRUCE)) { return true; } else { up.sendMessage( ChatColor.RED + "You are unable to enderpearl into the faction " + host.getName(up)); return false; } }
public static void setPlayerPending( final UPlayer p, String command, final String args, final boolean facCommand) { if (pendingTeleportCommands.containsKey(p.getPlayer())) { p.sendMessage(ChatColor.RED + "You already have a teleport pending!"); return; } else { int timer = 0; Faction host = FactionManager.getFactionAt(p.getPlayer().getLocation().getBlock()); Rel relation = host.getRelationTo(p); if (relation == Rel.ENEMY) { timer = 200; p.sendMessage(ChatColor.RED + "Commencing teleport from enemy land in 10 seconds"); } else if (host.getName().equalsIgnoreCase("Warzone")) { timer = 100; p.sendMessage(ChatColor.RED + "Commencing teleport from warzone in 5 seconds"); } if (facCommand) { command = "f " + command; } pendingTeleportCommands.put(p.getPlayer(), command); Bukkit.getScheduler() .runTaskLater( FactionsControl.instance, new Runnable() { @Override public void run() { if (pendingTeleportCommands.containsKey(p.getPlayer())) { ignore.add(p.getPlayer()); String full = "/" + pendingTeleportCommands.get(p.getPlayer()); if (facCommand) { if (args.split(" ").length > 1) { full += " " + args.split(" ", 2)[1]; } } else if (args != null && args.length() > 0) { full += " " + args; } p.getPlayer().chat(full); ignore.remove(p.getPlayer()); pendingTeleportCommands.remove(p.getPlayer()); } } }, timer); } }
public static boolean canPlayerTeleportHere(UPlayer up, Location from, Location to) { Faction host = FactionManager.getFactionAt(to.getBlock()); if (host.getRelationTo(up).isAtLeast(Rel.TRUCE)) { return true; } if (host.isDefault() && !host.isNone()) { return true; } if (up.getPower() > 1 && host.isNone()) { return true; } else if (up.getPower() <= 1) { up.sendMessage(ChatColor.RED + "Your weak power is preventing you from teleporting"); return false; } else { up.sendMessage( ChatColor.RED + "You are unable to teleport to the faction " + host.getName(up)); return false; } }
public Member makeUnavailable(String roleName, FactionManager fManager) { Member newUnavailable = null; for (RoleTemplate rt : members) { if (rt.isRandom()) continue; Member m = (Member) rt; if (m.getName().equals(roleName)) { newUnavailable = m; break; } } if (newUnavailable == null) return null; unavailableRoles.add(newUnavailable); members.remove(newUnavailable); Collections.sort(unavailableRoles); if (members.size() == 1) { fManager.removeFromRandoms(this); randomMember = null; } return newUnavailable; }