cleaned up /sethome old bed removal, as previous way would delete any beds around the home bed, which would destroy

This commit is contained in:
NewGarbo 2015-11-18 12:29:22 +00:00
parent 9eaffc8acf
commit 5c383a1df3

View File

@ -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<ClansManager>
// 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!!!]");
}
}