1.13.2 Calling from config in a event

Discussion in 'Spigot Plugin Development' started by TheJYT, Jan 27, 2020.

Thread Status:
Not open for further replies.
  1. Hi there, I am making a plugin and when I try to call from a config file in an event the ide gives me an error. upload_2020-1-27_19-30-30.png

    My Event Class Code:

    ```START OF CODE```
    import java.util.Random;

    import org.bukkit.Material;
    import org.bukkit.entity.LivingEntity;
    import org.bukkit.entity.Skeleton;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDeathEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.Plugin;

    public class Drops implements Listener {
    private Plugin plugin;

    public Drops(Plugin plugin)
    {
    this.plugin = plugin;
    }

    @EventHandler
    public void mobDeath(EntityDeathEvent event) {
    event.getDrops().clear();
    event.setDroppedExp(plugin.getConfig().getInt("exp_drop_amaount"));
    Random r = new Random();
    int number = r.nextInt(plugin.getConfig().getInt("max_drop_rate")-plugin.getConfig().getInt("min_drop_rate")) + 2;

    LivingEntity e = event.getEntity();

    if (e instanceof Skeleton) {
    e.getLocation().getWorld().dropItem(e.getLocation(), new ItemStack(Material.valueOf(plugin.getConfig().getString("drop")), number));
    }
    }
    }
    ```END OF CODE```

    How would I call the config?
     
  2. Just type in new Drops(this)
     
    • Like Like x 1
  3. ^^ Yup...
    The IDE tells you right there.

    Read those more carefully, and you will have your answer instantly instead of having to come on here and wait for an answer.
     
    • Like Like x 1
  4. Put your code in code format.
     
  5. Ty, however when I used the auto suggestions that the IDE gave me it put null in the brackets. It did fix the plugin, ty
     
Thread Status:
Not open for further replies.