mirror of
https://github.com/taoneill/war.git
synced 2024-11-14 06:17:01 +01:00
Added respawn timer and immunity, fixe join loadout, fixed a bug
- You will not get the loadout as soon you join - Fixed a bug where you would be kicked out of the zone if you walk into the glass walls above a team gate on a block layer equal with the roof of the gate - Made respawn timer configurable ("respawntimer", defaults to 10) - Can't attack/be attacked while respawning (this is already done by the spawn protection already, so this is something for an upcoming feature)
This commit is contained in:
parent
856da8cc77
commit
1061c24c5b
@ -88,6 +88,7 @@ public class War extends JavaPlugin {
|
||||
private boolean defaultInstaBreak = false;
|
||||
private boolean defaultNoDrops = false;
|
||||
private boolean defaultNoHunger = false;
|
||||
private int defaultRespawnTimer = 10;
|
||||
private int defaultSaturation = 10;
|
||||
private int defaultMinPlayers = 1; // By default, 1 player on 1 team is enough for unlocking the cant-exit-spawn guard
|
||||
private int defaultMinTeams = 1;
|
||||
@ -152,6 +153,8 @@ public class War extends JavaPlugin {
|
||||
pm.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_DAMAGE, this.blockListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_BREAK, this.blockListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_PISTON_EXTEND, this.blockListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_PISTON_RETRACT, this.blockListener, Priority.Normal, this);
|
||||
}
|
||||
|
||||
// Load files from disk or create them (using these defaults)
|
||||
@ -315,6 +318,10 @@ public class War extends JavaPlugin {
|
||||
warzone.setScoreCap(Integer.parseInt(namedParams.get("maxscore")));
|
||||
returnMessage.append(" maxscore set to " + warzone.getScoreCap() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("respawntimer")) {
|
||||
warzone.setRespawnTimer(Integer.parseInt(namedParams.get("respawntimer")));
|
||||
returnMessage.append(" respawntimer set to " + warzone.getRespawnTimer() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("ff")) {
|
||||
String onOff = namedParams.get("ff");
|
||||
warzone.setFriendlyFire(onOff.equals("on") || onOff.equals("true"));
|
||||
@ -539,6 +546,10 @@ public class War extends JavaPlugin {
|
||||
this.setDefaultScoreCap(Integer.parseInt(namedParams.get("maxscore")));
|
||||
returnMessage.append(" maxscore set to " + war.getDefaultScoreCap() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("respawntimer")) {
|
||||
this.setDefaultRespawnTimer(Integer.parseInt(namedParams.get("respawntimer")));
|
||||
returnMessage.append(" respawntimer set to " + war.getDefaultRespawnTimer() + ".");
|
||||
}
|
||||
if (namedParams.containsKey("ff")) {
|
||||
String onOff = namedParams.get("ff");
|
||||
this.setDefaultFriendlyFire(onOff.equals("on") || onOff.equals("true"));
|
||||
@ -1366,4 +1377,12 @@ public class War extends JavaPlugin {
|
||||
return maxZones;
|
||||
}
|
||||
|
||||
public void setDefaultRespawnTimer(int defaultRespawnTimer) {
|
||||
this.defaultRespawnTimer = defaultRespawnTimer;
|
||||
}
|
||||
|
||||
public int getDefaultRespawnTimer() {
|
||||
return defaultRespawnTimer;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package bukkit.tommytony.war;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -11,7 +12,9 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.tommytony.war.FlagReturn;
|
||||
@ -113,6 +116,42 @@ public class WarBlockListener extends BlockListener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
/*// disallow placing of sticky pistons near flags. If the flag is pulled from the right position, you can't pick it up
|
||||
if (block.getType() == Material.PISTON_STICKY_BASE && Team.getTeamByPlayerName(player.getName()).getTeamFlag().distance(block.getLocation()) < 4) {
|
||||
War.war.badMsg(player, "You can't place sticky pistons this close to the flag.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
/*public void onPistonExtend(BlockPistonExtendEvent event) {
|
||||
Warzone zone = Warzone.getZoneByLocation(event.getBlock().getLocation());
|
||||
if (zone!=null) {
|
||||
for (Block b : event.getBlocks()) {
|
||||
if (zone.isMonumentCenterBlock(b) || zone.isFlagBlock(b)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPistonRetract(BlockPistonRetractEvent event) {
|
||||
Warzone zone = Warzone.getZoneByLocation(event.getBlock().getLocation());
|
||||
if (zone!=null) {
|
||||
Block b = event.getBlock();
|
||||
if (zone.isImportantBlock(b)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
public void onPistonExtend(BlockPistonExtendEvent event) {
|
||||
War.war.log("EXTENDING",Level.INFO);
|
||||
}
|
||||
public void onPistonRetract(BlockPistonRetractEvent event) {
|
||||
War.war.log("RETRACTING",Level.INFO);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,6 +86,15 @@ public class WarEntityListener extends EntityListener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
// Make sure none of them are respawning
|
||||
} else if (defenderWarzone.isRespawning(d)) {
|
||||
War.war.badMsg(a, "The target is currently respawning!");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (attackerWarzone.isRespawning(a)) {
|
||||
War.war.badMsg(a, "You can't attack while respawning!");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!attackerWarzone.isPvpInZone()) {
|
||||
|
@ -331,11 +331,11 @@ public class WarPlayerListener extends PlayerListener {
|
||||
}
|
||||
zone.keepPlayerState(player);
|
||||
War.war.msg(player, "Your inventory is in storage until you exit with '/war leave'.");
|
||||
zone.resetInventory(team, player);
|
||||
zone.respawnPlayer(event, team, player);
|
||||
for (Team t : zone.getTeams()) {
|
||||
t.teamcast("" + player.getName() + " joined team " + team.getName() + ".");
|
||||
}
|
||||
zone.resetInventory(team, player);
|
||||
} else {
|
||||
event.setTo(zone.getTeleport());
|
||||
War.war.badMsg(player, "Team " + team.getName() + " is full.");
|
||||
@ -437,7 +437,10 @@ public class WarPlayerListener extends PlayerListener {
|
||||
return;
|
||||
}
|
||||
if (playerWarzone.isRespawning(player)) {
|
||||
War.war.badMsg(player, "Can't leave spawn for 10 seconds after spawning!");
|
||||
int rt = playerWarzone.getRespawnTimer();
|
||||
String isS = "s";
|
||||
if (rt==1) isS = "";
|
||||
War.war.badMsg(player, "Can't leave spawn for "+rt+" second"+isS+" after spawning!");
|
||||
event.setTo(playerTeam.getTeamSpawn());
|
||||
return;
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ public class Warzone {
|
||||
private boolean instaBreak = false;
|
||||
private boolean noDrops = false;
|
||||
private boolean noHunger = false;
|
||||
private int respawnTimer = 10;
|
||||
private int saturation = 10;
|
||||
private int minPlayers = 1;
|
||||
private int minTeams = 1;
|
||||
@ -109,6 +110,7 @@ public class Warzone {
|
||||
this.setInstaBreak(War.war.isDefaultInstaBreak());
|
||||
this.setNoDrops(War.war.isDefaultNoDrops());
|
||||
this.setNoHunger(War.war.isDefaultNoHunger());
|
||||
this.setRespawnTimer(War.war.getDefaultRespawnTimer());
|
||||
this.setSaturation(War.war.getDefaultSaturation());
|
||||
this.setMinPlayers(War.war.getDefaultMinPlayers());
|
||||
this.setMinTeams(War.war.getDefaultMinTeams());
|
||||
@ -340,7 +342,7 @@ public class Warzone {
|
||||
player.setFoodLevel(20);
|
||||
player.setSaturation(this.getSaturation());
|
||||
player.setExhaustion(0);
|
||||
player.setFireTicks(0);
|
||||
player.setFireTicks(0); //this works fine here, why put it in LoudoutResetJob...? I'll keep it over there though
|
||||
|
||||
player.getInventory().clear();
|
||||
|
||||
@ -351,10 +353,13 @@ public class Warzone {
|
||||
this.getNewlyRespawned().put(player.getName(), 0);
|
||||
}
|
||||
|
||||
// "Respawn" Timer - player will not be able to leave spawn for 10 seconds
|
||||
// TODO: Customizable "respawn" time
|
||||
respawn.add(player);
|
||||
// "Respawn" Timer - player will not be able to leave spawn for a few seconds
|
||||
final Warzone w = this;
|
||||
if (respawnTimer==0) {
|
||||
LoadoutResetJob job = new LoadoutResetJob(w, team, player);
|
||||
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
|
||||
} else {
|
||||
respawn.add(player);
|
||||
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, new Runnable() {
|
||||
public void run() {
|
||||
respawn.remove(player);
|
||||
@ -362,7 +367,8 @@ public class Warzone {
|
||||
LoadoutResetJob job = new LoadoutResetJob(w, team, player, newlyRespawned.get(player.getName()));
|
||||
War.war.getServer().getScheduler().scheduleSyncDelayedTask(War.war, job);
|
||||
}
|
||||
}, 10 * 20L); // 20 ticks = 1 second. So 10*20 ticks = 10 seconds.
|
||||
}, respawnTimer * 20L); // 20 ticks = 1 second
|
||||
}
|
||||
}
|
||||
|
||||
public void resetInventory(Team team, Player player) {
|
||||
@ -775,11 +781,11 @@ public class Warzone {
|
||||
this.keepPlayerState(player);
|
||||
}
|
||||
War.war.msg(player, "Your inventory is in storage until you use '/war leave'.");
|
||||
this.resetInventory(lowestNoOfPlayers, player);
|
||||
this.respawnPlayer(lowestNoOfPlayers, player);
|
||||
for (Team team : this.teams) {
|
||||
team.teamcast("" + player.getName() + " joined team " + lowestNoOfPlayers.getName() + ".");
|
||||
}
|
||||
resetInventory(lowestNoOfPlayers, player);
|
||||
}
|
||||
return lowestNoOfPlayers;
|
||||
}
|
||||
@ -967,6 +973,15 @@ public class Warzone {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isFlagBlock(Block block) {
|
||||
for (Team team : this.teams) {
|
||||
if (team.isTeamFlagBlock(block)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Team getTeamForFlagBlock(Block block) {
|
||||
for (Team team : this.teams) {
|
||||
if (team.isTeamFlagBlock(block)) {
|
||||
@ -1275,4 +1290,12 @@ public class Warzone {
|
||||
}
|
||||
return authors;
|
||||
}
|
||||
|
||||
public void setRespawnTimer(int respawnTimer) {
|
||||
this.respawnTimer = respawnTimer;
|
||||
}
|
||||
|
||||
public int getRespawnTimer() {
|
||||
return this.respawnTimer;
|
||||
}
|
||||
}
|
||||
|
@ -682,7 +682,7 @@ public class ZoneLobby {
|
||||
Volume gateExitVolume = new Volume("tempGateExit", location.getWorld());
|
||||
Block out = gate.getFace(inside);
|
||||
gateExitVolume.setCornerOne(out.getFace(left).getFace(BlockFace.DOWN));
|
||||
gateExitVolume.setCornerTwo(gate.getFace(right, 1).getFace(BlockFace.UP, 3));
|
||||
gateExitVolume.setCornerTwo(gate.getFace(right, 1).getFace(BlockFace.UP, 2));
|
||||
|
||||
if (gateExitVolume.contains(location)) {
|
||||
return true;
|
||||
|
@ -154,6 +154,11 @@ public class WarMapper {
|
||||
War.war.setDefaultScoreCap(warConfig.getInt("defaultScoreCap"));
|
||||
}
|
||||
|
||||
// defaultRespawnTimer
|
||||
if (warConfig.keyExists("defaultRespawnTimer")) {
|
||||
War.war.setDefaultRespawnTimer(warConfig.getInt("defaultRespawnTimer"));
|
||||
}
|
||||
|
||||
// pvpInZonesOnly
|
||||
if (warConfig.keyExists("pvpInZonesOnly")) {
|
||||
War.war.setPvpInZonesOnly(warConfig.getBoolean("pvpInZonesOnly"));
|
||||
@ -361,6 +366,9 @@ public class WarMapper {
|
||||
// defaultScoreCap
|
||||
warConfig.setInt("defaultScoreCap", War.war.getDefaultScoreCap());
|
||||
|
||||
// defaultRespawnTimer
|
||||
warConfig.setInt("defaultRespawnTimer", War.war.getDefaultRespawnTimer());
|
||||
|
||||
// pvpInZonesOnly
|
||||
warConfig.setBoolean("pvpInZonesOnly", War.war.isPvpInZonesOnly());
|
||||
|
||||
|
@ -196,7 +196,7 @@ public class WarzoneMapper {
|
||||
warzone.setFlagPointsOnly(warzoneConfig.getBoolean("flagPointsOnly"));
|
||||
}
|
||||
|
||||
// flagPointsOnly
|
||||
// flagMustBeHome
|
||||
if (warzoneConfig.containsKey("flagMustBeHome")) {
|
||||
warzone.setFlagMustBeHome(warzoneConfig.getBoolean("flagMustBeHome"));
|
||||
}
|
||||
@ -211,6 +211,11 @@ public class WarzoneMapper {
|
||||
warzone.setScoreCap(warzoneConfig.getInt("scoreCap"));
|
||||
}
|
||||
|
||||
// respawn timer
|
||||
if (warzoneConfig.containsKey("respawnTimer")) {
|
||||
warzone.setRespawnTimer(warzoneConfig.getInt("respawnTimer"));
|
||||
}
|
||||
|
||||
// blockHeads
|
||||
if (warzoneConfig.containsKey("blockHeads")) {
|
||||
warzone.setBlockHeads(warzoneConfig.getBoolean("blockHeads"));
|
||||
@ -497,6 +502,9 @@ public class WarzoneMapper {
|
||||
// score cap
|
||||
warzoneConfig.setInt("scoreCap", warzone.getScoreCap());
|
||||
|
||||
// respawn timer
|
||||
warzoneConfig.setInt("respawnTimer", warzone.getRespawnTimer());
|
||||
|
||||
// blockHeads
|
||||
warzoneConfig.setBoolean("blockHeads", warzone.isBlockHeads());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user