Skip to content

Commit

Permalink
move preTagExecute call to better place
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 4, 2019
1 parent b96909b commit 6d3b287
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/main/java/com/denizenscript/denizencore/tags/TagManager.java
Expand Up @@ -321,38 +321,38 @@ public static void fetchObject(ReplaceableTagEvent event) {

public static void executeWithTimeLimit(final ReplaceableTagEvent event, int seconds) {

DenizenCore.getImplementation().preTagExecute();
try {
ExecutorService executor = Executors.newFixedThreadPool(4);
ExecutorService executor = Executors.newFixedThreadPool(4);

Future<?> future = executor.submit(new Runnable() {
@Override
public void run() {
Future<?> future = executor.submit(new Runnable() {
@Override
public void run() {
try {
DenizenCore.getImplementation().preTagExecute();
fireEvent(event);
}
});

executor.shutdown();

try {
future.get(seconds, TimeUnit.SECONDS);
}
catch (InterruptedException e) {
Debug.echoError("Tag filling was interrupted!");
}
catch (ExecutionException e) {
Debug.echoError(e);
}
catch (TimeoutException e) {
future.cancel(true);
Debug.echoError("Tag filling timed out!");
finally {
DenizenCore.getImplementation().postTagExecute();
}
}
});

executor.shutdown();

executor.shutdownNow();
try {
future.get(seconds, TimeUnit.SECONDS);
}
finally {
DenizenCore.getImplementation().postTagExecute();
catch (InterruptedException e) {
Debug.echoError("Tag filling was interrupted!");
}
catch (ExecutionException e) {
Debug.echoError(e);
}
catch (TimeoutException e) {
future.cancel(true);
Debug.echoError("Tag filling timed out!");
}

executor.shutdownNow();
}

public static String readSingleTag(String str, TagContext context) {
Expand Down

0 comments on commit 6d3b287

Please sign in to comment.