mirror of
https://github.com/taoneill/war.git
synced 2025-03-11 06:00:48 +01:00
Remaining volumes mapping to files. Cleanup of old block state handling.
This commit is contained in:
parent
20032dddbf
commit
9204df2dc2
@ -132,45 +132,20 @@ public class Monument {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setInitialState(int[] initialState) {
|
||||
this.initialState = initialState;
|
||||
}
|
||||
|
||||
public int[] getInitialState() {
|
||||
return initialState;
|
||||
}
|
||||
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
volume.setCenter(warzone.getWorld().getBlockAt(x, y, z)); // resets the volume blocks
|
||||
|
||||
((CenteredVolume)volume).setCenter(warzone.getWorld().getBlockAt(x, y, z)); // resets the volume blocks
|
||||
this.addMonumentBlocks();
|
||||
}
|
||||
|
||||
public boolean contains(Block block) {
|
||||
int x = location.getBlockX();
|
||||
int y = location.getBlockY();
|
||||
int z = location.getBlockZ();
|
||||
int bx = block.getX();
|
||||
int by = block.getY();
|
||||
int bz = block.getZ();
|
||||
if(/*(bx == x && by == y && bz == z) ||*/
|
||||
(bx == x+1 && by == y-1 && bz == z+1) ||
|
||||
(bx == x+1 && by == y-1 && bz == z) ||
|
||||
(bx == x+1 && by == y-1 && bz == z-1) ||
|
||||
(bx == x && by == y-1 && bz == z+1) ||
|
||||
(bx == x && by == y-1 && bz == z) ||
|
||||
(bx == x && by == y-1 && bz == z-1) ||
|
||||
(bx == x-1 && by == y-1 && bz == z+1) ||
|
||||
(bx == x-1 && by == y-1 && bz == z) ||
|
||||
(bx == x-1 && by == y-1 && bz == z-1) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
public Volume getVolume() {
|
||||
// TODO Auto-generated method stub
|
||||
return volume;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ public class Team {
|
||||
private String name;
|
||||
private int remainingTickets;
|
||||
private int startTickets;
|
||||
private int[] oldSpawnState = new int[10];
|
||||
private int points = 0;
|
||||
private CenteredVolume volume;
|
||||
private final War war;
|
||||
@ -126,14 +125,6 @@ public class Team {
|
||||
public int getRemainingTickets() {
|
||||
return remainingTickets;
|
||||
}
|
||||
|
||||
public int[] getOldSpawnState() {
|
||||
return oldSpawnState;
|
||||
}
|
||||
|
||||
public void setOldSpawnState(int[] oldSpawnState) {
|
||||
this.oldSpawnState = oldSpawnState;
|
||||
}
|
||||
|
||||
public void addPoint() {
|
||||
points++;
|
||||
@ -143,28 +134,6 @@ public class Team {
|
||||
return points;
|
||||
}
|
||||
|
||||
public boolean contains(Block block) {
|
||||
int x = teamSpawn.getBlockX();
|
||||
int y = teamSpawn.getBlockY();
|
||||
int z = teamSpawn.getBlockZ();
|
||||
int bx = block.getX();
|
||||
int by = block.getY();
|
||||
int bz = block.getZ();
|
||||
if((bx == x && by == y && bz == z) ||
|
||||
(bx == x+1 && by == y-1 && bz == z+1) ||
|
||||
(bx == x+1 && by == y-1 && bz == z) ||
|
||||
(bx == x+1 && by == y-1 && bz == z-1) ||
|
||||
(bx == x && by == y-1 && bz == z+1) ||
|
||||
(bx == x && by == y-1 && bz == z) ||
|
||||
(bx == x && by == y-1 && bz == z-1) ||
|
||||
(bx == x-1 && by == y-1 && bz == z+1) ||
|
||||
(bx == x-1 && by == y-1 && bz == z) ||
|
||||
(bx == x-1 && by == y-1 && bz == z-1) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public CenteredVolume getVolume() {
|
||||
|
||||
return volume;
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlacedEvent;
|
||||
|
||||
|
||||
public class WarBlockListener extends BlockListener {
|
||||
|
||||
private War war;
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.event.entity.EntityDamagedByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamagedByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
|
||||
|
||||
public class WarEntityListener extends EntityListener {
|
||||
|
||||
private final War war;
|
||||
|
@ -331,12 +331,12 @@ public class Warzone {
|
||||
public boolean isImportantBlock(Block block) {
|
||||
block.getX();
|
||||
for(Monument m : monuments) {
|
||||
if(m.contains(block)){
|
||||
if(m.getVolume().contains(block)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for(Team t : teams) {
|
||||
if(t.contains(block)){
|
||||
if(t.getVolume().contains(block)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.tommytony.war;
|
||||
package com.tommytony.war.mappers;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
@ -2,7 +2,6 @@ package com.tommytony.war.mappers;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.tommytony.war.PropertiesFile;
|
||||
import com.tommytony.war.War;
|
||||
import com.tommytony.war.Warzone;
|
||||
|
||||
|
@ -3,10 +3,10 @@ package com.tommytony.war.mappers;
|
||||
import org.bukkit.*;
|
||||
|
||||
import com.tommytony.war.Monument;
|
||||
import com.tommytony.war.PropertiesFile;
|
||||
import com.tommytony.war.Team;
|
||||
import com.tommytony.war.War;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.volumes.CenteredVolume;
|
||||
import com.tommytony.war.volumes.VerticalVolume;
|
||||
import com.tommytony.war.volumes.Volume;
|
||||
|
||||
@ -143,23 +143,14 @@ public class WarzoneMapper {
|
||||
|
||||
// monument blocks
|
||||
for(Monument monument: warzone.getMonuments()) {
|
||||
Volume monumentVolume = new Volume(monument.getName(), war, warzone);
|
||||
String monumentBlocksStr = warzoneBlocksFile.getString("monument"+monument.getName()+"Blocks");
|
||||
monumentVolume.blocksFromString(monumentBlocksStr);
|
||||
monument.getVolume().blocksFromString(monumentBlocksStr);
|
||||
}
|
||||
|
||||
// team spawn blocks
|
||||
for(Team team : warzone.getTeams()) {
|
||||
String teamBlocksStr = warzoneBlocksFile.getString("team"+team.getName()+"Blocks");
|
||||
String[] teamBlocksSplit = teamBlocksStr.split(",");
|
||||
int[] teamState = new int[10];
|
||||
for(int i = 0; i < teamBlocksSplit.length; i++) {
|
||||
String split = teamBlocksSplit[i];
|
||||
if(split != null && !split.equals("")) {
|
||||
teamState[i] = Integer.parseInt(split);
|
||||
}
|
||||
}
|
||||
team.setOldSpawnState(teamState);
|
||||
team.getVolume().blocksFromString(teamBlocksStr);
|
||||
}
|
||||
|
||||
warzoneBlocksFile.close();
|
||||
@ -248,19 +239,13 @@ public class WarzoneMapper {
|
||||
|
||||
// monument blocks
|
||||
for(Monument monument: monuments) {
|
||||
String monumentBlocksStr = "";
|
||||
for(int type : monument.getInitialState()) {
|
||||
monumentBlocksStr += type + ",";
|
||||
}
|
||||
String monumentBlocksStr = monument.getVolume().blocksToString();
|
||||
warzoneBlocksFile.setString("monument"+monument.getName()+"Blocks", monumentBlocksStr);
|
||||
}
|
||||
|
||||
// team spawn blocks
|
||||
for(Team team : teams) {
|
||||
String teamBlocksStr = "";
|
||||
for(int type : team.getOldSpawnState()) {
|
||||
teamBlocksStr += type + ",";
|
||||
}
|
||||
String teamBlocksStr = team.getVolume().blocksToString();
|
||||
warzoneBlocksFile.setString("team"+team.getName()+"Blocks", teamBlocksStr);
|
||||
}
|
||||
|
||||
|
@ -263,4 +263,13 @@ public class Volume {
|
||||
z <= getMaxZ() && z >= getMinZ();
|
||||
}
|
||||
|
||||
public boolean contains(Block block) {
|
||||
int x = block.getX();
|
||||
int y = block.getY();
|
||||
int z = block.getZ();
|
||||
return x <= getMaxX() && x >= getMinX() &&
|
||||
y <= getMaxY() && y >= getMinY() &&
|
||||
z <= getMaxZ() && z >= getMinZ();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user