本文整理匯總了Java中org.bukkit.inventory.EntityEquipment.setItemInOffHand方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityEquipment.setItemInOffHand方法的具體用法?Java EntityEquipment.setItemInOffHand怎麽用?Java EntityEquipment.setItemInOffHand使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.inventory.EntityEquipment
的用法示例。
在下文中一共展示了EntityEquipment.setItemInOffHand方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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.setItemInOffHand(item);
else
e.setItemInHand(item); //Compatibility reasons
}
示例2: 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);
}
示例3: create
import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
public static PigZombie create(Location l) {
PigZombie police = (PigZombie) l.getWorld().spawnEntity(l, EntityType.PIG_ZOMBIE);
Pig hov = (Pig) l.getWorld().spawnEntity(l, EntityType.PIG);
police.setMaxHealth(80);
police.setHealth(80);
ItemStack helm = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta helmMeta = (LeatherArmorMeta) helm.getItemMeta();
helmMeta.setColor(Color.BLACK);
helmMeta.setDisplayName(ChatColor.BOLD + "Bullet Proof Helmet");
helmMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);
helm.setItemMeta(helmMeta);
ItemStack chest = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta chestMeta = (LeatherArmorMeta) chest.getItemMeta();
chestMeta.setColor(Color.BLACK);
chestMeta.setDisplayName(ChatColor.BOLD + "Bullet Proof Vest");
chestMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);
chest.setItemMeta(chestMeta);
ItemStack leg = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta legMeta = (LeatherArmorMeta) leg.getItemMeta();
legMeta.setColor(Color.BLACK);
legMeta.setDisplayName(ChatColor.BOLD + "Bullet Proof Leggings");
legMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);
leg.setItemMeta(legMeta);
ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta bootsMeta = (LeatherArmorMeta) boots.getItemMeta();
bootsMeta.setColor(Color.BLACK);
bootsMeta.setDisplayName(ChatColor.BOLD + "Bullet Proof Boots");
bootsMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);
bootsMeta.addEnchant(Enchantment.PROTECTION_FALL, 15, true);
boots.setItemMeta(bootsMeta);
EntityEquipment ee = police.getEquipment();
ee.setHelmet(helm);
ee.setChestplate(chest);
ee.setLeggings(leg);
ee.setBoots(boots);
ee.setItemInOffHand(new ItemStack(Material.CARROT_STICK));
police.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, true, false));
hov.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 4, true, false));
hov.setPassenger(police);
police.setCustomName("Officer");
police.setCustomNameVisible(true);
police.addScoreboardTag("law");
return police;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}
示例13: 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;
}
示例14: 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;
}
示例15: valueOf
import org.bukkit.inventory.EntityEquipment; //導入方法依賴的package包/類
public static SimpleChatNPC 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();
EntityType type = EntityType.valueOf((String) map.get("type"));
SimpleChatNPC npc = new SimpleChatNPC(loc);
loc.getChunk();
npc.setEntity(loc.getWorld().spawnEntity(loc, type));
npc.setStartingLoc(loc);
npc.name = (String) map.get("name");
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());
}
//UPDATE: We wanna also accept regular strings, too :P
Object msgObj = map.get("message");
if (msgObj instanceof Message) {
npc.chat = (Message) map.get("message");
} else if (msgObj instanceof FancyMessage) {
npc.chat = new SimpleMessage((FancyMessage) msgObj);
} else if (msgObj instanceof String){
npc.chat = new SimpleMessage((String) msgObj);
} else {
QuestManagerPlugin.logger.warning(
"Invalid message type for Simple Chat NPC: " + npc.name);
}
if (npc.chat != null || npc.name != null || !npc.name.trim().isEmpty()) {
npc.chat.setSourceLabel(new FancyMessage(npc.name));
}
return npc;
}