コード例 #1
0
ファイル: BrokenBlock.java プロジェクト: Albuca/BigBrother
  private void surroundingSignChecks(String player, Block block) {
    int x = block.getX();
    int y = block.getY();
    int z = block.getZ();

    Block top = block.getWorld().getBlockAt(x, y + 1, z);
    if (top.getTypeId() == 63) {
      bystanders.add(new BrokenBlock(player, top, world));
    }
    Block north = block.getWorld().getBlockAt(x + 1, y, z);
    if (north.getTypeId() == 68 && north.getData() == 5) {
      bystanders.add(new BrokenBlock(player, north, world));
    }
    Block south = block.getWorld().getBlockAt(x - 1, y, z);
    if (south.getTypeId() == 68 && south.getData() == 4) {
      bystanders.add(new BrokenBlock(player, south, world));
    }
    Block east = block.getWorld().getBlockAt(x, y, z + 1);
    if (east.getTypeId() == 68 && east.getData() == 3) {
      bystanders.add(new BrokenBlock(player, east, world));
    }
    Block west = block.getWorld().getBlockAt(x, y, z - 1);
    if (west.getTypeId() == 68 && west.getData() == 2) {
      bystanders.add(new BrokenBlock(player, west, world));
    }
  }
コード例 #2
0
ファイル: Portal.java プロジェクト: akrieger/Nethrar
  public BlockData getWorldBlockType() {
    Block b1, b2;
    Material mat1, mat2;
    byte data1, data2;
    boolean legacyBlockFace = BlockFace.NORTH.getModX() == -1;
    // This all needs to be remathed. Ugh.
    if (legacyBlockFace) {
      if (this.facingNorth) {
        b1 = this.keyBlock.getRelative(BlockFace.UP, 3).getRelative(BlockFace.EAST);
        b2 = this.keyBlock.getRelative(BlockFace.UP, 3).getRelative(BlockFace.WEST, 2);
      } else {
        b1 = this.keyBlock.getRelative(BlockFace.UP, 3).getRelative(BlockFace.NORTH);
        b2 = this.keyBlock.getRelative(BlockFace.UP, 3).getRelative(BlockFace.SOUTH, 2);
      }
    } else {
      if (this.facingNorth) {
        b1 = this.keyBlock.getRelative(BlockFace.UP, 3).getRelative(BlockFace.NORTH);
        b2 = this.keyBlock.getRelative(BlockFace.UP, 3).getRelative(BlockFace.SOUTH, 2);
      } else {
        b1 = this.keyBlock.getRelative(BlockFace.UP, 3).getRelative(BlockFace.WEST);
        b2 = this.keyBlock.getRelative(BlockFace.UP, 3).getRelative(BlockFace.EAST, 2);
      }
    }

    mat1 = b1.getType();
    mat2 = b2.getType();
    data1 = b1.getData();
    data2 = b2.getData();

    if (mat1.equals(mat2) && data1 == data2) {
      return new BlockData(mat1, data1);
    }
    return null;
  }
コード例 #3
0
  @SuppressWarnings("deprecation")
  @EventHandler
  public void onPlayerMove(PlayerMoveEvent event) {
    Player p = event.getPlayer();
    Block b = p.getTargetBlock((Set<Material>) null, p.getGameMode() == GameMode.CREATIVE ? 5 : 4);
    PumpkinCheck check =
        new PumpkinCheck(p.getWorld().getBlockAt(b.getLocation()).getType(), b.getLocation());

    if (targetBlocks.containsKey(p) && targetBlocks.get(p).isPumpkin() && !check.isPumpkin()) {
      Block newBlock = p.getWorld().getBlockAt(targetBlocks.get(p).getLocation());
      byte data = newBlock.getData();

      newBlock.setType(Material.PUMPKIN);
      newBlock.setData(data);
    }

    targetBlocks.put(p, check);

    if (targetBlocks.get(p).isPumpkin()) {
      Block newBlock = p.getWorld().getBlockAt(targetBlocks.get(p).getLocation());
      byte data = newBlock.getData();

      newBlock.setType(Material.JACK_O_LANTERN);
      newBlock.setData(data);
    }
  }
コード例 #4
0
ファイル: BrokenBlock.java プロジェクト: Albuca/BigBrother
  private void torchCheck(String player, Block block) {
    ArrayList<Integer> torchTypes = new ArrayList<Integer>();
    torchTypes.add(50); // Torch
    torchTypes.add(75); // Redstone torch (on)
    torchTypes.add(76); // Redstone torch (off)

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

    Block torchTop = block.getWorld().getBlockAt(x, y + 1, z);

    if (torchTypes.contains(torchTop.getTypeId()) && torchTop.getData() == 5) {
      bystanders.add(new BrokenBlock(player, torchTop, world));
    }
    Block torchNorth = block.getWorld().getBlockAt(x + 1, y, z);
    if (torchTypes.contains(torchNorth.getTypeId()) && torchNorth.getData() == 1) {
      bystanders.add(new BrokenBlock(player, torchNorth, world));
    }
    Block torchSouth = block.getWorld().getBlockAt(x - 1, y, z);
    if (torchTypes.contains(torchSouth.getTypeId()) && torchSouth.getData() == 2) {
      bystanders.add(new BrokenBlock(player, torchSouth, world));
    }
    Block torchEast = block.getWorld().getBlockAt(x, y, z + 1);
    if (torchTypes.contains(torchEast.getTypeId()) && torchEast.getData() == 3) {
      bystanders.add(new BrokenBlock(player, torchEast, world));
    }
    Block torchWest = block.getWorld().getBlockAt(x, y, z - 1);
    if (torchTypes.contains(torchWest.getTypeId()) && torchWest.getData() == 4) {
      bystanders.add(new BrokenBlock(player, torchWest, world));
    }
  }
コード例 #5
0
ファイル: PixlableBlock.java プロジェクト: arooons/Pixl
 public void increment(Block source) {
   if (source.getData() < (data)) {
     source.setData((byte) (source.getData() + 1));
   } // add one
   else {
     source.setData((byte) (0));
   } // reset it
 }
コード例 #6
0
ファイル: LoggingUtil.java プロジェクト: Cube-Nation/LogBlock
  public static void smartLogFallables(Consumer consumer, String playerName, Block origin) {

    WorldConfig wcfg = getWorldConfig(origin.getWorld());
    if (wcfg == null) return;

    // Handle falling blocks
    Block checkBlock = origin.getRelative(BlockFace.UP);
    int up = 0;
    final int highestBlock = checkBlock.getWorld().getHighestBlockYAt(checkBlock.getLocation());
    while (BukkitUtils.getRelativeTopFallables().contains(checkBlock.getType())) {

      // Record this block as falling
      consumer.queueBlockBreak(playerName, checkBlock.getState());

      // Guess where the block is going (This could be thrown of by explosions, but it is better
      // than nothing)
      Location loc = origin.getLocation();
      int x = loc.getBlockX();
      int y = loc.getBlockY();
      int z = loc.getBlockZ();
      while (y > 0 && BukkitUtils.canFall(loc.getWorld(), x, (y - 1), z)) {
        y--;
      }
      // If y is 0 then the sand block fell out of the world :(
      if (y != 0) {
        Location finalLoc = new Location(loc.getWorld(), x, y, z);
        // Run this check to avoid false positives
        if (!BukkitUtils.getFallingEntityKillers().contains(finalLoc.getBlock().getType())) {
          finalLoc.add(0, up, 0); // Add this here after checking for block breakers
          if (finalLoc.getBlock().getType() == Material.AIR
              || BukkitUtils.getRelativeTopFallables().contains(finalLoc.getBlock().getType())) {
            consumer.queueBlockPlace(
                playerName, finalLoc, checkBlock.getTypeId(), checkBlock.getData());
          } else {
            consumer.queueBlockReplace(
                playerName,
                finalLoc,
                finalLoc.getBlock().getTypeId(),
                finalLoc.getBlock().getData(),
                checkBlock.getTypeId(),
                checkBlock.getData());
          }
          up++;
        }
      }
      if (checkBlock.getY() >= highestBlock) break;
      checkBlock = checkBlock.getRelative(BlockFace.UP);
    }
  }
コード例 #7
0
 @Override
 public void perform(Block b) {
   if (b.getTypeId() == ir && b.getData() == dr) {
     h.put(b);
     b.setTypeId(i, false);
   }
 }
コード例 #8
0
  /**
   * @param block
   * @param owner
   */
  public Unbreakable(Block block, String owner) {
    super(block.getX(), block.getY(), block.getZ(), block.getWorld().getName());

    this.owner = owner;
    this.type = new BlockTypeEntry(block.getTypeId(), block.getData());
    this.dirty = true;
  }
コード例 #9
0
ファイル: RainbowClay.java プロジェクト: JoniMega/Minicat
  @Override
  protected void onBlockBreak(BlockBreakEvent evt, Block blk) {
    // TODO Auto-generated method stub
    super.onBlockBreak(evt, blk);
    Player ply = evt.getPlayer();

    Cuboid cub = pMapaActual().ObtenirCuboid("RegC", getWorld());
    if (cub.contains(blk)) {
      evt.setCancelled(true);
    }
    if (blk.getType() != Material.HARD_CLAY && blk.getData() != 11) {
      //			if(blk.getType() == Material.BEACON){
      //				for (Objectiu obj : obtenirObjectiusPly(ply)){
      //
      //	//Bukkit.broadcastMessage(Double.toString(obj.getLocation().distance(blk.getLocation())));
      //					if (obj.getLocation().distance(blk.getLocation()) < 2){
      //						obj.complete(ply);
      //
      //					}
      //
      //				}
      //			}else{
      //
      //			}
      //			//Bukkit.broadcastMessage("Retard!");
    } else {
      evt.setCancelled(true);
    }
  }
コード例 #10
0
ファイル: TARDISUtils.java プロジェクト: BioDroid/TARDIS
 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) {
       }
     }
   }
 }
コード例 #11
0
ファイル: settlerTrait.java プロジェクト: marcosx86/Realms
  private boolean isCloseDoor(Location actual) {
    BlockFace[] blockFaces = {BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH};
    actual.setY(actual.getY());
    Block base = actual.getBlock();
    for (BlockFace bf : blockFaces) {
      Block bu = base.getRelative(bf);
      if ((bu.getType() == Material.WOODEN_DOOR)) {
        byte openData = 0x4;
        byte doorData = (byte) (bu.getData());
        if ((doorData & 0x4) == 0x4) {
          doorData = (byte) (doorData & 0x3);
        } else {
          doorData = (byte) (doorData | 0x7);
        }
        bu.setData(doorData);

        if ((bu.getRelative(BlockFace.UP).getType() == Material.WOODEN_DOOR)) {
          doorData = (byte) (bu.getRelative(BlockFace.UP).getData());
          if ((doorData & 0x1) == 1) {
            doorData = 0x9;
          } else {
            doorData = 0x8;
          }
          bu.getRelative(BlockFace.UP).setData(doorData);
        }
        return true;
      }
    }
    return false;
  }
コード例 #12
0
  public void storeClaimBackup(Claim claim, World world) {
    int baseX = getBase(claim.getX());
    long topX = claim.getX() >= 0 ? baseX + claimSize : baseX - claimSize;

    int baseZ = getBase(claim.getZ());
    long topZ = claim.getZ() >= 0 ? baseZ + claimSize : baseZ - claimSize;

    int maxY = world.getMaxHeight();

    Properties props = new Properties();

    for (int y = 0; y <= maxY; y++) {
      for (int z = baseZ; z <= topZ; z++) {
        for (int x = baseX; x <= topX; x++) {
          Block blockAt = world.getBlockAt(x, y, z);
          props.put(
              String.format("%d,%d,%d", x, y, z),
              String.format("%d:%d", blockAt.getTypeId(), blockAt.getData()));
        }
      }
    }

    File file = new File(backupFolder, String.format("claim-%d.xml"));

    try {
      props.storeToXML(
          new FileOutputStream(file), String.format("Claim backup for claim %d", claim.getId()));
    } catch (FileNotFoundException e) {
      logger.severe("Could not write backup to file" + file.getName());
    } catch (IOException e) {
      logger.severe("Could not write backup to file" + file.getName() + ": " + e.getMessage());
    }
  }
コード例 #13
0
  /**
   * Sets the toggled state of a single lever<br>
   * <b>No Lever type check is performed</b>
   *
   * @param lever block
   * @param down state to set to
   */
  private static void setLever(org.bukkit.block.Block lever, boolean down) {
    if (lever.getType() != Material.LEVER) {
      return;
    }

    byte data = lever.getData();
    int newData;
    if (down) {
      newData = data | 0x8;
    } else {
      newData = data & 0x7;
    }
    if (newData != data) {
      // CraftBukkit start - Redstone event for lever
      int old = !down ? 1 : 0;
      int current = down ? 1 : 0;
      BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(lever, old, current);
      Bukkit.getServer().getPluginManager().callEvent(eventRedstone);
      if ((eventRedstone.getNewCurrent() > 0) != down) {
        return;
      }
      // CraftBukkit end
      lever.setData((byte) newData, true);
      lever.getState().update();
      Block attached =
          lever.getRelative(((Attachable) lever.getState().getData()).getAttachedFace());
    }
  }
コード例 #14
0
ファイル: StormUtil.java プロジェクト: agaricusb/Storm
  /**
   * 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;
      }
    }
  }
コード例 #15
0
ファイル: TestReplacer.java プロジェクト: notaro1997/tregmine
  @Override
  public void changeBlock(Block block) {
    if (block.getTypeId() == match.getItemTypeId()
        && (match.getData() == 0 || block.getData() == match.getData())) {

      player.sendBlockChange(block.getLocation(), item.getItemType(), item.getData());
    }
  }
コード例 #16
0
 @EventHandler
 public void onPlayerMove(PlayerMoveEvent event) {
   if (event.getPlayer().isSprinting()) {
     if (FreedomOpModRemastered.plugin.getConfig().getBoolean("jumppads.speed")) {
       Location loc = event.getPlayer().getLocation();
       Block one =
           new Location(loc.getWorld(), loc.getX(), loc.getBlockY() - 1, loc.getZ()).getBlock();
       Block two =
           new Location(loc.getWorld(), loc.getX(), loc.getBlockY() - 2, loc.getZ()).getBlock();
       if (one.getType() == Material.WOOL
           && two.getType() == Material.PISTON_BASE
           && two.getData() == 0) {
         event
             .getPlayer()
             .setVelocity(
                 event
                     .getPlayer()
                     .getLocation()
                     .getDirection()
                     .multiply(
                         FreedomOpModRemastered.plugin
                             .getConfig()
                             .getDouble("jumppads.speedstrength"))
                     .setY(0));
       }
       one = new Location(loc.getWorld(), loc.getX(), loc.getBlockY() - 2, loc.getZ()).getBlock();
       two = new Location(loc.getWorld(), loc.getX(), loc.getBlockY() - 3, loc.getZ()).getBlock();
       if (one.getType() == Material.WOOL
           && two.getType() == Material.PISTON_BASE
           && two.getData() == 0) {
         event
             .getPlayer()
             .setVelocity(
                 event
                     .getPlayer()
                     .getLocation()
                     .getDirection()
                     .multiply(
                         FreedomOpModRemastered.plugin
                             .getConfig()
                             .getDouble("jumppads.speedstrength"))
                     .setY(0));
       }
     }
   }
 }
コード例 #17
0
ファイル: BrokenBlock.java プロジェクト: Albuca/BigBrother
 private void bedCheck(String player, Block bed) {
   if (bed.getType() == Material.BED_BLOCK) {
     if (bed.getData() >= 8) { // Head of bed
       Block foot = null;
       switch (bed.getData() - 8) {
         case (0): // Head is pointing West
           foot = bed.getWorld().getBlockAt(x, y, z - 1);
           bystanders.add(new BrokenBlock(player, foot, world, false));
           break;
         case (1): // Head is pointing North
           foot = bed.getWorld().getBlockAt(x + 1, y, z);
           bystanders.add(new BrokenBlock(player, foot, world, false));
           break;
         case (2): // Head is pointing East
           foot = bed.getWorld().getBlockAt(x, y, z + 1);
           bystanders.add(new BrokenBlock(player, foot, world, false));
           break;
         case (3): // Head is pointing South
           foot = bed.getWorld().getBlockAt(x - 1, y, z);
           bystanders.add(new BrokenBlock(player, foot, world, false));
           break;
       }
     } else { // Foot of bed
       Block head = null;
       switch (bed.getData()) {
         case (0): // Head is pointing West
           head = bed.getWorld().getBlockAt(x, y, z + 1);
           bystanders.add(new BrokenBlock(player, head, world, false));
           break;
         case (1): // Head is pointing North
           head = bed.getWorld().getBlockAt(x - 1, y, z);
           bystanders.add(new BrokenBlock(player, head, world, false));
           break;
         case (2): // Head is pointing East
           head = bed.getWorld().getBlockAt(x, y, z - 1);
           bystanders.add(new BrokenBlock(player, head, world, false));
           break;
         case (3): // Head is pointing South
           head = bed.getWorld().getBlockAt(x + 1, y, z);
           bystanders.add(new BrokenBlock(player, head, world, false));
           break;
       }
     }
   }
 }
コード例 #18
0
ファイル: DynmapPlugin.java プロジェクト: zybey/dynmap
 private void checkBlock(Block b, String trigger) {
   BlockToCheck btt = new BlockToCheck();
   btt.loc = b.getLocation();
   btt.typeid = b.getTypeId();
   btt.data = b.getData();
   btt.trigger = trigger;
   blocks_to_check_accum.add(btt); /* Add to accumulator */
   btth.startIfNeeded();
 }
コード例 #19
0
ファイル: pInkCombo.java プロジェクト: balr0g/VoxelSniper
  @Override
  public void perform(Block b) {
    if (b.getY() > 128 || b.getY() < 0) return;

    if (b.getTypeId() == ir && b.getData() == dr) {
      h.put(b);
      b.setData(d);
    }
  }
コード例 #20
0
  @EventHandler(priority = EventPriority.MONITOR)
  public void onBlockBreak(BlockBreakEvent e) {
    arbre = new ArrayList<Block>();

    if (e.isCancelled()) {
      return;
    }

    final Block initialBloc = e.getBlock();

    if (initialBloc.getTypeId() != 17) {
      return;
    }

    final byte data = initialBloc.getData();
    Player p = e.getPlayer();

    boolean permEntire = Methods.hasPerm(p, "amatree.entiretree");
    boolean permReplant = Methods.hasPerm(p, "amatree.replanting");

    if (!permEntire && !permReplant) {
      return;
    }

    if (permEntire) {
      gessThree(initialBloc);
      for (Block b : arbre) {
        breakFoliage(b);
        b.breakNaturally();
      }
    }

    if (permReplant) {
      int id = initialBloc.getRelative(BlockFace.DOWN).getTypeId();

      if (id != 2 && id != 3) {
        return;
      }

      Core.plugin
          .getServer()
          .getScheduler()
          .scheduleSyncDelayedTask(
              Core.plugin,
              new Runnable() {

                public void run() {
                  if (initialBloc.getTypeId() == 0) {
                    initialBloc.setTypeId(6);
                    initialBloc.setData(data);
                  }
                }
              },
              1 * 20L);
    }
  }
コード例 #21
0
 /**
  * Replaces a block with a new material and data, and after delay, restore it.
  *
  * @param b The block.
  * @param newType The new material.
  * @param newData The new data.
  * @param tickDelay The delay after which the block is restored.
  */
 public static void setToRestore(final Block b, Material newType, byte newData, int tickDelay) {
   if (blocksToRestore.containsKey(b.getLocation())) return;
   Block bUp = b.getRelative(BlockFace.UP);
   if (b.getType() != Material.AIR
       && b.getType() != Material.SIGN_POST
       && b.getType() != Material.CHEST
       && b.getType() != Material.STONE_PLATE
       && b.getType() != Material.WOOD_PLATE
       && b.getType() != Material.WALL_SIGN
       && b.getType() != Material.WALL_BANNER
       && b.getType() != Material.STANDING_BANNER
       && b.getType() != Material.CROPS
       && b.getType() != Material.LONG_GRASS
       && b.getType() != Material.SAPLING
       && b.getType() != Material.DEAD_BUSH
       && b.getType() != Material.RED_ROSE
       && b.getType() != Material.RED_MUSHROOM
       && b.getType() != Material.BROWN_MUSHROOM
       && b.getType() != Material.TORCH
       && b.getType() != Material.LADDER
       && b.getType() != Material.VINE
       && b.getType() != Material.DOUBLE_PLANT
       && b.getType() != Material.PORTAL
       && b.getType() != Material.CACTUS
       && b.getType() != Material.WATER
       && b.getType() != Material.STATIONARY_WATER
       && b.getType() != Material.LAVA
       && b.getType() != Material.STATIONARY_LAVA
       && b.getType() != Material.PORTAL
       && b.getType() != Material.ENDER_PORTAL
       && b.getType() != Material.SOIL
       && b.getType() != Material.BARRIER
       && b.getType() != Material.COMMAND
       && !isPortalBlock(b)
       && !isRocketBlock(b)
       && net.minecraft.server.v1_8_R3.Block.getById(b.getTypeId()).getMaterial().isSolid()
       && a(bUp)
       && b.getType().getId() != 43
       && b.getType().getId() != 44) {
     if (!blocksToRestore.containsKey(b.getLocation())) {
       blocksToRestore.put(b.getLocation(), b.getType().toString() + "," + b.getData());
       b.setType(newType);
       b.setData(newData);
       Bukkit.getScheduler()
           .runTaskLater(
               Core.getPlugin(),
               new Runnable() {
                 @Override
                 public void run() {
                   restoreBlockAt(b.getLocation());
                 }
               },
               tickDelay);
     }
   }
 }
コード例 #22
0
  /**
   * Gets the experience for a block break.
   *
   * @param block block
   * @return experience
   */
  public Double getExp(Block block) {

    Hashtable<Byte, Double> datas = blockExp.get(block.getType());
    if (datas == null) return 0.0;

    Double exp = datas.get(new Byte(block.getData()));
    if (exp == null) return 0.0;

    return exp;
  }
コード例 #23
0
ファイル: SpleefGame.java プロジェクト: AlfieC/Minigames
 @SuppressWarnings("all")
 @EventHandler
 public void onPlayerDamageBlock(BlockDamageEvent event) {
   if (Spectator.isSpectating(event.getPlayer())) {
     event.setCancelled(true);
     return;
   }
   event.setInstaBreak(true);
   Block block = event.getBlock();
   block.getWorld().spawnFallingBlock(block.getLocation(), block.getType(), block.getData());
 }
コード例 #24
0
 public static void woodCuttingProcCheck(Player player, Block block) {
   PlayerProfile PP = Users.getProfile(player);
   byte type = block.getData();
   Material mat = Material.getMaterial(block.getTypeId());
   if (player != null) {
     if (Math.random() * 1000 <= PP.getSkill("woodcutting")) {
       ItemStack item = new ItemStack(mat, 1, (short) 0, type);
       block.getWorld().dropItemNaturally(block.getLocation(), item);
     }
   }
 }
コード例 #25
0
  public void restoreChunk(
      Chunk chunk,
      int miny,
      boolean aggressiveMode,
      long delayInTicks,
      Player playerReceivingVisualization) {
    // build a snapshot of this chunk, including 1 block boundary outside of the chunk all the way
    // around
    int maxHeight = chunk.getWorld().getMaxHeight();
    BlockSnapshot[][][] snapshots = new BlockSnapshot[18][maxHeight][18];
    Block startBlock = chunk.getBlock(0, 0, 0);
    Location startLocation =
        new Location(chunk.getWorld(), startBlock.getX() - 1, 0, startBlock.getZ() - 1);
    for (int x = 0; x < snapshots.length; x++) {
      for (int z = 0; z < snapshots[0][0].length; z++) {
        for (int y = 0; y < snapshots[0].length; y++) {
          Block block =
              chunk
                  .getWorld()
                  .getBlockAt(
                      startLocation.getBlockX() + x,
                      startLocation.getBlockY() + y,
                      startLocation.getBlockZ() + z);
          snapshots[x][y][z] =
              new BlockSnapshot(block.getLocation(), block.getTypeId(), block.getData());
        }
      }
    }

    // create task to process those data in another thread
    Location lesserBoundaryCorner = chunk.getBlock(0, 0, 0).getLocation();
    Location greaterBoundaryCorner = chunk.getBlock(15, 0, 15).getLocation();

    // create task
    // when done processing, this task will create a main thread task to actually update the world
    // with processing results
    RestoreNatureProcessingTask task =
        new RestoreNatureProcessingTask(
            snapshots,
            miny,
            chunk.getWorld().getEnvironment(),
            lesserBoundaryCorner.getBlock().getBiome(),
            lesserBoundaryCorner,
            greaterBoundaryCorner,
            this.getSeaLevel(chunk.getWorld()),
            aggressiveMode,
            GriefPrevention.instance.creativeRulesApply(lesserBoundaryCorner),
            playerReceivingVisualization);
    GriefPrevention.instance
        .getServer()
        .getScheduler()
        .runTaskLaterAsynchronously(GriefPrevention.instance, task, delayInTicks);
  }
コード例 #26
0
ファイル: AlterSpell.java プロジェクト: S-Toad/MagicPlugin
  @SuppressWarnings("deprecation")
  @Override
  public SpellResult onCast(ConfigurationSection parameters) {
    Target target = getTarget();
    if (target.hasEntity()) {
      SpellResult result = alterEntity(target.getEntity());
      if (result != SpellResult.NO_TARGET) {
        return result;
      }
    }
    Block targetBlock = target.getBlock();
    if (targetBlock == null) {
      return SpellResult.NO_TARGET;
    }

    int recurseDistance = parameters.getInt("depth", DEFAULT_RECURSE_DISTANCE);
    recurseDistance = (int) (mage.getRadiusMultiplier() * recurseDistance);

    List<Integer> adjustableMaterials = parseIntegers(DEFAULT_ADJUSTABLES);
    List<Integer> maxData = parseIntegers(DEFAULT_ADJUST_MAX);
    List<Integer> minData = parseIntegers(DEFAULT_ADJUST_MIN);

    if (adjustableMaterials.size() != maxData.size() || maxData.size() != minData.size()) {
      controller.getLogger().warning("Spells:Alter: Mis-match in adjustable material lists!");
    }

    if (!adjustableMaterials.contains(targetBlock.getTypeId())) {
      return SpellResult.FAIL;
    }
    if (!hasBuildPermission(targetBlock)) {
      return SpellResult.INSUFFICIENT_PERMISSION;
    }
    if (mage.isIndestructible(targetBlock)) {
      return SpellResult.NO_TARGET;
    }
    if (!isDestructible(targetBlock)) {
      return SpellResult.NO_TARGET;
    }

    int originalData = targetBlock.getData();

    int materialIndex = adjustableMaterials.indexOf(targetBlock.getTypeId());
    int minValue = minData.get(materialIndex);
    int maxValue = maxData.get(materialIndex);
    int dataSize = maxValue - minValue + 1;

    byte data = (byte) ((((originalData - minValue) + 1) % dataSize) + minValue);

    boolean recursive = recurseDistance > 0;
    adjust(targetBlock, data, recursive, recurseDistance, 0);
    registerForUndo();
    return SpellResult.CAST;
  }
コード例 #27
0
  public static void blockcheck(Block block, Player player, RpgEssentials plugin) {

    int addexp;
    String skilltype = "Woodcutting";
    if (block.getType() == Material.LOG) {
      // normal log
      if (block.getData() == (byte) 0) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Oak Log");
        LevelingSystem.addexp(player, skilltype, addexp, plugin);
        // redwood
      } else if (block.getData() == (byte) 1) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Redwood Log");
        LevelingSystem.addexp(player, skilltype, addexp, plugin);
        // birch
      } else if (block.getData() == (byte) 2) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Birch Log");
        LevelingSystem.addexp(player, skilltype, addexp, plugin);
      }
    } else if (block.getType() == Material.WOOD) {
      addexp = Configuration.level.getInt("Exp." + skilltype + ".Wood");
      LevelingSystem.addexp(player, skilltype, addexp, plugin);
    } else if (block.getType() == Material.FENCE) {
      addexp = Configuration.level.getInt("Exp." + skilltype + ".Fence");
      LevelingSystem.addexp(player, skilltype, addexp, plugin);
    } else if (block.getType() == Material.STEP) {
      if (block.getData() == (byte) 2) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Wood Slab");
        LevelingSystem.addexp(player, skilltype, addexp, plugin);
      }
    } else if (block.getType() == Material.DOUBLE_STEP) {
      if (block.getData() == (byte) 2) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Wood Slab");
        LevelingSystem.addexp(player, skilltype, addexp + 5, plugin);
      }
    } else if (block.getType() == Material.WOOD_STAIRS) {
      addexp = Configuration.level.getInt("Exp." + skilltype + ".Wood Stairs");
      LevelingSystem.addexp(player, skilltype, addexp + 5, plugin);
    }
  }
コード例 #28
0
 @EventHandler(ignoreCancelled = true)
 public void onBlockPistonRetract(BlockPistonRetractEvent event) {
   Block piston = event.getBlock();
   Block extension = piston.getRelative(event.getDirection());
   Block block = extension.getRelative(event.getDirection());
   Deadbolted db = Deadbolt.get(block);
   if (db.isProtected()) {
     // TODO why cant we just cancel
     event.setCancelled(true);
     piston.setData((byte) (piston.getData() ^ 0x8));
     extension.setType(Material.AIR);
   }
 }
コード例 #29
0
 private void setSignCoords(int id, int line) {
   // get the destination sign
   Sign s = getDestinationSign(id);
   // get repeater data
   Block r = getControlBlock(id, 2);
   // get comparator data
   Block c = getControlBlock(id, 3);
   if (s != null && r != null && c != null) {
     String txt = s.getLine(line);
     if (txt.isEmpty()) {
       txt = "0";
     }
     int multiplier = repeaterMap.get(r.getData());
     int positiveNegative = (c.getData() == 3) ? 1 : -1;
     // get current coord
     int current = TARDISNumberParsers.parseInt(txt);
     // increment / decrement sign coord value
     int amount = current + (multiplier * positiveNegative);
     s.setLine(line, "" + amount);
     s.update();
   }
 }
コード例 #30
0
ファイル: SkillLight.java プロジェクト: LarsDenBakker/Heroes
 @Override
 public void apply(Hero hero) {
   super.apply(hero);
   Player p = hero.getPlayer();
   broadcast(p.getLocation(), applyText, p.getDisplayName());
   Block thisBlock = p.getLocation().getBlock().getRelative(BlockFace.DOWN);
   if (allowedBlocks.contains(thisBlock.getType())) {
     lastLoc = thisBlock.getLocation();
     lastMat = thisBlock.getType();
     lastData = thisBlock.getData();
     p.sendBlockChange(lastLoc, Material.GLOWSTONE, (byte) 0);
   }
 }