當前位置: 首頁>>代碼示例>>Java>>正文


Java Skull.getOwner方法代碼示例

本文整理匯總了Java中org.bukkit.block.Skull.getOwner方法的典型用法代碼示例。如果您正苦於以下問題:Java Skull.getOwner方法的具體用法?Java Skull.getOwner怎麽用?Java Skull.getOwner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.block.Skull的用法示例。


在下文中一共展示了Skull.getOwner方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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;
    }
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLibv2,代碼行數:18,代碼來源:MapScanner.java

示例2: 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);
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:10,代碼來源:AntiDamageSkull.java

示例3: onClick

import org.bukkit.block.Skull; //導入方法依賴的package包/類
@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);
	}
}
 
開發者ID:iZenith,項目名稱:IZenith-Main,代碼行數:29,代碼來源:InteractListener.java

示例4: onPlayerClick

import org.bukkit.block.Skull; //導入方法依賴的package包/類
@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!");

        }
    }
}
 
開發者ID:sabersamus,項目名稱:Bytecraft,代碼行數:28,代碼來源:BytecraftPlayerListener.java

示例5: 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);
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLib,代碼行數:65,代碼來源:BukkitMapScanner.java

示例6: 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();
    }
}
 
開發者ID:JCThePants,項目名稱:NucleusFramework,代碼行數:51,代碼來源:SerializableBlockEntity.java


注:本文中的org.bukkit.block.Skull.getOwner方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。