diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 60bc9a835..d525328b7 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; @@ -895,15 +896,48 @@ public class ClansCommand extends CommandBase // Cleanup old if (clan.getHome() != null) { - for (int x = -2; x < 2; x++) + byte data = clan.getHome().getBlock().getData(); + + EnumDirection dir = null; + int xModif = 0; + int zModif = 0; + + if ((data & (1 << 0x2)) != 0) { - for (int z = -2; z < 2; z++) - { - if (clan.getHome().clone().add(x, 0, z).getBlock().getType().equals(Material.BED_BLOCK)) - { - clan.getHome().clone().add(x, 0, z).getBlock().setType(Material.AIR); - } - } + zModif = -1; + dir = EnumDirection.NORTH; + } + else if ((data & (1 << 0x0)) != 0) + { + zModif = 1; + dir = EnumDirection.SOUTH; + } + else if ((data & (1 << 0x1)) != 0) + { + xModif = -1; + dir = EnumDirection.WEST; + } + else if ((data & (1 << 0x3)) != 0) + { + xModif = 1; + dir = EnumDirection.EAST; + } + + if (dir == null) + { + return; + } + + Block footBlock = clan.getHome().clone().add(xModif, 0, zModif).getBlock(); + if (footBlock.getType().equals(Material.BED_BLOCK)) + { + footBlock.setType(Material.AIR); + clan.getHome().getBlock().setType(Material.AIR); + } + else + { + // Shoudln't happen, but just in case: + System.out.println("Second block of " + clan.getName() + "'s Clan Home should be a bed, but isn't. [STRANGE!!!]"); } }