make the RemoteEventManager actually tick
This commit is contained in:
parent
b94cddf64c
commit
3933a89608
3 changed files with 9 additions and 4 deletions
|
@ -66,6 +66,7 @@ public class FMLEventHandler {
|
||||||
return;
|
return;
|
||||||
playerLastTick = mc.player;
|
playerLastTick = mc.player;
|
||||||
BaseBand.updateKeyBinds();
|
BaseBand.updateKeyBinds();
|
||||||
|
BaseBand.remoteEventManager.onTick();
|
||||||
for(Feature feature : features) {
|
for(Feature feature : features) {
|
||||||
feature.onEveryTick();
|
feature.onEveryTick();
|
||||||
if(feature.enabled) {
|
if(feature.enabled) {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import de.tudbut.parsing.JSON;
|
||||||
import de.tudbut.parsing.TCN;
|
import de.tudbut.parsing.TCN;
|
||||||
import de.tudbut.tools.ConfigSaverTCN2;
|
import de.tudbut.tools.ConfigSaverTCN2;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InterruptedIOException;
|
import java.io.InterruptedIOException;
|
||||||
|
@ -33,7 +32,7 @@ public class RemoteEventManager {
|
||||||
private final Queue<RemoteEvent> toSend = new LinkedList<>();
|
private final Queue<RemoteEvent> toSend = new LinkedList<>();
|
||||||
private final Queue<RemoteEvent> toProcess = new LinkedList<>();
|
private final Queue<RemoteEvent> toProcess = new LinkedList<>();
|
||||||
|
|
||||||
public void connect(@Nullable String ip) {
|
public void connect(String ip) {
|
||||||
try {
|
try {
|
||||||
if(isConnected())
|
if(isConnected())
|
||||||
end();
|
end();
|
||||||
|
@ -92,6 +91,7 @@ public class RemoteEventManager {
|
||||||
s.setSoTimeout(1);
|
s.setSoTimeout(1);
|
||||||
clients.add(s);
|
clients.add(s);
|
||||||
publish(new RemoteInitEvent(++maxID));
|
publish(new RemoteInitEvent(++maxID));
|
||||||
|
BaseBand.notify("[Remote] Client connected.");
|
||||||
} else {
|
} else {
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,7 @@ public class RemoteEventManager {
|
||||||
end();
|
end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
BaseBand.notify("[Remote] Connected.");
|
||||||
while(head != null) {
|
while(head != null) {
|
||||||
while(!toSend.isEmpty()) {
|
while(!toSend.isEmpty()) {
|
||||||
o.write(0);
|
o.write(0);
|
||||||
|
@ -182,9 +183,11 @@ public class RemoteEventManager {
|
||||||
if(event instanceof RemoteInitEvent) {
|
if(event instanceof RemoteInitEvent) {
|
||||||
if(id == -1) {
|
if(id == -1) {
|
||||||
id = ((RemoteInitEvent) event).id;
|
id = ((RemoteInitEvent) event).id;
|
||||||
|
BaseBand.notify("[Remote] Received ID: " + id + ".");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
maxID = ((RemoteInitEvent) event).id;
|
maxID = ((RemoteInitEvent) event).id;
|
||||||
|
BaseBand.notify("[Remote] Someone connected with ID " + id + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -200,7 +203,7 @@ public class RemoteEventManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPeers() {
|
public int getPeers() {
|
||||||
return maxID;
|
return maxID + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class AltControl extends Feature {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRemoteSendChat(RemoteSendMessageEvent event) {
|
public void onRemoteSendChat(RemoteSendMessageEvent event) {
|
||||||
|
BaseBand.notify("[AltControl] Received a message to send.");
|
||||||
ChatUtil.simulateSend(event.message, false);
|
ChatUtil.simulateSend(event.message, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ public class AltControl extends Feature {
|
||||||
ChatUtil.print("syntax: " + Client.prefix + this + " <message...>");
|
ChatUtil.print("syntax: " + Client.prefix + this + " <message...>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BaseBand.remoteEventManager.publish(new RemoteSendMessageEvent(String.join(" ", args)));
|
BaseBand.publish(new RemoteSendMessageEvent(String.join(" ", args)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue