本文整理汇总了Java中org.bukkit.Material.SKULL属性的典型用法代码示例。如果您正苦于以下问题:Java Material.SKULL属性的具体用法?Java Material.SKULL怎么用?Java Material.SKULL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.SKULL属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
@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: NoSkullCrash
@EventHandler(priority = EventPriority.LOWEST)
public void NoSkullCrash(BlockFromToEvent evt) {
if (noSkullCrash) {
if(evt.isCancelled()) {
return;
}
if (evt.getToBlock().getType() == Material.SKULL) {
evt.setCancelled(true);
}
}
}
示例3: onPlayerInteractEvent
@EventHandler
public void onPlayerInteractEvent(PlayerInteractEvent event)
{
if (event.getClickedBlock() != null)
{
Material material = event.getClickedBlock().getType();
if (material == Material.SIGN || material == Material.SIGN_POST || material == Material.WALL_SIGN)
{
Sign sign = (Sign) event.getClickedBlock().getState();
if (sign.hasMetadata("game") && sign.hasMetadata("map"))
{
AbstractGame game = this.hub.getGameManager().getGameByIdentifier(sign.getMetadata("game").get(0).asString());
GameSign gameSign = game.getGameSignsByMap(sign.getMetadata("map").get(0).asString()).get(0);
if (SamaGamesAPI.get().getPermissionsManager().hasPermission(event.getPlayer(), "hub.debug.sign") && event.getPlayer().isSneaking())
{
gameSign.developperClick(event.getPlayer());
return;
}
gameSign.click(event.getPlayer());
}
}
else if (material == Material.SKULL)
{
Optional<AbstractGame> optional = this.hub.getGameManager().getGames().values().stream().filter(game -> game.getWebsiteDescriptionSkull().getBlock().getLocation().equals(event.getClickedBlock().getLocation())).findAny();
if (optional.isPresent() && optional.get().getWebsiteDescriptionURL() != null)
optional.get().showRulesWarning(event.getPlayer());
}
}
}
示例4: fixSkull
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);
}
}
}
示例5: onBlockFromTo
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent e) {
if (cm.isAntiCrashSkull && VersionUtils.isLowerThan(VersionUtils.V1_9) && e.getToBlock().getType() == Material.SKULL) {
e.setCancelled(true);
}
}
示例6: searchForMarkers
/**
* 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);
}