SHARE
TWEET

Untitled

a guest Aug 23rd, 2019 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package us.hcrealms.hcf.listener.fixes;
  2.  
  3. import us.hcrealms.hcf.*;
  4. import net.minecraft.util.com.google.common.collect.*;
  5. import org.bukkit.event.block.*;
  6. import org.bukkit.inventory.*;
  7. import org.bukkit.block.*;
  8. import us.hcrealms.hcf.faction.type.*;
  9. import org.bukkit.entity.*;
  10. import org.bukkit.event.*;
  11. import org.bukkit.event.player.*;
  12. import org.bukkit.*;
  13.  
  14. public class PearlGlitchListener implements Listener
  15. {
  16.     private final ImmutableSet<Material> blockedPearlTypes;
  17.     private final Base plugin;
  18.     Location previous;
  19.    
  20.     public PearlGlitchListener(final Base plugin) {
  21.         this.blockedPearlTypes = (ImmutableSet<Material>)Sets.immutableEnumSet((Enum)Material.THIN_GLASS, (Enum[])new Material[] { Material.STEP, Material.IRON_FENCE, Material.FENCE, Material.NETHER_FENCE, Material.ACACIA_STAIRS, Material.BIRCH_WOOD_STAIRS, Material.BRICK_STAIRS, Material.COBBLESTONE_STAIRS, Material.DARK_OAK_STAIRS, Material.JUNGLE_WOOD_STAIRS, Material.NETHER_BRICK_STAIRS, Material.QUARTZ_STAIRS, Material.SANDSTONE_STAIRS, Material.SMOOTH_STAIRS, Material.SPRUCE_WOOD_STAIRS, Material.WOOD_STAIRS });
  22.         this.plugin = plugin;
  23.     }
  24.    
  25.     @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
  26.     public void onPlayerInteract(final PlayerInteractEvent event) {
  27.         if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) {
  28.             final Block block = event.getClickedBlock();
  29.             if (block.getType().isSolid() && !(block.getState() instanceof InventoryHolder)) {
  30.                 final Faction factionAt = Base.getPlugin().getFactionManager().getFactionAt(block.getLocation());
  31.                 if (!(factionAt instanceof ClaimableFaction)) {
  32.                     return;
  33.                 }
  34.                 event.setCancelled(false);
  35.                 final Player player = event.getPlayer();
  36.                 player.setItemInHand(event.getItem());
  37.             }
  38.         }
  39.     }
  40.    
  41.     @EventHandler
  42.     public void onCommand(final PlayerCommandPreprocessEvent e) {
  43.         if ((e.getMessage().startsWith("/minecraft:") || e.getMessage().startsWith("/bukkit:")) && !e.getPlayer().isOp()) {
  44.             e.setCancelled(true);
  45.         }
  46.     }
  47.    
  48.     @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  49.     public void disableCommand23(final PlayerCommandPreprocessEvent event) {
  50.         event.getPlayer();
  51.         final String message = event.getMessage().toLowerCase();
  52.         final String c = "/me";
  53.         if (message.equals(c) || message.startsWith(String.valueOf(c) + " ")) {
  54.             event.setCancelled(true);
  55.         }
  56.     }
  57.    
  58.     @EventHandler
  59.     public void onPlayerTeleport(final PlayerTeleportEvent e) {
  60.         final Player p = e.getPlayer();
  61.         if (e.isCancelled() || e.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
  62.             return;
  63.         }
  64.         e.getTo();
  65.         if (e.getTo().getBlock().getType() == Material.FENCE_GATE) {
  66.             p.sendMessage(ChatColor.RED + "Invalid Pearl! Please try again");
  67.             this.plugin.getTimerManager().enderPearlTimer.refund(p);
  68.             e.setCancelled(true);
  69.         }
  70.         final Location target = e.getTo();
  71.         target.setX(target.getBlockX() + 0.5);
  72.         target.setZ(target.getBlockZ() + 0.5);
  73.         e.setTo(target);
  74.     }
  75.    
  76.     @EventHandler
  77.     public void onMove(final PlayerInteractEvent e) {
  78.         if (e.getPlayer().getLocation().getBlock() != null && e.getPlayer().getLocation().getBlock().getType() == Material.TRAP_DOOR && !Base.getPlugin().getFactionManager().getFactionAt(e.getPlayer().getLocation()).equals(Base.getPlugin().getFactionManager().getPlayerFaction(e.getPlayer().getUniqueId()))) {
  79.             e.getPlayer().teleport(e.getPlayer().getLocation().add(0.0, 1.0, 0.0));
  80.         }
  81.     }
  82. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top