Skip to content

Instantly share code, notes, and snippets.

@chyyran

chyyran/LegazyZombies.java Secret

Last active Jun 11, 2020
Embed
What would you like to do?
#LegacyZombies config
#if this is true, feathers will drop with flesh
#if false, feathers will drop by themselves only.
dropFleshAndFeathers: false
#Percent Chance in Decimal of Feather Drops
chanceOfFeatherDrop: 0.50
package net.mystia.LegacyZombies;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
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.java.JavaPlugin;
public class LegacyZombiesMain extends JavaPlugin implements Listener
{
public void onEnable()
{
File config = new File(this.getDataFolder(), "config.yml");
if (!config.exists())
{
this.saveDefaultConfig();
}
getLogger().info("Loading LegacyZombies");
Bukkit.getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onZombieDeath(EntityDeathEvent event)
{
if (event.getEntityType() == EntityType.ZOMBIE)
{
Double FeatherDropChance = this.getConfig().getDouble("chanceOfFeatherDrop");
Boolean DropBothItems = this.getConfig().getBoolean("dropFleshAndFeathers");
if (Math.random() < FeatherDropChance)
{
ItemStack feather = new ItemStack(Material.FEATHER, 1);
if (DropBothItems == false){
event.getDrops().clear();
}
event.getDrops().add(feather);
}
}
}
public void onDisable()
{
getLogger().info("LegacyZombies has been disabled");
}
}
name: LegacyZombies
main: net.mystia.LegacyZombies.LegacyZombiesMain
version: 0.1
description: Makes Zombies drop feathers
author: ron975
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.