Fixed duplication bug with sticky pistons

This commit is contained in:
bm01 2012-07-02 23:54:05 +02:00
parent 87f59cd3eb
commit f18a9bdcc7
3 changed files with 32 additions and 5 deletions

View File

@ -13,6 +13,7 @@ Version 1.3.10-dev
+ Added Ability API functions
+ Added 50% & 150% XP boost perks
+ Added "lucky" perk for donors
= Fixed duplication bug with sticky pistons
= Fixed "GenericLabel belonging to mcMMO..." message
= Fixed menu exit button not working
= Fixed Repair enchant downgrade not working

View File

@ -28,6 +28,7 @@ import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.runnables.StickyPistonTracker;
import com.gmail.nossr50.skills.gathering.Excavation;
import com.gmail.nossr50.skills.gathering.Herbalism;
import com.gmail.nossr50.skills.gathering.Mining;
@ -99,11 +100,9 @@ public class BlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
Block block = event.getRetractLocation().getBlock();
if (event.isSticky() && mcMMO.placeStore.isTrue(block)) {
mcMMO.placeStore.setFalse(block);
mcMMO.placeStore.setTrue(event.getBlock().getRelative(event.getDirection()));
if (event.isSticky()) {
//Needed only because under some circumstances Minecraft doesn't move the block
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StickyPistonTracker(event), 0);
}
}

View File

@ -0,0 +1,27 @@
package com.gmail.nossr50.runnables;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.block.BlockPistonRetractEvent;
import com.gmail.nossr50.mcMMO;
public class StickyPistonTracker implements Runnable {
BlockPistonRetractEvent event;
public StickyPistonTracker(BlockPistonRetractEvent event) {
this.event = event;
}
@Override
public void run() {
Block originalBlock = event.getRetractLocation().getBlock();
if (originalBlock.getType() == Material.AIR && mcMMO.placeStore.isTrue(originalBlock)) {
Block newBlock = originalBlock.getRelative(event.getDirection().getOppositeFace());
mcMMO.placeStore.setFalse(originalBlock);
mcMMO.placeStore.setTrue(newBlock);
}
}
}