Java 类org.bukkit.block.Skull 实例源码

项目:NeverLag    文件:AntiDamageSkull.java   
@Override
public void run() {
    if (loc == null) {
        return;
    }
    Block b = loc.getBlock();
    if (b.getType() != Material.SKULL) {
        return;
    }
    Skull skull = (Skull) b.getState();
    if (type == SkullType.PLAYER) {
        skull.setSkullType(type);
        skull.setOwner(owner);
    } else {
        skull.setSkullType(type);
    }
    skull.update();
}
项目:VoxelGamesLibv2    文件:MapScanner.java   
@Nullable
private String getMarkerData(@Nonnull Skull skull) {
    if (skull.getOwningPlayer() != null) {
        String markerData = skull.getOwningPlayer().getName();
        if (markerData == null) {
            log.warning("owning player name null?!");
            markerData = skull.getOwner();
            if (markerData == null) {
                log.warning("just set it to undefined...");
                markerData = "undefined";
            }
        }
        return markerData;
    } else {
        return null;
    }
}
项目:libelula    文件:ArenaManager.java   
public boolean delScoreHead(Skull head, String arenaName) {
    boolean result = true;
    Arena arena = arenas.get(arenaName);
    if (arena != null) {
        if (arena.scoreHeads != null && !arena.scoreHeads.isEmpty()) {
            Location lastLoc = arena.scoreHeads.get(arena.scoreHeads.size() - 1).getLocation();
            if (Tools.compareLocationBlocks(lastLoc, head.getLocation()) != 0) {
                result = false;
            } else {
                arena.scoreHeads.remove(arena.scoreHeads.size() - 1);
                if (arena.scoreHeads.isEmpty()) {
                    arena.scoreHeads = null;
                }
            }
        }
    }
    return result;
}
项目:libelula    文件:EventManager.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBlockPlace(BlockPlaceEvent e) {
    setupEvents setupEvent = setupPlayers.get(e.getPlayer());
    switch (setupEvent) {
        case HEADS:
            if (e.getBlock().getType() == Material.SKULL) {
                //Skull skull = new CraftSkull(e.getBlock());
                Skull skull = (Skull) e.getBlock().getState();
                plugin.am.addScoreHead(skull,
                        setupPlayersArena.get(e.getPlayer()));
                e.getPlayer().sendMessage(plugin.lm.getText("score-heads-added"));
                e.getPlayer().sendMessage(plugin.lm.getText("listen-setup-finish"));
            }
            break;
    }
}
项目:libelula    文件:EventManager.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onBlockBreak(BlockBreakEvent e) {
    setupEvents setupEvent = setupPlayers.get(e.getPlayer());
    switch (setupEvent) {
        case HEADS:
            if (e.getBlock().getType() == Material.SKULL) {
                //Skull skull = new CraftSkull(e.getBlock());
                Skull skull = (Skull) e.getBlock().getState();
                if (plugin.am.delScoreHead(skull,
                        setupPlayersArena.get(e.getPlayer()))) {
                    e.getPlayer().sendMessage(plugin.lm.getText("score-heads-removed"));
                    e.getPlayer().sendMessage(plugin.lm.getText("listen-setup-finish"));
                } else {
                    e.getPlayer().sendMessage(plugin.lm.getText("score-heads-desordered-del"));
                    e.setCancelled(true);
                }
            }
            break;
    }
}
项目:Slimefun4    文件:ChargableBlock.java   
private static void updateTexture(final Location l) throws Exception {
    Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {

        @Override
        public void run() {
            try {
                Block b = l.getBlock();
                int charge = getCharge(b), capacity = getMaxCharge(b);
                if (b.getState() instanceof Skull) {
                    if (charge < (int) (capacity * 0.25D)) CustomSkull.setSkull(b, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTEzNjFlNTc2YjQ5M2NiZmRmYWUzMjg2NjFjZWRkMWFkZDU1ZmFiNGU1ZWI0MThiOTJjZWJmNjI3NWY4YmI0In19fQ==");
                    else if (charge < (int) (capacity * 0.5D)) CustomSkull.setSkull(b, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzA1MzIzMzk0YTdkOTFiZmIzM2RmMDZkOTJiNjNjYjQxNGVmODBmMDU0ZDA0NzM0ZWEwMTVhMjNjNTM5In19fQ==");
                    else if (charge < (int) (capacity * 0.75D)) CustomSkull.setSkull(b, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTU4NDQzMmFmNmYzODIxNjcxMjAyNThkMWVlZThjODdjNmU3NWQ5ZTQ3OWU3YjBkNGM3YjZhZDQ4Y2ZlZWYifX19");
                    else CustomSkull.setSkull(b, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2EyNTY5NDE1YzE0ZTMxYzk4ZWM5OTNhMmY5OWU2ZDY0ODQ2ZGIzNjdhMTNiMTk5OTY1YWQ5OWM0MzhjODZjIn19fQ==");
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}
项目:Slimefun4    文件:ProgrammableAndroid.java   
@SuppressWarnings("deprecation")
private void move(Block b, BlockFace face, Block block) throws Exception {
    if (block.getY() < 0 || block.getY() > block.getWorld().getMaxHeight()) return;

    if (block.getType() == Material.AIR) {
        block.setType(Material.SKULL);
        block.setData((byte) 1);

        Skull skull = (Skull) block.getState();
        skull.setRotation(face);
        skull.update(true, false);
        CustomSkull.setSkull(block, CustomSkull.getTexture(getItem()));
        b.setType(Material.AIR);
        BlockStorage.moveBlockInfo(b, block);
    }
}
项目:acidisland    文件:SkullBlock.java   
@SuppressWarnings("deprecation")
public boolean set(Block block) {
    Skull skull = (Skull) block.getState();
    if(skullOwnerName != null){
        skull.setOwner(skullOwnerName);
    }
    skull.setSkullType(skullType);
    skull.setRotation(skullRotation);
    skull.setRawData((byte) skullStanding);
    // Texture update
    if(skullTextureValue != null){
        setSkullWithNonPlayerProfile(skullTextureValue, skullTextureSignature, skullOwnerUUID, skullOwnerName, skull);
    }
    skull.update(true, false);
    return true;
}
项目:askyblock    文件:SkullBlock.java   
@SuppressWarnings("deprecation")
public boolean set(Block block) {
    Skull skull = (Skull) block.getState();
    if(skullOwnerName != null){
        skull.setOwner(skullOwnerName);
    }
    skull.setSkullType(skullType);
    skull.setRotation(skullRotation);
    skull.setRawData((byte) skullStanding);
    // Texture update
    if(skullTextureValue != null){
        setSkullWithNonPlayerProfile(skullTextureValue, skullTextureSignature, skullOwnerUUID, skullOwnerName, skull);
    }
    skull.update(true, false);
    return true;
}
项目:Slimefun4-Chinese-Version    文件:ChargableBlock.java   
private static void updateTexture(final Location l)
        throws Exception
    {
        Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {

            private final Location val$l;

            public void run()
            {
                try
                {
                    Block b = l.getBlock();
                    int charge = ChargableBlock.getCharge(b);
                    int capacity = ChargableBlock.getMaxCharge(b);
                    if(b.getState() instanceof Skull)
                        if(charge < (int)((double)capacity * 0.25D))
                            CustomSkull.setSkull(b, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTEzNjFlNTc2YjQ5M2NiZmRmYWUzMjg2NjFjZWRkMWFkZDU1ZmFiNGU1ZWI0MThiOTJjZWJmNjI3NWY4YmI0In19fQ==");
                        else
                        if(charge < (int)((double)capacity * 0.5D))
                            CustomSkull.setSkull(b, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzA1MzIzMzk0YTdkOTFiZmIzM2RmMDZkOTJiNjNjYjQxNGVmODBmMDU0ZDA0NzM0ZWEwMTVhMjNjNTM5In19fQ==");
                        else
                        if(charge < (int)((double)capacity * 0.75D))
                            CustomSkull.setSkull(b, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTU4NDQzMmFmNmYzODIxNjcxMjAyNThkMWVlZThjODdjNmU3NWQ5ZTQ3OWU3YjBkNGM3YjZhZDQ4Y2ZlZWYifX19");
                        else
                            CustomSkull.setSkull(b, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvN2EyNTY5NDE1YzE0ZTMxYzk4ZWM5OTNhMmY5OWU2ZDY0ODQ2ZGIzNjdhMTNiMTk5OTY1YWQ5OWM0MzhjODZjIn19fQ==");
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }


            {
                l = location;
                super();
            }
        }
);
    }
项目:SamaGamesAPI    文件:BlockUtils.java   
/**
 * Set the given texture to a skull placed in the world
 *
 * @param texture Base64 texture
 */
public static void setCustomSkull(Block block, String texture)
{
    block.setType(Material.SKULL);

    Skull skullData = (Skull) block.getState();
    skullData.setSkullType(SkullType.PLAYER);

    World world = ((CraftWorld) block.getWorld()).getHandle();
    ((TileEntitySkull) world.getTileEntity(new BlockPosition(block.getX(), block.getY(), block.getZ()))).setGameProfile(ItemUtils.getHeadCustomizedGameProfile(texture));

    block.getState().update(true);
}
项目:ProjectAres    文件:WorldProblemMatchModule.java   
private void checkChunk(ChunkPosition pos, @Nullable Chunk chunk) {
    if(repairedChunks.add(pos)) {
        if(chunk == null) {
            chunk = pos.getChunk(match.getWorld());
        }

        for(BlockState state : chunk.getTileEntities()) {
            if(state instanceof Skull) {
                if(!NMSHacks.isSkullCached((Skull) state)) {
                    Location loc = state.getLocation();
                    broadcastDeveloperWarning("Uncached skull \"" + ((Skull) state).getOwner() + "\" at " + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ());
                }
            }
        }

        // Replace formerly invisible half-iron-door blocks with barriers
        for(Block ironDoor : chunk.getBlocks(Material.IRON_DOOR_BLOCK)) {
            BlockFace half = (ironDoor.getData() & 8) == 0 ? BlockFace.DOWN : BlockFace.UP;
            if(ironDoor.getRelative(half.getOppositeFace()).getType() != Material.IRON_DOOR_BLOCK) {
                ironDoor.setType(Material.BARRIER, false);
            }
        }

        // Remove all block 36 and remember the ones at y=0 so VoidFilter can check them
        for(Block block36 : chunk.getBlocks(Material.PISTON_MOVING_PIECE)) {
            if(block36.getY() == 0) {
                block36Locations.add(block36.getX(), block36.getY(), block36.getZ());
            }
            block36.setType(Material.AIR, false);
        }
    }
}
项目:MinecraftMarket-Plugin    文件:SkullUtils.java   
@SuppressWarnings("deprecation")
public static void setSkullWithNonPlayerProfile(String skinURL, String name, Block skullBlock) {
    if (skullBlock.getState() instanceof Skull) {
        Skull skull = (Skull) skullBlock.getState();
        try {
            setSkullProfile(skull, getNonPlayerProfile(skinURL, name));
        } catch (Exception e) {
            e.printStackTrace();
        }
        skullBlock.getWorld().refreshChunk(skullBlock.getChunk().getX(), skullBlock.getChunk().getZ());
    }
}
项目:MinecraftMarket-Plugin    文件:SkullUtils.java   
private static void setSkullProfile(Skull skull, GameProfile someGameProfile) {
    ReflectionUtils.RefClass classCraftWorld = ReflectionUtils.getRefClass("{cb}.CraftWorld");
    ReflectionUtils.RefMethod methodGetHandle = classCraftWorld.getMethod("getHandle");
    Object world = methodGetHandle.of(skull.getWorld()).call();
    ReflectionUtils.RefClass classBlockPosition = ReflectionUtils.getRefClass("{nms}.BlockPosition");
    ReflectionUtils.RefConstructor constructorBlockPosition = classBlockPosition.getConstructor(int.class, int.class, int.class);
    ReflectionUtils.RefClass classWorldServer = ReflectionUtils.getRefClass("{nms}.WorldServer");
    ReflectionUtils.RefMethod methodGetTileEntity = classWorldServer.getMethod("getTileEntity", classBlockPosition.getRealClass());
    Object tileSkull = methodGetTileEntity.of(world).call(constructorBlockPosition.create(skull.getX(), skull.getY(), skull.getZ()));
    ReflectionUtils.RefClass classTileEntitySkull = ReflectionUtils.getRefClass("{nms}.TileEntitySkull");
    ReflectionUtils.RefMethod methodSetGameProfile = classTileEntitySkull.getMethod("setGameProfile", GameProfile.class);
    methodSetGameProfile.of(tileSkull).call(someGameProfile);
}
项目:NeverLag    文件:AntiDamageSkull.java   
private void fixSkull(Block block) {
    if (block != null && Material.SKULL == block.getType()) {
        Skull skull = (Skull) block.getState();
        if (skull.getSkullType() != SkullType.SKELETON) {
            final FixSkullTask task = new FixSkullTask(block.getLocation(), skull.getSkullType(), skull.getOwner());
            Bukkit.getServer().getScheduler().runTaskLater(NeverLag.getInstance(), task, 1L);
        }
    }
}
项目:HCFCore    文件:SkullListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        Player player = event.getPlayer();
        BlockState state = event.getClickedBlock().getState();
        if (state instanceof Skull) {
            Skull skull = (Skull) state;
            player.sendMessage(ChatColor.YELLOW + "This is " + ChatColor.WHITE
                    + (skull.getSkullType() == SkullType.PLAYER && skull.hasOwner() ? skull.getOwner() : "a " + WordUtils.capitalizeFully(skull.getSkullType().name()) + " skull") + ChatColor.YELLOW
                    + '.');
        }
    }
}
项目:HCFCore    文件:SkullListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        Player player = event.getPlayer();
        BlockState state = event.getClickedBlock().getState();
        if (state instanceof Skull) {
            Skull skull = (Skull) state;
            player.sendMessage(ChatColor.YELLOW + "This is " + ChatColor.WHITE
                    + (skull.getSkullType() == SkullType.PLAYER && skull.hasOwner() ? skull.getOwner() : "a " + WordUtils.capitalizeFully(skull.getSkullType().name()) + " skull") + ChatColor.YELLOW
                    + '.');
        }
    }
}
项目:VoxelGamesLibv2    文件:HeadTextureChanger.java   
public static void applyTextureToSkull(Skull skull, Object profile) throws Exception {
    Location location = skull.getLocation();
    int x = location.getBlockX();
    int y = location.getBlockY();
    int z = location.getBlockZ();
    Object world = Minecraft.getHandle(location.getWorld());
    Object tileEntity = WorldServerMethodResolver.resolve("getTileEntity").invoke(world, x, y, z);
    TileEntitySkullFieldResolver.resolveByFirstType(GameProfile).set(tileEntity, profile);
    WorldMethodResolver.resolve(new ResolverQuery("notify", int.class, int.class, int.class)).invoke(world, x, y, z);
}
项目:Steel    文件:BlockStateSerializer.java   
@SuppressWarnings("deprecation")
public static Optional<String> serializeState(BlockState state) {
    YamlConfiguration yaml = new YamlConfiguration();

    // http://minecraft.gamepedia.com/Block_entity was used as a reference for this method

    if (state instanceof InventoryHolder) {
        yaml.set(INVENTORY_KEY, InventoryHelper.serializeInventory(((InventoryHolder) state).getInventory()));
    }

    if (state instanceof Sign) {
        yaml.set(SIGN_LINES_KEY, Arrays.asList(((Sign) state).getLines()));
    } else if (Support.BANNER && state instanceof Banner) {
        yaml.set(BANNER_BASE_COLOR_KEY, ((Banner) state).getBaseColor().name());
        ConfigurationSection patternSection = yaml.createSection(BANNER_PATTERNS_KEY);
        List<Pattern> patterns = ((Banner) state).getPatterns();
        for (int i = 0; i < patterns.size(); i++) {
            ConfigurationSection subSection = patternSection.createSection("" + i);
            subSection.set(BANNER_PATTERN_COLOR_KEY, patterns.get(i).getColor().name());
            subSection.set(BANNER_PATTERN_TYPE_KEY, patterns.get(i).getPattern().name());
        }
    } else if (state instanceof CreatureSpawner) {
        yaml.set(SPAWNER_TYPE_KEY, ((CreatureSpawner) state).getSpawnedType().name());
        yaml.set(SPAWNER_DELAY_KEY, ((CreatureSpawner) state).getDelay());
    } else if (state instanceof NoteBlock) {
        yaml.set(NOTE_OCTAVE_KEY, ((NoteBlock) state).getNote().getOctave());
        yaml.set(NOTE_TONE_KEY, ((NoteBlock) state).getNote().getTone().name());
    } else if (state instanceof Jukebox) {
        if (((Jukebox) state).isPlaying()) {
            yaml.set(JUKEBOX_DISC_KEY, ((Jukebox) state).getPlaying());
        }
    } else if (state instanceof Skull) {
        yaml.set(SKULL_OWNER_KEY, ((Skull) state).getOwner());
        yaml.set(SKULL_ROTATION_KEY, ((Skull) state).getRotation().name());
    } else if (state instanceof CommandBlock) {
        yaml.set(COMMAND_NAME_KEY, ((CommandBlock) state).getName());
        yaml.set(COMMAND_CMD_KEY, ((CommandBlock) state).getCommand());
    } else if (state instanceof FlowerPot) {
        yaml.set(FLOWER_TYPE_KEY, ((FlowerPot) state).getContents().getItemType().name());
        yaml.set(FLOWER_DATA_KEY, ((FlowerPot) state).getContents().getData());
    }

    if (yaml.getKeys(false).size() > 0) {
        return Optional.of(yaml.saveToString());
    }
    return Optional.absent();
}
项目:libelula    文件:ArenaManager.java   
public void addScoreHead(Skull head, String arenaName) {

        Arena arena = arenas.get(arenaName);
        if (arena != null) {
            if (arena.scoreHeads == null) {
                arena.scoreHeads = new TreeMap<>();
            }
            arena.scoreHeads.put(arena.scoreHeads.size(), head);
        }
    }
项目:libelula    文件:GameManager.java   
public final void clearHeads(ArenaManager.Arena arena) {
    TreeMap<Integer, Skull> skulls = arena.getScoreHeads();
    if (skulls != null) {
        for (Skull skull : skulls.values()) {
            skull.getBlock().setType(Material.AIR);
        }
    }
}
项目:IZenith-Main    文件:InteractListener.java   
@EventHandler
public void onClick(final PlayerInteractEvent e) {
    Action a = e.getAction();
    if (a.equals(Action.RIGHT_CLICK_BLOCK)) {
        Player p = e.getPlayer();
        BlockState b = e.getClickedBlock().getState(); //b is the block
        if (b instanceof Skull) { //this test if b is a skull
            if (!(p.isSneaking()) || (p.getItemInHand().getType() == Material.AIR)){
                Skull s = (Skull) b;
                String owner = s.getOwner();
                if (owner == null) {
                } else {
                    p.sendMessage(ChatColor.YELLOW + "That is the head of " + ChatColor.GOLD + owner + ChatColor.YELLOW + ".");
                    e.setCancelled(true);
                }
            }
        }
    }

    ItemStack item = e.getItem();
    if (e.getPlayer().getLocation().getWorld().getName().equals("spawn") && item != null && e.getItem().getType().equals(Material.NETHER_STAR)) {
        Vars.tpGUI.open(e.getPlayer());
    }

    if(e.getPlayer().getWorld().getName().equals("spawn") && e.getClickedBlock().getType().equals(Material.STONE_BUTTON)){
        e.setCancelled(false);
    }
}
项目:acidisland    文件:SkullBlock.java   
private static void setSkullProfile(Skull skull, GameProfile gameProfile) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {  

        Field profileField = null;
        try {
            profileField = skull.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(skull, gameProfile);
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
项目:MagicLib    文件:CompatibilityUtils.java   
public static Object getSkullProfile(Skull state)
{
    Object profile = null;
    try {
        if (state == null || !class_CraftSkull.isInstance(state)) return false;
        profile = class_CraftSkull_profile.get(state);
    } catch (Exception ex) {

    }
    return profile;
}
项目:MagicLib    文件:CompatibilityUtils.java   
public static boolean setSkullProfile(Skull state, Object data)
{
    try {
        if (state == null || !class_CraftSkull.isInstance(state)) return false;
        class_CraftSkull_profile.set(state, data);
        return true;
    } catch (Exception ex) {

    }

    return false;
}
项目:MagicLib    文件:CompatibilityUtils.java   
public static boolean setSkullOwner(Skull state, String playerName, UUID playerId)
{
    // TODO: This could be done directly, but is kind of tricky.
    ItemStack skullItem = InventoryUtils.getPlayerSkull(playerName, playerId);
    if (skullItem == null) {
        return false;
    }

    return setSkullProfile(state, InventoryUtils.getSkullProfile(skullItem.getItemMeta()));

}
项目:askyblock    文件:SkullBlock.java   
private static void setSkullProfile(Skull skull, GameProfile gameProfile) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {  

        Field profileField = null;
        try {
            profileField = skull.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(skull, gameProfile);
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
项目:sensibletoolbox    文件:STBUtil.java   
/**
 * Create a skull with the given player skin
 *
 * @param b      block in which to create the skull
 * @param name   name of the skin
 * @param direction direction the skull should face
 * @return the skull (the caller should call skull.update() when ready)
 */
public static Skull setSkullHead(Block b, String name, BlockFace direction) {
    b.setType(Material.SKULL);
    Skull skull = (Skull) b.getState();
    skull.setSkullType(SkullType.PLAYER);
    skull.setOwner(name);
    org.bukkit.material.Skull sk = (org.bukkit.material.Skull) skull.getData();
    sk.setFacingDirection(BlockFace.SELF);
    skull.setData(sk);
    skull.setRotation(direction);
    return skull;
}
项目:sensibletoolbox    文件:TrashCan.java   
@Override
public void onBlockRegistered(Location location, boolean isPlacing) {
    if (isPlacing) {
        // put a skull on top of the main block
        Block above = location.getBlock().getRelative(BlockFace.UP);
        Skull skull = STBUtil.setSkullHead(above, "MHF_Exclamation", getFacing());
        skull.update();
    }

    super.onBlockRegistered(location, isPlacing);
}
项目:sensibletoolbox    文件:PaintCan.java   
@Override
public void onBlockRegistered(Location location, boolean isPlacing) {
    if (isPlacing) {
        Block above = location.getBlock().getRelative(BlockFace.UP);
        Skull skull = STBUtil.setSkullHead(above, "MHF_OakLog", getFacing());
        skull.update();
    }

    super.onBlockRegistered(location, isPlacing);
}
项目:Bytecraft    文件:BytecraftPlayerListener.java   
@EventHandler
public void onPlayerClick(PlayerInteractEvent event)
{
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
        return;
    }
    Player player = event.getPlayer();
    BlockState block = event.getClickedBlock().getState();
    if (block instanceof Skull) {
        Skull skull = (Skull) block;
        if (!skull.getSkullType().equals(SkullType.PLAYER)) {
            return;
        }
        String owner = skull.getOwner();
        BytecraftPlayer skullowner = plugin.getPlayerOffline(owner);
        if (skullowner != null) {
            ChatColor C = skullowner.getNameColor();
            player.sendMessage(ChatColor.AQUA + "This is " + C + owner
                    + "'s " + ChatColor.AQUA + "head!");
        }
        else {
            player.sendMessage(ChatColor.AQUA + "This is "
                    + ChatColor.WHITE + owner + ChatColor.AQUA + "'s head!");

        }
    }
}
项目:tregmine    文件:Arena.java   
private void setWinnerHead(Player p)
{
    ConfigurationSection conf = SettingsManager.getInstance().get(id + "");

    this.head = getLocation(conf.getConfigurationSection("head" + "." + "latestwinner"));
    this.rotation = getRotation(conf.getConfigurationSection("head" + "." + "latestwinner"));

    BlockState block = head.getBlock().getState();

    Skull skull = (Skull) block;
    skull.setSkullType(SkullType.PLAYER);
    skull.setOwner(p.getName());
    skull.setRotation(BlockFace.valueOf(rotation));
    skull.update();
}
项目:NPlugins    文件:RelativeSkullBlock.java   
@Override
public void setAdditionalData(final Block block) {
    final Skull skullState = (Skull)block.getState();
    skullState.setSkullType(this.type);
    skullState.setRotation(this.rotation);
    skullState.update();
}
项目:ProjectAres    文件:NMSHacks.java   
/**
 * Test if a {@link Skull} has a cached skin. If this returns false, the skull will
 * likely try to fetch its skin the next time it is loaded.
 */
public static boolean isSkullCached(Skull skull) {
    TileEntitySkull nmsSkull = (TileEntitySkull) ((CraftWorld) skull.getWorld()).getTileEntityAt(skull.getX(), skull.getY(), skull.getZ());
    return nmsSkull.getGameProfile() == null ||
           nmsSkull.getGameProfile().getProperties().containsKey("textures");
}
项目:VoxelGamesLibv2    文件:MapScanner.java   
/**
 * Searches the map for "markers". Most of the time these are implemented as tile entities (skulls)
 *
 * @param map    the map to scan
 * @param center the center location
 * @param range  the range in where to scan
 */
public void searchForMarkers(@Nonnull Map map, @Nonnull Vector3D center, int range, @Nonnull UUID gameid) {
    World world = Bukkit.getWorld(map.getLoadedName(gameid));
    if (world == null) {
        throw new MapException("Could not find world " + map.getLoadedName(gameid) + "(" + map.getInfo().getName() + ")" + ". Is it loaded?");
    }

    List<Marker> markers = new ArrayList<>();
    List<ChestMarker> chestMarkers = new ArrayList<>();

    int startX = (int) center.getX();
    int startY = (int) center.getZ();

    int minX = Math.min(startX - range, startX + range);
    int minZ = Math.min(startY - range, startY + range);

    int maxX = Math.max(startX - range, startX + range);
    int maxZ = Math.max(startY - range, startY + range);

    for (int x = minX; x <= maxX; x += 16) {
        for (int z = minZ; z <= maxZ; z += 16) {
            Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
            for (BlockState te : chunk.getTileEntities()) {
                if (te.getType() == Material.SKULL) {
                    Skull skull = (Skull) te;
                    if (skull.getSkullType() == SkullType.PLAYER) {
                        String markerData = getMarkerData(skull);
                        if (markerData == null) continue;
                        MarkerDefinition markerDefinition = mapHandler.createMarkerDefinition(markerData);
                        markers.add(new Marker(new Vector3D(skull.getX(), skull.getY(), skull.getZ()),
                                DirectionUtil.directionToYaw(skull.getRotation()),
                                markerData, markerDefinition));
                    }
                } else if (te.getType() == Material.CHEST) {
                    Chest chest = (Chest) te;
                    String name = chest.getBlockInventory().getName();
                    ItemStack[] items = new ItemStack[chest.getBlockInventory()
                            .getStorageContents().length];
                    for (int i = 0; i < items.length; i++) {
                        ItemStack is = chest.getBlockInventory().getItem(i);
                        if (is == null) {
                            items[i] = new ItemStack(Material.AIR);
                        } else {
                            items[i] = is;
                        }
                    }
                    chestMarkers
                            .add(new ChestMarker(new Vector3D(chest.getX(), chest.getY(), chest.getZ()), name,
                                    items));
                }
            }
        }
    }

    map.setMarkers(markers);
    map.setChestMarkers(chestMarkers);
}
项目:VoxelGamesLib    文件:BukkitMapScanner.java   
@Override
public void searchForMarkers(@Nonnull Map map, @Nonnull Vector3D center, int range) {
    World world = Bukkit.getWorld(map.getWorldName());
    if (world == null) {
        throw new MapException("Could not find world " + map.getWorldName() + ". Is it loaded?");
    }

    List<Marker> markers = new ArrayList<>();
    List<ChestMarker> chestMarkers = new ArrayList<>();

    int startX = (int) center.getX();
    int startY = (int) center.getZ();

    int minX = Math.min(startX - range, startX + range);
    int minZ = Math.min(startY - range, startY + range);

    int maxX = Math.max(startX - range, startX + range);
    int maxZ = Math.max(startY - range, startY + range);

    for (int x = minX; x <= maxX; x += 16) {
        for (int z = minZ; z <= maxZ; z += 16) {
            Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
            for (BlockState te : chunk.getTileEntities()) {
                if (te.getType() == Material.SKULL) {
                    Skull skull = (Skull) te;
                    if (skull.getSkullType() == SkullType.PLAYER) {
                        if (skull.getOwningPlayer() != null) {
                            String markerData = skull.getOwningPlayer().getName();
                            if (markerData == null) {
                                log.warning("owning player name null?!");
                                markerData = skull.getOwner();
                            }
                            markers.add(new Marker(new Vector3D(skull.getX(), skull.getY(), skull.getZ()),
                                    DirectionUtil.directionToYaw(directionConverter.toVGL(skull.getRotation())), markerData));
                        } else {
                            log.warning("unknown owner");
                        }
                    }
                } else if (te.getType() == Material.CHEST) {
                    Chest chest = (Chest) te;
                    String name = chest.getBlockInventory().getName();
                    Item[] items = new Item[chest.getBlockInventory().getStorageContents().length];
                    for (int i = 0; i < items.length; i++) {
                        ItemStack is = chest.getBlockInventory().getItem(i);
                        Item item = injector.getInstance(Item.class);
                        if (is == null) {
                            //noinspection unchecked
                            item.setImplementationType(new ItemStack(Material.AIR));
                            items[i] = item;
                        } else {
                            //noinspection unchecked
                            item.setImplementationType(is);
                            items[i] = item;
                        }
                    }
                    chestMarkers.add(new ChestMarker(new Vector3D(chest.getX(), chest.getY(), chest.getZ()), name, items));
                }
            }
        }
    }

    map.setMarkers(markers);
    map.setChestMarkers(chestMarkers);
}
项目:libelula    文件:ArenaManager.java   
public TreeMap<Integer, Skull> getScoreHeads() {
    return scoreHeads;
}
项目:IZenith-Main    文件:Util.java   
public static void CreatePlotSkull(Plot plot, String owner, com.intellectualcrafters.plot.object.Location l1, com.intellectualcrafters.plot.object.Location l2, com.intellectualcrafters.plot.object.Location l3, com.intellectualcrafters.plot.object.Location l4) {
    Block b1 = Util.getLocation(l1).getBlock();
    b1.setTypeIdAndData(Material.SKULL.getId(), (byte) 1, true);
    Skull skull1 = ((Skull) b1.getState());
    skull1.setSkullType(SkullType.PLAYER);
    skull1.setOwner(owner);
    skull1.setRotation(BlockFace.SOUTH_EAST);
    skull1.update(true);
    Block slabs1 = Util.getLocation(l1).subtract(0, 1, 0).getBlock();
    slabs1.setTypeIdAndData(43, (byte) 8, true);

    Block b2 = Util.getLocation(l2).getBlock();
    b2.setTypeIdAndData(Material.SKULL.getId(), (byte) 1, true);
    Skull skull2 = (Skull) b2.getState();
    skull2.setSkullType(SkullType.PLAYER);
    skull2.setOwner(owner);
    skull2.setRotation(BlockFace.SOUTH_WEST);
    skull2.update(true);
    Block slabs2 = Util.getLocation(l2).subtract(0, 1, 0).getBlock();
    slabs2.setTypeIdAndData(43, (byte) 8, true);

    Block b3 = Util.getLocation(l3).getBlock();
    b3.setTypeIdAndData(Material.SKULL.getId(), (byte) 1, true);
    Skull skull3 = ((Skull) b3.getState());
    skull3.setSkullType(SkullType.PLAYER);
    skull3.setOwner(owner);
    skull3.setRotation(BlockFace.NORTH_WEST);
    skull3.update(true);
    Block slabs3 = Util.getLocation(l3).subtract(0, 1, 0).getBlock();
    slabs3.setTypeIdAndData(43, (byte) 8, true);

    Block b4 = Util.getLocation(l4).getBlock();
    b4.setTypeIdAndData(Material.SKULL.getId(), (byte) 1, true);
    Skull skull4 = ((Skull) b4.getState());
    skull4.setSkullType(SkullType.PLAYER);
    skull4.setOwner(owner);
    skull4.setRotation(BlockFace.NORTH_EAST);
    skull4.update(true);
    Block slabs4 = Util.getLocation(l4).subtract(0, 1, 0).getBlock();
    slabs4.setTypeIdAndData(43, (byte) 8, true);
}
项目:SuperbVote    文件:TopPlayerSignUpdater.java   
@Override
public void run() {
    for (TopPlayerSign sign : toUpdate) {
        Block block = sign.getSign().getBukkitLocation().getBlock();
        switch (block.getType()) {
            case SIGN_POST:
            case WALL_SIGN:
                break;
            default:
                // Not a sign, bail out.
                continue;
        }

        Sign worldSign = (Sign) block.getState();
        // TODO: Formatting
        if (sign.getPosition() > top.size()) {
            for (int i = 0; i < 4; i++) {
                worldSign.setLine(i, "???");
            }
        } else {
            for (int i = 0; i < Math.min(4, SuperbVote.getPlugin().getConfiguration().getTopPlayerSignsConfiguration().getSignText().size()); i++) {
                PlainStringMessage m = SuperbVote.getPlugin().getConfiguration().getTopPlayerSignsConfiguration().getSignText().get(i);
                worldSign.setLine(i, m.getWithOfflinePlayer(null, top.get(sign.getPosition() - 1).getUuid()).replace("%num%",
                        Integer.toString(sign.getPosition())));
            }
            for (int i = SuperbVote.getPlugin().getConfiguration().getTopPlayerSignsConfiguration().getSignText().size(); i < 4; i++) {
                worldSign.setLine(i, "");
            }
        }
        worldSign.update();

        // If a head location is also present, set the location for that.
        Optional<Block> headBlock = findSkullBlock(sign.getSign().getBukkitLocation().getBlock());
        if (headBlock.isPresent()) {
            Block head = headBlock.get();
            Skull skull = (Skull) head.getState();
            skull.setSkullType(SkullType.PLAYER);
            skull.setOwner(sign.getPosition() > top.size() ? UNKNOWN_USERNAME :
                    SuperbVote.getPlugin().getUuidCache().getNameFromUuid(top.get(sign.getPosition() - 1).getUuid()));
            skull.update();
        }
    }
}