コード例 #1
0
ファイル: BlockListener.java プロジェクト: mikenon/QuickShop
  /** Removes chests when they're destroyed. */
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onBreak(final BlockBreakEvent e) {
    if (e.isCancelled()) return;

    Block b = e.getBlock();
    Player p = e.getPlayer();

    // If the chest was a chest
    if (b.getType() == Material.CHEST) {
      Shop shop = plugin.getShopManager().getShop(b.getLocation());
      // If it was a shop
      if (shop != null) {
        if (plugin.lock) {
          // If they owned it or have bypass perms, they can destroy it
          if (!shop.getOwner().equalsIgnoreCase(p.getName())
              && !p.hasPermission("quickshop.other.destroy")) {
            e.setCancelled(true);
            p.sendMessage(MsgUtil.getMessage("no-permission"));
            return;
          }
        }

        // If they're either survival or the owner, they can break it
        if (p.getGameMode() == GameMode.CREATIVE
            && !p.getName().equalsIgnoreCase(shop.getOwner())) {
          e.setCancelled(true);
          p.sendMessage(MsgUtil.getMessage("no-creative-break"));
          return;
        }

        // Cancel their current menu... Doesnt cancel other's menu's.
        Info action = plugin.getShopManager().getActions().get(p.getName());
        if (action != null) {
          action.setAction(ShopAction.CANCELLED);
        }
        shop.delete();
        p.sendMessage(MsgUtil.getMessage("success-removed-shop"));
      }
    } else if (b.getType() == Material.WALL_SIGN) {
      Shop shop = getShopNextTo(e.getBlock().getLocation());
      if (shop != null) { // It is a shop sign we're dealing with.
        if (plugin.lock) {
          // If they're the shop owner or have bypass perms, they can destroy it.
          if (!shop.getOwner().equalsIgnoreCase(p.getName())
              && !e.getPlayer().hasPermission("quickshop.other.destroy")) {
            e.setCancelled(true);
            p.sendMessage(MsgUtil.getMessage("no-permission"));
            return;
          }
        }
        // If they're in creative and not the owner, don't let them (accidents happen)
        if (p.getGameMode() == GameMode.CREATIVE
            && !p.getName().equalsIgnoreCase(shop.getOwner())) {
          e.setCancelled(true);
          p.sendMessage(MsgUtil.getMessage("no-creative-break"));
          return;
        }
      }
    }
  }
コード例 #2
0
 @HawkEvent(dataType = DataType.BLOCK_BREAK)
 public void onBlockBreak(BlockBreakEvent event) {
   Block block = event.getBlock();
   if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST)
     DataManager.addEntry(new SignEntry(event.getPlayer(), DataType.SIGN_BREAK, event.getBlock()));
   DataManager.addEntry(new BlockEntry(event.getPlayer(), DataType.BLOCK_BREAK, block));
 }
コード例 #3
0
 @EventHandler
 public void onBlockBreak(BlockBreakEvent event) {
   String playerID = PlayerConverter.getID(event.getPlayer());
   // if the player has this objective, the event isn't canceled,
   // the block is correct and conditions are met
   if (containsPlayer(playerID)
       && !event.isCancelled()
       && event.getBlock().getType().equals(material)
       && (data < 0 || event.getBlock().getData() == data)
       && checkConditions(playerID)) {
     // remove the block from the total amount
     BlockData playerData = (BlockData) dataMap.get(playerID);
     playerData.remove();
     // complete the objective
     if (playerData.getAmount() == neededAmount) {
       completeObjective(playerID);
     } else if (notify) {
       // or maybe display a notification
       if (playerData.getAmount() > neededAmount) {
         Config.sendMessage(
             playerID,
             "blocks_to_break",
             new String[] {String.valueOf(playerData.getAmount() - neededAmount)});
       } else {
         Config.sendMessage(
             playerID,
             "blocks_to_place",
             new String[] {String.valueOf(neededAmount - playerData.getAmount())});
       }
     }
   }
 }
コード例 #4
0
ファイル: BlockBreak.java プロジェクト: C4K3/Portals
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void onBlockBreak(BlockBreakEvent event) {
    if (event.getBlock().getType() != Material.OBSIDIAN) return;

    Block block = event.getBlock();
    ArrayList<PortalLocation> portals = SQLite.obsidian_checker(block);

    for (PortalLocation portal : portals) {
      if (PortalCheck.is_valid_portal(portal.block, block) == false) {
        Portals.instance
            .getLogger()
            .info(
                "Query returned positive. "
                    + "Disabling this portal at "
                    + portal.block.getWorld().getName()
                    + " "
                    + portal.block.getX()
                    + " "
                    + portal.block.getY()
                    + " "
                    + portal.block.getZ());
        SQLite.delete_portal_pair(portal.id);
      }
    }
  }
コード例 #5
0
ファイル: BListener.java プロジェクト: Digiex/SFPlugin
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onBlockBreak(BlockBreakEvent event) {
   Player p = event.getPlayer();
   SFPlayer sfp = SFPlayer.getSFPlayer(p);
   if (!p.isOp()) {
     if (plugin.getConfig().getBoolean("features.spawnprotect", true)) {
       boolean inspawn = SFPlugin.isInSpawnProtect(event.getBlock().getLocation(), plugin);
       if (inspawn) {
         event.setCancelled(true);
         p.sendMessage(ChatColor.RED + sfp.translateString("general.inspawnprotect"));
       }
     }
     if (plugin.getConfig().getBoolean("features.bedrockprotect", true)) {
       if (p.getGameMode().equals(GameMode.CREATIVE)) {
         if (!event.isCancelled()) {
           if (event.getBlock().getY() < Double.valueOf(7)
               && event.getBlock().getType().equals(Material.BEDROCK)) {
             event.setCancelled(true);
             p.sendMessage(ChatColor.RED + sfp.translateString("general.bedrockblocked.removal"));
           }
         }
       }
     }
   }
 }
コード例 #6
0
ファイル: CEListener.java プロジェクト: paul-palmer/ce
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void BlockBreakEvent(BlockBreakEvent e) {

    if (e.getBlock().hasMetadata("ce.Ice")) e.setCancelled(true);

    CEventHandler.handleEvent(e.getPlayer(), e, blockBroken);
    if (e.getBlock().hasMetadata("ce.mine")) {
      Block b = e.getBlock();
      b.removeMetadata("ce.mine", Main.plugin);
      Block[] blocks = {
        b.getRelative(0, 1, 0),
        b.getRelative(1, 0, 0),
        b.getRelative(-1, 0, 0),
        b.getRelative(0, 0, 1),
        b.getRelative(0, 0, -1)
      };

      for (Block block : blocks) {
        if (block.hasMetadata("ce.mine.secondary")) {
          String[] s = block.getMetadata("ce.mine.secondary").get(0).asString().split(" ");
          Location loc =
              new Location(
                  e.getPlayer().getWorld(),
                  Integer.parseInt(s[0]),
                  Integer.parseInt(s[1]),
                  Integer.parseInt(s[2]));
          Location blockLoc = b.getLocation();
          if (loc.getBlockX() == blockLoc.getBlockX()
              && loc.getBlockY() == blockLoc.getBlockY()
              && loc.getBlockZ() == blockLoc.getBlockZ())
            block.removeMetadata("ce.mine.secondary", Main.plugin);
        }
      }
    }
  }
コード例 #7
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onBlockBreak(BlockBreakEvent event) {
    Player p = event.getPlayer();
    int pid = GameManager.getInstance().getPlayerGameId(p);

    if (pid == -1) {
      int blockgameid = GameManager.getInstance().getBlockGameId(event.getBlock().getLocation());

      if (blockgameid != -1) {
        if (GameManager.getInstance().getGame(blockgameid).getGameMode()
            != Game.GameMode.DISABLED) {
          event.setCancelled(true);
        }
      }
      return;
    }

    Game g = GameManager.getInstance().getGame(pid);

    if (g.getMode() == Game.GameMode.DISABLED) {
      return;
    }
    if (g.getMode() != Game.GameMode.INGAME) {
      event.setCancelled(true);
      return;
    }

    if (!allowedBreak.contains(event.getBlock().getTypeId())) event.setCancelled(true);
  }
コード例 #8
0
 /**
  * Blocks block breaking inside an arena for players not in that arena,<br>
  * or if the block's material is not whitelisted for breaking.
  *
  * <p>Stops blocks with ug signs attached from breaking.
  */
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onBlockBreak(BlockBreakEvent event) {
   Arena arena = ultimateGames.getArenaManager().getLocationArena(event.getBlock().getLocation());
   if (arena != null) {
     String playerName = event.getPlayer().getName();
     if (ultimateGames.getPlayerManager().isPlayerInArena(playerName)) {
       if (!ultimateGames.getPlayerManager().getArenaPlayer(playerName).isEditing()) {
         if (arena.getStatus() == ArenaStatus.RUNNING
             && ultimateGames
                 .getWhitelistManager()
                 .getBlockBreakWhitelist()
                 .canBreakMaterial(arena.getGame(), event.getBlock().getType())) {
           Block block = event.getBlock();
           if ((block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
               && ultimateGames.getUGSignManager().isUGSign((Sign) block.getState())) {
             event.setCancelled(true);
             return;
           }
           for (Sign attachedSign : UGUtils.getAttachedSigns(block, true)) {
             if (ultimateGames.getUGSignManager().isUGSign(attachedSign)) {
               event.setCancelled(true);
               return;
             }
           }
           arena.getGame().getGamePlugin().onBlockBreak(arena, event);
         } else {
           event.setCancelled(true);
         }
       }
     } else {
       event.setCancelled(true);
     }
   }
 }
コード例 #9
0
 @Override
 public void onBlockBreak(BlockBreakEvent event) {
   if (!event.isCancelled()) {
     if (BlockUtil.isSign(event.getBlock())) {
       SignActionDetector.removeDetector(event.getBlock());
     }
   }
 }
コード例 #10
0
 @EventHandler
 public void onBlockBreak_Appliance(final BlockBreakEvent event) {
   if (MadeToBreak.appliances.contains(event.getBlock().getTypeId())) {
     plugin.l.remove(event.getBlock().getLocation()); // remove location from map
     event.setCancelled(true); // cancel entire vanilla event, cancelling the drops as well
     event.getBlock().setTypeId(0); // set the block to air
     // add any extra drops (which are not technically needed in this case)
   }
 }
コード例 #11
0
 /*    */ @EventHandler
 /*    */ public void onBlockBreak(BlockBreakEvent event) /*    */ {
   /* 48 */ if ((event.getBlock().getType() == Material.ICE) && (this.iceDrop))
   /*    */ {
     /* 50 */ ItemStack item = new ItemStack(Material.ICE, 1);
     /* 51 */ event.getPlayer().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
     /*    */ }
   /* 53 */ if ((!this.iceWater) && (event.getBlock().getType() == Material.ICE))
     /* 54 */ event.getBlock().setType(Material.AIR);
   /*    */ }
コード例 #12
0
 @EventHandler(ignoreCancelled = true)
 public void onBeaconBreak(BlockBreakEvent event) {
   if (!(event.getBlock().getState() instanceof Beacon)) {
     return;
   }
   Beacon beacon = (Beacon) event.getBlock().getState();
   if (this.config.isDropBeacon(beacon)) {
     this.config.removeBeacon();
   }
 }
コード例 #13
0
  /** Called when a block is broken. */
  @Override
  public void onBlockBreak(BlockBreakEvent event) {
    if (event.isCancelled()) {
      return;
    }

    Player player = event.getPlayer();
    WorldConfiguration wcfg = getWorldConfig(player);

    if (!wcfg.itemDurability) {
      ItemStack held = player.getItemInHand();
      if (held.getTypeId() > 0) {
        held.setDurability((short) -1);
        player.setItemInHand(held);
      }
    }

    if (!plugin.getGlobalRegionManager().canBuild(player, event.getBlock())) {
      player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
      event.setCancelled(true);
      return;
    }

    if (wcfg.getBlacklist() != null) {
      if (!wcfg.getBlacklist()
          .check(
              new BlockBreakBlacklistEvent(
                  plugin.wrapPlayer(player),
                  toVector(event.getBlock()),
                  event.getBlock().getTypeId()),
              false,
              false)) {
        event.setCancelled(true);
        return;
      }

      if (!wcfg.getBlacklist()
          .check(
              new DestroyWithBlacklistEvent(
                  plugin.wrapPlayer(player),
                  toVector(event.getBlock()),
                  player.getItemInHand().getTypeId()),
              false,
              false)) {
        event.setCancelled(true);
        return;
      }
    }

    if (wcfg.isChestProtected(event.getBlock(), player)) {
      player.sendMessage(ChatColor.DARK_RED + "The chest is protected.");
      event.setCancelled(true);
      return;
    }
  }
コード例 #14
0
 @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
 public void onBlockBreak(BlockBreakEvent event) {
   if (windwalkers.size() > 0 && event.getBlock().getType() == platformBlock) {
     for (BlockPlatform platform : windwalkers.values()) {
       if (platform.blockInPlatform(event.getBlock())) {
         event.setCancelled(true);
         break;
       }
     }
   }
 }
コード例 #15
0
ファイル: PedestalBase.java プロジェクト: Schmoller/SkyQuest
    @EventHandler
    private void onBlockBreak(BlockBreakEvent event) {
      if (!mIsLoaded) return;
      if (event.getBlock().getWorld() == mLocation.getWorld()) {
        if (event.getBlock().getLocation().distanceSquared(mLocation) < 1D) {
          onRemove();

          onPedestalDestroyed();
        }
      }
    }
コード例 #16
0
 @Override
 public void onBlockBreak(BlockBreakEvent event) {
   if (dropglass) {
     int blockID = event.getBlock().getTypeId();
     if (droplist.containsKey(blockID)) {
       AbstractDrop newDrop = droplist.get(blockID);
       Location dropLocation = event.getBlock().getLocation();
       newDrop.CreateDrop(dropLocation, dropLocation.getWorld());
     }
   }
 }
コード例 #17
0
ファイル: SignHandler.java プロジェクト: recon88/TNTRun
 @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
 public void onSignDestroy(BlockBreakEvent e) {
   if (!(e.getBlock().getState() instanceof Sign)) {
     return;
   }
   Sign sign = (Sign) e.getBlock().getState();
   if (sign.getLine(0).equalsIgnoreCase(ChatColor.BLUE + "[TNTRun]")
       && sign.getLine(1).equalsIgnoreCase("[join]")
       && sign.getLine(2) != null) {
     joinsign.handleDestroy(e.getBlock());
   }
 }
コード例 #18
0
 // If block was removed, get rid of it from the HashMap
 @EventHandler
 public void onBlockBreak(BlockBreakEvent event) {
   if (plugin.getBlockCommandMap().get(event.getBlock().getLocation()) != null) {
     // Only remove a command block if the player is op
     if (event.getPlayer().hasPermission("autoruncommands.removeblock"))
       plugin.getBlockCommandMap().remove(event.getBlock().getLocation());
     else {
       event.getPlayer().sendMessage("You don't have permission to remove this block");
       event.setCancelled(true);
     }
   }
 }
コード例 #19
0
ファイル: VampireListener.java プロジェクト: Borito/Vampire
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onBlockBreak(BlockBreakEvent event) {
    if (event.isCancelled()) return;
    Material material = event.getBlock().getType();
    if (!Conf.dropSelfOverrideMaterials.contains(material)) return;

    event.setCancelled(true);
    event
        .getBlock()
        .getWorld()
        .dropItemNaturally(event.getBlock().getLocation(), new ItemStack(material, 1));
    event.getBlock().setType(Material.AIR);
  }
コード例 #20
0
  @EventHandler(priority = EventPriority.HIGH)
  public void onBlockBreak(BlockBreakEvent event) {
    Block block = event.getBlock();

    // Deny DPortal destroying
    if (block.getType() == Material.PORTAL) {
      if (DPortal.get(event.getBlock()) != null) {
        event.setCancelled(true);
      }
    }

    // Deny DGSignblocks destroying
    if (DGSign.isRelativeSign(block, 1, 0)
        || DGSign.isRelativeSign(block, -1, 0)
        || DGSign.isRelativeSign(block, 0, 1)
        || DGSign.isRelativeSign(block, 0, -1)) {
      event.setCancelled(true);
    }

    // DGSign destroying
    if (DGSign.getSign(block) != null) {
      DGSign.dgsigns.remove(DGSign.getSign(block));
    }

    // Deny LeaveSignblocks destroying
    if (LeaveSign.isRelativeSign(block, 1, 0)
        || LeaveSign.isRelativeSign(block, -1, 0)
        || LeaveSign.isRelativeSign(block, 0, 1)
        || LeaveSign.isRelativeSign(block, 0, -1)) {
      event.setCancelled(true);
    }

    // LeaveSign destroying
    if (LeaveSign.getSign(block) != null) {
      event.setCancelled(true);
      // LeaveSign.lsigns.remove(LeaveSign.getSign(block));
    }

    // Editworld Signs
    EditWorld eworld = EditWorld.get(block.getWorld());
    if (eworld != null) {
      eworld.sign.remove(event.getBlock());
    }

    // Deny GameWorld Blocks
    GameWorld gworld = GameWorld.get(block.getWorld());
    if (gworld != null) {
      event.setCancelled(true);
    }
  }
コード例 #21
0
 @Override
 public void onBlockBreak(BlockBreakEvent event) {
   Shop s = plugin.GetShop(event.getBlock().getLocation());
   if (s == null) return;
   if (s.getOwner().equalsIgnoreCase(event.getPlayer().getName())) {
     for (int i = s.getStock(); i > 0; i -= 64) {
       if (i >= 64)
         event
             .getBlock()
             .getWorld()
             .dropItemNaturally(event.getBlock().getLocation(), new ItemStack(s.getItemId(), 64));
       else
         event
             .getBlock()
             .getWorld()
             .dropItemNaturally(event.getBlock().getLocation(), new ItemStack(s.getItemId(), i));
     }
     for (int i = s.getBalance(); i > 0; i -= 64) {
       if (i >= 64)
         event
             .getBlock()
             .getWorld()
             .dropItemNaturally(event.getBlock().getLocation(), new ItemStack(s.getCurId(), 64));
       else
         event
             .getBlock()
             .getWorld()
             .dropItemNaturally(event.getBlock().getLocation(), new ItemStack(s.getCurId(), i));
     }
     plugin.getDatabase().delete(s);
     event.getPlayer().sendMessage("Sign shop removed.");
   } else {
     Sign block = new CraftSign(event.getBlock());
     event.setCancelled(true);
     if (s.getItemId() != 0) {
       block.setLine(0, s.getOwner());
       block.setLine(1, Material.getMaterial(s.getItemId()).toString());
       block.setLine(2, s.getCount() + " for " + s.getPrice() + " " + s.getCurName());
       block.setLine(3, s.getStock() + " items.");
     } else {
       block.setLine(0, s.getOwner());
       block.setLine(1, s.getPrice() + " " + s.getCurName());
       block.setLine(2, "Right click me");
       block.setLine(3, "with something");
     }
     block.update();
     event.getPlayer().sendMessage("Stop trying to grief " + s.getOwner() + "'s shops.");
   }
 }
コード例 #22
0
 @EventHandler
 public void onBlockBreakEvent(BlockBreakEvent event) {
   if (isEnabled()) {
     Material m = event.getBlock().getType();
     if (m == Material.LEAVES) {
       Random r = new Random();
       if (r.nextInt(100) == 0) {
         ItemStack apple = new ItemStack(Material.APPLE, 1);
         event.getPlayer().getWorld().dropItemNaturally(event.getBlock().getLocation(), apple);
       }
       event.setCancelled(true);
       event.getBlock().setType(Material.AIR);
     }
   }
 }
コード例 #23
0
 @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 public void onBlockBreak(BlockBreakEvent event) {
   if (event.getBlock().getType() == Material.CHEST) {
     List<PlayerShopkeeper> shopkeepers = plugin.getShopkeeperOwnersOfChest(event.getBlock());
     if (shopkeepers.size() > 0) {
       for (PlayerShopkeeper shopkeeper : shopkeepers) {
         plugin.closeTradingForShopkeeper(shopkeeper.getId());
         plugin.activeShopkeepers.remove(shopkeeper.getId());
         plugin.allShopkeepersByChunk.get(shopkeeper.getChunk()).remove(shopkeeper);
         shopkeeper.remove();
       }
       plugin.save();
     }
   }
 }
コード例 #24
0
ファイル: XRayListener.java プロジェクト: geord/AntiCheat
 @EventHandler
 public void onBlockBreak(BlockBreakEvent event) {
   if (config.logXRay()) {
     Player p = event.getPlayer();
     String player = p.getName();
     if (checkManager.willCheck(p, CheckType.XRAY)) {
       Material m = event.getBlock().getType();
       if (m == Material.DIAMOND_ORE) {
         tracker.addDiamond(player);
       } else if (m == Material.IRON_ORE) {
         tracker.addIron(player);
       } else if (m == Material.COAL_ORE) {
         tracker.addCoal(player);
       } else if (m == Material.GOLD_ORE) {
         tracker.addGold(player);
       } else if (m == Material.LAPIS_ORE) {
         tracker.addLapis(player);
       } else if (m == Material.REDSTONE_ORE) {
         tracker.addRedstone(player);
       } else if (m == Material.GOLD_ORE) {
         tracker.addGold(player);
       } else {
         tracker.addBlock(player);
       }
       tracker.addTotal(player);
     }
   }
 }
コード例 #25
0
ファイル: SBlockListener.java プロジェクト: Lolmewn/Sortal
 @EventHandler(priority = EventPriority.NORMAL)
 public void onBlockBreak(BlockBreakEvent event) {
   Block block = event.getBlock();
   if ((block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)) {
     Sign s = (Sign) block.getState();
     if (!plugin.loc.containsKey(block.getLocation())) {
       for (int i = 0; i < s.getLines().length; i++) {
         if (s.getLine(i).toLowerCase().contains("[sortal]")
             || s.getLine(i).toLowerCase().contains(plugin.signContains)) {
           if (!event.getPlayer().hasPermission("sortal.delsign")) {
             event
                 .getPlayer()
                 .sendMessage("[Sortal] You do not have permissions to destroy a [Sortal] sign!");
             event.setCancelled(true);
           }
         }
       }
       return;
     }
     if (!event.getPlayer().hasPermission("sortal.delsign")) {
       event
           .getPlayer()
           .sendMessage("[Sortal] You do not have permissions to destroy a registered sign!");
       event.setCancelled(true);
       return;
     }
     delLoc(block.getLocation());
     plugin.log.info(
         "Registered sign destroyed by "
             + event.getPlayer().getDisplayName()
             + ", AKA "
             + event.getPlayer().getName()
             + "!");
   }
 }
コード例 #26
0
  @Override
  public void onBlockBreak(BlockBreakEvent inEvent) {
    Player thePlayer = inEvent.getPlayer();
    Block theBlock = inEvent.getBlock();

    if ((theBlock.getType() != Material.MOB_SPAWNER) || (inEvent.isCancelled())) return;

    if (creaturebox.permissions != null) {
      if (creaturebox.permissions.has(thePlayer, "creaturebox.dropspawner") == false) {
        return;
      }
    } else {
      if (thePlayer.isOp() == false) {
        return;
      }
    }

    World theWorld = theBlock.getWorld();
    Location theLocation =
        new Location(theWorld, theBlock.getX(), theBlock.getY(), theBlock.getZ(), 0, 0);
    CreatureSpawner theSpawner = (CreatureSpawner) theBlock.getState();
    int theCreatureIndex = plugin.creatureIndex(theSpawner.getCreatureTypeId());

    MaterialData theMaterial = new MaterialData(Material.MOB_SPAWNER, (byte) theCreatureIndex);
    ItemStack theItem = new ItemStack(Material.MOB_SPAWNER, 1, (short) theCreatureIndex);

    theWorld.dropItemNaturally(theLocation, theItem);

    thePlayer.sendMessage(
        String.format(
            ChatColor.YELLOW + "creaturebox: %s spawner dropped.", theSpawner.getCreatureTypeId()));
  }
コード例 #27
0
  public void onBlockBreak(BlockBreakEvent event) {

    Block blockBreaked = event.getBlock();
    World world = blockBreaked.getWorld();
    Player player = event.getPlayer();

    // Sand/Gravel check when destroying a block

    if (world.getBlockTypeIdAt(blockBreaked.getX(), blockBreaked.getY() + 1, blockBreaked.getZ())
            == 12
        || world.getBlockTypeIdAt(blockBreaked.getX(), blockBreaked.getY() + 1, blockBreaked.getZ())
            == 13) {

      if (WorldGuard.getWorldGuardState() == false) {
        player.sendMessage(ChatColor.DARK_RED + "The required plugin is not enabled.");
        event.setCancelled(true);
        return;
      }

      for (int i = blockBreaked.getY() - 1; i >= 1; i = i - 1) {
        int xx = blockBreaked.getX();
        int yy = i;
        int zz = blockBreaked.getZ();
        Location location = new Location(world, xx, yy, zz);
        if (world.getBlockTypeIdAt(xx, yy, zz) != 0) {
          return;
        }
        if (!WorldGuard.IsMemberOnLocation(player, location)) {
          player.sendMessage(ChatColor.RED + "A block on this one is going to fall into a region.");
          event.setCancelled(true);
          return;
        }
      }
    }
  }
コード例 #28
0
 @EventHandler
 public void onBreak(BlockBreakEvent bbe) {
   if (!(bbe.isCancelled())) {
     Block block = bbe.getBlock();
     if (bbe.getPlayer() != null) {
       Player breaker = bbe.getPlayer();
       UUID uuid = breaker.getUniqueId();
       if (block.getState().getType().equals(Material.REDSTONE_ORE)
           || block.getType().equals(Material.REDSTONE_ORE)) {
         boolean notSilkTouch = true;
         if (breaker.getInventory().getItemInHand() != null) {
           ItemStack handItem = breaker.getInventory().getItemInHand();
           if (handItem.containsEnchantment(Enchantment.SILK_TOUCH)) {
             notSilkTouch = false;
           }
         }
         boolean lowLevel = true;
         int level = LevelManager.getLevel(breaker);
         if (level > 30) {
           lowLevel = false;
         }
         if (notSilkTouch && lowLevel) {
           int broke = LevelingXP_Breaking.get(uuid);
           broke += 1;
           if (broke >= (10 * LevelManager.getLevel(breaker))) {
             XPmanager.giveXP(breaker, 80);
           } else {
             LevelingXP_Breaking.set(uuid, broke);
           }
         }
       }
     }
   }
 }
コード例 #29
0
  @EventHandler(priority = EventPriority.HIGH) // , ignoreCancelled = true
  public void onBlockBreak(final BlockBreakEvent event) {
    Block b = event.getBlock();

    if (PlotManager.isPlotWorld(b)) {
      Player p = event.getPlayer();
      boolean canbuild = PlotMe.cPerms(event.getPlayer(), "plotme.admin.buildanywhere");
      String id = PlotManager.getPlotId(b.getLocation());

      if (id.equalsIgnoreCase("")) {
        if (!canbuild) {
          p.sendMessage(PlotMe.caption("ErrCannotBuild"));
          event.setCancelled(true);
        }
      } else {
        Plot plot = PlotManager.getMap(p).plots.get(id);

        if (plot == null) {
          if (!canbuild) {
            p.sendMessage(PlotMe.caption("ErrCannotBuild"));
            event.setCancelled(true);
          }
        } else if (!plot.isAllowed(p.getName())) {
          if (!canbuild) {
            p.sendMessage(PlotMe.caption("ErrCannotBuild"));
            event.setCancelled(true);
          }
        } else {
          plot.resetExpire(PlotManager.getMap(b).DaysToExpiration);
        }
      }
    }
  }
コード例 #30
0
 @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 public void onBlockBreak(BlockBreakEvent e) {
   Player p = e.getPlayer();
   Block b = e.getBlock();
   if (p.getGameMode() == GameMode.CREATIVE) {
     if (b.getType() == Material.SKULL) {
       Skull skull = (Skull) e.getBlock().getState();
       String name = this.hasOwner(skull) ? skull.getOwner() : this.def;
       if (!this.hasTool(p)) {
         if (p.isSneaking()) {
           if (SkullWalls.getWallHandler().getWallFromBlock(b) != null) {
             if (p.hasPermission(perm) || p.isOp()) {
               p.sendMessage(this.des.replace("#", name));
               // Disable skull?
             } else {
               e.setCancelled(true);
               p.sendMessage(this.noperm);
             }
           }
         } else if (SkullWalls.getWallHandler().getWallFromBlock(b) != null) {
           this.sw.getActionWorker().executeQuery(p, name);
           if (p.hasPermission(perm)) {
             e.setCancelled(true);
             p.sendMessage(RED + "To destroy skull you must sneak and break");
           } else {
             e.setCancelled(true);
             p.sendMessage(this.noperm);
           }
         }
       } else if (p.isSneaking()) {
         e.setCancelled(true);
         this.sw.getActionWorker().executeQuery(p.getPlayer(), name);
       } else {
         e.setCancelled(true);
         ItemStack s = p.getItemInHand();
         this.onBlockDamage(new BlockDamageEvent(p, b, s, false));
         if (SkullWalls.getWallHandler().getWallFromBlock(b) != null) {
           p.sendMessage(RED + "Block selected is already a part of a skull wall");
           p.sendMessage(RED + "Overlapping walls will not perform as expected!");
         }
       }
     }
   } else if (this.sw.getConfiguration().isProtecting()
       && e.getBlock().getType() == Material.SKULL
       && !p.hasPermission(perm))
     e.setCancelled(SkullWalls.getWallHandler().hasPermission(b, p, this.noperm));
 }