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


Java Villager類代碼示例

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


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

示例1: onEntityInteract

import org.bukkit.entity.Villager; //導入依賴的package包/類
@EventHandler
public void onEntityInteract(PlayerInteractEntityEvent event) {
    if (event.getRightClicked() != null && event.getRightClicked() instanceof Villager)
        event.setCancelled(true);
    if (event.getRightClicked() != null && npcs.containsKey(event.getRightClicked().getUniqueId())) {
        event.setCancelled(true);
        Player p = event.getPlayer();
        if (plugin.getPD(p) != null) {
            if (lastClick.containsKey(p.getUniqueId())) {
                if (System.currentTimeMillis() - lastClick.get(p.getUniqueId()) < 333) {
                    return;
                }
            }
            lastClick.put(p.getUniqueId(), System.currentTimeMillis());
            npcs.get(event.getRightClicked().getUniqueId()).interact(p, plugin.getPD(p));
        }
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:19,代碼來源:NPCManager.java

示例2: onTouchEntity

import org.bukkit.entity.Villager; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onTouchEntity(PlayerInteractEntityEvent e) {
	if (!cm.isAntiVillagerTrade) {
		return;
	}
	Entity entity = e.getRightClicked();
	if (entity == null || NeverLagUtils.checkCustomNpc(entity)) {
		return;
	}
	World world = entity.getWorld();
	if (world == null) {
		return;
	}
	if (cm.disableVillagerTradeWorld.contains(world.getName())) {
		if (entity instanceof Villager) {
			e.setCancelled(true);
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:20,代碼來源:AntiVillagerTrade.java

示例3: 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

示例4: 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

示例5: 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

示例6: modify

import org.bukkit.entity.Villager; //導入依賴的package包/類
public void modify(Villager villager, Player player) {
	WrappedEntityVillager<?> handle = WrapperCache.get(WrappedEntityVillager.class);
	handle.setVillager(villager);
	WrappedMerchantRecipeList<?> list = handle.getOffers();
	List<WrappedMerchantRecipe<?>> recipes = list.getRecipes();
	WrappedItemStack<?> item = WrapperCache.get(WrappedItemStack.class);
	for(WrappedMerchantRecipe<?> recipe : recipes) {
		recipe.newInstance(getItem(item, recipe.handleGetBuyingItem1()), getItem(item, recipe.handleGetBuyingItem2()), getItem(item, recipe.handleGetSellingItem()), recipe.getUses(),
				recipe.getMaxUses());
	}
	list.setRecipes(recipes);
	item.cache();
	recipes.forEach(Wrappable::cache);
	list.cache();
	handle.cache();
}
 
開發者ID:Warren1001,項目名稱:attributehider,代碼行數:17,代碼來源:Remover.java

示例7: 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

示例8: onEnable

import org.bukkit.entity.Villager; //導入依賴的package包/類
@Override
public void onEnable() {
	
	if(this.getServer().getPluginManager().isPluginEnabled("Vault")) {
		economyProvider = getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
	}
	
	fillTradeTable();
	
	//_location = new Location(getServer().getWorld("world"), -163.0, 71.0, 145.0); // server test punisher
	_location = new Location(getServer().getWorld("world"), 691.0,69.0,276.0); // shop village
	_zone = new WorldZone(_location, 5);
	//_zone = new WorldZone(getServer().getWorld("world"), "-167,140,-159,150,69,75");
	_villager = (Villager)getServer().getWorld("world").spawnCreature(_location, EntityUtilities.getCreatureType("Villager"));
	_location = _villager.getLocation(); 		
	getServer().getPluginManager().registerEvents(this, this);
	getCommand("tv").setExecutor(this);

	Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(this, 0, 100, TimeUnit.MILLISECONDS);

	ZoneServer.getInstance().addListener(this);
	
	
}
 
開發者ID:Allov,項目名稱:world-of-icerealm,代碼行數:25,代碼來源:TrashVendorPlugin.java

示例9: onInteractEvent

import org.bukkit.entity.Villager; //導入依賴的package包/類
@EventHandler
public void onInteractEvent(PlayerInteractEntityEvent e){
   	RedProtect.get().logger.debug("RPEntityListener - Is PlayerInteractEntityEvent");
   	if (e.isCancelled()) {
           return;
       }
	Player p = e.getPlayer();
	if (p == null){
		return;
	}
	Location l = e.getRightClicked().getLocation();
	Region r = RedProtect.get().rm.getTopRegion(l);	
	Entity et = e.getRightClicked();
	if (r != null && !r.canInteractPassives(p) && (et instanceof Animals || et instanceof Villager || et instanceof Golem)) {
		if (et instanceof Tameable){
			Tameable tam = (Tameable) et;
			if (tam.isTamed() && tam.getOwner() != null && tam.getOwner().getName().equals(p.getName())){
				return;
			}
		}
	    e.setCancelled(true);
		RPLang.sendMessage(p, "entitylistener.region.cantinteract");
	}
}
 
開發者ID:FabioZumbi12,項目名稱:RedProtect,代碼行數:25,代碼來源:RPEntityListener.java

示例10: ds

import org.bukkit.entity.Villager; //導入依賴的package包/類
private String ds(Villager.Profession a) {
	switch (a) {
	case BLACKSMITH:
		return "Blacksmith";
	case BUTCHER:
		return "Butcher";
	case FARMER:
		return "Farmer";
	case HUSK:
		return "Husk";
	case LIBRARIAN:
		return "Librarian";
	case NITWIT:
		return "Nitwit";
	case PRIEST:
		return "Priest";
	default:
		return "Unknown 0x8." + a.ordinal();
	}
}
 
開發者ID:Thomaz2Fast,項目名稱:Ultra-Hardcore-1.8,代碼行數:21,代碼來源:UhcDmg.java

示例11: onVillagerDamage

import org.bukkit.entity.Villager; //導入依賴的package包/類
@EventHandler
public void onVillagerDamage(EntityDamageByEntityEvent event) {
	if(event.getDamager() instanceof Player && event.getEntity() instanceof Villager) {
		Villager villager = (Villager) event.getEntity();
		Player damager = (Player) event.getDamager();
		if(villager.getCustomName().equals(damager.getName())) {
			for(Player online : Bukkit.getOnlinePlayers()) {
				if(online.hasPermission("cnohacks.view") || online.isOp()) {
					if (ConfigManager.contains("alerts.yml", online.getName())) {
						if (ConfigManager.get("alerts.yml").getBoolean(online.getName() + ".Alerts")) {
							online.sendMessage(Utils.getPrefix() + damager.getDisplayName() + " §7might be using §cForcefield");
						}
					}
				}
			}
		}
	}
}
 
開發者ID:Lilmac12312,項目名稱:cNoHacks,代碼行數:19,代碼來源:ForceField.java

示例12: onCommand

import org.bukkit.entity.Villager; //導入依賴的package包/類
public boolean onCommand(CommandSender sender, Command cmd, String tag, String[] args) {
	if (tag.equalsIgnoreCase("test")) {
			for (Player online : Bukkit.getOnlinePlayers()) {
				final Villager villager = (Villager) online.getLocation().getWorld().spawnEntity(online.getLocation().subtract(3,0,3), EntityType.VILLAGER);
				villager.setCustomName(online.getName());
				villager.setCustomNameVisible(true);
				villager.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1));
				villager.setMetadata("cancel", (MetadataValue)new FixedMetadataValue((Plugin)plugin, (Object)true));
				Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
					public void run() {
						vilager.removeMetaData("cancel");
						villager.remove();
					}
				}, 10);
			}
		}
	return false;
}
 
開發者ID:Lilmac12312,項目名稱:cNoHacks,代碼行數:19,代碼來源:ForceField.java

示例13: onEntityInteract

import org.bukkit.entity.Villager; //導入依賴的package包/類
@EventHandler
public void onEntityInteract(PlayerInteractEntityEvent e) {
	if (Main.PlayingPlayers.contains(e.getPlayer()) || Main.WaitingPlayers.contains(e.getPlayer())) {
		e.setCancelled(true);
	}

	if (e.getRightClicked() instanceof Villager) {
		Villager v = (Villager) e.getRightClicked();
		if (v.getCustomName().equals("Try Guns") || v.getCustomName().equals("§b§lTry Guns")) {
			if (Main.WaitingPlayers.contains(e.getPlayer())) {
				Player p = e.getPlayer();
				v.setCustomName("§b§lTry Guns");
				v.setCustomNameVisible(true);
				p.openInventory(Guns.tryGunsInventory);
			} else {
				e.setCancelled(true);
				e.getPlayer().sendMessage(Main.codSignature + "§cYou may only try guns when in COD-Warfare");
			}
		}
	}
}
 
開發者ID:frostythedev,項目名稱:COD-Warfare,代碼行數:22,代碼來源:Listeners.java

示例14: getCreatureType

import org.bukkit.entity.Villager; //導入依賴的package包/類
public CreatureType getCreatureType(EntityType entityType) {
    if (Monster.class.isAssignableFrom(entityType.getEntityClass())
            || WaterMob.class.isAssignableFrom(entityType.getEntityClass())
            || Slime.class.isAssignableFrom(entityType.getEntityClass())
            || Ghast.class.isAssignableFrom(entityType.getEntityClass())
            ) {
        return CreatureType.MONSTER;
    } else if (Animals.class.isAssignableFrom(entityType.getEntityClass())) {
        return CreatureType.ANIMAL;
    } else if (Villager.class.isAssignableFrom(entityType.getEntityClass())) {
        return CreatureType.VILLAGER;
    } else if (Golem.class.isAssignableFrom(entityType.getEntityClass())) {
        return CreatureType.GOLEM;
    }
    return CreatureType.UNKNOWN;
}
 
開發者ID:rlf,項目名稱:uSkyBlock,代碼行數:17,代碼來源:LimitLogic.java

示例15: onDamage

import org.bukkit.entity.Villager; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onDamage(EntityDamageByEntityEvent ev) {
	if ((ev.getDamager() instanceof Player)) {
		Player pl = (Player)ev.getDamager();
		
		// Is in game?
		if (this.am.isInGame(pl)) {
			if (((ev.getEntity() instanceof Villager)) || ((ev.getEntity() instanceof Player))) {
				// Cancel damage
				ev.setCancelled(true);
			}
			
			for (Arena a : this.am.arenas) {
				if (a.deadPlayers.contains(pl.getName())) {
					// Avoid damage by dead players
					ev.setCancelled(true);
				}
			}
		}
	}
	else if (ev.getDamager() instanceof Arrow){ // To avoid damage by arrow
		if (((ev.getEntity() instanceof Villager)) || ((ev.getEntity() instanceof Player))) {
			ev.setCancelled(true);
		}
       }
}
 
開發者ID:odarriba,項目名稱:defend-the-village,代碼行數:27,代碼來源:Main.java


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