Prechádzať zdrojové kódy

Sand/gravel exploit fix.

GJ 13 rokov pred
rodič
commit
37b5991dcc

+ 2 - 0
Changelog.txt

@@ -23,6 +23,8 @@ Version 2.0.00-dev
  = Fixed exploit where you could use /ptp to teleport to anyone
  = Fixed bug where Green Terra didn't work on Stone Brick
  = Fixed bug where Tree Feller could be used without permissions
+ = Fixed exploit where falling sand & gravel weren't tracked
+ ! Changed Chimera Wing failure check to use the maxWorldHeight.
  ! Changed inspect failed message to say inspect rather than whois
  ! Changed Call of the Wild to activate on left-click rather than right-click
  ! Changed Blast Mining to track based on Entity ID vs. Location

+ 1 - 1
src/main/java/com/gmail/nossr50/Item.java

@@ -37,7 +37,7 @@ public class Item {
             if (Skills.cooldownOver(player, PP.getRecentlyHurt(), 60) && amount >= itemsUsed) {
                 player.setItemInHand(new ItemStack(chimaeraID, amount - itemsUsed));
 
-                for (int blockY = block.getY(); blockY < 127; blockY++) {
+                for (int blockY = block.getY(); blockY < player.getWorld().getMaxHeight(); blockY++) {
                     if (player.getLocation().getWorld().getBlockAt(block.getX(), blockY, block.getZ()).getType() != Material.AIR) {
                         player.sendMessage(mcLocale.getString("Item.ChimaeraWingFail"));
                         player.teleport(player.getLocation().getWorld().getBlockAt(block.getX(), (blockY - 1), block.getZ()).getLocation());

+ 15 - 1
src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java

@@ -60,7 +60,21 @@ public class mcBlockListener implements Listener {
         int id = block.getTypeId();
         Material mat = block.getType();
 
-        //Check if the blocks placed should be monitored so they do not give out XP in the future
+        /* Code to prevent issues with placed falling Sand/Gravel not being tracked */
+        if (mat.equals(Material.SAND) || mat.equals(Material.GRAVEL)) {
+            for (int y = -1;  y + block.getY() >= 0 ; y--) {
+                if (block.getRelative(0, y, 0).getType().equals(Material.AIR)) {
+                    continue;
+                }
+                else {
+                    Block newLocation = block.getRelative(0, y+1, 0);
+                    newLocation.setData((byte) 0x5);
+                    break;
+                }
+            }
+        }
+
+        /* Check if the blocks placed should be monitored so they do not give out XP in the future */
         if (BlockChecks.shouldBeWatched(mat)) {
             BlockChecks.watchBlock(mat, block, plugin);
         }