mirror of
https://github.com/taoneill/war.git
synced 2024-11-30 14:13:23 +01:00
Bunch of litte fixes. Setting helmet instead of boots so everything works when it's patched. No more spammy signs. Added sign to war hub. Monuments are broken.
This commit is contained in:
parent
fbf4dc26fc
commit
6cc5ee64bc
@ -62,7 +62,16 @@ public class War extends JavaPlugin {
|
|||||||
private WarHub warHub;
|
private WarHub warHub;
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
Logger.getLogger("Minecraft").info(name + " " + version + " disabled.");
|
for(Warzone warzone : warzones) {
|
||||||
|
if(warzone.getLobby() != null) {
|
||||||
|
warzone.getLobby().getVolume().resetBlocks();
|
||||||
|
}
|
||||||
|
warzone.getVolume().resetBlocks();
|
||||||
|
}
|
||||||
|
if(warHub != null) {
|
||||||
|
warHub.getVolume().resetBlocks();
|
||||||
|
}
|
||||||
|
Logger.getLogger("Minecraft").info("All warzone blocks reset. War v" + version + " disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -73,14 +82,11 @@ public class War extends JavaPlugin {
|
|||||||
|
|
||||||
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this);
|
||||||
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_COMMAND, playerListener, Priority.Normal, this);
|
|
||||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Normal, this);
|
||||||
|
|
||||||
//pm.registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.Normal, this); // done thru Move at respawn
|
|
||||||
pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.Normal, this);
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal, this);
|
||||||
//pm.registerEvent(Event.Type.BLOCK_CANBUILD, blockListener, Priority.Normal, this);
|
|
||||||
pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this);
|
pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal, this);
|
||||||
|
|
||||||
// Load files from disk or create them (using these defaults)
|
// Load files from disk or create them (using these defaults)
|
||||||
@ -676,11 +682,13 @@ public class War extends JavaPlugin {
|
|||||||
|| command.equals("nextbattle")
|
|| command.equals("nextbattle")
|
||||||
|| command.equals("setzonelobby")
|
|| command.equals("setzonelobby")
|
||||||
|| command.equals("savezone")
|
|| command.equals("savezone")
|
||||||
|
|| command.equals("resetzone")
|
||||||
|| command.equals("deletezone")
|
|| command.equals("deletezone")
|
||||||
|| command.equals("setteam")
|
|| command.equals("setteam")
|
||||||
|| command.equals("deleteteam")
|
|| command.equals("deleteteam")
|
||||||
|| command.equals("setmonument")
|
|| command.equals("setmonument")
|
||||||
|| command.equals("deletemonument")) {
|
|| command.equals("deletemonument")
|
||||||
|
|| command.equals("setwarhub")) {
|
||||||
player.sendMessage(this.str("You can't do this if you are not a warzone maker."));
|
player.sendMessage(this.str("You can't do this if you are not a warzone maker."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class WarBlockListener extends BlockListener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
// let team members loot one block the spawn for monument captures
|
// let team members loot one block the spawn for monument captures
|
||||||
} else {
|
} else if (!warzone.isMonumentCenterBlock(block)){
|
||||||
player.sendMessage(war.str("Can't destroy this."));
|
player.sendMessage(war.str("Can't destroy this."));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -92,11 +92,22 @@ public class WarHub {
|
|||||||
currentGateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP).setType(Material.OBSIDIAN);
|
currentGateBlock.getFace(BlockFace.UP).getFace(BlockFace.UP).setType(Material.OBSIDIAN);
|
||||||
currentGateBlock = currentGateBlock.getFace(BlockFace.NORTH, 4);
|
currentGateBlock = currentGateBlock.getFace(BlockFace.NORTH, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// War hub sign
|
||||||
|
Block signBlock = locationBlock.getFace(BlockFace.WEST);
|
||||||
|
if(signBlock.getType() != Material.SIGN_POST) signBlock.setType(Material.SIGN_POST);
|
||||||
|
signBlock.setData((byte)8);
|
||||||
|
BlockState state = signBlock.getState();
|
||||||
|
Sign sign = (Sign) state;
|
||||||
|
sign.setLine(0, "War hub");
|
||||||
|
sign.setLine(1, "");
|
||||||
|
sign.setLine(2, "Pick you battle!");
|
||||||
|
sign.setLine(3, "");
|
||||||
|
state.update(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetZoneSign(Warzone zone) {
|
public void resetZoneSign(Warzone zone) {
|
||||||
// TODO Signs
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(i = 0; i < war.getWarzones().size(); i++) {
|
for(i = 0; i < war.getWarzones().size(); i++) {
|
||||||
if(zone.getName() == war.getWarzones().get(i).getName()) break;
|
if(zone.getName() == war.getWarzones().get(i).getName()) break;
|
||||||
|
@ -361,14 +361,13 @@ public class Warzone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(team.getMaterial() == Material.GOLD_BLOCK) {
|
if(team.getMaterial() == Material.GOLD_BLOCK) {
|
||||||
playerInv.setHelmet(new ItemStack(Material.GOLD_BOOTS));
|
playerInv.setHelmet(new ItemStack(Material.GOLD_HELMET));
|
||||||
} else if (team.getMaterial() == Material.DIAMOND_BLOCK) {
|
} else if (team.getMaterial() == Material.DIAMOND_BLOCK) {
|
||||||
playerInv.setHelmet(new ItemStack(Material.DIAMOND_BOOTS));
|
playerInv.setHelmet(new ItemStack(Material.DIAMOND_HELMET));
|
||||||
} else if (team.getMaterial() == Material.IRON_BLOCK) {
|
} else if (team.getMaterial() == Material.IRON_BLOCK) {
|
||||||
playerInv.setHelmet(new ItemStack(Material.IRON_BOOTS));
|
playerInv.setHelmet(new ItemStack(Material.IRON_HELMET));
|
||||||
}
|
}
|
||||||
//player.setHealth(20);
|
//player.setHealth(20);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMonumentCenterBlock(Block block) {
|
public boolean isMonumentCenterBlock(Block block) {
|
||||||
@ -446,9 +445,8 @@ public class Warzone {
|
|||||||
ItemStack[] originalContents = inventories.remove(player.getName());
|
ItemStack[] originalContents = inventories.remove(player.getName());
|
||||||
PlayerInventory playerInv = player.getInventory();
|
PlayerInventory playerInv = player.getInventory();
|
||||||
playerInv.clear();
|
playerInv.clear();
|
||||||
playerInv.remove(Material.DIAMOND_BOOTS.getId());
|
playerInv.setHelmet(new ItemStack(0));
|
||||||
playerInv.remove(Material.GOLD_BOOTS.getId());
|
playerInv.setBoots(new ItemStack(0));
|
||||||
playerInv.remove(Material.IRON_BOOTS.getId());
|
|
||||||
playerInv.setContents(originalContents);
|
playerInv.setContents(originalContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,35 +480,35 @@ public class Warzone {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(teleportNear(block)) {
|
// if(lobby != null) {
|
||||||
return true;
|
// lobby.getVolume().contains(block);
|
||||||
}
|
// }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean teleportNear(Block block) {
|
// private boolean teleportNear(Block block) {
|
||||||
if(teleport != null) {
|
// if(teleport != null) {
|
||||||
int x = (int)this.teleport.getBlockX();
|
// int x = (int)this.teleport.getBlockX();
|
||||||
int y = (int)this.teleport.getBlockY();
|
// int y = (int)this.teleport.getBlockY();
|
||||||
int z = (int)this.teleport.getBlockZ();
|
// int z = (int)this.teleport.getBlockZ();
|
||||||
int bx = block.getX();
|
// int bx = block.getX();
|
||||||
int by = block.getY();
|
// int by = block.getY();
|
||||||
int bz = block.getZ();
|
// int bz = block.getZ();
|
||||||
if((bx == x && by == y && bz == z) ||
|
// if((bx == x && by == y && bz == z) ||
|
||||||
(bx == x+1 && 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) ||
|
||||||
(bx == x+1 && by == y-1 && bz == z-1) ||
|
// (bx == x+1 && by == y-1 && bz == z-1) ||
|
||||||
(bx == x && 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) ||
|
||||||
(bx == x && by == y-1 && bz == z-1) ||
|
// (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+1) ||
|
||||||
(bx == x-1 && by == y-1 && bz == z) ||
|
// (bx == x-1 && by == y-1 && bz == z) ||
|
||||||
(bx == x-1 && by == y-1 && bz == z-1) ) {
|
// (bx == x-1 && by == y-1 && bz == z-1) ) {
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public World getWorld() {
|
public World getWorld() {
|
||||||
|
|
||||||
@ -669,7 +667,7 @@ public class Warzone {
|
|||||||
// because player can go around corner
|
// because player can go around corner
|
||||||
lobby.initialize();
|
lobby.initialize();
|
||||||
}
|
}
|
||||||
war.getLogger().info("Reset " + reset + " blocks in " + guard.getWall() + " wall of warzone " + name);
|
//war.getLogger().info("Reset " + reset + " blocks in " + guard.getWall() + " wall of warzone " + name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// now remove those zone guards
|
// now remove those zone guards
|
||||||
|
@ -364,10 +364,6 @@ public class ZoneLobby {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetSigns() {
|
|
||||||
// TODO Signs
|
|
||||||
}
|
|
||||||
|
|
||||||
public Volume getVolume() {
|
public Volume getVolume() {
|
||||||
return this.volume;
|
return this.volume;
|
||||||
}
|
}
|
||||||
|
@ -123,6 +123,7 @@ public class WarMapper {
|
|||||||
|
|
||||||
for(Warzone zone : war.getWarzones()) {
|
for(Warzone zone : war.getWarzones()) {
|
||||||
if(zone.getLobby() != null) {
|
if(zone.getLobby() != null) {
|
||||||
|
zone.getLobby().getVolume().resetBlocks();
|
||||||
zone.getLobby().initialize(); // adds the warhub link gate
|
zone.getLobby().initialize(); // adds the warhub link gate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,9 @@ public class Volume {
|
|||||||
|
|
||||||
public int resetBlocks() {
|
public int resetBlocks() {
|
||||||
int noOfResetBlocks = 0;
|
int noOfResetBlocks = 0;
|
||||||
|
Material[] toAirMaterials = new Material[1];
|
||||||
|
toAirMaterials[0] = Material.SIGN_POST;
|
||||||
|
switchMaterials(toAirMaterials, Material.AIR);
|
||||||
try {
|
try {
|
||||||
if(hasTwoCorners() && getBlockInfos() != null) {
|
if(hasTwoCorners() && getBlockInfos() != null) {
|
||||||
int x = getMinX();
|
int x = getMinX();
|
||||||
@ -190,82 +193,6 @@ public class Volume {
|
|||||||
return blockInfos;
|
return blockInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public String blocksToString() {
|
|
||||||
// if(hasTwoCorners() && blockInfos != null) {
|
|
||||||
// StringBuilder volumeStringBuilder = new StringBuilder();
|
|
||||||
// volumeStringBuilder.append(cornerOne.getX() + "," + cornerOne.getY() + "," + cornerOne.getZ() + ";");
|
|
||||||
// volumeStringBuilder.append(cornerTwo.getX() + "," + cornerTwo.getY() + "," + cornerTwo.getZ() + ";");
|
|
||||||
//
|
|
||||||
// for(int i = 0; i < getSizeX(); i++){
|
|
||||||
// for(int j = 0; j < getSizeY(); j++) {
|
|
||||||
// for(int k = 0; k < getSizeZ(); k++) {
|
|
||||||
// BlockInfo info = getBlockInfos()[i][j][k];
|
|
||||||
// if(info == null) {
|
|
||||||
// volumeStringBuilder.append("0,0,");
|
|
||||||
// } else {
|
|
||||||
// volumeStringBuilder.append(info.getTypeID() + "," + info.getData() + ",");
|
|
||||||
// if(info.getType() == Material.Sign || info.getType() == Material.SignPost) {
|
|
||||||
// String[] lines = info.getSignLines();
|
|
||||||
// volumeStringBuilder.append(lines[0] + "\n");
|
|
||||||
// volumeStringBuilder.append(lines[1] + "\n");
|
|
||||||
// volumeStringBuilder.append(lines[2] + "\n");
|
|
||||||
// volumeStringBuilder.append(lines[3] + "\n");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// volumeStringBuilder.append(";");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return volumeStringBuilder.toString();
|
|
||||||
// }
|
|
||||||
// return "";
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public void blocksFromString(String volumeString) {
|
|
||||||
// Scanner scanner = new Scanner(volumeString);
|
|
||||||
// int x1 = 0;
|
|
||||||
// if(scanner.hasNext(".+,")) x1 = Integer.parseInt(scanner.next(".+,").replace(",", ""));
|
|
||||||
// int y1 = 0;
|
|
||||||
// if(scanner.hasNext(".+,")) y1 = Integer.parseInt(scanner.next(".+,").replace(",", ""));
|
|
||||||
// int z1 = 0;
|
|
||||||
// if(scanner.hasNext(".+,")) z1 = Integer.parseInt(scanner.next(".+,").replace(",", ""));
|
|
||||||
// if(scanner.hasNext(";")) scanner.next(";");
|
|
||||||
// cornerOne = getWorld().getBlockAt(x1, y1, z1);
|
|
||||||
//
|
|
||||||
// int x2 = 0;
|
|
||||||
// if(scanner.hasNext(".+,")) x2 = Integer.parseInt(scanner.next(".+,").replace(",", ""));
|
|
||||||
// int y2 = 0;
|
|
||||||
// if(scanner.hasNext(".+,")) y2 = Integer.parseInt(scanner.next(".+,").replace(",", ""));
|
|
||||||
// int z2 = 0;
|
|
||||||
// if(scanner.hasNext(".+,")) z2 = Integer.parseInt(scanner.next(".+,").replace(",", ""));
|
|
||||||
// if(scanner.hasNext(";")) scanner.next(";");
|
|
||||||
// cornerTwo = getWorld().getBlockAt(x2, y2, z2);
|
|
||||||
//
|
|
||||||
// setBlockInfos(new BlockInfo[getSizeX()][getSizeY()][getSizeZ()]);
|
|
||||||
// for(int i = 0; i < getSizeX(); i++){
|
|
||||||
// for(int j = 0; j < getSizeY(); j++) {
|
|
||||||
// for(int k = 0; k < getSizeZ(); k++) {
|
|
||||||
// int typeID = 0;
|
|
||||||
// if(scanner.hasNext(".+,")) typeID = Integer.parseInt(scanner.next(".+,").replace(",", ""));
|
|
||||||
// byte data = 0;
|
|
||||||
// if(scanner.hasNext(".+,")) data = Byte.parseByte(scanner.next(".+,").replace(",", ""));
|
|
||||||
// String[] lines = null;
|
|
||||||
// if(typeID == Material.Sign.getID() || typeID == Material.SignPost.getID()) {
|
|
||||||
// lines = new String[4];
|
|
||||||
// if(scanner.hasNextLine()) lines[0] = scanner.nextLine();
|
|
||||||
// if(scanner.hasNextLine()) lines[1] = scanner.nextLine();
|
|
||||||
// if(scanner.hasNextLine()) lines[2] = scanner.nextLine();
|
|
||||||
// if(scanner.hasNextLine()) lines[3] = scanner.nextLine();
|
|
||||||
// }
|
|
||||||
// if(scanner.hasNext(";")) scanner.next(";");
|
|
||||||
// getBlockInfos()[i][j][k] = new BlockInfo(typeID, data, lines);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
public Block getCornerOne() {
|
public Block getCornerOne() {
|
||||||
return cornerOne;
|
return cornerOne;
|
||||||
}
|
}
|
||||||
@ -357,4 +284,31 @@ public class Volume {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void switchMaterials(Material[] oldTypes, Material newType) {
|
||||||
|
try {
|
||||||
|
if(hasTwoCorners() && getBlockInfos() != 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++) {
|
||||||
|
Block currentBlock = getWorld().getBlockAt(x, y, z);
|
||||||
|
for(Material oldType : oldTypes) {
|
||||||
|
if(currentBlock.getType() == oldType) {
|
||||||
|
currentBlock.setType(newType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
z++;
|
||||||
|
}
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.getWar().getLogger().warning("Failed to switch block to " + newType + "in volume " + name + "." + e.getClass().toString() + " " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user