本文整理匯總了Java中org.bukkit.block.Skull.setSkullType方法的典型用法代碼示例。如果您正苦於以下問題:Java Skull.setSkullType方法的具體用法?Java Skull.setSkullType怎麽用?Java Skull.setSkullType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.block.Skull
的用法示例。
在下文中一共展示了Skull.setSkullType方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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;
}
示例3: 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);
}
示例4: setSkullHead
import org.bukkit.block.Skull; //導入方法依賴的package包/類
/**
* 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;
}
示例5: setWinnerHead
import org.bukkit.block.Skull; //導入方法依賴的package包/類
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();
}
示例6: setAdditionalData
import org.bukkit.block.Skull; //導入方法依賴的package包/類
@Override
public void setAdditionalData(final Block block) {
final Skull skullState = (Skull)block.getState();
skullState.setSkullType(this.type);
skullState.setRotation(this.rotation);
skullState.update();
}
示例7: CreatePlotSkull
import org.bukkit.block.Skull; //導入方法依賴的package包/類
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);
}
示例8: run
import org.bukkit.block.Skull; //導入方法依賴的package包/類
@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();
}
}
}
示例9: run
import org.bukkit.block.Skull; //導入方法依賴的package包/類
@Override
public void run() {
for (Map.Entry<RecentPurchaseSignPosition, RecentPayment> entry : signToPurchases.entrySet()) {
Location location = BukkitSerializedBlockLocation.toBukkit(entry.getKey().getLocation());
if (location.getWorld() == null) {
// Invalid (no world).
continue;
}
Block block = location.getBlock();
if (block == null) {
// Invalid.
continue;
}
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) {
Sign sign = (Sign) block.getState();
if (entry.getValue() != null) {
List<String> lines = plugin.getRecentPurchaseSignLayout().format(entry.getValue());
for (int i = 0; i < 4; i++) {
sign.setLine(i, ChatColor.translateAlternateColorCodes('&', i >= lines.size() ? "" : lines.get(i)));
}
} else {
for (int i = 0; i < 4; i++) {
sign.setLine(i, "");
}
}
sign.update();
Block skullBlock = findSkullBlock(block);
if (skullBlock != null) {
Skull skull = (Skull) skullBlock.getState();
skull.setSkullType(SkullType.PLAYER);
skull.setOwner(entry.getValue() == null ? UNKNOWN_USERNAME : entry.getValue().getPlayer().getName());
skull.update();
}
} else {
// TODO: Help the user by cleaning it up.
plugin.getLogger().warning("Location " + entry.getKey().getLocation() + " doesn't have a sign!");
}
}
}
示例10: modify
import org.bukkit.block.Skull; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void modify(Block block, boolean applyPhysics) {
if (!isValid) return;
try {
BlockState blockState = block.getState();
// Clear chests so they don't dump their contents.
if (blockState instanceof InventoryHolder) {
NMSUtils.clearItems(block.getLocation());
}
if (material != null) {
byte blockData = data != null ? (byte)(short)data : block.getData();
block.setTypeIdAndData(material.getId(), blockData, applyPhysics);
blockState = block.getState();
}
// Set tile entity data first
// Command blocks still prefer internal data for parameterized commands
if (blockState != null && blockState instanceof CommandBlock && extraData != null && extraData instanceof BlockCommand) {
CommandBlock command = (CommandBlock)blockState;
BlockCommand commandData = (BlockCommand)extraData;
command.setCommand(commandData.command);
if (commandData.customName != null) {
command.setName(commandData.customName);
}
command.update();
} else if (extraData != null && extraData instanceof BlockTileEntity) {
// Tile entity data overrides everything else, and may replace all of this in the future.
NMSUtils.setTileEntityData(block.getLocation(), ((BlockTileEntity) extraData).data);
} else if (blockState != null && (material == Material.STANDING_BANNER || material == Material.WALL_BANNER) && extraData != null && extraData instanceof BlockBanner) {
if (blockState != null && blockState instanceof Banner) {
BlockBanner bannerData = (BlockBanner)extraData;
Banner banner = (Banner)blockState;
if (bannerData.patterns != null)
{
banner.setPatterns(bannerData.patterns);
}
if (bannerData.baseColor != null)
{
banner.setBaseColor(bannerData.baseColor);
}
}
blockState.update(true, false);
} else if (blockState != null && blockState instanceof Skull && extraData != null && extraData instanceof BlockSkull) {
Skull skull = (Skull)blockState;
BlockSkull skullData = (BlockSkull)extraData;
if (skullData.skullType != null) {
skull.setSkullType(skullData.skullType);
}
if (skullData.rotation != null) {
skull.setRotation(skullData.rotation);
}
if (skullData.profile != null) {
CompatibilityUtils.setSkullProfile(skull, skullData.profile);
}
skull.update(true, false);
} else if (blockState != null && blockState instanceof CreatureSpawner && extraData != null && extraData instanceof BlockMobSpawner) {
BlockMobSpawner spawnerData = (BlockMobSpawner)extraData;
if (spawnerData.mobName != null && !spawnerData.mobName.isEmpty())
{
CreatureSpawner spawner = (CreatureSpawner)blockState;
spawner.setCreatureTypeByName(spawnerData.mobName);
spawner.update();
}
}
} catch (Exception ex) {
Bukkit.getLogger().warning("Error updating block state: " + ex.getMessage());
}
}
示例11: generateHollowCube
import org.bukkit.block.Skull; //導入方法依賴的package包/類
public static void generateHollowCube(Location location, int length, Material material)
{
Block center = location.getBlock();
for (int xOffset = -length; xOffset <= length; xOffset++)
{
for (int yOffset = -length; yOffset <= length; yOffset++)
{
for (int zOffset = -length; zOffset <= length; zOffset++)
{
// Hollow
if (Math.abs(xOffset) != length && Math.abs(yOffset) != length && Math.abs(zOffset) != length)
{
continue;
}
final Block block = center.getRelative(xOffset, yOffset, zOffset);
if (material != Material.SKULL)
{
// Glowstone light
if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0)
{
block.setType(Material.GLOWSTONE);
continue;
}
block.setType(material);
}
else // Darth mode
{
if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length)
{
block.setType(Material.GLOWSTONE);
continue;
}
block.setType(Material.SKULL);
Skull skull = (Skull) block.getState();
skull.setSkullType(SkullType.PLAYER);
skull.setOwner("DarthSalamon");
skull.update();
}
}
}
}
}
示例12: applyTile
import org.bukkit.block.Skull; //導入方法依賴的package包/類
private void applyTile(BlockState blockState) {
boolean requiresUpdate = false;
// InventoryHolder
if (blockState instanceof InventoryHolder && _contents != null) {
InventoryHolder holder = (InventoryHolder)blockState;
Inventory inventory = holder.getInventory();
inventory.setContents(_contents);
requiresUpdate = true;
}
// CommandBlock
if (blockState instanceof CommandBlock) {
CommandBlock commandBlock = (CommandBlock)blockState;
if (_commandName != null)
commandBlock.setName(_commandName);
if (_command != null)
commandBlock.setCommand(_command);
requiresUpdate = true;
}
// CreatureSpawner
if (blockState instanceof CreatureSpawner) {
CreatureSpawner spawner = (CreatureSpawner)blockState;
if (_creatureTypeName != null) {
spawner.setCreatureTypeByName(_creatureTypeName);
spawner.setDelay(_creatureDelay);
}
requiresUpdate = true;
}
if (blockState instanceof NoteBlock && _noteTone != null) {
NoteBlock noteBlock = (NoteBlock)blockState;
Note note = new Note(_noteOctave, _noteTone, _noteSharped);
noteBlock.setNote(note);
requiresUpdate = true;
}
if (blockState instanceof Sign && _signLines != null) {
Sign sign = (Sign)blockState;
for (int i=0; i < 4; i++)
sign.setLine(i, _signLines[i]);
requiresUpdate = true;
}
if (blockState instanceof Skull && _skullType != null) {
Skull skull = (Skull)blockState;
skull.setSkullType(_skullType);
skull.setRotation(_skullRotation);
skull.setOwner(_skullOwner);
requiresUpdate = true;
}
if (requiresUpdate) {
blockState.update(true);
}
}