closes gh-365 gh-392 Preparation time

This allows a prep time to be added IN SECONDS!!!!
so /zonecfg preptime:<amount of time in secconds>
This commit is contained in:
grinning 2012-02-21 22:27:54 -05:00 committed by Connor Monahan
parent 4f00befeb2
commit eb7b600aef
6 changed files with 56 additions and 1 deletions

View File

@ -220,6 +220,7 @@ public class War extends JavaPlugin {
warzoneDefaultConfig.put(WarzoneConfig.ALLOWENDER, true);
warzoneDefaultConfig.put(WarzoneConfig.RESETBLOCKS, true);
warzoneDefaultConfig.put(WarzoneConfig.CAPTUREPOINTTIME, 15);
warzoneDefaultConfig.put(WarzoneConfig.PREPTIME, 0);
teamDefaultConfig.put(TeamConfig.FLAGMUSTBEHOME, true);
teamDefaultConfig.put(TeamConfig.FLAGPOINTSONLY, false);

View File

@ -8,6 +8,7 @@ import java.text.MessageFormat;
import java.util.*;
import java.util.logging.Level;
import com.tommytony.war.job.ZoneTimeJob;
import com.tommytony.war.structure.*;
import net.milkbowl.vault.economy.EconomyResponse;
@ -137,6 +138,8 @@ public class Warzone {
private boolean isReinitializing = false;
//private final Object gameEndLock = new Object();
private boolean pvpReady = true;
public Warzone(World world, String name) {
this.world = world;
this.name = name;
@ -144,6 +147,7 @@ public class Warzone {
this.teamDefaultConfig = new TeamConfigBag(); // don't use ctor with Warzone, as this changes config resolution
this.volume = new ZoneVolume(name, this.getWorld(), this);
this.lobbyMaterials = War.war.getWarhubMaterials().clone();
this.pvpReady = true;
}
public static Warzone getZoneByName(String name) {
@ -423,6 +427,17 @@ public class Warzone {
}
}
}
this.reallyDeadFighters.clear();
//get them config (here be crazy grinning's!)
int pvpready = warzoneConfig.getInt(WarzoneConfig.PREPTIME);
if(pvpready != 0) { //if it is equalz to zeroz then dinosaurs will take over the earth
this.pvpReady = false;
ZoneTimeJob timer = new ZoneTimeJob(this);
War.war.getServer().getScheduler().runTaskLater(War.war, timer, pvpready * 20);
}
// nom drops
for(Entity entity : (this.getWorld().getEntities())) {
if (!(entity instanceof Item)) {
@ -2101,4 +2116,12 @@ public class Warzone {
public boolean isThief(Player suspect) {
return this.isFlagThief(suspect) || this.isBombThief(suspect) || this.isCakeThief(suspect);
}
public void setPvpReady(boolean ready) {
this.pvpReady = ready;
}
public boolean getPvpReady() {
return this.pvpReady;
}
}

View File

@ -26,7 +26,8 @@ public enum WarzoneConfig {
SOUPHEALING (Boolean.class, "Soup Healing", "If true, allow players to heal by consuming soup"),
ALLOWENDER (Boolean.class, "Allow Ender Chests", "If true, ender chests are allowed\nEnder chests are usually blocked to prevent item duplication"),
RESETBLOCKS (Boolean.class, "Reset Blocks", "If true, reset warzone blocks each battle"),
CAPTUREPOINTTIME (Integer.class, "Capture Control Time", "Time, in seconds, required to gain control of a capture point");
CAPTUREPOINTTIME (Integer.class, "Capture Control Time", "Time, in seconds, required to gain control of a capture point"),
PREPTIME(Integer.class, "Preparation Time", "Time, in seconds, before players are allowed to fight");
private final Class<?> configType;

View File

@ -482,3 +482,5 @@ public class WarBlockListener implements Listener {
}
}
}

View File

@ -96,6 +96,12 @@ public class WarEntityListener implements Listener {
War.war.badMsg(a, "pvp.self.respawn");
event.setCancelled(true);
return;
}
if(!defenderWarzone.getPvpReady()) {
//if the timer is still tickin we gotta handle defense! (there be notchz in virgina)
event.setCancelled(true);
return;
}
if (!attackerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.PVPINZONE)) {

View File

@ -0,0 +1,22 @@
package com.tommytony.war.job;
import com.tommytony.war.Warzone;
/**
* @author grinning
*/
public class ZoneTimeJob implements Runnable {
private Warzone zone;
public ZoneTimeJob(Warzone zone) {
this.zone = zone;
}
@Override
public void run() {
zone.setPvpReady(true);
}
}