mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-19 14:59:20 +00:00
Simplified plugin message channel logic
This commit is contained in:
@@ -36,14 +36,12 @@ public interface PluginMessageChannel {
|
||||
|
||||
Result handleProxyCall(
|
||||
byte[] data,
|
||||
UUID targetUuid,
|
||||
String targetUsername,
|
||||
Identity targetIdentity,
|
||||
UUID sourceUuid,
|
||||
String sourceUsername,
|
||||
Identity sourceIdentity);
|
||||
Identity sourceIdentity
|
||||
);
|
||||
|
||||
Result handleServerCall(byte[] data, UUID targetUuid, String targetUsername);
|
||||
Result handleServerCall(byte[] data, UUID playerUuid, String playerUsername);
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
|
||||
@@ -56,13 +56,10 @@ public class FormChannel implements PluginMessageChannel {
|
||||
@Override
|
||||
public Result handleProxyCall(
|
||||
byte[] data,
|
||||
UUID targetUuid,
|
||||
String targetUsername,
|
||||
Identity targetIdentity,
|
||||
UUID sourceUuid,
|
||||
String sourceUsername,
|
||||
Identity sourceIdentity) {
|
||||
|
||||
Identity sourceIdentity
|
||||
) {
|
||||
if (sourceIdentity == Identity.SERVER) {
|
||||
// send it to the client
|
||||
return Result.forward();
|
||||
@@ -89,7 +86,7 @@ public class FormChannel implements PluginMessageChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result handleServerCall(byte[] data, UUID targetUuid, String targetUsername) {
|
||||
public Result handleServerCall(byte[] data, UUID playerUuid, String playerUsername) {
|
||||
callResponseConsumer(data);
|
||||
return Result.handled();
|
||||
}
|
||||
|
||||
@@ -40,23 +40,26 @@ public final class PacketChannel implements PluginMessageChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result handleProxyCall(byte[] data, UUID targetUuid, String targetUsername,
|
||||
Identity targetIdentity, UUID sourceUuid, String sourceUsername,
|
||||
Identity sourceIdentity) {
|
||||
public Result handleProxyCall(
|
||||
byte[] data,
|
||||
UUID sourceUuid,
|
||||
String sourceUsername,
|
||||
Identity sourceIdentity
|
||||
) {
|
||||
if (sourceIdentity == Identity.SERVER) {
|
||||
// send it to the client
|
||||
return Result.forward();
|
||||
}
|
||||
|
||||
if (sourceIdentity == Identity.PLAYER) {
|
||||
return handleServerCall(data, targetUuid, targetUsername);
|
||||
return handleServerCall(data, sourceUuid, sourceUsername);
|
||||
}
|
||||
|
||||
return Result.handled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result handleServerCall(byte[] data, UUID targetUuid, String targetUsername) {
|
||||
public Result handleServerCall(byte[] data, UUID playerUuid, String playerUsername) {
|
||||
return Result.kick("Cannot send packets from Geyser/Floodgate to Floodgate");
|
||||
}
|
||||
|
||||
|
||||
@@ -51,16 +51,13 @@ public class SkinChannel implements PluginMessageChannel {
|
||||
@Override
|
||||
public Result handleProxyCall(
|
||||
byte[] data,
|
||||
UUID targetUuid,
|
||||
String targetUsername,
|
||||
Identity targetIdentity,
|
||||
UUID sourceUuid,
|
||||
String sourceUsername,
|
||||
Identity sourceIdentity) {
|
||||
|
||||
Identity sourceIdentity
|
||||
) {
|
||||
// we can only get skins from Geyser (client)
|
||||
if (sourceIdentity == Identity.PLAYER) {
|
||||
Result result = handleServerCall(data, targetUuid, targetUsername);
|
||||
Result result = handleServerCall(data, sourceUuid, sourceUsername);
|
||||
// aka translate 'handled' into 'forward' when send-floodgate-data is enabled
|
||||
if (!result.isAllowed() && result.getReason() == null) {
|
||||
if (config.isProxy() && ((ProxyFloodgateConfig) config).isSendFloodgateData()) {
|
||||
@@ -78,8 +75,8 @@ public class SkinChannel implements PluginMessageChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result handleServerCall(byte[] data, UUID targetUuid, String targetUsername) {
|
||||
FloodgatePlayer floodgatePlayer = api.getPlayer(targetUuid);
|
||||
public Result handleServerCall(byte[] data, UUID playerUuid, String playerUsername) {
|
||||
FloodgatePlayer floodgatePlayer = api.getPlayer(playerUuid);
|
||||
if (floodgatePlayer == null) {
|
||||
return Result.kick("Player sent skins data for a non-Floodgate player");
|
||||
}
|
||||
|
||||
@@ -42,27 +42,24 @@ public class TransferChannel implements PluginMessageChannel {
|
||||
@Override
|
||||
public Result handleProxyCall(
|
||||
byte[] data,
|
||||
UUID targetUuid,
|
||||
String targetUsername,
|
||||
Identity targetIdentity,
|
||||
UUID sourceUuid,
|
||||
String sourceUsername,
|
||||
Identity sourceIdentity) {
|
||||
|
||||
Identity sourceIdentity
|
||||
) {
|
||||
if (sourceIdentity == Identity.SERVER) {
|
||||
// send it to the client
|
||||
return Result.forward();
|
||||
}
|
||||
|
||||
if (sourceIdentity == Identity.PLAYER) {
|
||||
handleServerCall(data, targetUuid, targetUsername);
|
||||
handleServerCall(data, sourceUuid, sourceUsername);
|
||||
}
|
||||
|
||||
return Result.handled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result handleServerCall(byte[] data, UUID targetUuid, String targetUsername) {
|
||||
public Result handleServerCall(byte[] data, UUID playerUuid, String playerUsername) {
|
||||
return Result.kick("I'm sorry, I'm unable to transfer a server :(");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user