mirror of
https://github.com/taoneill/war.git
synced 2025-01-07 00:08:25 +01:00
New active sign, gets random warzone with players
This commit is contained in:
parent
bc07a60b51
commit
b011d3a46f
@ -912,6 +912,21 @@ public class War extends JavaPlugin {
|
|||||||
return enabledZones;
|
return enabledZones;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of warzones that have players in them.
|
||||||
|
* @return List of enabled warzones with players.
|
||||||
|
*/
|
||||||
|
public List<Warzone> getActiveWarzones() {
|
||||||
|
List<Warzone> activeZones = new ArrayList<Warzone>(this.warzones.size());
|
||||||
|
for (Warzone zone : this.warzones) {
|
||||||
|
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED) == false
|
||||||
|
&& zone.getPlayerCount() > 0) {
|
||||||
|
activeZones.add(zone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return activeZones;
|
||||||
|
}
|
||||||
|
|
||||||
public void msg(CommandSender sender, String str) {
|
public void msg(CommandSender sender, String str) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
StringBuilder output = new StringBuilder(ChatColor.GRAY.toString())
|
StringBuilder output = new StringBuilder(ChatColor.GRAY.toString())
|
||||||
|
@ -309,6 +309,13 @@ public class WarPlayerListener implements Listener {
|
|||||||
int zone = random.nextInt(warzones.size());
|
int zone = random.nextInt(warzones.size());
|
||||||
Warzone random = warzones.get(zone);
|
Warzone random = warzones.get(zone);
|
||||||
player.teleport(random.getTeleport());
|
player.teleport(random.getTeleport());
|
||||||
|
} else if (sign.getLine(1).equalsIgnoreCase("$active")) {
|
||||||
|
List<Warzone> warzones = War.war.getActiveWarzones();
|
||||||
|
if (warzones.size() == 0) warzones = War.war.getEnabledWarzones();
|
||||||
|
if (warzones.size() == 0) return;
|
||||||
|
int zone = random.nextInt(warzones.size());
|
||||||
|
Warzone random = warzones.get(zone);
|
||||||
|
player.teleport(random.getTeleport());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user