0

This is my code

public final class CustomEntityDrops extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);

    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }

    @EventHandler
    public void onEntityDeath(EntityDeathEvent e) {
        // this.Object getConfig = new CustomEntityDrops().onEntityDeath(getConfig());
        double chance = CustomEntityDrops.getConfig().getDouble("dropChance", 50) / 100;

        if (e.getEntity() instanceof Player && nextDouble() <= chance) {
            //clear drops
            e.getDrops().clear();
            // Code for player deaths

            //item
            ItemStack blueShard = new ItemStack(Material.LIGHT_BLUE_DYE); //blueShard is the variable and after that we define the item
            ItemStack ametistFragment = new ItemStack(Material.PURPLE_DYE); //ametistFragment is the variable and after that we define the item

            //meta
            ItemMeta blueShardItemMeta = blueShard.getItemMeta(); //We set a meta for it
            ItemMeta ametistFragmentItemMeta = ametistFragment.getItemMeta(); //We set a meta for it

            //name
            blueShardItemMeta.setDisplayName(ChatColor.DARK_AQUA + "It's baked"); // The name of the item
            ametistFragmentItemMeta.setDisplayName(ChatColor.DARK_AQUA + "It's baked"); // The name of the item

            //set the meta
            blueShard.setItemMeta(blueShardItemMeta);
            ametistFragment.setItemMeta(ametistFragmentItemMeta);

            //item drop
            e.getEntity().getWorld().dropItem(e.getEntity().getLocation(), blueShard); // Drop the item on the ground
            e.getEntity().getWorld().dropItem(e.getEntity().getLocation(), ametistFragment); // Drop the item on the ground

        }
    }
}

That's the main class and the error says non-static getconfig() cannot be referenced from a static context. I would highly appreciate any kind of help (mostly held with code).

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
GerGeto
  • 1
  • 1
  • 3
    Does this answer your question? [Non-static variable cannot be referenced from a static context](https://stackoverflow.com/questions/2559527/non-static-variable-cannot-be-referenced-from-a-static-context) – Nowhere Man Jun 21 '20 at 19:06
  • Cannot you just call `getConfig`? It should be provided in the parent class `JavaPlugin` – Nowhere Man Jun 21 '20 at 19:12

0 Answers0