Guest User

EmptyBucket - EBPlayerListener.java

a guest
Jan 31st, 2011
101
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.bukkit.pandemic.EmptyBucket;
  2.  
  3. import org.bukkit.Material;
  4. import org.bukkit.entity.Player;
  5. import org.bukkit.event.player.PlayerChatEvent;
  6. import org.bukkit.event.player.PlayerListener;
  7.  
  8. public class EBPlayerListener extends PlayerListener {
  9.    
  10.     public EmptyBucket plugin;
  11.    
  12.     public EBPlayerListener(EmptyBucket _plugin) {
  13.         plugin = _plugin;
  14.     }
  15.  
  16.     public void onPlayerCommand(PlayerChatEvent event) {
  17.         if (event.getMessage().equalsIgnoreCase("/empty")) {
  18.             Player player = event.getPlayer();
  19.             if (player.getItemInHand().getType() == Material.WATER_BUCKET
  20.                     || player.getItemInHand().getType() == Material.LAVA_BUCKET) {
  21.                 player.getItemInHand().setType(Material.BUCKET);
  22.                 player.sendMessage("§6You have emptied your bucket!");
  23.             }
  24.         }
  25.         if (event.getMessage().equalsIgnoreCase("/empty all")) {
  26.             Player player = event.getPlayer();
  27.             for (int i = 0; i < player.getInventory().getSize(); i++) {
  28.                 if (player.getInventory().getItem(i).getType() == Material.WATER_BUCKET
  29.                     || player.getInventory().getItem(i).getType() == Material.LAVA_BUCKET) {
  30.                     player.getInventory().getItem(i).setType(Material.BUCKET);
  31.                 }
  32.             }
  33.             player.sendMessage("§6You have emptied all of your buckets!");
  34.         }
  35.     }
  36.    
  37. }
RAW Paste Data