Code: public static Chicken chick; Player p; public ChickenEntity(Main main, Player p){ this.main = main; this.p = p; chick = p.getLocation().getWorld().spawn(p.getLocation(), Chicken.class); chick.setCustomName(ChatColor.translateAlternateColorCodes('&' , main.getConfig().getString("ChickenPetName").replaceAll("<player>", p.getName()))); chick.setCustomNameVisible(true); chick.getAgeLock(); main.chickpet.put(p.getName(), chick); } There is problem I want to spawn pet/entity on protected WorldGuard. I dont want other mobs spawing there only my pet. I used WorldGuard API but I have no idea how could I do this.
I was never doing with WorldGuard so I don't even know how to start. I wan't to check if region have MOB_SPAWNING DENY and then if it has it can still spawn only custom entity(pet) with command.
@bronzzze Get all applicable regions, set MOB_SPAWNING to true, spawn the entity, then turn it off again.
@pie_flavor Code: @EventHandler public void onSpawn(CreatureSpawnEvent e) { WorldGuardPlugin wg = (WorldGuardPlugin) main.plugin; RegionManager rg = wg.getRegionManager(chick.getWorld()); ApplicableRegionSet set = manager.getApplicableRegions(chick.getLocation()); if(!(set.allows(DefaultFlag.MOB_SPAWNING))){ } } I tried something like this. But not sure what to do.
Couldnt you just manually set the flags ? Also you could do something like on entity spawn check if the chicken is inside a region and cancel it .
@MaTaMoR_ Problem is its public plugin. I already finished all only this is problem. I will try to find methods for Worldguard.
So you dont have to worry for that, if somebody wants to disable the pets on a region they must do it manually, i dont see any problem with that .