Java 类org.bukkit.entity.Villager 实例源码

项目:ZentrelaRPG    文件:NPCManager.java   
@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));
        }
    }
}
项目:NeverLag    文件:AntiVillagerTrade.java   
@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);
        }
    }
}
项目:PA    文件:ShopsCMD.java   
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;
    }
}
项目:Chambers    文件:VillagerManager.java   
/**
 * 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;
}
项目:Locked    文件:Prison.java   
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;
        }
    }

}
项目:attributehider    文件:Remover.java   
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();
}
项目:MCDeathSwap    文件:DeathSwapPlugin.java   
@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;
}
项目:world-of-icerealm    文件:TrashVendorPlugin.java   
@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);


}
项目:RedProtect    文件:RPEntityListener.java   
@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");
    }
}
项目:Ultra-Hardcore-1.8    文件:UhcDmg.java   
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();
    }
}
项目:cNoHacks    文件:ForceField.java   
@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");
                        }
                    }
                }
            }
        }
    }
}
项目:cNoHacks    文件:ForceField.java   
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;
}
项目:COD-Warfare    文件:Listeners.java   
@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");
            }
        }
    }
}
项目:uSkyBlock    文件:LimitLogic.java   
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;
}
项目:defend-the-village    文件:Main.java   
@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);
        }
       }
}
项目:Dexoria-Hub    文件:Interact.java   
@EventHandler
public void i(PlayerInteractEntityEvent e){
    Player p = e.getPlayer();
    Entity ent = e.getRightClicked();

    if(!(ent instanceof Villager)){
        return;
    }
    e.setCancelled(true);
    Villager v = (Villager) ent;

    if(v.getCustomName().equalsIgnoreCase(ChatColor.RED + "" + ChatColor.BOLD + "Mineageddon")){
        p.sendMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "--------" + ChatColor.RED + "" + ChatColor.BOLD + "Mineageddon" + ChatColor.AQUA + "" + ChatColor.BOLD + "--------");
        p.sendMessage(ChatColor.BLUE + "Description: " + ChatColor.GRAY + "Use our amazing custom items to kill other players whilst destorying everything!");
        p.sendMessage(ChatColor.BLUE + "Category: " + ChatColor.GRAY + "Kit PvP");
        p.sendMessage(ChatColor.BLUE + "Coded by: " + ChatColor.GRAY + "nxsupert");
        p.sendMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "------------------" + ChatColor.AQUA + "" + ChatColor.BOLD + "--------");
    }   
}
项目:RandomStuff    文件:randomStuff.java   
@EventHandler
public void PlayerRightClick(PlayerInteractEntityEvent event)
{
    if(event.getRightClicked() instanceof Villager)
    {
        Player p = event.getPlayer();
        if(p.getInventory().getHelmet() != null) {
            p.getInventory().getHelmet().setDurability((short) 0);
        }
        if(p.getInventory().getChestplate() != null){
            p.getInventory().getChestplate().setDurability((short) 0);
        }
        if(p.getInventory().getLeggings() != null) {
            p.getInventory().getLeggings().setDurability((short) 0);
        }
        if(p.getInventory().getLeggings() != null) {
            p.getInventory().getBoots().setDurability((short) 0);
        }
    }
}
项目:SpigotSource    文件:CraftHumanEntity.java   
@Override
public InventoryView openMerchant(Villager villager, boolean force) {
    Preconditions.checkNotNull(villager, "villager cannot be null");
    if (!force && villager.isTrading()) {
        return null;
    } else if (villager.isTrading()) {
        // we're not supposed to have multiple people using the same villager, so we have to close it.
        villager.getTrader().closeInventory();
    }

    EntityVillager ev = ((CraftVillager) villager).getHandle();
    ev.setTradingPlayer(this.getHandle());
    this.getHandle().openTrade(ev);

    return this.getHandle().activeContainer.getBukkitView();
}
项目:EntityAPI    文件:ControllableVillagerBase.java   
@Override
public BehaviourItem[] getDefaultMovementBehaviours() {
    return new BehaviourItem[]{
            new BehaviourItem(0, new BehaviourFloat(this)),
            new BehaviourItem(1, new BehaviourAvoidEntity(this, Zombie.class, 8.0F, 0.6D, 0.6D)),
            new BehaviourItem(1, new BehaviourTradeWithPlayer(this)),
            new BehaviourItem(1, new BehaviourLookAtTradingPlayer(this)),
            new BehaviourItem(2, new BehaviourMoveIndoors(this)),
            new BehaviourItem(3, new BehaviourRestrictOpenDoor(this)),
            new BehaviourItem(4, new BehaviourOpenDoor(this, true)),
            new BehaviourItem(5, new BehaviourMoveTowardsRestriction(this, 0.6D)),
            new BehaviourItem(6, new BehaviourMakeLove(this)),
            new BehaviourItem(7, new BehaviourTakeFlower(this)),
            new BehaviourItem(8, new BehaviourVillagerPlay(this, 0.32D)),
            new BehaviourItem(9, new BehaviourInteract(this, HumanEntity.class, 3.0F, 1.0F)),
            new BehaviourItem(9, new BehaviourInteract(this, Villager.class, 3.0F, 1.0F)),
            new BehaviourItem(9, new BehaviourRandomStroll(this, 0.6D)),
            new BehaviourItem(10, new BehaviourLookAtNearestEntity(this, InsentientEntity.class, 8.0F))
    };
}
项目:EpicQuest    文件:QuestEntityHandler.java   
public static Villager SpawnVillager(World world, Location loc, String name){
    if(EpicSystem.useCitizens()) return null;

    //Check if villager exists
    if(GetEntity(world, name) != null){
        RemoveVillager(world, name);
    }

    //Set properties
    Villager villager = (Villager) world.spawnEntity(loc, EntityType.VILLAGER);
    villager.setCustomName(name);
    villager.setCustomNameVisible(true);
    villager.setAgeLock(true);
    villager.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000000000, 100000000));
    villager.setCanPickupItems(false);

    QuestEntity epicVillager = new QuestEntity(villager);
    epicVillager.originalLocation = loc;

    entityList.put(villager, epicVillager);

    return villager;
}
项目:ZentrelaRPG    文件:NPCEntity.java   
protected boolean spawn() {
    if (loc.getChunk().isLoaded()) {
        despawn();
        le = type.createEntity(loc.clone().add(0, 0.5, 0));
        boolean mobile = false;
        if (this instanceof GenericNPC) {
            ((Leashable) ((CraftLivingEntity) le).getHandle()).allowWalk(((GenericNPC) this).leash);
            mobile = true;
        }
        String displayName = getColor() + name;
        le.setCustomName(displayName);
        le.setCustomNameVisible(true);
        if (le instanceof Villager) {
            if (this instanceof QuestVillager) {
                ((Villager) le).setProfession(Profession.PRIEST);
            } else if (this instanceof ShopVillager) {
                ((Villager) le).setProfession(Profession.LIBRARIAN);
            } else if (this instanceof DungeonVillager) {
                ((Villager) le).setProfession(Profession.BUTCHER);
            } else if (this instanceof HorseVillager) {
                ((Villager) le).setProfession(Profession.BLACKSMITH);
            }
        }
        if (!mobile) {
            double mult = type.tagHeight;
            as = RTags.makeStand(ChatColor.GRAY + getSub(), loc.clone().add(0, ((CraftLivingEntity) le).getHandle().getHeadHeight() * mult, 0), true);
            NPCManager.npcs.put(as.getUniqueId(), this);
        }
        NPCManager.npcs.put(le.getUniqueId(), this);
        RScheduler.schedule(NPCManager.plugin, new Runnable() {
            public void run() {
                if (loc.getChunk().isLoaded() && le != null && le.isValid()) {
                    le.teleport(loc);
                }
            }
        }, RTicks.seconds(1));
        return true;
    }
    return false;
}
项目:LoggerAPI    文件:LoggerEntity.java   
public LoggerEntity(Plugin plugin, Player player) {
    this.plugin = plugin;
    this.uuid = player.getUniqueId();
    this.name = player.getName();
    this.health = player.getHealth();
    this.contents = player.getInventory().getContents();
    this.armour = player.getInventory().getArmorContents();
    this.world = player.getWorld();

    this.villager = (Villager) this.world.spawnEntity(player.getLocation(), EntityType.VILLAGER);
    this.villager.setCustomName(this.name);
    this.villager.setHealth(this.health);

    this.resetTimer();
}
项目:ProjectAres    文件:MultiTradeMatchModule.java   
@ListenerScope(MatchScope.LOADED)
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void processItemRemoval(PlayerInteractEntityEvent event) {
    if(event.getRightClicked() instanceof Villager) {
        event.setCancelled(true);
        event.getPlayer().openMerchantCopy((Villager) event.getRightClicked());
    }
}
项目:FactionsXL    文件:FMob.java   
/**
 * @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;
}
项目:FactionsXL    文件:FMob.java   
/**
 * @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;
}
项目:Kineticraft    文件:ShearFinder.java   
@EventHandler
public void onInteract(PlayerInteractEntityEvent evt) {
    if (!(evt.getRightClicked() instanceof Villager) || !evt.getRightClicked().getCustomName().contains("Barley") || Cutscenes.isWatching(evt.getPlayer()) || isComplete())
        return;

    if (evt.getPlayer().getInventory().contains(Material.SHEARS)) {
        evt.getPlayer().getInventory().remove(Material.SHEARS);
        complete();
    } else {
        evt.getPlayer().sendMessage(ChatColor.DARK_GREEN + "Mr. Barley> " + ChatColor.GREEN + "We need my shears to move onward. Help me search from them!");
    }
}
项目:Locked    文件:Prison.java   
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);
    }

}
项目:Locked    文件:Prison.java   
public static void killAllNPCs() {
    for (Villager npc : getWorld().getEntitiesByClass(Villager.class)) {
        if (npc == null) continue;
        npc.setHealth(0);
    }
    npcs.clear();
}
项目:GameBoxx    文件:Professions.java   
@Override
public void onLoad() {
    add(Villager.Profession.FARMER, "Farmer", "Default", "Def", "Normal", "None", "Farm", "FA", "F");
    add(Villager.Profession.LIBRARIAN, "Librarian", "Library", "Lib", "LI", "L");
    add(Villager.Profession.PRIEST, "Priest", "PR", "P");
    add(Villager.Profession.BLACKSMITH, "Blacksmith", "Smith", "BSmith", "BlackS", "BS", "BL");
    add(Villager.Profession.BUTCHER, "Butcher", "BU", "B");
}
项目:Skript    文件:VillagerData.java   
@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;
}
项目:MagicLoot3    文件:MLListener.java   
@EventHandler
public void onInteract(PlayerInteractEntityEvent e) {
    if (e.getRightClicked() instanceof Villager && ((LivingEntity) e.getRightClicked()).getCustomName() != null && ((LivingEntity) e.getRightClicked()).getCustomName().equals("�5�lLost Librarian")) {
        e.setCancelled(true);
        try {
            LostLibrarian.openMenu(e.getPlayer());
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }
}
项目:RpgPlus    文件:VillagerEntityWrapper.java   
@Override
public void rawset(LuaValue key, LuaValue value) {
    if (key.isstring()) {
        switch (key.checkjstring()) {
            case "profession":
                getVillagerTrait().setProfession(ScriptUtil.enumValue(value, Villager.Profession.class));
                break;
        }
    }
    super.rawset(key, value);
}
项目:RedProtect    文件:RPGlobalListener.java   
@EventHandler
  public void onCreatureSpawn(CreatureSpawnEvent event) {
RedProtect.get().logger.debug("RPGlobalListener - Is CreatureSpawnEvent event! Cancelled? " + event.isCancelled());
    if (event.isCancelled()) {
          return;
      }
      Entity e = event.getEntity();
      if (e == null) {
          return;
      }

      Location l = event.getLocation();
      Region r = RedProtect.get().rm.getTopRegion(l);
      if (r != null){
        return;
      }

      if (e instanceof Wither && event.getSpawnReason().equals(SpawnReason.BUILD_WITHER) && !RPConfig.getGlobalFlagBool(e.getWorld().getName()+".spawn-wither")){ 
          event.setCancelled(true);
          return;
      }        
      if (e instanceof Monster && !RPConfig.getGlobalFlagBool(e.getWorld().getName()+".spawn-monsters")) {          
          if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.NATURAL)
                        || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER)
                        || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.CHUNK_GEN)
                        || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.DEFAULT)) {
            event.setCancelled(true);
              return;
          }
      }
      if ((e instanceof Animals || e instanceof Villager || e instanceof Golem) && !RPConfig.getGlobalFlagBool(e.getWorld().getName()+".spawn-passives")) {         
          if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.NATURAL)
                        || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER)
                        || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.CHUNK_GEN)
                        || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.DEFAULT)) {
            event.setCancelled(true);
    }
      }
  }
项目:cNoHacks    文件:ForceField.java   
@EventHandler
public void onVillagerInteract(PlayerInteractEntityEvent event) { 
    if(event.getRightClicked() instanceof Villager) {
        Villager villager = (Villager) event.getRightClicked();
        if(villager.hasMetadata("cancel")) {
            event.setCancelled(true);
        }
    }
}
项目:uSkyBlock    文件:LimitLogic.java   
public CreatureType getCreatureType(LivingEntity creature) {
    if (creature instanceof Monster
            || creature instanceof WaterMob
            || creature instanceof Slime
            || creature instanceof Ghast) {
        return CreatureType.MONSTER;
    } else if (creature instanceof Animals) {
        return CreatureType.ANIMAL;
    } else if (creature instanceof Villager) {
        return CreatureType.VILLAGER;
    } else if (creature instanceof Golem) {
        return CreatureType.GOLEM;
    }
    return CreatureType.UNKNOWN;
}
项目:acidisland    文件:Island.java   
/**
 * @return Provides count of villagers within the protected island boundaries
 */
public int getPopulation() {
    int result = 0; 
    for (int x = getMinProtectedX() /16; x <= (getMinProtectedX() + getProtectionSize() - 1)/16; x++) {
        for (int z = getMinProtectedZ() /16; z <= (getMinProtectedZ() + getProtectionSize() - 1)/16; z++) {
            for (Entity entity : world.getChunkAt(x, z).getEntities()) {
                if (entity instanceof Villager && onIsland(entity.getLocation())) {
                    result++;
                }
            }
        }  
    }
    return result;
}
项目:askyblock    文件:Island.java   
/**
 * @return Provides count of villagers within the protected island boundaries
 */
public int getPopulation() {
    int result = 0; 
    for (int x = getMinProtectedX() /16; x <= (getMinProtectedX() + getProtectionSize() - 1)/16; x++) {
        for (int z = getMinProtectedZ() /16; z <= (getMinProtectedZ() + getProtectionSize() - 1)/16; z++) {
            for (Entity entity : world.getChunkAt(x, z).getEntities()) {
                if (entity instanceof Villager && onIsland(entity.getLocation())) {
                    result++;
                }
            }
        }  
    }
    return result;
}
项目:Dexoria-Hub    文件:HubEntitys.java   
public static void spawn(){
    for(Location loc : mineageddon()){
        final Villager v = HubVillager.spawn(loc);
        v.setAdult();
        v.setCustomName(ChatColor.RED + "" + ChatColor.BOLD + "Mineageddon");
        v.setCustomNameVisible(true);
        v.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 10000000,100,false));
    }
}
项目:Dexoria-Hub    文件:HubVillager.java   
public static Villager spawn(Location location) {
    World mcWorld = (World) ((CraftWorld) location.getWorld()).getHandle();
    final HubVillager customEntity = new HubVillager(
            mcWorld,1);
    customEntity.setLocation(location.getX(), location.getY(),
            location.getZ(), location.getYaw(), location.getPitch());
    ((CraftLivingEntity) customEntity.getBukkitEntity())
            .setRemoveWhenFarAway(false);
    mcWorld.addEntity(customEntity, SpawnReason.CUSTOM);
    return (CraftVillager) customEntity.getBukkitEntity();
}
项目:TotalEconomyBukkit    文件:BusinessNPC.java   
public void createNPC(UUID uuid) {
    OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
    World world = player.getPlayer().getWorld();
    Villager villager = world.spawn(player.getPlayer().getLocation(), Villager.class);//Spawn villager at the player's location
    villager.setAge(9999);
    villager.setAgeLock(true);
}