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


Java EntityEquipment.setItemInMainHand方法代碼示例

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


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

示例1: onCommand

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
@Override
protected void onCommand(CommandSender sender, String[] args) {
    Player player = (Player) sender;

    EntityEquipment e = player.getEquipment();
    ItemStack held = e.getItemInMainHand();
    e.setItemInMainHand(e.getHelmet());
    e.setHelmet(held);

    sender.sendMessage(ChatColor.GOLD + "Enjoy your new hat.");
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:12,代碼來源:CommandHat.java

示例2: set

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void set(final EntityEquipment e, final @Nullable ItemStack item) {
	if (Skript.isRunningMinecraft(1, 9))
		e.setItemInMainHand(item);
	else
		e.setItemInHand(item); //Compatibility reasons
}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:9,代碼來源:EquipmentSlot.java

示例3: createRobot

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
private void createRobot(Skeleton s) {
	EntityEquipment e = s.getEquipment();
	e.setHelmet(new ItemStack(Material.DISPENSER, 1));
	e.setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1));
	e.setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS, 1));
	e.setLeggings(new ItemStack(Material.IRON_BOOTS, 1));
	e.setItemInMainHand(new ItemStack(Material.BOW, 1));
	permaVanish(s);
}
 
開發者ID:StarQuestMinecraft,項目名稱:StarQuestCode,代碼行數:10,代碼來源:EntityListener.java

示例4: restoreEquipment

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
void restoreEquipment(LivingEntity entity) {
    EntityEquipment equipment = entity.getEquipment();
    if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_0)) {
        equipment.setItemInMainHand(this.lived.mainHand);
        equipment.setItemInOffHand(this.lived.offHand);
    } else {
        equipment.setItemInHand(this.lived.mainHand);
    }
    equipment.setHelmet(this.lived.helmet);
    equipment.setChestplate(this.lived.chestplate);
    equipment.setLeggings(this.lived.leggings);
    equipment.setBoots(this.lived.boots);
}
 
開發者ID:IntellectualSites,項目名稱:PlotSquared,代碼行數:14,代碼來源:EntityWrapper.java

示例5: valueOf

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static ShopNPC valueOf(Map<String, Object> map) {
	if (map == null || !map.containsKey("name") || !map.containsKey("type") 
			 || !map.containsKey("location") || !map.containsKey("equipment")
			  || !map.containsKey("message") || !map.containsKey("shop")) {
		QuestManagerPlugin.logger.warning("Invalid NPC info! "
				+ (map.containsKey("name") ? ": " + map.get("name") : ""));
		return null;
	}
	
	
	EquipmentConfiguration econ = new EquipmentConfiguration();
	try {
		YamlConfiguration tmp = new YamlConfiguration();
		tmp.createSection("key",  (Map<?, ?>) map.get("equipment"));
		econ.load(tmp.getConfigurationSection("key"));
	} catch (InvalidConfigurationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	LocationState ls = (LocationState) map.get("location");
	Location loc = ls.getLocation();
	
	ShopNPC npc = new ShopNPC(loc);
	EntityType type = EntityType.valueOf((String) map.get("type"));
	
	npc.name = (String) map.get("name");
	
	npc.inventory = (ShopInventory) map.get("shop");
	

	loc.getChunk();
	npc.setEntity(loc.getWorld().spawnEntity(loc, type));
	npc.getEntity().setCustomName((String) map.get("name"));

	if (npc.getEntity() instanceof LivingEntity) {
		EntityEquipment equipment = ((LivingEntity) npc.getEntity()).getEquipment();
		equipment.setHelmet(econ.getHead());
		equipment.setChestplate(econ.getChest());
		equipment.setLeggings(econ.getLegs());
		equipment.setBoots(econ.getBoots());
		equipment.setItemInMainHand(econ.getHeldMain());
		equipment.setItemInOffHand(econ.getHeldOff());
		
	}
	
	npc.chat = (BioptionMessage) map.get("message");		
	
	//provide our npc's name, unless we don't have one!
	if (npc.name != null && !npc.name.equals("")) {
		FancyMessage label = new FancyMessage(npc.name);
		npc.chat.setSourceLabel(label);			
	}
	
	//update code 3
	if (map.containsKey("badrequirementmessage"))
		npc.altMessage = (Message) map.get("badrequirementmessage");
	if (map.containsKey("requiredquests"))
	npc.requirements = (List<String>) map.get("requiredquests");
	
	return npc;
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:64,代碼來源:ShopNPC.java

示例6: valueOf

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
public static DummyNPC valueOf(Map<String, Object> map) {
	if (map == null || !map.containsKey("name") || !map.containsKey("type") 
			 || !map.containsKey("location") || !map.containsKey("equipment")) {
		QuestManagerPlugin.logger.warning("Invalid NPC info! "
				+ (map.containsKey("name") ? ": " + map.get("name") : ""));
		return null;
	}
	
	EquipmentConfiguration econ = new EquipmentConfiguration();
	try {
		YamlConfiguration tmp = new YamlConfiguration();
		tmp.createSection("key",  (Map<?, ?>) map.get("equipment"));
		econ.load(tmp.getConfigurationSection("key"));
	} catch (InvalidConfigurationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	LocationState ls = (LocationState) map.get("location");
	Location loc = ls.getLocation();
	
	EntityType type = EntityType.valueOf((String) map.get("type"));
	
	
	DummyNPC npc = new DummyNPC(loc);

	loc.getChunk();
	npc.setEntity(loc.getWorld().spawnEntity(loc, type));
	npc.setStartingLoc(loc);
	npc.getEntity().setCustomName((String) map.get("name"));
	
	npc.name = (String) map.get("name");

	if (npc.getEntity() instanceof LivingEntity) {
		EntityEquipment equipment = ((LivingEntity) npc.getEntity()).getEquipment();
		equipment.setHelmet(econ.getHead());
		equipment.setChestplate(econ.getChest());
		equipment.setLeggings(econ.getLegs());
		equipment.setBoots(econ.getBoots());
		equipment.setItemInMainHand(econ.getHeldMain());
		equipment.setItemInOffHand(econ.getHeldOff());
		
	}
	
	return npc;
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:47,代碼來源:DummyNPC.java

示例7: valueOf

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
public static SimpleBioptionNPC valueOf(Map<String, Object> map) {
	if (map == null || !map.containsKey("name") || !map.containsKey("type") 
			 || !map.containsKey("location") || !map.containsKey("equipment")
			  || !map.containsKey("message")) {
		QuestManagerPlugin.logger.warning("Invalid NPC info! "
				+ (map.containsKey("name") ? ": " + map.get("name") : ""));
		return null;
	}
	
	
	EquipmentConfiguration econ = new EquipmentConfiguration();
	try {
		YamlConfiguration tmp = new YamlConfiguration();
		tmp.createSection("key",  (Map<?, ?>) map.get("equipment"));
		econ.load(tmp.getConfigurationSection("key"));
	} catch (InvalidConfigurationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	LocationState ls = (LocationState) map.get("location");
	Location loc = ls.getLocation();
	

	SimpleBioptionNPC npc = new SimpleBioptionNPC(loc);
	EntityType type = EntityType.valueOf((String) map.get("type"));
	
	npc.name = (String) map.get("name");
	

	loc.getChunk();
	npc.setEntity(loc.getWorld().spawnEntity(loc, type));
	npc.getEntity().setCustomName((String) map.get("name"));

	if (npc.getEntity() instanceof LivingEntity) {
		EntityEquipment equipment = ((LivingEntity) npc.getEntity()).getEquipment();
		equipment.setHelmet(econ.getHead());
		equipment.setChestplate(econ.getChest());
		equipment.setLeggings(econ.getLegs());
		equipment.setBoots(econ.getBoots());
		equipment.setItemInMainHand(econ.getHeldMain());
		equipment.setItemInOffHand(econ.getHeldOff());
		
	}
	
	npc.chat = (BioptionMessage) map.get("message");
	
	//provide our npc's name, unless we don't have one!
	if (npc.name != null && !npc.name.equals("")) {
		npc.chat.setSourceLabel(
				new FancyMessage(npc.name));
		
	}
	
	return npc;
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:57,代碼來源:SimpleBioptionNPC.java

示例8: valueOf

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
public static ServiceNPC valueOf(Map<String, Object> map) {
	if (map == null || !map.containsKey("name") || !map.containsKey("type") 
			 || !map.containsKey("location") || !map.containsKey("equipment")
			  || !map.containsKey("message") || !map.containsKey("services")) {
		QuestManagerPlugin.logger.warning("Invalid NPC info! "
				+ (map.containsKey("name") ? ": " + map.get("name") : ""));
		return null;
	}
	
	
	EquipmentConfiguration econ = new EquipmentConfiguration();
	try {
		YamlConfiguration tmp = new YamlConfiguration();
		tmp.createSection("key",  (Map<?, ?>) map.get("equipment"));
		econ.load(tmp.getConfigurationSection("key"));
	} catch (InvalidConfigurationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	LocationState ls = (LocationState) map.get("location");
	Location loc = ls.getLocation();
	
	ServiceNPC npc = new ServiceNPC(loc);
	EntityType type = EntityType.valueOf((String) map.get("type"));
	
	npc.name = (String) map.get("name");
	
	npc.inventory = (ServiceInventory) map.get("services");
	

	loc.getChunk();
	npc.setEntity(loc.getWorld().spawnEntity(loc, type));
	npc.getEntity().setCustomName((String) map.get("name"));

	if (npc.getEntity() instanceof LivingEntity) {
		EntityEquipment equipment = ((LivingEntity) npc.getEntity()).getEquipment();
		equipment.setHelmet(econ.getHead());
		equipment.setChestplate(econ.getChest());
		equipment.setLeggings(econ.getLegs());
		equipment.setBoots(econ.getBoots());
		equipment.setItemInMainHand(econ.getHeldMain());
		equipment.setItemInOffHand(econ.getHeldOff());
		
	}
	
	npc.chat = (BioptionMessage) map.get("message");		
	
	//provide our npc's name, unless we don't have one!
	if (npc.name != null && !npc.name.equals("")) {
		FancyMessage label = new FancyMessage(npc.name);
		npc.chat.setSourceLabel(label);			
	}
	
	return npc;
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:57,代碼來源:ServiceNPC.java

示例9: valueOf

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
public static SimpleQuestStartNPC valueOf(Map<String, Object> map) {
	if (map == null || !map.containsKey("name") || !map.containsKey("type") 
			 || !map.containsKey("location") || !map.containsKey("equipment")
			  || !map.containsKey("firstmessage") || !map.containsKey("duringmessage")
			  || !map.containsKey("postmessage") || !map.containsKey("badrequirementmessage")) {
		QuestManagerPlugin.logger.warning("Invalid NPC info! "
				+ (map.containsKey("name") ? ": " + map.get("name") : ""));
		return null;
	}
	EquipmentConfiguration econ = new EquipmentConfiguration();
	try {
		YamlConfiguration tmp = new YamlConfiguration();
		tmp.createSection("key",  (Map<?, ?>) map.get("equipment"));
		econ.load(tmp.getConfigurationSection("key"));
	} catch (InvalidConfigurationException e) {
		e.printStackTrace();
	}
	
	LocationState ls = (LocationState) map.get("location");
	Location loc = ls.getLocation();
	
	EntityType type = EntityType.valueOf((String) map.get("type"));
	
	
	SimpleQuestStartNPC npc = new SimpleQuestStartNPC(loc);
	npc.isEnd = false;
	
	npc.name = (String) map.get("name");
	
	//load the chunk
	loc.getChunk();
	npc.setEntity(loc.getWorld().spawnEntity(loc, type));
	npc.getEntity().setCustomName((String) map.get("name"));

	if (npc.getEntity() instanceof LivingEntity) {
		EntityEquipment equipment = ((LivingEntity) npc.getEntity()).getEquipment();
		equipment.setHelmet(econ.getHead());
		equipment.setChestplate(econ.getChest());
		equipment.setLeggings(econ.getLegs());
		equipment.setBoots(econ.getBoots());
		equipment.setItemInMainHand(econ.getHeldMain());
		equipment.setItemInOffHand(econ.getHeldOff());
		
	}
	
	npc.chat = (BioptionMessage) map.get("firstmessage");
	npc.duringMessage = (Message) map.get("duringmessage");
	npc.afterMessage = (Message) map.get("postmessage");
	npc.altMessage = (Message) map.get("badrequirementmessage");
	
	
	//provide our npc's name, unless we don't have one!
	if (npc.name != null && !npc.name.equals("")) {
		FancyMessage label = new FancyMessage(npc.name);
		npc.chat.setSourceLabel(label);
		npc.duringMessage.setSourceLabel(label);
		npc.afterMessage.setSourceLabel(label);
		npc.altMessage.setSourceLabel(label);
	}
	
	return npc;
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:63,代碼來源:SimpleQuestStartNPC.java

示例10: valueOf

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
public static LevelupNPC valueOf(Map<String, Object> map) {
	if (map == null || !map.containsKey("name") || !map.containsKey("type") 
			 || !map.containsKey("location") || !map.containsKey("equipment")
			  || !map.containsKey("message") || !map.containsKey("famerate") 
			  || !map.containsKey("famebase")) {
		QuestManagerPlugin.logger.warning("Invalid NPC info! "
				+ (map.containsKey("name") ? ": " + map.get("name") : ""));
		return null;
	}
	
	
	EquipmentConfiguration econ = new EquipmentConfiguration();
	try {
		YamlConfiguration tmp = new YamlConfiguration();
		tmp.createSection("key",  (Map<?, ?>) map.get("equipment"));
		econ.load(tmp.getConfigurationSection("key"));
	} catch (InvalidConfigurationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	LocationState ls = (LocationState) map.get("location");
	Location loc = ls.getLocation();
	

	LevelupNPC npc = new LevelupNPC(loc);
	EntityType type = EntityType.valueOf((String) map.get("type"));
	
	npc.name = (String) map.get("name");
	

	loc.getChunk();
	npc.setEntity(loc.getWorld().spawnEntity(loc, type));
	npc.getEntity().setCustomName((String) map.get("name"));

	if (npc.getEntity() instanceof LivingEntity) {
		EntityEquipment equipment = ((LivingEntity) npc.getEntity()).getEquipment();
		equipment.setHelmet(econ.getHead());
		equipment.setChestplate(econ.getChest());
		equipment.setLeggings(econ.getLegs());
		equipment.setBoots(econ.getBoots());
		equipment.setItemInMainHand(econ.getHeldMain());
		equipment.setItemInOffHand(econ.getHeldOff());
		
	}
	
	npc.chat = (BioptionMessage) map.get("message");
	
	//provide our npc's name, unless we don't have one!
	if (npc.name != null && !npc.name.equals("")) {
		npc.chat.setSourceLabel(
				new FancyMessage(npc.name));
		
	}
	
	npc.fameBase = (int) map.get("famebase");
	npc.fameRate = (double) map.get("famerate");
	
	npc.hpBase = npc.mpBase = 0;
	npc.hpRate = npc.mpRate = 0.0;
	
	if (map.containsKey("hpbase")) {
		npc.hpBase = (int) map.get("hpbase");
	}
	if (map.containsKey("hprate")) {
		npc.hpRate = (double) map.get("hprate");
	}
	if (map.containsKey("mpbase")) {
		npc.mpBase = (int) map.get("mpbase");
	}
	if (map.containsKey("mprate")) {
		npc.mpRate = (double) map.get("mprate");
	}
	
	return npc;
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:77,代碼來源:LevelupNPC.java

示例11: valueOf

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
public static InnNPC valueOf(Map<String, Object> map) {
	if (map == null || !map.containsKey("name") || !map.containsKey("type") 
			 || !map.containsKey("location") || !map.containsKey("equipment")
			  || !map.containsKey("message") || !map.containsKey("cost")) {
		QuestManagerPlugin.logger.warning("Invalid NPC info! "
				+ (map.containsKey("name") ? ": " + map.get("name") : ""));
		return null;
	}
	
	
	EquipmentConfiguration econ = new EquipmentConfiguration();
	try {
		YamlConfiguration tmp = new YamlConfiguration();
		tmp.createSection("key",  (Map<?, ?>) map.get("equipment"));
		econ.load(tmp.getConfigurationSection("key"));
	} catch (InvalidConfigurationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	LocationState ls = (LocationState) map.get("location");
	Location loc = ls.getLocation();
	
	InnNPC npc = new InnNPC(loc);
	EntityType type = EntityType.valueOf((String) map.get("type"));
	
	npc.name = (String) map.get("name");
	
	npc.cost = (int) map.get("cost");
	

	loc.getChunk();
	npc.setEntity(loc.getWorld().spawnEntity(loc, type));
	npc.getEntity().setCustomName((String) map.get("name"));

	if (npc.getEntity() instanceof LivingEntity) {
		EntityEquipment equipment = ((LivingEntity) npc.getEntity()).getEquipment();
		equipment.setHelmet(econ.getHead());
		equipment.setChestplate(econ.getChest());
		equipment.setLeggings(econ.getLegs());
		equipment.setBoots(econ.getBoots());
		equipment.setItemInMainHand(econ.getHeldMain());
		equipment.setItemInOffHand(econ.getHeldOff());
		
	}
	
	npc.chat = (BioptionMessage) map.get("message");		
	
	//provide our npc's name, unless we don't have one!
	if (npc.name != null && !npc.name.equals("")) {
		FancyMessage label = new FancyMessage(npc.name);
		npc.chat.setSourceLabel(label);			
	}
	
	return npc;
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:57,代碼來源:InnNPC.java

示例12: valueOf

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
public static BankNPC valueOf(Map<String, Object> map) {
	if (map == null || !map.containsKey("name") || !map.containsKey("type") 
			 || !map.containsKey("location") || !map.containsKey("equipment")
			  || !map.containsKey("message") || !map.containsKey("bank-id")) {
		QuestManagerPlugin.logger.warning("Invalid NPC info! "
				+ (map.containsKey("name") ? ": " + map.get("name") : ""));
		return null;
	}
	
	
	EquipmentConfiguration econ = new EquipmentConfiguration();
	try {
		YamlConfiguration tmp = new YamlConfiguration();
		tmp.createSection("key",  (Map<?, ?>) map.get("equipment"));
		econ.load(tmp.getConfigurationSection("key"));
	} catch (InvalidConfigurationException e) {
		e.printStackTrace();
	}
	
	LocationState ls = (LocationState) map.get("location");
	Location loc = ls.getLocation();
	
	BankNPC npc = new BankNPC(loc);
	EntityType type = EntityType.valueOf((String) map.get("type"));
	
	npc.name = (String) map.get("name");
	
	npc.bankID = (String) map.get("bank-id");
	

	loc.getChunk();
	npc.setEntity(loc.getWorld().spawnEntity(loc, type));
	npc.getEntity().setCustomName((String) map.get("name"));

	if (npc.getEntity() instanceof LivingEntity) {
		EntityEquipment equipment = ((LivingEntity) npc.getEntity()).getEquipment();
		equipment.setHelmet(econ.getHead());
		equipment.setChestplate(econ.getChest());
		equipment.setLeggings(econ.getLegs());
		equipment.setBoots(econ.getBoots());
		equipment.setItemInMainHand(econ.getHeldMain());
		equipment.setItemInOffHand(econ.getHeldOff());
		
	}
	
	npc.chat = (BioptionMessage) map.get("message");		
	
	//provide our npc's name, unless we don't have one!
	if (npc.name != null && !npc.name.equals("")) {
		FancyMessage label = new FancyMessage(npc.name);
		npc.chat.setSourceLabel(label);			
	}
	
	return npc;
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:56,代碼來源:BankNPC.java

示例13: valueOf

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
public static ForgeNPC valueOf(Map<String, Object> map) {
	if (map == null || !map.containsKey("name") || !map.containsKey("type") 
			 || !map.containsKey("location") || !map.containsKey("equipment")
			  || !map.containsKey("message") || !map.containsKey("cost")) {
		QuestManagerPlugin.logger.warning("Invalid NPC info! "
				+ (map.containsKey("name") ? ": " + map.get("name") : ""));
		return null;
	}
	
	
	EquipmentConfiguration econ = new EquipmentConfiguration();
	try {
		YamlConfiguration tmp = new YamlConfiguration();
		tmp.createSection("key",  (Map<?, ?>) map.get("equipment"));
		econ.load(tmp.getConfigurationSection("key"));
	} catch (InvalidConfigurationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	LocationState ls = (LocationState) map.get("location");
	Location loc = ls.getLocation();
	
	ForgeNPC npc = new ForgeNPC(loc);
	EntityType type = EntityType.valueOf((String) map.get("type"));
	
	npc.name = (String) map.get("name");
	
	npc.cost = (int) map.get("cost");
	

	loc.getChunk();
	npc.setEntity(loc.getWorld().spawnEntity(loc, type));
	npc.getEntity().setCustomName((String) map.get("name"));

	if (npc.getEntity() instanceof LivingEntity) {
		EntityEquipment equipment = ((LivingEntity) npc.getEntity()).getEquipment();
		equipment.setHelmet(econ.getHead());
		equipment.setChestplate(econ.getChest());
		equipment.setLeggings(econ.getLegs());
		equipment.setBoots(econ.getBoots());
		equipment.setItemInMainHand(econ.getHeldMain());
		equipment.setItemInOffHand(econ.getHeldOff());
		
	}
	
	npc.chat = (BioptionMessage) map.get("message");		
	
	//provide our npc's name, unless we don't have one!
	if (npc.name != null && !npc.name.equals("")) {
		FancyMessage label = new FancyMessage(npc.name);
		npc.chat.setSourceLabel(label);			
	}
	
	return npc;
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:57,代碼來源:ForgeNPC.java

示例14: valueOf

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
public static MuteNPC valueOf(Map<String, Object> map) {
	if (map == null || !map.containsKey("name") || !map.containsKey("type") 
			 || !map.containsKey("location") || !map.containsKey("equipment")) {
		QuestManagerPlugin.logger.warning("Invalid NPC info! "
				+ (map.containsKey("name") ? ": " + map.get("name") : ""));
		return null;
	}
	
	EquipmentConfiguration econ = new EquipmentConfiguration();
	try {
		YamlConfiguration tmp = new YamlConfiguration();
		tmp.createSection("key",  (Map<?, ?>) map.get("equipment"));
		econ.load(tmp.getConfigurationSection("key"));
	} catch (InvalidConfigurationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	LocationState ls = (LocationState) map.get("location");
	Location loc = ls.getLocation();
	
	EntityType type = EntityType.valueOf((String) map.get("type"));
	
	
	MuteNPC npc = new MuteNPC(loc);

	loc.getChunk();
	npc.setEntity(loc.getWorld().spawnEntity(loc, type));
	npc.setStartingLoc(loc);
	npc.getEntity().setCustomName((String) map.get("name"));
	
	npc.name = (String) map.get("name");

	if (npc.getEntity() instanceof LivingEntity) {
		EntityEquipment equipment = ((LivingEntity) npc.getEntity()).getEquipment();
		equipment.setHelmet(econ.getHead());
		equipment.setChestplate(econ.getChest());
		equipment.setLeggings(econ.getLegs());
		equipment.setBoots(econ.getBoots());
		equipment.setItemInMainHand(econ.getHeldMain());
		equipment.setItemInOffHand(econ.getHeldOff());
		
	}
	
	return npc;
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:47,代碼來源:MuteNPC.java

示例15: valueOf

import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static TeleportNPC valueOf(Map<String, Object> map) {
	if (map == null || !map.containsKey("name") || !map.containsKey("type") 
			 || !map.containsKey("location") || !map.containsKey("equipment")
			  || !map.containsKey("message") || !map.containsKey("cost") 
			|| !map.containsKey("destination") || !map.containsKey("requiredquests")
			|| !map.containsKey("badrequirementmessage")) {
		QuestManagerPlugin.logger.warning("Invalid NPC info! "
				+ (map.containsKey("name") ? ": " + map.get("name") : ""));
		return null;
	}
	
	EquipmentConfiguration econ = new EquipmentConfiguration();
	try {
		YamlConfiguration tmp = new YamlConfiguration();
		tmp.createSection("key",  (Map<?, ?>) map.get("equipment"));
		econ.load(tmp.getConfigurationSection("key"));
	} catch (InvalidConfigurationException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	LocationState ls = (LocationState) map.get("location");
	Location loc = ls.getLocation();
	
	EntityType type = EntityType.valueOf((String) map.get("type"));
	
	TeleportNPC npc = new TeleportNPC(loc);
	
	npc.name = (String) map.get("name");
	
	npc.cost = (int) map.get("cost");
	
	npc.destination = ((LocationState) map.get("destination")).getLocation();
	

	loc.getChunk();
	npc.setEntity(loc.getWorld().spawnEntity(loc, type));
	npc.getEntity().setCustomName((String) map.get("name"));

	if (npc.getEntity() instanceof LivingEntity) {
		EntityEquipment equipment = ((LivingEntity) npc.getEntity()).getEquipment();
		equipment.setHelmet(econ.getHead());
		equipment.setChestplate(econ.getChest());
		equipment.setLeggings(econ.getLegs());
		equipment.setBoots(econ.getBoots());
		equipment.setItemInMainHand(econ.getHeldMain());
		equipment.setItemInOffHand(econ.getHeldOff());
		
	}
	
	npc.chat = (BioptionMessage) map.get("message");
	npc.altMessage = (Message) map.get("badrequirementmessage");
	npc.requirements = (List<String>) map.get("requiredquests");
	
	//provide our npc's name, unless we don't have one!
	if (npc.name != null && !npc.name.equals("")) {
		FancyMessage label = new FancyMessage(npc.name);
		npc.chat.setSourceLabel(label);			
		npc.altMessage.setSourceLabel(label);
	}
	
	return npc;
}
 
開發者ID:Dove-Bren,項目名稱:QuestManager,代碼行數:65,代碼來源:TeleportNPC.java


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