getting altcontrol peers now possible
All checks were successful
/ Build BaseBand (push) Successful in 2m39s

This commit is contained in:
Daniella / Tove 2024-10-05 11:46:31 +02:00
parent 6985663cbf
commit 389da94385
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
2 changed files with 45 additions and 0 deletions

View file

@ -0,0 +1,19 @@
package de.com.baseband.client.event.remote.events;
import com.mojang.authlib.GameProfile;
import de.com.baseband.client.BaseBand;
import de.com.baseband.client.event.remote.RemoteEvent;
import de.tudbut.obj.Save;
public class RemoteDataRequestEvent extends RemoteEvent {
public static class Request extends RemoteDataRequestEvent {}
public static class Response extends RemoteDataRequestEvent {
@Save
public int id = BaseBand.REMOTE_EVENT_BUS.getID();
@Save
public GameProfile profile = BaseBand.mc.getSession().getProfile();
}
}

View file

@ -1,8 +1,10 @@
package de.com.baseband.client.feature.modules.client; package de.com.baseband.client.feature.modules.client;
import com.mojang.authlib.GameProfile;
import de.com.baseband.client.BaseBand; import de.com.baseband.client.BaseBand;
import de.com.baseband.client.event.Listen; import de.com.baseband.client.event.Listen;
import de.com.baseband.client.event.remote.events.RemoteConfigEvent; import de.com.baseband.client.event.remote.events.RemoteConfigEvent;
import de.com.baseband.client.event.remote.events.RemoteDataRequestEvent;
import de.com.baseband.client.event.remote.events.RemoteSendMessageEvent; import de.com.baseband.client.event.remote.events.RemoteSendMessageEvent;
import de.com.baseband.client.feature.Feature; import de.com.baseband.client.feature.Feature;
import de.com.baseband.client.feature.Features; import de.com.baseband.client.feature.Features;
@ -16,6 +18,8 @@ import de.com.baseband.client.registry.annotation.Trigger;
import de.com.baseband.client.util.adapt.Marker; import de.com.baseband.client.util.adapt.Marker;
import de.com.baseband.client.util.interact.Chat; import de.com.baseband.client.util.interact.Chat;
import java.util.ArrayList;
@ClientCategory @ClientCategory
public class AltControl extends Feature { public class AltControl extends Feature {
@ -30,6 +34,12 @@ public class AltControl extends Feature {
BaseBand.publish(new RemoteConfigEvent()); BaseBand.publish(new RemoteConfigEvent());
} }
@Trigger("Who is connected?")
@Gate(M_ENABLED)
public void requestData() {
BaseBand.publish(new RemoteDataRequestEvent.Request());
}
@Marker(1) @Marker(1)
boolean notEnabled = true; boolean notEnabled = true;
@ -64,6 +74,22 @@ public class AltControl extends Feature {
this.ip = ip; this.ip = ip;
} }
ArrayList<GameProfile> peers = new ArrayList<>();
@Listen
public void onRequestData(RemoteDataRequestEvent.Request event) {
peers.clear();
BaseBand.publish(new RemoteDataRequestEvent.Response());
}
@Listen
public void onDataResponse(RemoteDataRequestEvent.Response event) {
peers.add(event.profile);
if(peers.size() == BaseBand.REMOTE_EVENT_BUS.getPeers()) {
BaseBand.notifyAll("§a§lPeers: §r" + String.join(", ", (Iterable<? extends CharSequence>) peers.stream().map(GameProfile::getName)));
}
}
@Override @Override
public void onCommand(String[] args) { public void onCommand(String[] args) {
if(!enabled) if(!enabled)