本文整理匯總了Java中org.bukkit.block.Skull.getSkullType方法的典型用法代碼示例。如果您正苦於以下問題:Java Skull.getSkullType方法的具體用法?Java Skull.getSkullType怎麽用?Java Skull.getSkullType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.block.Skull
的用法示例。
在下文中一共展示了Skull.getSkullType方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
}
示例2: searchForMarkers
import org.bukkit.block.Skull; //導入方法依賴的package包/類
/**
* 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);
}
示例3: searchForMarkers
import org.bukkit.block.Skull; //導入方法依賴的package包/類
@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);
}
示例4: updateFrom
import org.bukkit.block.Skull; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void updateFrom(Block block, Set<Material> restrictedMaterials) {
if (block == null) {
isValid = false;
return;
}
if (!block.getChunk().isLoaded()) {
block.getChunk().load(true);
return;
}
Material blockMaterial = block.getType();
if (restrictedMaterials != null && restrictedMaterials.contains(blockMaterial)) {
isValid = false;
return;
}
// Look for special block states
extraData = null;
material = blockMaterial;
data = (short)block.getData();
try {
BlockState blockState = block.getState();
if (material == Material.FLOWER_POT || blockState instanceof InventoryHolder || blockState instanceof Sign) {
extraData = new BlockTileEntity(NMSUtils.getTileEntityData(block.getLocation()));
} else if (blockState instanceof CommandBlock){
// This seems to occasionally throw exceptions...
CommandBlock command = (CommandBlock)blockState;
extraData = new BlockCommand(command.getCommand(), command.getName());
} else if (blockState instanceof Skull) {
Skull skull = (Skull)blockState;
data = (short)skull.getSkullType().ordinal();
extraData = new BlockSkull(CompatibilityUtils.getSkullProfile(skull), skull.getSkullType(), skull.getRotation());
} else if (blockState instanceof CreatureSpawner) {
CreatureSpawner spawner = (CreatureSpawner)blockState;
extraData = new BlockMobSpawner(spawner.getCreatureTypeName());
} else if (blockMaterial == Material.STANDING_BANNER || blockMaterial == Material.WALL_BANNER) {
if (blockState != null && blockState instanceof Banner) {
Banner banner = (Banner)blockState;
DyeColor color = banner.getBaseColor();
extraData = new BlockBanner(banner.getPatterns(), color);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
isValid = true;
}
示例5: SerializableBlockEntity
import org.bukkit.block.Skull; //導入方法依賴的package包/類
/**
* Constructor.
*
* @param blockState The {@link org.bukkit.block.BlockState} that needs to be serialized.
*/
public SerializableBlockEntity(BlockState blockState) {
PreCon.notNull(blockState);
_location = blockState.getLocation();
_material = blockState.getType();
_data = blockState.getRawData();
if (blockState instanceof InventoryHolder) {
_contents = ((InventoryHolder) blockState).getInventory().getContents();
}
if (blockState instanceof CommandBlock) {
CommandBlock commandBlock = (CommandBlock)blockState;
_commandName = commandBlock.getName();
_command = commandBlock.getCommand();
}
if (blockState instanceof CreatureSpawner) {
CreatureSpawner spawner = (CreatureSpawner)blockState;
_creatureTypeName = spawner.getCreatureTypeName();
_creatureDelay = spawner.getDelay();
}
if (blockState instanceof NoteBlock) {
NoteBlock noteBlock = (NoteBlock)blockState;
_noteTone = noteBlock.getNote().getTone();
_noteOctave = noteBlock.getNote().getOctave();
_noteSharped = noteBlock.getNote().isSharped();
}
if (blockState instanceof Sign) {
Sign sign = (Sign)blockState;
_signLines = sign.getLines().clone();
}
if (blockState instanceof Skull) {
Skull skull = (Skull)blockState;
_skullType = skull.getSkullType();
_skullRotation = skull.getRotation();
_skullOwner = skull.getOwner();
}
}