Skip to content

Instantly share code, notes, and snippets.

@chyyran
Last active June 11, 2020 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chyyran/5c0225e61702d12755135ecd885da63a to your computer and use it in GitHub Desktop.
Save chyyran/5c0225e61702d12755135ecd885da63a to your computer and use it in GitHub Desktop.
#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