@EventHandler
 public void onPlayerBlockInteract(PlayerInteractEvent event) {
   if (VAR.config.getBoolean("enableRules")) {
     if (!VAR.pLog
         .getString("players." + event.getPlayer().getName() + ".Has accepted rules")
         .equalsIgnoreCase("true")) {
       if (event.getAction().equals(Action.LEFT_CLICK_BLOCK)) return;
       String msg = VAR.config.getString("RulesNotAcceptedMsg");
       msg = ip.replace(msg, event.getPlayer());
       if (VAR.config.getString("PreventNotAccepted").toLowerCase().contains("chest")) {
         if (event.getClickedBlock().getTypeId() == 54) {
           event.getPlayer().sendMessage(msg);
           event.setCancelled(true);
           return;
         }
       }
       if (VAR.config.getString("PreventNotAccepted").toLowerCase().contains("redstone")) {
         int ID = event.getClickedBlock().getTypeId();
         if (ID == 69 || ID == 70 || ID == 72 || ID == 77) {
           event.getPlayer().sendMessage(msg);
           event.setCancelled(true);
           return;
         }
       }
     }
   }
 }
  @SuppressWarnings("deprecation")
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.isCancelled()) return;

    final Player player = event.getPlayer();
    final Block block = event.getClickedBlock();
    final ItemStack item = event.getItem();

    if (player.getWorld() != plugin.getIslandWorld()) return;
    if (player.isOp()) return;
    if (player.hasPermission("islandworld.bypass.island")) return;

    if (block != null) {
      final Material t = block.getType();

      plugin.debug("Interact with block: " + t.getId() + " : " + block);

      if (!(plugin.getConfig().getBoolean("flags.use-switches", false) && isSwitch(t))) {
        if (!(isOnAllowedList(t) || plugin.canBuildOnLocation(player, block.getLocation())))
          event.setCancelled(true);
      }
    } else {
      if (item != null) {
        plugin.debug("Using item: " + item.getTypeId());

        if (!(isOnAllowedList(item.getType())
            || plugin.canBuildOnLocation(player, player.getLocation()))) event.setCancelled(true);
      }
    }
    plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled());
  }
Exemplo n.º 3
0
  @Override
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.isCancelled()) {
      return;
    }

    Block block = event.getClickedBlock();
    Player player = event.getPlayer();

    if (block == null) {
      return; // clicked in air, apparently
    }

    if (!canPlayerUseBlock(player, block)) {
      event.setCancelled(true);
      return;
    }

    if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
      return; // only interested on right-clicks for below
    }

    if (!this.playerCanUseItemHere(player, block, event.getMaterial())) {
      event.setCancelled(true);
      return;
    }
  }
  /* (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);
        }
      }
    }
  }
Exemplo n.º 5
0
  @EventHandler
  public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();

    if (player.getItemInHand().getType() == plugin.getWorldEditSettings().getWandMaterial()) {
      PlayerSettings settings = plugin.getPlayerSettings(player);

      if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
        settings.setFirstPosition(event.getClickedBlock().getLocation());

        if (settings.getSelection() == null) {
          player.sendMessage("First position is set!");
        } else {
          player.sendMessage(
              "First position is set!(" + settings.getSelection().getBlocks().size() + " blocks)");
        }

        event.setCancelled(true);
      } else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        settings.setSecondPosition(event.getClickedBlock().getLocation());

        if (settings.getSelection() == null) {
          player.sendMessage("Second position is set!");
        } else {
          player.sendMessage(
              "Second position is set!(" + settings.getSelection().getBlocks().size() + " blocks)");
        }

        event.setCancelled(true);
      }
    }
  }
  @EventHandler(priority = EventPriority.NORMAL)
  public void onRightHandPlayerInteact(PlayerInteractEvent event) {
    if (event.isCancelled()) return;

    final Player player = event.getPlayer();

    if (player != null
        && (event.getAction() == Action.RIGHT_CLICK_BLOCK
            || event.getAction() == Action.RIGHT_CLICK_AIR)) {
      Location loc = player.getLocation();
      // If block is not null use block location, if null use player loc
      final Block block = event.getClickedBlock();
      if (block != null) loc = block.getLocation();

      if (player.getWorld() != plugin.getIslandWorld()) return;
      if (player.isOp()) return;
      if (player.hasPermission("islandworld.bypass.island")) return;

      if (player.getItemInHand().getType() == Material.MONSTER_EGG) {
        if (!(plugin.canBuildOnLocation(player, loc))) event.setCancelled(true);
      } else if (player.getItemInHand().getType() == Material.FIREBALL) {
        if (!plugin.canBuildOnLocation(player, loc)) event.setCancelled(true);
      }
    }
    plugin.debug("Evento :" + event.getEventName() + ", cancelled:" + event.isCancelled());
  }
 /**
  * Called when a player clicks on anything.
  *
  * @param event The Interact event.
  */
 @EventHandler
 public void playerInteract(PlayerInteractEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
     if (event.getClickedBlock().getState() instanceof Sign) {
       this.plugin.log(Level.FINER, "Found a Sign!");
       Sign s = (Sign) event.getClickedBlock().getState();
       SignStatus status = this.pd.getSignStatus(s);
       if (status == SignStatus.SignPortal) {
         String destString = this.pd.processSign(s);
         this.takePlayerToDestination(event.getPlayer(), destString);
         event.setCancelled(true);
       } else if (status == SignStatus.Disabled) {
         this.pd.activateSignPortal(event.getPlayer(), ChatColor.RED + "Disabled", s);
         event.setCancelled(true);
       } else if (status == SignStatus.Legacy) {
         this.pd.activateSignPortal(event.getPlayer(), ChatColor.AQUA + "Legacy", s);
         event.setCancelled(true);
       } else if (status == SignStatus.NetherPortalSign) {
         event.setCancelled(true);
       }
     }
   }
 }
Exemplo n.º 8
0
  @EventHandler(priority = EventPriority.LOW)
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event == null) return;
    if (event.getPlayer() == null) event.setCancelled(true);

    if (validateAuthorizer(event.getPlayer())) event.setCancelled(true);
    else if (validateClickAuth(event.getPlayer(), event.getAction())) event.setCancelled(true);
  }
Exemplo n.º 9
0
  @EventHandler
  public void onPlayerAction(PlayerInteractEvent e) {
    Player player = e.getPlayer();
    if ((e.getAction() == Action.RIGHT_CLICK_AIR
        || (e.getAction() == Action.RIGHT_CLICK_BLOCK) && !e.isCancelled())) {
      ItemStack item = player.getItemInHand();
      if (item.getType() == Material.BOW
          || item.getType() == Material.SNOW_BALL
          || item.getType() == Material.EGG
          || item.getType() == Material.POTION) return;

      RPGItem rItem = ItemManager.toRPGItem(item);
      if (rItem == null) return;
      if (!WorldGuard.canPvP(player.getLocation()) && !rItem.ignoreWorldGuard) return;
      if (rItem.getHasPermission() == true
          && player.hasPermission(rItem.getPermission()) == false) {
        e.setCancelled(true);
        player.sendMessage(
            ChatColor.RED
                + String.format(
                    Locale.get("message.error.permission", Locale.getPlayerLocale(player))));
      }
      rItem.rightClick(player);
      if (player.getItemInHand().getTypeId() != 0) {
        RPGItem.updateItem(item, Locale.getPlayerLocale(player));
      } else player.setItemInHand(null);
      player.updateInventory();
    } else if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
      ItemStack item = player.getItemInHand();
      if (item.getType() == Material.BOW
          || item.getType() == Material.SNOW_BALL
          || item.getType() == Material.EGG
          || item.getType() == Material.POTION) return;

      RPGItem rItem = ItemManager.toRPGItem(item);
      if (rItem == null) return;
      if (!WorldGuard.canPvP(player.getLocation()) && !rItem.ignoreWorldGuard) return;
      if (rItem.getHasPermission() == true
          && player.hasPermission(rItem.getPermission()) == false) {
        e.setCancelled(true);
        player.sendMessage(
            ChatColor.RED
                + String.format(
                    Locale.get("message.error.permission", Locale.getPlayerLocale(player))));
      }
      rItem.leftClick(player);
      RPGItem.updateItem(item, Locale.getPlayerLocale(player));
    }
  }
Exemplo n.º 10
0
 @EventHandler
 public void stopArenaInteract(PlayerInteractEvent e) {
   if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
     Player p = e.getPlayer();
     if (BattleArena.inArena(p)) {
       e.setCancelled(true);
     }
     List<Player> inProgress = ma.getArenaMaster().getAllPlayers();
     for (Player p2 : inProgress) {
       if (p == p2) {
         e.setCancelled(true);
       }
     }
   }
 }
Exemplo n.º 11
0
  @SuppressWarnings("deprecation")
  @EventHandler
  public void onClickBeacon(PlayerInteractEvent event) {
    if (!RedstonePvP.config.isFeatureEnabled(RedstoneFeature.BEACON_DROPS)) {
      return;
    }
    Player ply = event.getPlayer();
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
      return;
    }
    if (event.getClickedBlock() == null) {
      return;
    }
    if (!(event.getClickedBlock().getState() instanceof Beacon)) {
      if (this.beaconSetters.contains(ply.getName())) {
        ply.sendMessage(this.config.getMessage("not-beacon"));
        this.beaconSetters.remove(ply.getName());
      }
      return;
    }
    Beacon beacon = (Beacon) event.getClickedBlock().getState();
    if (this.beaconSetters.contains(ply.getName())) {
      event.setCancelled(true);
      if (!this.config.isDropBeacon(beacon)) {
        this.config.setBeacon(beacon);
        ply.sendMessage(this.config.getMessage("beacon-set"));
      } else {
        ply.sendMessage(this.config.getMessage("already-set"));
      }
      this.beaconSetters.remove(ply.getName());

      return;
    }
    if (this.config.isDropBeacon(beacon)) {
      event.setCancelled(true);
      if (!this.canRun) {
        ply.sendMessage(this.config.getMessage("wait"));
        return;
      }
      if (Bukkit.getOnlinePlayers().length
          < this.config.getPlayerAmount()) // <-- you get an error ingame?
      {
        ply.sendMessage(this.config.getMessage("not-enough-players"));
        return;
      }
      runBeaconDrops(beacon);
    }
  }
	@EventHandler(priority = EventPriority.NORMAL)
	public void onPlayerInteract(final PlayerInteractEvent event)
	{
		final IUser user = userMap.getUser(event.getPlayer());
		user.updateActivity(true);
		switch (event.getAction())
		{
		case RIGHT_CLICK_BLOCK:
			if (event.isCancelled())
			{
				return;
			}

			final ISettings settings = ess.getSettings();
			if (settings.getData().getCommands().getHome().isUpdateBedAtDaytime() && event.getClickedBlock().getType() == Material.BED_BLOCK)
			{
				event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation());
			}
			break;
		case LEFT_CLICK_AIR:
		case LEFT_CLICK_BLOCK:
			if (user.getData().hasPowerTools() && user.getData().isPowerToolsEnabled())
			{
				if (usePowertools(user))
				{
					event.setCancelled(true);
				}
			}
			break;
		default:
			break;
		}
	}
Exemplo n.º 13
0
  @EventHandler(priority = EventPriority.HIGH)
  public void protectBlockStates(PlayerInteractEvent event) {
    Material[] blockedItems = {
      Material.NOTE_BLOCK,
      Material.REDSTONE_COMPARATOR_OFF,
      Material.REDSTONE_COMPARATOR_ON,
      Material.DIODE_BLOCK_OFF,
      Material.DIODE_BLOCK_ON,
      Material.FLOWER_POT,
      Material.CAKE_BLOCK,
      Material.DAYLIGHT_DETECTOR,
      Material.DAYLIGHT_DETECTOR_INVERTED
    };
    if (event.getClickedBlock() == null) {
      return;
    }
    Player p = event.getPlayer();
    // System.out.println(event.getClickedBlock().getType());
    if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
        && Arrays.asList(blockedItems).contains(event.getClickedBlock().getType())) {
      OwnedLand land = OwnedLand.getApplicableLand(event.getClickedBlock().getLocation());
      if (land == null) {
        return;
      }
      if (land.hasPermTo(p, this)) {
        return;
      }

      p.sendMessage(
          ChatColor.RED + getPlugin().getMessageConfig().getString("event.build.blockStateChange"));
      event.setCancelled(true);
    }
  }
Exemplo n.º 14
0
  @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!");
    }
  }
Exemplo n.º 15
0
  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);
  }
Exemplo n.º 16
0
 @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);
         }
       }
     }
   }
 }
Exemplo n.º 17
0
  @EventHandler
  public void onPlayerInteract(PlayerInteractEvent event) {
    int BLWand = getConfig().getInt("blocklog.wand");
    boolean WandEnabled = plugin.users.contains(event.getPlayer().getName());
    if (!event.isCancelled()) {
      if (event.getPlayer().getItemInHand().getTypeId() == BLWand && WandEnabled) {
        if ((event.getAction() == Action.RIGHT_CLICK_BLOCK
                && (!event.getPlayer().getItemInHand().getType().isBlock())
            || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
          Material type = event.getClickedBlock().getType();
          if (type == Material.WOODEN_DOOR
              || type == Material.TRAP_DOOR
              || type == Material.CHEST
              || type == Material.DISPENSER
              || type == Material.STONE_BUTTON
              || type == Material.LEVER)
            getBlockInteractions(
                event.getPlayer(), event.getClickedBlock(), Interaction.getByMaterial(type));
          else getBlockEdits(event.getPlayer(), event.getClickedBlock());

          event.setCancelled(true);
        }
      }
    }
  }
Exemplo n.º 18
0
  private boolean checkPermission(
      PlayerInteractEvent event,
      SafeCityPlayer scPlayer,
      SafeCityZone zone,
      SafeCitySubZone subZone) {
    // cannot create sub-zones within sub-zones.
    if (subZone != null) {
      scPlayer.getBukkitPlayer().sendMessage(context.getMessageHandler().Too_Many_Children());

      scPlayer.getZoneManager().clearCreationData();
      scPlayer.startCoolDown(2L);

      event.setCancelled(true);
      return false;
    }

    // is using the 3D tool outside a main zone.
    if (zone == null
        && scPlayer.getBukkitPlayer().getItemInHand().getType()
            == SafeCityTool.ZoneTool3d.material()) {
      scPlayer.getZoneManager().clearCreationData();
      scPlayer.startCoolDown(2L);

      scPlayer
          .getBukkitPlayer()
          .sendMessage(context.getMessageHandler().Create_3DZone_InPrimary_Only());
      return false;
    }

    // check permission
    if (zone != null) {
      for (ZonePermissionType p : ZonePermissionType.values()) {
        // if (zone.hasPermission(scPlayer.getBukkitPlayer().getName(), p))
        if (zone.hasPermission(scPlayer.getBukkitPlayer().getName(), p)) {
          if (p.getPermissions().canCreateSubZones()) {
            return true;
          }
        }
      }

      if (context
          .getBukkitPermissions()
          .has(
              (World) null,
              scPlayer.getBukkitPlayer().getName(),
              PluginPermission.Staff_Override.permissionNode())) {
        scPlayer.getBukkitPlayer().sendMessage(ChatColor.RED + ">>** Staff Override");
        return true;
      }

      scPlayer.getZoneManager().clearCreationData();
      scPlayer.startCoolDown(2L);

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

      return false;
    }

    return true;
  }
  @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);
      }
    }
  }
Exemplo n.º 20
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);
      }
    }
  }
  @EventHandler
  public void onPlayerClickTool(PlayerInteractEvent event) {
    Location location = null;

    try {
      Block clicked = event.getClickedBlock();

      if ((clicked != null) && (event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
        Block relative = clicked.getRelative(event.getBlockFace());
        location = relative.getLocation();
      } else {
        BlockIterator iterator = new BlockIterator(event.getPlayer(), 16);
        Block target = null;

        while (iterator.hasNext()) {
          Block block = iterator.next();
          if (block.getType() != Material.AIR) {
            target = iterator.next();
            break;
          }
        }

        if (target != null) location = target.getLocation();
      }
    } catch (Exception e) {

    }

    if (setBlock(event.getPlayer(), event.getPlayer().getItemInHand(), location)) {
      event.setCancelled(true);
    }
  }
Exemplo n.º 22
0
  @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!");
    }
  }
Exemplo n.º 23
0
  @EventHandler
  public void throwSnowball(PlayerInteractEvent e) {
    final Player p = e.getPlayer();
    if (UtilBlock.usable(e.getClickedBlock())) {
      return;
    }
    if (e.getPlayer().getItemInHand() == null) {
      return;
    }
    if (e.getPlayer().getItemInHand().getType() != Material.FIREWORK_CHARGE) {
      return;
    }
    if (_coolDown.contains(p.getUniqueId())) {
      return;
    }
    if (((e.getAction() == Action.RIGHT_CLICK_AIR) || (e.getAction() == Action.RIGHT_CLICK_BLOCK))
        && (disName(p.getItemInHand()) != null)
        && (disName(p.getItemInHand())
            .equalsIgnoreCase(
                ChatColor.DARK_AQUA
                    + "EnderDoge "
                    + ChatColor.DARK_RED
                    + EnderDogeAmmoManager.balaceEnderDogeAmmo(p)))) {
      Player player = e.getPlayer();
      e.setCancelled(true);

      _coolDown.add(p.getUniqueId());
      Bukkit.getScheduler()
          .runTaskLater(
              Main.getInstance(),
              new Runnable() {
                public void run() {
                  _coolDown.remove(p.getUniqueId());
                }
              },
              5L);
      Projectile proj = player.launchProjectile(Snowball.class);
      proj.setVelocity(proj.getVelocity().multiply(2));
      _balls.add(proj);
      player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.5F, 1.5F);
      EnderDogeAmmoManager.takeEnderDogeAmmo(p, 1);
      if (EnderDogeAmmoManager.balaceEnderDogeAmmo(p) < 1) {
        player.getInventory().setItemInHand(null);
        player.sendMessage(
            StringManager.getPrefix(MessageType.ERROR) + ChatColor.AQUA + "You ran out of ammo!");
        return;
      }
      ItemStack snow = new ItemStack(Material.FIREWORK_CHARGE, 1);
      ItemMeta sno = snow.getItemMeta();
      sno.setDisplayName(
          ChatColor.DARK_AQUA
              + "EnderDoge "
              + ChatColor.DARK_RED
              + EnderDogeAmmoManager.balaceEnderDogeAmmo(p));
      snow.setItemMeta(sno);
      player.getInventory().setItemInHand(snow);
    }
  }
  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!");
    }
  }
Exemplo n.º 25
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);
			}
		}
Exemplo n.º 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);
   }
 }
Exemplo n.º 27
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);
   }
 }
Exemplo n.º 28
0
 @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);
   }
 }
Exemplo n.º 29
0
  @EventHandler(priority = EventPriority.HIGH)
  public void CropTrampleOrFireCharge(PlayerInteractEvent event) {
    if (event.getClickedBlock() == null) {
      return;
    }

    Player p = event.getPlayer();

    // trampling crops
    if (p != null
        && event.getAction().equals(Action.PHYSICAL)
        && event.getClickedBlock().getType().toString().equals("SOIL")) {
      OwnedLand land = OwnedLand.getApplicableLand(event.getClickedBlock().getLocation());
      if (land == null) {
        return;
      }
      if (land.hasPermTo(p, this)) {
        return;
      }
      p.sendMessage(
          ChatColor.RED + getPlugin().getMessageConfig().getString("event.build.cropDestroy"));
      event.setCancelled(true);
      return;
    }

    // Using fire charge
    ItemStack item = event.getItem();
    if (p != null
        && item != null
        && event.getAction().equals(Action.RIGHT_CLICK_BLOCK)
        && event.getItem().getType().equals(Material.FIREBALL)) {
      OwnedLand land = OwnedLand.getApplicableLand(event.getClickedBlock().getLocation());
      if (land == null) {
        return;
      }
      if (land.hasPermTo(p, this)) {
        return;
      }
      p.sendMessage(
          ChatColor.RED + getPlugin().getMessageConfig().getString("event.build.useFireCharge"));
      event.setCancelled(true);
    }
  }
Exemplo n.º 30
0
  @Override
  public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    if (event.useItemInHand() == Result.DENY) return;

    Hero hero = plugin.getHeroManager().getHero(player);
    if (hero.hasEffectType(EffectType.DISARM)) Util.disarmCheck(hero, plugin);

    if (!hero.canEquipItem(player.getInventory().getHeldItemSlot())) {
      event.setCancelled(true);
      Util.syncInventory(player, plugin);
      return;
    }

    // Remove effects dependant on non-interaction
    if (hero.hasEffect("Invisible")) {
      hero.removeEffect(hero.getEffect("Invisible"));
    }

    Block clickedBlock = event.getClickedBlock();
    if (clickedBlock != null) {
      switch (clickedBlock.getType()) {
        case DISPENSER:
        case BED:
        case FURNACE:
        case BURNING_FURNACE:
        case WOOD_DOOR:
        case LEVER:
        case IRON_DOOR:
        case JUKEBOX:
        case DIODE_BLOCK_OFF:
        case DIODE_BLOCK_ON:
        case CHEST:
        case LOCKED_CHEST:
        case TRAP_DOOR:
          hero.cancelDelayedSkill();
          return;
      }
    }

    if (player.getItemInHand() != null) {
      Material material = player.getItemInHand().getType();
      if (hero.hasBind(material)) {
        if (event.getAction() == Action.RIGHT_CLICK_AIR
            || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
          String[] args = hero.getBind(material);
          plugin.onCommand(player, null, "skill", args);
        } else {
          hero.cancelDelayedSkill();
        }
      } else {
        hero.cancelDelayedSkill();
      }
    }
  }