mirror of
https://github.com/taoneill/war.git
synced 2024-11-14 06:17:01 +01:00
First v0.6 (Zhukov) commit. Adding CTF with setteamflag command. Works great.
This commit is contained in:
parent
4d8179c8fd
commit
82367f22e6
@ -97,8 +97,9 @@ public class War extends JavaPlugin {
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
||||
|
||||
pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.High, this);
|
||||
//pm.registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.High, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_PROJECTILE, entityListener, Priority.High, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.High, this);
|
||||
|
||||
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this);
|
||||
@ -615,7 +616,8 @@ public class War extends JavaPlugin {
|
||||
lobby = warzone.getLobby();
|
||||
}
|
||||
for(Team t : warzone.getTeams()) {
|
||||
t.getVolume().resetBlocks();
|
||||
if(t.getTeamFlag() != null) t.getFlagVolume().resetBlocks();
|
||||
t.getSpawnVolume().resetBlocks();
|
||||
}
|
||||
for(Monument m : warzone.getMonuments()) {
|
||||
m.getVolume().resetBlocks();
|
||||
@ -663,7 +665,6 @@ public class War extends JavaPlugin {
|
||||
warzone.getLobby().initialize();
|
||||
}
|
||||
newTeam.setTeamSpawn(player.getLocation());
|
||||
|
||||
player.sendMessage(this.str("Team " + name + " created with spawn here."));
|
||||
}
|
||||
|
||||
@ -671,6 +672,43 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// /setteamflag <diamond/iron/gold/d/i/g>
|
||||
else if(command.equals("setteamflag")) {
|
||||
if(arguments.length < 1 || !this.inAnyWarzone(player.getLocation())
|
||||
|| (arguments.length > 0 && TeamMaterials.teamMaterialFromString(arguments[0]) == null)) {
|
||||
player.sendMessage(this.str("Usage: /setteamflag <diamond/iron/gold/d/i/g>. " +
|
||||
"Sets the team flag post to the current location. " +
|
||||
"Must be in a warzone (try /zones and /zone). "));
|
||||
} else {
|
||||
Material teamMaterial = TeamMaterials.teamMaterialFromString(arguments[0]);
|
||||
String name = TeamMaterials.teamMaterialToString(teamMaterial);
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
Team team = warzone.getTeamByMaterial(teamMaterial);
|
||||
if(team == null) {
|
||||
// no such team yet
|
||||
player.sendMessage(this.str("Place the team spawn first."));
|
||||
return true;
|
||||
} else if (team.getFlagVolume() == null){
|
||||
// new team flag
|
||||
team.setTeamFlag(player.getLocation());
|
||||
Location playerLoc = player.getLocation();
|
||||
player.teleportTo(new Location(playerLoc.getWorld(),
|
||||
playerLoc.getBlockX(), playerLoc.getBlockY() + 1, playerLoc.getBlockZ()));
|
||||
player.sendMessage(this.str("Team " + name + " flag added here."));
|
||||
} else {
|
||||
// relocate flag
|
||||
team.getFlagVolume().resetBlocks();
|
||||
team.setTeamFlag(player.getLocation());
|
||||
Location playerLoc = player.getLocation();
|
||||
player.teleportTo(new Location(playerLoc.getWorld(),
|
||||
playerLoc.getBlockX(), playerLoc.getBlockY() + 1, playerLoc.getBlockZ()));
|
||||
player.sendMessage(this.str("Team " + name + " flag moved."));
|
||||
}
|
||||
|
||||
WarzoneMapper.save(this, warzone, false);
|
||||
}
|
||||
}
|
||||
|
||||
// /deleteteam <teamname>
|
||||
else if(command.equals("deleteteam")) {
|
||||
if(arguments.length < 1 || (!this.inAnyWarzone(player.getLocation())
|
||||
@ -695,7 +733,8 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
if(team != null) {
|
||||
team.getVolume().resetBlocks();
|
||||
if(team.getFlagVolume() != null) team.getFlagVolume().resetBlocks();
|
||||
team.getSpawnVolume().resetBlocks();
|
||||
warzone.getTeams().remove(team);
|
||||
if(warzone.getLobby() != null) {
|
||||
warzone.getLobby().getVolume().resetBlocks();
|
||||
|
@ -2,15 +2,18 @@ package bukkit.tommytony.war;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockDamageLevel;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.tommytony.war.Monument;
|
||||
import com.tommytony.war.Team;
|
||||
import com.tommytony.war.TeamMaterials;
|
||||
import com.tommytony.war.Warzone;
|
||||
|
||||
/**
|
||||
@ -103,13 +106,35 @@ public class WarBlockListener extends BlockListener {
|
||||
}
|
||||
return;
|
||||
}else if(warzone != null && warzone.isImportantBlock(block) && !isZoneMaker) {
|
||||
if(team != null && team.getVolume().contains(block)) {
|
||||
if(team != null && team.getSpawnVolume().contains(block)) {
|
||||
if(player.getInventory().contains(team.getMaterial())) {
|
||||
player.sendMessage(war.str("You already have a " + team.getName() + " block."));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
// let team members loot one block the spawn for monument captures
|
||||
} else if (team != null && warzone.isEnemyTeamFlagBlock(team, block)) {
|
||||
if(warzone.isFlagThief(player.getName())) {
|
||||
// detect audacious thieves
|
||||
player.sendMessage(war.str("You can only steal one flag at a time!"));
|
||||
} else {
|
||||
// player just broke the flag block of other team: cancel to avoid drop, give player the block, set block to air
|
||||
Team lostFlagTeam = warzone.getTeamForFlagBlock(block);
|
||||
player.getInventory().clear();
|
||||
player.getInventory().addItem(new ItemStack(lostFlagTeam.getMaterial(), 1));
|
||||
warzone.addFlagThief(lostFlagTeam, player.getName());
|
||||
block.setType(Material.AIR);
|
||||
|
||||
for(Team t : warzone.getTeams()) {
|
||||
t.teamcast(war.str(player.getName() + " stole team " + lostFlagTeam.getName() + "'s flag."));
|
||||
if(t.getName().equals(lostFlagTeam.getName())){
|
||||
t.teamcast(war.str("Prevent " + player.getName() + " from reaching team " + team.getName() + "'s spawn."));
|
||||
}
|
||||
}
|
||||
player.sendMessage(war.str("You have team " + lostFlagTeam + "'s flag. Reach your team spawn to capture it!"));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (!warzone.isMonumentCenterBlock(block)){
|
||||
player.sendMessage(war.str("Can't destroy this."));
|
||||
event.setCancelled(true);
|
||||
|
@ -1,9 +1,14 @@
|
||||
package bukkit.tommytony.war;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
|
||||
import com.tommytony.war.Team;
|
||||
@ -23,6 +28,13 @@ public class WarEntityListener extends EntityListener {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
if(event.getEntity() instanceof Player) {
|
||||
((Player)event.getEntity()).sendMessage(war.str("You really died!"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// public void onEntityDamage(EntityDamageEvent event) {
|
||||
//// Entity defender = event.getEntity();
|
||||
////
|
||||
@ -62,7 +74,7 @@ public class WarEntityListener extends EntityListener {
|
||||
&& attackerTeam != defenderTeam
|
||||
&& attackerWarzone == defenderWarzone) {
|
||||
// Make sure one of the players isn't in the spawn
|
||||
if(!defenderTeam.getVolume().contains(d.getLocation())){
|
||||
if(!defenderTeam.getSpawnVolume().contains(d.getLocation())){
|
||||
// A real attack: handle death scenario. ==> now handled in entity damage as well
|
||||
//synchronized(d) {
|
||||
// if(d.getHealth() <= 0) {
|
||||
@ -133,6 +145,29 @@ public class WarEntityListener extends EntityListener {
|
||||
public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
||||
handlerAttackDefend(event);
|
||||
}
|
||||
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
// protect zones elements, lobbies and warhub from creepers
|
||||
List<Block> explodedBlocks = event.blockList();
|
||||
for(Block block : explodedBlocks) {
|
||||
if(war.getWarHub() != null && war.getWarHub().getVolume().contains(block)) {
|
||||
event.setCancelled(true);
|
||||
war.info("Explosion prevented at warhub.");
|
||||
return;
|
||||
}
|
||||
for(Warzone zone : war.getWarzones()) {
|
||||
if(zone.isImportantBlock(block)) {
|
||||
event.setCancelled(true);
|
||||
war.info("Explosion prevented in zone " + zone.getName() + ".");
|
||||
return;
|
||||
} else if (zone.getLobby() != null && zone.getLobby().getVolume().contains(block)) {
|
||||
event.setCancelled(true);
|
||||
war.info("Explosion prevented at zone " + zone.getName() + " lobby.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// private void handleDeath(Player player, Warzone playerWarzone, Team playerTeam) {
|
||||
// // teleport to team spawn upon death
|
||||
|
@ -50,15 +50,10 @@ public class WarPlayerListener extends PlayerListener {
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Location playerLoc = event.getFrom(); // same as player.getLoc. Don't call again we need same result.
|
||||
//Location from = event.getFrom();
|
||||
Warzone locZone = null;
|
||||
ZoneLobby locLobby = null;
|
||||
//if(from != null) {
|
||||
locZone = war.warzone(playerLoc);
|
||||
locLobby = war.lobby(playerLoc);
|
||||
//}
|
||||
// synchronized(player) {
|
||||
//Location to = event.getTo();
|
||||
locZone = war.warzone(playerLoc);
|
||||
locLobby = war.lobby(playerLoc);
|
||||
boolean canPlay = war.canPlayWar(player);
|
||||
boolean isMaker = war.isZoneMaker(player);
|
||||
|
||||
@ -242,6 +237,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
//playerWarzone.respawnPlayer(team, player);
|
||||
player.teleportTo(team.getTeamSpawn());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Monuments
|
||||
@ -251,6 +247,24 @@ public class WarPlayerListener extends PlayerListener {
|
||||
&& random.nextInt(42) == 3 ) { // one chance out of many of getting healed
|
||||
player.setHealth(20);
|
||||
player.sendMessage(war.str("Your dance pleases the monument's voodoo. You gain full health!"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Flag capture
|
||||
if(playerWarzone.isFlagThief(player.getName())
|
||||
&& (team.getSpawnVolume().contains(player.getLocation())
|
||||
|| (team.getFlagVolume() != null && team.getFlagVolume().contains(player.getLocation())))) {
|
||||
// flags can be captured at own spawn or own flag pole
|
||||
team.setPoints(team.getPoints() + 1);
|
||||
Team victim = playerWarzone.getVictimTeamForThief(player.getName());
|
||||
victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
|
||||
victim.initializeTeamFlag();
|
||||
for(Team t : playerWarzone.getTeams()) {
|
||||
t.teamcast(war.str(player.getName() + " captured team " + victim.getName()
|
||||
+ "'s flag. Team " + team.getName() + " scores one point." ));
|
||||
}
|
||||
playerWarzone.respawnPlayer(team, player);
|
||||
playerWarzone.removeThief(player.getName());
|
||||
}
|
||||
} else if (locZone != null && locZone.getLobby() != null
|
||||
&& !locZone.getLobby().isLeavingZone(playerLoc) && !isMaker) {
|
||||
|
@ -24,38 +24,42 @@ import com.tommytony.war.volumes.Volume;
|
||||
public class Team {
|
||||
private List<Player> players = new ArrayList<Player>();
|
||||
private Location teamSpawn = null;
|
||||
private Location teamFlag = null;
|
||||
private String name;
|
||||
private int remainingTickets;
|
||||
private int points = 0;
|
||||
private Volume volume;
|
||||
private Volume spawnVolume;
|
||||
private Volume flagVolume;
|
||||
private final Warzone warzone;
|
||||
private Material material;
|
||||
private War war;
|
||||
|
||||
public Team(String name, Material material, Location teamSpawn, War war, Warzone warzone) {
|
||||
this.warzone = warzone;
|
||||
this.setName(name);
|
||||
this.teamSpawn = teamSpawn;
|
||||
this.setVolume(new Volume(name, war, warzone.getWorld()));
|
||||
this.war = war;
|
||||
this.setSpawnVolume(new Volume(name, war, warzone.getWorld()));
|
||||
this.material = material;
|
||||
|
||||
this.setFlagVolume(null); // no flag at the start
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
private void setVolume() {
|
||||
if(volume.isSaved()) volume.resetBlocks();
|
||||
private void setSpawnVolume() {
|
||||
if(spawnVolume.isSaved()) spawnVolume.resetBlocks();
|
||||
int x = teamSpawn.getBlockX();
|
||||
int y = teamSpawn.getBlockY();
|
||||
int z = teamSpawn.getBlockZ();
|
||||
this.volume.setCornerOne(warzone.getWorld().getBlockAt(x-2, y-1, z-2));
|
||||
this.volume.setCornerTwo(warzone.getWorld().getBlockAt(x+2, y+5, z+2));
|
||||
this.spawnVolume.setCornerOne(warzone.getWorld().getBlockAt(x-2, y-1, z-2));
|
||||
this.spawnVolume.setCornerTwo(warzone.getWorld().getBlockAt(x+2, y+5, z+2));
|
||||
}
|
||||
|
||||
public void initializeTeamSpawn(Location teamSpawn) {
|
||||
public void initializeTeamSpawn() {
|
||||
// make air
|
||||
this.volume.setToMaterial(Material.AIR);
|
||||
this.spawnVolume.setToMaterial(Material.AIR);
|
||||
|
||||
// Set the spawn
|
||||
int x = teamSpawn.getBlockX();
|
||||
@ -159,10 +163,10 @@ public class Team {
|
||||
this.teamSpawn = teamSpawn;
|
||||
|
||||
// this resets the block to old state
|
||||
this.setVolume();
|
||||
getVolume().saveBlocks();
|
||||
this.setSpawnVolume();
|
||||
getSpawnVolume().saveBlocks();
|
||||
|
||||
initializeTeamSpawn(teamSpawn);
|
||||
initializeTeamSpawn();
|
||||
}
|
||||
|
||||
public Location getTeamSpawn() {
|
||||
@ -221,14 +225,14 @@ public class Team {
|
||||
return points;
|
||||
}
|
||||
|
||||
public Volume getVolume() {
|
||||
public Volume getSpawnVolume() {
|
||||
|
||||
return volume;
|
||||
return spawnVolume;
|
||||
}
|
||||
|
||||
public void resetSign(){
|
||||
this.getVolume().resetBlocks();
|
||||
this.initializeTeamSpawn(this.getTeamSpawn()); // reset everything instead of just sign
|
||||
this.getSpawnVolume().resetBlocks();
|
||||
this.initializeTeamSpawn(); // reset everything instead of just sign
|
||||
|
||||
// BUKKIT
|
||||
// int x = teamSpawn.getBlockX();
|
||||
@ -263,12 +267,107 @@ public class Team {
|
||||
}
|
||||
}
|
||||
|
||||
public void setVolume(Volume volume) {
|
||||
this.volume = volume;
|
||||
public void setSpawnVolume(Volume volume) {
|
||||
this.spawnVolume = volume;
|
||||
}
|
||||
|
||||
public void setPoints(int score) {
|
||||
this.points = score;
|
||||
}
|
||||
|
||||
public void setFlagVolume(Volume flagVolume) {
|
||||
this.flagVolume = flagVolume;
|
||||
}
|
||||
|
||||
public Volume getFlagVolume() {
|
||||
return flagVolume;
|
||||
}
|
||||
|
||||
private void setFlagVolume() {
|
||||
if(flagVolume == null) flagVolume = new Volume(getName() + "flag", war, warzone.getWorld());
|
||||
if(flagVolume.isSaved()) flagVolume.resetBlocks();
|
||||
int x = teamFlag.getBlockX();
|
||||
int y = teamFlag.getBlockY();
|
||||
int z = teamFlag.getBlockZ();
|
||||
this.flagVolume.setCornerOne(warzone.getWorld().getBlockAt(x-2, y-1, z-2));
|
||||
this.flagVolume.setCornerTwo(warzone.getWorld().getBlockAt(x+2, y+5, z+2));
|
||||
}
|
||||
|
||||
public void initializeTeamFlag() {
|
||||
// make air
|
||||
this.flagVolume.setToMaterial(Material.AIR);
|
||||
|
||||
// Set the flag blocks
|
||||
int x = teamFlag.getBlockX();
|
||||
int y = teamFlag.getBlockY();
|
||||
int z = teamFlag.getBlockZ();
|
||||
|
||||
// first ring
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
|
||||
// outer ring
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z+2).setType(Material.GLOWSTONE);
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+2, y-1, z-2).setType(Material.GLOWSTONE);
|
||||
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-1, y-1, z-2).setType(Material.OBSIDIAN);
|
||||
|
||||
warzone.getWorld().getBlockAt(x, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y-1, z-2).setType(Material.OBSIDIAN);
|
||||
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z+2).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x+1, y-1, z-2).setType(Material.OBSIDIAN);
|
||||
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z+2).setType(Material.GLOWSTONE);
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z+1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z-1).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x-2, y-1, z-2).setType(Material.GLOWSTONE);
|
||||
|
||||
// flag post
|
||||
warzone.getWorld().getBlockAt(x, y, z).setType(Material.OBSIDIAN);
|
||||
warzone.getWorld().getBlockAt(x, y+1, z).setType(material);
|
||||
|
||||
}
|
||||
|
||||
public void setTeamFlag(Location teamFlag) {
|
||||
|
||||
this.teamFlag = teamFlag;
|
||||
|
||||
// this resets the block to old state
|
||||
this.setFlagVolume();
|
||||
getFlagVolume().saveBlocks();
|
||||
|
||||
initializeTeamFlag();
|
||||
}
|
||||
|
||||
public boolean isTeamFlagBlock(Block block) {
|
||||
if(teamFlag != null) {
|
||||
int flagX = teamFlag.getBlockX();
|
||||
int flagY = teamFlag.getBlockY() + 1;
|
||||
int flagZ = teamFlag.getBlockZ();
|
||||
if(block.getX() == flagX
|
||||
&& block.getY() == flagY
|
||||
&& block.getZ() == flagZ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Location getTeamFlag() {
|
||||
|
||||
return teamFlag;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class WarHub {
|
||||
public WarHub(War war, Location location) {
|
||||
this.war = war;
|
||||
this.location = location;
|
||||
this.volume = new Volume("warHub", war, location.getWorld());
|
||||
this.volume = new Volume("warhub", war, location.getWorld());
|
||||
}
|
||||
|
||||
public Volume getVolume() {
|
||||
|
@ -39,6 +39,7 @@ public class Warzone {
|
||||
private int scoreCap = 5;
|
||||
|
||||
private HashMap<String, ItemStack[]> inventories = new HashMap<String, ItemStack[]>();
|
||||
private HashMap<String, Team> flagThieves = new HashMap<String, Team>();
|
||||
private World world;
|
||||
private Material[] originalSoutheastBlocks;
|
||||
private Material[] originalNorthwestBlocks;
|
||||
@ -184,7 +185,8 @@ public class Warzone {
|
||||
volume.resetWallBlocks(BlockFace.SOUTH);
|
||||
|
||||
for(Team team : teams) {
|
||||
team.getVolume().resetBlocks();
|
||||
team.getSpawnVolume().resetBlocks();
|
||||
if(team.getTeamFlag() != null) team.getFlagVolume().resetBlocks();
|
||||
}
|
||||
|
||||
for(Monument monument : monuments) {
|
||||
@ -221,6 +223,7 @@ public class Warzone {
|
||||
}
|
||||
team.setRemainingTickets(lifePool);
|
||||
team.setTeamSpawn(team.getTeamSpawn());
|
||||
if(team.getTeamFlag() != null) team.setTeamFlag(team.getTeamFlag());
|
||||
team.resetSign();
|
||||
}
|
||||
|
||||
@ -238,6 +241,7 @@ public class Warzone {
|
||||
}
|
||||
team.setRemainingTickets(lifePool);
|
||||
team.setTeamSpawn(team.getTeamSpawn());
|
||||
if(team.getTeamFlag() != null) team.setTeamFlag(team.getTeamFlag());
|
||||
team.resetSign();
|
||||
}
|
||||
}
|
||||
@ -488,10 +492,16 @@ public class Warzone {
|
||||
}
|
||||
}
|
||||
for(Team t : teams) {
|
||||
if(t.getVolume().contains(block)){
|
||||
if(t.getSpawnVolume().contains(block)){
|
||||
return true;
|
||||
} else if (t.getFlagVolume() != null
|
||||
&& t.getFlagVolume().contains(block)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(volume.isWallBlock(block)){
|
||||
return true;
|
||||
}
|
||||
// if(lobby != null) {
|
||||
// lobby.getVolume().contains(block);
|
||||
// }
|
||||
@ -801,5 +811,41 @@ public class Warzone {
|
||||
|
||||
}
|
||||
|
||||
public boolean isEnemyTeamFlagBlock(Team playerTeam, Block block) {
|
||||
for(Team team : teams) {
|
||||
if(!team.getName().equals(playerTeam.getName())
|
||||
&& team.isTeamFlagBlock(block)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Team getTeamForFlagBlock(Block block) {
|
||||
for(Team team : teams) {
|
||||
if(team.isTeamFlagBlock(block)) {
|
||||
return team;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addFlagThief(Team lostFlagTeam, String flagThief) {
|
||||
flagThieves.put(flagThief, lostFlagTeam);
|
||||
}
|
||||
|
||||
public boolean isFlagThief(String suspect) {
|
||||
if(flagThieves.containsKey(suspect)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public Team getVictimTeamForThief(String thief) {
|
||||
return flagThieves.get(thief);
|
||||
}
|
||||
|
||||
public void removeThief(String thief) {
|
||||
flagThieves.remove(thief);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -112,6 +112,24 @@ public class WarzoneMapper {
|
||||
}
|
||||
}
|
||||
|
||||
// teamFlags
|
||||
String teamFlagsStr = warzoneConfig.getString("teamFlags");
|
||||
if(teamFlagsStr != null && !teamFlagsStr.equals("")) {
|
||||
String[] teamFlagsSplit = teamFlagsStr.split(";");
|
||||
for(String teamFlagStr : teamFlagsSplit) {
|
||||
if(teamFlagStr != null && !teamFlagStr.equals("")){
|
||||
String[] teamFlagStrSplit =teamFlagStr.split(",");
|
||||
Team team = warzone.getTeamByMaterial(TeamMaterials.teamMaterialFromString(teamFlagStrSplit[0]));
|
||||
if(team != null) {
|
||||
int teamFlagX = Integer.parseInt(teamFlagStrSplit[1]);
|
||||
int teamFlagY = Integer.parseInt(teamFlagStrSplit[2]);
|
||||
int teamFlagZ = Integer.parseInt(teamFlagStrSplit[3]);
|
||||
team.setTeamFlag(new Location(world, teamFlagX, teamFlagY, teamFlagZ)); // this may screw things up
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ff
|
||||
warzone.setFriendlyFire(warzoneConfig.getBoolean("friendlyFire"));
|
||||
|
||||
@ -183,7 +201,10 @@ public class WarzoneMapper {
|
||||
|
||||
// team spawn blocks
|
||||
for(Team team : warzone.getTeams()) {
|
||||
team.setVolume(VolumeMapper.loadVolume(team.getName(), warzone.getName(), war, world));
|
||||
team.setSpawnVolume(VolumeMapper.loadVolume(team.getName(), warzone.getName(), war, world));
|
||||
if(team.getTeamFlag() != null) {
|
||||
team.setFlagVolume(VolumeMapper.loadVolume(team.getName()+"flag", warzone.getName(), war, world));
|
||||
}
|
||||
}
|
||||
|
||||
// lobby
|
||||
@ -251,6 +272,16 @@ public class WarzoneMapper {
|
||||
}
|
||||
warzoneConfig.setString("teams", teamsStr);
|
||||
|
||||
// team flags
|
||||
String teamFlagsStr = "";;
|
||||
for(Team team : teams) {
|
||||
if(team.getFlagVolume() != null) {
|
||||
Location flag = team.getTeamFlag();
|
||||
teamFlagsStr += team.getName() + "," + flag.getBlockX() + "," + flag.getBlockY() + "," + flag.getBlockZ() + ";";
|
||||
}
|
||||
}
|
||||
warzoneConfig.setString("teamFlags", teamFlagsStr);
|
||||
|
||||
// ff
|
||||
warzoneConfig.setBoolean("firendlyFire", warzone.getFriendlyFire());
|
||||
|
||||
@ -315,10 +346,13 @@ public class WarzoneMapper {
|
||||
VolumeMapper.save(monument.getVolume(), warzone.getName(), war);
|
||||
}
|
||||
|
||||
// team spawn blocks
|
||||
// team spawn & flag blocks
|
||||
for(Team team : teams) {
|
||||
VolumeMapper.save(team.getVolume(), warzone.getName(), war);
|
||||
}
|
||||
VolumeMapper.save(team.getSpawnVolume(), warzone.getName(), war);
|
||||
if(team.getFlagVolume() != null) {
|
||||
VolumeMapper.save(team.getFlagVolume(), warzone.getName(), war);
|
||||
}
|
||||
}
|
||||
|
||||
if(warzone.getLobby() != null) {
|
||||
VolumeMapper.save(warzone.getLobby().getVolume(), warzone.getName(), war);
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: War
|
||||
version: 0.5 (Rommel)
|
||||
version: 0.6 (Zhukov)
|
||||
description: Lets you create team deathmatch arenas (warzones) for a more structured PVP experience.
|
||||
author: tommytony
|
||||
website: war.tommytony.com
|
||||
@ -54,6 +54,9 @@ commands:
|
||||
setmonument:
|
||||
description: Zone makers only. Creates or moves a monument. Must be in warzone.
|
||||
usage: /setmonument <monument-name>
|
||||
setteamflag:
|
||||
description: Zone makers only. Creates or moves a team flag post for CTF-style play. The only available teams are diamond, iron and gold. Must be warzone.
|
||||
usage: /setteamflag <diamond/iron/gold/d/i/g>
|
||||
resetzone:
|
||||
description: Zone makers only. Reloads zone blocks from memory by default. Reloads blocks from disk if "hard" option is added. Sends everyone back to the warzone lobby. Must be in zone or lobby.
|
||||
usage: /resetzone, /resetzone <hard/h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: War
|
||||
version: 0.5 (Rommel)
|
||||
version: 0.6 (Zhukov)
|
||||
description: Lets you create team deathmatch arenas (warzones) for a more structured PVP experience.
|
||||
author: tommytony
|
||||
website: war.tommytony.com
|
||||
@ -54,6 +54,9 @@ commands:
|
||||
setmonument:
|
||||
description: Zone makers only. Creates or moves a monument. Must be in warzone.
|
||||
usage: /setmonument <monument-name>
|
||||
setteamflag:
|
||||
description: Zone makers only. Creates or moves a team flag post for CTF-style play. The only available teams are diamond, iron and gold. Must be warzone.
|
||||
usage: /setteamflag <diamond/iron/gold/d/i/g>
|
||||
resetzone:
|
||||
description: Zone makers only. Reloads zone blocks from memory by default. Reloads blocks from disk if "hard" option is added. Sends everyone back to the warzone lobby. Must be in zone or lobby.
|
||||
usage: /resetzone, /resetzone <hard/h>
|
||||
|
Loading…
Reference in New Issue
Block a user