Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.nosma_stew.thewalkingdead;
- import java.util.Random;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.command.ConsoleCommandSender;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.LivingEntity;
- import org.bukkit.entity.Player;
- import org.bukkit.entity.Zombie;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.CreatureSpawnEvent;
- import org.bukkit.event.entity.EntityCombustEvent;
- import org.bukkit.event.entity.EntityDamageByEntityEvent;
- import org.bukkit.event.entity.EntityDeathEvent;
- import org.bukkit.event.entity.EntityTargetEvent;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.plugin.RegisteredServiceProvider;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- import net.milkbowl.vault.economy.Economy;
- public class Main extends JavaPlugin implements Listener {
- public static Plugin plugin;
- private static final Logger log = Logger.getLogger("Minecraft");
- public static Economy econ = null;
- public void onEnable() {
- getConfig().options().copyDefaults(true);
- saveConfig();
- Bukkit.getServer().getPluginManager().registerEvents(new InfiniteCauldron(this), this);
- Bukkit.getServer().getPluginManager().registerEvents(new CustomZombie(this), this);
- Bukkit.getServer().getPluginManager().registerEvents(this, this);
- Bukkit.getConsoleSender().sendMessage(org.bukkit.ChatColor.GREEN + "TheWalkingDead is now enabled - Version Using: " + getDescription().getVersion());
- if (!setupEconomy() ) {
- log.severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
- getServer().getPluginManager().disablePlugin(this);
- return;
- }
- }
- private boolean setupEconomy() {
- if (getServer().getPluginManager().getPlugin("Vault") == null) {
- return false;
- }
- RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
- if (rsp == null) {
- return false;
- }
- econ = rsp.getProvider();
- return econ != null;
- }
- public void onDisable() {
- saveConfig();
- Bukkit.getConsoleSender().sendMessage(org.bukkit.ChatColor.GREEN + "TheWalkingDead is now disabled - Version Using: " + getDescription().getVersion());
- }
- @EventHandler
- public void onEntityDeath(EntityDeathEvent e)
- {
- if (this.getConfig().getBoolean("Zombies-MoneyReward") == true) {
- if (e.getEntity().getKiller() instanceof Player && e.getEntity() instanceof Zombie) {
- Player p = e.getEntity().getKiller();
- econ.depositPlayer(p, getConfig().getDouble("Zombies-SetMoneyReward", 10.00));
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("Zombies-RewardMessage")));
- }
- }
- }
- @EventHandler
- public void onEntityTarget(EntityTargetEvent e)
- {
- Entity z = e.getEntity();
- if (e.getTarget() instanceof Player)
- {
- Player p = (Player) e.getTarget();
- if(z instanceof Zombie && p instanceof Player)
- {
- if(p.getInventory().getChestplate() != null)
- {
- if(p.getInventory().getChestplate().getType() == Material.GOLD_CHESTPLATE)
- {
- p.getInventory().getChestplate().setDurability((short) +1);
- e.setCancelled(true);
- }
- }
- }
- }
- }
- @EventHandler
- public void onZombieSpawn(CreatureSpawnEvent e)
- {
- Entity zombie = e.getEntity();
- int hp = getConfig().getInt("Zombies-SetHealth");
- if ((zombie instanceof Zombie)) {
- ((Zombie)zombie).setHealth(hp);
- zombie.setCustomName(ChatColor.translateAlternateColorCodes('&', getConfig().getString("Zombies-SetName")));
- }
- }
- @EventHandler
- public void entityCombust(EntityCombustEvent e)
- {
- Entity entity = e.getEntity();
- if(entity instanceof LivingEntity)
- {
- LivingEntity le = (LivingEntity) entity;
- if(le instanceof Zombie)
- {
- Zombie zombie = (Zombie) le;
- if(zombie.getWorld().getTime() >= 0L && zombie.getWorld().getTime() <= 24000L)
- {
- e.setCancelled(true);
- }
- }
- }
- }
- @EventHandler
- public void onentitydie(EntityDeathEvent e)
- {
- e.setDroppedExp(0);
- if ((e.getEntity() instanceof Zombie)) {
- e.getDrops().clear();
- Random ob = new Random();
- for (int counter = 1; counter <= 1; counter++) {
- int num = 1 + ob.nextInt(4);
- if (num == 3) {
- e.getEntity().getLocation().getWorld().dropItemNaturally(e.getEntity().getLocation(), new ItemStack(Material.ROTTEN_FLESH, 0));
- }
- }
- }
- if ((e.getEntity() instanceof Zombie))
- e.getDrops().clear();
- }
- @EventHandler
- public void ZombieStrength(EntityDamageByEntityEvent e)
- {
- int strength = getConfig().getInt("Zombies-SetStrength");
- if ((e.getDamager() instanceof Zombie))
- e.setDamage(strength);
- }
- @EventHandler
- public void onZombieHitPlayer(EntityDamageByEntityEvent e) {
- int poison = getConfig().getInt("PoisonEffect");
- int nausea = getConfig().getInt("NauseaEffect");
- int blindness = getConfig().getInt("BlindnessEffect");
- int saturation = getConfig().getInt("SaturationEffect");
- int harm = getConfig().getInt("HarmEffect");
- int slowness = getConfig().getInt("SlownessEffect");
- int weakness = getConfig().getInt("WeaknessEffect");
- int increasedamage = getConfig().getInt("IncreaseDamageEffect");
- if (((e.getDamager() instanceof Zombie)) && ((e.getEntity() instanceof Player))) {
- ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, slowness, 1));
- ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.POISON, poison, 1));
- ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, nausea, 5));
- ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindness, 1));
- ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, saturation, 1));
- ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.HARM, harm, 1));
- ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, weakness, 1));
- ((LivingEntity) e.getEntity()).addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, increasedamage, 1));
- }
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
- {
- if (cmd.getName().equalsIgnoreCase("twd-reload") || (cmd.getName().equalsIgnoreCase("thewalkingdead-reload")))
- {
- if (sender instanceof Player)
- {
- Player player = (Player) sender;
- if (player.hasPermission("thewalkingdead.reload"))
- {
- player.sendMessage(ChatColor.GREEN + ("TheWalkingDead config was successful reloaded!"));
- this.reloadConfig();
- }
- else
- {
- player.sendMessage(ChatColor.RED + ("You don't have the permission to do that"));
- }
- }
- else if (sender instanceof ConsoleCommandSender)
- {
- ConsoleCommandSender console = (ConsoleCommandSender) sender;
- this.reloadConfig();
- console.sendMessage(ChatColor.GREEN + ("TheWalkingDead config was successful reloaded!"));
- }
- }
- else if (cmd.getName().equalsIgnoreCase("twd-version") || (cmd.getName().equalsIgnoreCase("thewalkingdead-version")))
- {
- if (sender instanceof Player)
- {
- Player player = (Player) sender;
- if (player.hasPermission("thewalkingdead.version"))
- {
- player.sendMessage(ChatColor.GREEN + ("Current Version Using: " + getDescription().getVersion()));
- }
- else
- {
- player.sendMessage(ChatColor.RED + ("You don't have the permission to do that"));
- }
- }
- else if (sender instanceof ConsoleCommandSender)
- {
- ConsoleCommandSender console = (ConsoleCommandSender) sender;
- console.sendMessage(ChatColor.GREEN + ("Current Version Using: " + getDescription().getVersion()));
- }
- }
- else if (cmd.getName().equalsIgnoreCase("twd") || (cmd.getName().equalsIgnoreCase("thewalkingdead")))
- {
- if (sender instanceof Player)
- {
- Player player = (Player) sender;
- if (player.hasPermission("thewalkingdead.use"))
- {
- player.sendMessage(ChatColor.RED + (" ------[") + ChatColor.WHITE + (" The Walking Dead ") + ChatColor.RED + ("]------"));
- player.sendMessage(ChatColor.RED + (" Author:") + ChatColor.GRAY + (" Nosma_Stew "));
- player.sendMessage(ChatColor.RED + (" Version:") + ChatColor.GRAY + (" ") + getDescription().getVersion());
- player.sendMessage(ChatColor.RED + (" Aliases:") + ChatColor.GRAY + (" /twd, /thewalkingdead "));
- player.sendMessage(ChatColor.RED + (" Commands:"));
- player.sendMessage(ChatColor.RED + (" - ") + ChatColor.GRAY + ("/twd-reload - Reloads The Config."));
- player.sendMessage(ChatColor.RED + (" - ") + ChatColor.GRAY + ("/twd-version - Current Version Using."));
- }
- else
- {
- player.sendMessage(ChatColor.RED + ("You don't have the permission to do that"));
- }
- }
- else if (sender instanceof ConsoleCommandSender)
- {
- ConsoleCommandSender console = (ConsoleCommandSender) sender;
- console.sendMessage(ChatColor.RED + (" ------[") + ChatColor.WHITE + (" The Walking Dead ") + ChatColor.RED + ("]------"));
- console.sendMessage(ChatColor.RED + (" Author:") + ChatColor.GRAY + (" Nosma_Stew "));
- console.sendMessage(ChatColor.RED + (" Version:") + ChatColor.GRAY + (" ") + getDescription().getVersion());
- console.sendMessage(ChatColor.RED + (" Aliases:") + ChatColor.GRAY + (" /twd, /thewalkingdead "));
- console.sendMessage(ChatColor.RED + (" Commands:"));
- console.sendMessage(ChatColor.RED + (" - ") + ChatColor.GRAY + ("/twd-reload - Reloads The Config."));
- console.sendMessage(ChatColor.RED + (" - ") + ChatColor.GRAY + ("/twd-version - Current Version Using."));
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement