Fixed casting error when the heads command is used
This commit is contained in:
parent
3734f2af1f
commit
5a73226c9d
@ -3,14 +3,11 @@ package net.theprogrammersworld.herobrine.misc;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.block.data.Rotatable;
|
||||
|
||||
public class BlockChanger {
|
||||
|
||||
@ -96,31 +93,23 @@ public class BlockChanger {
|
||||
}
|
||||
|
||||
public static void PlaceSkull(final Location loc, final UUID uuid) {
|
||||
final int chance = new Random().nextInt(7);
|
||||
final int chance = new Random().nextInt(4);
|
||||
BlockFace bface;
|
||||
|
||||
final Block b = loc.getBlock();
|
||||
b.setType(Material.PLAYER_HEAD);
|
||||
|
||||
BlockFace bface = BlockFace.EAST;
|
||||
|
||||
if (chance == 0) {
|
||||
if (chance == 0)
|
||||
bface = BlockFace.WEST;
|
||||
} else if (chance == 1) {
|
||||
else if (chance == 1)
|
||||
bface = BlockFace.EAST;
|
||||
} else if (chance == 2) {
|
||||
else if (chance == 2)
|
||||
bface = BlockFace.SOUTH;
|
||||
} else if (chance == 3) {
|
||||
else
|
||||
bface = BlockFace.NORTH;
|
||||
}
|
||||
|
||||
BlockData blockData = b.getBlockData();
|
||||
((Directional) blockData).setFacing(bface);
|
||||
|
||||
Block b = loc.getBlock();
|
||||
b.setType(Material.PLAYER_HEAD);
|
||||
Rotatable blockData = (Rotatable) b.getBlockData();
|
||||
blockData.setRotation(bface);
|
||||
b.setBlockData(blockData);
|
||||
|
||||
final Skull skull = (Skull) b.getState();
|
||||
skull.setOwningPlayer(Bukkit.getOfflinePlayer(uuid));
|
||||
|
||||
skull.update(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user