Remove deprecation with player skulls

This commit is contained in:
JediMasterSoda 2019-07-07 17:30:35 -05:00
parent 2c2f4d8f08
commit a92b3e7f07
3 changed files with 20 additions and 8 deletions

View File

@ -2,6 +2,7 @@ package net.theprogrammersworld.herobrine.AI.cores;
import java.util.ArrayList;
import java.util.Random;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -57,7 +58,7 @@ public class Heads extends Core {
}
final Block block = loc.getWorld().getBlockAt(px + x, y, pz + z);
if (loc.getBlock().getType().equals(Material.AIR)) {
BlockChanger.PlaceSkull(block.getLocation(), "Herobrine");
BlockChanger.PlaceSkull(block.getLocation(), UUID.fromString("f84c6a79-0a4e-45e0-879b-cd49ebd4c4e2"));
headList.add(block);
}
}

View File

@ -67,6 +67,7 @@ public class Signs extends Core {
final Block undersignblock = signblock.getLocation().subtract(0.0, 1.0, 0.0).getBlock();
if (Herobrine.isAllowedBlock(signblock.getType()) && !Herobrine.isAllowedBlock(undersignblock.getType())) {
signblock.setType(Material.matchMaterial("SIGN_POST"));
final Sign sign = (Sign) signblock.getState();
BlockData blockData = sign.getBlockData();

View File

@ -1,13 +1,16 @@
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.SkullType;
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;
public class BlockChanger {
@ -92,14 +95,14 @@ public class BlockChanger {
return dir;
}
public static void PlaceSkull(final Location loc, final String name) {
public static void PlaceSkull(final Location loc, final UUID uuid) {
final int chance = new Random().nextInt(7);
final Block b = loc.getBlock();
b.setType(Material.matchMaterial("SKULL"));
final Skull skull = (Skull) b.getState();
skull.setSkullType(SkullType.PLAYER);
skull.setOwner(name);
b.setType(Material.PLAYER_HEAD);
BlockFace bface = BlockFace.EAST;
if (chance == 0) {
bface = BlockFace.WEST;
} else if (chance == 1) {
@ -109,7 +112,14 @@ public class BlockChanger {
} else if (chance == 3) {
bface = BlockFace.NORTH;
}
skull.setRawData((byte) bface.ordinal());
BlockData blockData = b.getBlockData();
((Directional) blockData).setFacing(bface);
b.setBlockData(blockData);
final Skull skull = (Skull) b.getState();
skull.setOwningPlayer(Bukkit.getOfflinePlayer(uuid));
skull.update(true);
}