public static boolean doCollectParallel(final MinecartManiaMinecart minecart) {
   final ArrayList<Block> blockList = minecart.getParallelBlocks();
   for (final Block block : blockList) {
     if (block.getState() instanceof Chest) {
       final MinecartManiaChest chest =
           MinecartManiaWorld.getMinecartManiaChest((Chest) block.getState());
       final ArrayList<Sign> signList =
           SignUtils.getAdjacentMinecartManiaSignList(chest.getLocation(), 1);
       for (final Sign sign : signList) {
         for (int i = 0; i < sign.getNumLines(); i++) {
           if (sign.getLine(i).toLowerCase().contains("parallel")) {
             sign.setLine(i, "[Parallel]");
             if (!minecart.isMovingAway(block.getLocation())) {
               if (chest.addItem(minecart.getType().getId())) {
                 minecart.kill(false);
                 return true;
               }
             }
           }
         }
       }
     }
   }
   return false;
 }
예제 #2
0
  private boolean moveEarth() {
    progress++;
    Block affectedblock = location.clone().add(direction).getBlock();
    location = location.add(direction);
    if (GeneralMethods.isRegionProtectedFromBuild(player, "IceSpike", location)) return false;
    for (Entity en : GeneralMethods.getEntitiesAroundPoint(location, 1.4)) {
      if (en instanceof LivingEntity && en != player && !damaged.contains(((LivingEntity) en))) {
        LivingEntity le = (LivingEntity) en;
        affect(le);
        // le.setVelocity(thrown);
        // le.damage(damage);
        // damaged.add(le);
        // Methods.verbose(damage + " Hp:" + le.getHealth());
      }
    }
    affectedblock.setType(Material.ICE);
    WaterMethods.playIcebendingSound(block.getLocation());
    loadAffectedBlocks();

    if (location.distance(origin) >= height) {
      return false;
    }

    return true;
  }
예제 #3
0
 /**
  * Detects if a Block is protected by a Sign or not. Returns the Sign owner if protected, null
  * otherwise.
  *
  * @param b the block to check
  * @return the Sign owner name if protected, null otherwise
  */
 public String isProtected(final Block b) {
   final NLocation loc = new NLocation(b.getLocation());
   final ProtectionState state = this.isProtectedCache.get(loc);
   if (state != null && state.timeout > System.currentTimeMillis()) {
     return state.protectedBy;
   } else {
     final Material blockType = b.getType();
     String result = null;
     List<Sign> signLines = null;
     if (blockType == Material.CHEST || blockType == Material.TRAPPED_CHEST) {
       signLines = SignUtil.getSignsForChest(b);
     } else if (getProtectedMaterials().contains(blockType)) {
       signLines = SignUtil.getSignsForBlock(b);
     }
     if (signLines != null) {
       for (final Sign sign : signLines) {
         if (PROTECTION.equals(sign.getLine(0))) {
           result = ColorUtil.stripColorCodes(sign.getLine(3));
           break;
         }
       }
     }
     this.isProtectedCache.put(
         loc, new ProtectionState(result, System.currentTimeMillis() + CACHE_TIME));
     return result;
   }
 }
예제 #4
0
  public void onEntityExplode(EntityExplodeEvent event) {
    ArrayList<Integer> ids = iCoLand.landMgr.getLandIds(event.getEntity().getLocation());
    for (Integer id : ids) {
      if (iCoLand.landMgr.getLandById(id).hasAddon("noboom")) {
        event.setCancelled(true);
        return;
      }
    }

    if (ids.size() == 0 && !Config.unclaimedLandCanBoom) {
      event.setCancelled(true);
      return;
    }

    List<Block> bl = event.blockList();
    int total = bl.size();
    int cancelled = 0;
    for (Block block : bl) {
      ids = iCoLand.landMgr.getLandIds(block.getLocation());
      for (Integer id : ids) {
        if (iCoLand.landMgr.getLandById(id).hasAddon("noboom")) {
          // TODO - cancel block explosion here

          cancelled++;
        }
      }
    }
    float ratio = 1 - cancelled / total;

    event.setYield(ratio * event.getYield());
  }
예제 #5
0
 @Override
 public PostCastAction castSpell(Player player, SpellCastState state, float power, String[] args) {
   if (state == SpellCastState.NORMAL) {
     Block block = null;
     if (targeted) {
       block = getTargetedBlock(player, power);
     } else {
       block = player.getLocation().subtract(0, 1, 0).getBlock();
     }
     if (block != null) {
       SpellTargetLocationEvent event =
           new SpellTargetLocationEvent(this, player, block.getLocation(), power);
       Bukkit.getPluginManager().callEvent(event);
       if (event.isCancelled()) {
         block = null;
       } else {
         block = event.getTargetLocation().getBlock();
         power = event.getPower();
       }
     }
     if (block != null) {
       boolean farmed = farm(block, Math.round(radius * power));
       if (!farmed) return noTarget(player);
       playSpellEffects(EffectPosition.CASTER, player);
       if (targeted) {
         playSpellEffects(EffectPosition.TARGET, block.getLocation());
       }
     } else {
       return noTarget(player);
     }
   }
   return PostCastAction.HANDLE_NORMALLY;
 }
예제 #6
0
 @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 public void onBlockPhysics(BlockPhysicsEvent event) {
   final Block block = event.getBlock();
   final Material type = block.getType();
   if (MaterialUtil.ISSIGN.get(type)) {
     if (Util.isSupported(block)) {
       // Check for potential redstone changes
       updateRedstonePower(block);
     } else {
       // Remove from block power storage
       poweredBlocks.remove(block);
     }
   } else if (MaterialUtil.ISREDSTONETORCH.get(type)) {
     // Send proper update events for all signs around this power source
     for (BlockFace face : FaceUtil.RADIAL) {
       final Block rel = event.getBlock().getRelative(face);
       if (MaterialUtil.ISSIGN.get(rel)) {
         CommonUtil.nextTick(
             new Runnable() {
               public void run() {
                 updateRedstonePower(rel);
               }
             });
       }
     }
   }
 }
예제 #7
0
  @Override
  public boolean check(RequirementsContext context, List<String> args)
      throws RequirementCheckException {
    boolean outcome = false;
    Block blockToCheck = null;

    for (String thisArg : args) {

      if (aH.matchesLocation(thisArg)) {
        blockToCheck = aH.getLocationFrom(thisArg).getBlock();
        if (blockToCheck != null)
          dB.echoDebug("...block to check is type '%s'.", blockToCheck.getType().toString());
      } else dB.echoError("Could not match argument '%s'!", thisArg);
    }

    if (blockToCheck != null) {
      if (blockToCheck.isBlockPowered()) outcome = true;
      else if (blockToCheck.isBlockIndirectlyPowered()) outcome = true;
    }

    if (outcome == true) dB.echoDebug("...block is powered!");
    else dB.echoDebug("...block is not powered!");

    return outcome;
  }
  @EventHandler
  public void onBlockPlace(BlockPlaceEvent e) {
    if (e.isCancelled()) {
      return;
    }
    Player player = e.getPlayer();
    Block block = e.getBlock();
    // If the block placed isn't a mob spawner, then quit listening
    if (Material.MOB_SPAWNER != block.getType()) {
      return;
    }

    Location spawnerLoc = block.getLocation();

    if (ChunkManager.addSpawnerLocation(spawnerLoc)) {
      return;
    }

    ChunkWrapper wrapper = ChunkManager.getData(spawnerLoc);
    Players.sendMessage(
        player,
        String.format(
            "&eThis chunk has reached it's limit for mob spawners &7(%s).",
            wrapper.getSpawnerCount()));
    e.setCancelled(true);
  }
예제 #9
0
  /** 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;
        }
      }
    }
  }
예제 #10
0
 private void pathStep() {
   if (pathIterator.hasNext()) {
     Node n = pathIterator.next();
     Block b = null;
     if (last == null || runningPath.checkPath(n, last, true)) {
       b = n.b;
       if (last != null) {
         this.lookAtPoint(last.b.getLocation(), b.getLocation());
       }
       getHandle().setPosition(b.getX(), b.getY(), b.getZ());
     }
     last = n;
   } else {
     getHandle()
         .setPositionRotation(
             runningPath.getEnd().getX(),
             runningPath.getEnd().getY(),
             runningPath.getEnd().getZ(),
             runningPath.getEnd().getYaw(),
             runningPath.getEnd().getPitch());
     Bukkit.getServer().getScheduler().cancelTask(taskid);
     taskid = 0;
   }
   location =
       new Location(
           getHandle().world.getWorld(), getHandle().locX, getHandle().locY, getHandle().locZ);
 }
 @Override
 public void perform(Block b) {
   if (b.getTypeId() == ir) {
     h.put(b);
     b.setTypeIdAndData(i, d, true);
   }
 }
예제 #12
0
    protected void checkForGround() {
      checkCounter = 0;

      Location playerLocation = player.getLocation();
      World world = playerLocation.getWorld();
      Block targetBlock = world.getBlockAt(playerLocation);
      targetBlock = targetBlock.getFace(BlockFace.DOWN);

      int newGroundHeight = targetBlock.getY();

      while (targetBlock.getType() == Material.AIR && newGroundHeight > 1) {
        newGroundHeight--;
        targetBlock = targetBlock.getFace(BlockFace.DOWN);
      }

      // if the terrain has changed more than the auto-hover tolerance, re-adjust hover height and
      // keep level.
      if (groundHeight == 0 || targetHeight == 0) {
        hoverHeight = player.getLocation().getBlockY() - newGroundHeight;
        if (hoverHeight < defaultHoverHeight) {
          hoverHeight = defaultHoverHeight;
        }
      } else if (Math.abs(newGroundHeight - groundHeight) > maxTerrainChangeHeight) {
        hoverHeight = targetHeight - newGroundHeight;
      }

      groundHeight = newGroundHeight;

      updateTargetHeight();
    }
  @SuppressWarnings("deprecation")
  @Command(
      value = "myplanet",
      desc = "Erzeugt einen Testplaneten",
      perm = "craftoplugin.galaxywar.generate",
      onlyplayers = true)
  public void generatePlanet(final CommandSender cs, final String command, final String[] args) {
    final Player p = (Player) cs;
    p.sendMessage("Aktiv!");
    final int r = 6;
    PlanetType type = PlanetType.SUN;
    if (args.length > 0) {
      try {
        type = PlanetType.valueOf(args[0].toUpperCase());
      } catch (final IllegalArgumentException e) {
      }
    }
    final World world = p.getWorld();

    final Planet planet = new Planet(new Position(p.getLocation()), r, type);
    final ArrayList<MaterialBlockPoint> blocks = planet.getMaterialBlockPoints();

    Block block;
    for (final MaterialBlockPoint b : blocks) {
      block = world.getBlockAt(b.getX(), b.getY(), b.getZ());
      block.setType(b.getMaterial());
      block.setData((byte) 0);
    }
  }
예제 #14
0
  @Override
  public boolean doPowerSign(
      PowerSigns plugin, Block signBlock, String action, Matcher argsm, Boolean isOn) {
    Sign signState = (Sign) signBlock.getState();

    BlockFace signDir = PowerSigns.getSignDirection(signBlock);

    Vector dir = PowerSigns.strToVector(argsm.group(1), signDir);

    Block invBlock = signBlock.getRelative(dir.getBlockX(), dir.getBlockY(), dir.getBlockZ());

    Inventory inventory;
    BlockState state = invBlock.getState();
    if (state instanceof InventoryHolder) inventory = ((InventoryHolder) state).getInventory();
    else return plugin.debugFail("bad inv:" + invBlock.getType().toString() + " " + dir.toString());

    Material[] materials = PowerSigns.getMaterials(signState.getLine(1));

    int count = 0;

    for (Material material : materials) count += PowerSigns.inventoryCount(inventory, material);

    signState.setLine(2, Integer.toString(count));

    plugin.updateSignState(signState);

    return true;
  }
예제 #15
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);
     }
   }
 }
예제 #16
0
  /**
   * Applies a list of transformation on a block, if the block is not protected.
   *
   * @param toTransform the Bukkit block object to transform
   * @param transformations the list if transformations to apply
   */
  public static void transform(Block toTransform, List<List<String>> transformations) {
    if (isBlockProtected(toTransform)) {
      return;
    }

    for (List<String> toCheck : transformations) {
      ArrayList<String[]> stateIndex = new ArrayList<String[]>();

      for (int i = 0; i != 2; ++i) {
        String got = toCheck.get(i);

        if (got.contains(":")) { // Check for data _ appended.
          stateIndex.add(got.split(":"));
        } else {
          stateIndex.add(new String[] {got, "0"});
        }
      }

      String[] curState = stateIndex.get(0), toState = stateIndex.get(1);

      if (Integer.valueOf(curState[0]) == toTransform.getTypeId()
          && Integer.valueOf(curState[1]) == toTransform.getData()) {
        toTransform.setTypeIdAndData(Integer.valueOf(toState[0]), Byte.parseByte(toState[1]), true);
        return;
      }
    }
  }
예제 #17
0
  @EventHandler
  public void onMove(PlayerMoveEvent e) {
    Player p = e.getPlayer();
    double x = p.getLocation().getX();
    double y = p.getLocation().getY() - 1;
    double z = p.getLocation().getZ();
    Location loc = new Location(p.getWorld(), x, y, z);
    Block b1 = loc.getBlock();
    Block b2 = p.getLocation().getBlock();

    if (b1.getType().equals(Material.REDSTONE_BLOCK) && b2.getType().equals(Material.WOOD_PLATE)) {
      // p.sendMessage("ON " + b1.getType().toString() + " + " + b2.getType().toString());
      p.setVelocity(p.getLocation().getDirection().multiply(2).setY(p.getVelocity().getY() + 1));
      p.setFallDistance(0f);
      for (Player all : Bukkit.getOnlinePlayers()) {
        all.playSound(p.getLocation(), Sound.WITHER_SHOOT, 0.1f, 0.1f);
      }
    }

    p.setSaturation(100f);
    p.setFoodLevel(20);
    p.setHealth(20f);

    if (p.getLocation().getY() <= 80) {
      p.teleport(p.getWorld().getSpawnLocation());
      p.setGameMode(GameMode.ADVENTURE);
      p.setAllowFlight(true);
      p.setFlying(false);
    }
  }
예제 #18
0
  public void addBlock(Block b) {
    if (b != null) {
      try {
        File file = new File("plugins/NerdLocker/blocks.lock");
        Scanner scan = null;
        String str = null;

        if (file.exists()) {
          scan = new java.util.Scanner(file);
          str = scan.nextLine();
          while (scan.hasNextLine()) {
            str = str.concat("\n" + scan.nextLine());
          }
        }

        int x = (int) b.getLocation().getX();
        int y = (int) b.getLocation().getY();
        int z = (int) b.getLocation().getZ();

        str = (x + "," + y + "," + z);

        PrintWriter out = new PrintWriter(new FileWriter(file, true));

        out.println(str);
        out.close();
        scan.close();
      } catch (Exception e) {
        // TODO: solve error not just cover it up :D
      }
    }
  }
예제 #19
0
 @EventHandler(priority = EventPriority.HIGH)
 public void onBlockIgniteEvent(BlockIgniteEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (event.getPlayer() == null) {
     return;
   }
   Player player = event.getPlayer();
   if (vanishNoPacket.isPlayerInvisible(player)) {
     return;
   }
   Block block = event.getBlock();
   Set<Snitch> snitches = snitchManager.findSnitches(block.getWorld(), block.getLocation());
   for (Snitch snitch : snitches) {
     if (!snitch.shouldLog()) {
       continue;
     }
     if (!isOnSnitch(snitch, player.getName()) || isDebugging()) {
       if (checkProximity(snitch, player.getName())) {
         plugin.getJaLogger().logSnitchIgnite(snitch, player, block);
       }
     }
   }
 }
예제 #20
0
  public void loopThrough(Location loc1, Location loc2, World w) {

    File file = new File("plugins/NerdLocker/blocks.lock");
    if (!(file.exists())) {
      try {
        FileInputStream fstream = new FileInputStream("plugins/NerdLocker/blocks.lock");
        fstream.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    int minx = Math.min(loc1.getBlockX(), loc2.getBlockX()),
        miny = Math.min(loc1.getBlockY(), loc2.getBlockY()),
        minz = Math.min(loc1.getBlockZ(), loc2.getBlockZ()),
        maxx = Math.max(loc1.getBlockX(), loc2.getBlockX()),
        maxy = Math.max(loc1.getBlockY(), loc2.getBlockY()),
        maxz = Math.max(loc1.getBlockZ(), loc2.getBlockZ());
    for (int x = minx; x <= maxx; x++) {
      for (int y = miny; y <= maxy; y++) {
        for (int z = minz; z <= maxz; z++) {
          Block b = w.getBlockAt(x, y, z);
          if (b.getTypeId() != 0) {
            addBlock(b);
          }
        }
      }
    }
  }
예제 #21
0
    public eBlock(final Block bl) {
      this.b = bl;
      this.i = bl.getTypeId();
      switch (bl.getType()) {
        case AIR:
          this.solid = false;
          break;

        case WATER:
          this.solid = false;
          break;

        case STATIONARY_WATER:
          this.solid = false;
          break;

        case STATIONARY_LAVA:
          this.solid = false;
          break;
        case LAVA:
          this.solid = false;
          break;

        default:
          this.solid = true;
      }
    }
예제 #22
0
  @SuppressWarnings("deprecation")
  @EventHandler
  public void onInventoryClick(InventoryClickEvent e) {
    Player player = (Player) e.getWhoClicked();
    Inventory inventory = e.getInventory();
    ItemStack currentItem = e.getCurrentItem();

    if (ArenaManager.getInstance().getArena(player) == null) {
      return;
    }

    Plot plot = ArenaManager.getInstance().getArena(player).getPlot(player);

    if (!inventory.getName().equals(ChatColor.GREEN + "Options menu")) {
      return;
    }
    if (currentItem.getType() != Material.HARD_CLAY) {
      return;
    }
    if (!currentItem.hasItemMeta()) {
      return;
    }
    if (!currentItem.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Floor block")) {
      return;
    }

    for (Block block : plot.getFloor().getAllBlocks()) {
      block.setType(e.getCursor().getType());
      block.setData(e.getCursor().getData().getData());
    }

    e.setCancelled(true);
  }
 @Override
 public SkillResult use(Hero hero, String[] args) {
   Player player = hero.getPlayer();
   broadcastExecuteText(hero);
   double chance2x = SkillConfigManager.getUseSetting(hero, this, "chance-2x", 0.2, false);
   double chance3x = SkillConfigManager.getUseSetting(hero, this, "chance-3x", 0.1, false);
   Block wTargetBlock = player.getTargetBlock(null, 20).getRelative(BlockFace.UP);
   double rand = Math.random();
   LivingEntity le =
       player.getWorld().spawnCreature(wTargetBlock.getLocation(), CreatureType.SPIDER);
   le.getWorld().playEffect(le.getLocation(), Effect.SMOKE, 3);
   int count = 1;
   if (rand > (1 - chance2x - chance3x)) {
     LivingEntity le1 =
         player.getWorld().spawnCreature(wTargetBlock.getLocation(), CreatureType.SPIDER);
     le1.getWorld().playEffect(le1.getLocation(), Effect.SMOKE, 3);
     count++;
   }
   if (rand > (1 - chance3x)) {
     LivingEntity le1 =
         player.getWorld().spawnCreature(wTargetBlock.getLocation(), CreatureType.SPIDER);
     le1.getWorld().playEffect(le1.getLocation(), Effect.SMOKE, 3);
     count++;
   }
   broadcast(player.getLocation(), "" + count + "x Multiplier!");
   return SkillResult.NORMAL;
 }
예제 #24
0
  /*
   * (non-Javadoc)
   * @see com.nitnelave.CreeperHeal.block.Replaceable#replace(boolean)
   */
  @Override
  public boolean replace(boolean shouldDrop) {
    Block block = getBlock();
    int blockId = block.getTypeId();

    if (!CreeperConfig.overwriteBlocks && !isEmpty(blockId)) {
      if (CreeperConfig.dropDestroyedBlocks) drop();
      return true;
    } else if (CreeperConfig.overwriteBlocks
        && !isEmpty(blockId)
        && CreeperConfig.dropDestroyedBlocks) {
      CreeperBlock.newBlock(block.getState()).drop();
      block.setTypeIdAndData(0, (byte) 0, false);
    }

    if (!shouldDrop
        && isDependent(getTypeId())
        && isEmpty(getBlock().getRelative(getAttachingFace()).getTypeId())) {
      delay_replacement();
      return true;
    } else update();

    // TODO: Check the necessity, and move to CreeperRail if possible.
    checkForAscendingRails();

    return true;
  }
 @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);
           }
         }
       }
     }
   }
 }
예제 #26
0
 @Override
 public Cauldron detect(BlockWorldVector pt) {
   Block block = pt.toBlock();
   // check if this looks at all like something we're interested in first
   if (block.getTypeId() == BlockID.AIR) return null;
   return new Cauldron(this.recipes, pt, plugin);
 }
예제 #27
0
 /**
  * Detect if a Block can be broken by a Player or by something else (Explosion...)
  *
  * @param b the Block to be broken
  * @param player the Player that want to break the Block, if there is one, null otherwise
  * @return true if the block can be broken [by the Player], false otherwise
  */
 public boolean canBreak(final Block b, final Player player) {
   final Material blockType = b.getType();
   final String userId = player != null ? PlayerIdsUtil.getId(player.getName()) : null;
   if (blockType == Material.SIGN_POST || blockType == Material.WALL_SIGN) {
     final Sign sign = (Sign) b.getState();
     return !sign.getLine(0).equals(PROTECTION)
         || player != null && ColorUtil.stripColorCodes(sign.getLine(3)).equals(userId)
         || player != null && Perms.hasProtectionSignBreak(player);
   } else {
     final List<Sign> signLines;
     if (blockType == Material.CHEST || blockType == Material.TRAPPED_CHEST) {
       signLines = SignUtil.getSignsForChest(b);
     } else if (getProtectedMaterials().contains(blockType)) {
       signLines = SignUtil.getSignsForBlock(b);
     } else {
       return true;
     }
     for (final Sign sign : signLines) {
       if (sign.getLine(0).equals(PROTECTION)) {
         return false;
       }
     }
     return true;
   }
 }
예제 #28
0
  public static void useJailStick(Player player) {
    Boolean enabled = Jail.jailStickToggle.get(player);
    if (enabled == null || !enabled) return;

    if (!InputOutput.global.getBoolean(Setting.EnableJailStick.getString(), false)
        || !InputOutput.jailStickParameters.containsKey(player.getItemInHand().getTypeId())) return;
    if (!Util.permission(
        player,
        "jail.usejailstick." + String.valueOf(player.getItemInHand().getTypeId()),
        PermissionDefault.OP)) return;
    String[] param = InputOutput.jailStickParameters.get(player.getItemInHand().getTypeId());

    List<Block> targets = player.getLineOfSight(null, Integer.parseInt(param[1]));
    for (Block b : targets) {
      for (Player p : Bukkit.getServer().getOnlinePlayers()) {
        if (p == player) continue;
        if ((b.getLocation().equals(p.getLocation().getBlock().getLocation())
                || b.getLocation().equals(p.getEyeLocation().getBlock().getLocation()))
            && Util.permission(player, "jail.canbestickjailed", PermissionDefault.TRUE)) {
          String args[] = new String[4];
          args[0] = p.getName();
          args[1] = param[2];
          args[2] = param[3];
          args[3] = param[4];
          PrisonerManager.PrepareJail((CommandSender) player, args);
        }
      }
    }
  }
예제 #29
0
 public void setBlockCheck(World w, int x, int y, int z, int m, byte d, int id) {
   // List of blocks that a door cannot be placed on
   List<Integer> ids =
       Arrays.asList(
           0, 6, 8, 9, 10, 11, 18, 20, 26, 27, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 44, 46,
           50, 51, 53, 54, 55, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 75, 76,
           77, 78, 79, 81, 83, 85, 89, 92, 93, 94, 96, 101, 102, 104, 105, 106, 107, 108, 109, 111,
           113, 114, 115, 116, 117, 118, 119, 120, 122, 128, 130, 131, 132, 134, 135, 136);
   Block b = w.getBlockAt(x, y, z);
   Integer bId = Integer.valueOf(b.getTypeId());
   byte bData = b.getData();
   Statement statement = null;
   if (ids.contains(bId)) {
     b.setTypeIdAndData(m, d, true);
     // remember replaced block location, TypeId and Data so we can restore it later
     try {
       Connection connection = service.getConnection();
       statement = connection.createStatement();
       String replaced = w.getName() + ":" + x + ":" + y + ":" + z + ":" + bId + ":" + bData;
       String queryReplaced =
           "UPDATE tardis SET replaced = '" + replaced + "' WHERE tardis_id = " + id;
       statement.executeUpdate(queryReplaced);
       statement.close();
     } catch (SQLException e) {
       plugin.console.sendMessage(plugin.pluginName + "Set Replaced Block Error: " + e);
     } finally {
       try {
         statement.close();
       } catch (Exception 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);
        }
      }
    }
  }