Package com.viaversion.nbt.limiter
Interface TagLimiter
public interface TagLimiter
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionintbytes()Returns the amount of currently read bytes.voidcheckLevel(int nestedLevel) Checks the current level of nesting and throws an exception if it exceeds the max levels.default voidvoidcountBytes(int bytes) Counts the given number of bytes and throws an exception if the max bytes count is exceeded.default voiddefault voiddefault voidcountInt()default voiddefault voidstatic TagLimitercreate(int maxBytes, int maxLevels) Returns a new tag limiter with the given max bytes and nesting levels.intmaxBytes()Returns the max number of bytes to be read before an exception is thrown when reading nbt.intReturns the max number of levels of nesting before an exception is thrown when reading nbt.static TagLimiternoop()Returns a noop tag limiter.voidreset()Resets the current byte count.
-
Field Details
-
DEFAULT_MAX_BYTES
static final int DEFAULT_MAX_BYTES- See Also:
-
DEFAULT_MAX_NESTING_LEVEL
static final int DEFAULT_MAX_NESTING_LEVEL- See Also:
-
-
Method Details
-
create
Returns a new tag limiter with the given max bytes and nesting levels.- Parameters:
maxBytes- max amount of bytes to be read before an exception is thrown when reading nbtmaxLevels- max levels of nesting before an exception is thrown when reading nbt- Returns:
- tag limiter
-
noop
Returns a noop tag limiter.- Returns:
- noop tag limiter
-
countBytes
void countBytes(int bytes) Counts the given number of bytes and throws an exception if the max bytes count is exceeded.- Parameters:
bytes- bytes to count- Throws:
IllegalArgumentException- if max bytes count is exceeded
-
checkLevel
void checkLevel(int nestedLevel) Checks the current level of nesting and throws an exception if it exceeds the max levels.- Parameters:
nestedLevel- current level of nesting- Throws:
IllegalArgumentException- if max level count is exceeded
-
countByte
default void countByte() -
countShort
default void countShort() -
countInt
default void countInt() -
countFloat
default void countFloat() -
countLong
default void countLong() -
countDouble
default void countDouble() -
maxBytes
int maxBytes()Returns the max number of bytes to be read before an exception is thrown when reading nbt.- Returns:
- max bytes
-
maxLevels
int maxLevels()Returns the max number of levels of nesting before an exception is thrown when reading nbt.- Returns:
- max nesting levels
-
bytes
int bytes()Returns the amount of currently read bytes.- Returns:
- currently read bytes
-
reset
void reset()Resets the current byte count.
-