Laloth

LalothCMD PLAYERLISTNER 8/8/12 9:30 PM

Jul 27th, 2012
57
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.Laloth.Main;
  2.  
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.Material;
  5. import org.bukkit.block.Block;
  6. import org.bukkit.event.EventHandler;
  7. import org.bukkit.event.EventPriority;
  8. import org.bukkit.event.Listener;
  9. import org.bukkit.event.player.AsyncPlayerChatEvent;
  10. import org.bukkit.event.player.PlayerInteractEvent;
  11. import org.bukkit.event.player.PlayerMoveEvent;
  12. import org.bukkit.entity.Player;
  13. import org.bukkit.event.block.Action;
  14. import org.bukkit.event.block.BlockPlaceEvent;
  15. import org.bukkit.event.entity.EntityDamageEvent;
  16. import org.bukkit.event.inventory.CraftItemEvent;
  17. import org.bukkit.inventory.ItemStack;
  18.  
  19. public class PlayerListener implements Listener {
  20.  
  21.     public Main plugin;
  22.  
  23.     public PlayerListener(Main instance) {
  24.         plugin = instance;
  25.  
  26.     }
  27.  
  28.     @EventHandler(priority = EventPriority.HIGHEST)
  29.     public void onPlayerchat(AsyncPlayerChatEvent e) {
  30.         if (plugin.mute.contains(e.getPlayer().getName())) {
  31.             e.setCancelled(true);
  32.             e.getPlayer().sendMessage(ChatColor.RED + "You have been mutted!");
  33.         }
  34.     }
  35.  
  36.     @EventHandler(priority = EventPriority.HIGHEST)
  37.     public void onPlayerMove(PlayerMoveEvent e) {
  38.         if (plugin.freeze.contains(e.getPlayer().getName())) {
  39.             e.getPlayer().teleport(e.getPlayer().getLocation());
  40.             e.getPlayer().sendMessage(ChatColor.RED + "You have been frozen!");
  41.         }
  42.     }
  43.  
  44.     @EventHandler(priority = EventPriority.HIGHEST)
  45.     public void onEntityDamage(EntityDamageEvent event) {
  46.         if ((event.getEntity() instanceof Player)
  47.                 && plugin.playerList.contains(event.getEntity())) {
  48.             event.setCancelled(true);
  49.             if (event.getEntity().getMaxFireTicks() > 1) {
  50.                 event.getEntity().setFireTicks(0);
  51.             }
  52.         }
  53.     }
  54.  
  55.     @EventHandler
  56.     public static void onPlayerPlaceBlock(BlockPlaceEvent event) {
  57.         Player player = event.getPlayer();
  58.         Block block = event.getBlockPlaced();
  59.         int id = block.getTypeId();
  60.         if (((id == 130) || (id == 0))
  61.                 && (!player.hasPermission("BlockEnderChest.PlaceEnderChest"))) {
  62.             player.sendMessage(ChatColor.RED + "You cannot Place EnderChest!");
  63.             event.setCancelled(true);
  64.         }
  65.     }
  66.  
  67.     @EventHandler
  68.     public void onPlayerCraft(CraftItemEvent event) {
  69.         ItemStack itm = event.getRecipe().getResult();
  70.         Player player = (Player) event.getView().getPlayer();
  71.         int id = itm.getTypeId();
  72.         if (((id == 130) || (id == 0))
  73.                 && (!player.hasPermission("BlockEnderChest.CreateEnderChest"))) {
  74.             player.sendMessage(ChatColor.RED + "You cannot Create EnderChest!");
  75.             event.setCancelled(true);
  76.         }
  77.     }
  78.  
  79.     @EventHandler
  80.     public void onPlayerInteract(PlayerInteractEvent event) {
  81.         Player player = event.getPlayer();
  82.         if ((event.getAction() == Action.RIGHT_CLICK_BLOCK)
  83.                 && (event.getClickedBlock().getType() == Material.ENDER_CHEST)) {
  84.             if (!player.hasPermission("BlockEnderChest.UseEnderChest")) {
  85.                 player.sendMessage(ChatColor.RED
  86.                         + "You cannot Access EnderChest!");
  87.                 event.setCancelled(true);
  88.             }
  89.         }
  90.     }
  91. }
RAW Paste Data