diff --git a/war/src/main/java/bukkit/tommytony/war/command/SetmonumentCommand.java b/war/src/main/java/bukkit/tommytony/war/command/SetmonumentCommand.java new file mode 100644 index 0000000..8daa162 --- /dev/null +++ b/war/src/main/java/bukkit/tommytony/war/command/SetmonumentCommand.java @@ -0,0 +1,55 @@ +package bukkit.tommytony.war.command; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.tommytony.war.Monument; +import com.tommytony.war.Warzone; +import com.tommytony.war.mappers.WarzoneMapper; + +import bukkit.tommytony.war.WarCommandHandler; + +public class SetmonumentCommand extends AbstractZoneMakerCommand { + public SetmonumentCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NoZoneMakerException { + super(handler, sender, args); + } + + @Override + public boolean handle() { + if (!(this.sender instanceof Player)) return true; + + Player player = (Player) this.sender; + + if (this.args.length != 1) { + return false; + } + + Warzone zone = Warzone.getZoneByLocation(player); + + if (zone == null) { + return false; + } + if (this.args[0].equals(zone.getName())) { + return false; + } + + Warzone warzone = Warzone.getZoneByLocation(player); + if (warzone.hasMonument(this.args[0])) { + // move the existing monument + Monument monument = warzone.getMonument(this.args[0]); + monument.getVolume().resetBlocks(); + monument.setLocation(player.getLocation()); + this.msg("Monument " + monument.getName() + " was moved."); + } else { + // create a new monument + Monument monument = new Monument(this.args[0], warzone, player.getLocation()); + warzone.getMonuments().add(monument); + this.msg("Monument " + monument.getName() + " created."); + } + WarzoneMapper.save(warzone, false); + + WarzoneMapper.save(zone, false); + + return true; + } +} diff --git a/war/src/main/java/bukkit/tommytony/war/command/SetteamCommand.java b/war/src/main/java/bukkit/tommytony/war/command/SetteamCommand.java new file mode 100644 index 0000000..2c39ccc --- /dev/null +++ b/war/src/main/java/bukkit/tommytony/war/command/SetteamCommand.java @@ -0,0 +1,59 @@ +package bukkit.tommytony.war.command; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.tommytony.war.Team; +import com.tommytony.war.TeamKind; +import com.tommytony.war.TeamKinds; +import com.tommytony.war.Warzone; +import com.tommytony.war.mappers.WarzoneMapper; + +import bukkit.tommytony.war.WarCommandHandler; + +public class SetteamCommand extends AbstractZoneMakerCommand { + public SetteamCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NoZoneMakerException { + super(handler, sender, args); + } + + @Override + public boolean handle() { + if (!(this.sender instanceof Player)) return true; + + Player player = (Player) this.sender; + + if (this.args.length != 1) { + return false; + } + Warzone zone = Warzone.getZoneByLocation(player); + + if (zone == null) { + return false; + } + + TeamKind teamKind = TeamKinds.teamKindFromString(this.args[0]); + Team existingTeam = zone.getTeamByKind(teamKind); + if (existingTeam != null) { + // relocate + existingTeam.setTeamSpawn(player.getLocation()); + this.msg("Team " + existingTeam.getName() + " spawn relocated."); + } else { + // new team (use default TeamKind name for now) + Team newTeam = new Team(teamKind.getDefaultName(), teamKind, player.getLocation(), zone); + newTeam.setRemainingLives(zone.getLifePool()); + zone.getTeams().add(newTeam); + if (zone.getLobby() != null) { + zone.getLobby().getVolume().resetBlocks(); + // warzone.getVolume().resetWallBlocks(warzone.getLobby().getWall()); + // warzone.addZoneOutline(warzone.getLobby().getWall()); + zone.getLobby().initialize(); + } + newTeam.setTeamSpawn(player.getLocation()); + this.msg("Team " + newTeam.getName() + " created with spawn here."); + } + + WarzoneMapper.save(zone, false); + + return true; + } +} diff --git a/war/src/main/java/bukkit/tommytony/war/command/SetteamflagCommand.java b/war/src/main/java/bukkit/tommytony/war/command/SetteamflagCommand.java new file mode 100644 index 0000000..018a9ef --- /dev/null +++ b/war/src/main/java/bukkit/tommytony/war/command/SetteamflagCommand.java @@ -0,0 +1,59 @@ +package bukkit.tommytony.war.command; + +import org.bukkit.Location; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.tommytony.war.Team; +import com.tommytony.war.TeamKind; +import com.tommytony.war.TeamKinds; +import com.tommytony.war.Warzone; +import com.tommytony.war.mappers.WarzoneMapper; + +import bukkit.tommytony.war.WarCommandHandler; + +public class SetteamflagCommand extends AbstractZoneMakerCommand { + public SetteamflagCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NoZoneMakerException { + super(handler, sender, args); + } + + @Override + public boolean handle() { + if (!(this.sender instanceof Player)) return true; + + Player player = (Player) this.sender; + + if (this.args.length != 1) { + return false; + } + Warzone zone = Warzone.getZoneByLocation(player); + + if (zone == null) { + return false; + } + + TeamKind kind = TeamKinds.teamKindFromString(this.args[0]); + Team team = zone.getTeamByKind(kind); + if (team == null) { + // no such team yet + this.msg("Place the team spawn first."); + } else if (team.getFlagVolume() == null) { + // new team flag + team.setTeamFlag(player.getLocation()); + Location playerLoc = player.getLocation(); + player.teleport(new Location(playerLoc.getWorld(), playerLoc.getBlockX() + 1, playerLoc.getBlockY(), playerLoc.getBlockZ())); + this.msg("Team " + team.getName() + " flag added here."); + WarzoneMapper.save(zone, false); + } else { + // relocate flag + team.getFlagVolume().resetBlocks(); + team.setTeamFlag(player.getLocation()); + Location playerLoc = player.getLocation(); + player.teleport(new Location(playerLoc.getWorld(), playerLoc.getBlockX() + 1, playerLoc.getBlockY(), playerLoc.getBlockZ() + 1)); + this.msg("Team " + team.getName() + " flag moved."); + WarzoneMapper.save(zone, false); + } + + return true; + } +}