mm api: SkillEvents dont work

Discussion in 'Add-Ons, API & Compatible Plugins' started by BerndiVader, Nov 1, 2016.

  1. BerndiVader

    BerndiVader Active Member
    Supporter

    Joined:
    Feb 9, 2016
    Messages:
    602
    Likes Received:
    219
    Hi! Both SkillEvents are dead.

    Code:
    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    
    import net.elseland.xikage.MythicMobs.API.Bukkit.Events.*;
    
    public class mmSkillEvents implements Listener {
    
        @EventHandler
        private void onMythicMobSkillEvent(MythicMobSkillEvent e) {
    
            Bukkit.getLogger().warning("dead event");
        }
    
        @EventHandler
        private void onMythicMobCustomSkill(MythicMobCustomSkillEvent e) {
       
            Bukkit.getLogger().warning("dead event");
        }
    
    
    }
    Code:
        @Override
        public void onEnable() {
       
            getServer().getPluginManager().registerEvents(new mmSkillEvents(), this);   
     
       
        }
    
    
        @Override
        public void onDisable() {
       
        }



    EDIT: Noticed that it still works with legacyskills. So its fine for me atm. But still would be nice if you could add the events to the new skillsystem too.
     
    #1
    Last edited: Nov 1, 2016
  2. jaylawl

    jaylawl Community Manager
    Super Moderator Supporter Premium Supporter Quality Assurance

    Joined:
    Sep 16, 2015
    Messages:
    1,763
    Likes Received:
    171
    this topic feels like it belongs into the api section, done
     
    #2
  3. Mixxit

    Mixxit Member
    Supporter Premium Supporter

    Joined:
    Jun 10, 2016
    Messages:
    42
    Likes Received:
    2
    This is because the event is fired from LegacySkill where as SkillSkill does not call it

    This should fire just fine (and does for me on 2.6) - Note the LegacySkill section will fire the SkillEvent with the string skill SPAWN ~onSpawn

    NPCID_117:
    Type: SKELETON
    Display: GuardOran
    Health: 63
    Damage: 1
    MovementSpeed: 0
    MaxCombatDistance: 15
    PreventOtherDrops: true
    PreventRandomEquipment: true
    Options:
    PreventMobKillDrops: true
    PreventOtherDrops: true
    Silent: true
    ShowHealth: true
    PreventRenaming: true
    PreventRandomEquipment: true
    AlwaysShowName: true
    Modules:
    ThreatTable: true
    AIGoalSelectors:
    - 0 clear
    - 1 skeletonbowattack
    - 2 meleeattack
    AITargetSelectors:
    - 0 clear
    - 1 attacker
    Equipment:
    - CUSTOMHEADNPCID_117:4
    - IRON_CHESTPLATE:3
    - IRON_LEGGINGS:2
    - IRON_BOOTS:1
    - IRON_SWORD:0
    LegacySkills:
    - skill SPAWN ~onSpawn




    Don't forget to enable legacyskills for this in config.yml though

    Mobs:
    EnableLegacySkills: true
    EnableAIModifiers: true
    EnableTimerSkills: true
     
    #3
    Last edited: Feb 20, 2017
  4. Xikage

    Xikage Administrator
    Administrator Developer Super Moderator Supporter Premium Supporter Quality Assurance

    Joined:
    Jul 18, 2015
    Messages:
    657
    Likes Received:
    230
    the skill events were replaced by the ability to add custom skills.

    Is there a reason you'd like them back?
     
    #4
  5. BerndiVader

    BerndiVader Active Member
    Supporter

    Joined:
    Feb 9, 2016
    Messages:
    602
    Likes Received:
    219
    well not me no. thx it was a necro that mixxit brought bsck

    btw good job with the api from almost 0 to everything. nice
     
    #5
  6. Mixxit

    Mixxit Member
    Supporter Premium Supporter

    Joined:
    Jun 10, 2016
    Messages:
    42
    Likes Received:
    2
    This is kind of complicated to answer but essentially I needed to capture the spawngroup of a mob when it spawns

    Sadly the MobSpawn event does not have an ActiveMob to retrieve the spawngroup from

    So instead I had to attach a legacy skill spawn event to the mob which I could create a listener for

    When searching how to do this, I saw this post which I figured future people may find useful if i responded to
     
    #6
  7. BerndiVader

    BerndiVader Active Member
    Supporter

    Joined:
    Feb 9, 2016
    Messages:
    602
    Likes Received:
    219
    use the creaturespawnevent instead

    Code:
        @EventHandler
        public void onCreatureSpawnEvent(CreatureSpawnEvent e) {
            if (e.getSpawnReason().equals(SpawnReason.CUSTOM) && !e.isCancelled()) {
                Entity bukkitEntity = e.getEntity();
                new BukkitRunnable() {
                    @Override
                    public void run() {
                        if (!(MythicMobs.inst().getAPIHelper().isMythicMob(bukkitEntity))) return;
                        ActiveMob am = MythicMobs.inst().getAPIHelper().getMythicMobInstance(bukkitEntity);
                    }
                }.runTaskLater(plugin, 1);
            }
        }
     
    #7
  8. Mixxit

    Mixxit Member
    Supporter Premium Supporter

    Joined:
    Jun 10, 2016
    Messages:
    42
    Likes Received:
    2
    Code:
    @EventHandler
       public void onCreatureSpawnEvent(CreatureSpawnEvent e) {
         if (e.getSpawnReason().equals(SpawnReason.CUSTOM) && !e.isCancelled()) {
           Entity bukkitEntity = e.getEntity();
           new BukkitRunnable() {
             @Override
             public void run() {
               if (!(MythicMobs.inst().getMobManager().isActiveMob(BukkitAdapter.adapt(bukkitEntity))))
                 return;
               ActiveMob am = MythicMobs.inst().getMobManager().getMythicMobInstance(bukkitEntity);
    
               if (am.getSpawner() == null)
                 return;
    
               int spawngroupid = Integer.parseInt(am.getSpawner().getInternalName()
                   .substring(am.getSpawner().getInternalName().lastIndexOf('_') + 1));
               SoliniaSpawnGroup sg = SoliniaDataManager.getSoliniaData().GetSpawnGroupByID(spawngroupid);
               MythicMobsUtils.SetRotation(am, (float) sg.yaw);
             }
           }.runTaskLater(plugin, 1);
         }
       }
    
    
    I think your example was 4.0 but after adjusting slightly that seemed to work thank you!

    I don't know if you guys can add support for rotation, but here is how i do it currently

    Code:
    public static void SetRotation(final ActiveMob am, float yaw) {
         final net.minecraft.server.v1_11_R1.Entity nmsEntity = ((CraftEntity)am.getEntity().getBukkitEntity()).getHandle();
         final NBTTagCompound tag = new NBTTagCompound();
         nmsEntity.c(tag);
         NBTTagList list = new NBTTagList();
         list.add(new NBTTagFloat(yaw));
         list.add(new NBTTagFloat(0f));
         tag.set("Rotation", list);
         // tag.set("Rotation", this.a(new float[] { this.yaw, this.pitch}));
         nmsEntity.f(tag);
       }
    
     
    #8

Share This Page