-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+TimeoutInputListener abstraction layer SelectorListener is now an InputListener which no longer timeouts.
- Loading branch information
1 parent
e682a7d
commit b1451f6
Showing
11 changed files
with
111 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/us/mytheria/bloblib/entities/listeners/ChatListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/us/mytheria/bloblib/entities/listeners/TimeoutInputListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package us.mytheria.bloblib.entities.listeners; | ||
|
||
import org.bukkit.scheduler.BukkitRunnable; | ||
import org.bukkit.scheduler.BukkitTask; | ||
import us.mytheria.bloblib.BlobLib; | ||
|
||
public abstract class TimeoutInputListener extends InputListener { | ||
protected final long timeout; | ||
protected final Runnable timeoutRunnable; | ||
protected BukkitTask task; | ||
|
||
public TimeoutInputListener(String owner, long timeout, Runnable inputRunnable, | ||
Runnable timeoutRunnable) { | ||
super(owner, inputRunnable); | ||
this.timeout = timeout; | ||
this.timeoutRunnable = timeoutRunnable; | ||
} | ||
|
||
@Override | ||
public void runTasks() { | ||
BukkitRunnable bukkitRunnable = new BukkitRunnable() { | ||
@Override | ||
public void run() { | ||
TimeoutInputListener.this.cancel(); | ||
timeoutRunnable.run(); | ||
} | ||
}; | ||
this.task = bukkitRunnable.runTaskLater(BlobLib.getInstance(), timeout); | ||
} | ||
|
||
@Override | ||
public void cancel() { | ||
task.cancel(); | ||
} | ||
|
||
public long getTimeout() { | ||
return timeout; | ||
} | ||
|
||
public BukkitTask getTask() { | ||
return task; | ||
} | ||
|
||
public Runnable getTimeoutRunnable() { | ||
return timeoutRunnable; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters