Update event bus library, fix compile errors
This commit is contained in:
parent
0161fef673
commit
ef08583850
5 changed files with 58 additions and 93 deletions
27
build.gradle
27
build.gradle
|
@ -20,6 +20,7 @@ archivesBaseName = "LibAC"
|
||||||
java {
|
java {
|
||||||
toolchain.languageVersion = JavaLanguageVersion.of(17)
|
toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
|
withJavadocJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
def determinePatchVersion = {
|
def determinePatchVersion = {
|
||||||
|
@ -54,12 +55,6 @@ repositories {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
// This dependency is exported to consumers, that is to say found on their compile classpath.
|
|
||||||
api 'org.apache.commons:commons-math3:3.6.1'
|
|
||||||
|
|
||||||
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
|
|
||||||
implementation 'com.google.guava:guava:31.1-jre'
|
|
||||||
|
|
||||||
implementation "dev.zontreck:EventsBus:${Bus_API}.${Bus_Patch}"
|
implementation "dev.zontreck:EventsBus:${Bus_API}.${Bus_Patch}"
|
||||||
api "dev.zontreck:EventsBus:${Bus_API}.${Bus_Patch}:sources"
|
api "dev.zontreck:EventsBus:${Bus_API}.${Bus_Patch}:sources"
|
||||||
}
|
}
|
||||||
|
@ -71,19 +66,7 @@ publishing {
|
||||||
mavenJava(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
artifact sourcesJar
|
artifact sourcesJar
|
||||||
artifact jar
|
artifact jar
|
||||||
|
artifact javadocJar
|
||||||
|
|
||||||
pom.withXml {
|
|
||||||
def dependenciesNode = asNode().appendNode('dependencies')
|
|
||||||
|
|
||||||
//Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
|
|
||||||
configurations.compile.allDependencies.each {
|
|
||||||
def dependencyNode = dependenciesNode.appendNode('dependency')
|
|
||||||
dependencyNode.appendNode('groupId', it.group)
|
|
||||||
dependencyNode.appendNode('artifactId', it.name)
|
|
||||||
dependencyNode.appendNode('version', it.version)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -99,9 +82,3 @@ publishing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.finalizedBy("sourcesJar")
|
|
||||||
artifacts {
|
|
||||||
archives jar
|
|
||||||
archives sourcesJar
|
|
||||||
}
|
|
|
@ -1,3 +1,3 @@
|
||||||
apiVer=1.4
|
apiVer=1.4
|
||||||
Bus_API=1.0
|
Bus_API=1.0
|
||||||
Bus_Patch=16
|
Bus_Patch=29
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
package dev.zontreck.ariaslib.events;
|
package dev.zontreck.ariaslib.events;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import dev.zontreck.eventsbus.Cancellable;
|
import dev.zontreck.eventsbus.Cancellable;
|
||||||
import dev.zontreck.eventsbus.Event;
|
import dev.zontreck.eventsbus.Event;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Cancellable
|
@Cancellable
|
||||||
public class CommandEvent extends Event {
|
public class CommandEvent extends Event {
|
||||||
public String command;
|
public String command;
|
||||||
public List<String> arguments = Lists.newArrayList();
|
public List<String> arguments = new ArrayList<>();
|
||||||
|
|
||||||
public CommandEvent(String commandString) {
|
public CommandEvent(String commandString) {
|
||||||
String[] cmds = commandString.split(" ");
|
String[] cmds = commandString.split(" ");
|
||||||
if (cmds.length > 0) {
|
if (cmds.length > 0) {
|
||||||
command = cmds[0];
|
command = cmds[0];
|
||||||
if (cmds.length == 1) return;
|
if (cmds.length == 1) return;
|
||||||
for (int i = 1; i < cmds.length; i++) {
|
for (int i = 1; i < cmds.length; i++) {
|
||||||
arguments.add(cmds[i]);
|
arguments.add(cmds[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else throw new IllegalArgumentException("The command cannot be empty!");
|
} else throw new IllegalArgumentException("The command cannot be empty!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,33 +5,26 @@ import dev.zontreck.ariaslib.util.DelayedExecutorService;
|
||||||
import dev.zontreck.eventsbus.Bus;
|
import dev.zontreck.eventsbus.Bus;
|
||||||
|
|
||||||
import java.io.Console;
|
import java.io.Console;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
public class ConsolePrompt extends Task {
|
public class ConsolePrompt extends Task {
|
||||||
public static final Console console = System.console();
|
public static final Console console = System.console();
|
||||||
|
|
||||||
public ConsolePrompt() {
|
public ConsolePrompt() {
|
||||||
super("ConsolePrompt", true);
|
super("ConsolePrompt", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Print a prompt
|
// Print a prompt
|
||||||
console.printf("\n" + Terminal.PREFIX + " > ");
|
console.printf("\n" + Terminal.PREFIX + " > ");
|
||||||
String commandInput = console.readLine();
|
String commandInput = console.readLine();
|
||||||
|
|
||||||
CommandEvent event = new CommandEvent(commandInput);
|
CommandEvent event = new CommandEvent(commandInput);
|
||||||
try {
|
if (!Bus.Post(event)) {
|
||||||
if (!Bus.Post(event)) {
|
DelayedExecutorService.getInstance().schedule(new ConsolePrompt(), 2);
|
||||||
DelayedExecutorService.getInstance().schedule(new ConsolePrompt(), 2);
|
}
|
||||||
}
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,43 +1,38 @@
|
||||||
package dev.zontreck.ariaslib.terminal;
|
package dev.zontreck.ariaslib.terminal;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import dev.zontreck.ariaslib.util.DelayedExecutorService;
|
import dev.zontreck.ariaslib.util.DelayedExecutorService;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TaskBus extends Task
|
public class TaskBus extends Task {
|
||||||
{
|
public static List<Task> tasks = new ArrayList<>();
|
||||||
public static List<Task> tasks = new ArrayList<>();
|
public static Task current = null;
|
||||||
public static Task current = null;
|
|
||||||
|
|
||||||
public TaskBus()
|
public TaskBus() {
|
||||||
{
|
super("TaskBus", true);
|
||||||
super("TaskBus",true);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public static void register() {
|
||||||
public void run()
|
DelayedExecutorService.getInstance().scheduleRepeating(new TaskBus(), 1);
|
||||||
{
|
}
|
||||||
try{
|
|
||||||
|
|
||||||
if(TaskBus.current == null)
|
@Override
|
||||||
{
|
public void run() {
|
||||||
TaskBus.current = tasks.get(0);
|
try {
|
||||||
tasks.remove(0);
|
|
||||||
TaskBus.current.startTask();
|
|
||||||
}else {
|
|
||||||
if(TaskBus.current.isComplete())
|
|
||||||
{
|
|
||||||
TaskBus.current.stopTask();
|
|
||||||
TaskBus.current=null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Don't care about a empty stack exception. We'll just queue this task check back up
|
|
||||||
}catch(Exception e){}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void register()
|
if (TaskBus.current == null) {
|
||||||
{
|
TaskBus.current = tasks.get(0);
|
||||||
DelayedExecutorService.getInstance().scheduleRepeating(new TaskBus(), 1);
|
tasks.remove(0);
|
||||||
}
|
TaskBus.current.startTask();
|
||||||
|
} else {
|
||||||
|
if (TaskBus.current.isComplete()) {
|
||||||
|
TaskBus.current.stopTask();
|
||||||
|
TaskBus.current = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Don't care about a empty stack exception. We'll just queue this task check back up
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue