Class PlanetLimits
java.lang.Object
ua.mcchickenstudio.opencreative.planets.PlanetLimits
PlanetLimits
This class represents all limits of the planet.
Use it to check if the limit is reached or not.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if bee for beehive can spawn in world to prevent "too many bees at once" crash.booleanChecks if world can strike lightning.booleanChecks if world can send web request.booleancantLoadOrSaveInventory(org.bukkit.entity.Player player) Checks if world can load or save player's inventory.booleancantModifyBlock(@NotNull Action action) Checks whether block cannot be placed, destroyed or modified, because of reaching the limit.booleancantOpenMenu(org.bukkit.entity.Player player) Checks if world can open custom menu for player.voidclear()Clears data on planet unload.voidClears modified blocks amount.voidclearPlayerLimits(org.bukkit.entity.Player player) Clears player's data when player leaves planet.intReturns maximum blacklisted players amount in the planet.intReturns maximum bossbars amount in the planet.intReturns maximum builders amount in the planet.intReturns maximum code operations amount in the planet.intReturns maximum actions calls amount per time in the planet.intReturns maximum coding errors amount in the planet.intReturns maximum coding platforms amount in the planet.intReturns maximum developers amount in the planet.intReturns maximum entities amount in the planet.intReturns last coding errors amount from last 3 seconds.intReturns last modified blocks amount.intReturns last modified targets amount.intReturns last redstone operations amount.intReturns last elements changes amount in lists or maps.intReturns modifying blocks limit.intReturns maximum amount of opening or closing inventories for player in the last 5 seconds.intReturns maximum physical objects limit in the planet.intReturns maximum recipes amount in the planet.intReturns maximum redstone operations amount in the planet.intReturns maximum repeats activations per 1 second amount in the planet.intReturns maximum scoreboards amount in the planet.intReturns maximum targets changes per 1 second amount in the planet.intReturns maximum elements changes amount in the planet.intReturns limit of all variables' size in the planet.intReturns maximum amount of sending web requests in the last 5 seconds.intReturns maximum whitelisted players amount in the planet.booleanisTooManyActionsAtOnce(int count) Checks whether coding encountered too many actions in the last 3 seconds.booleanChecks whether coding encountered too many errors in the last 3 seconds.booleanChecks if world has a lot of explosions in a short time.booleanChecks if world has a lot of spawned mobs by spawner block.booleanChecks whether coding encountered too many recipe operations in the last 3 seconds.voidsetLastModifiedBlocksAmount(int lastModifiedBlocksAmount) Sets last modified blocks amount.voidsetLastModifiedTargetsAmount(int lastModifiedTargetsAmount) Sets last modified targets amount.voidsetLastRedstoneOperationsAmount(int lastRedstoneOperationsAmount) Sets last redstone operations amount.voidsetLastVariableElementsChangesAmount(int changedElementsAmount) Sets last amount of changed elements in lists or maps.
-
Constructor Details
-
PlanetLimits
-
-
Method Details
-
getVariablesAmountLimit
public int getVariablesAmountLimit()Returns limit of all variables' size in the planet. If the value of a variable is map, keys' amount will be added to size. If the value of a variable is list, elements' amount will be added to size.- Returns:
- limit of variables size.
-
getModifyingBlocksLimit
public int getModifyingBlocksLimit()Returns modifying blocks limit.- Returns:
- limit of changing blocks.
-
getBuildersLimit
public int getBuildersLimit()Returns maximum builders amount in the planet.- Returns:
- limit of builders amount.
-
getDevelopersLimit
public int getDevelopersLimit()Returns maximum developers amount in the planet.- Returns:
- limit of developers amount.
-
getBlacklistedLimit
public int getBlacklistedLimit()Returns maximum blacklisted players amount in the planet.- Returns:
- limit of banned players amount.
-
getCodingActionsCallsLimit
public int getCodingActionsCallsLimit()Returns maximum actions calls amount per time in the planet.- Returns:
- limit of actions calls amount.
-
getWhitelistedLimit
public int getWhitelistedLimit()Returns maximum whitelisted players amount in the planet.- Returns:
- limit of whitelisted players amount.
-
getRedstoneOperationsLimit
public int getRedstoneOperationsLimit()Returns maximum redstone operations amount in the planet.- Returns:
- limit of redstone operations.
-
getTargetsChangesLimit
public int getTargetsChangesLimit()Returns maximum targets changes per 1 second amount in the planet.- Returns:
- limit of changed targets.
-
getRepeatsAmountLimit
public int getRepeatsAmountLimit()Returns maximum repeats activations per 1 second amount in the planet.- Returns:
- limit of repeats.
-
getCodeOperationsLimit
public int getCodeOperationsLimit()Returns maximum code operations amount in the planet.- Returns:
- limit of executor calls.
-
getCodingErrorsLimit
public int getCodingErrorsLimit()Returns maximum coding errors amount in the planet.- Returns:
- limit of errors amount.
-
getOpeningInventoriesLimit
public int getOpeningInventoriesLimit()Returns maximum amount of opening or closing inventories for player in the last 5 seconds.- Returns:
- limit of inventory actions.
-
getWebRequestsLimit
public int getWebRequestsLimit()Returns maximum amount of sending web requests in the last 5 seconds.- Returns:
- limit of web requests.
-
getEntitiesLimit
public int getEntitiesLimit()Returns maximum entities amount in the planet.- Returns:
- limit of entities.
-
getRecipesLimit
public int getRecipesLimit()Returns maximum recipes amount in the planet.- Returns:
- limit of recipes.
-
getScoreboardsLimit
public int getScoreboardsLimit()Returns maximum scoreboards amount in the planet.- Returns:
- limit of scoreboards.
-
getVariableElementsChangesLimit
public int getVariableElementsChangesLimit()Returns maximum elements changes amount in the planet.- Returns:
- limit of scoreboards.
-
getBossBarsLimit
public int getBossBarsLimit()Returns maximum bossbars amount in the planet.- Returns:
- limit of bossbars.
-
getPhysicalObjectsLimit
public int getPhysicalObjectsLimit()Returns maximum physical objects limit in the planet. It's not related to sand, gravel, anvil and other blocks, they are related to entities.- Returns:
- limit of physical objects.
-
getLastModifiedBlocksAmount
public int getLastModifiedBlocksAmount()Returns last modified blocks amount.- Returns:
- number of modified blocks.
-
setLastModifiedBlocksAmount
public void setLastModifiedBlocksAmount(int lastModifiedBlocksAmount) Sets last modified blocks amount.- Parameters:
lastModifiedBlocksAmount- number of changed blocks.
-
getLastCodingErrorsAmount
public int getLastCodingErrorsAmount()Returns last coding errors amount from last 3 seconds.- Returns:
- amount of coding errors in last 3 seconds.
-
getLastModifiedTargetsAmount
public int getLastModifiedTargetsAmount()Returns last modified targets amount.- Returns:
- number of changed targets.
-
setLastModifiedTargetsAmount
public void setLastModifiedTargetsAmount(int lastModifiedTargetsAmount) Sets last modified targets amount.- Parameters:
lastModifiedTargetsAmount- number of changed targets.
-
getLastRedstoneOperationsAmount
public int getLastRedstoneOperationsAmount()Returns last redstone operations amount.- Returns:
- number of redstone operations.
-
setLastRedstoneOperationsAmount
public void setLastRedstoneOperationsAmount(int lastRedstoneOperationsAmount) Sets last redstone operations amount.- Parameters:
lastRedstoneOperationsAmount- number of redstone operations.
-
getLastVariableElementsChangesAmount
public int getLastVariableElementsChangesAmount()Returns last elements changes amount in lists or maps.- Returns:
- number of elements changes.
-
setLastVariableElementsChangesAmount
public void setLastVariableElementsChangesAmount(int changedElementsAmount) Sets last amount of changed elements in lists or maps.- Parameters:
changedElementsAmount- number of changed elements.
-
getCodingPlatformsLimit
public int getCodingPlatformsLimit()Returns maximum coding platforms amount in the planet. Doesn't change with players' amount.- Returns:
- limit of coding platforms.
-
canLightningStrike
public boolean canLightningStrike()Checks if world can strike lightning. Used to prevent "too many lightning strikes" crash. Checks if the amount of lightning strikes in last 5 seconds is not greater than 5.- Returns:
- true - if it's allowed to strike lightning, false - it's disallowed.
-
cantLoadOrSaveInventory
public boolean cantLoadOrSaveInventory(org.bukkit.entity.Player player) Checks if world can load or save player's inventory. Checks if the amount of inventory operations in last 5 seconds is greater than 5.- Returns:
- true - if it's allowed to load or save inventory, false - it's disallowed.
-
canBeeSpawnFromBeehive
public boolean canBeeSpawnFromBeehive()Checks if bee for beehive can spawn in world to prevent "too many bees at once" crash. Checks if the amount of spawned bees in last 5 seconds is not greater than 5.- Returns:
- true - if it's allowed to exit from beehive for bee, false - it's disallowed.
-
isTooManyExplosionsAtOnce
public boolean isTooManyExplosionsAtOnce()Checks if world has a lot of explosions in a short time. Useful to prevent "too many explosions" crash.- Returns:
- true - if it's disallowed to create an explosion, false - it's allowed.
-
isTooManyMobSpawnsBySpawner
public boolean isTooManyMobSpawnsBySpawner()Checks if world has a lot of spawned mobs by spawner block. Useful to prevent "too many spawns" crash.- Returns:
- true - if it's disallowed to spawn a mob by spawner, false - it's allowed.
-
canSendWebRequest
public boolean canSendWebRequest()Checks if world can send web request. Used to prevent web attacks. Checks if the amount of sent web requests in last 5 seconds is not greater than limit.- Returns:
- true - if it's allowed to strike lightning, false - it's disallowed.
-
isTooManyCodingErrors
public boolean isTooManyCodingErrors()Checks whether coding encountered too many errors in the last 3 seconds.- Returns:
- true - must stop the code, false - few or no errors.
-
isTooManyActionsAtOnce
public boolean isTooManyActionsAtOnce(int count) Checks whether coding encountered too many actions in the last 3 seconds.- Returns:
- true - must stop the code, false - few or no actions.
-
isTooManyRecipeOperationsAtOnce
public boolean isTooManyRecipeOperationsAtOnce()Checks whether coding encountered too many recipe operations in the last 3 seconds.- Returns:
- true - must throw the error, false - few or no recipe operations.
-
cantModifyBlock
Checks whether block cannot be placed, destroyed or modified, because of reaching the limit.- Parameters:
action- action, that changes block.- Returns:
- true - cannot modify block, action should stop; false - can.
-
clearModifiedBlocks
public void clearModifiedBlocks()Clears modified blocks amount. -
cantOpenMenu
public boolean cantOpenMenu(org.bukkit.entity.Player player) Checks if world can open custom menu for player. Used to prevent unavailability of leaving game. Checks if the amount of player's opened menus in last 5 seconds is not greater than limit.- Returns:
- true - if it's allowed to open menu, false - it's disallowed.
-
clearPlayerLimits
public void clearPlayerLimits(org.bukkit.entity.Player player) Clears player's data when player leaves planet.- Parameters:
player- player to clear data.
-
clear
public void clear()Clears data on planet unload.
-