Skip to content

Commit

Permalink
* Added information appliance for immediate recursion on constructed …
Browse files Browse the repository at this point in the history
…tasks.
  • Loading branch information
Hempfest committed Feb 27, 2021
1 parent c3f3fd8 commit 5026aee
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 deletions.
3 changes: 1 addition & 2 deletions Labyrinth.iml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.github.ms5984.lib:menu-man:1.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.3-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
Expand All @@ -33,6 +32,6 @@
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" name="Maven: com.github.ms5984.lib:menu-man:1.1.0" level="project" />
<orderEntry type="library" name="Maven: com.github.the-h-team:Enterprise:1.4" level="project" />
<orderEntry type="library" name="Maven: com.github.the-h-team:Enterprise:1.5" level="project" />
</component>
</module>
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.sanctum.Labyrinth</groupId>
<artifactId>Labyrinth</artifactId>
<version>1.2.9</version>
<version>1.3.0</version>
<packaging>jar</packaging>

<name>Labyrinth</name>
Expand Down Expand Up @@ -135,7 +135,7 @@
<dependency>
<groupId>com.github.the-h-team</groupId>
<artifactId>Enterprise</artifactId>
<version>1.4</version>
<version>1.5</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
26 changes: 21 additions & 5 deletions src/main/java/com/github/sanctum/labyrinth/task/Asynchronous.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@
public class Asynchronous {

private final BukkitRunnable runnable;

private Applicable apply = null;
private String cancel = null;

private boolean check;

private boolean fallback;

private boolean debug;

private Player p = null;

protected Asynchronous(Applicable applicable) {
Expand All @@ -40,6 +36,9 @@ public void run() {
}
}
applicable.apply();
if (apply != null) {
apply.apply();
}
} else {
int count = Integer.parseInt(cancel);
count--;
Expand All @@ -59,6 +58,9 @@ public void run() {
}
}
applicable.apply();
if (apply != null) {
apply.apply();
}
} else {
if (debug) {
Labyrinth.getInstance().getLogger().info("Closing task, max usage counter achieved.");
Expand Down Expand Up @@ -129,6 +131,20 @@ public Asynchronous debug() {
return this;
}

/**
* Use this to apply defined logic to the runnable as soon as it finishes.
*
* <p>The information passed here will have secondary important and will be called
* directly after the initial runnable has executed one time for each time ran.</p>
*
* @param applicable The information to pass be it via Void or lambda reference.
* @return The same synchronous task builder.
*/
public Asynchronous applyAfter(Applicable applicable) {
this.apply = applicable;
return this;
}

/**
* Run this scheduled task on the very next tick.
*/
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/com/github/sanctum/labyrinth/task/Synchronous.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Synchronous {

private BukkitRunnable outer;
private final BukkitRunnable runnable;
private Applicable apply = null;
private boolean check;
private boolean debug;
private boolean fallback;
Expand All @@ -36,6 +37,9 @@ public void run() {
}
}
applicable.apply();
if (apply != null) {
apply.apply();
}
} else {
int count = Integer.parseInt(cancel);
count--;
Expand All @@ -55,6 +59,9 @@ public void run() {
}
}
applicable.apply();
if (apply != null) {
apply.apply();
}
} else {
if (debug) {
Labyrinth.getInstance().getLogger().info("Closing task, max usage counter achieved.");
Expand Down Expand Up @@ -138,6 +145,20 @@ public Synchronous debug() {
return this;
}

/**
* Use this to apply defined logic to the runnable as soon as it finishes.
*
* <p>The information passed here will have secondary important and will be called
* directly after the initial runnable has executed one time for each time ran.</p>
*
* @param applicable The information to pass be it via Void or lambda reference.
* @return The same synchronous task builder.
*/
public Synchronous applyAfter(Applicable applicable) {
this.apply = applicable;
return this;
}

/**
* Run this scheduled task on the very next tick.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Labyrinth
version: 1.2.9
version: 1.3.0
main: com.github.sanctum.labyrinth.Labyrinth
prefix: Labyrinth
api-version: 1.13
Expand Down

0 comments on commit 5026aee

Please sign in to comment.