Attempting to fix sendplayer
This commit is contained in:
@@ -87,6 +87,13 @@ public class ServiceClient {
|
|||||||
session.request(ServiceMethods.SetCloak, itemId).whenComplete((msg, throwable) -> {
|
session.request(ServiceMethods.SetCloak, itemId).whenComplete((msg, throwable) -> {
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
session.request(ServiceMethods.SendPlayer,
|
||||||
|
new ServiceMethods.Types.SendPlayerRequest(SaturnPlayer.getExternalUUIDAsString()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -99,6 +106,13 @@ public class ServiceClient {
|
|||||||
session.request(ServiceMethods.SetHat, itemId).whenComplete((msg, throwable) -> {
|
session.request(ServiceMethods.SetHat, itemId).whenComplete((msg, throwable) -> {
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
session.request(ServiceMethods.SendPlayer,
|
||||||
|
new ServiceMethods.Types.SendPlayerRequest(SaturnPlayer.getExternalUUIDAsString()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -167,15 +181,20 @@ public class ServiceClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
session.onNotification(ServiceMethods.Player, (player) -> {
|
||||||
|
System.out.println(player);
|
||||||
|
SaturnPlayer.set(player.toSaturnPlayer());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void player(UUID uuid, String name) {
|
public static void player(UUID uuid, String name) {
|
||||||
try {
|
try {
|
||||||
session.request(ServiceMethods.Player, uuid.toString().replaceAll("-", ""))
|
session.request(ServiceMethods.GetPlayer, uuid.toString().replaceAll("-", ""))
|
||||||
.whenComplete((user, throwable) -> {
|
.whenComplete((user, throwable) -> {
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
} else {
|
} else if (user != null) {
|
||||||
SaturnPlayer.set(user.toSaturnPlayer(uuid, name));
|
SaturnPlayer.set(user.toSaturnPlayer(uuid, name));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,47 +2,112 @@ package org.saturnclient.saturnclient.client;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.saturnclient.saturnclient.client.ServiceMethods.Types.SendPlayerRequest;
|
||||||
import org.saturnclient.saturnclient.client.player.SaturnPlayer;
|
import org.saturnclient.saturnclient.client.player.SaturnPlayer;
|
||||||
|
|
||||||
import dev.selimaj.session.types.Method;
|
import dev.selimaj.session.types.Method;
|
||||||
|
|
||||||
public class ServiceMethods {
|
public class ServiceMethods {
|
||||||
public class Types {
|
|
||||||
|
// =========================
|
||||||
|
// Types (Rust structs)
|
||||||
|
// =========================
|
||||||
|
public static class Types {
|
||||||
|
|
||||||
public record EmoteRequest(String emote, String[] targets) {
|
public record EmoteRequest(String emote, String[] targets) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public record EmoteEvent(String emote, String from) {
|
public record EmoteEvent(String emote, String from) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Player(String cloak, String hat, String[] cloaks, String[] hats) {
|
public record Player(
|
||||||
|
String cloak,
|
||||||
|
String hat,
|
||||||
|
String[] cloaks,
|
||||||
|
String[] hats) {
|
||||||
public SaturnPlayer toSaturnPlayer(UUID uuid, String name) {
|
public SaturnPlayer toSaturnPlayer(UUID uuid, String name) {
|
||||||
return new SaturnPlayer(uuid, name, cloak, hat);
|
return new SaturnPlayer(uuid, name, cloak, hat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public record PlayerStream(Player player, String name, String uuid) {
|
||||||
|
public SaturnPlayer toSaturnPlayer() {
|
||||||
|
return new SaturnPlayer(UUID.fromString(uuid), name, this.player.cloak, this.player.hat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public record SendPlayerRequest(String[] targets) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================
|
||||||
|
// AUTH
|
||||||
|
// =========================
|
||||||
public static final Method<String, Types.Player, String> Authenticate = new Method<>("auth",
|
public static final Method<String, Types.Player, String> Authenticate = new Method<>("auth",
|
||||||
String.class, Types.Player.class, String.class);
|
String.class,
|
||||||
|
Types.Player.class,
|
||||||
|
String.class);
|
||||||
|
|
||||||
// Equip
|
// =========================
|
||||||
|
// EQUIP
|
||||||
|
// =========================
|
||||||
public static final Method<String, String, String> SetCloak = new Method<>("set_cloak",
|
public static final Method<String, String, String> SetCloak = new Method<>("set_cloak",
|
||||||
String.class, String.class, String.class);
|
String.class,
|
||||||
|
String.class,
|
||||||
|
String.class);
|
||||||
|
|
||||||
public static final Method<String, String, String> SetHat = new Method<>("set_hat",
|
public static final Method<String, String, String> SetHat = new Method<>("set_hat",
|
||||||
String.class, String.class, String.class);
|
String.class,
|
||||||
|
String.class,
|
||||||
|
String.class);
|
||||||
|
|
||||||
// Buy
|
// =========================
|
||||||
|
// BUY
|
||||||
|
// =========================
|
||||||
public static final Method<String, String, String> BuyCloak = new Method<>("buy_cloak",
|
public static final Method<String, String, String> BuyCloak = new Method<>("buy_cloak",
|
||||||
String.class, String.class, String.class);
|
String.class,
|
||||||
|
String.class,
|
||||||
|
String.class);
|
||||||
|
|
||||||
public static final Method<String, String, String> BuyHat = new Method<>("buy_hat",
|
public static final Method<String, String, String> BuyHat = new Method<>("buy_hat",
|
||||||
String.class, String.class, String.class);
|
String.class,
|
||||||
|
String.class,
|
||||||
|
String.class);
|
||||||
|
|
||||||
// Emote
|
// =========================
|
||||||
public static final Method<Types.EmoteRequest, String, String> Emote = new Method<>("emote",
|
// EMOTE
|
||||||
Types.EmoteRequest.class, String.class, String.class);
|
// =========================
|
||||||
|
public static final Method<Types.EmoteRequest, Void, String> Emote = new Method<>("emote",
|
||||||
|
Types.EmoteRequest.class,
|
||||||
|
Void.class,
|
||||||
|
String.class);
|
||||||
|
|
||||||
public static final Method<Types.EmoteEvent, String, String> EmoteEvent = new Method<>("emote_event",
|
public static final Method<Types.EmoteEvent, Void, Void> EmoteEvent = new Method<>("emote_event",
|
||||||
Types.EmoteEvent.class, String.class, String.class);
|
Types.EmoteEvent.class,
|
||||||
|
Void.class,
|
||||||
|
Void.class);
|
||||||
|
|
||||||
public static final Method<String, Types.Player, String> Player = new Method<>("player",
|
// =========================
|
||||||
String.class, Types.Player.class, String.class);
|
// GET PLAYER
|
||||||
|
// =========================
|
||||||
|
public static final Method<String, Types.Player, String> GetPlayer = new Method<>("get_player",
|
||||||
|
String.class,
|
||||||
|
Types.Player.class,
|
||||||
|
String.class);
|
||||||
|
|
||||||
|
// =========================
|
||||||
|
// PLAYER (Server Notification)
|
||||||
|
// =========================
|
||||||
|
public static final Method<Types.PlayerStream, Void, Void> Player = new Method<>("player",
|
||||||
|
Types.PlayerStream.class,
|
||||||
|
Void.class,
|
||||||
|
Void.class);
|
||||||
|
|
||||||
|
// =========================
|
||||||
|
// SEND PLAYER
|
||||||
|
// =========================
|
||||||
|
public static final Method<SendPlayerRequest, Void, String> SendPlayer = new Method<>("send_player",
|
||||||
|
SendPlayerRequest.class,
|
||||||
|
Void.class,
|
||||||
|
String.class);
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ public class SaturnPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getExternalUUIDAsString() {
|
public static String[] getExternalUUIDAsString() {
|
||||||
return PLAYERS.keySet().stream().filter(id -> !id.equals(ServiceClient.uuid)).map(UUID::toString)
|
return PLAYERS.keySet().stream().filter(id -> id.equals(ServiceClient.uuid)).map(UUID::toString)
|
||||||
.toArray(String[]::new);
|
.toArray(String[]::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class Cloaks {
|
|||||||
*/
|
*/
|
||||||
public static void setCloak(String cloakName) {
|
public static void setCloak(String cloakName) {
|
||||||
if (availableCloaks.contains(cloakName)) {
|
if (availableCloaks.contains(cloakName)) {
|
||||||
setCloak(ServiceClient.uuid, cloakName);
|
// setCloak(ServiceClient.uuid, cloakName);
|
||||||
ServiceClient.setCloak(cloakName);
|
ServiceClient.setCloak(cloakName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user