Package org.bukkit

Examples of org.bukkit.Material


 
  public boolean check(final Player player, final Block block, final Material placedMat, final Block blockAgainst, final BlockPlaceData data, final BlockPlaceConfig cc) {
    boolean violation = false;
    // TODO: Make more precise (workarounds like WATER_LILY, general points).
    // Workaround for signs on cactus and similar.
        final Material againstType = blockAgainst.getType();
        if (againstType == null || againstType == Material.AIR) {
          // Attempt to workaround blocks like cactus.
          final BlockInteractData bdata = BlockInteractData.getData(player);
          if (bdata.lastType != null && bdata.lastX != Integer.MAX_VALUE && TickTask.getTick() == bdata.lastTick && TrigUtil.manhattan(bdata.lastX, bdata.lastY, bdata.lastZ, blockAgainst) == 0) {
            // (Wide screen.)
View Full Code Here


            return;
       
        // TODO: Revise material use (not block.get... ?)
        //final Material mat = block.getType();
        final Player player = event.getPlayer();
        final Material placedMat = player.getItemInHand().getType(); // Safety first.
        boolean cancelled = false;
       
        final BlockPlaceData data = BlockPlaceData.getData(player);
        final BlockPlaceConfig cc = BlockPlaceConfig.getConfig(player);
       
View Full Code Here

      final Player player = event.getPlayer();
     
      final ItemStack stack = player.getItemInHand();
      if (stack == null) return;
     
      final Material type = stack.getType();
     
      if (type == Material.BOAT){
        // Check boats-anywhere.
          final org.bukkit.block.Block block = event.getClickedBlock();
          final Material mat = block.getType();
         
          // TODO: allow lava ?
          if (mat == Material.WATER || mat == Material.STATIONARY_WATER) return;
         
          final org.bukkit.block.Block relBlock = block.getRelative(event.getBlockFace());
          final Material relMat = relBlock.getType();
         
          // TODO: Placing inside of water, but not "against" ?
          if (relMat == Material.WATER || relMat == Material.STATIONARY_WATER) return;
         
          if (!player.hasPermission(Permissions.BLOCKPLACE_BOATSANYWHERE)){
View Full Code Here

                // Something between player
                // TODO: This might be a general check later.
                cancel = true;
              }
              else{
                final Material mat = player.getLocation(useLoc).getBlock().getType();
                final long flags = BlockProperties.F_CLIMBABLE | BlockProperties.F_LIQUID | BlockProperties.F_IGN_PASSABLE;
                if (mat != null && mat != Material.AIR && (BlockProperties.getBlockFlags(mat) & flags) == 0 && !mcAccess.hasGravity(mat)){
                  // Still fails on piston traps etc.
                  if (!BlockProperties.isPassable(player.getLocation(), projectile.getLocation()) && !BlockProperties.isOnGroundOrResetCond(player, player.getLocation(), MovingConfig.getConfig(player).yOnGround)){
                    cancel = true;
View Full Code Here

     * Check for material existence and naming (exact match).
     * @param id
     * @param name
     */
    public static void assertMaterialName(int id, String name) {
        Material mat = BlockProperties.getMaterial(id);
        if ( mat == null) {
            throw new RuntimeException("Material " + id + " does not exist.");
        }
        if (mat.name().equals(name)) {
            throw new RuntimeException("Name for Material " + id + " ('" + mat.name() + "') does not match '" + name + "'.");
        }
    }
View Full Code Here

     * Check for material existence and naming (parts must all be contained with ignored case).
     * @param id
     * @param parts
     */
    public static void assertMaterialNameMatch(int id, String... parts) {
        Material mat = BlockProperties.getMaterial(id);
        if ( mat == null) {
            throw new RuntimeException("Material " + id + " does not exist.");
        }
        String name = mat.name().toLowerCase();
        for (String part : parts) {
            if (name.indexOf(part.toLowerCase()) < 0) {
                throw new RuntimeException("Name for Material " + id + " ('" + mat.name() + "') should contain '" + part + "'.");
            }
        }
    }
View Full Code Here

       
        boolean resetAll = false;
       
        if (event.hasItem()){
            final ItemStack item = event.getItem();
            final Material type = item.getType();
            // TODO: Get Magic values (800) from the config.
            if (type == Material.BOW){
                final long now = System.currentTimeMillis();
                // It was a bow, the player starts to pull the string, remember this time.
                data.instantBowInteract = (data.instantBowInteract > 0 && now - data.instantBowInteract < 800) ? Math.min(System.currentTimeMillis(), data.instantBowInteract) : System.currentTimeMillis();
            }
            else if (type.isEdible() || type == Material.POTION || type == Material.MILK_BUCKET) {
                final long now = System.currentTimeMillis();
                // It was food, the player starts to eat some food, remember this time and the type of food.
                data.instantEatFood = type;
                data.instantEatInteract = (data.instantEatInteract > 0 && now - data.instantEatInteract < 800) ? Math.min(System.currentTimeMillis(), data.instantEatInteract) : System.currentTimeMillis();
                data.instantBowInteract = 0;
View Full Code Here

    public boolean check(final Player player, final Block block, final AlmostBoolean isInstaBreak, final BlockBreakConfig cc, final BlockBreakData data) {
      final long now = System.currentTimeMillis();
        boolean cancel = false;
       
        // Determine expected breaking time by block type.
        final Material blockType = block.getType();
        final long expectedBreakingTime = Math.max(0, Math.round((double) BlockProperties.getBreakingDuration(blockType, player) * (double) cc.fastBreakModSurvival / 100D));
     
        final long elapsedTime;
        // TODO: Concept for unbreakable blocks? Context: extreme VL.
        // TODO: Should it be breakingTime instead of 0 for inconsistencies?
        if (cc.fastBreakStrict) {
          // Counting interact...break.
          elapsedTime = (data.fastBreakBreakTime > data.fastBreakfirstDamage) ? 0 : now - data.fastBreakfirstDamage;
        }
        else {
          // Counting break...break.
          elapsedTime = (data.fastBreakBreakTime > now) ? 0 : now - data.fastBreakBreakTime;
        }
         
        // Check if the time used time is lower than expected.
        if (isInstaBreak.decideOptimistically()) {
          // Ignore those for now.
          // TODO: Find out why this was commented out long ago a) did not fix mcMMO b) exploits.
          // TODO: Maybe adjust time to min(time, SOMETHING) for MAYBE/YES.
        }
        else if (elapsedTime < 0) {
          // Ignore it. TODO: ?
        }
        else if (elapsedTime + cc.fastBreakDelay < expectedBreakingTime) {
        // lag or cheat or Minecraft.
         
        // Count in server side lag, if desired.
            final float lag = cc.lag ? TickTask.getLag(expectedBreakingTime, true) : 1f;
         
        final long missingTime = expectedBreakingTime - (long) (lag * elapsedTime);
       
        if (missingTime > 0) {
            // Add as penalty
            data.fastBreakPenalties.add(now, (float) missingTime);
           

            // Only raise a violation, if the total penalty score exceeds the contention duration (for lag, delay).
            if (data.fastBreakPenalties.score(cc.fastBreakBucketFactor) > cc.fastBreakGrace) {
              // TODO: maybe add one absolute penalty time for big amounts to stop breaking until then
                final double vlAdded = (double) missingTime / 1000.0;
              data.fastBreakVL += vlAdded;
              final ViolationData vd = new ViolationData(this, player, data.fastBreakVL, vlAdded, cc.fastBreakActions);
              if (vd.needsParameters()) {
                vd.setParameter(ParameterName.BLOCK_TYPE, blockType.toString());
                vd.setParameter(ParameterName.BLOCK_ID, Integer.toString(BlockProperties.getId(blockType)));
              }
              cancel = executeActions(vd);
            }
            // else: still within contention limits.
View Full Code Here

        }
       
        final int tick = TickTask.getTick();
        // Skip if already set to the same block without breaking within one tick difference.
        final ItemStack stack = player.getItemInHand();
        final Material tool = stack == null ? null: stack.getType();
        if (data.toolChanged(tool)) {
          // Update.
        } else if (tick < data.clickedTick || now < data.fastBreakfirstDamage || now < data.fastBreakBreakTime) {
          // Time/tick ran backwards: Update.
          // Tick running backwards should not happen in the main thread unless for reload. A plugin could reset it (not intended).
View Full Code Here

      // Take time once.
     
      final float amount;
     
      if (cursor != null && cc.fastClickTweaks1_5){
        final Material cursorMat = cursor.getType();
        final int cursorAmount = Math.max(1, cursor.getAmount());
        final Material clickedMat = clicked == null ? Material.AIR : clicked.getType();
        if (cursorMat != data.fastClickLastCursor && (!isShiftClick || clicked == null || clicked.getType() != data.fastClickLastClicked) || cursorMat == Material.AIR || cursorAmount != data.fastClickLastCursorAmount){
          amount = 1f;
        }
        else{
          if (clickedMat == Material.AIR || clickedMat == cursorMat || isShiftClick && clickedMat == data.fastClickLastClicked ){
View Full Code Here

TOP

Related Classes of org.bukkit.Material

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.