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


Java Villager.setProfession方法代碼示例

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


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

示例1: spawnVillager

import org.bukkit.entity.Villager; //導入方法依賴的package包/類
private boolean spawnVillager(Location l, int data) {
    final Villager v = (Villager) l.getWorld().spawnEntity(l, EntityType.VILLAGER);
    v.setAgeLock(true);
    v.setCustomNameVisible(true);

    NoAI.setAIEnabled(v, false); //No queremos la "querida" AI de Minecraft :D

    v.teleport(l);

    switch (data) {
        case 0:
            v.setProfession(Villager.Profession.FARMER);
            v.setCustomName("&dComprador Variado");
            return true;
        case 1:
            v.setProfession(Villager.Profession.BLACKSMITH);
            v.setCustomName("&cComprador Armas");
            return true;
        default:
            return false;
    }
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:23,代碼來源:ShopsCMD.java

示例2: spawnVillager

import org.bukkit.entity.Villager; //導入方法依賴的package包/類
/**
 * Spawns a Villager of the given VillagerType at the provided Location
 * 
 * @param type - the Type of the Villager you wish to Spawn
 * @param location - the Location at which you want the Villager to be
 * @return Villager - the Villager that you had set at the provided Location if you wish to use it
 */
public Villager spawnVillager(VillagerType type, Location location) {
	if (!location.getChunk().isLoaded()) {
		location.getChunk().load();
	}
	Villager villager = (Villager) location.getWorld().spawnEntity(location, EntityType.VILLAGER);
	villager.setAdult();
	villager.setAgeLock(true);
	villager.setProfession(Profession.FARMER);
	villager.setRemoveWhenFarAway(false);
	villager.setCustomName(type.getColor() + type.getName());
	villager.setCustomNameVisible(true);
	villager.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, -6, true), true);
	villager.teleport(location, TeleportCause.PLUGIN);
	villager.setHealth(20.0D);
	return villager;
}
 
開發者ID:HuliPvP,項目名稱:Chambers,代碼行數:24,代碼來源:VillagerManager.java

示例3: resetupNPC

import org.bukkit.entity.Villager; //導入方法依賴的package包/類
public static void resetupNPC(String namee) {
    killNPC(namee);
    for (String name : MerchantManager.getAllNPCs()) {
        if (name.equals(namee)) {
            Villager npc = getWorld().spawn(MerchantManager.getLocation(name), Villager.class);
            npc.setCustomName(name); //change name here
            npc.setCustomNameVisible(true);
            npc.setAI(false);
            npc.setInvulnerable(true);
            npc.setProfession(Villager.Profession.BLACKSMITH);
            npcs.add(npc);
            break;
        }
    }

}
 
開發者ID:Warvale,項目名稱:Locked,代碼行數:17,代碼來源:Prison.java

示例4: onCommand

import org.bukkit.entity.Villager; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof Player) {
        Player player = (Player) sender;

        if (command.getName().equalsIgnoreCase("spawnNPC")) {
            if (!player.hasPermission("deathswap.admin")) {
                player.sendMessage(ChatUtil.formatWithPrefix("&cYou do not have permission to use this command!"));
                return true;
            }

            Villager villager = (Villager) player.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.VILLAGER);
            villager.setCustomName(ChatUtil.format("&aJoin DeathSwap"));
            villager.setProfession(Villager.Profession.BUTCHER);
            villager.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 999999, 999999));
        }

    }
    return false;
}
 
開發者ID:ShadowTechnicalSystems,項目名稱:MCDeathSwap,代碼行數:21,代碼來源:DeathSwapPlugin.java

示例5: spawnVillager

import org.bukkit.entity.Villager; //導入方法依賴的package包/類
/**
 * @param location
 * the location where the villager will spawn
 * @return
 * the spawned villager
 */
public static Villager spawnVillager(Location location) {
    Villager villager = (Villager) location.getWorld().spawnEntity(location, EntityType.VILLAGER);
    if (Version.andHigher(Version.MC1_11).contains(CompatibilityHandler.getInstance().getVersion())) {
        villager.setProfession(Profession.NITWIT);
    } else {
        villager.setProfession(Profession.FARMER);
    }
    villager.setCustomName(MOB_VILLAGER.getMessage());
    villager.setCustomNameVisible(true);
    return villager;
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:18,代碼來源:FMob.java

示例6: spawnTrader

import org.bukkit.entity.Villager; //導入方法依賴的package包/類
/**
 * @param location
 * the location where the trader will spawn
 * @return
 * the spawned trader
 */
public static Villager spawnTrader(Location location) {
    Villager villager = (Villager) location.getWorld().spawnEntity(location, EntityType.VILLAGER);
    villager.setProfession(Profession.LIBRARIAN);
    villager.setCustomName(MOB_TRADER.getMessage());
    villager.setCustomNameVisible(true);
    return villager;
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:14,代碼來源:FMob.java

示例7: setupNPCs

import org.bukkit.entity.Villager; //導入方法依賴的package包/類
private static void setupNPCs() {
    for (String name : MerchantManager.getAllNPCs()) {
        Villager npc = getWorld().spawn(MerchantManager.getLocation(name), Villager.class);
        npc.setCustomName(name); //change name here
        npc.setCustomNameVisible(true);
        npc.setAI(false);
        npc.setInvulnerable(true);
        npc.setProfession(Villager.Profession.BLACKSMITH);
        npcs.add(npc);
    }

}
 
開發者ID:Warvale,項目名稱:Locked,代碼行數:13,代碼來源:Prison.java

示例8: spawn

import org.bukkit.entity.Villager; //導入方法依賴的package包/類
@Override
@Nullable
public Villager spawn(final Location loc) {
	final Villager v = super.spawn(loc);
	if (v == null)
		return null;
	if (profession == null)
		v.setProfession(CollectionUtils.getRandom(Profession.values()));
	return v;
}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:11,代碼來源:VillagerData.java

示例9: onGrinchDeath

import org.bukkit.entity.Villager; //導入方法依賴的package包/類
@EventHandler
public void onGrinchDeath(EntityDeathEvent e) {
	final Location loc = e.getEntity().getLocation();
	final World wLoc = loc.getWorld();

	if(e.getEntity().getCustomName() == null){
		return;
	}

	Player player = e.getEntity().getKiller();

	if(e.getEntity().getCustomName().contains("The Grinch!") && (e.getEntityType() == EntityType.GIANT)){

		spawnedGrinch = 0;
		dropXmasBoots(player);
		GrinchDefeatSpeech.speech(player);
		dropExp(e.getEntity().getLocation());

		for(Player p : Bukkit.getOnlinePlayers()){
			if (p.getWorld().getName() == "Christmas"){
				giveCake(p);
			}
		}

		final Villager v = (Villager)wLoc.spawnEntity(loc.add(0,1,0), EntityType.VILLAGER);
		v.setCanPickupItems(false);
		v.setCustomName(ChatColor.GREEN + "The Grinch!");
		v.setProfession(Profession.PRIEST);			
	}
}
 
開發者ID:EmilHernvall,項目名稱:tregmine,代碼行數:31,代碼來源:GrinchListener.java

示例10: set

import org.bukkit.entity.Villager; //導入方法依賴的package包/類
@Override
public void set(final Villager entity) {
	if (profession != null)
		entity.setProfession(profession);
}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:6,代碼來源:VillagerData.java

示例11: onBlockPlaced

import org.bukkit.entity.Villager; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockPlaced(BlockPlaceEvent evt) {
	Block block = evt.getBlock();
	if (block.getType().equals(Material.EMERALD_BLOCK) || block.getType().equals(Material.DIAMOND_BLOCK) || block.getType().equals(Material.IRON_BLOCK)) {
		World world = block.getWorld();
		
		Block below = world.getBlockAt(new Location(world, block.getX(), block.getY() - 1, block.getZ()));
		Block below2 = world.getBlockAt(new Location(world, block.getX(), block.getY() - 2, block.getZ()));
		
		if (below != null && below.getType().equals(Material.OBSIDIAN) && below2.getType().equals(Material.OBSIDIAN)) {
			
			VillagerTradeOffer[] offers = null;
			
			Profession profession = Profession.FARMER;
			

			if (block.getType().equals(Material.DIAMOND_BLOCK)) { 
				offers = new VillagerTradeOffer[] {
						new VillagerTradeOffer(new ItemStack(Material.EMERALD, 24), new ItemStack(Material.DIAMOND_SWORD, 1)),
						new VillagerTradeOffer(new ItemStack(Material.EMERALD, 64), new ItemStack(Material.DIAMOND_LEGGINGS, 1)),
						new VillagerTradeOffer(new ItemStack(Material.EMERALD, 64), new ItemStack(Material.DIAMOND_CHESTPLATE, 1)),
						new VillagerTradeOffer(new ItemStack(Material.EMERALD, 32), new ItemStack(Material.DIAMOND_HELMET, 1)),					
						new VillagerTradeOffer(new ItemStack(Material.EMERALD, 32), new ItemStack(Material.DIAMOND_BOOTS, 1)),					
						new VillagerTradeOffer(new ItemStack(Material.EMERALD, 24), new ItemStack(Material.DIAMOND_PICKAXE, 1))
				};

				profession = Profession.BLACKSMITH;
			} else if (block.getType().equals(Material.EMERALD_BLOCK)) {
				offers = new VillagerTradeOffer[] {
						new VillagerTradeOffer(new ItemStack(Material.BONE, 64), new ItemStack(Material.EMERALD, 1)),
						new VillagerTradeOffer(new ItemStack(Material.ROTTEN_FLESH, 64), new ItemStack(Material.EMERALD, 1)),
						new VillagerTradeOffer(new ItemStack(Material.SPIDER_EYE, 64), new ItemStack(Material.EMERALD, 1)),
						new VillagerTradeOffer(new ItemStack(Material.STRING, 64), new ItemStack(Material.EMERALD, 1)),
				};
				profession = Profession.FARMER;
			}
			
			if (offers != null) {
				block.setType(Material.AIR);
				below.setType(Material.AIR);
				below2.setType(Material.AIR);

				Villager villager = world.spawn(block.getLocation(), Villager.class);
				villager.setAdult();
				villager.setBreed(false);
				villager.setProfession(profession);					

				EntityVillager entityVillager = ((CraftVillager)villager).getHandle();
				MerchantRecipeList recipes = entityVillager.getOffers(((CraftPlayer)evt.getPlayer()).getHandle());
				recipes.clear();
				
				for(VillagerTradeOffer offer : offers) {
					recipes.add(offer.getMerchantRecipie());
				}
			}
		}
	}
}
 
開發者ID:Allov,項目名稱:world-of-icerealm,代碼行數:59,代碼來源:TradingPlugin.java

示例12: onSpawn

import org.bukkit.entity.Villager; //導入方法依賴的package包/類
@Override
public void onSpawn() {
    Villager horse = (Villager) getNPC().getEntity();
    if (profession != null) horse.setProfession(profession);
}
 
開發者ID:leMaik,項目名稱:RpgPlus,代碼行數:6,代碼來源:VillagerTrait.java

示例13: spawnVillager

import org.bukkit.entity.Villager; //導入方法依賴的package包/類
public void spawnVillager(Villager.Profession p) {
	Location l = e.getCentre().toLocation();
	Villager v = Castle.getInstance().getWorld().spawn(l, Villager.class);
	v.setProfession(p);
	Castle.getInstance().incDenizenCount(p);
}
 
開發者ID:jimfinnis,項目名稱:Gorm,代碼行數:7,代碼來源:Room.java


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