WorldGuard Pet

Discussion in 'Plugin Development' started by bronzzze, Apr 25, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    bronzzze

    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.
     
  2. Offline

    bronzzze

    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.
     
  3. Offline

    pie_flavor

    @bronzzze Get all applicable regions, set MOB_SPAWNING to true, spawn the entity, then turn it off again.
     
  4. Offline

    bronzzze

    @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.
     
    Last edited: Apr 26, 2015
  5. Offline

    bronzzze

  6. 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 .
     
  7. Offline

    bronzzze

    @MaTaMoR_
    Problem is its public plugin. I already finished all only this is problem. I will try to find methods for Worldguard.
     
  8. 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 .
     
Thread Status:
Not open for further replies.

Share This Page