Skip to content

Commit 5026aee

Browse files
committed
* Added information appliance for immediate recursion on constructed tasks.
1 parent c3f3fd8 commit 5026aee

File tree

5 files changed

+46
-10
lines changed

5 files changed

+46
-10
lines changed

Labyrinth.iml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
</content>
2020
<orderEntry type="inheritedJdk" />
2121
<orderEntry type="sourceFolder" forTests="false" />
22-
<orderEntry type="library" name="Maven: com.github.ms5984.lib:menu-man:1.1.0" level="project" />
2322
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.3-R0.1-SNAPSHOT" level="project" />
2423
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
2524
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
@@ -33,6 +32,6 @@
3332
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
3433
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
3534
<orderEntry type="library" name="Maven: com.github.ms5984.lib:menu-man:1.1.0" level="project" />
36-
<orderEntry type="library" name="Maven: com.github.the-h-team:Enterprise:1.4" level="project" />
35+
<orderEntry type="library" name="Maven: com.github.the-h-team:Enterprise:1.5" level="project" />
3736
</component>
3837
</module>

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.sanctum.Labyrinth</groupId>
88
<artifactId>Labyrinth</artifactId>
9-
<version>1.2.9</version>
9+
<version>1.3.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Labyrinth</name>
@@ -135,7 +135,7 @@
135135
<dependency>
136136
<groupId>com.github.the-h-team</groupId>
137137
<artifactId>Enterprise</artifactId>
138-
<version>1.4</version>
138+
<version>1.5</version>
139139
<scope>compile</scope>
140140
</dependency>
141141
</dependencies>

src/main/java/com/github/sanctum/labyrinth/task/Asynchronous.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,11 @@
99
public class Asynchronous {
1010

1111
private final BukkitRunnable runnable;
12-
12+
private Applicable apply = null;
1313
private String cancel = null;
14-
1514
private boolean check;
16-
1715
private boolean fallback;
18-
1916
private boolean debug;
20-
2117
private Player p = null;
2218

2319
protected Asynchronous(Applicable applicable) {
@@ -40,6 +36,9 @@ public void run() {
4036
}
4137
}
4238
applicable.apply();
39+
if (apply != null) {
40+
apply.apply();
41+
}
4342
} else {
4443
int count = Integer.parseInt(cancel);
4544
count--;
@@ -59,6 +58,9 @@ public void run() {
5958
}
6059
}
6160
applicable.apply();
61+
if (apply != null) {
62+
apply.apply();
63+
}
6264
} else {
6365
if (debug) {
6466
Labyrinth.getInstance().getLogger().info("Closing task, max usage counter achieved.");
@@ -129,6 +131,20 @@ public Asynchronous debug() {
129131
return this;
130132
}
131133

134+
/**
135+
* Use this to apply defined logic to the runnable as soon as it finishes.
136+
*
137+
* <p>The information passed here will have secondary important and will be called
138+
* directly after the initial runnable has executed one time for each time ran.</p>
139+
*
140+
* @param applicable The information to pass be it via Void or lambda reference.
141+
* @return The same synchronous task builder.
142+
*/
143+
public Asynchronous applyAfter(Applicable applicable) {
144+
this.apply = applicable;
145+
return this;
146+
}
147+
132148
/**
133149
* Run this scheduled task on the very next tick.
134150
*/

src/main/java/com/github/sanctum/labyrinth/task/Synchronous.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class Synchronous {
1010

1111
private BukkitRunnable outer;
1212
private final BukkitRunnable runnable;
13+
private Applicable apply = null;
1314
private boolean check;
1415
private boolean debug;
1516
private boolean fallback;
@@ -36,6 +37,9 @@ public void run() {
3637
}
3738
}
3839
applicable.apply();
40+
if (apply != null) {
41+
apply.apply();
42+
}
3943
} else {
4044
int count = Integer.parseInt(cancel);
4145
count--;
@@ -55,6 +59,9 @@ public void run() {
5559
}
5660
}
5761
applicable.apply();
62+
if (apply != null) {
63+
apply.apply();
64+
}
5865
} else {
5966
if (debug) {
6067
Labyrinth.getInstance().getLogger().info("Closing task, max usage counter achieved.");
@@ -138,6 +145,20 @@ public Synchronous debug() {
138145
return this;
139146
}
140147

148+
/**
149+
* Use this to apply defined logic to the runnable as soon as it finishes.
150+
*
151+
* <p>The information passed here will have secondary important and will be called
152+
* directly after the initial runnable has executed one time for each time ran.</p>
153+
*
154+
* @param applicable The information to pass be it via Void or lambda reference.
155+
* @return The same synchronous task builder.
156+
*/
157+
public Synchronous applyAfter(Applicable applicable) {
158+
this.apply = applicable;
159+
return this;
160+
}
161+
141162
/**
142163
* Run this scheduled task on the very next tick.
143164
*/

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Labyrinth
2-
version: 1.2.9
2+
version: 1.3.0
33
main: com.github.sanctum.labyrinth.Labyrinth
44
prefix: Labyrinth
55
api-version: 1.13

0 commit comments

Comments
 (0)