mirror of
https://github.com/taoneill/war.git
synced 2025-01-09 01:07:57 +01:00
Spawn protection is back. Can't re-enter spawn.
- Players are now technically invincible while in spawn. Closes gh-492. - More air cleared around warhub tp and moved the warhub sign by one block.
This commit is contained in:
parent
b504b5b014
commit
7a90119c97
@ -173,7 +173,6 @@ public class War extends JavaPlugin {
|
|||||||
warzoneDefaultConfig.put(WarzoneConfig.UNBREAKABLE, false);
|
warzoneDefaultConfig.put(WarzoneConfig.UNBREAKABLE, false);
|
||||||
warzoneDefaultConfig.put(WarzoneConfig.DEATHMESSAGES, true);
|
warzoneDefaultConfig.put(WarzoneConfig.DEATHMESSAGES, true);
|
||||||
|
|
||||||
|
|
||||||
teamDefaultConfig.put(TeamConfig.FLAGMUSTBEHOME, true);
|
teamDefaultConfig.put(TeamConfig.FLAGMUSTBEHOME, true);
|
||||||
teamDefaultConfig.put(TeamConfig.FLAGPOINTSONLY, false);
|
teamDefaultConfig.put(TeamConfig.FLAGPOINTSONLY, false);
|
||||||
teamDefaultConfig.put(TeamConfig.FLAGRETURN, FlagReturn.BOTH);
|
teamDefaultConfig.put(TeamConfig.FLAGRETURN, FlagReturn.BOTH);
|
||||||
@ -186,7 +185,6 @@ public class War extends JavaPlugin {
|
|||||||
teamDefaultConfig.put(TeamConfig.SPAWNSTYLE, TeamSpawnStyle.SMALL);
|
teamDefaultConfig.put(TeamConfig.SPAWNSTYLE, TeamSpawnStyle.SMALL);
|
||||||
teamDefaultConfig.put(TeamConfig.TEAMSIZE, 10);
|
teamDefaultConfig.put(TeamConfig.TEAMSIZE, 10);
|
||||||
|
|
||||||
|
|
||||||
this.getDefaultInventories().getLoadouts().clear();
|
this.getDefaultInventories().getLoadouts().clear();
|
||||||
HashMap<Integer, ItemStack> defaultLoadout = new HashMap<Integer, ItemStack>();
|
HashMap<Integer, ItemStack> defaultLoadout = new HashMap<Integer, ItemStack>();
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ import com.tommytony.war.job.DeferredBlockResetsJob;
|
|||||||
import com.tommytony.war.spout.SpoutDisplayer;
|
import com.tommytony.war.spout.SpoutDisplayer;
|
||||||
import com.tommytony.war.structure.Bomb;
|
import com.tommytony.war.structure.Bomb;
|
||||||
import com.tommytony.war.utility.DeferredBlockReset;
|
import com.tommytony.war.utility.DeferredBlockReset;
|
||||||
|
import com.tommytony.war.utility.LoadoutSelection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles Entity-Events
|
* Handles Entity-Events
|
||||||
@ -80,7 +81,21 @@ public class WarEntityListener implements Listener {
|
|||||||
if ((attackerTeam != null && defenderTeam != null && attackerTeam != defenderTeam && attackerWarzone == defenderWarzone)
|
if ((attackerTeam != null && defenderTeam != null && attackerTeam != defenderTeam && attackerWarzone == defenderWarzone)
|
||||||
|| (attackerTeam != null && defenderTeam != null && attacker.getEntityId() == defender.getEntityId())) {
|
|| (attackerTeam != null && defenderTeam != null && attacker.getEntityId() == defender.getEntityId())) {
|
||||||
|
|
||||||
// Make sure none of them are respawning
|
LoadoutSelection defenderLoadoutState = defenderWarzone.getLoadoutSelections().get(d.getName());
|
||||||
|
if (defenderLoadoutState != null && defenderLoadoutState.isStillInSpawn()) {
|
||||||
|
War.war.badMsg(a, "The target is still in spawn!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadoutSelection attackerLoadoutState = attackerWarzone.getLoadoutSelections().get(a.getName());
|
||||||
|
if (attackerLoadoutState != null && attackerLoadoutState.isStillInSpawn()) {
|
||||||
|
War.war.badMsg(a, "You can't attack while still in spawn!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure none of them are locked in by respawn timer
|
||||||
if (defenderWarzone.isRespawning(d)) {
|
if (defenderWarzone.isRespawning(d)) {
|
||||||
War.war.badMsg(a, "The target is currently respawning!");
|
War.war.badMsg(a, "The target is currently respawning!");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -411,40 +426,48 @@ public class WarEntityListener implements Listener {
|
|||||||
this.handlerAttackDefend((EntityDamageByEntityEvent) event);
|
this.handlerAttackDefend((EntityDamageByEntityEvent) event);
|
||||||
} else {
|
} else {
|
||||||
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
|
Warzone zone = Warzone.getZoneByPlayerName(player.getName());
|
||||||
|
Team team = Team.getTeamByPlayerName(player.getName());
|
||||||
|
|
||||||
if (zone != null && event.getDamage() >= player.getHealth()) {
|
if (zone != null && team != null) {
|
||||||
if (zone.getReallyDeadFighters().contains(player.getName())) {
|
LoadoutSelection playerLoadoutState = zone.getLoadoutSelections().get(player.getName());
|
||||||
// don't re-count the death points of an already dead person, make sure they are dead though
|
if (team.getSpawnVolume().contains(player.getLocation())
|
||||||
// (reason for this is that onEntityDamage sometimes fires more than once for one death)
|
&& playerLoadoutState != null && playerLoadoutState.isStillInSpawn()) {
|
||||||
if (player.getHealth() != 0) {
|
// don't let a player still in spawn get damaged
|
||||||
player.setHealth(0);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Detect death, prevent it and respawn the player
|
|
||||||
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DEATHMESSAGES)) {
|
|
||||||
String deathMessage = "";
|
|
||||||
String cause = " died";
|
|
||||||
if (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK
|
|
||||||
|| event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.LIGHTNING) {
|
|
||||||
cause = " burned to a crisp";
|
|
||||||
} else if (event.getCause() == DamageCause.DROWNING) {
|
|
||||||
cause = " drowned";
|
|
||||||
} else if (event.getCause() == DamageCause.FALL) {
|
|
||||||
cause = " fell to an untimely death";
|
|
||||||
}
|
|
||||||
deathMessage = Team.getTeamByPlayerName(player.getName()).getKind().getColor() + player.getName() + ChatColor.WHITE + cause;
|
|
||||||
for (Team team : zone.getTeams()) {
|
|
||||||
team.teamcast(deathMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
zone.handleDeath(player);
|
|
||||||
|
|
||||||
if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
|
|
||||||
// fast respawn, don't really die
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
} else if (event.getDamage() >= player.getHealth()) {
|
||||||
|
if (zone.getReallyDeadFighters().contains(player.getName())) {
|
||||||
|
// don't re-count the death points of an already dead person, make sure they are dead though
|
||||||
|
// (reason for this is that onEntityDamage sometimes fires more than once for one death)
|
||||||
|
if (player.getHealth() != 0) {
|
||||||
|
player.setHealth(0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detect death, prevent it and respawn the player
|
||||||
|
if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.DEATHMESSAGES)) {
|
||||||
|
String deathMessage = "";
|
||||||
|
String cause = " died";
|
||||||
|
if (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK
|
||||||
|
|| event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.LIGHTNING) {
|
||||||
|
cause = " burned to a crisp";
|
||||||
|
} else if (event.getCause() == DamageCause.DROWNING) {
|
||||||
|
cause = " drowned";
|
||||||
|
} else if (event.getCause() == DamageCause.FALL) {
|
||||||
|
cause = " fell to an untimely death";
|
||||||
|
}
|
||||||
|
deathMessage = Team.getTeamByPlayerName(player.getName()).getKind().getColor() + player.getName() + ChatColor.WHITE + cause;
|
||||||
|
for (Team teamToMsg : zone.getTeams()) {
|
||||||
|
teamToMsg.teamcast(deathMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zone.handleDeath(player);
|
||||||
|
|
||||||
|
if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
|
||||||
|
// fast respawn, don't really die
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ public class WarPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location playerLoc = event.getFrom(); // same as player.getLoc. Don't call again we need same result.
|
Location playerLoc = event.getTo(); // Don't call again we need same result.
|
||||||
|
|
||||||
Location previousLocation = latestLocations.get(player.getName());
|
Location previousLocation = latestLocations.get(player.getName());
|
||||||
if (previousLocation != null &&
|
if (previousLocation != null &&
|
||||||
@ -436,6 +436,7 @@ public class WarPlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoadoutSelection loadoutSelectionState = playerWarzone.getLoadoutSelections().get(player.getName());
|
||||||
if (!playerTeam.getSpawnVolume().contains(playerLoc)) {
|
if (!playerTeam.getSpawnVolume().contains(playerLoc)) {
|
||||||
if (!playerWarzone.isEnoughPlayers()) {
|
if (!playerWarzone.isEnoughPlayers()) {
|
||||||
War.war.badMsg(player, "Can't leave spawn until there's a minimum of " + playerWarzone.getWarzoneConfig().getInt(WarzoneConfig.MINPLAYERS)
|
War.war.badMsg(player, "Can't leave spawn until there's a minimum of " + playerWarzone.getWarzoneConfig().getInt(WarzoneConfig.MINPLAYERS)
|
||||||
@ -446,11 +447,57 @@ public class WarPlayerListener implements Listener {
|
|||||||
if (playerWarzone.isRespawning(player)) {
|
if (playerWarzone.isRespawning(player)) {
|
||||||
int rt = playerTeam.getTeamConfig().resolveInt(TeamConfig.RESPAWNTIMER);
|
int rt = playerTeam.getTeamConfig().resolveInt(TeamConfig.RESPAWNTIMER);
|
||||||
String isS = "s";
|
String isS = "s";
|
||||||
if (rt==1) isS = "";
|
if (rt == 1) {
|
||||||
War.war.badMsg(player, "Can't leave spawn for "+rt+" second"+isS+" after spawning!");
|
isS = "";
|
||||||
|
}
|
||||||
|
War.war.badMsg(player, "Can't leave spawn for " + rt + " second" + isS + " after spawning!");
|
||||||
event.setTo(playerTeam.getTeamSpawn());
|
event.setTo(playerTeam.getTeamSpawn());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (loadoutSelectionState != null && !loadoutSelectionState.isStillInSpawn()) {
|
||||||
|
// player is in spawn, but has left already: he should NOT be let back in - kick him out gently
|
||||||
|
int diffZ = playerLoc.getBlockZ() - playerTeam.getTeamSpawn().getBlockZ();
|
||||||
|
int diffX = playerLoc.getBlockX() - playerTeam.getTeamSpawn().getBlockX();
|
||||||
|
|
||||||
|
int finalZ = playerLoc.getBlockZ();
|
||||||
|
int finalX = playerLoc.getBlockX();
|
||||||
|
int bumpDistance = 1;
|
||||||
|
if (diffZ == 0 && diffX == 0) {
|
||||||
|
// at spawn already, get him moving
|
||||||
|
finalZ += bumpDistance + 1;
|
||||||
|
finalX += bumpDistance + 1;
|
||||||
|
} else if (diffZ > 0 && diffX > 0) {
|
||||||
|
finalZ += bumpDistance;
|
||||||
|
finalX += bumpDistance;
|
||||||
|
} else if (diffZ == 0 && diffX > 0) {
|
||||||
|
finalX += bumpDistance;
|
||||||
|
}else if (diffZ < 0 && diffX > 0) {
|
||||||
|
finalZ -= bumpDistance;
|
||||||
|
finalX += bumpDistance;
|
||||||
|
} else if (diffZ < 0 && diffX == 0) {
|
||||||
|
finalZ -= bumpDistance;
|
||||||
|
} else if (diffZ > 0 && diffX < 0) {
|
||||||
|
finalZ -= bumpDistance;
|
||||||
|
finalX -= bumpDistance;
|
||||||
|
} else if (diffZ == 0 && diffX < 0) {
|
||||||
|
finalX -= bumpDistance;
|
||||||
|
} else if (diffZ > 0 && diffX < 0) {
|
||||||
|
finalZ += bumpDistance;
|
||||||
|
finalX -= bumpDistance;
|
||||||
|
} else if (diffZ > 0 && diffX == 0) {
|
||||||
|
finalZ += bumpDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setTo(new Location(playerLoc.getWorld(),
|
||||||
|
finalX,
|
||||||
|
playerLoc.getY(),
|
||||||
|
finalZ,
|
||||||
|
playerLoc.getYaw(),
|
||||||
|
playerLoc.getPitch()
|
||||||
|
));
|
||||||
|
|
||||||
|
War.war.badMsg(player, "Can't re-enter spawn!");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Monuments
|
// Monuments
|
||||||
|
@ -175,13 +175,11 @@ public class WarHub {
|
|||||||
this.volume.setFloorOutlineMaterial(outline, outlineData);
|
this.volume.setFloorOutlineMaterial(outline, outlineData);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear minimal path
|
// clear minimal path around warhub tp
|
||||||
locationBlock.setType(Material.AIR);
|
Volume warhubTpVolume = new Volume("warhubtp", this.location.getWorld());
|
||||||
locationBlock.getRelative(BlockFace.UP).setType(Material.AIR);
|
warhubTpVolume.setCornerOne(locationBlock.getRelative(back).getRelative(left));
|
||||||
locationBlock.getRelative(this.getOrientation()).setType(Material.AIR);
|
warhubTpVolume.setCornerTwo(locationBlock.getRelative(front, 2).getRelative(right).getRelative(BlockFace.UP));
|
||||||
locationBlock.getRelative(this.getOrientation()).getRelative(BlockFace.UP).setType(Material.AIR);
|
warhubTpVolume.setToMaterial(Material.AIR);
|
||||||
locationBlock.getRelative(this.getOrientation()).getRelative(this.getOrientation()).setType(Material.AIR);
|
|
||||||
locationBlock.getRelative(this.getOrientation()).getRelative(this.getOrientation()).getRelative(BlockFace.UP).setType(Material.AIR);
|
|
||||||
|
|
||||||
// draw gates
|
// draw gates
|
||||||
Block currentGateBlock = BlockInfo.getBlock(this.location.getWorld(), this.volume.getCornerOne()).getRelative(BlockFace.UP).getRelative(front, hubDepth).getRelative(right, 2);
|
Block currentGateBlock = BlockInfo.getBlock(this.location.getWorld(), this.volume.getCornerOne()).getRelative(BlockFace.UP).getRelative(front, hubDepth).getRelative(right, 2);
|
||||||
@ -241,7 +239,7 @@ public class WarHub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// War hub sign
|
// War hub sign
|
||||||
Block signBlock = locationBlock.getRelative(front);
|
Block signBlock = locationBlock.getRelative(front, 2);
|
||||||
|
|
||||||
String[] lines = new String[4];
|
String[] lines = new String[4];
|
||||||
lines[0] = "War hub";
|
lines[0] = "War hub";
|
||||||
|
Loading…
Reference in New Issue
Block a user