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

@@ -65,7 +65,7 @@ public final class BlockUtils {
* @param block target block
*/
public static void setUnnaturalBlock(@NotNull Block block) {
mcMMO.getPlaceStore().setTrue(block);
mcMMO.getPlaceStore().setIneligible(block);
// Failsafe against lingering metadata
if (block.hasMetadata(MetadataConstants.METADATA_KEY_BONUS_DROPS))
@@ -82,7 +82,7 @@ public final class BlockUtils {
block.removeMetadata(MetadataConstants.METADATA_KEY_REPLANT, mcMMO.p);
}
mcMMO.getPlaceStore().setFalse(block);
mcMMO.getPlaceStore().setEligible(block);
}
/**

View File

@@ -1,7 +1,6 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.taming.TrackedTamingEntity;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;

View File

@@ -152,7 +152,7 @@ public class HashChunkManager implements ChunkManager {
}
}
private synchronized boolean isTrue(int x, int y, int z, @NotNull World world) {
private synchronized boolean isIneligible(int x, int y, int z, @NotNull World world) {
CoordinateKey chunkKey = blockCoordinateToChunkKey(world.getUID(), x, y, z);
// Get chunk, load from file if necessary
@@ -178,32 +178,42 @@ public class HashChunkManager implements ChunkManager {
}
@Override
public synchronized boolean isTrue(@NotNull Block block) {
return isTrue(block.getX(), block.getY(), block.getZ(), block.getWorld());
public synchronized boolean isIneligible(@NotNull Block block) {
return isIneligible(block.getX(), block.getY(), block.getZ(), block.getWorld());
}
@Override
public synchronized boolean isTrue(@NotNull BlockState blockState) {
return isTrue(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld());
public synchronized boolean isIneligible(@NotNull BlockState blockState) {
return isIneligible(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld());
}
@Override
public synchronized void setTrue(@NotNull Block block) {
public synchronized boolean isEligible(@NotNull Block block) {
return !isIneligible(block);
}
@Override
public synchronized boolean isEligible(@NotNull BlockState blockState) {
return !isIneligible(blockState);
}
@Override
public synchronized void setIneligible(@NotNull Block block) {
set(block.getX(), block.getY(), block.getZ(), block.getWorld(), true);
}
@Override
public synchronized void setTrue(@NotNull BlockState blockState) {
public synchronized void setIneligible(@NotNull BlockState blockState) {
set(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld(), true);
}
@Override
public synchronized void setFalse(@NotNull Block block) {
public synchronized void setEligible(@NotNull Block block) {
set(block.getX(), block.getY(), block.getZ(), block.getWorld(), false);
}
@Override
public synchronized void setFalse(@NotNull BlockState blockState) {
public synchronized void setEligible(@NotNull BlockState blockState) {
set(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld(), false);
}

View File

@@ -17,24 +17,34 @@ public class NullChunkManager implements ChunkManager {
public void unloadWorld(@NotNull World world) {}
@Override
public boolean isTrue(@NotNull Block block) {
public boolean isIneligible(@NotNull Block block) {
return false;
}
@Override
public boolean isTrue(@NotNull BlockState blockState) {
public boolean isIneligible(@NotNull BlockState blockState) {
return false;
}
@Override
public void setTrue(@NotNull Block block) {}
public boolean isEligible(@NotNull Block block) {
return false;
}
@Override
public void setTrue(@NotNull BlockState blockState) {}
public boolean isEligible(@NotNull BlockState blockState) {
return false;
}
@Override
public void setFalse(@NotNull Block block) {}
public void setIneligible(@NotNull Block block) {}
@Override
public void setFalse(@NotNull BlockState blockState) {}
public void setIneligible(@NotNull BlockState blockState) {}
@Override
public void setEligible(@NotNull Block block) {}
@Override
public void setEligible(@NotNull BlockState blockState) {}
}

View File

@@ -11,46 +11,136 @@ import org.jetbrains.annotations.NotNull;
*/
public interface UserBlockTracker {
/**
* Check to see if a given block location is set to true
* Check to see if a given {@link Block} is ineligible for rewards.
* This is a location-based lookup, and the other properties of the {@link Block} do not matter.
*
* @param block Block location to check
* @return true if the given block location is set to true, false if otherwise
* @param block Block to check
* @return true if the given block should not give rewards, false if otherwise
*/
boolean isTrue(@NotNull Block block);
boolean isIneligible(@NotNull Block block);
/**
* Check to see if a given BlockState location is set to true
* Check to see if a given {@link Block} is eligible for rewards.
* This is a location-based lookup, and the other properties of the {@link Block} do not matter.
*
* @param block Block to check
* @return true if the given block should give rewards, false if otherwise
*/
boolean isEligible(@NotNull Block block);
/**
* Check to see if a given {@link BlockState} is eligible for rewards.
* This is a location-based lookup, and the other properties of the {@link BlockState} do not matter.
*
* @param blockState BlockState to check
* @return true if the given BlockState location is set to true, false if otherwise
*/
boolean isTrue(@NotNull BlockState blockState);
boolean isEligible(@NotNull BlockState blockState);
/**
* Set a given block location to true
* Check to see if a given {@link BlockState} is ineligible for rewards.
* This is a location-based lookup, and the other properties of the {@link BlockState} do not matter.
*
* @param block Block location to set
* @param blockState BlockState to check
* @return true if the given BlockState location is set to true, false if otherwise
*/
void setTrue(@NotNull Block block);
boolean isIneligible(@NotNull BlockState blockState);
/**
* Set a given {@link Block} as ineligible for rewards.
* This is a location-based lookup, and the other properties of the {@link Block} do not matter.
*
* @param block block whose location to set as ineligible
*/
void setIneligible(@NotNull Block block);
/**
* Set a given BlockState location to true
*
* @param blockState BlockState location to set
*/
void setTrue(@NotNull BlockState blockState);
void setIneligible(@NotNull BlockState blockState);
/**
* Set a given block location to false
* Set a given {@link Block} as eligible for rewards.
* This is a location-based lookup, and the other properties of the {@link Block} do not matter.
*
* @param block Block location to set
* @param block block whose location to set as eligible
*/
void setFalse(@NotNull Block block);
void setEligible(@NotNull Block block);
/**
* Set a given BlockState location to false
*
* @param blockState BlockState location to set
*/
void setFalse(@NotNull BlockState blockState);
void setEligible(@NotNull BlockState blockState);
/**
* Check to see if a given block location is set to true
*
* @param block Block location to check
* @return true if the given block location is set to true, false if otherwise
* @deprecated Use {@link #isIneligible(Block)} instead
*/
@Deprecated(since = "2.2.013")
default boolean isTrue(@NotNull Block block) {
return isIneligible(block);
}
/**
* Check to see if a given BlockState location is set to true
*
* @param blockState BlockState to check
* @return true if the given BlockState location is set to true, false if otherwise
* @deprecated Use {@link #isIneligible(BlockState)} instead
*/
@Deprecated(since = "2.2.013")
default boolean isTrue(@NotNull BlockState blockState) {
return isIneligible(blockState);
}
/**
* Set a given block location to true
*
* @param block Block location to set
* @deprecated Use {@link #setIneligible(Block)} instead
*/
@Deprecated(since = "2.2.013")
default void setTrue(@NotNull Block block) {
setIneligible(block);
}
/**
* Set a given BlockState location to true
*
* @param blockState BlockState location to set
* @deprecated Use {@link #setIneligible(BlockState)} instead
*/
@Deprecated(since = "2.2.013")
default void setTrue(@NotNull BlockState blockState) {
setIneligible(blockState);
}
/**
* Set a given block location to false
*
* @param block Block location to set
* @deprecated Use {@link #setEligible(Block)} instead
*/
@Deprecated(since = "2.2.013")
default void setFalse(@NotNull Block block) {
setEligible(block);
}
/**
* Set a given BlockState location to false
*
* @param blockState BlockState location to set
* @deprecated Use {@link #setEligible(BlockState)} instead
*/
@Deprecated(since = "2.2.013")
default void setFalse(@NotNull BlockState blockState) {
setEligible(blockState);
}
}