Class ErrorUtils
ErrorUtils
This class contains utilities for handling exceptions and logging them in console with friendly look.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcutClassesName(@Nullable String text) Cuts common packages paths from stack trace text.static voidnotifyBuildModeByCode(Executor executor, Action action) static @NotNull StringparseException(@NotNull Exception error, boolean colored) Parses exception into user-friendly message, that can be printed into console or sent to player.static voidsendCodingDebugAction(Action action) Sends notification to planet players about action information, that will be executed.static voidsendCodingDebugExecutor(Executor executor) Sends notification to planet players about calling executor.static voidsendCodingDebugLog(Planet planet, String log) Sends debug log message to planet players, if planet's debug mode is enabled.static voidsendCodingDebugNotFoundVariable(Planet planet, String name) Sends notification to planet players about not found value while filling arguments in action, only if planet's debug mode is enabled.static voidsendCodingDebugVariable(Planet planet, String name, Object value) Sends notification to planet players about found value while filling arguments in action, only if planet's debug mode is enabled.static voidsendCodingNotFoundEventValue(Planet planet, Executor executor, Class<? extends EventValue> clazz) Sends notification to planet players about not found event value while executing actions or conditions, that require event value.static voidsendCriticalErrorMessage(String errorMessage) Sends error log in console about problem with plugin.static voidsendCriticalErrorMessage(String errorMessage, Exception error) Sends error log in console with stack traces to find line, that produced critical error.static voidSends debug log in console, only if debug mode is enabled in plugin's settings.static voidsendDebugError(String errorMessage, Exception error) Sends error log in console with stack traces, only if debug mode is enabled in plugin's settings.static voidsendPlanetCodeCriticalErrorMessage(Planet planet, Executor executor, String errorMessage) Notifies planet players about coding fatal error, that has happened while executing code.static voidsendPlanetCodeErrorMessage(Executor executor, Action action, String errorMessage, Exception error) Notifies planet players about coding exception, that has happened while executing action in executor.static voidsendPlanetCodeErrorMessage(Executor executor, Action action, org.bukkit.entity.Entity entity, String errorMessage) Notifies planet players about coding exception, that has happened while executing action in executor.static voidsendPlanetCodeErrorMessage(Planet planet, Executor executor, String errorMessage) Notifies planet players about coding exception, that has happened while executing action in executor.static voidsendPlanetCodeWarningMessage(@NotNull Executor executor, @NotNull Action action, @NotNull String warningID, @NotNull PlaceholderReplacer placeholder) Notifies planet players about coding warning, that has happened while executing action in executor.static voidsendPlanetCompileErrorMessage(Planet planet, List<org.bukkit.block.Block> unknownBlocks) Notifies planet players about unknown coding blocks, that were found while compiling a new code from dev planet.static voidsendPlanetCompileErrorMessage(Planet planet, org.bukkit.block.Block block, String errorMessage) Notifies planet players about coding issue, that has happened while compiling new code from dev planet.static voidsendPlanetErrorMessage(@NotNull Planet planet, @NotNull String error) Notifies planet players about general error by sending message with error description in chat and sends warning log in console.static voidsendPlanetErrorMessage(Planet planet, String errorMessage, Exception error) Notifies planet players about general error by sending message with error description in chat and sends warning log in console with stack traces to find line, where error has occurred.static voidsendPlanetLimitWarningMessage(@NotNull Action action, @NotNull String limitID, int count, int limit) Notifies planet players about reaching limit, so some operations will be cancelled.static voidsendPlanetLimitWarningMessage(@NotNull Planet planet, @NotNull String limitID, @Nullable String command, int count, int limit) Notifies planet players about reaching limit, so some operations will be canceled.static voidsendPlayerErrorMessage(org.bukkit.entity.Player player, String errorMessage) Notifies player about error by sending message with error description in chat and sends warning log in console.static voidsendPlayerErrorMessage(org.bukkit.entity.Player player, String errorMessage, Exception error) Notifies player about error by sending message with error description in chat and sends warning log in console with stack traces to find line, where error has occurred.static voidsendWarningErrorMessage(String warning) Sends warning log in console about issue with plugin.static voidsendWarningMessage(String errorMessage, Exception error) Sends warning log in console with stack traces to find line, that produced not too serious error.
-
Constructor Details
-
ErrorUtils
public ErrorUtils()
-
-
Method Details
-
cutClassesName
-
parseException
@NotNull public static @NotNull String parseException(@NotNull @NotNull Exception error, boolean colored) Parses exception into user-friendly message, that can be printed into console or sent to player.- Parameters:
error- exception to parse.colored- true - for player, false - for console.- Returns:
- user-friendly exception.
-
sendPlayerErrorMessage
Notifies player about error by sending message with error description in chat and sends warning log in console.- Parameters:
player- player to send error message.errorMessage- message of exception.
-
sendPlayerErrorMessage
public static void sendPlayerErrorMessage(org.bukkit.entity.Player player, String errorMessage, Exception error) Notifies player about error by sending message with error description in chat and sends warning log in console with stack traces to find line, where error has occurred.- Parameters:
player- player to send error message.errorMessage- description of error.error- exception, that has occurred.
-
sendPlanetErrorMessage
public static void sendPlanetErrorMessage(@NotNull @NotNull Planet planet, @NotNull @NotNull String error) Notifies planet players about general error by sending message with error description in chat and sends warning log in console.Not related to coding errors.
- Parameters:
planet- planet to send error message.error- description of error.
-
sendPlanetErrorMessage
Notifies planet players about general error by sending message with error description in chat and sends warning log in console with stack traces to find line, where error has occurred.Not related to coding errors.
- Parameters:
planet- planet to send error message.errorMessage- description of error.error- exception, that has occurred.
-
sendPlanetLimitWarningMessage
public static void sendPlanetLimitWarningMessage(@NotNull @NotNull Action action, @NotNull @NotNull String limitID, int count, int limit) Notifies planet players about reaching limit, so some operations will be cancelled.- Parameters:
action- action, that produced warning.limitID- limit name.count- count of operations.limit- maximum amount of operations.
-
sendPlanetLimitWarningMessage
public static void sendPlanetLimitWarningMessage(@NotNull @NotNull Planet planet, @NotNull @NotNull String limitID, @Nullable @Nullable String command, int count, int limit) Notifies planet players about reaching limit, so some operations will be canceled.- Parameters:
planet- planet, where limit was reached.limitID- limit name.command- command to execute on click.count- count of operations.limit- maximum amount of operations.
-
sendPlanetCodeWarningMessage
public static void sendPlanetCodeWarningMessage(@NotNull @NotNull Executor executor, @NotNull @NotNull Action action, @NotNull @NotNull String warningID, @NotNull @NotNull PlaceholderReplacer placeholder) Notifies planet players about coding warning, that has happened while executing action in executor.Warnings don't stop executing the code, they just send notification, that something can be improved.
- Parameters:
executor- executor, that executed action.action- action, that produced warning.warningID- path of warning message.placeholder- placeholders to replace.
-
sendPlanetCodeErrorMessage
public static void sendPlanetCodeErrorMessage(Executor executor, Action action, String errorMessage, Exception error) Notifies planet players about coding exception, that has happened while executing action in executor.Errors stop executing next actions to prevent happening new errors in same coding line. They tell that something went wrong, and it needs to be fixed.
- Parameters:
executor- executor, that executed action.action- action, that produced error.errorMessage- description of error.error- exception, that has occurred.
-
notifyBuildModeByCode
-
sendPlanetCodeErrorMessage
public static void sendPlanetCodeErrorMessage(Executor executor, Action action, org.bukkit.entity.Entity entity, String errorMessage) Notifies planet players about coding exception, that has happened while executing action in executor.Errors stop executing next actions to prevent happening new errors in same coding line. They tell that something went wrong, and it needs to be fixed.
- Parameters:
executor- executor, that executed action.action- action, that produced error.entity- target of action.errorMessage- description of error.
-
sendPlanetCodeCriticalErrorMessage
public static void sendPlanetCodeCriticalErrorMessage(Planet planet, Executor executor, String errorMessage) Notifies planet players about coding fatal error, that has happened while executing code.Critical errors stop entire code in planet, and change its mode to Build.
- Parameters:
planet- planet to send error message.executor- executor, that executed action.errorMessage- description of error.
-
sendPlanetCodeErrorMessage
public static void sendPlanetCodeErrorMessage(Planet planet, Executor executor, String errorMessage) Notifies planet players about coding exception, that has happened while executing action in executor.Errors stop executing next actions to prevent happening new errors in same coding line. They tell that something went wrong, and it needs to be fixed.
- Parameters:
planet- planet to send error message.executor- executor, that executed action.errorMessage- description of error.
-
sendPlanetCompileErrorMessage
public static void sendPlanetCompileErrorMessage(Planet planet, org.bukkit.block.Block block, String errorMessage) Notifies planet players about coding issue, that has happened while compiling new code from dev planet.- Parameters:
planet- planet to send error message.block- block, that caused issue.errorMessage- description of error.
-
sendPlanetCompileErrorMessage
public static void sendPlanetCompileErrorMessage(Planet planet, List<org.bukkit.block.Block> unknownBlocks) Notifies planet players about unknown coding blocks, that were found while compiling a new code from dev planet.- Parameters:
planet- planet to send error message.unknownBlocks- list of unknown blocks.
-
sendWarningErrorMessage
Sends warning log in console about issue with plugin.- Parameters:
warning- description of warning.
-
sendWarningMessage
-
sendCriticalErrorMessage
Sends error log in console about problem with plugin.- Parameters:
errorMessage- description of error.
-
sendCriticalErrorMessage
-
sendDebug
Sends debug log in console, only if debug mode is enabled in plugin's settings.- Parameters:
message- debug log.
-
sendDebugError
Sends error log in console with stack traces, only if debug mode is enabled in plugin's settings.Used for not serious errors for server owners.
- Parameters:
errorMessage- description of critical error.error- exception, that has occurred.
-
sendCodingDebugNotFoundVariable
Sends notification to planet players about not found value while filling arguments in action, only if planet's debug mode is enabled.Happens when player forgets to fill items in coding container.
- Parameters:
planet- planet to send error message.name- name of value.
-
sendCodingNotFoundEventValue
public static void sendCodingNotFoundEventValue(Planet planet, Executor executor, Class<? extends EventValue> clazz) Sends notification to planet players about not found event value while executing actions or conditions, that require event value.Happens when player uses wrong coding block in event.
- Parameters:
planet- planet to send message.executor- executor, that stores event.clazz- class of event value, that was not found.
-
sendCodingDebugLog
-
sendCodingDebugVariable
Sends notification to planet players about found value while filling arguments in action, only if planet's debug mode is enabled.- Parameters:
planet- planet to send message.name- executor, that stores event.value- value.
-
sendCodingDebugExecutor
Sends notification to planet players about calling executor.- Parameters:
executor- executor, that has activated.
-
sendCodingDebugAction
Sends notification to planet players about action information, that will be executed. Only if planet's debug mode is enabled.- Parameters:
action- action, that will be executed.
-