Beispiel #1
0
  // handle sign click
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onSignClick(PlayerInteractEvent e) {
    if (e.getAction() != Action.RIGHT_CLICK_BLOCK) {
      return;
    }
    if (!(e.getClickedBlock().getState() instanceof Sign)) {
      return;
    }
    Sign sign = (Sign) e.getClickedBlock().getState();
    Player player = e.getPlayer();
    if (sign.getLine(0).equalsIgnoreCase(ChatColor.BLUE + "[TNTRun]")) {
      if (!player.hasPermission("tntrun.game")) {
        player.sendMessage("You don't have permission to do this");
        e.setCancelled(true);
        return;
      }

      if (sign.getLine(1).equalsIgnoreCase("[join]") && sign.getLine(2) != null) {
        joinsign.handleClick(e);
      } else if (sign.getLine(1).equalsIgnoreCase("[leave]")) {
        leavesign.handleClick(e);
      } else if (sign.getLine(1).equalsIgnoreCase("[vote]")) {
        votesign.handleClick(e);
      }
    }
  }
  /* (non-Javadoc)
   * @see org.bukkit.event.player.PlayerListener#onPlayerInteract(org.bukkit.event.player.PlayerInteractEvent)
   */
  @Override
  public void onPlayerInteract(PlayerInteractEvent event) {
    Block clicked = event.getClickedBlock();
    Player player = event.getPlayer();

    if (clicked != null
        && (clicked.getType() == Material.STONE_BUTTON || clicked.getType() == Material.LEVER)) {
      if (!this.ButtonLeverHit(player, clicked, null)) {
        event.setCancelled(true);
      }
    } else if (clicked != null && clicked.getType() == Material.WALL_SIGN) {
      Stargate stargate = StargateManager.getGateFromBlock(clicked);

      if (stargate != null) {
        if (WXPermissions.checkWXPermissions(player, stargate, PermissionType.SIGN)) {
          if (stargate.TryClickTeleportSign(clicked)) {
            String target = "";
            if (stargate.SignTarget != null) {
              target = stargate.SignTarget.Name;
            }
            player.sendMessage("Dialer set to: " + target);
          }
        } else {
          player.sendMessage(ConfigManager.output_strings.get(StringTypes.PERMISSION_NO));
          event.setCancelled(true);
        }
      }
    }
  }
  /**
   * Event - onBlockRightClick - If a player right clicks a block check their permissions and set a
   * Coordinate.
   */
  @Override
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.isCancelled()) {
      return;
    }

    Player player = event.getPlayer();

    if (player.getItemInHand().getTypeId() == this.plugin.configMV.getInt("setwand", 270)
        && MultiVerse.Permissions.has(player, "multiverse.portal.create")) {
      String[] whitelist = this.plugin.configMV.getString("portalblocks", "").split(",");
      if (whitelist.length > 0 && whitelist[0] != "") {
        for (String element : whitelist) {
          int w = Integer.valueOf(element);
          if (w != event.getClickedBlock().getTypeId()) {
            return;
          }
        }
      }
      Location l = event.getClickedBlock().getLocation();
      if (this.plugin.playerSessions.get(player.getName()).compareLocation2(l)) {
        return;
      }
      this.plugin.playerSessions.get(player.getName()).setLocation2(l);
      player.sendMessage("Position 2 - Set");
    }
  }
Beispiel #4
0
  public void onPlayerInteract(PlayerInteractEvent ev) {

    Player player = ev.getPlayer();
    World world = player.getWorld();
    Location playerLoc = player.getLocation();
    ItemStack arrow = new ItemStack(Material.ARROW, 5);

    if (ev.getAction() == Action.LEFT_CLICK_AIR) {
      if (player.getItemInHand().getType() == Material.BOOK) {
        if (player.hasPermission("s.shotgun") || player.isOp()) {
          player.shootArrow();
          player.shootArrow();
          player.shootArrow();
          player.shootArrow();
          player.shootArrow();
          world.playEffect(playerLoc, Effect.BOW_FIRE, 50);
          world.createExplosion(playerLoc, -1);
          world.createExplosion(playerLoc, -1);
          world.playEffect(playerLoc, Effect.SMOKE, 105);

          player.getInventory().removeItem(arrow);
        }
      }
    }
  }
	@EventHandler(priority = EventPriority.HIGHEST)
	public void onPlayerInteract(PlayerInteractEvent e) {
		SpleefPlayer player = HeavySpleef.getInstance().getSpleefPlayer(e.getPlayer());
		Block block = e.getClickedBlock();

		if (player == null)
			return;
		if (block == null)
			return;
		if (!player.isActive())
			return;
		if (e.getAction() != Action.LEFT_CLICK_BLOCK)
			return;

		Game game = player.getGame();
		if (!game.canSpleef(player, block.getLocation()))
			return;

		if (game.getFlag(FlagType.BOWSPLEEF) || game.getFlag(FlagType.SPLEGG))
			return;

		if (game.getFlag(FlagType.BLOCKBREAKEFFECT)) {
			block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
		}

		block.setType(Material.AIR);
		player.addBrokenBlock(block);
	}
  public static void signClick(PlayerInteractEvent event, PlayerHolder am) {
    /// Get our sign
    final Sign sign = (Sign) event.getClickedBlock().getState();
    /// Check to see if sign has correct format (is more efficient than doing string manipulation )
    if (!sign.getLine(0).matches("^.[0-9a-fA-F]\\*.*$") && !sign.getLine(0).matches("^\\[.*$")) {
      return;
    }

    final Action action = event.getAction();
    if (action != Action.LEFT_CLICK_BLOCK && action != Action.RIGHT_CLICK_BLOCK) {
      return;
    }
    if (action == Action.LEFT_CLICK_BLOCK) { // / Dont let them break the sign
      event.setCancelled(true);
    }

    final ArenaClass ac =
        ArenaClassController.getClass(
            MessageUtil.decolorChat(sign.getLine(0))
                .replace('*', ' ')
                .replace('[', ' ')
                .replace(']', ' ')
                .trim());
    ArenaClassController.changeClass(event.getPlayer(), am, ac);
  }
  @EventHandler
  public void onPlayerInteract(PlayerInteractEvent e) {
    Player p = e.getPlayer();
    if (p.getItemInHand().getType() == Material.EYE_OF_ENDER
        && p.getItemInHand().getDurability() == 1) {
      Action a = e.getAction();
      if ((a == Action.RIGHT_CLICK_AIR) || (a == Action.RIGHT_CLICK_BLOCK)) {
        try {
          if (p.getInventory().getHelmet().getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)
              == 7) {
            if (p.getInventory()
                    .getChestplate()
                    .getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)
                == 7) {
              if (p.getInventory()
                      .getLeggings()
                      .getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)
                  == 7) {
                if (p.getInventory()
                        .getBoots()
                        .getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)
                    == 7) {
                  p.launchProjectile(EnderPearl.class);
                }
              }
            }
          } else if (p.getInventory().getChestplate() != null) {
            if (p.getInventory().getChestplate().hasItemMeta()) {
              if (p.getInventory().getChestplate().getItemMeta().hasDisplayName()) {
                if (p.getInventory()
                    .getChestplate()
                    .getItemMeta()
                    .getDisplayName()
                    .equalsIgnoreCase(
                        ChatColor.BLUE
                            + ""
                            + ChatColor.BOLD
                            + "Uber"
                            + ChatColor.GOLD
                            + ""
                            + ChatColor.BOLD
                            + "Chestplate")) {
                  if (p.getInventory()
                      .getChestplate()
                      .getItemMeta()
                      .getLore()
                      .contains(ChatColor.GRAY + "Ender Fake")) {
                    p.launchProjectile(EnderPearl.class);
                  }
                }
              }
            }
          }
        } catch (Exception x) {

        }
        e.setCancelled(true);
      }
    }
  }
 @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
 public void onPlayerInteract(PlayerInteractEvent event) {
   Player player = event.getPlayer();
   Block block = event.getClickedBlock();
   if (player.getItemInHand().getType() == Material.STICK) {
     select(player, event);
   }
   /*if(player.getItemInHand().getType() == Material.STICK && player.getItemInHand().hasItemMeta()){
   	if(player.getItemInHand().getItemMeta().getDisplayName().contains(Tools.SelectionTool)){
   		select(player, event);
   	}else if(player.getItemInHand().getItemMeta().getDisplayName().contains(Tools.InfoTool)){
   		info(player, block, event);
   	}
   }*/
   if (block == null) {
     return;
   }
   if (event.getAction() != Action.LEFT_CLICK_BLOCK
       && event.getAction() != Action.RIGHT_CLICK_BLOCK) {
     pressure(player, block, event);
     return;
   }
   if (event.isCancelled()) {
     return;
   }
   if (player.getItemInHand().getType() == Material.ARMOR_STAND) {
     armorStand(player, block, event);
   }
   interact(player, block, event);
 }
 @EventHandler
 public void onInteract(PlayerInteractEvent pie) {
   if (pie.getAction().equals(Action.RIGHT_CLICK_BLOCK)
       || pie.getAction().equals(Action.RIGHT_CLICK_AIR)) {
     Player player = pie.getPlayer();
     World world = player.getWorld();
     if (player.getInventory().getItemInHand() != null) {
       ItemStack item = player.getInventory().getItemInHand();
       if (item.getType().equals(Material.DOUBLE_PLANT)) {
         pie.setCancelled(true);
         Item bomb = world.dropItem(player.getEyeLocation(), new ItemStack(Material.GOLD_BLOCK));
         bomb.setPickupDelay(Integer.MAX_VALUE);
         bomb.setVelocity(player.getLocation().getDirection().multiply(0.5));
         double radius = 1.5;
         for (double i = 0; i <= 20D; i += 0.1) {
           Item coin = world.dropItem(bomb.getLocation(), new ItemStack(Material.DOUBLE_PLANT));
           double x = Math.sin(radius * i);
           double z = Math.cos(radius * i);
           Bukkit.getScheduler()
               .scheduleSyncDelayedTask(
                   Factions.instance,
                   new Runnable() {
                     public void run() {}
                   },
                   1);
         }
       }
     }
   }
 }
  @Override
  public void leftClickBIM(PlayerInteractEvent event) {

    event.setCancelled(true);

    Block clicked = event.getClickedBlock();
    Player p = event.getPlayer();

    boolean isOwnBomb = Core.getBIMStore().isBIMOwner(p, clicked);
    if (isOwnBomb) {
      boolean inactiv = Core.getBIMStore().isBIMInactiv(clicked);
      boolean activ = Core.getBIMStore().isBIMActiv(clicked);

      if (inactiv) {
        if (isResetedBomb(clicked)) {
          Core.getBIMStore().BIMbreak(event);
          return;
        }
        resetBomb(clicked);
        p.sendMessage("Bomb: reseted");
      }
      if (activ) {
        Core.getBIMStore().deactivateBIM(clicked);
        p.sendMessage("Bomb deactivated!");
      }
    } else {
      p.sendMessage("Not your Bomb!");
    }
  }
  @Override
  public void leftClickAir(PlayerInteractEvent event) {
    event.setCancelled(true);

    Player p = event.getPlayer();
    ItemStack item = p.getItemInHand();

    boolean isOwnBomb = Core.getBIMStore().isBIMOwner(p, item);
    if (isOwnBomb) {
      boolean inactiv = Core.getBIMStore().isBIMInactiv(item);
      boolean activ = Core.getBIMStore().isBIMActiv(item);

      if (inactiv) {

        resetBomb(item);
        p.sendMessage("Bomb reseted");
      }
      if (activ) {
        Core.getBIMStore().deactivateBIM(item);
        p.sendMessage("Bomb deactivated!");
      }
    } else {
      p.sendMessage("Not your Bomb!");
    }
  }
  @EventHandler(priority = EventPriority.NORMAL)
  public void togglePlayerStacker(PlayerInteractEvent event) {
    // Do nothing if player is not right clicking.
    Action action = event.getAction();
    if (action != RIGHT_CLICK_AIR && action != RIGHT_CLICK_BLOCK) return;

    // Do nothing if player does not have permission.
    Player player = event.getPlayer();
    if (!Perm.PLAYERSTACKER.has(player)) return;

    // Do nothing if player is not clicking the player hider item.
    if (!player.getItemInHand().equals(plugin.getSettings().getPlayerStackerItemDisabled())
        && !player.getItemInHand().equals(plugin.getSettings().getPlayerStackerItemEnabled()))
      return;

    // Do nothing if user is null.
    User user = plugin.getUser(player.getUniqueId());
    if (user == null) return;

    // Toggle users stacking option.
    user.setStacking(!user.isStacking());

    // Update players inventory with the newer player hider item.
    if (plugin.getSettings().getPlayerStackerSlot() >= 0) {
      ItemStack reverse =
          player.getItemInHand().equals(plugin.getSettings().getPlayerStackerItemEnabled())
              ? plugin.getSettings().getPlayerStackerItemDisabled()
              : plugin.getSettings().getPlayerStackerItemEnabled();
      player.getInventory().setItem(plugin.getSettings().getPlayerStackerSlot(), reverse);
      player.updateInventory();
    }

    // Play a clicking sound.
    player.playSound(player.getLocation(), Sound.CLICK, 2.0F, 1.0F);
  }
 @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 public void onPlayerInteract(PlayerInteractEvent event) {
   if (event.getClickedBlock() != null
       && event.getClickedBlock().getState() instanceof InventoryHolder) {
     addToCheck(event.getClickedBlock(), event.getClickedBlock().getState());
   }
 }
Beispiel #14
0
  // ================================================================================================
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
      if (plugin.posIsWithinColdBiome(
          event.getPlayer().getTargetBlock(null, 5).getX(),
          event.getPlayer().getTargetBlock(null, 5).getZ())) {
        Block targetedBlock =
            event
                .getPlayer()
                .getTargetBlock(
                    null,
                    5); // first arg is transparent block, second arg is maxDistance to scan. 5 is
                        // default reach for players.

        if ((null != targetedBlock) && (targetedBlock.getType() == Material.FIRE)) {
          // check if player is about to extinguish a registered fire with his hands or a tool (and
          // not a Block)
          if (plugin.blockIsRegisteredFire(
              targetedBlock.getX(), targetedBlock.getY(), targetedBlock.getZ())) {
            plugin.removeDiedFireFromFireList(
                targetedBlock.getX(), targetedBlock.getY(), targetedBlock.getZ());
            if (Arctica.debug) {
              event.getPlayer().sendMessage(ChatColor.AQUA + "Feuerstelle aus Liste geloescht!");
            }
          }
        }
      }
    }
  }
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.isCancelled()) return;

    if (event.getAction() == org.bukkit.event.block.Action.LEFT_CLICK_BLOCK
        || event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK) {
      PlayerEvent playerEvent;
      if (SignUtil.isSign(event.getClickedBlock())) {
        playerEvent =
            new PlayerEvent(
                SignUtil.getSign(event.getClickedBlock()),
                event.getAction() == Action.LEFT_CLICK_BLOCK
                    ? PlayerEvent.Action.LEFT_CLICK
                    : PlayerEvent.Action.RIGHT_CLICK,
                event.getPlayer(),
                event);
      } else {
        playerEvent =
            new PlayerEvent(
                event.getClickedBlock(),
                event.getAction() == Action.LEFT_CLICK_BLOCK
                    ? PlayerEvent.Action.LEFT_CLICK
                    : PlayerEvent.Action.RIGHT_CLICK,
                event.getPlayer(),
                event);
      }
      mechanicsHandler.callPlayerEvent(playerEvent);
    }
  }
  private void initCreation(PlayerInteractEvent event, SafeCityPlayer scPlayer, SafeCityZone zone) {
    if (zone == null & scPlayer.getZoneManager().getSubZoneCreationParent() == null) {
      scPlayer.getZoneManager().setIsCreatingZone(true);
      scPlayer
          .getZoneManager()
          .setNewZoneLocation1(context.toThinLocation(event.getClickedBlock().getLocation()));

      // createPrimaryZone(event, scPlayer);
    } else {
      // first click of sub-zone creation
      if (!scPlayer.getZoneManager().isCreatingSubZone()) {
        scPlayer.getZoneManager().setIsCreatingSubZone(true);
        scPlayer.getZoneManager().setSubZoneCreationParent(zone);

        scPlayer.getBukkitPlayer().sendMessage(context.getMessageHandler().Zone_Sub_Creating());

        scPlayer
            .getZoneManager()
            .setNewZoneLocation1(context.toThinLocation(event.getClickedBlock().getLocation()));

        return;
      } else // second click
      {
        createSubZone(scPlayer, event, zone);
      }
    }

    scPlayer.getZoneManager().clearCreationData();
    scPlayer.startCoolDown(2L);
  }
  @EventHandler(priority = EventPriority.HIGH)
  public void onPlayerInteract(org.bukkit.event.player.PlayerInteractEvent event) {
    Player p = event.getPlayer();
    if (event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
      if (p.getItemInHand().getType() == Material.EYE_OF_ENDER) {

        for (Player other : Bukkit.getServer().getOnlinePlayers()) {
          other.hidePlayer(p);
          p.hidePlayer(other);

          Inventory inventory = p.getInventory();
          inventory.setItem(8, new ItemStack(Material.ENDER_PEARL, 1));
        }

      } else if (p.getItemInHand().getType() == Material.ENDER_PEARL) {
        for (Player other : Bukkit.getServer().getOnlinePlayers()) {
          other.showPlayer(p);
          p.showPlayer(other);
          Inventory inventory = p.getInventory();
          inventory.setItem(8, new ItemStack(Material.EYE_OF_ENDER, 1));
        }
      } else if (p.getItemInHand().getType() == Material.GOLD_AXE) {
        p.launchProjectile(EnderPearl.class);
      }
    } else {

    }
  }
  @EventHandler
  public void onPlayerInteract(PlayerInteractEvent e) {
    Player p = e.getPlayer();

    if (e.getAction() != Action.RIGHT_CLICK_BLOCK || p.getItemInHand().getType() != sc.getTool()) {
      return;
    }

    Block block = e.getClickedBlock();

    if (block.getType() != Material.MOB_SPAWNER) {
      return;
    }

    CreatureSpawner cs = (CreatureSpawner) block.getState();
    Spawner s = sc.getSpawner(block.getLocation());

    if (s == null) {
      return;
    }

    if (s.getOwner().equals(p.getName()) || p.hasPermission("sc.bypass")) {
      EntityType currentMob = cs.getSpawnedType();
      ActiveList<EntityType> al = sc.buildAllowed(p);

      if (al.isEmpty()) {
        p.sendMessage(sc.getMsg("NO_PERMISSION_SET"));
        return;
      }

      if (al.contains(currentMob)) {
        al.setActive(currentMob);
      }

      al.setActive(al.next());
      s.setMobType(al.getActive());
      s.setDate(new Date());
      cs.setSpawnedType(al.getActive());
      cs.update();

      if (s.getOwner().equals(p.getName()) && currentMob != al.getActive()) {
        p.sendMessage(
            String.format(
                sc.getMsg("CHANGED_MONSTER"), currentMob.getName(), al.getActive().getName()));
      } else {
        p.sendMessage(
            String.format(
                sc.getMsg("CHANGED_MONSTER_OTHER"),
                s.getOwner(),
                currentMob.getName(),
                al.getActive().getName()));
      }

      sc.writeDataAsynchronously();
      return;
    }

    p.sendMessage(String.format(sc.getMsg("OWNER_IS"), s.getOwner()));
  }
Beispiel #19
0
  @Override
  public boolean onInteract(PlayerInteractEvent e, int level) {
    for (int i = 0; i < level; i++) {
      e.getPlayer().getWorld().spawnEntity(e.getPlayer().getLocation(), EntityType.OCELOT);
    }

    return true;
  }
 @Override
 public void onPlayerInteract(PlayerInteractEvent event) {
   if (event.getAction() == Action.RIGHT_CLICK_BLOCK
       || event.getAction() == Action.RIGHT_CLICK_AIR)
     if (event.getPlayer().getItemInHand().getType() == Material.SULPHUR)
       if (event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN).getType()
           == Material.LAPIS_BLOCK) Cannon.fire(event.getPlayer());
 }
Beispiel #21
0
		@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
		public void onPlayerInteract(final PlayerInteractEvent event)
		{
			final User user = ess.getUser(event.getPlayer());
			if (user.isJailed())
			{
				event.setCancelled(true);
			}
		}
  public void onPlayerInteract(PlayerInteractEvent event) {

    String eventplayer = event.getPlayer().getName();
    if (admin.freeze.contains(eventplayer)) {
      // cancel here
      event.setCancelled(true);
      event.getPlayer().sendMessage(ChatColor.RED + "Can't do that while frozen!");
    }
  }
Beispiel #23
0
 @Override
 public void onRightClick(PlayerInteractEvent event) {
   if (!plugin.getLocalConfiguration().cauldronSettings.enable) return;
   if (!BukkitUtil.toWorldVector(event.getClickedBlock()).equals(pt))
     return; // wth? our manager is insane
   if (event.getPlayer().getItemInHand().getTypeId() >= 255
       || event.getPlayer().getItemInHand().getType() == Material.AIR)
     preCauldron(event.getPlayer(), event.getPlayer().getWorld(), pt);
 }
Beispiel #24
0
  @EventHandler
  public void onTurretFire(PlayerInteractEvent e) {
    if (isInTurret(e.getPlayer())) {
      Player shooter = e.getPlayer();
      Turret t = getTurret(shooter);

      t.shoot();
    }
  }
Beispiel #25
0
  @Override
  public boolean onInteract(PlayerInteractEvent e, int level) {
    if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.COBBLESTONE) {
      e.getClickedBlock().setType(Material.STONE);

      return true;
    }
    return false;
  }
Beispiel #26
0
 @EventHandler
 public void onBlock(PlayerInteractEvent e) {
   Player p = e.getPlayer();
   if (p.getItemInHand().getType() == Material.SNOW_BALL) {
     e.setCancelled(true);
     p.updateInventory();
     onFrozen(e);
   }
 }
Beispiel #27
0
  @Override
  public boolean onInteract(PlayerInteractEvent e, int level) {
    e.getPlayer()
        .addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 20 * 60, 20 * level));

    e.getPlayer().sendMessage("Upped your fire resistance!");

    return true;
  }
  @EventHandler
  public void onPlayerInteract(PlayerInteractEvent arg0) {
    Player player = arg0.getPlayer();

    if (arg0.getItem().getType() == Material.STICK) {
      if (userMap.containsKey(player)) {
        player.performCommand(userMap.get(player));
      }
    }
  }
Beispiel #29
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onPlayerInteract(PlayerInteractEvent event) {
   Player player = event.getPlayer();
   if (event.getAction() == Action.LEFT_CLICK_BLOCK
       && player.getItemInHand().equals(Config.ToolBlock)
       && SessionManager.getSession(player).isUsingTool()) {
     ToolManager.toolSearch(player, event.getClickedBlock());
     event.setCancelled(true);
   }
 }
 @EventHandler(ignoreCancelled = true)
 public void onPlayerInteract(PlayerInteractEvent event) {
   if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_AIR) {
     return;
   }
   if (!event.getPlayer().hasPermission("permissions.build")) {
     bother(event.getPlayer());
     event.setCancelled(true);
   }
 }