本文整理匯總了Java中org.bukkit.block.Skull類的典型用法代碼示例。如果您正苦於以下問題:Java Skull類的具體用法?Java Skull怎麽用?Java Skull使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Skull類屬於org.bukkit.block包,在下文中一共展示了Skull類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.bukkit.block.Skull; //導入依賴的package包/類
@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();
}
示例2: getMarkerData
import org.bukkit.block.Skull; //導入依賴的package包/類
@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;
}
}
示例3: delScoreHead
import org.bukkit.block.Skull; //導入依賴的package包/類
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;
}
示例4: onBlockPlace
import org.bukkit.block.Skull; //導入依賴的package包/類
@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;
}
}
示例5: onBlockBreak
import org.bukkit.block.Skull; //導入依賴的package包/類
@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;
}
}
示例6: updateTexture
import org.bukkit.block.Skull; //導入依賴的package包/類
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();
}
}
});
}
示例7: move
import org.bukkit.block.Skull; //導入依賴的package包/類
@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);
}
}
示例8: set
import org.bukkit.block.Skull; //導入依賴的package包/類
@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;
}
示例9: updateTexture
import org.bukkit.block.Skull; //導入依賴的package包/類
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();
}
}
);
}
示例10: setCustomSkull
import org.bukkit.block.Skull; //導入依賴的package包/類
/**
* 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);
}
示例11: checkChunk
import org.bukkit.block.Skull; //導入依賴的package包/類
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);
}
}
}
示例12: setSkullWithNonPlayerProfile
import org.bukkit.block.Skull; //導入依賴的package包/類
@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());
}
}
示例13: setSkullProfile
import org.bukkit.block.Skull; //導入依賴的package包/類
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);
}
示例14: fixSkull
import org.bukkit.block.Skull; //導入依賴的package包/類
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);
}
}
}
示例15: onPlayerInteract
import org.bukkit.block.Skull; //導入依賴的package包/類
@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
+ '.');
}
}
}