当前位置: 首页>>代码示例>>Java>>正文


Java SkullMeta.hasOwner方法代码示例

本文整理汇总了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));
    }
}
 
开发者ID:NyaaCat,项目名称:NyaaCore,代码行数:17,代码来源:LocaleUtils.java

示例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);
		}
	    }
	}
    }
}
   }
 
开发者ID:AlexMl,项目名称:ZvP,代码行数:24,代码来源:DeathMatch.java

示例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;
}
 
开发者ID:nisovin,项目名称:Shopkeepers,代码行数:20,代码来源:Utils.java

示例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 "";
    }
}
 
开发者ID:St3venAU,项目名称:ArmorStandTools,代码行数:12,代码来源:NMS.java

示例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();
}
 
开发者ID:St3venAU,项目名称:ArmorStandTools,代码行数:8,代码来源:ArmorStandGUI.java

示例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;
    }
}
 
开发者ID:ThisIzEthan,项目名称:NexusInventory,代码行数:20,代码来源:SkullSerialization.java

示例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;
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:13,代码来源:CardboardMetaSkull.java

示例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;
		}
	}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:12,代码来源:CardboardMetaSkull.java

示例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;
}
 
开发者ID:virustotalop,项目名称:ObsidianAuctions,代码行数:57,代码来源:MaterialUtil.java

示例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);
    }
}
 
开发者ID:St3venAU,项目名称:ArmorStandTools,代码行数:60,代码来源:MainListener.java


注:本文中的org.bukkit.inventory.meta.SkullMeta.hasOwner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。