mirror of
https://github.com/taoneill/war.git
synced 2024-11-24 03:05:54 +01:00
Added Setteam, setteamflag and setmonument command
This commit is contained in:
parent
15c3fadbb3
commit
65aff76af1
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user