Advertisement
kman2010

Untitled

May 17th, 2011
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. package me.GoldEnchantTeam.GoldEnchant;
  2.  
  3. import org.bukkit.Material;
  4. import org.bukkit.entity.Player;
  5. import org.bukkit.event.entity.EntityDamageEvent;
  6. import org.bukkit.event.entity.EntityListener;
  7. import org.bukkit.inventory.ItemStack;
  8.  
  9. public class GoldEnchantEntityListener extends EntityListener
  10. {
  11.   public static GoldEnchant plugin;
  12.   private final Timer timer = new Timer();
  13.  
  14.   public GoldEnchantEntityListener(GoldEnchant instance)
  15.   {
  16.     plugin = instance;
  17.   }
  18.  
  19.   public void onEntityDamage(EntityDamageEvent event) {
  20.     if (!(event.getEntity() instanceof Player)) return;
  21.     Player eventPlayer = (Player)event.getEntity();
  22.  
  23.     if (eventPlayer.getInventory().getChestplate().getType().equals(Material.CHAINMAIL_CHESTPLATE)) {
  24.       eventPlayer.setHealth(20);
  25.       event.setCancelled(true);
  26.       if (eventPlayer.getInventory().getChestplate().getDurability() == 96) {
  27.         timer.scheduleAtFixedRate(new StopGodMode(eventPlayer.getInventory().getChestplate()), 0, 30000 / 96L);
  28.       }
  29.     }
  30.   }
  31.  
  32.   private class StopGodMode {
  33.     private ItemStack p;
  34.     public StopGodMode(ItemStack p) {
  35.       this.p = p;
  36.     }
  37.     public void run() {
  38.       if (p == null) {
  39.         this.cancel();
  40.         return;
  41.       }
  42.       else if (p.getDurability() <= 1) {
  43.         p = null;
  44.         this.cancel();
  45.         return;
  46.       }
  47.       p.setDurability((short) (p.getDurability() - 1));
  48.     }
  49.     private void cancel() {
  50.         // TODO Auto-generated method stub
  51.        
  52.     }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement