本文整理匯總了Java中org.bukkit.inventory.meta.SkullMeta.hasOwner方法的典型用法代碼示例。如果您正苦於以下問題:Java SkullMeta.hasOwner方法的具體用法?Java SkullMeta.hasOwner怎麽用?Java SkullMeta.hasOwner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.inventory.meta.SkullMeta
的用法示例。
在下文中一共展示了SkullMeta.hasOwner方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getNameComponent
import org.bukkit.inventory.meta.SkullMeta; //導入方法依賴的package包/類
public static BaseComponent getNameComponent(ItemStack item) {
if (item == null) throw new IllegalArgumentException();
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName())
return new TextComponent(item.getItemMeta().getDisplayName());
Material type = item.getType();
if (type == Material.SKULL_ITEM && item.getDurability() == 3) {
SkullMeta meta = (SkullMeta) item.getItemMeta();
if (meta.hasOwner()) {
return new TranslatableComponent("item.skull.player.name", meta.getOwner());
} else {
return new TranslatableComponent("item.skull.char.name");
}
} else {
return new TranslatableComponent(getUnlocalizedName(item));
}
}
示例2: onZombieKill
import org.bukkit.inventory.meta.SkullMeta; //導入方法依賴的package包/類
@Override
public void onZombieKill(ZvPPlayer attacker, Entity zombie, EntityDeathEvent event) {
super.onZombieKill(attacker, zombie, event);
Zombie z = (Zombie) zombie;
if (z.getEquipment().getHelmet().getType() == Material.SKULL_ITEM) {
if (z.getEquipment().getHelmet().hasItemMeta() && z.getEquipment().getHelmet().getItemMeta() instanceof SkullMeta) {
SkullMeta meta = (SkullMeta) z.getEquipment().getHelmet().getItemMeta();
if (meta.hasOwner()) {
ZvPPlayer player = GameManager.getManager().getPlayer(meta.getOwner());
if (player != null) {
if (this.playerDrops.containsKey(player)) {
event.getDrops().clear();
event.getDrops().addAll(this.playerDrops.get(player));
this.playerDrops.remove(player);
}
}
}
}
}
}
示例3: isCustomHeadItem
import org.bukkit.inventory.meta.SkullMeta; //導入方法依賴的package包/類
public static boolean isCustomHeadItem(ItemStack item) {
if (item == null) return false;
if (item.getType() != Material.SKULL_ITEM) {
return false;
}
if (item.getDurability() != SkullType.PLAYER.ordinal()) {
return false;
}
ItemMeta meta = item.getItemMeta();
if (meta instanceof SkullMeta) {
SkullMeta skullMeta = (SkullMeta) meta;
if (skullMeta.hasOwner() && skullMeta.getOwner() == null) {
// custom head items usually don't have a valid owner
return true;
}
}
return false;
}
示例4: skullOwner
import org.bukkit.inventory.meta.SkullMeta; //導入方法依賴的package包/類
private String skullOwner(ItemStack is) {
if(is == null || is.getItemMeta() == null || !(is.getItemMeta() instanceof SkullMeta)) {
return "";
}
SkullMeta skull = (SkullMeta) is.getItemMeta();
if(skull.hasOwner()) {
return ",tag:{SkullOwner:\"" + skull.getOwner() + "\"}";
} else {
return "";
}
}
示例5: plrHeadName
import org.bukkit.inventory.meta.SkullMeta; //導入方法依賴的package包/類
private String plrHeadName(ArmorStand as) {
if(as.getHelmet() == null) return null;
if(!(as.getHelmet().getItemMeta() instanceof SkullMeta)) return null;
SkullMeta meta = (SkullMeta) as.getHelmet().getItemMeta();
if(!meta.hasOwner()) return null;
return meta.getOwner();
}
示例6: serializeSkull
import org.bukkit.inventory.meta.SkullMeta; //導入方法依賴的package包/類
/**
* Serialize a skull into a JSONObject.
*
* @param meta The SkullMeta to serialize
* @return The serialized SkullMeta
*/
public static JSONObject serializeSkull(SkullMeta meta) {
//only one value is saved, I know. But just in case Mojang/Bukkit decides
//to do anything further with skulls, causing it to add to the meta.
try {
JSONObject root = new JSONObject();
if (meta.hasOwner())
root.put("owner", meta.getOwner());
return root;
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
示例7: CardboardMetaSkull
import org.bukkit.inventory.meta.SkullMeta; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public CardboardMetaSkull(ItemStack head) {
this.id = head.getTypeId();
SkullMeta meta = (SkullMeta) head.getItemMeta();
if (meta.hasOwner()) {
this.hasowner = true;
this.owner = meta.getOwner();
} else {
this.hasowner = false;
}
}
示例8: CardboardMetaSkull
import org.bukkit.inventory.meta.SkullMeta; //導入方法依賴的package包/類
public CardboardMetaSkull(ItemStack head) {
this.id = head.getTypeId();
SkullMeta meta = (SkullMeta) head.getItemMeta();
if (meta.hasOwner()) {
this.hasowner = true;
this.owner = meta.getOwner();
} else {
this.hasowner = false;
}
}
示例9: getName
import org.bukkit.inventory.meta.SkullMeta; //導入方法依賴的package包/類
public static String getName(ItemStack item)
{
if(item == null) //Even though it shouldn't happen
return "Air";
HashMap<String,String> names = FloAuction.plugin.names;
int id = item.getTypeId(); //Code needs to be updated eventually, waiting for dura to be completely removed
short dura = item.getDurability();
String name = "";
if(id == 397)
{
if(dura == 3)
{
SkullMeta skullMeta = (SkullMeta) item.getItemMeta();
if(skullMeta.hasOwner())
{
if(skullMeta.getOwner() != null && !(skullMeta.equals("")))
return skullMeta.getOwner() + "\'s" + " Head";
}
}
}
else if(id == 383) //mob eggs
{
return MaterialUtil.getMobEggType(item) + " Spawn Egg";
}
if(id == 52 && AuctionConfig.getBoolean("allow-mobspawners", null))
{
return MaterialUtil.getSpawnerType(item) + " Spawner";
}
else if(AuctionConfig.getBoolean("renamed-items-override", null) && Items.getDisplayName(item) != null && id != 52)
{
return Items.getDisplayName(item);
}
else if(names.get(id + "," + dura) == null && FloAuction.isDamagedAllowed)
{
if(names.get(id + "," + 0) != null)
{
name = names.get(id + "," + 0);
}
else
{
name = MaterialUtil.getItemType(item) + ":" + dura;
}
}
else if(names.get(id + "," + dura) != null)
{
name = names.get(id + "," + dura);
}
else
{
name = MaterialUtil.getItemType(item);
}
return name;
}
示例10: onSignChange
import org.bukkit.inventory.meta.SkullMeta; //導入方法依賴的package包/類
@EventHandler
public void onSignChange(final SignChangeEvent event) {
if(event.getBlock().hasMetadata("armorStand")) {
final Block b = event.getBlock();
final ArmorStand as = getArmorStand(b);
if (as != null) {
String input = "";
for (String line : event.getLines()) {
if (line != null && line.length() > 0) {
input += ChatColor.translateAlternateColorCodes('&', line);
}
}
if(b.hasMetadata("setName")) {
if (input.length() > 0) {
as.setCustomName(input);
as.setCustomNameVisible(true);
} else {
as.setCustomName("");
as.setCustomNameVisible(false);
as.setCustomNameVisible(false);
}
} else if(b.hasMetadata("setSkull")) {
if(MC_USERNAME_PATTERN.matcher(input).matches()) {
b.setMetadata("protected", new FixedMetadataValue(plugin, true));
event.getPlayer().sendMessage(ChatColor.GOLD + Config.pleaseWait);
String cmd = "minecraft:give " + event.getPlayer().getName() + " minecraft:skull 1 3 {SkullOwner:\"" + input + "\"}";
String current = b.getWorld().getGameRuleValue("sendCommandFeedback");
b.getWorld().setGameRuleValue("sendCommandFeedback", "false");
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
b.getWorld().setGameRuleValue("sendCommandFeedback", current);
boolean found = false;
for(int slot : event.getPlayer().getInventory().all(Material.SKULL_ITEM).keySet()) {
ItemStack skull = event.getPlayer().getInventory().getItem(slot);
SkullMeta sm = (SkullMeta) skull.getItemMeta();
if(sm.hasOwner() && input.equalsIgnoreCase(sm.getOwner())) {
as.setHelmet(skull);
event.getPlayer().sendMessage(ChatColor.GREEN + Config.appliedHead + ChatColor.GOLD + " " + input);
event.getPlayer().getInventory().setItem(slot, null);
found = true;
break;
}
}
if(!found) {
event.getPlayer().sendMessage(ChatColor.GOLD + Config.headFailed);
}
} else {
event.getPlayer().sendMessage(ChatColor.RED + input + " " + Config.invalidName);
}
}
}
event.setCancelled(true);
b.removeMetadata("armorStand", plugin);
b.removeMetadata("setName", plugin);
b.removeMetadata("setSkull", plugin);
b.setType(Material.AIR);
//noinspection deprecation
b.setData((byte) 0);
}
}