From da227afe33eb16104ba10cdbfebba4b5b91e53c5 Mon Sep 17 00:00:00 2001 From: Intelli Date: Tue, 9 Jul 2024 18:59:16 -0600 Subject: [PATCH] Added primary thread error when running a rollback via API (implements #456) --- src/main/java/net/coreprotect/CoreProtectAPI.java | 3 +++ src/main/java/net/coreprotect/language/Language.java | 1 + src/main/java/net/coreprotect/language/Phrase.java | 1 + 3 files changed, 5 insertions(+) diff --git a/src/main/java/net/coreprotect/CoreProtectAPI.java b/src/main/java/net/coreprotect/CoreProtectAPI.java index 2235f72b..74f9f939 100755 --- a/src/main/java/net/coreprotect/CoreProtectAPI.java +++ b/src/main/java/net/coreprotect/CoreProtectAPI.java @@ -546,6 +546,9 @@ else if (argBlock instanceof EntityType && !addedEntity) { boolean verbose = false; result = Rollback.performRollbackRestore(statement, null, uuids, restrictUsers, null, restrictBlocks, excludeBlocks, excludeUsers, actionList, location, argRadius, startTime, endTime, restrictWorld, false, verbose, action, 0); } + else { + Chat.console(Phrase.build(Phrase.PRIMARY_THREAD_ERROR)); + } } statement.close(); diff --git a/src/main/java/net/coreprotect/language/Language.java b/src/main/java/net/coreprotect/language/Language.java index 918da473..a19004da 100644 --- a/src/main/java/net/coreprotect/language/Language.java +++ b/src/main/java/net/coreprotect/language/Language.java @@ -176,6 +176,7 @@ public static void loadPhrases() { phrases.put(Phrase.PREVIEW_CANCELLING, "Cancelling preview..."); phrases.put(Phrase.PREVIEW_IN_GAME, "You can only preview rollbacks in-game."); phrases.put(Phrase.PREVIEW_TRANSACTION, "You can't preview {container|inventory} transactions."); + phrases.put(Phrase.PRIMARY_THREAD_ERROR, "That API method can't be used on the primary thread."); phrases.put(Phrase.PURGE_ABORTED, "Purge failed. Database may be corrupt."); phrases.put(Phrase.PURGE_ERROR, "Unable to process {0} data!"); phrases.put(Phrase.PURGE_FAILED, "Purge failed. Please try again later."); diff --git a/src/main/java/net/coreprotect/language/Phrase.java b/src/main/java/net/coreprotect/language/Phrase.java index fc26ee7b..89e487f2 100644 --- a/src/main/java/net/coreprotect/language/Phrase.java +++ b/src/main/java/net/coreprotect/language/Phrase.java @@ -159,6 +159,7 @@ public enum Phrase { PREVIEW_CANCELLING, PREVIEW_IN_GAME, PREVIEW_TRANSACTION, + PRIMARY_THREAD_ERROR, PURGE_ABORTED, PURGE_ERROR, PURGE_FAILED,