当前位置: 首页>>代码示例>>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;未经允许,请勿转载。