mirror of
https://github.com/taoneill/war.git
synced 2024-11-27 20:59:39 +01:00
Closes gh-72. Prevent players form using any commands but War ones inside warzones. Cant place flag or spawn block anymore. Not getting killed when sneaking out of a warzone anymore. Reward gets saved properly. Auto-assign join message fixed. Cant pickup more than one precious block. Updated to 439 to get rid of pesky reset bugs. Still getting block freeze bugs. :(
This commit is contained in:
parent
29353f9c73
commit
58e59c75c2
@ -87,8 +87,9 @@ public class War extends JavaPlugin {
|
||||
this.logInfo("Clearing zone " + warzone.getName() + "...");
|
||||
for(Team team : warzone.getTeams()) {
|
||||
for(Player player : team.getPlayers()) {
|
||||
warzone.handlePlayerLeave(player, warzone.getTeleport());
|
||||
warzone.handlePlayerLeave(player, warzone.getTeleport(), false);
|
||||
}
|
||||
team.getPlayers().clear();
|
||||
}
|
||||
if(warzone.getLobby() != null) {
|
||||
warzone.getLobby().getVolume().resetBlocks();
|
||||
@ -116,6 +117,7 @@ public class War extends JavaPlugin {
|
||||
pm.registerEvent(Event.Type.PLAYER_PICKUP_ITEM, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.INVENTORY_OPEN, 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.ENTITY_EXPLODE, entityListener, Priority.Normal, this);
|
||||
@ -886,7 +888,7 @@ public class War extends JavaPlugin {
|
||||
Team playerTeam = this.getPlayerTeam(player.getName());
|
||||
Warzone playerWarzone = getPlayerTeamWarzone(player.getName());
|
||||
if(playerTeam != null) { // was in zone
|
||||
playerWarzone.handlePlayerLeave(player, this.getWarHub().getLocation());
|
||||
playerWarzone.handlePlayerLeave(player, this.getWarHub().getLocation(), true);
|
||||
}
|
||||
player.teleportTo(this.getWarHub().getLocation());
|
||||
}
|
||||
@ -921,7 +923,7 @@ public class War extends JavaPlugin {
|
||||
"Must be in a team already.");
|
||||
} else {
|
||||
Warzone zone = getPlayerTeamWarzone(player.getName());
|
||||
zone.handlePlayerLeave(player, zone.getTeleport());
|
||||
zone.handlePlayerLeave(player, zone.getTeleport(), true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1018,7 +1020,7 @@ public class War extends JavaPlugin {
|
||||
Team playerTeam = getPlayerTeam(player.getName());
|
||||
if(playerTeam != null) {
|
||||
Warzone playerWarzone = getPlayerTeamWarzone(player.getName());
|
||||
playerWarzone.handlePlayerLeave(player, warzone.getTeleport());
|
||||
playerWarzone.handlePlayerLeave(player, warzone.getTeleport(), true);
|
||||
} else {
|
||||
player.teleportTo(warzone.getTeleport());
|
||||
}
|
||||
@ -1490,10 +1492,10 @@ public class War extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public BlockState refetchStateForBlock(World world, Block block) {
|
||||
Block again = world.getBlockAt(block.getX(), block.getY(), block.getZ());
|
||||
return again.getState();
|
||||
}
|
||||
// public BlockState refetchStateForBlock(World world, Block block) {
|
||||
// Block again = world.getBlockAt(block.getX(), block.getY(), block.getZ());
|
||||
// return again.getState();
|
||||
// }
|
||||
|
||||
public void setDefaultBlockHeads(boolean defaultBlockHeads) {
|
||||
this.defaultBlockHeads = defaultBlockHeads;
|
||||
|
@ -85,6 +85,20 @@ public class WarBlockListener extends BlockListener {
|
||||
return;
|
||||
}
|
||||
|
||||
// can't place a block of your team's color
|
||||
if(team != null && block.getType() == team.getMaterial()) {
|
||||
war.badMsg(player, "You can only use your team's blocks to capture monuments.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if(team != null && zone != null && zone.isFlagThief(player.getName())) {
|
||||
// a flag thief can't drop his flag
|
||||
war.badMsg(player, "Can't drop the flag. What are you doing? Run!");
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
boolean isZoneMaker = war.isZoneMaker(player);
|
||||
// unbreakableZoneBlocks
|
||||
if(zone != null && zone.isUnbreakableZoneBlocks()
|
||||
@ -142,7 +156,7 @@ public class WarBlockListener extends BlockListener {
|
||||
}else if(warzone != null && warzone.isImportantBlock(block)) {
|
||||
if(team != null && team.getSpawnVolume().contains(block)) {
|
||||
if(player.getInventory().contains(team.getMaterial())) {
|
||||
//war.badMsg(player, "You already have a " + team.getName() + " block.");
|
||||
war.badMsg(player, "You already have a " + team.getName() + " block.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else {
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.entity.CraftItem;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerInventoryEvent;
|
||||
@ -89,7 +90,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if(zone.hasPlayerInventory(player.getName())) {
|
||||
disconnected.put(player.getName(), zone.getPlayerInventory(player.getName()));
|
||||
}
|
||||
zone.handlePlayerLeave(player, zone.getTeleport());
|
||||
zone.handlePlayerLeave(player, zone.getTeleport(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -137,7 +138,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if(itemStack != null && itemStack.getType().getId() == team.getMaterial().getId()
|
||||
&& player.getInventory().contains(team.getMaterial())) {
|
||||
// Can't pick up a second precious block
|
||||
war.badMsg(player, "You already have a " + team.getName() + " block.");
|
||||
//war.badMsg(player, "You already have a " + team.getName() + " block.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -161,6 +162,30 @@ public class WarPlayerListener extends PlayerListener {
|
||||
war.badMsg(player, "All that " + team.getName() + " must have been heavy!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerCommandPreprocess(PlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Team talkingPlayerTeam = war.getPlayerTeam(player.getName());
|
||||
if(talkingPlayerTeam != null) {
|
||||
String msg = event.getMessage();
|
||||
String[] split = msg.split(" ");
|
||||
if(!war.isZoneMaker(player) && split.length > 0 && split[0].startsWith("/")) {
|
||||
String command = split[0].substring(1);
|
||||
if(!command.equals("zones") && !command.equals("warzones")
|
||||
&& !command.equals("zone") && !command.equals("warzone")
|
||||
&& !command.equals("teams")
|
||||
&& !command.equals("join")
|
||||
&& !command.equals("leave")
|
||||
&& !command.equals("team")
|
||||
&& !command.equals("warhub")
|
||||
&& !command.equals("zonemaker")) {
|
||||
war.badMsg(player, "Can't use anything but War commands (e.g. /leave, /warhub) while you're playing in a warzone.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
@ -356,7 +381,7 @@ public class WarPlayerListener extends PlayerListener {
|
||||
Team playerTeam = war.getPlayerTeam(player.getName());
|
||||
if(playerTeam != null) {
|
||||
event.setFrom(playerWarzone.getTeleport());
|
||||
playerWarzone.handlePlayerLeave(player, playerWarzone.getTeleport());
|
||||
playerWarzone.handlePlayerLeave(player, playerWarzone.getTeleport(), true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -369,7 +394,6 @@ public class WarPlayerListener extends PlayerListener {
|
||||
if(locZone == null && team != null) {;
|
||||
war.badMsg(player, "You can't sneak out of a zone while in a team. Use /leave or walk out the lobby to exit the zone, please.");
|
||||
event.setFrom(team.getTeamSpawn());
|
||||
playerWarzone.handleDeath(player);
|
||||
player.teleportTo(team.getTeamSpawn());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -275,22 +275,22 @@ public class Team {
|
||||
// signBlock.setType(Material.SIGN_POST);
|
||||
// }
|
||||
|
||||
|
||||
if(signBlock.getType() != Material.SIGN_POST) {
|
||||
signBlock.setType(Material.SIGN_POST);
|
||||
}
|
||||
signBlock.setData((byte)signData);
|
||||
BlockState state = signBlock.getState();
|
||||
if(state.getType() != Material.SIGN_POST) {
|
||||
state.setType(Material.SIGN_POST);
|
||||
state.update(true);
|
||||
state = war.refetchStateForBlock(warzone.getWorld(), signBlock);
|
||||
}
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
sign.setType(Material.SIGN_POST);
|
||||
sign.setData(new MaterialData(Material.SIGN_POST, (byte)signData));
|
||||
sign.setLine(0, "Team " + name);
|
||||
sign.setLine(1, remainingLives + "/" + warzone.getLifePool() + " lives left");
|
||||
sign.setLine(2, points + "/" + warzone.getScoreCap() + " pts");
|
||||
sign.setLine(3, players.size() + "/" + warzone.getTeamCap() + " players");
|
||||
if(sign.getLines() != null) {
|
||||
sign.setLine(0, "Team " + name);
|
||||
sign.setLine(1, remainingLives + "/" + warzone.getLifePool() + " lives left");
|
||||
sign.setLine(2, points + "/" + warzone.getScoreCap() + " pts");
|
||||
sign.setLine(3, players.size() + "/" + warzone.getTeamCap() + " players");
|
||||
sign.update(true);
|
||||
}
|
||||
}
|
||||
state.update(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,20 +106,21 @@ public class WarHub {
|
||||
|
||||
// War hub sign
|
||||
Block signBlock = locationBlock.getFace(BlockFace.WEST);
|
||||
BlockState state = signBlock.getState();
|
||||
if(state.getType() != Material.SIGN_POST) {
|
||||
state.setType(Material.SIGN_POST);
|
||||
|
||||
if(signBlock.getType() != Material.SIGN_POST) {
|
||||
signBlock.setType(Material.SIGN_POST);
|
||||
}
|
||||
state.setData(new MaterialData(Material.SIGN_POST, (byte)8));
|
||||
state.update(true);
|
||||
state = war.refetchStateForBlock(location.getWorld(), signBlock);
|
||||
signBlock.setData((byte)8);
|
||||
BlockState state = signBlock.getState();
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, "War hub");
|
||||
sign.setLine(1, "");
|
||||
sign.setLine(2, "Pick your battle!");
|
||||
sign.setLine(3, "");
|
||||
state.update(true);
|
||||
if(sign.getLines() != null) {
|
||||
sign.setLine(0, "War hub");
|
||||
sign.setLine(1, "");
|
||||
sign.setLine(2, "Pick your battle!");
|
||||
sign.setLine(3, "");
|
||||
sign.update(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Warzone signs
|
||||
@ -145,21 +146,21 @@ public class WarHub {
|
||||
zoneCap += zone.getTeamCap();
|
||||
}
|
||||
|
||||
BlockState state = block.getState();
|
||||
if(state.getType() != Material.SIGN_POST) {
|
||||
state.setType(Material.SIGN_POST);
|
||||
if(block.getType() != Material.SIGN_POST) {
|
||||
block.setType(Material.SIGN_POST);
|
||||
}
|
||||
state.setData(new MaterialData(Material.SIGN_POST, (byte)8));
|
||||
state.update(true);
|
||||
state = war.refetchStateForBlock(location.getWorld(), block);
|
||||
block.setData((byte)8);
|
||||
BlockState state = block.getState();
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, "Warzone");
|
||||
sign.setLine(1, zone.getName());
|
||||
sign.setLine(2, zonePlayers + "/" + zoneCap + " players");
|
||||
sign.setLine(3, zone.getTeams().size() + " teams");
|
||||
if(sign.getLines() != null) {
|
||||
sign.setLine(0, "Warzone");
|
||||
sign.setLine(1, zone.getName());
|
||||
sign.setLine(2, zonePlayers + "/" + zoneCap + " players");
|
||||
sign.setLine(3, zone.getTeams().size() + " teams");
|
||||
sign.update(true);
|
||||
}
|
||||
}
|
||||
state.update(true);
|
||||
}
|
||||
|
||||
public void setVolume(Volume vol) {
|
||||
|
@ -830,7 +830,7 @@ public class Warzone {
|
||||
war.msg(player, "Your inventory is in storage until you /leave.");
|
||||
respawnPlayer(lowestNoOfPlayers, player);
|
||||
for(Team team : teams){
|
||||
team.teamcast("" + player.getName() + " joined team " + team.getName() + ".");
|
||||
team.teamcast("" + player.getName() + " joined team " + lowestNoOfPlayers.getName() + ".");
|
||||
}
|
||||
}
|
||||
return lowestNoOfPlayers;
|
||||
@ -961,10 +961,10 @@ public class Warzone {
|
||||
}
|
||||
}
|
||||
|
||||
public void handlePlayerLeave(Player player, Location destination) {
|
||||
public void handlePlayerLeave(Player player, Location destination, boolean removeFromTeam) {
|
||||
Team playerTeam = war.getPlayerTeam(player.getName());
|
||||
if(playerTeam !=null) {
|
||||
playerTeam.removePlayer(player.getName());
|
||||
if(removeFromTeam) playerTeam.removePlayer(player.getName());
|
||||
playerTeam.resetSign();
|
||||
if(this.isFlagThief(player.getName())) {
|
||||
Team victim = this.getVictimTeamForThief(player.getName());
|
||||
@ -998,6 +998,10 @@ public class Warzone {
|
||||
// reset the zone for a new game when the last player leaves
|
||||
int resetBlocks = this.getVolume().resetBlocks();
|
||||
this.initializeZone();
|
||||
for(Team team : this.getTeams()) {
|
||||
team.setPoints(0);
|
||||
team.setRemainingLives(this.getLifePool());
|
||||
}
|
||||
war.logInfo("Last player left warzone " + this.getName() + ". " + resetBlocks + " blocks reset automatically.");
|
||||
}
|
||||
}
|
||||
|
@ -181,34 +181,35 @@ public class ZoneLobby {
|
||||
|
||||
// set zone sign
|
||||
Block zoneSignBlock = lobbyMiddleWallBlock.getFace(wall, 4);
|
||||
BlockState state = zoneSignBlock.getState();
|
||||
if(state.getType() != Material.SIGN_POST) {
|
||||
state.setType(Material.SIGN_POST);
|
||||
|
||||
if(zoneSignBlock.getType() != Material.SIGN_POST) {
|
||||
zoneSignBlock.setType(Material.SIGN_POST);
|
||||
}
|
||||
if(wall == BlockFace.NORTH) {
|
||||
state.setData(new MaterialData(Material.SIGN_POST, (byte)4));
|
||||
zoneSignBlock.setData((byte)4);
|
||||
} else if(wall == BlockFace.EAST) {
|
||||
state.setData(new MaterialData(Material.SIGN_POST, (byte)8));
|
||||
zoneSignBlock.setData((byte)8);
|
||||
} else if(wall == BlockFace.SOUTH) {
|
||||
state.setData(new MaterialData(Material.SIGN_POST, (byte)12));
|
||||
zoneSignBlock.setData((byte)12);
|
||||
} else if(wall == BlockFace.WEST) {
|
||||
state.setData(new MaterialData(Material.SIGN_POST, (byte)0));
|
||||
zoneSignBlock.setData((byte)0);
|
||||
}
|
||||
state.update(true);
|
||||
state = war.refetchStateForBlock(warzone.getWorld(), zoneSignBlock);
|
||||
BlockState state = zoneSignBlock.getState();
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, "Warzone");
|
||||
sign.setLine(1, warzone.getName());
|
||||
if(autoAssignGate != null) {
|
||||
sign.setLine(2, "Walk in the");
|
||||
sign.setLine(3, "auto-assign gate.");
|
||||
} else {
|
||||
sign.setLine(2, "");
|
||||
sign.setLine(3, "Pick your team.");
|
||||
if(sign.getLines() != null) {
|
||||
sign.setLine(0, "Warzone");
|
||||
sign.setLine(1, warzone.getName());
|
||||
if(autoAssignGate != null) {
|
||||
sign.setLine(2, "Walk in the");
|
||||
sign.setLine(3, "auto-assign gate.");
|
||||
} else {
|
||||
sign.setLine(2, "");
|
||||
sign.setLine(3, "Pick your team.");
|
||||
}
|
||||
sign.update(true);
|
||||
}
|
||||
}
|
||||
state.update(true);
|
||||
|
||||
// lets get some light in here
|
||||
if(wall == BlockFace.NORTH || wall == BlockFace.SOUTH) {
|
||||
@ -561,7 +562,6 @@ public class ZoneLobby {
|
||||
private void resetGateSign(Block gate, String[] lines, boolean awayFromWall) {
|
||||
Block block = null;
|
||||
BlockFace direction = null;
|
||||
BlockState state = null;
|
||||
if(awayFromWall) {
|
||||
direction = wall;
|
||||
} else if (wall == BlockFace.NORTH) {
|
||||
@ -576,40 +576,36 @@ public class ZoneLobby {
|
||||
|
||||
if(wall == BlockFace.NORTH) {
|
||||
block = gate.getFace(direction).getFace(BlockFace.EAST);
|
||||
state = block.getState();
|
||||
if(state.getType() != Material.SIGN_POST) state.setType(Material.SIGN_POST);
|
||||
if(awayFromWall) state.setData(new MaterialData(Material.SIGN_POST, (byte)4));
|
||||
else state.setData(new MaterialData(Material.SIGN_POST, (byte)12));
|
||||
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
|
||||
if(awayFromWall) block.setData((byte)4);
|
||||
else block.setData((byte)12);
|
||||
} else if(wall == BlockFace.EAST) {
|
||||
block = gate.getFace(direction).getFace(BlockFace.SOUTH);
|
||||
state = block.getState();
|
||||
if(state.getType() != Material.SIGN_POST) state.setType(Material.SIGN_POST);
|
||||
if(awayFromWall) state.setData(new MaterialData(Material.SIGN_POST, (byte)8));
|
||||
else state.setData(new MaterialData(Material.SIGN_POST, (byte)0));
|
||||
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
|
||||
if(awayFromWall) block.setData((byte)8);
|
||||
else block.setData((byte)0);
|
||||
} else if(wall == BlockFace.SOUTH) {
|
||||
block = gate.getFace(direction).getFace(BlockFace.WEST);
|
||||
state = block.getState();
|
||||
if(state.getType() != Material.SIGN_POST) state.setType(Material.SIGN_POST);
|
||||
if(awayFromWall) state.setData(new MaterialData(Material.SIGN_POST, (byte)12));
|
||||
else state.setData(new MaterialData(Material.SIGN_POST, (byte)4));
|
||||
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
|
||||
if(awayFromWall) block.setData((byte)12);
|
||||
else block.setData((byte)4);
|
||||
} else if(wall == BlockFace.WEST) {
|
||||
block = gate.getFace(direction).getFace(BlockFace.NORTH);
|
||||
state = block.getState();
|
||||
if(state.getType() != Material.SIGN_POST) state.setType(Material.SIGN_POST);
|
||||
if(awayFromWall) state.setData(new MaterialData(Material.SIGN_POST, (byte)0));
|
||||
else state.setData(new MaterialData(Material.SIGN_POST, (byte)8));
|
||||
if(block.getType() != Material.SIGN_POST) block.setType(Material.SIGN_POST);
|
||||
if(awayFromWall) block.setData((byte)0);
|
||||
else block.setData((byte)8);
|
||||
}
|
||||
state.update(true);
|
||||
state = war.refetchStateForBlock(warzone.getWorld(), block);
|
||||
BlockState state = block.getState();
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, lines[0]);
|
||||
sign.setLine(1, lines[1]);
|
||||
sign.setLine(2, lines[2]);
|
||||
sign.setLine(3, lines[3]);
|
||||
|
||||
if(sign.getLines() != null) {
|
||||
sign.setLine(0, lines[0]);
|
||||
sign.setLine(1, lines[1]);
|
||||
sign.setLine(2, lines[2]);
|
||||
sign.setLine(3, lines[3]);
|
||||
sign.update(true);
|
||||
}
|
||||
}
|
||||
state.update(true);
|
||||
}
|
||||
|
||||
public boolean isLeavingZone(Location location) {
|
||||
|
@ -393,7 +393,7 @@ public class WarzoneMapper {
|
||||
String rewardStr = "";
|
||||
HashMap<Integer, ItemStack> rewardItems = warzone.getReward();
|
||||
for(Integer slot : rewardItems.keySet()) {
|
||||
ItemStack item = items.get(slot);
|
||||
ItemStack item = rewardItems.get(slot);
|
||||
rewardStr += item.getTypeId() + "," + item.getAmount() + "," + slot + ";";
|
||||
}
|
||||
warzoneConfig.setString("reward", rewardStr);
|
||||
|
@ -78,7 +78,9 @@ public class Volume {
|
||||
if(state instanceof Sign) {
|
||||
// Signs
|
||||
Sign sign = (Sign)state;
|
||||
this.getSignLines().put("sign-" + i + "-" + j + "-" + k, sign.getLines());
|
||||
if(sign.getLines() != null) {
|
||||
this.getSignLines().put("sign-" + i + "-" + j + "-" + k, sign.getLines());
|
||||
}
|
||||
} else if(state instanceof Chest) {
|
||||
// Chests
|
||||
Chest chest = (Chest)state;
|
||||
@ -117,6 +119,7 @@ public class Volume {
|
||||
} catch (Exception e) {
|
||||
this.getWar().getLogger().warning("Failed to save volume " + getName() + " blocks. Saved blocks:" + noOfSavedBlocks
|
||||
+ ". Error at x:" + x + " y:" + y + " z:" + z + ". Exception:" + e.getClass().toString() + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return noOfSavedBlocks;
|
||||
}
|
||||
@ -145,66 +148,58 @@ public class Volume {
|
||||
|| oldBlockType == Material.CHEST.getId() || oldBlockType == Material.DISPENSER.getId())
|
||||
)
|
||||
) {
|
||||
|
||||
// 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();
|
||||
// }
|
||||
BlockState state = currentBlock.getState();
|
||||
if(oldBlockType == Material.WALL_SIGN.getId()
|
||||
|| oldBlockType == Material.SIGN_POST.getId()) {
|
||||
// Signs
|
||||
state.setType(Material.getMaterial(oldBlockType));
|
||||
state.setData(new MaterialData(oldBlockType, oldBlockData));
|
||||
state.update(true);
|
||||
state = war.refetchStateForBlock(world, state.getBlock());
|
||||
Sign sign = (Sign)state;
|
||||
String[] lines = this.getSignLines().get("sign-" + i + "-" + j + "-" + k);
|
||||
if(lines != null) {
|
||||
if(lines.length>0)sign.setLine(0, lines[0]);
|
||||
if(lines.length>1)sign.setLine(1, lines[1]);
|
||||
if(lines.length>2)sign.setLine(2, lines[2]);
|
||||
if(lines.length>3)sign.setLine(3, lines[3]);
|
||||
sign.update(true);
|
||||
currentBlock.setType(Material.getMaterial(oldBlockType));
|
||||
currentBlock.setData(oldBlockData);
|
||||
BlockState state = currentBlock.getState();
|
||||
if(state instanceof Sign) {
|
||||
Sign sign = (Sign)state;
|
||||
String[] lines = this.getSignLines().get("sign-" + i + "-" + j + "-" + k);
|
||||
if(lines != null && sign.getLines() != null) {
|
||||
if(lines.length>0)sign.setLine(0, lines[0]);
|
||||
if(lines.length>1)sign.setLine(1, lines[1]);
|
||||
if(lines.length>2)sign.setLine(2, lines[2]);
|
||||
if(lines.length>3)sign.setLine(3, lines[3]);
|
||||
sign.update(true);
|
||||
}
|
||||
}
|
||||
} else if(oldBlockType == Material.CHEST.getId()) {
|
||||
// Chests
|
||||
state.setType(Material.getMaterial(oldBlockType));
|
||||
state.setData(new MaterialData(oldBlockType, oldBlockData));
|
||||
state.update(true);
|
||||
state = war.refetchStateForBlock(world, state.getBlock());
|
||||
Chest chest = (Chest)state;
|
||||
List<ItemStack> contents = this.getInvBlockContents().get("chest-" + i + "-" + j + "-" + k);
|
||||
if(contents != null) {
|
||||
int ii = 0;
|
||||
chest.getInventory().clear();
|
||||
for(ItemStack item : contents) {
|
||||
chest.getInventory().setItem(ii, item);
|
||||
ii++;
|
||||
currentBlock.setType(Material.getMaterial(oldBlockType));
|
||||
currentBlock.setData(oldBlockData);
|
||||
BlockState state = currentBlock.getState();
|
||||
if(state instanceof Chest) {
|
||||
Chest chest = (Chest)state;
|
||||
List<ItemStack> contents = this.getInvBlockContents().get("chest-" + i + "-" + j + "-" + k);
|
||||
if(contents != null) {
|
||||
int ii = 0;
|
||||
chest.getInventory().clear();
|
||||
for(ItemStack item : contents) {
|
||||
chest.getInventory().setItem(ii, item);
|
||||
ii++;
|
||||
}
|
||||
chest.update(true);
|
||||
}
|
||||
chest.update(true);
|
||||
}
|
||||
} else if(oldBlockType == Material.DISPENSER.getId()) {
|
||||
// Dispensers
|
||||
state.setType(Material.getMaterial(oldBlockType));
|
||||
state.setData(new MaterialData(oldBlockType, oldBlockData));
|
||||
state.update(true);
|
||||
state = war.refetchStateForBlock(world, state.getBlock());
|
||||
Dispenser dispenser = (Dispenser)state;
|
||||
List<ItemStack> contents = this.getInvBlockContents().get("dispenser-" + i + "-" + j + "-" + k);
|
||||
if(contents != null) {
|
||||
int ii = 0;
|
||||
dispenser.getInventory().clear();
|
||||
for(ItemStack item : contents) {
|
||||
dispenser.getInventory().setItem(ii, item);
|
||||
ii++;
|
||||
currentBlock.setType(Material.getMaterial(oldBlockType));
|
||||
currentBlock.setData(oldBlockData);
|
||||
BlockState state = currentBlock.getState();
|
||||
if(state instanceof Dispenser) {
|
||||
Dispenser dispenser = (Dispenser)state;
|
||||
List<ItemStack> contents = this.getInvBlockContents().get("dispenser-" + i + "-" + j + "-" + k);
|
||||
if(contents != null) {
|
||||
int ii = 0;
|
||||
dispenser.getInventory().clear();
|
||||
for(ItemStack item : contents) {
|
||||
dispenser.getInventory().setItem(ii, item);
|
||||
ii++;
|
||||
}
|
||||
dispenser.update(true);
|
||||
}
|
||||
dispenser.update(true);
|
||||
}
|
||||
} else if(oldBlockType == Material.WOODEN_DOOR.getId() || oldBlockType == Material.IRON_DOOR_BLOCK.getId()){
|
||||
// Door blocks
|
||||
@ -237,6 +232,7 @@ public class Volume {
|
||||
this.getWar().logWarn("Failed to reset volume " + getName() + " blocks. Blocks visited: " + visitedBlocks
|
||||
+ ". Blocks reset: "+ noOfResetBlocks + ". Error at x:" + x + " y:" + y + " z:" + z
|
||||
+ ". Current block: " + currentBlockId + ". Old block: " + oldBlockType + ". Exception: " + e.getClass().toString() + " " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return noOfResetBlocks;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user