Coding A Dupe Plugin

Discussion in 'Plugin Development' started by 6ingie, May 15, 2020.

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

    6ingie

    I know this may sound VERY odd. This is a custom Plugin for my own/friends uses that we play offline.. Essentially, I want the plugin to make it so when you splash a potion of Slow Falling on a Mule, and kill it, it duplicates the items inside the chest it carries. I'll post the code I have so far, however, I feel like I'm batting 1000 and I'm not even close xD...

    Code:
    package me.gingie.muledupe;
    
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityPotionEffectEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    
    public final class MuleDupe extends JavaPlugin implements Listener {
        //The Dupe goes as follows: You must breed a Horse and a Donkey to get a mule.
        //Then you must tame the Mule and add a chest to it.
        //Add all items you want duped in to the ChestedHorse inventory.
        //Lastly, splash a potion of Slow Falling on the Mule and kill it.
        @Override
        public void onEnable() {
            // Plugin startup logic
            System.out.println("MuleDupe Plugin is starting...");
            muleDupe();
        }
    
        @EventHandler
        public void muleDupe(){
            //Main Handler for the Mule Dupe Process.
        }
        public void potionEffect(EntityPotionEffectEvent entityPotionEffectEvent) {
            PotionEffect potionEffect; PotionEffectType slowFalling = PotionEffectType.SLOW_FALLING;
        }
    }
    I'd love it if someone could either help me through dev'ing this, or put my on the right track <3. Thank you!
     
  2. Online

    timtower Administrator Administrator Moderator

    @6ingie Check when a mule dies, check if it has slow falling, get chest content, drop them extra.
     
    6ingie likes this.
  3. Offline

    6ingie

    How do I specify the mule itself? This is what I have so far...

    Code:
        public void muleDeath(EntityDeathEvent muleDeath){
    
        }
     
  4. Online

    timtower Administrator Administrator Moderator

    @6ingie Get the entity, check if it is a mule, cast to mule.
     
  5. Offline

    6ingie

    Code:
    package me.gingie.muledupe;
    import com.sun.istack.internal.NotNull;
    import org.bukkit.entity.*;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDeathEvent;
    import org.bukkit.event.entity.EntityDropItemEvent;
    import org.bukkit.event.entity.EntityPotionEffectEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffectType;
    
    public final class MuleDupe extends JavaPlugin implements Listener {
    private boolean PotionEffectType;//The Dupe goes as follows: You must breed a Horse and a Donkey to get a mule. 
    //Then you must tame the Mule and add a chest to it. 
    //Add all items you want duped in to the ChestedHorse inventory. 
    //Lastly, splash a potion of Slow Falling on the Mule and kill it.
    @Override
    public void onEnable() {
    // Plugin startup logicSystem.out.println("MuleDupe Plugin is starting...");muleDeath(); //<---Error Here}
    
    @EventHandler
    public void muleDeath(@NotNull EntityDeathEvent event){
    //Main Handler for the Mule Dupe Process.
    LivingEntity e = event.getEntity();
    PotionEffectType potionEffectType;
    potionEffectType = PotionEffectType.SLOW_FALLING;
    if(e instanceof Mule){
    PotionEffectType = true;}
    
    }
    }
    
    Ok. I think I made a little progress in establishing if the mule has the potion effect.. Is this correct? I do have one error about args expecting 1 but got 0 in onEnable for muleDeath();
     
  6. Online

    timtower Administrator Administrator Moderator

    @6ingie You need to register the events, not call the method.
     
  7. Offline

    6ingie

    Code:
    package me.gingie.muledupe;
    import com.sun.istack.internal.NotNull;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.*;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDeathEvent;
    import org.bukkit.event.entity.EntityDropItemEvent;
    import org.bukkit.event.entity.EntityPotionEffectEvent;
    import org.bukkit.inventory.HorseInventory;
    import org.bukkit.entity.LivingEntity;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffectType;
    
    public final class MuleDupe extends JavaPlugin implements Listener {
    private boolean PotionEffectType;
    //The Dupe goes as follows: You must breed a Horse and a Donkey to get a mule.
    //Then you must tame the Mule and add a chest to it.
    //Add all items you want duped in to the ChestedHorse inventory.
    //Lastly, splash a potion of Slow Falling on the Mule and kill it.
    @Overridepublic void onEnable() {
    // Plugin startup logicSystem.out.println("MuleDupe Plugin is starting...");
    Bukkit.getServer().getPluginManager().registerEvents(this, this);
    }
    
    @EventHandlerpublic void muleDeath(@NotNull EntityDeathEvent event){
    //Main Handler for the Mule Dupe
    Process.LivingEntity e = event.getEntity();PotionEffectType potionEffectType;
    potionEffectType = PotionEffectType.SLOW_FALLING; /*Error Here*
    /if(e instanceof Mule){
    PotionEffectType = true; }
    
    }
    }
    
    I managed to figure out what you meant by registering, but I'm still trying to figure out the rest...
     
Thread Status:
Not open for further replies.

Share This Page