mirror of https://github.com/taoneill/war.git
Only randomly teleport to zones that are enabled
This commit is contained in:
parent
dc764de258
commit
bc07a60b51
|
@ -898,6 +898,20 @@ public class War extends JavaPlugin {
|
|||
return this.warzones;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of warzones that are not disabled.
|
||||
* @return List of enabled warzones.
|
||||
*/
|
||||
public List<Warzone> getEnabledWarzones() {
|
||||
List<Warzone> enabledZones = new ArrayList<Warzone>(this.warzones.size());
|
||||
for (Warzone zone : this.warzones) {
|
||||
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED) == false) {
|
||||
enabledZones.add(zone);
|
||||
}
|
||||
}
|
||||
return enabledZones;
|
||||
}
|
||||
|
||||
public void msg(CommandSender sender, String str) {
|
||||
if (sender instanceof Player) {
|
||||
StringBuilder output = new StringBuilder(ChatColor.GRAY.toString())
|
||||
|
|
|
@ -304,8 +304,10 @@ public class WarPlayerListener implements Listener {
|
|||
if (indicated != null) {
|
||||
player.teleport(indicated.getTeleport());
|
||||
} else if (sign.getLine(1).equalsIgnoreCase("$random")) {
|
||||
int zone = random.nextInt(War.war.getWarzones().size());
|
||||
Warzone random = War.war.getWarzones().get(zone);
|
||||
List<Warzone> 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