Plugin Help Wolf spawning set owner event.

Discussion in 'Plugin Help/Development/Requests' started by Scorpionvssub, Aug 8, 2015.

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

    Scorpionvssub

    When someone picks the werewolf kit they are allowed to spawn 2 wolves, but in pvp noone really has time to tame them so i wanna have it do this automaticly.

    So i set them to be tamed upon spawning and some other stuff. But now i have an issue with the owner part of it. Since it doesnt work the same way horses do im not sure how to make sure how to set it to be following or atleast be friendly to the 1 spawning the wolf and hostile to anyone else.

    Heres the code i have thus far.
    Code:
        @EventHandler
             public void onWolfspawn(PlayerInteractEntityEvent e) {
            if (e.getRightClicked().equals(Material.MONSTER_EGG)) {
                Player p = e.getPlayer();
                Material egg = Material.MONSTER_EGG;
                egg.getData();
                if (egg.getData().equals(95)) {
                    List<Wolf> list = new ArrayList<>();
                    Wolf w = p.getWorld().spawnEntity(p.getLocation(p.getUniqueId(), EntityType.WOLF));
                    list.add(w);
                    wolves.put(e.getPlayer().getUniqueId(), (List<Wolf>) w);
                }
            }
        }
    
        @EventHandler
        public void onWolfSpawner(final EntitySpawnEvent e) {
            if (e.getEntity() instanceof Wolf) {
                final Wolf wolf = (Wolf) e.getEntity();
                wolf.setTamed(true);
                wolf.setBreed(false);
                wolf.setOwner(wolves.get(e.getEntity().getUniqueId(), List<Wolf>));
                wolf.setAdult();
                wolf.setHealth(10);
                Random r1 = new Random();
                int c1i = r1.nextInt(16) + 1;
                Color c1 = getColour(c1i);
                wolf.setCollarColor(DyeColor.getByColor(c1));
                Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                    @Override
                    public void run() {
                        wolf.setHealth(0);
                    }
                }, 6000);
            }
        }
    
        @EventHandler
        public void onPlayerQuit(PlayerQuitEvent e) {
            Player p = e.getPlayer();
            List<Wolf> list = wolves.get(p.getUniqueId());
            for (Wolf w : list){
                w.setHealth(0);
                w.remove();
            }
        }
    
     
    Last edited: Aug 9, 2015
Thread Status:
Not open for further replies.

Share This Page