mirror of
https://github.com/taoneill/war.git
synced 2024-11-23 18:55:28 +01:00
Less memory usage for zone block storage. savezone and setzoneconfig fixes for named params. Resetting lobby more often. v0.3 finish line is getting much closer.
This commit is contained in:
parent
6f2b7c92c4
commit
d24709bbd6
@ -342,6 +342,7 @@ public class War extends JavaPlugin {
|
||||
} else {
|
||||
int reset = warzone.getVolume().resetBlocks();
|
||||
warzone.setNorthwest(player.getLocation());
|
||||
player.sendMessage(this.str("Saving warzone " + warzone.getName() + "."));
|
||||
warzone.saveState();
|
||||
warzone.initializeZone();
|
||||
message += "Northwesternmost point set at x=" + (int)warzone.getNorthwest().getBlockX()
|
||||
@ -356,6 +357,7 @@ public class War extends JavaPlugin {
|
||||
} else {
|
||||
int reset = warzone.getVolume().resetBlocks();
|
||||
warzone.setSoutheast(player.getLocation());
|
||||
player.sendMessage(this.str("Saving warzone " + warzone.getName() + "."));
|
||||
warzone.saveState();
|
||||
warzone.initializeZone();
|
||||
|
||||
@ -453,6 +455,7 @@ public class War extends JavaPlugin {
|
||||
} else {
|
||||
lobby = warzone.getLobby();
|
||||
}
|
||||
player.sendMessage(this.str("Saving warzone " + warzone.getName() + "."));
|
||||
int savedBlocks = warzone.saveState();
|
||||
if(warzone.getLobby() == null) {
|
||||
// Set default lobby on south side
|
||||
@ -467,7 +470,12 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
updateZoneFromNamedParams(warzone, arguments);
|
||||
WarzoneMapper.save(this, warzone, true);
|
||||
warzone.getVolume().resetBlocks();
|
||||
if(lobby != null) {
|
||||
lobby.getVolume().resetBlocks();
|
||||
}
|
||||
warzone.initializeZone(); // bring back team spawns etc
|
||||
|
||||
player.sendMessage(this.str("Warzone " + warzone.getName() + " initial state changed. Saved " + savedBlocks + " blocks."));
|
||||
}
|
||||
}
|
||||
@ -477,7 +485,7 @@ public class War extends JavaPlugin {
|
||||
if((!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation()))
|
||||
|| arguments.length == 0) {
|
||||
player.sendMessage(this.str("Usage: /setzoneconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on " +
|
||||
"Please give at leaset one named parameter. Does not save the blocks of the warzone. Must be in warzone."));
|
||||
"Please give at leaset one named parameter. Does not save the blocks of the warzone. Resets the zone with the new config. Must be in warzone."));
|
||||
} else {
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
ZoneLobby lobby = this.lobby(player.getLocation());
|
||||
@ -487,6 +495,7 @@ public class War extends JavaPlugin {
|
||||
lobby = warzone.getLobby();
|
||||
}
|
||||
if(updateZoneFromNamedParams(warzone, arguments)) {
|
||||
player.sendMessage(this.str("Saving config and resetting warzone " + warzone.getName() + "."));
|
||||
WarzoneMapper.save(this, warzone, false);
|
||||
warzone.getVolume().resetBlocks();
|
||||
if(lobby != null) {
|
||||
@ -523,16 +532,24 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
|
||||
Warzone resetWarzone = null;
|
||||
player.sendMessage(this.str("Reloading warzone " + warzone.getName() + "."));
|
||||
if(arguments.length == 1 && (arguments[0].equals("hard") || arguments[0].equals("h"))) {
|
||||
// reset from disk
|
||||
this.getWarzones().remove(warzone);
|
||||
resetWarzone = WarzoneMapper.load(this, warzone.getName(), true);
|
||||
this.getWarzones().add(resetWarzone);
|
||||
warzone.getVolume().resetBlocks();
|
||||
if(lobby!=null) {
|
||||
lobby.getVolume().resetBlocks();
|
||||
}
|
||||
resetWarzone.initializeZone();
|
||||
} else {
|
||||
resetBlocks = warzone.getVolume().resetBlocks();
|
||||
if(lobby!=null) {
|
||||
lobby.getVolume().resetBlocks();
|
||||
}
|
||||
warzone.initializeZone();
|
||||
|
||||
}
|
||||
|
||||
player.sendMessage(this.str("Warzone and teams reset. " + resetBlocks + " blocks reset."));
|
||||
@ -543,9 +560,9 @@ public class War extends JavaPlugin {
|
||||
// /deletezone
|
||||
else if(command.equals("deletezone")) {
|
||||
if(!this.inAnyWarzone(player.getLocation()) && !this.inAnyWarzoneLobby(player.getLocation())) {
|
||||
player.sendMessage(this.str("Usage: /deletewarzone." +
|
||||
" Deletes the warzone. " +
|
||||
"Must be in the warzone (try /warzones and /warzone). "));
|
||||
player.sendMessage(this.str("Usage: /deletewarzone. " +
|
||||
"Deletes the warzone. " +
|
||||
"Must be in the warzone (try /zones and /zone). "));
|
||||
} else {
|
||||
Warzone warzone = this.warzone(player.getLocation());
|
||||
ZoneLobby lobby = this.lobby(player.getLocation());
|
||||
@ -579,8 +596,8 @@ public class War extends JavaPlugin {
|
||||
else if(command.equals("setteam")) {
|
||||
if(arguments.length < 1 || !this.inAnyWarzone(player.getLocation())
|
||||
|| (arguments.length > 0 && TeamMaterials.teamMaterialFromString(arguments[0]) == null)) {
|
||||
player.sendMessage(this.str("Usage: /setteam <diamond/iron/gold/d/i/g>." +
|
||||
" Sets the team spawn to the current location. " +
|
||||
player.sendMessage(this.str("Usage: /setteam <diamond/iron/gold/d/i/g>. " +
|
||||
"Sets the team spawn to the current location. " +
|
||||
"Must be in a warzone (try /zones and /zone). "));
|
||||
} else {
|
||||
Material teamMaterial = TeamMaterials.teamMaterialFromString(arguments[0]);
|
||||
@ -840,19 +857,24 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
if(namedParams.containsKey("lifepool")){
|
||||
warzone.setLifePool(Integer.parseInt(namedParams.get("lifepool")));
|
||||
} else if(namedParams.containsKey("teamsize")){
|
||||
}
|
||||
if(namedParams.containsKey("teamsize")){
|
||||
warzone.setTeamCap(Integer.parseInt(namedParams.get("teamsize")));
|
||||
} else if(namedParams.containsKey("maxscore")){
|
||||
}
|
||||
if(namedParams.containsKey("maxscore")){
|
||||
warzone.setScoreCap(Integer.parseInt(namedParams.get("maxscore")));
|
||||
} else if(namedParams.containsKey("ff")){
|
||||
}
|
||||
if(namedParams.containsKey("ff")){
|
||||
String onOff = namedParams.get("ff");
|
||||
warzone.setFriendlyFire(onOff.equals("on"));
|
||||
} else if(namedParams.containsKey("autoassign")){
|
||||
warzone.setFriendlyFire(onOff.equals("on") || onOff.equals("true"));
|
||||
}
|
||||
if(namedParams.containsKey("autoassign")){
|
||||
String onOff = namedParams.get("autoassign");
|
||||
warzone.setAutoAssignOnly(onOff.equals("on"));
|
||||
} else if(namedParams.containsKey("outline")){
|
||||
warzone.setAutoAssignOnly(onOff.equals("on") || onOff.equals("true"));
|
||||
}
|
||||
if(namedParams.containsKey("outline")){
|
||||
String onOff = namedParams.get("outline");
|
||||
warzone.setDrawZoneOutline(onOff.equals("on"));
|
||||
warzone.setDrawZoneOutline(onOff.equals("on") || onOff.equals("true"));
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
@ -871,22 +893,28 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
if(namedParams.containsKey("lifepool")){
|
||||
setDefaultLifepool(Integer.parseInt(namedParams.get("lifepool")));
|
||||
} else if(namedParams.containsKey("teamsize")){
|
||||
}
|
||||
if(namedParams.containsKey("teamsize")){
|
||||
setDefaultTeamCap(Integer.parseInt(namedParams.get("teamsize")));
|
||||
} else if(namedParams.containsKey("maxscore")){
|
||||
}
|
||||
if(namedParams.containsKey("maxscore")){
|
||||
setDefaultScoreCap(Integer.parseInt(namedParams.get("maxscore")));
|
||||
} else if(namedParams.containsKey("ff")){
|
||||
}
|
||||
if(namedParams.containsKey("ff")){
|
||||
String onOff = namedParams.get("ff");
|
||||
setDefaultFriendlyFire(onOff.equals("on"));
|
||||
} else if(namedParams.containsKey("autoassign")){
|
||||
}
|
||||
if(namedParams.containsKey("autoassign")){
|
||||
String onOff = namedParams.get("autoassign");
|
||||
setDefaultAutoAssignOnly(onOff.equals("on"));
|
||||
} else if(namedParams.containsKey("outline")){
|
||||
setDefaultAutoAssignOnly(onOff.equals("on") || onOff.equals("true"));
|
||||
}
|
||||
if(namedParams.containsKey("outline")){
|
||||
String onOff = namedParams.get("outline");
|
||||
setDefaultDrawZoneOutline(onOff.equals("on"));
|
||||
} else if(namedParams.containsKey("pvpinzonesonly")){
|
||||
setDefaultDrawZoneOutline(onOff.equals("on") || onOff.equals("true"));
|
||||
}
|
||||
if(namedParams.containsKey("pvpinzonesonly")){
|
||||
String onOff = namedParams.get("pvpinzonesonly");
|
||||
setDefaultDrawZoneOutline(onOff.equals("on"));
|
||||
setDefaultDrawZoneOutline(onOff.equals("on") || onOff.equals("true"));
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
@ -103,7 +103,7 @@ public class WarHub {
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, "War hub");
|
||||
sign.setLine(1, "");
|
||||
sign.setLine(2, "Pick you battle!");
|
||||
sign.setLine(2, "Pick your battle!");
|
||||
sign.setLine(3, "");
|
||||
state.update(true);
|
||||
}
|
||||
|
@ -441,11 +441,12 @@ public class Warzone {
|
||||
|
||||
public void restorePlayerInventory(Player player) {
|
||||
ItemStack[] originalContents = inventories.remove(player.getName());
|
||||
PlayerInventory playerInv = player.getInventory();
|
||||
playerInv.clear();
|
||||
playerInv.setHelmet(new ItemStack(0));
|
||||
playerInv.setBoots(new ItemStack(0));
|
||||
playerInv.setContents(originalContents);
|
||||
if(originalContents != null) {
|
||||
PlayerInventory playerInv = player.getInventory();
|
||||
playerInv.clear();
|
||||
playerInv.setHelmet(new ItemStack(0));
|
||||
playerInv.setContents(originalContents);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasMonument(String monumentName) {
|
||||
|
@ -205,6 +205,9 @@ public class ZoneLobby {
|
||||
}
|
||||
if(warzone.getAutoAssignOnly()){
|
||||
autoAssignGate = lobbyMiddleWallBlock;
|
||||
diamondGate = null;
|
||||
ironGate = null;
|
||||
goldGate = null;
|
||||
} else if(warzone.getTeams().size() == 1) {
|
||||
if(warzone.getTeamByMaterial(TeamMaterials.TEAMDIAMOND) != null) {
|
||||
diamondGate = lobbyMiddleWallBlock;
|
||||
|
@ -55,7 +55,8 @@ public class VolumeMapper {
|
||||
volume.setCornerOne(world.getBlockAt(x1, y1, z1));
|
||||
volume.setCornerTwo(world.getBlockAt(x2, y2, z2));
|
||||
|
||||
volume.setBlockInfos(new BlockInfo[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()]);
|
||||
for(int i = 0; i < volume.getSizeX(); i++){
|
||||
for(int j = 0; j < volume.getSizeY(); j++) {
|
||||
for(int k = 0; k < volume.getSizeZ(); k++) {
|
||||
@ -65,22 +66,24 @@ public class VolumeMapper {
|
||||
int typeID = Integer.parseInt(blockSplit[0]);
|
||||
byte data = Byte.parseByte(blockSplit[1]);
|
||||
String[] lines = null;
|
||||
if(typeID == Material.SIGN.getId() || typeID == Material.SIGN_POST.getId()) {
|
||||
String signLines = blockSplit[2];
|
||||
if(blockSplit.length > 3) {
|
||||
// sign includes commas
|
||||
for(int splitI = 3; splitI < blockSplit.length; splitI++) {
|
||||
signLines.concat(blockSplit[splitI]);
|
||||
}
|
||||
}
|
||||
String[] signLinesSplit = signLines.split("[line]");
|
||||
lines = new String[4];
|
||||
lines[0] = signLinesSplit[0];
|
||||
lines[1] = signLinesSplit[1];
|
||||
lines[2] = signLinesSplit[2];
|
||||
lines[3] = signLinesSplit[3];
|
||||
}
|
||||
volume.getBlockInfos()[i][j][k] = new BlockInfo(typeID, data, lines);
|
||||
// if(typeID == Material.SIGN.getId() || typeID == Material.SIGN_POST.getId()) {
|
||||
// String signLines = blockSplit[2];
|
||||
// if(blockSplit.length > 3) {
|
||||
// // sign includes commas
|
||||
// for(int splitI = 3; splitI < blockSplit.length; splitI++) {
|
||||
// signLines.concat(blockSplit[splitI]);
|
||||
// }
|
||||
// }
|
||||
// String[] signLinesSplit = signLines.split("[line]");
|
||||
// lines = new String[4];
|
||||
// lines[0] = signLinesSplit[0];
|
||||
// lines[1] = signLinesSplit[1];
|
||||
// lines[2] = signLinesSplit[2];
|
||||
// lines[3] = signLinesSplit[3];
|
||||
// }
|
||||
//volume.getBlockTypes()[i][j][k] = new BlockInfo(typeID, data, lines);
|
||||
volume.getBlockTypes()[i][j][k] = typeID;
|
||||
volume.getBlockDatas()[i][j][k] = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -103,7 +106,7 @@ public class VolumeMapper {
|
||||
}
|
||||
|
||||
public static void save(Volume volume, String zoneName, War war) {
|
||||
if(volume.isSaved() && volume.getBlockInfos() != null) {
|
||||
if(volume.isSaved() && volume.getBlockTypes() != null) {
|
||||
BufferedWriter out = null;
|
||||
try {
|
||||
if(zoneName.equals("")) out = new BufferedWriter(new FileWriter(new File("War/dat/volume-" + volume.getName() + ".dat")));
|
||||
@ -121,19 +124,22 @@ public class VolumeMapper {
|
||||
for(int i = 0; i < volume.getSizeX(); i++){
|
||||
for(int j = 0; j < volume.getSizeY(); j++) {
|
||||
for(int k = 0; k < volume.getSizeZ(); k++) {
|
||||
BlockInfo info = volume.getBlockInfos()[i][j][k];
|
||||
if(info == null) {
|
||||
out.write("0,0,");
|
||||
} else {
|
||||
if(info.getType() == Material.SIGN || info.getType() == Material.SIGN_POST) {
|
||||
String[] lines = info.getSignLines();
|
||||
out.write(info.getTypeId() + "," + info.getData() + "," + lines[0] + "[line]" + lines[1]
|
||||
+ "[line]" + lines[2] + "[line]"+ lines[3]);
|
||||
|
||||
} else {
|
||||
out.write(info.getTypeId() + "," + info.getData() + ",");
|
||||
}
|
||||
}
|
||||
int typeId = volume.getBlockTypes()[i][j][k];
|
||||
byte data = volume.getBlockDatas()[i][j][k];
|
||||
out.write(typeId + "," + data + ",");
|
||||
//BlockInfo info = volume.getBlockTypes()[i][j][k];
|
||||
// if(info == null) {
|
||||
// out.write("0,0,");
|
||||
// } else {
|
||||
// if(info.getType() == Material.SIGN || info.getType() == Material.SIGN_POST) {
|
||||
// String[] lines = info.getSignLines();
|
||||
// out.write(info.getTypeId() + "," + info.getData() + "," + lines[0] + "[line]" + lines[1]
|
||||
// + "[line]" + lines[2] + "[line]"+ lines[3]);
|
||||
//
|
||||
// } else {
|
||||
// out.write(info.getTypeId() + "," + info.getData() + ",");
|
||||
//}
|
||||
// }
|
||||
out.newLine();
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class BlockInfo {
|
||||
// private int z;
|
||||
private int type;
|
||||
private byte data;
|
||||
private String[] signLines;
|
||||
//private String[] signLines;
|
||||
|
||||
public BlockInfo(Block block) {
|
||||
// this.x = block.getX();
|
||||
@ -24,10 +24,10 @@ public class BlockInfo {
|
||||
// this.z = block.getX();
|
||||
this.type = block.getTypeId();
|
||||
this.data = block.getData();
|
||||
if(is(Material.SIGN) || is(Material.SIGN_POST)) {
|
||||
Sign sign = (Sign)block.getState();
|
||||
this.signLines = sign.getLines();
|
||||
}
|
||||
// if(is(Material.SIGN) || is(Material.SIGN_POST)) {
|
||||
// Sign sign = (Sign)block.getState();
|
||||
// this.signLines = sign.getLines();
|
||||
// }
|
||||
}
|
||||
|
||||
public BlockInfo(BlockState blockState) {
|
||||
@ -36,16 +36,16 @@ public class BlockInfo {
|
||||
// this.z = blockState.getX();
|
||||
this.type = blockState.getTypeId();
|
||||
this.data = blockState.getData().getData();
|
||||
if(is(Material.SIGN) || is(Material.SIGN_POST)) {
|
||||
Sign sign = (Sign)blockState;
|
||||
this.signLines = sign.getLines();
|
||||
}
|
||||
// if(is(Material.SIGN) || is(Material.SIGN_POST)) {
|
||||
// Sign sign = (Sign)blockState;
|
||||
// this.signLines = sign.getLines();
|
||||
// }
|
||||
}
|
||||
|
||||
public BlockInfo(int typeID, byte data, String[] lines) {
|
||||
type = typeID;
|
||||
this.data = data;
|
||||
signLines = lines;
|
||||
//signLines = lines;
|
||||
}
|
||||
|
||||
// public int getX() {
|
||||
@ -76,10 +76,10 @@ public class BlockInfo {
|
||||
return getType() == material;
|
||||
}
|
||||
|
||||
public String[] getSignLines() {
|
||||
if(is(Material.SIGN) || is(Material.SIGN_POST)){
|
||||
return signLines;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// public String[] getSignLines() {
|
||||
// if(is(Material.SIGN) || is(Material.SIGN_POST)){
|
||||
// return new String[4] {"", ""};
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class VerticalVolume extends Volume{
|
||||
public int resetWallBlocks(BlockFace wall) {
|
||||
int noOfResetBlocks = 0;
|
||||
try {
|
||||
if(hasTwoCorners() && getBlockInfos() != null) {
|
||||
if(hasTwoCorners() && getBlockTypes() != null) {
|
||||
if(wall == BlockFace.EAST) {
|
||||
int z = getMinZ();
|
||||
int k = 0;
|
||||
@ -86,13 +86,12 @@ public class VerticalVolume extends Volume{
|
||||
for(int j = 0; j < getSizeY(); j++) {
|
||||
int x = getMinX();
|
||||
for(int i = 0; i < getSizeX(); i++) {
|
||||
BlockInfo oldBlockInfo = getBlockInfos()[i][j][k];
|
||||
if(oldBlockInfo != null) {
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if(resetBlock(oldBlockInfo, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
}
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if(resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
y++;
|
||||
@ -104,12 +103,11 @@ public class VerticalVolume extends Volume{
|
||||
for(int j = 0; j < getSizeY(); j++) {
|
||||
int x = getMinX();
|
||||
for(int i = 0; i < getSizeX(); i++) {
|
||||
BlockInfo oldBlockInfo = getBlockInfos()[i][j][k];
|
||||
if(oldBlockInfo != null) {
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if(resetBlock(oldBlockInfo, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if(resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
x++;
|
||||
}
|
||||
@ -122,12 +120,11 @@ public class VerticalVolume extends Volume{
|
||||
for(int j = 0; j < getSizeY(); j++) {
|
||||
int z = getMinZ();
|
||||
for(int k = 0; k < getSizeZ(); k++) {
|
||||
BlockInfo oldBlockInfo = getBlockInfos()[i][j][k];
|
||||
if(oldBlockInfo != null) {
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if(resetBlock(oldBlockInfo, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if(resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
z++;
|
||||
}
|
||||
@ -140,12 +137,11 @@ public class VerticalVolume extends Volume{
|
||||
for(int j = 0; j < getSizeY(); j++) {
|
||||
int z = getMinZ();
|
||||
for(int k = 0; k < getSizeZ(); k++) {
|
||||
BlockInfo oldBlockInfo = getBlockInfos()[i][j][k];
|
||||
if(oldBlockInfo != null) {
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if(resetBlock(oldBlockInfo, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if(resetBlock(oldBlockType, oldBlockData, currentBlock)) {
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
z++;
|
||||
}
|
||||
@ -159,24 +155,24 @@ public class VerticalVolume extends Volume{
|
||||
return noOfResetBlocks;
|
||||
}
|
||||
|
||||
private boolean resetBlock(BlockInfo oldBlockInfo, Block currentBlock) {
|
||||
if(currentBlock.getTypeId() != oldBlockInfo.getTypeId() ||
|
||||
(currentBlock.getTypeId() == oldBlockInfo.getTypeId() && currentBlock.getData() != oldBlockInfo.getData()) ||
|
||||
(currentBlock.getTypeId() == oldBlockInfo.getTypeId() && currentBlock.getData() == oldBlockInfo.getData() &&
|
||||
(oldBlockInfo.is(Material.SIGN) || oldBlockInfo.is(Material.SIGN_POST))
|
||||
private boolean resetBlock(int oldBlockType, byte oldBlockData, Block currentBlock) {
|
||||
if(currentBlock.getTypeId() != oldBlockType ||
|
||||
(currentBlock.getTypeId() == oldBlockType && currentBlock.getData() != oldBlockData) ||
|
||||
(currentBlock.getTypeId() == oldBlockType && currentBlock.getData() == oldBlockData &&
|
||||
(oldBlockType == Material.SIGN.getId() || oldBlockType == Material.SIGN_POST.getId())
|
||||
)
|
||||
) {
|
||||
currentBlock.setType(oldBlockInfo.getType());
|
||||
currentBlock.setData(oldBlockInfo.getData());
|
||||
if(oldBlockInfo.is(Material.SIGN) || oldBlockInfo.is(Material.SIGN_POST)) {
|
||||
BlockState state = currentBlock.getState();
|
||||
Sign currentSign = (Sign) state;
|
||||
currentSign.setLine(0, oldBlockInfo.getSignLines()[0]);
|
||||
currentSign.setLine(1, oldBlockInfo.getSignLines()[0]);
|
||||
currentSign.setLine(2, oldBlockInfo.getSignLines()[0]);
|
||||
currentSign.setLine(3, oldBlockInfo.getSignLines()[0]);
|
||||
state.update();
|
||||
}
|
||||
currentBlock.setTypeId(oldBlockType);
|
||||
currentBlock.setData(oldBlockData);
|
||||
// if(oldBlockInfo.is(Material.SIGN) || oldBlockInfo.is(Material.SIGN_POST)) {
|
||||
// BlockState state = currentBlock.getState();
|
||||
// Sign currentSign = (Sign) state;
|
||||
// currentSign.setLine(0, oldBlockInfo.getSignLines()[0]);
|
||||
// currentSign.setLine(1, oldBlockInfo.getSignLines()[0]);
|
||||
// currentSign.setLine(2, oldBlockInfo.getSignLines()[0]);
|
||||
// currentSign.setLine(3, oldBlockInfo.getSignLines()[0]);
|
||||
// state.update();
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -5,8 +5,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
import bukkit.tommytony.war.War;
|
||||
|
||||
@ -21,7 +19,8 @@ public class Volume {
|
||||
//private final Warzone warzone;
|
||||
private Block cornerOne;
|
||||
private Block cornerTwo;
|
||||
private BlockInfo[][][] blockInfos = null;
|
||||
private int[][][] blockTypes = null;
|
||||
private byte[][][] blockDatas = null;
|
||||
private final War war;
|
||||
|
||||
public Volume(String name, War war, World world) {
|
||||
@ -46,14 +45,17 @@ public class Volume {
|
||||
int noOfSavedBlocks = 0;
|
||||
try {
|
||||
if(hasTwoCorners()) {
|
||||
this.setBlockInfos(new BlockInfo[getSizeX()][getSizeY()][getSizeZ()]);
|
||||
this.setBlockTypes(new int[getSizeX()][getSizeY()][getSizeZ()]);
|
||||
this.setBlockDatas(new byte[getSizeX()][getSizeY()][getSizeZ()]);
|
||||
int x = getMinX();
|
||||
for(int i = 0; i < getSizeX(); i++){
|
||||
int y = getMinY();
|
||||
for(int j = 0; j < getSizeY(); j++){
|
||||
int z = getMinZ();
|
||||
for(int k = 0;k < getSizeZ(); k++) {
|
||||
this.getBlockInfos()[i][j][k] = new BlockInfo(getWorld().getBlockAt(x, y, z));
|
||||
Block block = getWorld().getBlockAt(x, y, z);
|
||||
this.getBlockTypes()[i][j][k] = block.getTypeId();
|
||||
this.getBlockDatas()[i][j][k] = block.getData();
|
||||
z++;
|
||||
noOfSavedBlocks++;
|
||||
}
|
||||
@ -72,32 +74,33 @@ public class Volume {
|
||||
int noOfResetBlocks = 0;
|
||||
clearBlocksThatDontFloat();
|
||||
try {
|
||||
if(hasTwoCorners() && getBlockInfos() != null) {
|
||||
if(hasTwoCorners() && getBlockTypes() != null) {
|
||||
int x = getMinX();
|
||||
for(int i = 0; i < getSizeX(); i++){
|
||||
int y = getMinY();
|
||||
for(int j = 0; j < getSizeY(); j++){
|
||||
int z = getMinZ();
|
||||
for(int k = 0;k < getSizeZ(); k++) {
|
||||
BlockInfo oldBlockInfo = getBlockInfos()[i][j][k];
|
||||
int oldBlockType = getBlockTypes()[i][j][k];
|
||||
byte oldBlockData = getBlockDatas()[i][j][k];
|
||||
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||
if(currentBlock.getTypeId() != oldBlockInfo.getTypeId() ||
|
||||
(currentBlock.getTypeId() == oldBlockInfo.getTypeId() && currentBlock.getData() != oldBlockInfo.getData()) ||
|
||||
(currentBlock.getTypeId() == oldBlockInfo.getTypeId() && currentBlock.getData() == oldBlockInfo.getData() &&
|
||||
(oldBlockInfo.is(Material.SIGN) || oldBlockInfo.is(Material.SIGN_POST))
|
||||
if(currentBlock.getTypeId() != oldBlockType ||
|
||||
(currentBlock.getTypeId() == oldBlockType && currentBlock.getData() != oldBlockData ) ||
|
||||
(currentBlock.getTypeId() == oldBlockType && currentBlock.getData() == oldBlockData &&
|
||||
(oldBlockType == Material.SIGN.getId() || oldBlockType == Material.SIGN_POST.getId())
|
||||
)
|
||||
) {
|
||||
currentBlock.setType(oldBlockInfo.getType());
|
||||
currentBlock.setData(oldBlockInfo.getData());
|
||||
if(oldBlockInfo.is(Material.SIGN) || oldBlockInfo.is(Material.SIGN_POST)) {
|
||||
BlockState state = currentBlock.getState();
|
||||
Sign currentSign = (Sign) state;
|
||||
currentSign.setLine(0, oldBlockInfo.getSignLines()[0]);
|
||||
currentSign.setLine(1, oldBlockInfo.getSignLines()[1]);
|
||||
currentSign.setLine(2, oldBlockInfo.getSignLines()[2]);
|
||||
currentSign.setLine(3, oldBlockInfo.getSignLines()[3]);
|
||||
state.update();
|
||||
}
|
||||
currentBlock.setTypeId(oldBlockType);
|
||||
currentBlock.setData(oldBlockData);
|
||||
// if(oldBlockInfo.is(Material.SIGN) || oldBlockInfo.is(Material.SIGN_POST)) {
|
||||
// BlockState state = currentBlock.getState();
|
||||
// Sign currentSign = (Sign) state;
|
||||
// currentSign.setLine(0, oldBlockInfo.getSignLines()[0]);
|
||||
// currentSign.setLine(1, oldBlockInfo.getSignLines()[1]);
|
||||
// currentSign.setLine(2, oldBlockInfo.getSignLines()[2]);
|
||||
// currentSign.setLine(3, oldBlockInfo.getSignLines()[3]);
|
||||
// state.update();
|
||||
// }
|
||||
noOfResetBlocks++;
|
||||
}
|
||||
z++;
|
||||
@ -113,6 +116,16 @@ public class Volume {
|
||||
return noOfResetBlocks;
|
||||
}
|
||||
|
||||
public byte[][][] getBlockDatas() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.blockDatas;
|
||||
}
|
||||
|
||||
public void setBlockDatas(byte[][][] data) {
|
||||
this.blockDatas = data;
|
||||
}
|
||||
|
||||
|
||||
public void setCornerTwo(Block block) {
|
||||
this.cornerTwo = block;
|
||||
}
|
||||
@ -184,11 +197,11 @@ public class Volume {
|
||||
}
|
||||
|
||||
public boolean isSaved() {
|
||||
return getBlockInfos() != null;
|
||||
return getBlockTypes() != null;
|
||||
}
|
||||
|
||||
public BlockInfo[][][] getBlockInfos() {
|
||||
return blockInfos;
|
||||
public int[][][] getBlockTypes() {
|
||||
return blockTypes;
|
||||
}
|
||||
|
||||
public Block getCornerOne() {
|
||||
@ -217,8 +230,8 @@ public class Volume {
|
||||
z <= getMaxZ() && z >= getMinZ();
|
||||
}
|
||||
|
||||
public void setBlockInfos(BlockInfo[][][] blockInfos) {
|
||||
this.blockInfos = blockInfos;
|
||||
public void setBlockTypes(int[][][] blockTypes) {
|
||||
this.blockTypes = blockTypes;
|
||||
}
|
||||
|
||||
public War getWar() {
|
||||
@ -231,7 +244,7 @@ public class Volume {
|
||||
|
||||
public void setToMaterial(Material material) {
|
||||
try {
|
||||
if(hasTwoCorners() && getBlockInfos() != null) {
|
||||
if(hasTwoCorners() && getBlockTypes() != null) {
|
||||
int x = getMinX();
|
||||
for(int i = 0; i < getSizeX(); i++){
|
||||
int y = getMinY();
|
||||
@ -254,7 +267,7 @@ public class Volume {
|
||||
|
||||
public void setFaceMaterial(BlockFace face, Material material) {
|
||||
try {
|
||||
if(hasTwoCorners() && getBlockInfos() != null) {
|
||||
if(hasTwoCorners() && getBlockTypes() != null) {
|
||||
int x = getMinX();
|
||||
for(int i = 0; i < getSizeX(); i++){
|
||||
int y = getMinY();
|
||||
@ -284,7 +297,7 @@ public class Volume {
|
||||
|
||||
private void switchMaterials(Material[] oldTypes, Material newType) {
|
||||
try {
|
||||
if(hasTwoCorners() && getBlockInfos() != null) {
|
||||
if(hasTwoCorners() && getBlockTypes() != null) {
|
||||
int x = getMinX();
|
||||
for(int i = 0; i < getSizeX(); i++){
|
||||
int y = getMinY();
|
||||
|
@ -2,13 +2,7 @@ name: War
|
||||
main: bukkit.tommytony.war.War
|
||||
version: 0.3
|
||||
commands:
|
||||
#-Fallback-
|
||||
war:
|
||||
description: Prompts you to use /warhub, /zones and /zone. Can also be used as a prefix for all commands as a fallback if they are taken.
|
||||
usage: /war, /war setzone ziggy northwest, /war warhub, /war zone ziggy, etc.
|
||||
War:
|
||||
description: Same as /war. Used as fallback.
|
||||
usage: See /war.
|
||||
|
||||
#-Player commands-
|
||||
warzones:
|
||||
description: Lists the warzones on the server. Each warzone is an independent TDM arena.
|
||||
@ -37,12 +31,16 @@ commands:
|
||||
team:
|
||||
description: Team chat.
|
||||
usage: /team Leeeroooy!!!
|
||||
|
||||
|
||||
#-Warzone maker commands-
|
||||
#--Battle-related commands--
|
||||
|
||||
#|-Battle-related commands-
|
||||
nextbattle:
|
||||
description: War makers only. Zone blocks are restored (from memory). Teams are respawned. Just as if a team's life pool had been exhausted.
|
||||
usage: /nextbattle
|
||||
#--Warzone creation commands--
|
||||
|
||||
#|-Warzone creation commands-
|
||||
setzone:
|
||||
description: Zone makers only. Use to create and adjust the warzone outline. A zone area is defined by its Northwest and Southeast corners, up to the sky and down to adminium. When the second corner is set down correctly, the zone blocks are saved.
|
||||
usage: /setzone <northwest/southeast/nw/se>, e.g. first, /setzone ziggy se, then, /setzone ziggy northwest
|
||||
@ -76,19 +74,28 @@ commands:
|
||||
zonemaker:
|
||||
description: Zone makers only. Toggles between player mode and zone maker mode. Or gives/removes access to zonemaker commands for another player.
|
||||
usage: /zonemaker, /zonemaker <new-or-kicked-maker-name>
|
||||
#--War hub--
|
||||
|
||||
#|-War hub--
|
||||
setwarhub:
|
||||
description: War makers only. Create or moves a West-facing wall of portals. One portal per warzone. Warzones get a portal back to the warhub.
|
||||
usage: /setwarhub
|
||||
deletewarhub:
|
||||
description: War makers only. Deletes the warhub if it exists. Resets all warzone lobbies.
|
||||
usage: /deletewarhub
|
||||
#--Defaults--
|
||||
|
||||
#|-Defaults--
|
||||
setwarconfig:
|
||||
description: War makers only. Change the default warzone configuration values.
|
||||
usage: /setwarconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on
|
||||
|
||||
|
||||
|
||||
|
||||
#-Fallback-
|
||||
war:
|
||||
description: Prompts you to use /warhub, /zones and /zone. Can also be used as a prefix for all commands as a fallback if they are taken.
|
||||
usage: /war, /war setzone ziggy northwest, /war warhub, /war zone ziggy, etc.
|
||||
War:
|
||||
description: Same as /war. Used as fallback.
|
||||
usage: See /war.
|
||||
|
||||
#Note: When you /disable War with General, all warzone blocks will be reset and artifacts will disappear.
|
||||
# When you /enable War, all blocks will be loaded from disk and the War-related artifacts will reappear.
|
@ -2,13 +2,7 @@ name: War
|
||||
main: bukkit.tommytony.war.War
|
||||
version: 0.3
|
||||
commands:
|
||||
#-Fallback-
|
||||
war:
|
||||
description: Prompts you to use /warhub, /zones and /zone. Can also be used as a prefix for all commands as a fallback if they are taken.
|
||||
usage: /war, /war setzone ziggy northwest, /war warhub, /war zone ziggy, etc.
|
||||
War:
|
||||
description: Same as /war. Used as fallback.
|
||||
usage: See /war.
|
||||
|
||||
#-Player commands-
|
||||
warzones:
|
||||
description: Lists the warzones on the server. Each warzone is an independent TDM arena.
|
||||
@ -37,12 +31,16 @@ commands:
|
||||
team:
|
||||
description: Team chat.
|
||||
usage: /team Leeeroooy!!!
|
||||
|
||||
|
||||
#-Warzone maker commands-
|
||||
#--Battle-related commands--
|
||||
|
||||
#|-Battle-related commands-
|
||||
nextbattle:
|
||||
description: War makers only. Zone blocks are restored (from memory). Teams are respawned. Just as if a team's life pool had been exhausted.
|
||||
usage: /nextbattle
|
||||
#--Warzone creation commands--
|
||||
|
||||
#|-Warzone creation commands-
|
||||
setzone:
|
||||
description: Zone makers only. Use to create and adjust the warzone outline. A zone area is defined by its Northwest and Southeast corners, up to the sky and down to adminium. When the second corner is set down correctly, the zone blocks are saved.
|
||||
usage: /setzone <northwest/southeast/nw/se>, e.g. first, /setzone ziggy se, then, /setzone ziggy northwest
|
||||
@ -76,19 +74,28 @@ commands:
|
||||
zonemaker:
|
||||
description: Zone makers only. Toggles between player mode and zone maker mode. Or gives/removes access to zonemaker commands for another player.
|
||||
usage: /zonemaker, /zonemaker <new-or-kicked-maker-name>
|
||||
#--War hub--
|
||||
|
||||
#|-War hub--
|
||||
setwarhub:
|
||||
description: War makers only. Create or moves a West-facing wall of portals. One portal per warzone. Warzones get a portal back to the warhub.
|
||||
usage: /setwarhub
|
||||
deletewarhub:
|
||||
description: War makers only. Deletes the warhub if it exists. Resets all warzone lobbies.
|
||||
usage: /deletewarhub
|
||||
#--Defaults--
|
||||
|
||||
#|-Defaults--
|
||||
setwarconfig:
|
||||
description: War makers only. Change the default warzone configuration values.
|
||||
usage: /setwarconfig lifepool:8 teamsize:5 maxscore:7 autoassign:on outline:off ff:on
|
||||
|
||||
|
||||
|
||||
|
||||
#-Fallback-
|
||||
war:
|
||||
description: Prompts you to use /warhub, /zones and /zone. Can also be used as a prefix for all commands as a fallback if they are taken.
|
||||
usage: /war, /war setzone ziggy northwest, /war warhub, /war zone ziggy, etc.
|
||||
War:
|
||||
description: Same as /war. Used as fallback.
|
||||
usage: See /war.
|
||||
|
||||
#Note: When you /disable War with General, all warzone blocks will be reset and artifacts will disappear.
|
||||
# When you /enable War, all blocks will be loaded from disk and the War-related artifacts will reappear.
|
Loading…
Reference in New Issue
Block a user