update UserBlockTracker API

This commit is contained in:
nossr50
2024-05-19 12:44:34 -07:00
parent c2054a5d45
commit 8b82163e3d
26 changed files with 708 additions and 468 deletions

View File

@@ -1,47 +0,0 @@
package com.gmail.nossr50.runnables;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.MetadataConstants;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import java.util.List;
public class PistonTrackerTask extends CancellableRunnable {
private final List<Block> blocks;
private final BlockFace direction;
private final Block futureEmptyBlock;
public PistonTrackerTask(List<Block> blocks, BlockFace direction, Block futureEmptyBlock) {
this.blocks = blocks;
this.direction = direction;
this.futureEmptyBlock = futureEmptyBlock;
}
@Override
public void run() {
// Check to see if futureEmptyBlock is empty - if it isn't; the blocks didn't move
if (!BlockUtils.isPistonPiece(futureEmptyBlock.getState())) {
return;
}
if (mcMMO.getPlaceStore().isTrue(futureEmptyBlock)) {
mcMMO.getPlaceStore().setFalse(futureEmptyBlock);
}
for (Block b : blocks) {
Block nextBlock = b.getRelative(direction);
if (nextBlock.hasMetadata(MetadataConstants.METADATA_KEY_PISTON_TRACKING)) {
BlockUtils.setUnnaturalBlock(nextBlock);
nextBlock.removeMetadata(MetadataConstants.METADATA_KEY_PISTON_TRACKING, mcMMO.p);
}
else if (mcMMO.getPlaceStore().isTrue(nextBlock)) {
// Block doesn't have metadatakey but isTrue - set it to false
mcMMO.getPlaceStore().setFalse(nextBlock);
}
}
}
}

View File

@@ -19,7 +19,7 @@ public class StickyPistonTrackerTask extends CancellableRunnable {
@Override
public void run() {
if (!mcMMO.getPlaceStore().isTrue(movedBlock.getRelative(direction))) {
if (!mcMMO.getPlaceStore().isIneligible(movedBlock.getRelative(direction))) {
return;
}
@@ -29,7 +29,7 @@ public class StickyPistonTrackerTask extends CancellableRunnable {
}
// The sticky piston actually pulled the block so move the PlaceStore data
mcMMO.getPlaceStore().setFalse(movedBlock.getRelative(direction));
mcMMO.getPlaceStore().setEligible(movedBlock.getRelative(direction));
BlockUtils.setUnnaturalBlock(movedBlock);
}
}

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.skills.alchemy.Alchemy;
import com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer;
import com.gmail.nossr50.util.CancellableRunnable;
import com.gmail.nossr50.util.ContainerMetadataUtils;
import com.gmail.nossr50.util.player.UserManager;
@@ -17,7 +16,6 @@ import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import static com.gmail.nossr50.skills.alchemy.AlchemyPotionBrewer.isValidBrew;
import static com.gmail.nossr50.util.EventUtils.getMcMMOPlayer;
public class AlchemyBrewCheckTask extends CancellableRunnable {
private final BrewingStand brewingStand;