Closes gh-353. Closes gh-354. Finally some new gameplay elements. Added Bomb and Cake structures. Use /setbomb <name>, /setcake <name>, /deletebomb and /deletecake. Grab the bomb and blow up your enemy's spawn for a point. Don't get touched or you blow up. Return the cake to your spawn to get a point and a replenished lifepool.

This commit is contained in:
taoneill 2012-01-16 23:57:59 -05:00
parent 940ad072d4
commit 934292df88
19 changed files with 1180 additions and 55 deletions

View File

@ -18,6 +18,8 @@ import org.bukkit.inventory.ItemStack;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.tommytony.war.Bomb;
import com.tommytony.war.Cake;
import com.tommytony.war.FlagReturn;
import com.tommytony.war.Monument;
import com.tommytony.war.Team;
@ -127,7 +129,21 @@ public class WarBlockListener extends BlockListener {
if (team != null && zone != null && zone.isFlagThief(player.getName())) {
War.war.badMsg(player, "Can't drop the flag. What are you doing? Run!");
event.setCancelled(true);
return;
}
// a bomb thief can't drop his bomb
if (team != null && zone != null && zone.isBombThief(player.getName())) {
War.war.badMsg(player, "Can't drop the bomb. What are you doing? Run for your enemy's spawn!");
event.setCancelled(true);
return;
}
// a cake thief can't drop his cake
if (team != null && zone != null && zone.isBombThief(player.getName())) {
War.war.badMsg(player, "Can't drop the cake. What are you doing? Run to your spawn!");
event.setCancelled(true);
return;
}
// unbreakableZoneBlocks
@ -254,6 +270,8 @@ public class WarBlockListener extends BlockListener {
if (warzone.isFlagThief(player.getName())) {
// detect audacious thieves
War.war.badMsg(player, "You can only steal one flag at a time!");
} else if (warzone.isBombThief(player.getName()) || warzone.isCakeThief(player.getName())) {
War.war.badMsg(player, "You can only steal one thing at a time!");
} else {
Team lostFlagTeam = warzone.getTeamForFlagBlock(block);
if (lostFlagTeam.getPlayers().size() != 0) {
@ -297,6 +315,90 @@ public class WarBlockListener extends BlockListener {
War.war.msg(player, "You can't steal team " + lostFlagTeam.getName() + "'s flag since no players are on that team.");
}
}
event.setCancelled(true);
return;
} else if (team != null && warzone.isBombBlock(block)) {
if (warzone.isBombThief(player.getName())) {
// detect audacious thieves
War.war.badMsg(player, "You can only steal one bomb at a time!");
} else if (warzone.isFlagThief(player.getName()) || warzone.isCakeThief(player.getName())) {
War.war.badMsg(player, "You can only steal one thing at a time!");
} else {
Bomb bomb = warzone.getBombForBlock(block);
// player just broke the bomb block: cancel to avoid drop, give player the block, set block to air
ItemStack tntBlock = new ItemStack(Material.TNT);
player.getInventory().clear();
player.getInventory().addItem(tntBlock);
warzone.addBombThief(bomb, player.getName());
block.setType(Material.AIR);
for (Team t : warzone.getTeams()) {
t.teamcast(team.getKind().getColor() + player.getName() + ChatColor.WHITE + " has bomb " + ChatColor.GREEN + bomb.getName() + ChatColor.WHITE + ".");
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(team.getKind().getColor() + player.getName() + ChatColor.YELLOW + " has "),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "bomb " + ChatColor.GREEN + bomb.getName() + ChatColor.YELLOW + "!"),
Material.TNT,
(short)0,
5000);
}
}
}
t.teamcast("Prevent " + team.getKind().getColor() + player.getName() + ChatColor.WHITE
+ " from reaching your spawn with the bomb!");
}
War.war.msg(player, "You have bomb " + bomb.getName() + ". Reach another team's spawn to score. Don't get touched by anyone or you'll blow up!");
}
event.setCancelled(true);
return;
} else if (team != null && warzone.isCakeBlock(block)) {
if (warzone.isCakeThief(player.getName())) {
// detect audacious thieves
War.war.badMsg(player, "You can only steal one cake at a time!");
} else if (warzone.isFlagThief(player.getName()) || warzone.isBombThief(player.getName())) {
War.war.badMsg(player, "You can only steal one thing at a time!");
} else {
Cake cake = warzone.getCakeForBlock(block);
// player just broke the cake block: cancel to avoid drop, give player the block, set block to air
ItemStack cakeBlock = new ItemStack(Material.CAKE);
player.getInventory().clear();
player.getInventory().addItem(cakeBlock);
warzone.addCakeThief(cake, player.getName());
block.setType(Material.AIR);
for (Team t : warzone.getTeams()) {
t.teamcast(team.getKind().getColor() + player.getName() + ChatColor.WHITE + " has cake " + ChatColor.GREEN + cake.getName() + ChatColor.WHITE + ".");
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(team.getKind().getColor() + player.getName() + ChatColor.YELLOW + " has "),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "cake " + ChatColor.GREEN + cake.getName() + ChatColor.YELLOW + "!"),
Material.CAKE,
(short)0,
5000);
}
}
}
t.teamcast("Prevent " + team.getKind().getColor() + player.getName() + ChatColor.WHITE
+ " from reaching their spawn with the cake!");
}
War.war.msg(player, "You have cake " + cake.getName() + ". Reach your team's spawn to score and replenish your lifepool.");
}
event.setCancelled(true);
return;
} else if (!warzone.isMonumentCenterBlock(block)) {

View File

@ -93,7 +93,15 @@ public class WarCommandHandler {
commandObj = new SetMonumentCommand(this, sender, arguments);
} else if (command.equals("deletemonument")) {
commandObj = new DeleteMonumentCommand(this, sender, arguments);
} else if (command.equals("setteamconfig") || command.equals("teamcfg")) {
} else if (command.equals("setbomb")) {
commandObj = new SetBombCommand(this, sender, arguments);
} else if (command.equals("deletebomb")) {
commandObj = new DeleteBombCommand(this, sender, arguments);
} else if (command.equals("setcake")) {
commandObj = new SetCakeCommand(this, sender, arguments);
} else if (command.equals("deletecake")) {
commandObj = new DeleteCakeCommand(this, sender, arguments);
}else if (command.equals("setteamconfig") || command.equals("teamcfg")) {
commandObj = new SetTeamConfigCommand(this, sender, arguments);
} else if (command.equals("setzoneconfig") || command.equals("zonecfg")) {
commandObj = new SetZoneConfigCommand(this, sender, arguments);

View File

@ -30,13 +30,17 @@ import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.inventory.ItemStack;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.tommytony.war.Bomb;
import com.tommytony.war.Team;
import com.tommytony.war.Warzone;
import com.tommytony.war.config.TeamConfig;
import com.tommytony.war.config.WarConfig;
import com.tommytony.war.config.WarzoneConfig;
import com.tommytony.war.jobs.DeferredBlockResetsJob;
import com.tommytony.war.spout.SpoutMessenger;
import com.tommytony.war.utils.DeferredBlockReset;
/**
@ -79,14 +83,16 @@ public class WarEntityListener extends EntityListener {
|| (attackerTeam != null && defenderTeam != null && attacker.getEntityId() == defender.getEntityId())) {
// Make sure one of the players isn't in the spawn
if (defenderTeam.getSpawnVolume().contains(d.getLocation())) { // attacking person in spawn
if (!defenderWarzone.isFlagThief(d.getName())) { // thieves can always be attacked
if (!defenderWarzone.isFlagThief(d.getName())
&& !defenderWarzone.isBombThief(d.getName())) { // thieves can always be attacked
War.war.badMsg(a, "Can't attack a player that's inside his team's spawn.");
event.setCancelled(true);
return;
}
} else if (attackerTeam.getSpawnVolume().contains(a.getLocation()) && !attackerTeam.getSpawnVolume().contains(d.getLocation())) {
// only let a player inside spawn attack an enemy player if that player enters the spawn
if (!attackerWarzone.isFlagThief(a.getName())) { // thieves can always attack
if (!attackerWarzone.isFlagThief(a.getName())
&& !defenderWarzone.isBombThief(d.getName())) { // thieves can always attack
War.war.badMsg(a, "Can't attack a player from inside your spawn.");
event.setCancelled(true);
return;
@ -152,6 +158,38 @@ public class WarEntityListener extends EntityListener {
defenderWarzone.handleDeath(d);
event.setCancelled(true);
} else if (defenderWarzone.isBombThief(d.getName()) && d.getLocation().distance(a.getLocation()) < 2) {
Bomb bomb = defenderWarzone.getBombForThief(d.getName());
// Kill the bomber
defenderWarzone.handleDeath(d);
// blow up bomb man if attacker is close enough
defenderWarzone.getWorld().createExplosion(a.getLocation(), 4F);
// Notify everyone
for (Team t : defenderWarzone.getTeams()) {
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(attackerTeam.getKind().getColor() + a.getName() + ChatColor.YELLOW + " made "),
SpoutMessenger.cleanForNotification(defenderTeam.getKind().getColor() + d.getName() + ChatColor.YELLOW + " blow up!"),
Material.TNT,
(short)0,
10000);
}
}
}
// bring back tnt
bomb.getVolume().resetBlocks();
bomb.addBombBlocks();
t.teamcast(attackerTeam.getKind().getColor() + a.getName() + ChatColor.WHITE
+ " made " + defenderTeam.getKind().getColor() + d.getName() + ChatColor.WHITE + " blow up!");
}
}
} else if (attackerTeam != null && defenderTeam != null && attackerTeam == defenderTeam && attackerWarzone == defenderWarzone && attacker.getEntityId() != defender.getEntityId()) {
// same team, but not same person

View File

@ -28,6 +28,8 @@ import org.bukkit.inventory.PlayerInventory;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.tommytony.war.Bomb;
import com.tommytony.war.Cake;
import com.tommytony.war.FlagReturn;
import com.tommytony.war.LoadoutSelection;
import com.tommytony.war.Team;
@ -79,6 +81,14 @@ public class WarPlayerListener extends PlayerListener {
// a flag thief can't drop his flag
War.war.badMsg(player, "Can't drop items while stealing flag. What are you doing?! Run!");
event.setCancelled(true);
} else if (zone.isBombThief(player.getName())) {
// a bomb thief can't drop his bomb
War.war.badMsg(player, "Can't drop items while stealing bomb. What are you doing?! Run for your enemy's spawn!");
event.setCancelled(true);
} else if (zone.isCakeThief(player.getName())) {
// a cake thief can't drop his cake
War.war.badMsg(player, "Can't drop items while stealing cake. What are you doing?! Run!");
event.setCancelled(true);
} else if (zone.getWarzoneConfig().getBoolean(WarzoneConfig.NODROPS)) {
War.war.badMsg(player, "Can't drop items in this warzone.");
event.setCancelled(true);
@ -504,10 +514,140 @@ public class WarPlayerListener extends PlayerListener {
if (playerWarzone.isTeamFlagStolen(playerTeam) && playerTeam.getTeamConfig().resolveBoolean(TeamConfig.FLAGMUSTBEHOME)) {
War.war.badMsg(player, "You can't capture the enemy flag until your team's flag is returned.");
} else {
synchronized (playerWarzone) {
// flags can be captured at own spawn or own flag pole
// flags can be captured at own spawn or own flag pole
playerTeam.addPoint();
Team victim = playerWarzone.getVictimTeamForFlagThief(player.getName());
// Notify everyone
for (Team t : playerWarzone.getTeams()) {
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " captured"),
SpoutMessenger.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + " flag!"),
victim.getKind().getMaterial(),
victim.getKind().getData(),
10000);
}
}
}
t.teamcast(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE
+ " captured team " + victim.getName() + "'s flag. Team " + playerTeam.getName() + " scores one point.");
}
// Detect win conditions
if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
if (playerWarzone.hasPlayerState(player.getName())) {
playerWarzone.restorePlayerState(player);
}
playerWarzone.handleScoreCapReached(player, playerTeam.getName());
event.setTo(playerWarzone.getTeleport());
} else {
// just added a point
victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
victim.initializeTeamFlag();
playerWarzone.respawnPlayer(event, playerTeam, player);
playerTeam.resetSign();
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
}
playerWarzone.removeFlagThief(player.getName());
}
return;
}
// Bomb detonation
if (playerWarzone.isBombThief(player.getName())) {
boolean inEnemySpawn = false;
Team victim = null;
for (Team team : playerWarzone.getTeams()) {
if (team != playerTeam
&& team.getSpawnVolume().contains(player.getLocation())
&& team.getPlayers().size() > 0) {
inEnemySpawn = true;
victim = team;
break;
}
}
if (inEnemySpawn) {
Bomb bomb = playerWarzone.getBombForThief(player.getName());
// Boom!
playerWarzone.getWorld().createExplosion(player.getLocation(), 1F);
playerTeam.addPoint();
// Notify everyone
for (Team t : playerWarzone.getTeams()) {
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " blew up "),
SpoutMessenger.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + "'s spawn!"),
victim.getKind().getMaterial(),
victim.getKind().getData(),
10000);
}
}
}
t.teamcast(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE
+ " blew up team " + victim.getName() + "'s spawn. Team " + playerTeam.getName() + " scores one point.");
}
// Detect win conditions
if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
if (playerWarzone.hasPlayerState(player.getName())) {
playerWarzone.restorePlayerState(player);
}
playerWarzone.handleScoreCapReached(player, playerTeam.getName());
event.setTo(playerWarzone.getTeleport());
} else {
// just added a point
// bring back flag to team that lost it
victim.getSpawnVolume().resetBlocks();
victim.initializeTeamSpawn();
// bring back tnt
bomb.getVolume().resetBlocks();
bomb.addBombBlocks();
playerWarzone.respawnPlayer(event, playerTeam, player);
playerTeam.resetSign();
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
}
playerWarzone.removeBombThief(player.getName());
}
return;
}
// Cake retrieval
if (playerWarzone.isCakeThief(player.getName())) {
boolean inSpawn = playerTeam.getSpawnVolume().contains(player.getLocation());
if (inSpawn) {
boolean hasOpponent = false;
for (Team t : playerWarzone.getTeams()) {
if (t != playerTeam && t.getPlayers().size() > 0) {
hasOpponent = true;
}
}
// Don't let someone alone make points off cakes
if (hasOpponent) {
Cake cake = playerWarzone.getCakeForThief(player.getName());
// Woot!
playerTeam.addPoint();
Team victim = playerWarzone.getVictimTeamForThief(player.getName());
playerTeam.setRemainingLives(playerTeam.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL));
// Notify everyone
for (Team t : playerWarzone.getTeams()) {
@ -517,15 +657,16 @@ public class WarPlayerListener extends PlayerListener {
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " captured"),
SpoutMessenger.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + " flag!"),
victim.getKind().getMaterial(),
victim.getKind().getData(),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "cake " + ChatColor.GREEN + cake.getName() + ChatColor.YELLOW + "!"),
playerTeam.getKind().getMaterial(),
playerTeam.getKind().getData(),
10000);
}
}
}
t.teamcast(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE
+ " captured team " + victim.getName() + "'s flag. Team " + playerTeam.getName() + " scores one point.");
+ " captured cake " + ChatColor.GREEN + cake.getName() + ChatColor.WHITE + ". Team " + playerTeam.getName() + " scores one point and gets a full lifepool.");
}
// Detect win conditions
@ -537,16 +678,20 @@ public class WarPlayerListener extends PlayerListener {
event.setTo(playerWarzone.getTeleport());
} else {
// just added a point
victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
victim.initializeTeamFlag();
// bring back cake
cake.getVolume().resetBlocks();
cake.addCakeBlocks();
playerWarzone.respawnPlayer(event, playerTeam, player);
playerTeam.resetSign();
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
}
playerWarzone.removeThief(player.getName());
playerWarzone.removeCakeThief(player.getName());
}
}
return;
}

View File

@ -0,0 +1,67 @@
package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Bomb;
import com.tommytony.war.Monument;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.WarzoneYmlMapper;
/**
* Deletes a bomb.
*
* @author tommytony
*/
public class DeleteBombCommand extends AbstractZoneMakerCommand {
public DeleteBombCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args);
}
@Override
public boolean handle() {
Warzone zone;
if (this.args.length == 0) {
return false;
} else if (this.args.length == 2) {
zone = Warzone.getZoneByName(this.args[0]);
this.args[0] = this.args[1];
} else if (this.args.length == 1) {
if (!(this.getSender() instanceof Player)) {
return false;
}
zone = Warzone.getZoneByLocation((Player) this.getSender());
if (zone == null) {
ZoneLobby lobby = ZoneLobby.getLobbyByLocation((Player) this.getSender());
if (lobby == null) {
return false;
}
zone = lobby.getZone();
}
} else {
return false;
}
if (zone == null) {
return false;
} else if (!this.isSenderAuthorOfZone(zone)) {
return true;
}
Bomb bomb = zone.getBomb(this.args[0]);
if (bomb != null) {
bomb.getVolume().resetBlocks();
zone.getBombs().remove(bomb);
WarzoneYmlMapper.save(zone, false);
this.msg("Bomb " + bomb.getName() + " removed.");
} else {
this.badMsg("No such bomb.");
}
return true;
}
}

View File

@ -0,0 +1,66 @@
package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Cake;
import com.tommytony.war.Warzone;
import com.tommytony.war.ZoneLobby;
import com.tommytony.war.mappers.WarzoneYmlMapper;
/**
* Deletes a cake.
*
* @author tommytony
*/
public class DeleteCakeCommand extends AbstractZoneMakerCommand {
public DeleteCakeCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args);
}
@Override
public boolean handle() {
Warzone zone;
if (this.args.length == 0) {
return false;
} else if (this.args.length == 2) {
zone = Warzone.getZoneByName(this.args[0]);
this.args[0] = this.args[1];
} else if (this.args.length == 1) {
if (!(this.getSender() instanceof Player)) {
return false;
}
zone = Warzone.getZoneByLocation((Player) this.getSender());
if (zone == null) {
ZoneLobby lobby = ZoneLobby.getLobbyByLocation((Player) this.getSender());
if (lobby == null) {
return false;
}
zone = lobby.getZone();
}
} else {
return false;
}
if (zone == null) {
return false;
} else if (!this.isSenderAuthorOfZone(zone)) {
return true;
}
Cake cake = zone.getCake(this.args[0]);
if (cake != null) {
cake.getVolume().resetBlocks();
zone.getCakes().remove(cake);
WarzoneYmlMapper.save(zone, false);
this.msg("Cake " + cake.getName() + " removed.");
} else {
this.badMsg("No such cake.");
}
return true;
}
}

View File

@ -78,15 +78,6 @@ public class JoinCommand extends AbstractWarCommand {
if (!previousTeam.removePlayer(player.getName())) {
War.war.log("Could not remove player " + player.getName() + " from team " + previousTeam.getName(), java.util.logging.Level.WARNING);
}
if (oldZone.isFlagThief(player.getName())) {
Team victim = oldZone.getVictimTeamForThief(player.getName());
victim.getFlagVolume().resetBlocks();
victim.initializeTeamFlag();
zone.removeThief(player.getName());
for (Team t : oldZone.getTeams()) {
t.teamcast("Team " + victim.getName() + " flag was returned.");
}
}
previousTeam.resetSign();
}

View File

@ -39,7 +39,7 @@ public class NextBattleCommand extends AbstractZoneMakerCommand {
return false;
}
zone.clearFlagThieves();
zone.clearThieves();
for (Team team : zone.getTeams()) {
team.teamcast("The battle was interrupted. " + zone.getTeamInformation() + " Resetting warzone " + zone.getName() + " and life pools...");
}

View File

@ -42,7 +42,7 @@ public class ResetZoneCommand extends AbstractZoneMakerCommand {
return true;
}
zone.clearFlagThieves();
zone.clearThieves();
for (Team team : zone.getTeams()) {
team.teamcast("The war has ended. " + zone.getTeamInformation() + " Resetting warzone " + zone.getName() + " and teams...");
for (Player p : team.getPlayers()) {

View File

@ -0,0 +1,64 @@
package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Bomb;
import com.tommytony.war.Warzone;
import com.tommytony.war.mappers.WarzoneYmlMapper;
/**
* Places a bomb
*
* @author tommytony
*/
public class SetBombCommand extends AbstractZoneMakerCommand {
public SetBombCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args);
}
@Override
public boolean handle() {
if (!(this.getSender() instanceof Player)) {
this.badMsg("You can't do this if you are not in-game.");
return true;
}
Player player = (Player) this.getSender();
if (this.args.length != 1) {
return false;
}
Warzone zone = Warzone.getZoneByLocation(player);
if (zone == null) {
return false;
} else if (!this.isSenderAuthorOfZone(zone)) {
return true;
}
if (this.args[0].equals(zone.getName())) {
return false;
}
if (zone.hasBomb(this.args[0])) {
// move the existing bomb
Bomb bomb = zone.getBomb(this.args[0]);
bomb.getVolume().resetBlocks();
bomb.setLocation(player.getLocation());
this.msg("Bomb " + bomb.getName() + " was moved.");
} else {
// create a new bomb
Bomb bomb = new Bomb(this.args[0], zone, player.getLocation());
zone.getBombs().add(bomb);
this.msg("Bomb " + bomb.getName() + " created.");
}
WarzoneYmlMapper.save(zone, false);
return true;
}
}

View File

@ -0,0 +1,64 @@
package bukkit.tommytony.war.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import bukkit.tommytony.war.WarCommandHandler;
import com.tommytony.war.Cake;
import com.tommytony.war.Warzone;
import com.tommytony.war.mappers.WarzoneYmlMapper;
/**
* Places a cake
*
* @author tommytony
*/
public class SetCakeCommand extends AbstractZoneMakerCommand {
public SetCakeCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
super(handler, sender, args);
}
@Override
public boolean handle() {
if (!(this.getSender() instanceof Player)) {
this.badMsg("You can't do this if you are not in-game.");
return true;
}
Player player = (Player) this.getSender();
if (this.args.length != 1) {
return false;
}
Warzone zone = Warzone.getZoneByLocation(player);
if (zone == null) {
return false;
} else if (!this.isSenderAuthorOfZone(zone)) {
return true;
}
if (this.args[0].equals(zone.getName())) {
return false;
}
if (zone.hasCake(this.args[0])) {
// move the existing cake
Cake cake = zone.getCake(this.args[0]);
cake.getVolume().resetBlocks();
cake.setLocation(player.getLocation());
this.msg("Cake " + cake.getName() + " was moved.");
} else {
// create a new cake
Cake cake = new Cake(this.args[0], zone, player.getLocation());
zone.getCakes().add(cake);
this.msg("Cake " + cake.getName() + " created.");
}
WarzoneYmlMapper.save(zone, false);
return true;
}
}

View File

@ -0,0 +1,110 @@
package com.tommytony.war;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import com.tommytony.war.volumes.Volume;
/**
*
* @author tommytony
*
*/
public class Bomb {
private Location location;
private Volume volume;
private final String name;
private Warzone warzone;
private Player capturer;
public Bomb(String name, Warzone warzone, Location location) {
this.name = name;
this.location = location;
this.warzone = warzone;
this.volume = new Volume("bomb-" + name, warzone.getWorld());
this.setLocation(location);
}
public void addBombBlocks() {
this.volume.setToMaterial(Material.AIR);
int x = this.location.getBlockX();
int y = this.location.getBlockY();
int z = this.location.getBlockZ();
// center
this.warzone.getWorld().getBlockAt(x, y - 1, z).getState().setType(Material.OBSIDIAN);
// inner ring
this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1).setType(Material.GLOWSTONE);
this.warzone.getWorld().getBlockAt(x + 1, y - 1, z).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1).setType(Material.GLOWSTONE);
this.warzone.getWorld().getBlockAt(x, y - 1, z + 1).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x, y - 1, z).setType(Material.GLOWSTONE);
this.warzone.getWorld().getBlockAt(x, y - 1, z - 1).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1).setType(Material.GLOWSTONE);
this.warzone.getWorld().getBlockAt(x - 1, y - 1, z).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1).setType(Material.GLOWSTONE);
// block holder
this.warzone.getWorld().getBlockAt(x, y, z).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x, y + 1, z).setType(Material.TNT);
}
public boolean isBombBlock(Location otherLocation) {
int x = this.location.getBlockX();
int y = this.location.getBlockY() + 1;
int z = this.location.getBlockZ();
int otherX = otherLocation.getBlockX();
int otherY = otherLocation.getBlockY();
int otherZ = otherLocation.getBlockZ();
return x == otherX
&& y == otherY
&& z == otherZ;
}
public void capture(Player capturer) {
this.capturer = capturer;
}
public boolean isCaptured() {
return this.capturer != null;
}
public void uncapture() {
this.capturer = null;
}
public Location getLocation() {
return this.location;
}
public String getName() {
return this.name;
}
public void setLocation(Location location) {
Block locationBlock = this.warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
this.volume.setCornerOne(locationBlock.getRelative(BlockFace.DOWN).getRelative(BlockFace.EAST, 1).getRelative(BlockFace.SOUTH, 1));
this.volume.setCornerTwo(locationBlock.getRelative(BlockFace.UP, 2).getRelative(BlockFace.WEST, 1).getRelative(BlockFace.NORTH, 1));
this.volume.saveBlocks();
this.location = location;
this.addBombBlocks();
}
public Volume getVolume() {
return this.volume;
}
public void setVolume(Volume newVolume) {
this.volume = newVolume;
}
}

View File

@ -0,0 +1,110 @@
package com.tommytony.war;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import com.tommytony.war.volumes.Volume;
/**
*
* @author tommytony
*
*/
public class Cake {
private Location location;
private Volume volume;
private final String name;
private Warzone warzone;
private Player capturer;
public Cake(String name, Warzone warzone, Location location) {
this.name = name;
this.location = location;
this.warzone = warzone;
this.volume = new Volume("cake-" + name, warzone.getWorld());
this.setLocation(location);
}
public void addCakeBlocks() {
this.volume.setToMaterial(Material.AIR);
int x = this.location.getBlockX();
int y = this.location.getBlockY();
int z = this.location.getBlockZ();
// center
this.warzone.getWorld().getBlockAt(x, y - 1, z).getState().setType(Material.OBSIDIAN);
// inner ring
this.warzone.getWorld().getBlockAt(x + 1, y - 1, z + 1).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x + 1, y - 1, z).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x + 1, y - 1, z - 1).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x, y - 1, z + 1).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x, y - 1, z).setType(Material.GLOWSTONE);
this.warzone.getWorld().getBlockAt(x, y - 1, z - 1).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x - 1, y - 1, z + 1).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x - 1, y - 1, z).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1).setType(Material.OBSIDIAN);
// block holder
this.warzone.getWorld().getBlockAt(x, y, z).setType(Material.GLASS);
this.warzone.getWorld().getBlockAt(x, y + 1, z).setType(Material.CAKE_BLOCK);
}
public boolean isCakeBlock(Location otherLocation) {
int x = this.location.getBlockX();
int y = this.location.getBlockY() + 1;
int z = this.location.getBlockZ();
int otherX = otherLocation.getBlockX();
int otherY = otherLocation.getBlockY();
int otherZ = otherLocation.getBlockZ();
return x == otherX
&& y == otherY
&& z == otherZ;
}
public void capture(Player capturer) {
this.capturer = capturer;
}
public boolean isCaptured() {
return this.capturer != null;
}
public void uncapture() {
this.capturer = null;
}
public Location getLocation() {
return this.location;
}
public String getName() {
return this.name;
}
public void setLocation(Location location) {
Block locationBlock = this.warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
this.volume.setCornerOne(locationBlock.getRelative(BlockFace.DOWN).getRelative(BlockFace.EAST, 1).getRelative(BlockFace.SOUTH, 1));
this.volume.setCornerTwo(locationBlock.getRelative(BlockFace.UP, 2).getRelative(BlockFace.WEST, 1).getRelative(BlockFace.NORTH, 1));
this.volume.saveBlocks();
this.location = location;
this.addCakeBlocks();
}
public Volume getVolume() {
return this.volume;
}
public void setVolume(Volume newVolume) {
this.volume = newVolume;
}
}

View File

@ -26,8 +26,6 @@ public class Monument {
this.warzone = warzone;
this.volume = new Volume(name, warzone.getWorld());
this.setLocation(location);
this.addMonumentBlocks();
}
public void addMonumentBlocks() {
@ -54,7 +52,6 @@ public class Monument {
this.warzone.getWorld().getBlockAt(x - 1, y - 1, z - 1).setType(Material.OBSIDIAN);
// outer ring
this.warzone.getWorld().getBlockAt(x + 2, y - 1, z + 2).setType(Material.GLOWSTONE);
this.warzone.getWorld().getBlockAt(x + 2, y - 1, z + 1).setType(Material.OBSIDIAN);
this.warzone.getWorld().getBlockAt(x + 2, y - 1, z).setType(Material.OBSIDIAN);
@ -144,6 +141,7 @@ public class Monument {
this.volume.setCornerTwo(locationBlock.getRelative(BlockFace.UP, 2).getRelative(BlockFace.WEST, 2).getRelative(BlockFace.NORTH, 2));
this.volume.saveBlocks();
this.location = location;
this.addMonumentBlocks();
}

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -395,8 +396,40 @@ public class Team {
}
if (thePlayer != null) {
this.players.remove(thePlayer);
if (this.warzone.isFlagThief(thePlayer.getName())) {
Team victim = this.warzone.getVictimTeamForFlagThief(thePlayer.getName());
victim.getFlagVolume().resetBlocks();
victim.initializeTeamFlag();
this.warzone.removeFlagThief(thePlayer.getName());
for (Team t : this.warzone.getTeams()) {
t.teamcast("Team " + ChatColor.GREEN + victim.getName() + ChatColor.WHITE + " flag was returned.");
}
}
if (this.warzone.isBombThief(thePlayer.getName())) {
Bomb bomb = this.warzone.getBombForThief(thePlayer.getName());
bomb.getVolume().resetBlocks();
bomb.addBombBlocks();
this.warzone.removeBombThief(thePlayer.getName());
for (Team t : this.warzone.getTeams()) {
t.teamcast("Bomb " + ChatColor.GREEN + bomb.getName() + ChatColor.WHITE + " was returned.");
}
}
if (this.warzone.isCakeThief(thePlayer.getName())) {
Cake cake = this.warzone.getCakeForThief(thePlayer.getName());
cake.getVolume().resetBlocks();
cake.addCakeBlocks();
this.warzone.removeCakeThief(thePlayer.getName());
for (Team t : this.warzone.getTeams()) {
t.teamcast("Cake " + ChatColor.GREEN + cake.getName() + ChatColor.WHITE + " was returned.");
}
}
return true;
}
}
return false;
}

View File

@ -51,6 +51,8 @@ public class Warzone {
private World world;
private final List<Team> teams = new ArrayList<Team>();
private final List<Monument> monuments = new ArrayList<Monument>();
private final List<Bomb> bombs = new ArrayList<Bomb>();
private final List<Cake> cakes = new ArrayList<Cake>();
private Location teleport;
private ZoneLobby lobby;
private Location rallyPoint;
@ -61,6 +63,8 @@ public class Warzone {
private List<ZoneWallGuard> zoneWallGuards = new ArrayList<ZoneWallGuard>();
private HashMap<String, PlayerState> playerStates = new HashMap<String, PlayerState>();
private HashMap<String, Team> flagThieves = new HashMap<String, Team>();
private HashMap<String, Bomb> bombThieves = new HashMap<String, Bomb>();
private HashMap<String, Cake> cakeThieves = new HashMap<String, Cake>();
private HashMap<String, LoadoutSelection> loadoutSelections = new HashMap<String, LoadoutSelection>();
private HashMap<String, PlayerState> deadMenInventories = new HashMap<String, PlayerState>();
private final List<Player> respawn = new ArrayList<Player>();
@ -247,6 +251,18 @@ public class Warzone {
monument.getVolume().resetBlocks();
monument.addMonumentBlocks();
}
// reset bombs
for (Bomb bomb : this.bombs) {
bomb.getVolume().resetBlocks();
bomb.addBombBlocks();
}
// reset cakes
for (Cake cake : this.cakes) {
cake.getVolume().resetBlocks();
cake.addCakeBlocks();
}
// reset lobby (here be demons)
if (this.lobby != null) {
@ -498,7 +514,7 @@ public class Warzone {
public boolean hasMonument(String monumentName) {
for (Monument monument : this.monuments) {
if (monument.getName().equals(monumentName)) {
if (monument.getName().startsWith(monumentName)) {
return true;
}
}
@ -513,6 +529,42 @@ public class Warzone {
}
return null;
}
public boolean hasBomb(String bombName) {
for (Bomb bomb : this.bombs) {
if (bomb.getName().equals(bombName)) {
return true;
}
}
return false;
}
public Bomb getBomb(String bombName) {
for (Bomb bomb : this.bombs) {
if (bomb.getName().startsWith(bombName)) {
return bomb;
}
}
return null;
}
public boolean hasCake(String cakeName) {
for (Cake cake : this.cakes) {
if (cake.getName().equals(cakeName)) {
return true;
}
}
return false;
}
public Cake getCake(String cakeName) {
for (Cake cake : this.cakes) {
if (cake.getName().startsWith(cakeName)) {
return cake;
}
}
return null;
}
public boolean isImportantBlock(Block block) {
if (this.ready()) {
@ -521,6 +573,16 @@ public class Warzone {
return true;
}
}
for (Bomb b : this.bombs) {
if (b.getVolume().contains(block)) {
return true;
}
}
for (Cake c : this.cakes) {
if (c.getVolume().contains(block)) {
return true;
}
}
for (Team t : this.teams) {
if (t.getSpawnVolume().contains(block)) {
return true;
@ -801,21 +863,21 @@ public class Warzone {
// player died without causing his team's demise
if (playerWarzone.isFlagThief(player.getName())) {
// died while carrying flag.. dropped it
Team victim = playerWarzone.getVictimTeamForThief(player.getName());
Team victim = playerWarzone.getVictimTeamForFlagThief(player.getName());
victim.getFlagVolume().resetBlocks();
victim.initializeTeamFlag();
playerWarzone.removeThief(player.getName());
playerWarzone.removeFlagThief(player.getName());
if (War.war.isSpoutServer()) {
for (Player p : victim.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " dropped"),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "your flag."),
playerTeam.getKind().getMaterial(),
playerTeam.getKind().getData(),
5000);
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " dropped"),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "your flag."),
playerTeam.getKind().getMaterial(),
playerTeam.getKind().getData(),
5000);
}
}
}
@ -824,6 +886,59 @@ public class Warzone {
t.teamcast(player.getName() + " died and dropped team " + victim.getName() + "'s flag.");
}
}
// Bomb thieves
if (playerWarzone.isBombThief(player.getName())) {
// died while carrying bomb.. dropped it
Bomb bomb = playerWarzone.getBombForThief(player.getName());
bomb.getVolume().resetBlocks();
bomb.addBombBlocks();
playerWarzone.removeBombThief(player.getName());
for (Team t : playerWarzone.getTeams()) {
t.teamcast(player.getName() + " died and dropped bomb " + ChatColor.GREEN + bomb.getName() + ChatColor.WHITE + ".");
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " dropped"),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "bomb " + ChatColor.GREEN + bomb.getName() + ChatColor.YELLOW + "."),
Material.TNT,
(short)0,
5000);
}
}
}
}
}
if (playerWarzone.isCakeThief(player.getName())) {
// died while carrying cake.. dropped it
Cake cake = playerWarzone.getCakeForThief(player.getName());
cake.getVolume().resetBlocks();
cake.addCakeBlocks();
playerWarzone.removeCakeThief(player.getName());
for (Team t : playerWarzone.getTeams()) {
t.teamcast(player.getName() + " died and dropped cake " + ChatColor.GREEN + cake.getName() + ChatColor.WHITE + ".");
if (War.war.isSpoutServer()) {
for (Player p : t.getPlayers()) {
SpoutPlayer sp = SpoutManager.getPlayer(p);
if (sp.isSpoutCraftEnabled()) {
sp.sendNotification(
SpoutMessenger.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " dropped"),
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "cake " + ChatColor.GREEN + cake.getName() + ChatColor.YELLOW + "."),
Material.CAKE,
(short)0,
5000);
}
}
}
}
}
// Lifepool empty warning
playerTeam.setRemainingLives(remaining - 1);
if (remaining - 1 == 0) {
for (Team t : playerWarzone.getTeams()) {
@ -855,15 +970,7 @@ public class Warzone {
t.teamcast(playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE + " left the zone.");
}
playerTeam.resetSign();
if (this.isFlagThief(player.getName())) {
Team victim = this.getVictimTeamForThief(player.getName());
victim.getFlagVolume().resetBlocks();
victim.initializeTeamFlag();
this.removeThief(player.getName());
for (Team t : this.getTeams()) {
t.teamcast("Team " + victim.getName() + " flag was returned.");
}
}
if (this.getLobby() != null) {
this.getLobby().resetTeamGateSign(playerTeam);
}
@ -933,7 +1040,44 @@ public class Warzone {
}
return null;
}
public boolean isBombBlock(Block block) {
for (Bomb bomb : this.bombs) {
if (bomb.isBombBlock(block.getLocation())) {
return true;
}
}
return false;
}
public Bomb getBombForBlock(Block block) {
for (Bomb bomb : this.bombs) {
if (bomb.isBombBlock(block.getLocation())) {
return bomb;
}
}
return null;
}
public boolean isCakeBlock(Block block) {
for (Cake cake : this.cakes) {
if (cake.isCakeBlock(block.getLocation())) {
return true;
}
}
return false;
}
public Cake getCakeForBlock(Block block) {
for (Cake cake : this.cakes) {
if (cake.isCakeBlock(block.getLocation())) {
return cake;
}
}
return null;
}
// Flags
public void addFlagThief(Team lostFlagTeam, String flagThief) {
this.flagThieves.put(flagThief, lostFlagTeam);
}
@ -945,16 +1089,59 @@ public class Warzone {
return false;
}
public Team getVictimTeamForThief(String thief) {
public Team getVictimTeamForFlagThief(String thief) {
return this.flagThieves.get(thief);
}
public void removeThief(String thief) {
public void removeFlagThief(String thief) {
this.flagThieves.remove(thief);
}
public void clearFlagThieves() {
// Bomb
public void addBombThief(Bomb bomb, String bombThief) {
this.bombThieves.put(bombThief, bomb);
}
public boolean isBombThief(String suspect) {
if (this.bombThieves.containsKey(suspect)) {
return true;
}
return false;
}
public Bomb getBombForThief(String thief) {
return this.bombThieves.get(thief);
}
public void removeBombThief(String thief) {
this.bombThieves.remove(thief);
}
// Cake
public void addCakeThief(Cake cake, String cakeThief) {
this.cakeThieves.put(cakeThief, cake);
}
public boolean isCakeThief(String suspect) {
if (this.cakeThieves.containsKey(suspect)) {
return true;
}
return false;
}
public Cake getCakeForThief(String thief) {
return this.cakeThieves.get(thief);
}
public void removeCakeThief(String thief) {
this.cakeThieves.remove(thief);
}
public void clearThieves() {
this.flagThieves.clear();
this.bombThieves.clear();
this.cakeThieves.clear();
}
public boolean isTeamFlagStolen(Team team) {
@ -965,7 +1152,7 @@ public class Warzone {
}
return false;
}
public void handleScoreCapReached(Player player, String winnersStr) {
// Score cap reached. Reset everything.
ScoreCapReachedJob job = new ScoreCapReachedJob(this, winnersStr);
@ -1099,4 +1286,12 @@ public class Warzone {
public InventoryBag getDefaultInventories() {
return this.defaultInventories ;
}
public List<Bomb> getBombs() {
return bombs;
}
public List<Cake> getCakes() {
return cakes;
}
}

View File

@ -16,6 +16,8 @@ import org.bukkit.inventory.ItemStack;
import bukkit.tommytony.war.War;
import com.tommytony.war.Bomb;
import com.tommytony.war.Cake;
import com.tommytony.war.Monument;
import com.tommytony.war.Team;
import com.tommytony.war.TeamKind;
@ -123,6 +125,38 @@ public class WarzoneYmlMapper {
}
}
// bombs
if (warzoneRootSection.contains(zoneInfoPrefix + "bomb")) {
List<String> bombNames = warzoneRootSection.getStringList(zoneInfoPrefix + "bomb.names");
for (String bombName : bombNames) {
if (bombName != null && !bombName.equals("")) {
String bombPrefix = zoneInfoPrefix + "bomb." + bombName + ".";
int bombX = warzoneRootSection.getInt(bombPrefix + "x");
int bombY = warzoneRootSection.getInt(bombPrefix + "y");
int bombZ = warzoneRootSection.getInt(bombPrefix + "z");
int bombYaw = warzoneRootSection.getInt(bombPrefix + "yaw");
Bomb bomb = new Bomb(bombName, warzone, new Location(world, bombX, bombY, bombZ, bombYaw, 0));
warzone.getBombs().add(bomb);
}
}
}
// cakes
if (warzoneRootSection.contains(zoneInfoPrefix + "cake")) {
List<String> cakeNames = warzoneRootSection.getStringList(zoneInfoPrefix + "cake.names");
for (String cakeName : cakeNames) {
if (cakeName != null && !cakeName.equals("")) {
String cakePrefix = zoneInfoPrefix + "cake." + cakeName + ".";
int cakeX = warzoneRootSection.getInt(cakePrefix + "x");
int cakeY = warzoneRootSection.getInt(cakePrefix + "y");
int cakeZ = warzoneRootSection.getInt(cakePrefix + "z");
int cakeYaw = warzoneRootSection.getInt(cakePrefix + "yaw");
Cake cake = new Cake(cakeName, warzone, new Location(world, cakeX, cakeY, cakeZ, cakeYaw, 0));
warzone.getCakes().add(cake);
}
}
}
// teams (maybe no teams)
if (warzoneRootSection.contains("team.names")) {
List<String> teamsNames = warzoneRootSection.getStringList("team.names");
@ -183,7 +217,17 @@ public class WarzoneYmlMapper {
for (Monument monument : warzone.getMonuments()) {
monument.setVolume(VolumeMapper.loadVolume(monument.getName(), warzone.getName(), world));
}
// bomb blocks
for (Bomb bomb : warzone.getBombs()) {
bomb.setVolume(VolumeMapper.loadVolume("bomb-" + bomb.getName(), warzone.getName(), world));
}
// cake blocks
for (Cake cake : warzone.getCakes()) {
cake.setVolume(VolumeMapper.loadVolume("cake-" + cake.getName(), warzone.getName(), world));
}
// team spawn blocks
for (Team team : warzone.getTeams()) {
team.setSpawnVolume(VolumeMapper.loadVolume(team.getName(), warzone.getName(), world));
@ -298,6 +342,46 @@ public class WarzoneYmlMapper {
}
}
// bombs
if (warzone.getMonuments().size() > 0) {
ConfigurationSection bombsSection = warzoneInfoSection.createSection("bomb");
List<String> bombNames = new ArrayList<String>();
for (Bomb bomb : warzone.getBombs()) {
bombNames.add(bomb.getName());
}
bombsSection.set("names", bombNames);
for (Bomb bomb : warzone.getBombs()) {
ConfigurationSection bombSection = bombsSection.createSection(bomb.getName());
bombSection.set("x", bomb.getLocation().getBlockX());
bombSection.set("y", bomb.getLocation().getBlockY());
bombSection.set("z", bomb.getLocation().getBlockZ());
bombSection.set("yaw", toIntYaw(bomb.getLocation().getYaw()));
}
}
// cakes
if (warzone.getMonuments().size() > 0) {
ConfigurationSection cakesSection = warzoneInfoSection.createSection("cake");
List<String> cakeNames = new ArrayList<String>();
for (Cake cake : warzone.getCakes()) {
cakeNames.add(cake.getName());
}
cakesSection.set("names", cakeNames);
for (Cake cake : warzone.getCakes()) {
ConfigurationSection cakeSection = cakesSection.createSection(cake.getName());
cakeSection.set("x", cake.getLocation().getBlockX());
cakeSection.set("y", cake.getLocation().getBlockY());
cakeSection.set("z", cake.getLocation().getBlockZ());
cakeSection.set("yaw", toIntYaw(cake.getLocation().getYaw()));
}
}
ConfigurationSection teamsSection = warzoneRootSection.createSection("team");
// teams
@ -371,6 +455,16 @@ public class WarzoneYmlMapper {
for (Monument monument : warzone.getMonuments()) {
VolumeMapper.save(monument.getVolume(), warzone.getName());
}
// bomb blocks
for (Bomb bomb : warzone.getBombs()) {
VolumeMapper.save(bomb.getVolume(), warzone.getName());
}
// cake blocks
for (Cake cake : warzone.getCakes()) {
VolumeMapper.save(cake.getVolume(), warzone.getName());
}
// team spawn & flag blocks
for (Team team : teams) {

View File

@ -131,8 +131,8 @@ commands:
Ex -
/setteam <diamond/iron/gold/white/orange/magenta/blue/green/pink/gray/purple/navy/brown/darkgreen/red/black>
setmonument:
description: War> Creates or moves a monument.
usage: Creates or moves a monument. Must be standing in warzone.
description: War> Creates or moves a monument. Monuments can be capture with wool from your team and give your health.
usage: Creates or moves a monument. Monuments can be capture with wool from your team and give your health. Must be standing in warzone.
Ex -
/setmonument <monument-name>
setteamflag:
@ -140,6 +140,16 @@ commands:
usage: Creates/moves a team flag post for CTF. Must be standing in warzone.
Ex -
/setteamflag <team-color>
setbomb:
description: War> Creates or moves a bomb. Get the bomb to the other team's spawn. People from other teams can blow you up.
usage: Creates or moves a bomb. Get the bomb to the other team's spawn. People from other teams can blow you up. Must be standing in warzone.
Ex -
/setbomb <bomb-name>
setcake:
description: War> Creates or moves a cake. Get the cake to your spawn to score a replenish your lifepool.
usage: Creates or moves a bomb. Get the cake to your spawn to score a replenish your lifepool. Must be standing in warzone.
Ex -
/setcake <cake-name>
resetzone:
description: War> Reloads zone blocks from disk. Everyone is teleported back to the lobby.
usage: Reloads zone blocks from disk. Everyone is teleported back to the lobby. Provide a zone name if not standing in warzone or lobby.
@ -170,6 +180,16 @@ commands:
usage: Deletes the monument. Provide a zone name if not standing in warzone or lobby.
Ex -
/deletemonument [zone-name] <monument-name>
deletebomb:
description: War> Deletes the bomb.
usage: Deletes the bomb. Provide a zone name if not standing in warzone or lobby.
Ex -
/deletebomb [zone-name] <bomb-name>
deletecake:
description: War> Deletes the cake.
usage: Deletes the cake. Provide a zone name if not standing in warzone or lobby.
Ex -
/deletecake [zone-name] <cake-name>
setzoneconfig:
description: War> Use named parameters to change the configuration of the warzone. Resets blocks like /nextbattle. Does not save zone blocks like /savezone.
usage: Use named parameters to change the configuration of the warzone. Resets blocks like /nextbattle. Does not save zone blocks like /savezone. Provide a zone name if not standing in warzone or lobby.

View File

@ -131,8 +131,8 @@ commands:
Ex -
/setteam <diamond/iron/gold/white/orange/magenta/blue/green/pink/gray/purple/navy/brown/darkgreen/red/black>
setmonument:
description: War> Creates or moves a monument.
usage: Creates or moves a monument. Must be standing in warzone.
description: War> Creates or moves a monument. Monuments can be capture with wool from your team and give your health.
usage: Creates or moves a monument. Monuments can be capture with wool from your team and give your health. Must be standing in warzone.
Ex -
/setmonument <monument-name>
setteamflag:
@ -140,6 +140,16 @@ commands:
usage: Creates/moves a team flag post for CTF. Must be standing in warzone.
Ex -
/setteamflag <team-color>
setbomb:
description: War> Creates or moves a bomb. Get the bomb to the other team's spawn. People from other teams can blow you up.
usage: Creates or moves a bomb. Get the bomb to the other team's spawn. People from other teams can blow you up. Must be standing in warzone.
Ex -
/setbomb <bomb-name>
setcake:
description: War> Creates or moves a cake. Get the cake to your spawn to score a replenish your lifepool.
usage: Creates or moves a bomb. Get the cake to your spawn to score a replenish your lifepool. Must be standing in warzone.
Ex -
/setcake <cake-name>
resetzone:
description: War> Reloads zone blocks from disk. Everyone is teleported back to the lobby.
usage: Reloads zone blocks from disk. Everyone is teleported back to the lobby. Provide a zone name if not standing in warzone or lobby.
@ -170,6 +180,16 @@ commands:
usage: Deletes the monument. Provide a zone name if not standing in warzone or lobby.
Ex -
/deletemonument [zone-name] <monument-name>
deletebomb:
description: War> Deletes the bomb.
usage: Deletes the bomb. Provide a zone name if not standing in warzone or lobby.
Ex -
/deletebomb [zone-name] <bomb-name>
deletecake:
description: War> Deletes the cake.
usage: Deletes the cake. Provide a zone name if not standing in warzone or lobby.
Ex -
/deletecake [zone-name] <cake-name>
setzoneconfig:
description: War> Use named parameters to change the configuration of the warzone. Resets blocks like /nextbattle. Does not save zone blocks like /savezone.
usage: Use named parameters to change the configuration of the warzone. Resets blocks like /nextbattle. Does not save zone blocks like /savezone. Provide a zone name if not standing in warzone or lobby.