mirror of
https://github.com/taoneill/war.git
synced 2024-11-23 18:55:28 +01:00
General cleanup (Removed unneeded code)
This commit is contained in:
parent
15d4497c5e
commit
6c0212d405
@ -26,29 +26,18 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import com.nijiko.permissions.PermissionHandler;
|
import com.nijiko.permissions.PermissionHandler;
|
||||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||||
import com.tommytony.war.Monument;
|
import com.tommytony.war.*;
|
||||||
import com.tommytony.war.Team;
|
import com.tommytony.war.mappers.*;
|
||||||
import com.tommytony.war.TeamKind;
|
import com.tommytony.war.utils.*;
|
||||||
import com.tommytony.war.TeamKinds;
|
|
||||||
import com.tommytony.war.TeamSpawnStyles;
|
|
||||||
import com.tommytony.war.WarHub;
|
|
||||||
import com.tommytony.war.Warzone;
|
|
||||||
import com.tommytony.war.ZoneLobby;
|
|
||||||
import com.tommytony.war.ZoneSetter;
|
|
||||||
import com.tommytony.war.mappers.VolumeMapper;
|
|
||||||
import com.tommytony.war.mappers.WarMapper;
|
|
||||||
import com.tommytony.war.mappers.WarzoneMapper;
|
|
||||||
import com.tommytony.war.utils.ChatFixUtil;
|
|
||||||
import com.tommytony.war.utils.InventoryStash;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tommytony
|
* @author tommytony
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class War extends JavaPlugin {
|
public class War extends JavaPlugin {
|
||||||
public static PermissionHandler permissionHandler;
|
public static PermissionHandler permissionHandler;
|
||||||
|
|
||||||
public War(){
|
public War(){
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@ -59,7 +48,7 @@ public class War extends JavaPlugin {
|
|||||||
private Logger log;
|
private Logger log;
|
||||||
private PluginDescriptionFile desc = null;
|
private PluginDescriptionFile desc = null;
|
||||||
private boolean loaded = false;
|
private boolean loaded = false;
|
||||||
|
|
||||||
private List<Warzone> warzones;
|
private List<Warzone> warzones;
|
||||||
private final List<Warzone> incompleteZones = new ArrayList<Warzone>();
|
private final List<Warzone> incompleteZones = new ArrayList<Warzone>();
|
||||||
private final List<String> zoneMakerNames = new ArrayList<String>();
|
private final List<String> zoneMakerNames = new ArrayList<String>();
|
||||||
@ -80,28 +69,28 @@ public class War extends JavaPlugin {
|
|||||||
private final HashMap<Integer, ItemStack> defaultReward = new HashMap<Integer, ItemStack>();
|
private final HashMap<Integer, ItemStack> defaultReward = new HashMap<Integer, ItemStack>();
|
||||||
private boolean defaultUnbreakableZoneBlocks = false;
|
private boolean defaultUnbreakableZoneBlocks = false;
|
||||||
private boolean defaultNoCreatures = false;
|
private boolean defaultNoCreatures = false;
|
||||||
|
|
||||||
private boolean pvpInZonesOnly = false;
|
private boolean pvpInZonesOnly = false;
|
||||||
private boolean buildInZonesOnly = false;
|
private boolean buildInZonesOnly = false;
|
||||||
|
|
||||||
private WarHub warHub;
|
private WarHub warHub;
|
||||||
|
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
unloadWar();
|
unloadWar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unloadWar() {
|
public void unloadWar() {
|
||||||
setLoaded(false);
|
setLoaded(false);
|
||||||
for(Warzone warzone : warzones) {
|
for(Warzone warzone : warzones) {
|
||||||
warzone.unload();
|
warzone.unload();
|
||||||
}
|
}
|
||||||
warzones.clear();
|
warzones.clear();
|
||||||
|
|
||||||
if(warHub != null) {
|
if(warHub != null) {
|
||||||
warHub.getVolume().resetBlocks();
|
warHub.getVolume().resetBlocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread thread = new Thread(new Runnable()
|
Thread thread = new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
@ -125,24 +114,24 @@ public class War extends JavaPlugin {
|
|||||||
});
|
});
|
||||||
thread.setPriority(Thread.MIN_PRIORITY);
|
thread.setPriority(Thread.MIN_PRIORITY);
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
this.logInfo("Done. War v" + desc.getVersion() + " is off.");
|
this.logInfo("Done. War v" + desc.getVersion() + " is off.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.loadWar();
|
this.loadWar();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadWar() {
|
public void loadWar() {
|
||||||
setLoaded(true);
|
setLoaded(true);
|
||||||
warzones = new ArrayList<Warzone>();
|
warzones = new ArrayList<Warzone>();
|
||||||
desc = this.getDescription();
|
desc = this.getDescription();
|
||||||
this.log = this.getServer().getLogger();
|
this.log = this.getServer().getLogger();
|
||||||
this.setupPermissions();
|
this.setupPermissions();
|
||||||
|
|
||||||
// Register hooks
|
// Register hooks
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_KICK, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_KICK, playerListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
||||||
@ -151,19 +140,19 @@ public class War extends JavaPlugin {
|
|||||||
pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this);
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal, this);
|
||||||
//pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Normal, this);
|
//pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_REGAIN_HEALTH, entityListener, Priority.Normal, this);
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Priority.Normal, this);
|
||||||
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.Normal, this);
|
||||||
|
|
||||||
//pm.registerEvent(Event.Type.CHUNK_UNLOADED, blockListener, Priority.Normal, this);
|
//pm.registerEvent(Event.Type.CHUNK_UNLOADED, blockListener, Priority.Normal, this);
|
||||||
|
|
||||||
// Load files from disk or create them (using these defaults)
|
// Load files from disk or create them (using these defaults)
|
||||||
this.defaultLoadout.put(0, new ItemStack(Material.STONE_SWORD, 1, (byte) 8));
|
this.defaultLoadout.put(0, new ItemStack(Material.STONE_SWORD, 1, (byte) 8));
|
||||||
this.defaultLoadout.put(1, new ItemStack(Material.BOW, 1, (byte) 8));
|
this.defaultLoadout.put(1, new ItemStack(Material.BOW, 1, (byte) 8));
|
||||||
@ -200,7 +189,7 @@ public class War extends JavaPlugin {
|
|||||||
} else {
|
} else {
|
||||||
arguments = args;
|
arguments = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Player commands: /warzones, /warzone, /teams, /join, /leave
|
// Player commands: /warzones, /warzone, /teams, /join, /leave
|
||||||
if(command.equals("zones") || command.equals("warzones")){
|
if(command.equals("zones") || command.equals("warzones")){
|
||||||
performZones(player);
|
performZones(player);
|
||||||
@ -216,11 +205,11 @@ public class War extends JavaPlugin {
|
|||||||
performTeam(player, arguments);
|
performTeam(player, arguments);
|
||||||
} else if(command.equals("warhub")) {
|
} else if(command.equals("warhub")) {
|
||||||
performWarhub(player);
|
performWarhub(player);
|
||||||
} else if(this.isZoneMaker(player)) {
|
} else if(this.isZoneMaker(player)) {
|
||||||
// Mod commands : /nextbattle
|
// Mod commands : /nextbattle
|
||||||
if(command.equals("nextbattle")) {
|
if(command.equals("nextbattle")) {
|
||||||
performNextBattle(player);
|
performNextBattle(player);
|
||||||
}
|
}
|
||||||
// Warzone maker commands: /setzone, /savezone, /setteam, /setmonument, /resetzone
|
// Warzone maker commands: /setzone, /savezone, /setteam, /setmonument, /resetzone
|
||||||
else if(command.equals("setzone")) {
|
else if(command.equals("setzone")) {
|
||||||
performSetZone(player, arguments);
|
performSetZone(player, arguments);
|
||||||
@ -290,7 +279,7 @@ public class War extends JavaPlugin {
|
|||||||
loadout.put(i, stack);
|
loadout.put(i, stack);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(inv.getBoots() != null && inv.getBoots().getType() != Material.AIR) {
|
if(inv.getBoots() != null && inv.getBoots().getType() != Material.AIR) {
|
||||||
loadout.put(100, inv.getBoots());
|
loadout.put(100, inv.getBoots());
|
||||||
@ -349,7 +338,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
msg(player, "You are now impersonating a regular player. Type /zonemaker again to toggle back to war maker mode.");
|
msg(player, "You are now impersonating a regular player. Type /zonemaker again to toggle back to war maker mode.");
|
||||||
}
|
}
|
||||||
|
|
||||||
WarMapper.save(this);
|
WarMapper.save(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -380,7 +369,7 @@ public class War extends JavaPlugin {
|
|||||||
zone.getLobby().initialize();
|
zone.getLobby().initialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.msg(player, "War hub removed.");
|
this.msg(player, "War hub removed.");
|
||||||
} else {
|
} else {
|
||||||
this.badMsg(player, "No War hub to delete.");
|
this.badMsg(player, "No War hub to delete.");
|
||||||
@ -414,7 +403,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void performDeleteMonument(Player player, String[] arguments) {
|
public void performDeleteMonument(Player player, String[] arguments) {
|
||||||
if(arguments.length < 1 || (!this.inAnyWarzone(player.getLocation())
|
if(arguments.length < 1 || (!this.inAnyWarzone(player.getLocation())
|
||||||
&& !this.inAnyWarzoneLobby(player.getLocation()))) {
|
&& !this.inAnyWarzoneLobby(player.getLocation()))) {
|
||||||
this.badMsg(player, "Usage: /deletemonument <name>." +
|
this.badMsg(player, "Usage: /deletemonument <name>." +
|
||||||
" Deletes the monument. " +
|
" Deletes the monument. " +
|
||||||
@ -441,7 +430,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void performSetMonument(Player player, String[] arguments) {
|
public void performSetMonument(Player player, String[] arguments) {
|
||||||
if(!this.inAnyWarzone(player.getLocation()) || arguments.length < 1 || arguments.length > 1
|
if(!this.inAnyWarzone(player.getLocation()) || arguments.length < 1 || arguments.length > 1
|
||||||
|| (arguments.length == 1 && this.warzone(player.getLocation()) != null
|
|| (arguments.length == 1 && this.warzone(player.getLocation()) != null
|
||||||
&& arguments[0].equals(this.warzone(player.getLocation()).getName()))) {
|
&& arguments[0].equals(this.warzone(player.getLocation()).getName()))) {
|
||||||
this.badMsg(player, "Usage: /setmonument <name>. Creates or moves a monument. Monument can't have same name as zone. Must be in warzone.");
|
this.badMsg(player, "Usage: /setmonument <name>. Creates or moves a monument. Monument can't have same name as zone. Must be in warzone.");
|
||||||
@ -465,7 +454,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void performDeleteTeam(Player player, String[] arguments) {
|
public void performDeleteTeam(Player player, String[] arguments) {
|
||||||
if(arguments.length < 1 || (!this.inAnyWarzone(player.getLocation())
|
if(arguments.length < 1 || (!this.inAnyWarzone(player.getLocation())
|
||||||
&& !this.inAnyWarzoneLobby(player.getLocation()))) {
|
&& !this.inAnyWarzoneLobby(player.getLocation()))) {
|
||||||
this.badMsg(player, "Usage: /deleteteam <team-name/color>." +
|
this.badMsg(player, "Usage: /deleteteam <team-name/color>." +
|
||||||
" Deletes the team and its spawn. " +
|
" Deletes the team and its spawn. " +
|
||||||
@ -482,7 +471,7 @@ public class War extends JavaPlugin {
|
|||||||
Team team = warzone.getTeamByKind(TeamKinds.teamKindFromString(name));
|
Team team = warzone.getTeamByKind(TeamKinds.teamKindFromString(name));
|
||||||
if(team != null) {
|
if(team != null) {
|
||||||
if(team.getFlagVolume() != null) team.getFlagVolume().resetBlocks();
|
if(team.getFlagVolume() != null) team.getFlagVolume().resetBlocks();
|
||||||
team.getSpawnVolume().resetBlocks();
|
team.getSpawnVolume().resetBlocks();
|
||||||
warzone.getTeams().remove(team);
|
warzone.getTeams().remove(team);
|
||||||
if(warzone.getLobby() != null) {
|
if(warzone.getLobby() != null) {
|
||||||
warzone.getLobby().getVolume().resetBlocks();
|
warzone.getLobby().getVolume().resetBlocks();
|
||||||
@ -499,23 +488,23 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void performSetTeamFlag(Player player, String[] arguments) {
|
public void performSetTeamFlag(Player player, String[] arguments) {
|
||||||
if(arguments.length < 1 || !this.inAnyWarzone(player.getLocation())
|
if(arguments.length < 1 || !this.inAnyWarzone(player.getLocation())
|
||||||
|| (arguments.length > 0 && TeamKinds.teamKindFromString(arguments[0]) == null)) {
|
|| (arguments.length > 0 && TeamKinds.teamKindFromString(arguments[0]) == null)) {
|
||||||
this.badMsg(player, "Usage: /setteamflag <team-name/color>, e.g. /setteamflag diamond. " +
|
this.badMsg(player, "Usage: /setteamflag <team-name/color>, e.g. /setteamflag diamond. " +
|
||||||
"Sets the team flag post to the current location. " +
|
"Sets the team flag post to the current location. " +
|
||||||
"Must be in a warzone (try /zones and /zone). ");
|
"Must be in a warzone (try /zones and /zone). ");
|
||||||
} else {
|
} else {
|
||||||
TeamKind kind = TeamKinds.teamKindFromString(arguments[0]);
|
TeamKind kind = TeamKinds.teamKindFromString(arguments[0]);
|
||||||
Warzone warzone = this.warzone(player.getLocation());
|
Warzone warzone = this.warzone(player.getLocation());
|
||||||
Team team = warzone.getTeamByKind(kind);
|
Team team = warzone.getTeamByKind(kind);
|
||||||
if(team == null) {
|
if(team == null) {
|
||||||
// no such team yet
|
// no such team yet
|
||||||
this.badMsg(player, "Place the team spawn first.");
|
this.badMsg(player, "Place the team spawn first.");
|
||||||
} else if (team.getFlagVolume() == null){
|
} else if (team.getFlagVolume() == null){
|
||||||
// new team flag
|
// new team flag
|
||||||
team.setTeamFlag(player.getLocation());
|
team.setTeamFlag(player.getLocation());
|
||||||
Location playerLoc = player.getLocation();
|
Location playerLoc = player.getLocation();
|
||||||
player.teleport(new Location(playerLoc.getWorld(),
|
player.teleport(new Location(playerLoc.getWorld(),
|
||||||
playerLoc.getBlockX()+1, playerLoc.getBlockY(), playerLoc.getBlockZ()));
|
playerLoc.getBlockX()+1, playerLoc.getBlockY(), playerLoc.getBlockZ()));
|
||||||
this.msg(player, "Team " + team.getName() + " flag added here.");
|
this.msg(player, "Team " + team.getName() + " flag added here.");
|
||||||
WarzoneMapper.save(this, warzone, false);
|
WarzoneMapper.save(this, warzone, false);
|
||||||
@ -524,7 +513,7 @@ public class War extends JavaPlugin {
|
|||||||
team.getFlagVolume().resetBlocks();
|
team.getFlagVolume().resetBlocks();
|
||||||
team.setTeamFlag(player.getLocation());
|
team.setTeamFlag(player.getLocation());
|
||||||
Location playerLoc = player.getLocation();
|
Location playerLoc = player.getLocation();
|
||||||
player.teleport(new Location(playerLoc.getWorld(),
|
player.teleport(new Location(playerLoc.getWorld(),
|
||||||
playerLoc.getBlockX()+1, playerLoc.getBlockY(), playerLoc.getBlockZ()+1));
|
playerLoc.getBlockX()+1, playerLoc.getBlockY(), playerLoc.getBlockZ()+1));
|
||||||
this.msg(player, "Team " + team.getName() + " flag moved.");
|
this.msg(player, "Team " + team.getName() + " flag moved.");
|
||||||
WarzoneMapper.save(this, warzone, false);
|
WarzoneMapper.save(this, warzone, false);
|
||||||
@ -533,13 +522,13 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void performSetTeam(Player player, String[] arguments) {
|
public void performSetTeam(Player player, String[] arguments) {
|
||||||
if(arguments.length < 1 || !this.inAnyWarzone(player.getLocation())
|
if(arguments.length < 1 || !this.inAnyWarzone(player.getLocation())
|
||||||
|| (arguments.length > 0 && TeamKinds.teamKindFromString(arguments[0]) == null)) {
|
|| (arguments.length > 0 && TeamKinds.teamKindFromString(arguments[0]) == null)) {
|
||||||
this.badMsg(player, "Usage: /setteam <team-kind/color>, e.g. /setteam red." +
|
this.badMsg(player, "Usage: /setteam <team-kind/color>, e.g. /setteam red." +
|
||||||
"Sets the team spawn to the current location. " +
|
"Sets the team spawn to the current location. " +
|
||||||
"Must be in a warzone (try /zones and /zone). ");
|
"Must be in a warzone (try /zones and /zone). ");
|
||||||
} else {
|
} else {
|
||||||
TeamKind teamKind = TeamKinds.teamKindFromString(arguments[0]);
|
TeamKind teamKind = TeamKinds.teamKindFromString(arguments[0]);
|
||||||
Warzone warzone = this.warzone(player.getLocation());
|
Warzone warzone = this.warzone(player.getLocation());
|
||||||
Team existingTeam = warzone.getTeamByKind(teamKind);
|
Team existingTeam = warzone.getTeamByKind(teamKind);
|
||||||
if(existingTeam != null) {
|
if(existingTeam != null) {
|
||||||
@ -560,7 +549,7 @@ public class War extends JavaPlugin {
|
|||||||
newTeam.setTeamSpawn(player.getLocation());
|
newTeam.setTeamSpawn(player.getLocation());
|
||||||
this.msg(player, "Team " + newTeam.getName() + " created with spawn here.");
|
this.msg(player, "Team " + newTeam.getName() + " created with spawn here.");
|
||||||
}
|
}
|
||||||
|
|
||||||
WarzoneMapper.save(this, warzone, false);
|
WarzoneMapper.save(this, warzone, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -637,7 +626,7 @@ public class War extends JavaPlugin {
|
|||||||
team.resetPoints();
|
team.resetPoints();
|
||||||
team.getPlayers().clear();
|
team.getPlayers().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Warzone resetWarzone = null;
|
Warzone resetWarzone = null;
|
||||||
this.msg(player, "Reloading warzone " + warzone.getName() + ".");
|
this.msg(player, "Reloading warzone " + warzone.getName() + ".");
|
||||||
if(arguments.length == 1 && (arguments[0].equals("hard") || arguments[0].equals("h"))) {
|
if(arguments.length == 1 && (arguments[0].equals("hard") || arguments[0].equals("h"))) {
|
||||||
@ -656,7 +645,7 @@ public class War extends JavaPlugin {
|
|||||||
lobby.getVolume().resetBlocksAsJob();
|
lobby.getVolume().resetBlocksAsJob();
|
||||||
}
|
}
|
||||||
warzone.initializeZoneAsJob();
|
warzone.initializeZoneAsJob();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -683,7 +672,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
warzone.initializeZone(); // bring back team spawns etc
|
warzone.initializeZone(); // bring back team spawns etc
|
||||||
this.msg(player, "Warzone config saved. Zone reset.");
|
this.msg(player, "Warzone config saved. Zone reset.");
|
||||||
|
|
||||||
if(warHub != null) { // maybe the zone was disabled/enabled
|
if(warHub != null) { // maybe the zone was disabled/enabled
|
||||||
warHub.getVolume().resetBlocks();
|
warHub.getVolume().resetBlocks();
|
||||||
warHub.initialize();
|
warHub.initialize();
|
||||||
@ -717,13 +706,13 @@ public class War extends JavaPlugin {
|
|||||||
lobby.getVolume().resetBlocks();
|
lobby.getVolume().resetBlocks();
|
||||||
}
|
}
|
||||||
warzone.initializeZone(); // bring back team spawns etc
|
warzone.initializeZone(); // bring back team spawns etc
|
||||||
|
|
||||||
if(warHub != null) { // maybe the zone was disabled/enabled
|
if(warHub != null) { // maybe the zone was disabled/enabled
|
||||||
warHub.getVolume().resetBlocks();
|
warHub.getVolume().resetBlocks();
|
||||||
warHub.initialize();
|
warHub.initialize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.msg(player, "Warzone " + warzone.getName() + " initial state changed. Saved " + savedBlocks + " blocks.");
|
this.msg(player, "Warzone " + warzone.getName() + " initial state changed. Saved " + savedBlocks + " blocks.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -735,14 +724,14 @@ public class War extends JavaPlugin {
|
|||||||
if(arguments.length < 1 || arguments.length > 1) {
|
if(arguments.length < 1 || arguments.length > 1) {
|
||||||
this.badMsg(player, usageStr);
|
this.badMsg(player, usageStr);
|
||||||
} else if (this.inAnyWarzone(player.getLocation()) || this.inAnyWarzoneLobby(player.getLocation())){
|
} else if (this.inAnyWarzone(player.getLocation()) || this.inAnyWarzoneLobby(player.getLocation())){
|
||||||
// Inside a warzone: use the classic n/s/e/w mode
|
// Inside a warzone: use the classic n/s/e/w mode
|
||||||
if(!arguments[0].equals("north") && !arguments[0].equals("n")
|
if(!arguments[0].equals("north") && !arguments[0].equals("n")
|
||||||
&& !arguments[0].equals("east") && !arguments[0].equals("e")
|
&& !arguments[0].equals("east") && !arguments[0].equals("e")
|
||||||
&& !arguments[0].equals("south") && !arguments[0].equals("s")
|
&& !arguments[0].equals("south") && !arguments[0].equals("s")
|
||||||
&& !arguments[0].equals("west") && !arguments[0].equals("w")){
|
&& !arguments[0].equals("west") && !arguments[0].equals("w")){
|
||||||
this.badMsg(player, usageStr);
|
this.badMsg(player, usageStr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Warzone warzone = this.warzone(player.getLocation());
|
Warzone warzone = this.warzone(player.getLocation());
|
||||||
ZoneLobby lobby = this.lobby(player.getLocation());
|
ZoneLobby lobby = this.lobby(player.getLocation());
|
||||||
if(warzone == null && lobby != null) {
|
if(warzone == null && lobby != null) {
|
||||||
@ -764,7 +753,7 @@ public class War extends JavaPlugin {
|
|||||||
} else if(arguments[0].equals("west") || arguments[0].equals("w")) {
|
} else if(arguments[0].equals("west") || arguments[0].equals("w")) {
|
||||||
wall = BlockFace.WEST;
|
wall = BlockFace.WEST;
|
||||||
wallStr = "west";
|
wallStr = "west";
|
||||||
}
|
}
|
||||||
if(lobby != null) {
|
if(lobby != null) {
|
||||||
// reset existing lobby
|
// reset existing lobby
|
||||||
lobby.getVolume().resetBlocks();
|
lobby.getVolume().resetBlocks();
|
||||||
@ -809,12 +798,12 @@ public class War extends JavaPlugin {
|
|||||||
this.msg(player, "Warzone lobby moved to your location.");
|
this.msg(player, "Warzone lobby moved to your location.");
|
||||||
}
|
}
|
||||||
WarzoneMapper.save(this, warzone, false);
|
WarzoneMapper.save(this, warzone, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void performSetZone(Player player, String[] arguments) {
|
public void performSetZone(Player player, String[] arguments) {
|
||||||
if(arguments.length < 2 || arguments.length > 2
|
if(arguments.length < 2 || arguments.length > 2
|
||||||
|| (arguments.length == 2 && (!arguments[1].equals("southeast") && !arguments[1].equals("northwest")
|
|| (arguments.length == 2 && (!arguments[1].equals("southeast") && !arguments[1].equals("northwest")
|
||||||
&& !arguments[1].equals("se") && !arguments[1].equals("nw")
|
&& !arguments[1].equals("se") && !arguments[1].equals("nw")
|
||||||
&& !arguments[1].equals("corner1") && !arguments[1].equals("corner2")
|
&& !arguments[1].equals("corner1") && !arguments[1].equals("corner2")
|
||||||
@ -829,7 +818,7 @@ public class War extends JavaPlugin {
|
|||||||
"=<Wand Cuboid mode>= /setzone <warzone-name> wand (gives you a wooden sword to right and left click, drop to disable). " +
|
"=<Wand Cuboid mode>= /setzone <warzone-name> wand (gives you a wooden sword to right and left click, drop to disable). " +
|
||||||
"=<Wandless Cuboid mode>= /setzone <warzone-name> <'corner1'/'corner2'/'c1'/'c2'/'pos1'/'pos2'> (block where you're standing). " +
|
"=<Wandless Cuboid mode>= /setzone <warzone-name> <'corner1'/'corner2'/'c1'/'c2'/'pos1'/'pos2'> (block where you're standing). " +
|
||||||
"Set one corner, then the next. Defines the outline of the warzone, which will be reset at the start of every battle. " +
|
"Set one corner, then the next. Defines the outline of the warzone, which will be reset at the start of every battle. " +
|
||||||
"Saves the zone blocks if the outline is valid.");
|
"Saves the zone blocks if the outline is valid.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ZoneSetter setter = new ZoneSetter(this, player, arguments[0]);
|
ZoneSetter setter = new ZoneSetter(this, player, arguments[0]);
|
||||||
@ -909,14 +898,14 @@ public class War extends JavaPlugin {
|
|||||||
" Teams are warzone specific." +
|
" Teams are warzone specific." +
|
||||||
" You must be inside a warzone or zone lobby to join a team." +
|
" You must be inside a warzone or zone lobby to join a team." +
|
||||||
" Use as an alternative to walking through the team gate.");
|
" Use as an alternative to walking through the team gate.");
|
||||||
} else {
|
} else {
|
||||||
// drop from old team if any
|
// drop from old team if any
|
||||||
Team previousTeam = this.getPlayerTeam(player.getName());
|
Team previousTeam = this.getPlayerTeam(player.getName());
|
||||||
if(previousTeam != null) {
|
if(previousTeam != null) {
|
||||||
Warzone zone = this.getPlayerTeamWarzone(player.getName());
|
Warzone zone = this.getPlayerTeamWarzone(player.getName());
|
||||||
if(!previousTeam.removePlayer(player.getName())){
|
if(!previousTeam.removePlayer(player.getName())){
|
||||||
logWarn("Could not remove player " + player.getName() + " from team " + previousTeam.getName());
|
logWarn("Could not remove player " + player.getName() + " from team " + previousTeam.getName());
|
||||||
}
|
}
|
||||||
if(zone.isFlagThief(player.getName())) {
|
if(zone.isFlagThief(player.getName())) {
|
||||||
Team victim = zone.getVictimTeamForThief(player.getName());
|
Team victim = zone.getVictimTeamForThief(player.getName());
|
||||||
victim.getFlagVolume().resetBlocks();
|
victim.getFlagVolume().resetBlocks();
|
||||||
@ -928,7 +917,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
previousTeam.resetSign();
|
previousTeam.resetSign();
|
||||||
}
|
}
|
||||||
|
|
||||||
// join new team
|
// join new team
|
||||||
String name = arguments[0];
|
String name = arguments[0];
|
||||||
TeamKind kind = TeamKinds.teamKindFromString(arguments[0]);
|
TeamKind kind = TeamKinds.teamKindFromString(arguments[0]);
|
||||||
@ -997,7 +986,7 @@ public class War extends JavaPlugin {
|
|||||||
if(playerTeam != null) {
|
if(playerTeam != null) {
|
||||||
Warzone playerWarzone = getPlayerTeamWarzone(player.getName());
|
Warzone playerWarzone = getPlayerTeamWarzone(player.getName());
|
||||||
playerWarzone.handlePlayerLeave(player, warzone.getTeleport(), true);
|
playerWarzone.handlePlayerLeave(player, warzone.getTeleport(), true);
|
||||||
} else {
|
} else {
|
||||||
player.teleport(warzone.getTeleport());
|
player.teleport(warzone.getTeleport());
|
||||||
}
|
}
|
||||||
warped = true;
|
warped = true;
|
||||||
@ -1016,7 +1005,7 @@ public class War extends JavaPlugin {
|
|||||||
warzonesMessage += "none.";
|
warzonesMessage += "none.";
|
||||||
}
|
}
|
||||||
for(Warzone warzone : this.getWarzones()) {
|
for(Warzone warzone : this.getWarzones()) {
|
||||||
|
|
||||||
warzonesMessage += warzone.getName() + " ("
|
warzonesMessage += warzone.getName() + " ("
|
||||||
+ warzone.getTeams().size() + " teams, ";
|
+ warzone.getTeams().size() + " teams, ";
|
||||||
int playerTotal = 0;
|
int playerTotal = 0;
|
||||||
@ -1107,7 +1096,7 @@ public class War extends JavaPlugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean updateFromNamedParams(Player player, String[] arguments) {
|
private boolean updateFromNamedParams(Player player, String[] arguments) {
|
||||||
try {
|
try {
|
||||||
Map<String,String> namedParams = new HashMap<String,String>();
|
Map<String,String> namedParams = new HashMap<String,String>();
|
||||||
@ -1119,7 +1108,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
if(namedParams.containsKey("lifepool")){
|
if(namedParams.containsKey("lifepool")){
|
||||||
setDefaultLifepool(Integer.parseInt(namedParams.get("lifepool")));
|
setDefaultLifepool(Integer.parseInt(namedParams.get("lifepool")));
|
||||||
}
|
}
|
||||||
if(namedParams.containsKey("monumentheal")){
|
if(namedParams.containsKey("monumentheal")){
|
||||||
setDefaultMonumentHeal(Integer.parseInt(namedParams.get("monumentheal")));
|
setDefaultMonumentHeal(Integer.parseInt(namedParams.get("monumentheal")));
|
||||||
}
|
}
|
||||||
@ -1132,19 +1121,19 @@ public class War extends JavaPlugin {
|
|||||||
if(namedParams.containsKey("ff")){
|
if(namedParams.containsKey("ff")){
|
||||||
String onOff = namedParams.get("ff");
|
String onOff = namedParams.get("ff");
|
||||||
setDefaultFriendlyFire(onOff.equals("on"));
|
setDefaultFriendlyFire(onOff.equals("on"));
|
||||||
}
|
}
|
||||||
if(namedParams.containsKey("autoassign")){
|
if(namedParams.containsKey("autoassign")){
|
||||||
String onOff = namedParams.get("autoassign");
|
String onOff = namedParams.get("autoassign");
|
||||||
setDefaultAutoAssignOnly(onOff.equals("on") || onOff.equals("true"));
|
setDefaultAutoAssignOnly(onOff.equals("on") || onOff.equals("true"));
|
||||||
}
|
}
|
||||||
if(namedParams.containsKey("outline")){
|
if(namedParams.containsKey("outline")){
|
||||||
String onOff = namedParams.get("outline");
|
String onOff = namedParams.get("outline");
|
||||||
setDefaultDrawZoneOutline(onOff.equals("on") || onOff.equals("true"));
|
setDefaultDrawZoneOutline(onOff.equals("on") || onOff.equals("true"));
|
||||||
}
|
}
|
||||||
if(namedParams.containsKey("pvpinzonesonly")){
|
if(namedParams.containsKey("pvpinzonesonly")){
|
||||||
String onOff = namedParams.get("pvpinzonesonly");
|
String onOff = namedParams.get("pvpinzonesonly");
|
||||||
setPvpInZonesOnly(onOff.equals("on") || onOff.equals("true"));
|
setPvpInZonesOnly(onOff.equals("on") || onOff.equals("true"));
|
||||||
}
|
}
|
||||||
if(namedParams.containsKey("blockheads")){
|
if(namedParams.containsKey("blockheads")){
|
||||||
String onOff = namedParams.get("blockheads");
|
String onOff = namedParams.get("blockheads");
|
||||||
setDefaultBlockHeads(onOff.equals("on") || onOff.equals("true"));
|
setDefaultBlockHeads(onOff.equals("on") || onOff.equals("true"));
|
||||||
@ -1196,7 +1185,7 @@ public class War extends JavaPlugin {
|
|||||||
private void setZoneRallyPoint(String warzoneName, Player player) {
|
private void setZoneRallyPoint(String warzoneName, Player player) {
|
||||||
Warzone zone = findWarzone(warzoneName);
|
Warzone zone = findWarzone(warzoneName);
|
||||||
if(zone == null) {
|
if(zone == null) {
|
||||||
badMsg(player, "Can't set rally point. No such warzone.");
|
badMsg(player, "Can't set rally point. No such warzone.");
|
||||||
} else {
|
} else {
|
||||||
zone.setRallyPoint(player.getLocation());
|
zone.setRallyPoint(player.getLocation());
|
||||||
WarzoneMapper.save(this, zone, false);
|
WarzoneMapper.save(this, zone, false);
|
||||||
@ -1210,19 +1199,19 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Warzone getPlayerTeamWarzone(String playerName) {
|
public Warzone getPlayerTeamWarzone(String playerName) {
|
||||||
for(Warzone warzone : warzones) {
|
for(Warzone warzone : warzones) {
|
||||||
Team team = warzone.getPlayerTeam(playerName);
|
Team team = warzone.getPlayerTeam(playerName);
|
||||||
if(team != null) return warzone;
|
if(team != null) return warzone;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Logger getLogger() {
|
public Logger getLogger() {
|
||||||
return log;
|
return log;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Warzone warzone(Location location) {
|
public Warzone warzone(Location location) {
|
||||||
for(Warzone warzone : warzones) {
|
for(Warzone warzone : warzones) {
|
||||||
if(location.getWorld().getName().equals(warzone.getWorld().getName())
|
if(location.getWorld().getName().equals(warzone.getWorld().getName())
|
||||||
@ -1235,13 +1224,13 @@ public class War extends JavaPlugin {
|
|||||||
Block locBlock = location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
Block locBlock = location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
Warzone currentZone = warzone(location);
|
Warzone currentZone = warzone(location);
|
||||||
if(currentZone == null) {
|
if(currentZone == null) {
|
||||||
return false;
|
return false;
|
||||||
} else if (currentZone.getVolume().isWallBlock(locBlock)) {
|
} else if (currentZone.getVolume().isWallBlock(locBlock)) {
|
||||||
return false; // wall block doesnt count. this lets people in at the lobby side wall because wall gates overlap with the zone.
|
return false; // wall block doesnt count. this lets people in at the lobby side wall because wall gates overlap with the zone.
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inWarzone(String warzoneName, Location location) {
|
public boolean inWarzone(String warzoneName, Location location) {
|
||||||
Warzone currentZone = warzone(location);
|
Warzone currentZone = warzone(location);
|
||||||
if(currentZone == null) {
|
if(currentZone == null) {
|
||||||
@ -1259,32 +1248,32 @@ public class War extends JavaPlugin {
|
|||||||
public List<Warzone> getWarzones() {
|
public List<Warzone> getWarzones() {
|
||||||
return warzones;
|
return warzones;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void msg(Player player, String str) {
|
public void msg(Player player, String str) {
|
||||||
String out = ChatColor.GRAY + "War> " + ChatColor.WHITE + colorTeams(str, ChatColor.WHITE) + " ";
|
String out = ChatColor.GRAY + "War> " + ChatColor.WHITE + colorTeams(str, ChatColor.WHITE) + " ";
|
||||||
ChatFixUtil.sendMessage(player, out);
|
ChatFixUtil.sendMessage(player, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void badMsg(Player player, String str) {
|
public void badMsg(Player player, String str) {
|
||||||
String out = ChatColor.GRAY + "War> " + ChatColor.RED + colorTeams(str, ChatColor.RED) + " ";
|
String out = ChatColor.GRAY + "War> " + ChatColor.RED + colorTeams(str, ChatColor.RED) + " ";
|
||||||
ChatFixUtil.sendMessage(player, out);
|
ChatFixUtil.sendMessage(player, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String colorTeams(String str, ChatColor msgColor) {
|
private String colorTeams(String str, ChatColor msgColor) {
|
||||||
for(TeamKind kind : TeamKinds.getTeamkinds()) {
|
for(TeamKind kind : TeamKinds.getTeamkinds()) {
|
||||||
str = str.replaceAll(" " + kind.getDefaultName(), " " + kind.getColor() + kind.getDefaultName() + msgColor);
|
str = str.replaceAll(" " + kind.getDefaultName(), " " + kind.getColor() + kind.getDefaultName() + msgColor);
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logInfo(String str) {
|
public void logInfo(String str) {
|
||||||
this.getLogger().log(Level.INFO, "War> " + str);
|
this.getLogger().log(Level.INFO, "War> " + str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logWarn(String str) {
|
public void logWarn(String str) {
|
||||||
this.getLogger().log(Level.WARNING, "War> " + str);
|
this.getLogger().log(Level.WARNING, "War> " + str);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the only way to find a zone that has only one corner
|
// the only way to find a zone that has only one corner
|
||||||
public Warzone findWarzone(String warzoneName) {
|
public Warzone findWarzone(String warzoneName) {
|
||||||
for(Warzone warzone : warzones) {
|
for(Warzone warzone : warzones) {
|
||||||
@ -1292,14 +1281,14 @@ public class War extends JavaPlugin {
|
|||||||
return warzone;
|
return warzone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(Warzone warzone : incompleteZones) {
|
for(Warzone warzone : incompleteZones) {
|
||||||
if(warzone.getName().equals(warzoneName)) {
|
if(warzone.getName().equals(warzoneName)) {
|
||||||
return warzone;
|
return warzone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Warzone matchWarzone(String warzoneSubString) {
|
public Warzone matchWarzone(String warzoneSubString) {
|
||||||
for(Warzone warzone : warzones) {
|
for(Warzone warzone : warzones) {
|
||||||
if(warzone.getName().toLowerCase().startsWith(warzoneSubString.toLowerCase())) {
|
if(warzone.getName().toLowerCase().startsWith(warzoneSubString.toLowerCase())) {
|
||||||
@ -1314,7 +1303,7 @@ public class War extends JavaPlugin {
|
|||||||
String alreadyHaveWand = wandBearers.get(player.getName());
|
String alreadyHaveWand = wandBearers.get(player.getName());
|
||||||
if(player.getInventory().first(Material.WOOD_SWORD) != -1) {
|
if(player.getInventory().first(Material.WOOD_SWORD) != -1) {
|
||||||
if(zoneName.equals(alreadyHaveWand)) {
|
if(zoneName.equals(alreadyHaveWand)) {
|
||||||
this.badMsg(player, "You already have a wand for zone " + alreadyHaveWand + ". Drop the wooden sword first.");
|
this.badMsg(player, "You already have a wand for zone " + alreadyHaveWand + ". Drop the wooden sword first.");
|
||||||
} else {
|
} else {
|
||||||
// new zone, already have sword
|
// new zone, already have sword
|
||||||
wandBearers.remove(player.getName());
|
wandBearers.remove(player.getName());
|
||||||
@ -1327,7 +1316,7 @@ public class War extends JavaPlugin {
|
|||||||
// same zone, give him a new sword
|
// same zone, give him a new sword
|
||||||
player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD, 1, (byte) 8));
|
player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD, 1, (byte) 8));
|
||||||
this.msg(player, "Here's a new sword for zone " + zoneName + ".");
|
this.msg(player, "Here's a new sword for zone " + zoneName + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(player.getInventory().firstEmpty() == -1) {
|
if(player.getInventory().firstEmpty() == -1) {
|
||||||
@ -1336,22 +1325,22 @@ public class War extends JavaPlugin {
|
|||||||
wandBearers.put(player.getName(), zoneName);
|
wandBearers.put(player.getName(), zoneName);
|
||||||
player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD, 1, (byte) 8));
|
player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD, 1, (byte) 8));
|
||||||
//player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.WOOD_SWORD));
|
//player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.WOOD_SWORD));
|
||||||
this.msg(player, "You now have a wand for zone " + zoneName + ". Left-click with wodden sword for corner 1. Right-click for corner 2.");
|
this.msg(player, "You now have a wand for zone " + zoneName + ". Left-click with wodden sword for corner 1. Right-click for corner 2.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWandBearer(Player player) {
|
public boolean isWandBearer(Player player) {
|
||||||
return wandBearers.containsKey(player.getName());
|
return wandBearers.containsKey(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWandBearerZone(Player player) {
|
public String getWandBearerZone(Player player) {
|
||||||
if(isWandBearer(player)) {
|
if(isWandBearer(player)) {
|
||||||
return wandBearers.get(player.getName());
|
return wandBearers.get(player.getName());
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeWandBearer(Player player) {
|
public void removeWandBearer(Player player) {
|
||||||
if(wandBearers.containsKey(player.getName())){
|
if(wandBearers.containsKey(player.getName())){
|
||||||
wandBearers.remove(player.getName());
|
wandBearers.remove(player.getName());
|
||||||
@ -1377,7 +1366,7 @@ public class War extends JavaPlugin {
|
|||||||
public int getDefaultMonumentHeal() {
|
public int getDefaultMonumentHeal() {
|
||||||
return defaultMonumentHeal;
|
return defaultMonumentHeal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultFriendlyFire(boolean defaultFriendlyFire) {
|
public void setDefaultFriendlyFire(boolean defaultFriendlyFire) {
|
||||||
this.defaultFriendlyFire = defaultFriendlyFire;
|
this.defaultFriendlyFire = defaultFriendlyFire;
|
||||||
}
|
}
|
||||||
@ -1400,9 +1389,9 @@ public class War extends JavaPlugin {
|
|||||||
public List<String> getZoneMakerNames() {
|
public List<String> getZoneMakerNames() {
|
||||||
return zoneMakerNames;
|
return zoneMakerNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canPlayWar(Player player) {
|
public boolean canPlayWar(Player player) {
|
||||||
if(War.permissionHandler != null
|
if(War.permissionHandler != null
|
||||||
&& (War.permissionHandler.has(player, "war.player")
|
&& (War.permissionHandler.has(player, "war.player")
|
||||||
|| War.permissionHandler.has(player, "War.player"))) {
|
|| War.permissionHandler.has(player, "War.player"))) {
|
||||||
return true;
|
return true;
|
||||||
@ -1413,9 +1402,9 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canWarp(Player player) {
|
public boolean canWarp(Player player) {
|
||||||
if(War.permissionHandler != null
|
if(War.permissionHandler != null
|
||||||
&& (War.permissionHandler.has(player, "war.warp")
|
&& (War.permissionHandler.has(player, "war.warp")
|
||||||
|| War.permissionHandler.has(player, "War.warp"))) {
|
|| War.permissionHandler.has(player, "War.warp"))) {
|
||||||
return true;
|
return true;
|
||||||
@ -1426,10 +1415,10 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBuildOutsideZone(Player player) {
|
public boolean canBuildOutsideZone(Player player) {
|
||||||
if(isBuildInZonesOnly()) {
|
if(isBuildInZonesOnly()) {
|
||||||
if(War.permissionHandler != null
|
if(War.permissionHandler != null
|
||||||
&& (War.permissionHandler.has(player, "war.build")
|
&& (War.permissionHandler.has(player, "war.build")
|
||||||
|| War.permissionHandler.has(player, "War.build"))) {
|
|| War.permissionHandler.has(player, "War.build"))) {
|
||||||
return true;
|
return true;
|
||||||
@ -1440,8 +1429,7 @@ public class War extends JavaPlugin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
|
||||||
public boolean isZoneMaker(Player player) {
|
public boolean isZoneMaker(Player player) {
|
||||||
boolean isPlayerImpersonator = false;
|
boolean isPlayerImpersonator = false;
|
||||||
for(String disguised : zoneMakersImpersonatingPlayers) {
|
for(String disguised : zoneMakersImpersonatingPlayers) {
|
||||||
@ -1451,13 +1439,13 @@ public class War extends JavaPlugin {
|
|||||||
for(String zoneMaker : zoneMakerNames) {
|
for(String zoneMaker : zoneMakerNames) {
|
||||||
if(zoneMaker.equals(player.getName())) return true;
|
if(zoneMaker.equals(player.getName())) return true;
|
||||||
}
|
}
|
||||||
if(War.permissionHandler != null
|
if(War.permissionHandler != null
|
||||||
&& (War.permissionHandler.has(player, "war.*")
|
&& (War.permissionHandler.has(player, "war.*")
|
||||||
|| War.permissionHandler.has(player, "War.*"))) {
|
|| War.permissionHandler.has(player, "War.*"))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getDefaultDrawZoneOutline() {
|
public boolean getDefaultDrawZoneOutline() {
|
||||||
@ -1465,7 +1453,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean getDefaultAutoAssignOnly() {
|
public boolean getDefaultAutoAssignOnly() {
|
||||||
|
|
||||||
return defaultAutoAssignOnly;
|
return defaultAutoAssignOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1483,9 +1471,9 @@ public class War extends JavaPlugin {
|
|||||||
|
|
||||||
public ZoneLobby lobby(Location location) {
|
public ZoneLobby lobby(Location location) {
|
||||||
for(Warzone warzone : warzones) {
|
for(Warzone warzone : warzones) {
|
||||||
if(warzone.getLobby() != null
|
if(warzone.getLobby() != null
|
||||||
&& warzone.getLobby().getVolume() != null
|
&& warzone.getLobby().getVolume() != null
|
||||||
&& warzone.getLobby().getVolume().contains(location))
|
&& warzone.getLobby().getVolume().contains(location))
|
||||||
return warzone.getLobby();
|
return warzone.getLobby();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -1497,7 +1485,7 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean inWarzoneLobby(String warzoneName, Location location) {
|
public boolean inWarzoneLobby(String warzoneName, Location location) {
|
||||||
ZoneLobby currentLobby = lobby(location);
|
ZoneLobby currentLobby = lobby(location);
|
||||||
if(currentLobby == null) {
|
if(currentLobby == null) {
|
||||||
@ -1543,12 +1531,12 @@ public class War extends JavaPlugin {
|
|||||||
public List<String> getZoneMakersImpersonatingPlayers() {
|
public List<String> getZoneMakersImpersonatingPlayers() {
|
||||||
return zoneMakersImpersonatingPlayers;
|
return zoneMakersImpersonatingPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setupPermissions() {
|
public void setupPermissions() {
|
||||||
Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions");
|
Plugin permissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions");
|
||||||
if(this.permissionHandler == null) {
|
if(War.permissionHandler == null) {
|
||||||
if(permissionsPlugin != null) {
|
if(permissionsPlugin != null) {
|
||||||
this.permissionHandler = ((Permissions) permissionsPlugin).getHandler();
|
War.permissionHandler = ((Permissions) permissionsPlugin).getHandler();
|
||||||
} else {
|
} else {
|
||||||
logInfo("Permissions system not enabled. Defaulting to regular War config.");
|
logInfo("Permissions system not enabled. Defaulting to regular War config.");
|
||||||
}
|
}
|
||||||
@ -1630,5 +1618,4 @@ public class War extends JavaPlugin {
|
|||||||
public boolean isLoaded() {
|
public boolean isLoaded() {
|
||||||
return loaded;
|
return loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -29,7 +29,7 @@ import com.tommytony.war.ZoneSetter;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tommytony
|
* @author tommytony
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -37,7 +37,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
|
|
||||||
private final War war;
|
private final War war;
|
||||||
private Random random = null;
|
private Random random = null;
|
||||||
|
|
||||||
|
|
||||||
public WarPlayerListener(War war) {
|
public WarPlayerListener(War war) {
|
||||||
this.war = war;
|
this.war = war;
|
||||||
@ -66,25 +66,25 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
Team team = war.getPlayerTeam(player.getName());
|
Team team = war.getPlayerTeam(player.getName());
|
||||||
if(team != null) {
|
if(team != null) {
|
||||||
Warzone zone = war.getPlayerTeamWarzone(player.getName());
|
Warzone zone = war.getPlayerTeamWarzone(player.getName());
|
||||||
|
|
||||||
if(zone.isFlagThief(player.getName())) {
|
if(zone.isFlagThief(player.getName())) {
|
||||||
// a flag thief can't drop his flag
|
// a flag thief can't drop his flag
|
||||||
war.badMsg(player, "Can't drop items while stealing flag. What are you doing?! Run!");
|
war.badMsg(player, "Can't drop items while stealing flag. What are you doing?! Run!");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Item item = event.getItemDrop();
|
Item item = event.getItemDrop();
|
||||||
if(item != null) {
|
if(item != null) {
|
||||||
ItemStack itemStack = item.getItemStack();
|
ItemStack itemStack = item.getItemStack();
|
||||||
if(itemStack != null
|
if(itemStack != null
|
||||||
&& itemStack.getType() == team.getKind().getMaterial()
|
&& itemStack.getType() == team.getKind().getMaterial()
|
||||||
&& itemStack.getData().getData() == team.getKind().getData()) {
|
&& itemStack.getData().getData() == team.getKind().getData()) {
|
||||||
// Can't drop your team's kind block
|
// Can't drop your team's kind block
|
||||||
war.badMsg(player, "Can't drop " + team.getName() + " block blocks.");
|
war.badMsg(player, "Can't drop " + team.getName() + " block blocks.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(zone.isNearWall(player.getLocation()) && itemStack != null) {
|
if(zone.isNearWall(player.getLocation()) && itemStack != null) {
|
||||||
war.badMsg(player, "Can't drop items near the zone border!");
|
war.badMsg(player, "Can't drop items near the zone border!");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -110,7 +110,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
Team team = war.getPlayerTeam(player.getName());
|
Team team = war.getPlayerTeam(player.getName());
|
||||||
if(team != null) {
|
if(team != null) {
|
||||||
Warzone zone = war.getPlayerTeamWarzone(player.getName());
|
Warzone zone = war.getPlayerTeamWarzone(player.getName());
|
||||||
|
|
||||||
if(zone.isFlagThief(player.getName())) {
|
if(zone.isFlagThief(player.getName())) {
|
||||||
// a flag thief can't pick up anything
|
// a flag thief can't pick up anything
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -133,7 +133,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onInventoryOpen(PlayerInventoryEvent event) {
|
public void onInventoryOpen(PlayerInventoryEvent event) {
|
||||||
if(war.isLoaded()) {
|
if(war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -152,7 +152,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
if(war.isLoaded()) {
|
if(war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -177,7 +177,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerKick(PlayerKickEvent event) {
|
public void onPlayerKick(PlayerKickEvent event) {
|
||||||
if(war.isLoaded()) {
|
if(war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -186,7 +186,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
boolean inWarzone = war.inAnyWarzone(player.getLocation());
|
boolean inWarzone = war.inAnyWarzone(player.getLocation());
|
||||||
boolean inLobby = war.inAnyWarzone(player.getLocation());
|
boolean inLobby = war.inAnyWarzone(player.getLocation());
|
||||||
boolean inWarhub = false;
|
boolean inWarhub = false;
|
||||||
if(war.getWarHub() != null && war.getWarHub().getVolume().contains(player.getLocation())) {
|
if(war.getWarHub() != null && war.getWarHub().getVolume().contains(player.getLocation())) {
|
||||||
inWarhub = true;
|
inWarhub = true;
|
||||||
}
|
}
|
||||||
if(inWarzone || inLobby || inWarhub) {
|
if(inWarzone || inLobby || inWarhub) {
|
||||||
@ -196,7 +196,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if(war.isLoaded()) {
|
if(war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -215,7 +215,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
if(war.isLoaded()) {
|
if(war.isLoaded()) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -226,7 +226,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
locLobby = war.lobby(playerLoc);
|
locLobby = war.lobby(playerLoc);
|
||||||
boolean canPlay = war.canPlayWar(player);
|
boolean canPlay = war.canPlayWar(player);
|
||||||
boolean isMaker = war.isZoneMaker(player);
|
boolean isMaker = war.isZoneMaker(player);
|
||||||
|
|
||||||
// Zone walls
|
// Zone walls
|
||||||
Team currentTeam = war.getPlayerTeam(player.getName());
|
Team currentTeam = war.getPlayerTeam(player.getName());
|
||||||
Warzone playerWarzone = war.getPlayerTeamWarzone(player.getName()); // this uses the teams, so it asks: get the player's team's warzone
|
Warzone playerWarzone = war.getPlayerTeamWarzone(player.getName()); // this uses the teams, so it asks: get the player's team's warzone
|
||||||
@ -240,7 +240,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
protecting = nearbyZone.protectZoneWallAgainstPlayer(player);
|
protecting = nearbyZone.protectZoneWallAgainstPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!protecting) {
|
if(!protecting) {
|
||||||
// zone makers still need to delete their walls
|
// zone makers still need to delete their walls
|
||||||
// make sure to delete any wall guards as you leave
|
// make sure to delete any wall guards as you leave
|
||||||
@ -248,10 +248,10 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
zone.dropZoneWallGuardIfAny(player);
|
zone.dropZoneWallGuardIfAny(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warzone lobby gates
|
// Warzone lobby gates
|
||||||
if(locLobby != null) {
|
if(locLobby != null) {
|
||||||
Warzone zone = locLobby.getZone();
|
Warzone zone = locLobby.getZone();
|
||||||
Team oldTeam = war.getPlayerTeam(player.getName());
|
Team oldTeam = war.getPlayerTeam(player.getName());
|
||||||
boolean isAutoAssignGate = false;
|
boolean isAutoAssignGate = false;
|
||||||
if(oldTeam == null && canPlay) { // trying to counter spammy player move
|
if(oldTeam == null && canPlay) { // trying to counter spammy player move
|
||||||
@ -266,8 +266,8 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
noOfPlayers += t.getPlayers().size();
|
noOfPlayers += t.getPlayers().size();
|
||||||
}
|
}
|
||||||
if(noOfPlayers < zone.getTeams().size() * zone.getTeamCap()) {
|
if(noOfPlayers < zone.getTeams().size() * zone.getTeamCap()) {
|
||||||
Team team = zone.autoAssign(player);
|
zone.autoAssign(player);
|
||||||
|
|
||||||
if(war.getWarHub() != null) {
|
if(war.getWarHub() != null) {
|
||||||
war.getWarHub().resetZoneSign(zone);
|
war.getWarHub().resetZoneSign(zone);
|
||||||
}
|
}
|
||||||
@ -279,7 +279,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// go through all the team gates
|
// go through all the team gates
|
||||||
for(Team team : zone.getTeams()){
|
for(Team team : zone.getTeams()){
|
||||||
if(zone.getLobby().isInTeamGate(team, playerLoc)) {
|
if(zone.getLobby().isInTeamGate(team, playerLoc)) {
|
||||||
@ -305,8 +305,8 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (war.getWarHub() != null && zone.getLobby().isInWarHubLinkGate(playerLoc)
|
if (war.getWarHub() != null && zone.getLobby().isInWarHubLinkGate(playerLoc)
|
||||||
&& !war.getWarHub().getVolume().contains(player.getLocation())){
|
&& !war.getWarHub().getVolume().contains(player.getLocation())){
|
||||||
dropFromOldTeamIfAny(player);
|
dropFromOldTeamIfAny(player);
|
||||||
event.setTo(war.getWarHub().getLocation());
|
event.setTo(war.getWarHub().getLocation());
|
||||||
@ -315,9 +315,9 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warhub zone gates
|
// Warhub zone gates
|
||||||
WarHub hub = war.getWarHub();
|
WarHub hub = war.getWarHub();
|
||||||
if(hub != null && hub.getVolume().contains(player.getLocation())) {
|
if(hub != null && hub.getVolume().contains(player.getLocation())) {
|
||||||
@ -329,7 +329,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isLeaving = playerWarzone != null && playerWarzone.getLobby().isLeavingZone(playerLoc);
|
boolean isLeaving = playerWarzone != null && playerWarzone.getLobby().isLeavingZone(playerLoc);
|
||||||
Team playerTeam = war.getPlayerTeam(player.getName());
|
Team playerTeam = war.getPlayerTeam(player.getName());
|
||||||
if(isLeaving) { // already in a team and in warzone, leaving
|
if(isLeaving) { // already in a team and in warzone, leaving
|
||||||
@ -338,26 +338,26 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
boolean atSpawnAlready = playerTeam.getTeamSpawn().getBlockX() == player.getLocation().getBlockX() &&
|
boolean atSpawnAlready = playerTeam.getTeamSpawn().getBlockX() == player.getLocation().getBlockX() &&
|
||||||
playerTeam.getTeamSpawn().getBlockY() == player.getLocation().getBlockY() &&
|
playerTeam.getTeamSpawn().getBlockY() == player.getLocation().getBlockY() &&
|
||||||
playerTeam.getTeamSpawn().getBlockZ() == player.getLocation().getBlockZ();
|
playerTeam.getTeamSpawn().getBlockZ() == player.getLocation().getBlockZ();
|
||||||
if(!atSpawnAlready) {
|
if(!atSpawnAlready) {
|
||||||
playerWarzone.handlePlayerLeave(player, playerWarzone.getTeleport(), event, true);
|
playerWarzone.handlePlayerLeave(player, playerWarzone.getTeleport(), event, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(playerWarzone != null) {
|
if(playerWarzone != null) {
|
||||||
// Player belongs to a warzone team but is outside: he snuck out or is at spawn and died
|
// Player belongs to a warzone team but is outside: he snuck out or is at spawn and died
|
||||||
if(locZone == null && playerTeam != null && playerWarzone.getLobby() != null
|
if(locZone == null && playerTeam != null && playerWarzone.getLobby() != null
|
||||||
&& !playerWarzone.getLobby().getVolume().contains(playerLoc)
|
&& !playerWarzone.getLobby().getVolume().contains(playerLoc)
|
||||||
&& !isLeaving) {
|
&& !isLeaving) {
|
||||||
war.badMsg(player, "Use /leave to exit the zone.");
|
war.badMsg(player, "Use /leave to exit the zone.");
|
||||||
event.setTo(playerTeam.getTeamSpawn());
|
event.setTo(playerTeam.getTeamSpawn());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Monuments
|
// Monuments
|
||||||
if(playerTeam != null
|
if(playerTeam != null
|
||||||
&& playerWarzone.nearAnyOwnedMonument(playerLoc, playerTeam)
|
&& playerWarzone.nearAnyOwnedMonument(playerLoc, playerTeam)
|
||||||
&& player.getHealth() < 20
|
&& player.getHealth() < 20
|
||||||
&& player.getHealth() > 0 // don't heal the dead
|
&& player.getHealth() > 0 // don't heal the dead
|
||||||
&& random.nextInt(77) == 3 ) { // one chance out of many of getting healed
|
&& random.nextInt(77) == 3 ) { // one chance out of many of getting healed
|
||||||
@ -377,9 +377,9 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
war.msg(player, "Your dance pleases the monument's voodoo. You gain "+heartNum+"heart"+isS+"!");
|
war.msg(player, "Your dance pleases the monument's voodoo. You gain "+heartNum+"heart"+isS+"!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flag capture
|
// Flag capture
|
||||||
if(playerWarzone.isFlagThief(player.getName())
|
if(playerWarzone.isFlagThief(player.getName())
|
||||||
&& (playerTeam.getSpawnVolume().contains(player.getLocation())
|
&& (playerTeam.getSpawnVolume().contains(player.getLocation())
|
||||||
|| (playerTeam.getFlagVolume() != null && playerTeam.getFlagVolume().contains(player.getLocation())))) {
|
|| (playerTeam.getFlagVolume() != null && playerTeam.getFlagVolume().contains(player.getLocation())))) {
|
||||||
if(playerWarzone.isTeamFlagStolen(playerTeam)) {
|
if(playerWarzone.isTeamFlagStolen(playerTeam)) {
|
||||||
@ -407,14 +407,14 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
playerWarzone.respawnPlayer(event, playerTeam, player);
|
playerWarzone.respawnPlayer(event, playerTeam, player);
|
||||||
playerTeam.resetSign();
|
playerTeam.resetSign();
|
||||||
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
|
playerWarzone.getLobby().resetTeamGateSign(playerTeam);
|
||||||
}
|
}
|
||||||
playerWarzone.removeThief(player.getName());
|
playerWarzone.removeThief(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (locZone != null && locZone.getLobby() != null
|
} else if (locZone != null && locZone.getLobby() != null
|
||||||
&& !locZone.getLobby().isLeavingZone(playerLoc) && !isMaker) {
|
&& !locZone.getLobby().isLeavingZone(playerLoc) && !isMaker) {
|
||||||
// player is not in any team, but inside warzone boundaries, get him out
|
// player is not in any team, but inside warzone boundaries, get him out
|
||||||
Warzone zone = war.warzone(playerLoc);
|
Warzone zone = war.warzone(playerLoc);
|
||||||
event.setTo(zone.getTeleport());
|
event.setTo(zone.getTeleport());
|
||||||
@ -424,7 +424,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleDisabledZone(PlayerMoveEvent event, Player player, Warzone zone) {
|
private void handleDisabledZone(PlayerMoveEvent event, Player player, Warzone zone) {
|
||||||
if(zone.getLobby() != null) {
|
if(zone.getLobby() != null) {
|
||||||
war.badMsg(player, "This warzone is disabled.");
|
war.badMsg(player, "This warzone is disabled.");
|
||||||
|
@ -7,38 +7,34 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Dispenser;
|
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import com.tommytony.war.Warzone;
|
|
||||||
import com.tommytony.war.utils.DeferredBlockReset;
|
import com.tommytony.war.utils.DeferredBlockReset;
|
||||||
|
|
||||||
public class DeferredBlockResetsJob implements Runnable {
|
public class DeferredBlockResetsJob implements Runnable {
|
||||||
|
|
||||||
List<DeferredBlockReset> deferred = new ArrayList<DeferredBlockReset>();
|
List<DeferredBlockReset> deferred = new ArrayList<DeferredBlockReset>();
|
||||||
private final World world;
|
private final World world;
|
||||||
|
|
||||||
public DeferredBlockResetsJob(World world) {
|
public DeferredBlockResetsJob(World world) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(DeferredBlockReset pleaseResetLater) {
|
public void add(DeferredBlockReset pleaseResetLater) {
|
||||||
deferred.add(pleaseResetLater);
|
deferred.add(pleaseResetLater);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return deferred.isEmpty();
|
return deferred.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
for(DeferredBlockReset reset : deferred) {
|
for(DeferredBlockReset reset : deferred) {
|
||||||
Block worldBlock = world.getBlockAt(reset.getX(), reset.getY(), reset.getZ());
|
Block worldBlock = world.getBlockAt(reset.getX(), reset.getY(), reset.getZ());
|
||||||
worldBlock.setType(Material.getMaterial(reset.getBlockType()));
|
worldBlock.setType(Material.getMaterial(reset.getBlockType()));
|
||||||
|
|
||||||
if(reset.getBlockType() == Material.SIGN_POST.getId()) {
|
if(reset.getBlockType() == Material.SIGN_POST.getId()) {
|
||||||
BlockState state = worldBlock.getState();
|
BlockState state = worldBlock.getState();
|
||||||
state.setData(new org.bukkit.material.Sign(reset.getBlockType(), reset.getBlockData()));
|
state.setData(new org.bukkit.material.Sign(reset.getBlockType(), reset.getBlockData()));
|
||||||
@ -55,12 +51,12 @@ public class DeferredBlockResetsJob implements Runnable {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// normal data reset
|
// normal data reset
|
||||||
worldBlock.setData(reset.getBlockData());
|
worldBlock.setData(reset.getBlockData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,12 +3,9 @@ package com.tommytony.war.mappers;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -26,7 +23,6 @@ import org.bukkit.material.MaterialData;
|
|||||||
import bukkit.tommytony.war.War;
|
import bukkit.tommytony.war.War;
|
||||||
|
|
||||||
import com.tommytony.war.jobs.DeferredBlockResetsJob;
|
import com.tommytony.war.jobs.DeferredBlockResetsJob;
|
||||||
import com.tommytony.war.jobs.ZoneVolumeSaveJob;
|
|
||||||
import com.tommytony.war.utils.DeferredBlockReset;
|
import com.tommytony.war.utils.DeferredBlockReset;
|
||||||
import com.tommytony.war.volumes.Volume;
|
import com.tommytony.war.volumes.Volume;
|
||||||
import com.tommytony.war.volumes.ZoneVolume;
|
import com.tommytony.war.volumes.ZoneVolume;
|
||||||
@ -34,12 +30,12 @@ import com.tommytony.war.volumes.ZoneVolume;
|
|||||||
/**
|
/**
|
||||||
* The ZoneVolumeMapper take the blocks from disk and sets them in the worlds, since
|
* The ZoneVolumeMapper take the blocks from disk and sets them in the worlds, since
|
||||||
* the ZoneVolume doesn't hold its blocks in memory like regular Volumes.
|
* the ZoneVolume doesn't hold its blocks in memory like regular Volumes.
|
||||||
*
|
*
|
||||||
* @author tommytony
|
* @author tommytony
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PreDeGaulleZoneVolumeMapper {
|
public class PreDeGaulleZoneVolumeMapper {
|
||||||
|
|
||||||
private static List<ItemStack> readInventoryString(String invString) {
|
private static List<ItemStack> readInventoryString(String invString) {
|
||||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||||
String[] itemsStrSplit = invString.split(";;");
|
String[] itemsStrSplit = invString.split(";;");
|
||||||
@ -73,7 +69,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
try {
|
try {
|
||||||
in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||||
String firstLine = in.readLine();
|
String firstLine = in.readLine();
|
||||||
|
|
||||||
if(firstLine != null && !firstLine.equals("")) {
|
if(firstLine != null && !firstLine.equals("")) {
|
||||||
boolean height129Fix = false;
|
boolean height129Fix = false;
|
||||||
int x1 = Integer.parseInt(in.readLine());
|
int x1 = Integer.parseInt(in.readLine());
|
||||||
@ -91,10 +87,10 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
y2 = 127;
|
y2 = 127;
|
||||||
}
|
}
|
||||||
int z2 = Integer.parseInt(in.readLine());
|
int z2 = Integer.parseInt(in.readLine());
|
||||||
|
|
||||||
volume.setCornerOne(world.getBlockAt(x1, y1, z1));
|
volume.setCornerOne(world.getBlockAt(x1, y1, z1));
|
||||||
volume.setCornerTwo(world.getBlockAt(x2, y2, z2));
|
volume.setCornerTwo(world.getBlockAt(x2, y2, z2));
|
||||||
|
|
||||||
if(!onlyLoadCorners) {
|
if(!onlyLoadCorners) {
|
||||||
DeferredBlockResetsJob deferred = new DeferredBlockResetsJob(world);
|
DeferredBlockResetsJob deferred = new DeferredBlockResetsJob(world);
|
||||||
int blockReads = 0, visitedBlocks = 0, x = 0, y = 0, z = 0, i = 0, j = 0 , k = 0;
|
int blockReads = 0, visitedBlocks = 0, x = 0, y = 0, z = 0, i = 0, j = 0 , k = 0;
|
||||||
@ -107,13 +103,13 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
String blockLine;
|
String blockLine;
|
||||||
String[] blockSplit;
|
String[] blockSplit;
|
||||||
for(i = 0; i < volume.getSizeX(); i++){
|
for(i = 0; i < volume.getSizeX(); i++){
|
||||||
y = volume.getMinY();
|
y = volume.getMinY();
|
||||||
for(j = 0; j < volume.getSizeY(); j++) {
|
for(j = 0; j < volume.getSizeY(); j++) {
|
||||||
z = volume.getMinZ();
|
z = volume.getMinZ();
|
||||||
for(k = 0; k < volume.getSizeZ(); k++) {
|
for(k = 0; k < volume.getSizeZ(); k++) {
|
||||||
try {
|
try {
|
||||||
blockLine = in.readLine();
|
blockLine = in.readLine();
|
||||||
|
|
||||||
if(blockLine != null && !blockLine.equals("")) {
|
if(blockLine != null && !blockLine.equals("")) {
|
||||||
blockSplit = blockLine.split(",");
|
blockSplit = blockLine.split(",");
|
||||||
if(blockLine != null && !blockLine.equals("") && blockSplit.length > 1) {
|
if(blockLine != null && !blockLine.equals("") && blockSplit.length > 1) {
|
||||||
@ -124,11 +120,11 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
if(worldBlockId != diskBlockType ||
|
if(worldBlockId != diskBlockType ||
|
||||||
(worldBlockId == diskBlockType && worldBlock.getData() != diskBlockData ) ||
|
(worldBlockId == diskBlockType && worldBlock.getData() != diskBlockData ) ||
|
||||||
(worldBlockId == diskBlockType && worldBlock.getData() == diskBlockData &&
|
(worldBlockId == diskBlockType && worldBlock.getData() == diskBlockData &&
|
||||||
(diskBlockType == Material.WALL_SIGN.getId() || diskBlockType == Material.SIGN_POST.getId()
|
(diskBlockType == Material.WALL_SIGN.getId() || diskBlockType == Material.SIGN_POST.getId()
|
||||||
|| diskBlockType == Material.CHEST.getId() || diskBlockType == Material.DISPENSER.getId())
|
|| diskBlockType == Material.CHEST.getId() || diskBlockType == Material.DISPENSER.getId())
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if(diskBlockType == Material.WALL_SIGN.getId()
|
if(diskBlockType == Material.WALL_SIGN.getId()
|
||||||
|| diskBlockType == Material.SIGN_POST.getId()) {
|
|| diskBlockType == Material.SIGN_POST.getId()) {
|
||||||
// Signs read
|
// Signs read
|
||||||
String linesStr = "";
|
String linesStr = "";
|
||||||
@ -139,7 +135,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
String[] lines = linesStr.split(";;");
|
String[] lines = linesStr.split(";;");
|
||||||
|
|
||||||
// Signs set
|
// Signs set
|
||||||
// A sign post hanging on a wall south of here will
|
// A sign post hanging on a wall south of here will
|
||||||
if(diskBlockType == Material.SIGN_POST.getId() && ((diskBlockData & 0x04) == 0x04)
|
if(diskBlockType == Material.SIGN_POST.getId() && ((diskBlockData & 0x04) == 0x04)
|
||||||
&& i+1 != volume.getSizeX()) {
|
&& i+1 != volume.getSizeX()) {
|
||||||
deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData, lines));
|
deferred.add(new DeferredBlockReset(x, y, z, diskBlockType, diskBlockData, lines));
|
||||||
@ -166,7 +162,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
String itemsStr = blockSplit[2];
|
String itemsStr = blockSplit[2];
|
||||||
items = readInventoryString(itemsStr);
|
items = readInventoryString(itemsStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chests set
|
// Chests set
|
||||||
worldBlock.setType(Material.getMaterial(diskBlockType));
|
worldBlock.setType(Material.getMaterial(diskBlockType));
|
||||||
worldBlock.setData(diskBlockData);
|
worldBlock.setData(diskBlockData);
|
||||||
@ -193,7 +189,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
//String itemsStr = lineScanner.nextLine();
|
//String itemsStr = lineScanner.nextLine();
|
||||||
items = readInventoryString(itemsStr);
|
items = readInventoryString(itemsStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispensers set
|
// Dispensers set
|
||||||
worldBlock.setType(Material.getMaterial(diskBlockType));
|
worldBlock.setType(Material.getMaterial(diskBlockType));
|
||||||
worldBlock.setData(diskBlockData);
|
worldBlock.setData(diskBlockData);
|
||||||
@ -214,7 +210,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
}
|
}
|
||||||
} else if(diskBlockType == Material.WOODEN_DOOR.getId() || diskBlockType == Material.IRON_DOOR_BLOCK.getId()){
|
} else if(diskBlockType == Material.WOODEN_DOOR.getId() || diskBlockType == Material.IRON_DOOR_BLOCK.getId()){
|
||||||
// Door blocks
|
// Door blocks
|
||||||
|
|
||||||
if(j-1 > 0) {
|
if(j-1 > 0) {
|
||||||
Block blockBelow = world.getBlockAt(x, y-1, z);
|
Block blockBelow = world.getBlockAt(x, y-1, z);
|
||||||
boolean belowIsGlass = blockBelow.getTypeId() == Material.GLASS.getId();
|
boolean belowIsGlass = blockBelow.getTypeId() == Material.GLASS.getId();
|
||||||
@ -230,8 +226,8 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
worldBlock.setType(Material.GLASS);
|
worldBlock.setType(Material.GLASS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(((diskBlockType == Material.TORCH.getId() && ((diskBlockData & 0x02) == 0x02))
|
} else if(((diskBlockType == Material.TORCH.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||||
|| (diskBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((diskBlockData & 0x02) == 0x02))
|
|| (diskBlockType == Material.REDSTONE_TORCH_OFF.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||||
|| (diskBlockType == Material.REDSTONE_TORCH_ON.getId() && ((diskBlockData & 0x02) == 0x02))
|
|| (diskBlockType == Material.REDSTONE_TORCH_ON.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||||
|| (diskBlockType == Material.LEVER.getId() && ((diskBlockData & 0x02) == 0x02))
|
|| (diskBlockType == Material.LEVER.getId() && ((diskBlockData & 0x02) == 0x02))
|
||||||
@ -253,12 +249,12 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
}
|
}
|
||||||
blockReads++;
|
blockReads++;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
volume.getWar().getLogger().warning("Failed to reset block in zone volume " + volume.getName() + ". "
|
volume.getWar().getLogger().warning("Failed to reset block in zone volume " + volume.getName() + ". "
|
||||||
+ "Blocks read: " + blockReads
|
+ "Blocks read: " + blockReads
|
||||||
+ ". Visited blocks so far:" + visitedBlocks
|
+ ". Visited blocks so far:" + visitedBlocks
|
||||||
+ ". Blocks reset: "+ noOfResetBlocks +
|
+ ". Blocks reset: "+ noOfResetBlocks +
|
||||||
". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " " + e.getMessage());
|
". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@ -281,11 +277,11 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.logWarn("Failed to read volume file " + volume.getName() +
|
war.logWarn("Failed to read volume file " + volume.getName() +
|
||||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
war.logWarn("Unexpected error caused failure to read volume file " + zoneName +
|
war.logWarn("Unexpected error caused failure to read volume file " + zoneName +
|
||||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@ -312,9 +308,9 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
try {
|
try {
|
||||||
(new File(war.getDataFolder().getPath() +"/dat/warzone-"+zoneName)).mkdir();
|
(new File(war.getDataFolder().getPath() +"/dat/warzone-"+zoneName)).mkdir();
|
||||||
if(zoneName.equals("")) out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));
|
if(zoneName.equals("")) out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));
|
||||||
else out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() +
|
else out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() +
|
||||||
"/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
"/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||||
|
|
||||||
out.write("corner1"); out.newLine();
|
out.write("corner1"); out.newLine();
|
||||||
out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();
|
out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();
|
||||||
out.write(Integer.toString(volume.getCornerOne().getY())); out.newLine();
|
out.write(Integer.toString(volume.getCornerOne().getY())); out.newLine();
|
||||||
@ -323,7 +319,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
out.write(Integer.toString(volume.getCornerTwo().getX())); out.newLine();
|
out.write(Integer.toString(volume.getCornerTwo().getX())); out.newLine();
|
||||||
out.write(Integer.toString(volume.getCornerTwo().getY())); out.newLine();
|
out.write(Integer.toString(volume.getCornerTwo().getY())); out.newLine();
|
||||||
out.write(Integer.toString(volume.getCornerTwo().getZ())); out.newLine();
|
out.write(Integer.toString(volume.getCornerTwo().getZ())); out.newLine();
|
||||||
|
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
int z = 0;
|
int z = 0;
|
||||||
@ -331,7 +327,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
int typeId;
|
int typeId;
|
||||||
byte data;
|
byte data;
|
||||||
BlockState state;
|
BlockState state;
|
||||||
|
|
||||||
x = volume.getMinX();
|
x = volume.getMinX();
|
||||||
for(int i = 0; i < volume.getSizeX(); i++){
|
for(int i = 0; i < volume.getSizeX(); i++){
|
||||||
y = volume.getMinY();
|
y = volume.getMinY();
|
||||||
@ -343,9 +339,9 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
typeId = block.getTypeId();
|
typeId = block.getTypeId();
|
||||||
data = block.getData();
|
data = block.getData();
|
||||||
state = block.getState();
|
state = block.getState();
|
||||||
|
|
||||||
out.write(typeId + "," + data + ",");
|
out.write(typeId + "," + data + ",");
|
||||||
|
|
||||||
if(state instanceof Sign) {
|
if(state instanceof Sign) {
|
||||||
// Signs
|
// Signs
|
||||||
String extra = "";
|
String extra = "";
|
||||||
@ -356,7 +352,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
}
|
}
|
||||||
out.write(extra);
|
out.write(extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(state instanceof Chest) {
|
} else if(state instanceof Chest) {
|
||||||
// Chests
|
// Chests
|
||||||
Chest chest = (Chest)state;
|
Chest chest = (Chest)state;
|
||||||
@ -373,9 +369,9 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
if(items != null) {
|
if(items != null) {
|
||||||
for(ItemStack item : items) {
|
for(ItemStack item : items) {
|
||||||
if(item != null) {
|
if(item != null) {
|
||||||
extra += item.getTypeId() + ";"
|
extra += item.getTypeId() + ";"
|
||||||
+ item.getAmount() + ";"
|
+ item.getAmount() + ";"
|
||||||
+ item.getDurability();
|
+ item.getDurability();
|
||||||
if(item.getData() != null)
|
if(item.getData() != null)
|
||||||
extra += ";" + item.getData().getData() ;
|
extra += ";" + item.getData().getData() ;
|
||||||
extra += ";;";
|
extra += ";;";
|
||||||
@ -384,7 +380,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
out.write(extra);
|
out.write(extra);
|
||||||
}
|
}
|
||||||
} else if(state instanceof Dispenser) {
|
} else if(state instanceof Dispenser) {
|
||||||
// Dispensers
|
// Dispensers
|
||||||
Dispenser dispenser = (Dispenser)state;
|
Dispenser dispenser = (Dispenser)state;
|
||||||
Inventory inv = dispenser.getInventory();
|
Inventory inv = dispenser.getInventory();
|
||||||
int size = inv.getSize();
|
int size = inv.getSize();
|
||||||
@ -399,9 +395,9 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
if(items != null) {
|
if(items != null) {
|
||||||
for(ItemStack item : items) {
|
for(ItemStack item : items) {
|
||||||
if(item != null) {
|
if(item != null) {
|
||||||
extra += item.getTypeId() + ";"
|
extra += item.getTypeId() + ";"
|
||||||
+ item.getAmount() + ";"
|
+ item.getAmount() + ";"
|
||||||
+ item.getDurability();
|
+ item.getDurability();
|
||||||
if(item.getData() != null)
|
if(item.getData() != null)
|
||||||
extra += ";" + item.getData().getData() ;
|
extra += ";" + item.getData().getData() ;
|
||||||
extra += ";;";
|
extra += ";;";
|
||||||
@ -415,7 +411,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
war.logWarn("Unexpected error while saving a block to " +
|
war.logWarn("Unexpected error while saving a block to " +
|
||||||
" file for zone " + zoneName + ". Blocks saved so far: " + noOfSavedBlocks
|
" file for zone " + zoneName + ". Blocks saved so far: " + noOfSavedBlocks
|
||||||
+ "Position: x:" + x + " y:" + y + " z:" + z + ". " + e.getClass().getName() + " " + e.getMessage());
|
+ "Position: x:" + x + " y:" + y + " z:" + z + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@ -427,14 +423,14 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.logWarn("Failed to write volume file " + zoneName +
|
war.logWarn("Failed to write volume file " + zoneName +
|
||||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
war.logWarn("Unexpected error caused failure to write volume file " + zoneName +
|
war.logWarn("Unexpected error caused failure to write volume file " + zoneName +
|
||||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if(out != null)
|
if(out != null)
|
||||||
try {
|
try {
|
||||||
@ -443,7 +439,7 @@ public class PreDeGaulleZoneVolumeMapper {
|
|||||||
war.logWarn("Failed to close file writer for volume " + volume.getName() +
|
war.logWarn("Failed to close file writer for volume " + volume.getName() +
|
||||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return noOfSavedBlocks;
|
return noOfSavedBlocks;
|
||||||
|
@ -16,35 +16,33 @@ import org.bukkit.material.MaterialData;
|
|||||||
|
|
||||||
import bukkit.tommytony.war.War;
|
import bukkit.tommytony.war.War;
|
||||||
|
|
||||||
import com.tommytony.war.Warzone;
|
|
||||||
import com.tommytony.war.volumes.Volume;
|
import com.tommytony.war.volumes.Volume;
|
||||||
import com.tommytony.war.volumes.ZoneVolume;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tommytony
|
* @author tommytony
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class VolumeMapper {
|
public class VolumeMapper {
|
||||||
|
|
||||||
public static Volume loadVolume(String volumeName, String zoneName,
|
public static Volume loadVolume(String volumeName, String zoneName,
|
||||||
War war, World world) {
|
War war, World world) {
|
||||||
Volume volume = new Volume(volumeName, war, world);
|
Volume volume = new Volume(volumeName, war, world);
|
||||||
load(volume, zoneName, war, world);
|
load(volume, zoneName, war, world);
|
||||||
return volume;
|
return volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static ZoneVolume loadZoneVolume(String volumeName, String zoneName,
|
// public static ZoneVolume loadZoneVolume(String volumeName, String zoneName,
|
||||||
// War war, World world, Warzone zone) {
|
// War war, World world, Warzone zone) {
|
||||||
// ZoneVolume volume = new ZoneVolume(volumeName, war, world, zone);
|
// ZoneVolume volume = new ZoneVolume(volumeName, war, world, zone);
|
||||||
// load(volume, zoneName, war, world);
|
// load(volume, zoneName, war, world);
|
||||||
// return volume;
|
// return volume;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public static void load(Volume volume, String zoneName, War war, World world) {
|
public static void load(Volume volume, String zoneName, War war, World world) {
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
try {
|
try {
|
||||||
if(zoneName.equals("")) in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() +
|
if(zoneName.equals("")) in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() +
|
||||||
"/dat/volume-" + volume.getName() + ".dat"))); // for the warhub
|
"/dat/volume-" + volume.getName() + ".dat"))); // for the warhub
|
||||||
else in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
else in = new BufferedReader(new FileReader(new File(war.getDataFolder().getPath() + "/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||||
String firstLine = in.readLine();
|
String firstLine = in.readLine();
|
||||||
@ -65,10 +63,10 @@ public class VolumeMapper {
|
|||||||
y2 = 127;
|
y2 = 127;
|
||||||
}
|
}
|
||||||
int z2 = Integer.parseInt(in.readLine());
|
int z2 = Integer.parseInt(in.readLine());
|
||||||
|
|
||||||
volume.setCornerOne(world.getBlockAt(x1, y1, z1));
|
volume.setCornerOne(world.getBlockAt(x1, y1, z1));
|
||||||
volume.setCornerTwo(world.getBlockAt(x2, y2, z2));
|
volume.setCornerTwo(world.getBlockAt(x2, y2, z2));
|
||||||
|
|
||||||
volume.setBlockTypes(new int[volume.getSizeX()][volume.getSizeY()][volume.getSizeZ()]);
|
volume.setBlockTypes(new int[volume.getSizeX()][volume.getSizeY()][volume.getSizeZ()]);
|
||||||
volume.setBlockDatas(new byte[volume.getSizeX()][volume.getSizeY()][volume.getSizeZ()]);
|
volume.setBlockDatas(new byte[volume.getSizeX()][volume.getSizeY()][volume.getSizeZ()]);
|
||||||
int blockReads = 0;
|
int blockReads = 0;
|
||||||
@ -82,11 +80,11 @@ public class VolumeMapper {
|
|||||||
if(blockLine != null && !blockLine.equals("") && blockSplit.length > 1) {
|
if(blockLine != null && !blockLine.equals("") && blockSplit.length > 1) {
|
||||||
int typeID = Integer.parseInt(blockSplit[0]);
|
int typeID = Integer.parseInt(blockSplit[0]);
|
||||||
byte data = Byte.parseByte(blockSplit[1]);
|
byte data = Byte.parseByte(blockSplit[1]);
|
||||||
|
|
||||||
volume.getBlockTypes()[i][j][k] = typeID;
|
volume.getBlockTypes()[i][j][k] = typeID;
|
||||||
volume.getBlockDatas()[i][j][k] = data;
|
volume.getBlockDatas()[i][j][k] = data;
|
||||||
|
|
||||||
if(typeID == Material.WALL_SIGN.getId()
|
if(typeID == Material.WALL_SIGN.getId()
|
||||||
|| typeID == Material.SIGN_POST.getId()) {
|
|| typeID == Material.SIGN_POST.getId()) {
|
||||||
// Signs
|
// Signs
|
||||||
String linesStr = "";
|
String linesStr = "";
|
||||||
@ -153,12 +151,12 @@ public class VolumeMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
volume.getInvBlockContents().put("dispenser-" + i + "-" + j + "-" + k, items);
|
volume.getInvBlockContents().put("dispenser-" + i + "-" + j + "-" + k, items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blockReads++;
|
blockReads++;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
war.logWarn("Unexpected error while reading block from volume " + volume.getName() +
|
war.logWarn("Unexpected error while reading block from volume " + volume.getName() +
|
||||||
" file for zone " + zoneName + ". Blocks read so far: " + blockReads
|
" file for zone " + zoneName + ". Blocks read so far: " + blockReads
|
||||||
+ "Position: x:" + i + " y:" + j + " z:" + k + ". " + e.getClass().getName() + " " + e.getMessage());
|
+ "Position: x:" + i + " y:" + j + " z:" + k + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -173,11 +171,11 @@ public class VolumeMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.logWarn("Failed to read volume file " + volume.getName() +
|
war.logWarn("Failed to read volume file " + volume.getName() +
|
||||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
war.logWarn("Unexpected error caused failure to read volume file " + zoneName +
|
war.logWarn("Unexpected error caused failure to read volume file " + zoneName +
|
||||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@ -191,15 +189,15 @@ public class VolumeMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void save(Volume volume, String zoneName, War war) {
|
public static void save(Volume volume, String zoneName, War war) {
|
||||||
if(volume.hasTwoCorners()) {
|
if(volume.hasTwoCorners()) {
|
||||||
BufferedWriter out = null;
|
BufferedWriter out = null;
|
||||||
try {
|
try {
|
||||||
if(zoneName.equals("")) out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));
|
if(zoneName.equals("")) out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() + "/dat/volume-" + volume.getName() + ".dat")));
|
||||||
else out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() +
|
else out = new BufferedWriter(new FileWriter(new File(war.getDataFolder().getPath() +
|
||||||
"/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
"/dat/warzone-" + zoneName + "/volume-" + volume.getName() + ".dat")));
|
||||||
|
|
||||||
out.write("corner1"); out.newLine();
|
out.write("corner1"); out.newLine();
|
||||||
out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();
|
out.write(Integer.toString(volume.getCornerOne().getX())); out.newLine();
|
||||||
out.write(Integer.toString(volume.getCornerOne().getY())); out.newLine();
|
out.write(Integer.toString(volume.getCornerOne().getY())); out.newLine();
|
||||||
@ -216,7 +214,7 @@ public class VolumeMapper {
|
|||||||
int typeId = volume.getBlockTypes()[i][j][k];
|
int typeId = volume.getBlockTypes()[i][j][k];
|
||||||
byte data = volume.getBlockDatas()[i][j][k];
|
byte data = volume.getBlockDatas()[i][j][k];
|
||||||
out.write(typeId + "," + data + ",");
|
out.write(typeId + "," + data + ",");
|
||||||
if(typeId == Material.WALL_SIGN.getId()
|
if(typeId == Material.WALL_SIGN.getId()
|
||||||
|| typeId == Material.SIGN_POST.getId()) {
|
|| typeId == Material.SIGN_POST.getId()) {
|
||||||
// Signs
|
// Signs
|
||||||
String extra = "";
|
String extra = "";
|
||||||
@ -234,9 +232,9 @@ public class VolumeMapper {
|
|||||||
if(contents != null) {
|
if(contents != null) {
|
||||||
for(ItemStack item : contents) {
|
for(ItemStack item : contents) {
|
||||||
if(item != null) {
|
if(item != null) {
|
||||||
extra += item.getTypeId() + ";"
|
extra += item.getTypeId() + ";"
|
||||||
+ item.getAmount() + ";"
|
+ item.getAmount() + ";"
|
||||||
+ item.getDurability();
|
+ item.getDurability();
|
||||||
if(item.getData() != null)
|
if(item.getData() != null)
|
||||||
extra += ";" + item.getData().getData() ;
|
extra += ";" + item.getData().getData() ;
|
||||||
extra += ";;";
|
extra += ";;";
|
||||||
@ -251,9 +249,9 @@ public class VolumeMapper {
|
|||||||
if(contents != null) {
|
if(contents != null) {
|
||||||
for(ItemStack item : contents) {
|
for(ItemStack item : contents) {
|
||||||
if(item != null) {
|
if(item != null) {
|
||||||
extra += item.getTypeId() + ";"
|
extra += item.getTypeId() + ";"
|
||||||
+ item.getAmount() + ";"
|
+ item.getAmount() + ";"
|
||||||
+ item.getDurability();
|
+ item.getDurability();
|
||||||
if(item.getData() != null)
|
if(item.getData() != null)
|
||||||
extra += ";" + item.getData().getData() ;
|
extra += ";" + item.getData().getData() ;
|
||||||
extra += ";;";
|
extra += ";;";
|
||||||
@ -265,8 +263,8 @@ public class VolumeMapper {
|
|||||||
out.newLine();
|
out.newLine();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
war.logWarn("Unexpected error while writing block into volume " + volume.getName() +
|
war.logWarn("Unexpected error while writing block into volume " + volume.getName() +
|
||||||
" file for zone " + zoneName + ". Blocks written so far: " + blockWrites
|
" file for zone " + zoneName + ". Blocks written so far: " + blockWrites
|
||||||
+ "Position: x:" + i + " y:" + j + " z:" + k + ". " + e.getClass().getName() + " " + e.getMessage());
|
+ "Position: x:" + i + " y:" + j + " z:" + k + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -274,14 +272,14 @@ public class VolumeMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
war.logWarn("Failed to write volume file " + zoneName +
|
war.logWarn("Failed to write volume file " + zoneName +
|
||||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
war.logWarn("Unexpected error caused failure to write volume file " + zoneName +
|
war.logWarn("Unexpected error caused failure to write volume file " + zoneName +
|
||||||
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
" for warzone " + volume.getName() + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if(out != null)
|
if(out != null)
|
||||||
try {
|
try {
|
||||||
@ -290,7 +288,7 @@ public class VolumeMapper {
|
|||||||
war.logWarn("Failed to close file writer for volume " + volume.getName() +
|
war.logWarn("Failed to close file writer for volume " + volume.getName() +
|
||||||
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
" for warzone " + zoneName + ". " + e.getClass().getName() + " " + e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package com.tommytony.war.utils;
|
package com.tommytony.war.utils;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class DeferredBlockReset {
|
public class DeferredBlockReset {
|
||||||
|
|
||||||
private final int x;
|
private final int x;
|
||||||
@ -12,7 +8,6 @@ public class DeferredBlockReset {
|
|||||||
private final int blockType;
|
private final int blockType;
|
||||||
private final byte blockData;
|
private final byte blockData;
|
||||||
private String[] lines;
|
private String[] lines;
|
||||||
private List<ItemStack> items;
|
|
||||||
|
|
||||||
public DeferredBlockReset(int x, int y, int z, int blockType, byte blockData) {
|
public DeferredBlockReset(int x, int y, int z, int blockType, byte blockData) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@ -21,7 +16,7 @@ public class DeferredBlockReset {
|
|||||||
this.blockType = blockType;
|
this.blockType = blockType;
|
||||||
this.blockData = blockData;
|
this.blockData = blockData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signs
|
// Signs
|
||||||
public DeferredBlockReset(int x, int y, int z, int blockType, byte blockData, String[] signLines) {
|
public DeferredBlockReset(int x, int y, int z, int blockType, byte blockData, String[] signLines) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
@ -55,7 +50,4 @@ public class DeferredBlockReset {
|
|||||||
public String[] getLines() {
|
public String[] getLines() {
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
package com.tommytony.war.spec.volumes;
|
package com.tommytony.war.spec.volumes;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -12,20 +11,13 @@ import static org.mockito.Mockito.*;
|
|||||||
|
|
||||||
import bukkit.tommytony.war.War;
|
import bukkit.tommytony.war.War;
|
||||||
|
|
||||||
import com.tommytony.war.Monument;
|
import com.tommytony.war.*;
|
||||||
import com.tommytony.war.Team;
|
import com.tommytony.war.volumes.*;
|
||||||
import com.tommytony.war.Warzone;
|
|
||||||
import com.tommytony.war.volumes.BlockInfo;
|
|
||||||
import com.tommytony.war.volumes.NotNorthwestException;
|
|
||||||
import com.tommytony.war.volumes.NotSoutheastException;
|
|
||||||
import com.tommytony.war.volumes.TooBigException;
|
|
||||||
import com.tommytony.war.volumes.TooSmallException;
|
|
||||||
import com.tommytony.war.volumes.ZoneVolume;
|
|
||||||
|
|
||||||
public class ZoneVolumeSpecTest {
|
public class ZoneVolumeSpecTest {
|
||||||
|
|
||||||
// setNorthwest
|
// setNorthwest
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreatingAndNoCornersAreSet_shouldSetCorner1AtTop() throws NotNorthwestException, TooSmallException, TooBigException{
|
public void setNorthwest_whenCreatingAndNoCornersAreSet_shouldSetCorner1AtTop() throws NotNorthwestException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -41,10 +33,10 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(0);
|
when(blockMock.getZ()).thenReturn(0);
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
volume.setNorthwest(blockMock);
|
volume.setNorthwest(blockMock);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals(null, volume.getCornerTwo());
|
assertEquals(null, volume.getCornerTwo());
|
||||||
assertEquals(0, volume.getCornerOne().getX());
|
assertEquals(0, volume.getCornerOne().getX());
|
||||||
@ -53,7 +45,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(10, volume.getCornerOne().getTypeId());
|
assertEquals(10, volume.getCornerOne().getTypeId());
|
||||||
assertEquals((byte)2, volume.getCornerOne().getData());
|
assertEquals((byte)2, volume.getCornerOne().getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsToEastOfCorner2_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsToEastOfCorner2_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -69,25 +61,25 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(-64); // further east
|
when(blockMock.getZ()).thenReturn(-64); // further east
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
try {
|
try {
|
||||||
volume.setNorthwest(blockMock);
|
volume.setNorthwest(blockMock);
|
||||||
}
|
}
|
||||||
catch(NotNorthwestException e) {
|
catch(NotNorthwestException e) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertTrue(failed);
|
assertTrue(failed);
|
||||||
assertEquals(null, volume.getCornerOne());
|
assertEquals(null, volume.getCornerOne());
|
||||||
assertEquals(existingCorner2, volume.getCornerTwo());
|
assertEquals(existingCorner2, volume.getCornerTwo());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsToSouthOfCorner2_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsToSouthOfCorner2_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -103,25 +95,25 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(64); // further west
|
when(blockMock.getZ()).thenReturn(64); // further west
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
try {
|
try {
|
||||||
volume.setNorthwest(blockMock);
|
volume.setNorthwest(blockMock);
|
||||||
}
|
}
|
||||||
catch(NotNorthwestException e) {
|
catch(NotNorthwestException e) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertTrue(failed);
|
assertTrue(failed);
|
||||||
assertEquals(null, volume.getCornerOne());
|
assertEquals(null, volume.getCornerOne());
|
||||||
assertEquals(existingCorner2, volume.getCornerTwo());
|
assertEquals(existingCorner2, volume.getCornerTwo());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsTooCloseToCorner2_shouldThrowTooSmallException() throws NotNorthwestException, TooBigException{
|
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsTooCloseToCorner2_shouldThrowTooSmallException() throws NotNorthwestException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -137,25 +129,25 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(5); // further west
|
when(blockMock.getZ()).thenReturn(5); // further west
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
try {
|
try {
|
||||||
volume.setNorthwest(blockMock);
|
volume.setNorthwest(blockMock);
|
||||||
}
|
}
|
||||||
catch(TooSmallException e) {
|
catch(TooSmallException e) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertTrue(failed);
|
assertTrue(failed);
|
||||||
assertEquals(null, volume.getCornerOne());
|
assertEquals(null, volume.getCornerOne());
|
||||||
assertEquals(existingCorner2, volume.getCornerTwo());
|
assertEquals(existingCorner2, volume.getCornerTwo());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsTooFarFromCorner2_shouldThrowTooBigException() throws NotNorthwestException, TooSmallException{
|
public void setNorthwest_whenCreating_AndNoCorner1IsSet_ButCorner2Set_AndNewCornerBlockIsTooFarFromCorner2_shouldThrowTooBigException() throws NotNorthwestException, TooSmallException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -171,25 +163,25 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(1000); // further west
|
when(blockMock.getZ()).thenReturn(1000); // further west
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
try {
|
try {
|
||||||
volume.setNorthwest(blockMock);
|
volume.setNorthwest(blockMock);
|
||||||
}
|
}
|
||||||
catch(TooBigException e) {
|
catch(TooBigException e) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertTrue(failed);
|
assertTrue(failed);
|
||||||
assertEquals(null, volume.getCornerOne());
|
assertEquals(null, volume.getCornerOne());
|
||||||
assertEquals(existingCorner2, volume.getCornerTwo());
|
assertEquals(existingCorner2, volume.getCornerTwo());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreatingAndCorner1AlreadySet_shouldSetCorner2AtTop() throws NotNorthwestException, TooSmallException, TooBigException{ // nw always goes to top
|
public void setNorthwest_whenCreatingAndCorner1AlreadySet_shouldSetCorner2AtTop() throws NotNorthwestException, TooSmallException, TooBigException{ // nw always goes to top
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -205,12 +197,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(64); // further west
|
when(blockMock.getZ()).thenReturn(64); // further west
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner1 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
BlockInfo existingCorner1 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
||||||
volume.setCornerOne(existingCorner1); // corner 1 already set
|
volume.setCornerOne(existingCorner1); // corner 1 already set
|
||||||
volume.setNorthwest(blockMock);
|
volume.setNorthwest(blockMock);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertEquals(0, volume.getCornerOne().getX());
|
assertEquals(0, volume.getCornerOne().getX());
|
||||||
@ -218,14 +210,14 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(0, volume.getCornerOne().getZ());
|
assertEquals(0, volume.getCornerOne().getZ());
|
||||||
assertEquals(4, volume.getCornerOne().getTypeId());
|
assertEquals(4, volume.getCornerOne().getTypeId());
|
||||||
assertEquals((byte)4, volume.getCornerOne().getData());
|
assertEquals((byte)4, volume.getCornerOne().getData());
|
||||||
|
|
||||||
assertEquals(-64, volume.getCornerTwo().getX());
|
assertEquals(-64, volume.getCornerTwo().getX());
|
||||||
assertEquals(127, volume.getCornerTwo().getY()); // the new corner should shoot up to the top
|
assertEquals(127, volume.getCornerTwo().getY()); // the new corner should shoot up to the top
|
||||||
assertEquals(64, volume.getCornerTwo().getZ());
|
assertEquals(64, volume.getCornerTwo().getZ());
|
||||||
assertEquals(10, volume.getCornerTwo().getTypeId());
|
assertEquals(10, volume.getCornerTwo().getTypeId());
|
||||||
assertEquals((byte)2, volume.getCornerTwo().getData());
|
assertEquals((byte)2, volume.getCornerTwo().getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreating_AndCorner1AlreadySet_ButNewCornerBlockIsEastOfCorner1_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
public void setNorthwest_whenCreating_AndCorner1AlreadySet_ButNewCornerBlockIsEastOfCorner1_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -241,25 +233,25 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(-64); // further east
|
when(blockMock.getZ()).thenReturn(-64); // further east
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner1 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
BlockInfo existingCorner1 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
||||||
volume.setCornerOne(existingCorner1); // corner 1 already set
|
volume.setCornerOne(existingCorner1); // corner 1 already set
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
try {
|
try {
|
||||||
volume.setNorthwest(blockMock);
|
volume.setNorthwest(blockMock);
|
||||||
}
|
}
|
||||||
catch(NotNorthwestException e) {
|
catch(NotNorthwestException e) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertTrue(failed);
|
assertTrue(failed);
|
||||||
assertEquals(null, volume.getCornerTwo());
|
assertEquals(null, volume.getCornerTwo());
|
||||||
assertEquals(existingCorner1, volume.getCornerOne());
|
assertEquals(existingCorner1, volume.getCornerOne());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenCreating_AndCorner1AlreadySet_ButNewCornerBlockIsSouthOfCorner1_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
public void setNorthwest_whenCreating_AndCorner1AlreadySet_ButNewCornerBlockIsSouthOfCorner1_shouldThrowNotNorthwestException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -275,25 +267,25 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(64); // further west
|
when(blockMock.getZ()).thenReturn(64); // further west
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner1 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
BlockInfo existingCorner1 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
||||||
volume.setCornerOne(existingCorner1); // corner 1 already set
|
volume.setCornerOne(existingCorner1); // corner 1 already set
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
try {
|
try {
|
||||||
volume.setNorthwest(blockMock);
|
volume.setNorthwest(blockMock);
|
||||||
}
|
}
|
||||||
catch(NotNorthwestException e) {
|
catch(NotNorthwestException e) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertTrue(failed);
|
assertTrue(failed);
|
||||||
assertEquals(null, volume.getCornerTwo());
|
assertEquals(null, volume.getCornerTwo());
|
||||||
assertEquals(existingCorner1, volume.getCornerOne());
|
assertEquals(existingCorner1, volume.getCornerOne());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenChangingVolumeWithCorner1NwCorner2Se_shouldMoveCorner1() throws NotNorthwestException, TooSmallException, TooBigException{
|
public void setNorthwest_whenChangingVolumeWithCorner1NwCorner2Se_shouldMoveCorner1() throws NotNorthwestException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -309,14 +301,14 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(64); // further west
|
when(blockMock.getZ()).thenReturn(64); // further west
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner1 = new BlockInfo(-32, 32, 32, 2, (byte)2); // corner 1 at minX and maxZ (nw)
|
BlockInfo existingCorner1 = new BlockInfo(-32, 32, 32, 2, (byte)2); // corner 1 at minX and maxZ (nw)
|
||||||
volume.setCornerOne(existingCorner1); // corner 1 already set
|
volume.setCornerOne(existingCorner1); // corner 1 already set
|
||||||
BlockInfo existingCorner2 = new BlockInfo(32, 96, -32, 4, (byte)4); // corner 2 at maxX and minZ (se)
|
BlockInfo existingCorner2 = new BlockInfo(32, 96, -32, 4, (byte)4); // corner 2 at maxX and minZ (se)
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
volume.setNorthwest(blockMock);
|
volume.setNorthwest(blockMock);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner should move but not along y
|
// first corner should move but not along y
|
||||||
assertEquals(-64, volume.getCornerOne().getX());
|
assertEquals(-64, volume.getCornerOne().getX());
|
||||||
@ -324,7 +316,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(64, volume.getCornerOne().getZ());
|
assertEquals(64, volume.getCornerOne().getZ());
|
||||||
assertEquals(2, volume.getCornerOne().getTypeId());
|
assertEquals(2, volume.getCornerOne().getTypeId());
|
||||||
assertEquals((byte)2, volume.getCornerOne().getData());
|
assertEquals((byte)2, volume.getCornerOne().getData());
|
||||||
|
|
||||||
// second corner shouldn't move
|
// second corner shouldn't move
|
||||||
assertEquals(32, volume.getCornerTwo().getX());
|
assertEquals(32, volume.getCornerTwo().getX());
|
||||||
assertEquals(96, volume.getCornerTwo().getY()); // moving an existing corner shouldn't change its height
|
assertEquals(96, volume.getCornerTwo().getY()); // moving an existing corner shouldn't change its height
|
||||||
@ -332,7 +324,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(4, volume.getCornerTwo().getTypeId());
|
assertEquals(4, volume.getCornerTwo().getTypeId());
|
||||||
assertEquals((byte)4, volume.getCornerTwo().getData());
|
assertEquals((byte)4, volume.getCornerTwo().getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenChangingVolumeWithCorner1SeCorner2Nw_shouldMoveCorner2() throws NotNorthwestException, TooSmallException, TooBigException{
|
public void setNorthwest_whenChangingVolumeWithCorner1SeCorner2Nw_shouldMoveCorner2() throws NotNorthwestException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -348,14 +340,14 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(64); // further west
|
when(blockMock.getZ()).thenReturn(64); // further west
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner1 = new BlockInfo(32, 32, -32, 2, (byte)2); // corner 1 at maxX and minZ (se)
|
BlockInfo existingCorner1 = new BlockInfo(32, 32, -32, 2, (byte)2); // corner 1 at maxX and minZ (se)
|
||||||
volume.setCornerOne(existingCorner1); // corner 1 already set
|
volume.setCornerOne(existingCorner1); // corner 1 already set
|
||||||
BlockInfo existingCorner2 = new BlockInfo(-32, 96, 32, 4, (byte)4); // corner 2 at minX and maxZ (nw)
|
BlockInfo existingCorner2 = new BlockInfo(-32, 96, 32, 4, (byte)4); // corner 2 at minX and maxZ (nw)
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
volume.setNorthwest(blockMock);
|
volume.setNorthwest(blockMock);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertEquals(32, volume.getCornerOne().getX());
|
assertEquals(32, volume.getCornerOne().getX());
|
||||||
@ -363,7 +355,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(-32, volume.getCornerOne().getZ());
|
assertEquals(-32, volume.getCornerOne().getZ());
|
||||||
assertEquals(2, volume.getCornerOne().getTypeId());
|
assertEquals(2, volume.getCornerOne().getTypeId());
|
||||||
assertEquals((byte)2, volume.getCornerOne().getData());
|
assertEquals((byte)2, volume.getCornerOne().getData());
|
||||||
|
|
||||||
// second corner should move but not along y
|
// second corner should move but not along y
|
||||||
assertEquals(-64, volume.getCornerTwo().getX());
|
assertEquals(-64, volume.getCornerTwo().getX());
|
||||||
assertEquals(96, volume.getCornerTwo().getY()); // moving an existing corner shouldn't change its height
|
assertEquals(96, volume.getCornerTwo().getY()); // moving an existing corner shouldn't change its height
|
||||||
@ -371,7 +363,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(4, volume.getCornerTwo().getTypeId());
|
assertEquals(4, volume.getCornerTwo().getTypeId());
|
||||||
assertEquals((byte)4, volume.getCornerTwo().getData());
|
assertEquals((byte)4, volume.getCornerTwo().getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenChangingVolumeWithCorner1NeCorner2Sw_shouldMoveCorner1XAndCorner2Z() throws NotNorthwestException, TooSmallException, TooBigException{
|
public void setNorthwest_whenChangingVolumeWithCorner1NeCorner2Sw_shouldMoveCorner1XAndCorner2Z() throws NotNorthwestException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -387,14 +379,14 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(64); // further west
|
when(blockMock.getZ()).thenReturn(64); // further west
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner1 = new BlockInfo(-32, 32, -32, 2, (byte)2); // corner 1 at minX and minZ (ne)
|
BlockInfo existingCorner1 = new BlockInfo(-32, 32, -32, 2, (byte)2); // corner 1 at minX and minZ (ne)
|
||||||
volume.setCornerOne(existingCorner1); // corner 1 already set
|
volume.setCornerOne(existingCorner1); // corner 1 already set
|
||||||
BlockInfo existingCorner2 = new BlockInfo(32, 96, 32, 4, (byte)4); // corner 2 at maxX and maxZ (sw)
|
BlockInfo existingCorner2 = new BlockInfo(32, 96, 32, 4, (byte)4); // corner 2 at maxX and maxZ (sw)
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
volume.setNorthwest(blockMock);
|
volume.setNorthwest(blockMock);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner should move along x but not along y or z
|
// first corner should move along x but not along y or z
|
||||||
assertEquals(-64, volume.getCornerOne().getX());
|
assertEquals(-64, volume.getCornerOne().getX());
|
||||||
@ -402,7 +394,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(-32, volume.getCornerOne().getZ());
|
assertEquals(-32, volume.getCornerOne().getZ());
|
||||||
assertEquals(2, volume.getCornerOne().getTypeId());
|
assertEquals(2, volume.getCornerOne().getTypeId());
|
||||||
assertEquals((byte)2, volume.getCornerOne().getData());
|
assertEquals((byte)2, volume.getCornerOne().getData());
|
||||||
|
|
||||||
// second corner should move along z but not along x or y
|
// second corner should move along z but not along x or y
|
||||||
assertEquals(32, volume.getCornerTwo().getX());
|
assertEquals(32, volume.getCornerTwo().getX());
|
||||||
assertEquals(96, volume.getCornerTwo().getY());
|
assertEquals(96, volume.getCornerTwo().getY());
|
||||||
@ -410,7 +402,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(4, volume.getCornerTwo().getTypeId());
|
assertEquals(4, volume.getCornerTwo().getTypeId());
|
||||||
assertEquals((byte)4, volume.getCornerTwo().getData());
|
assertEquals((byte)4, volume.getCornerTwo().getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setNorthwest_whenChangingVolumeWithCorner1SwCorner2Ne_shouldMoveCorner1ZAndCorner2X() throws NotNorthwestException, TooSmallException, TooBigException{
|
public void setNorthwest_whenChangingVolumeWithCorner1SwCorner2Ne_shouldMoveCorner1ZAndCorner2X() throws NotNorthwestException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -426,14 +418,14 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(64); // further west
|
when(blockMock.getZ()).thenReturn(64); // further west
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner1 = new BlockInfo(32, 32, 32, 2, (byte)2); // corner 1 at maxX and maxZ (sw)
|
BlockInfo existingCorner1 = new BlockInfo(32, 32, 32, 2, (byte)2); // corner 1 at maxX and maxZ (sw)
|
||||||
volume.setCornerOne(existingCorner1); // corner 1 already set
|
volume.setCornerOne(existingCorner1); // corner 1 already set
|
||||||
BlockInfo existingCorner2 = new BlockInfo(-32, 96, -32, 4, (byte)4); // corner 2 at minX and minZ (ne)
|
BlockInfo existingCorner2 = new BlockInfo(-32, 96, -32, 4, (byte)4); // corner 2 at minX and minZ (ne)
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
volume.setNorthwest(blockMock);
|
volume.setNorthwest(blockMock);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner should move along z but not along x or y
|
// first corner should move along z but not along x or y
|
||||||
assertEquals(32, volume.getCornerOne().getX());
|
assertEquals(32, volume.getCornerOne().getX());
|
||||||
@ -441,7 +433,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(64, volume.getCornerOne().getZ());
|
assertEquals(64, volume.getCornerOne().getZ());
|
||||||
assertEquals(2, volume.getCornerOne().getTypeId());
|
assertEquals(2, volume.getCornerOne().getTypeId());
|
||||||
assertEquals((byte)2, volume.getCornerOne().getData());
|
assertEquals((byte)2, volume.getCornerOne().getData());
|
||||||
|
|
||||||
// second corner should move along x but not along y or z
|
// second corner should move along x but not along y or z
|
||||||
assertEquals(-64, volume.getCornerTwo().getX());
|
assertEquals(-64, volume.getCornerTwo().getX());
|
||||||
assertEquals(96, volume.getCornerTwo().getY());
|
assertEquals(96, volume.getCornerTwo().getY());
|
||||||
@ -449,13 +441,13 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(4, volume.getCornerTwo().getTypeId());
|
assertEquals(4, volume.getCornerTwo().getTypeId());
|
||||||
assertEquals((byte)4, volume.getCornerTwo().getData());
|
assertEquals((byte)4, volume.getCornerTwo().getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
// getNorthwestX
|
// getNorthwestX
|
||||||
|
|
||||||
// getNorthwestZ
|
// getNorthwestZ
|
||||||
|
|
||||||
// setSoutheast
|
// setSoutheast
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenCreatingAndNoCornersAreSet_shouldSetCorner2AtBottom() throws NotSoutheastException, TooSmallException, TooBigException{
|
public void setSoutheast_whenCreatingAndNoCornersAreSet_shouldSetCorner2AtBottom() throws NotSoutheastException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -471,10 +463,10 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(0);
|
when(blockMock.getZ()).thenReturn(0);
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
volume.setSoutheast(blockMock);
|
volume.setSoutheast(blockMock);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals(null, volume.getCornerOne());
|
assertEquals(null, volume.getCornerOne());
|
||||||
assertEquals(0, volume.getCornerTwo().getX());
|
assertEquals(0, volume.getCornerTwo().getX());
|
||||||
@ -483,7 +475,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(10, volume.getCornerTwo().getTypeId());
|
assertEquals(10, volume.getCornerTwo().getTypeId());
|
||||||
assertEquals((byte)2, volume.getCornerTwo().getData());
|
assertEquals((byte)2, volume.getCornerTwo().getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenCreatingAndNoCorner2IsSet_ButCorner1IsAlreadySet_AndNewCornerBlockIsToWestOfCorner1_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
public void setSoutheast_whenCreatingAndNoCorner2IsSet_ButCorner1IsAlreadySet_AndNewCornerBlockIsToWestOfCorner1_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -499,25 +491,25 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(64); // further west
|
when(blockMock.getZ()).thenReturn(64); // further west
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner1 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
BlockInfo existingCorner1 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
||||||
volume.setCornerOne(existingCorner1); // corner 1 already set
|
volume.setCornerOne(existingCorner1); // corner 1 already set
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
try {
|
try {
|
||||||
volume.setSoutheast(blockMock);
|
volume.setSoutheast(blockMock);
|
||||||
}
|
}
|
||||||
catch(NotSoutheastException e) {
|
catch(NotSoutheastException e) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertTrue(failed);
|
assertTrue(failed);
|
||||||
assertEquals(null, volume.getCornerTwo());
|
assertEquals(null, volume.getCornerTwo());
|
||||||
assertEquals(existingCorner1, volume.getCornerOne());
|
assertEquals(existingCorner1, volume.getCornerOne());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenCreatingAndNoCorner2IsSet_ButCorner1IsAlreadySet_AndNewCornerBlockIsToNorthOfCorner1_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
public void setSoutheast_whenCreatingAndNoCorner2IsSet_ButCorner1IsAlreadySet_AndNewCornerBlockIsToNorthOfCorner1_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -533,25 +525,25 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(-64); // further east
|
when(blockMock.getZ()).thenReturn(-64); // further east
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner1 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
BlockInfo existingCorner1 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
||||||
volume.setCornerOne(existingCorner1); // corner 1 already set
|
volume.setCornerOne(existingCorner1); // corner 1 already set
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
try {
|
try {
|
||||||
volume.setSoutheast(blockMock);
|
volume.setSoutheast(blockMock);
|
||||||
}
|
}
|
||||||
catch(NotSoutheastException e) {
|
catch(NotSoutheastException e) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertTrue(failed);
|
assertTrue(failed);
|
||||||
assertEquals(null, volume.getCornerTwo());
|
assertEquals(null, volume.getCornerTwo());
|
||||||
assertEquals(existingCorner1, volume.getCornerOne());
|
assertEquals(existingCorner1, volume.getCornerOne());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenCreatingAndCorner2AlreadySet_shouldSetCorner1AtBottom() throws NotSoutheastException, TooSmallException, TooBigException{ // se always goes to bottom
|
public void setSoutheast_whenCreatingAndCorner2AlreadySet_shouldSetCorner1AtBottom() throws NotSoutheastException, TooSmallException, TooBigException{ // se always goes to bottom
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -567,12 +559,12 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(-64); // further east
|
when(blockMock.getZ()).thenReturn(-64); // further east
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
volume.setSoutheast(blockMock);
|
volume.setSoutheast(blockMock);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertEquals(0, volume.getCornerTwo().getX());
|
assertEquals(0, volume.getCornerTwo().getX());
|
||||||
@ -580,14 +572,14 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(0, volume.getCornerTwo().getZ());
|
assertEquals(0, volume.getCornerTwo().getZ());
|
||||||
assertEquals(4, volume.getCornerTwo().getTypeId());
|
assertEquals(4, volume.getCornerTwo().getTypeId());
|
||||||
assertEquals((byte)4, volume.getCornerTwo().getData());
|
assertEquals((byte)4, volume.getCornerTwo().getData());
|
||||||
|
|
||||||
assertEquals(64, volume.getCornerOne().getX());
|
assertEquals(64, volume.getCornerOne().getX());
|
||||||
assertEquals(0, volume.getCornerOne().getY()); // the new corner should shoot down
|
assertEquals(0, volume.getCornerOne().getY()); // the new corner should shoot down
|
||||||
assertEquals(-64, volume.getCornerOne().getZ());
|
assertEquals(-64, volume.getCornerOne().getZ());
|
||||||
assertEquals(10, volume.getCornerOne().getTypeId());
|
assertEquals(10, volume.getCornerOne().getTypeId());
|
||||||
assertEquals((byte)2, volume.getCornerOne().getData());
|
assertEquals((byte)2, volume.getCornerOne().getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenCreating_AndCorner2AlreadySet_ButNewCornerBlockIsToWestOfCorner2_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
public void setSoutheast_whenCreating_AndCorner2AlreadySet_ButNewCornerBlockIsToWestOfCorner2_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -603,25 +595,25 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(64); // further west
|
when(blockMock.getZ()).thenReturn(64); // further west
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
try {
|
try {
|
||||||
volume.setSoutheast(blockMock);
|
volume.setSoutheast(blockMock);
|
||||||
}
|
}
|
||||||
catch(NotSoutheastException e) {
|
catch(NotSoutheastException e) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertTrue(failed);
|
assertTrue(failed);
|
||||||
assertEquals(null, volume.getCornerOne());
|
assertEquals(null, volume.getCornerOne());
|
||||||
assertEquals(existingCorner2, volume.getCornerTwo());
|
assertEquals(existingCorner2, volume.getCornerTwo());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenCreating_AndCorner2AlreadySet_ButNewCornerBlockIsToNorthOfCorner2_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
public void setSoutheast_whenCreating_AndCorner2AlreadySet_ButNewCornerBlockIsToNorthOfCorner2_shouldThrowNotSoutheastException() throws TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -637,25 +629,25 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(-64); // further east
|
when(blockMock.getZ()).thenReturn(-64); // further east
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
BlockInfo existingCorner2 = new BlockInfo(0, 64, 0, 4, (byte)4);
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
boolean failed = false;
|
boolean failed = false;
|
||||||
try {
|
try {
|
||||||
volume.setSoutheast(blockMock);
|
volume.setSoutheast(blockMock);
|
||||||
}
|
}
|
||||||
catch(NotSoutheastException e) {
|
catch(NotSoutheastException e) {
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertTrue(failed);
|
assertTrue(failed);
|
||||||
assertEquals(null, volume.getCornerOne());
|
assertEquals(null, volume.getCornerOne());
|
||||||
assertEquals(existingCorner2, volume.getCornerTwo());
|
assertEquals(existingCorner2, volume.getCornerTwo());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenChangingVolumeWithCorner1NwCorner2Se_shouldMoveCorner2() throws NotSoutheastException, TooSmallException, TooBigException{
|
public void setSoutheast_whenChangingVolumeWithCorner1NwCorner2Se_shouldMoveCorner2() throws NotSoutheastException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -671,14 +663,14 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(-64); // further east
|
when(blockMock.getZ()).thenReturn(-64); // further east
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner1 = new BlockInfo(-32, 32, 32, 2, (byte)2); // corner 1 at minX and maxZ (nw)
|
BlockInfo existingCorner1 = new BlockInfo(-32, 32, 32, 2, (byte)2); // corner 1 at minX and maxZ (nw)
|
||||||
volume.setCornerOne(existingCorner1); // corner 1 already set
|
volume.setCornerOne(existingCorner1); // corner 1 already set
|
||||||
BlockInfo existingCorner2 = new BlockInfo(32, 96, -32, 4, (byte)4); // corner 2 at maxX and minZ (se)
|
BlockInfo existingCorner2 = new BlockInfo(32, 96, -32, 4, (byte)4); // corner 2 at maxX and minZ (se)
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
volume.setSoutheast(blockMock);
|
volume.setSoutheast(blockMock);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner shouldn't move
|
// first corner shouldn't move
|
||||||
assertEquals(-32, volume.getCornerOne().getX());
|
assertEquals(-32, volume.getCornerOne().getX());
|
||||||
@ -686,7 +678,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(32, volume.getCornerOne().getZ());
|
assertEquals(32, volume.getCornerOne().getZ());
|
||||||
assertEquals(2, volume.getCornerOne().getTypeId());
|
assertEquals(2, volume.getCornerOne().getTypeId());
|
||||||
assertEquals((byte)2, volume.getCornerOne().getData());
|
assertEquals((byte)2, volume.getCornerOne().getData());
|
||||||
|
|
||||||
// second corner should move but not along y
|
// second corner should move but not along y
|
||||||
assertEquals(64, volume.getCornerTwo().getX());
|
assertEquals(64, volume.getCornerTwo().getX());
|
||||||
assertEquals(96, volume.getCornerTwo().getY());
|
assertEquals(96, volume.getCornerTwo().getY());
|
||||||
@ -694,7 +686,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(4, volume.getCornerTwo().getTypeId());
|
assertEquals(4, volume.getCornerTwo().getTypeId());
|
||||||
assertEquals((byte)4, volume.getCornerTwo().getData());
|
assertEquals((byte)4, volume.getCornerTwo().getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenChangingVolumeWithCorner1SeCorner2Nw_shouldMoveCorner1() throws NotSoutheastException, TooSmallException, TooBigException{
|
public void setSoutheast_whenChangingVolumeWithCorner1SeCorner2Nw_shouldMoveCorner1() throws NotSoutheastException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -710,14 +702,14 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(-64); // further east
|
when(blockMock.getZ()).thenReturn(-64); // further east
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner1 = new BlockInfo(32, 32, -32, 2, (byte)2); // corner 1 at maxX and minZ (se)
|
BlockInfo existingCorner1 = new BlockInfo(32, 32, -32, 2, (byte)2); // corner 1 at maxX and minZ (se)
|
||||||
volume.setCornerOne(existingCorner1); // corner 1 already set
|
volume.setCornerOne(existingCorner1); // corner 1 already set
|
||||||
BlockInfo existingCorner2 = new BlockInfo(-32, 96, 32, 4, (byte)4); // corner 2 at minX and maxZ (nw)
|
BlockInfo existingCorner2 = new BlockInfo(-32, 96, 32, 4, (byte)4); // corner 2 at minX and maxZ (nw)
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
volume.setSoutheast(blockMock);
|
volume.setSoutheast(blockMock);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner should move but not along y
|
// first corner should move but not along y
|
||||||
assertEquals(64, volume.getCornerOne().getX());
|
assertEquals(64, volume.getCornerOne().getX());
|
||||||
@ -725,7 +717,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(-64, volume.getCornerOne().getZ());
|
assertEquals(-64, volume.getCornerOne().getZ());
|
||||||
assertEquals(2, volume.getCornerOne().getTypeId());
|
assertEquals(2, volume.getCornerOne().getTypeId());
|
||||||
assertEquals((byte)2, volume.getCornerOne().getData());
|
assertEquals((byte)2, volume.getCornerOne().getData());
|
||||||
|
|
||||||
// second corner shouldn't move
|
// second corner shouldn't move
|
||||||
assertEquals(-32, volume.getCornerTwo().getX());
|
assertEquals(-32, volume.getCornerTwo().getX());
|
||||||
assertEquals(96, volume.getCornerTwo().getY());
|
assertEquals(96, volume.getCornerTwo().getY());
|
||||||
@ -733,7 +725,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(4, volume.getCornerTwo().getTypeId());
|
assertEquals(4, volume.getCornerTwo().getTypeId());
|
||||||
assertEquals((byte)4, volume.getCornerTwo().getData());
|
assertEquals((byte)4, volume.getCornerTwo().getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenChangingVolumeWithCorner1NeCorner2Sw_shouldMoveCorner1ZAndCorner2X() throws NotSoutheastException, TooSmallException, TooBigException{
|
public void setSoutheast_whenChangingVolumeWithCorner1NeCorner2Sw_shouldMoveCorner1ZAndCorner2X() throws NotSoutheastException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -749,14 +741,14 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(-64); // further east
|
when(blockMock.getZ()).thenReturn(-64); // further east
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner1 = new BlockInfo(-32, 32, -32, 2, (byte)2); // corner 1 at minX and minZ (ne)
|
BlockInfo existingCorner1 = new BlockInfo(-32, 32, -32, 2, (byte)2); // corner 1 at minX and minZ (ne)
|
||||||
volume.setCornerOne(existingCorner1); // corner 1 already set
|
volume.setCornerOne(existingCorner1); // corner 1 already set
|
||||||
BlockInfo existingCorner2 = new BlockInfo(32, 96, 32, 4, (byte)4); // corner 2 at maxX and maxZ (sw)
|
BlockInfo existingCorner2 = new BlockInfo(32, 96, 32, 4, (byte)4); // corner 2 at maxX and maxZ (sw)
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
volume.setSoutheast(blockMock);
|
volume.setSoutheast(blockMock);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner should move along z but not along x or y
|
// first corner should move along z but not along x or y
|
||||||
assertEquals(-32, volume.getCornerOne().getX());
|
assertEquals(-32, volume.getCornerOne().getX());
|
||||||
@ -764,7 +756,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(-64, volume.getCornerOne().getZ());
|
assertEquals(-64, volume.getCornerOne().getZ());
|
||||||
assertEquals(2, volume.getCornerOne().getTypeId());
|
assertEquals(2, volume.getCornerOne().getTypeId());
|
||||||
assertEquals((byte)2, volume.getCornerOne().getData());
|
assertEquals((byte)2, volume.getCornerOne().getData());
|
||||||
|
|
||||||
// second corner should move along x but not along y or z
|
// second corner should move along x but not along y or z
|
||||||
assertEquals(64, volume.getCornerTwo().getX());
|
assertEquals(64, volume.getCornerTwo().getX());
|
||||||
assertEquals(96, volume.getCornerTwo().getY());
|
assertEquals(96, volume.getCornerTwo().getY());
|
||||||
@ -772,7 +764,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(4, volume.getCornerTwo().getTypeId());
|
assertEquals(4, volume.getCornerTwo().getTypeId());
|
||||||
assertEquals((byte)4, volume.getCornerTwo().getData());
|
assertEquals((byte)4, volume.getCornerTwo().getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setSoutheast_whenChangingVolumeWithCorner1SwCorner2Ne_shouldMoveCorner1XAndCorner2Z() throws NotSoutheastException, TooSmallException, TooBigException{
|
public void setSoutheast_whenChangingVolumeWithCorner1SwCorner2Ne_shouldMoveCorner1XAndCorner2Z() throws NotSoutheastException, TooSmallException, TooBigException{
|
||||||
// Arrange
|
// Arrange
|
||||||
@ -788,14 +780,14 @@ public class ZoneVolumeSpecTest {
|
|||||||
when(blockMock.getZ()).thenReturn(-64); // further east
|
when(blockMock.getZ()).thenReturn(-64); // further east
|
||||||
when(blockMock.getTypeId()).thenReturn(10);
|
when(blockMock.getTypeId()).thenReturn(10);
|
||||||
when(blockMock.getData()).thenReturn((byte)2);
|
when(blockMock.getData()).thenReturn((byte)2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
BlockInfo existingCorner1 = new BlockInfo(32, 32, 32, 2, (byte)2); // corner 1 at maxX and maxZ (sw)
|
BlockInfo existingCorner1 = new BlockInfo(32, 32, 32, 2, (byte)2); // corner 1 at maxX and maxZ (sw)
|
||||||
volume.setCornerOne(existingCorner1); // corner 1 already set
|
volume.setCornerOne(existingCorner1); // corner 1 already set
|
||||||
BlockInfo existingCorner2 = new BlockInfo(-32, 96, -32, 4, (byte)4); // corner 2 at minX and minZ (ne)
|
BlockInfo existingCorner2 = new BlockInfo(-32, 96, -32, 4, (byte)4); // corner 2 at minX and minZ (ne)
|
||||||
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
volume.setCornerTwo(existingCorner2); // corner 2 already set
|
||||||
volume.setSoutheast(blockMock);
|
volume.setSoutheast(blockMock);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
// first corner should move along x but not along y or z
|
// first corner should move along x but not along y or z
|
||||||
assertEquals(64, volume.getCornerOne().getX());
|
assertEquals(64, volume.getCornerOne().getX());
|
||||||
@ -803,7 +795,7 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(32, volume.getCornerOne().getZ());
|
assertEquals(32, volume.getCornerOne().getZ());
|
||||||
assertEquals(2, volume.getCornerOne().getTypeId());
|
assertEquals(2, volume.getCornerOne().getTypeId());
|
||||||
assertEquals((byte)2, volume.getCornerOne().getData());
|
assertEquals((byte)2, volume.getCornerOne().getData());
|
||||||
|
|
||||||
// second corner should move along z but not along x or y
|
// second corner should move along z but not along x or y
|
||||||
assertEquals(-32, volume.getCornerTwo().getX());
|
assertEquals(-32, volume.getCornerTwo().getX());
|
||||||
assertEquals(96, volume.getCornerTwo().getY());
|
assertEquals(96, volume.getCornerTwo().getY());
|
||||||
@ -811,13 +803,13 @@ public class ZoneVolumeSpecTest {
|
|||||||
assertEquals(4, volume.getCornerTwo().getTypeId());
|
assertEquals(4, volume.getCornerTwo().getTypeId());
|
||||||
assertEquals((byte)4, volume.getCornerTwo().getData());
|
assertEquals((byte)4, volume.getCornerTwo().getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
// getSoutheastX
|
// getSoutheastX
|
||||||
|
|
||||||
// getSoutheastZ
|
// getSoutheastZ
|
||||||
|
|
||||||
// setCornerOne
|
// setCornerOne
|
||||||
|
|
||||||
// setCornerTwo
|
// setCornerTwo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user