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 {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
def determinePatchVersion = {
|
||||
|
@ -54,12 +55,6 @@ repositories {
|
|||
|
||||
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}"
|
||||
api "dev.zontreck:EventsBus:${Bus_API}.${Bus_Patch}:sources"
|
||||
}
|
||||
|
@ -71,19 +66,7 @@ publishing {
|
|||
mavenJava(MavenPublication) {
|
||||
artifact sourcesJar
|
||||
artifact jar
|
||||
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
artifact javadocJar
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
|
@ -99,9 +82,3 @@ publishing {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
compileJava.finalizedBy("sourcesJar")
|
||||
artifacts {
|
||||
archives jar
|
||||
archives sourcesJar
|
||||
}
|
|
@ -1,3 +1,3 @@
|
|||
apiVer=1.4
|
||||
Bus_API=1.0
|
||||
Bus_Patch=16
|
||||
Bus_Patch=29
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
package dev.zontreck.ariaslib.events;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.zontreck.eventsbus.Cancellable;
|
||||
import dev.zontreck.eventsbus.Event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Cancellable
|
||||
public class CommandEvent extends Event {
|
||||
public String command;
|
||||
public List<String> arguments = Lists.newArrayList();
|
||||
public String command;
|
||||
public List<String> arguments = new ArrayList<>();
|
||||
|
||||
public CommandEvent(String commandString) {
|
||||
String[] cmds = commandString.split(" ");
|
||||
if (cmds.length > 0) {
|
||||
command = cmds[0];
|
||||
if (cmds.length == 1) return;
|
||||
for (int i = 1; i < cmds.length; i++) {
|
||||
arguments.add(cmds[i]);
|
||||
}
|
||||
public CommandEvent(String commandString) {
|
||||
String[] cmds = commandString.split(" ");
|
||||
if (cmds.length > 0) {
|
||||
command = cmds[0];
|
||||
if (cmds.length == 1) return;
|
||||
for (int i = 1; i < cmds.length; 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 java.io.Console;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class ConsolePrompt extends Task {
|
||||
public static final Console console = System.console();
|
||||
public static final Console console = System.console();
|
||||
|
||||
public ConsolePrompt() {
|
||||
super("ConsolePrompt", true);
|
||||
}
|
||||
public ConsolePrompt() {
|
||||
super("ConsolePrompt", true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// Print a prompt
|
||||
console.printf("\n" + Terminal.PREFIX + " > ");
|
||||
String commandInput = console.readLine();
|
||||
@Override
|
||||
public void run() {
|
||||
// Print a prompt
|
||||
console.printf("\n" + Terminal.PREFIX + " > ");
|
||||
String commandInput = console.readLine();
|
||||
|
||||
CommandEvent event = new CommandEvent(commandInput);
|
||||
try {
|
||||
if (!Bus.Post(event)) {
|
||||
DelayedExecutorService.getInstance().schedule(new ConsolePrompt(), 2);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
CommandEvent event = new CommandEvent(commandInput);
|
||||
if (!Bus.Post(event)) {
|
||||
DelayedExecutorService.getInstance().schedule(new ConsolePrompt(), 2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,43 +1,38 @@
|
|||
package dev.zontreck.ariaslib.terminal;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.zontreck.ariaslib.util.DelayedExecutorService;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TaskBus extends Task
|
||||
{
|
||||
public static List<Task> tasks = new ArrayList<>();
|
||||
public static Task current = null;
|
||||
public class TaskBus extends Task {
|
||||
public static List<Task> tasks = new ArrayList<>();
|
||||
public static Task current = null;
|
||||
|
||||
public TaskBus()
|
||||
{
|
||||
super("TaskBus",true);
|
||||
}
|
||||
public TaskBus() {
|
||||
super("TaskBus", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try{
|
||||
public static void register() {
|
||||
DelayedExecutorService.getInstance().scheduleRepeating(new TaskBus(), 1);
|
||||
}
|
||||
|
||||
if(TaskBus.current == null)
|
||||
{
|
||||
TaskBus.current = tasks.get(0);
|
||||
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){}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
||||
public static void register()
|
||||
{
|
||||
DelayedExecutorService.getInstance().scheduleRepeating(new TaskBus(), 1);
|
||||
}
|
||||
if (TaskBus.current == null) {
|
||||
TaskBus.current = tasks.get(0);
|
||||
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…
Reference in a new issue