mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-19 14:59:20 +00:00
Updated Cumulus to 1.1
This commit is contained in:
@@ -28,7 +28,7 @@ package org.geysermc.floodgate.api;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.geysermc.cumulus.Form;
|
||||
import org.geysermc.cumulus.form.Form;
|
||||
import org.geysermc.cumulus.util.FormBuilder;
|
||||
import org.geysermc.floodgate.api.link.PlayerLink;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
@@ -94,7 +94,7 @@ public interface FloodgateApi {
|
||||
|
||||
boolean sendForm(UUID uuid, Form form);
|
||||
|
||||
boolean sendForm(UUID uuid, FormBuilder<?, ?> formBuilder);
|
||||
boolean sendForm(UUID uuid, FormBuilder<?, ?, ?> formBuilder);
|
||||
|
||||
boolean transferPlayer(UUID uuid, String address, int port);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
package org.geysermc.floodgate.api.player;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.geysermc.cumulus.Form;
|
||||
import org.geysermc.cumulus.form.Form;
|
||||
import org.geysermc.cumulus.util.FormBuilder;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import org.geysermc.floodgate.util.DeviceOs;
|
||||
@@ -115,7 +115,7 @@ public interface FloodgatePlayer {
|
||||
return FloodgateApi.getInstance().sendForm(getCorrectUniqueId(), form);
|
||||
}
|
||||
|
||||
default boolean sendForm(FormBuilder<?, ?> formBuilder) {
|
||||
default boolean sendForm(FormBuilder<?, ?, ?> formBuilder) {
|
||||
return sendForm(formBuilder.build());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,17 +24,17 @@
|
||||
*/
|
||||
|
||||
object Versions {
|
||||
const val geyserVersion= "2.0.0-SNAPSHOT"
|
||||
const val cumulusVersion= "1.0-SNAPSHOT"
|
||||
const val spigotVersion= "1.13-R0.1-SNAPSHOT"
|
||||
const val fastutilVersion= "8.5.3"
|
||||
const val lombokVersion= "1.18.20"
|
||||
const val guiceVersion= "5.0.1"
|
||||
const val nettyVersion= "4.1.49.Final"
|
||||
const val snakeyamlVersion= "1.28"
|
||||
const val cloudVersion= "1.5.0"
|
||||
const val adventureApiVersion= "4.9.1"
|
||||
const val adventurePlatformVersion= "4.0.0"
|
||||
const val geyserVersion = "2.0.1-cumulus-SNAPSHOT"
|
||||
const val cumulusVersion = "1.1-SNAPSHOT"
|
||||
const val spigotVersion = "1.13-R0.1-SNAPSHOT"
|
||||
const val fastutilVersion = "8.5.3"
|
||||
const val lombokVersion = "1.18.20"
|
||||
const val guiceVersion = "5.0.1"
|
||||
const val nettyVersion = "4.1.49.Final"
|
||||
const val snakeyamlVersion = "1.28"
|
||||
const val cloudVersion = "1.5.0"
|
||||
const val adventureApiVersion = "4.9.1"
|
||||
const val adventurePlatformVersion = "4.0.0"
|
||||
|
||||
const val javaWebsocketVersion = "1.5.2"
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.geysermc.cumulus.Form;
|
||||
import org.geysermc.cumulus.form.Form;
|
||||
import org.geysermc.cumulus.util.FormBuilder;
|
||||
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
@@ -121,7 +121,7 @@ public class SimpleFloodgateApi implements FloodgateApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendForm(UUID uuid, FormBuilder<?, ?> formBuilder) {
|
||||
public boolean sendForm(UUID uuid, FormBuilder<?, ?, ?> formBuilder) {
|
||||
return sendForm(uuid, formBuilder.build());
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,16 @@ import it.unimi.dsi.fastutil.shorts.Short2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.geysermc.cumulus.Form;
|
||||
import org.geysermc.cumulus.form.Form;
|
||||
import org.geysermc.cumulus.form.impl.FormDefinition;
|
||||
import org.geysermc.cumulus.form.impl.FormDefinitions;
|
||||
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||
import org.geysermc.floodgate.config.FloodgateConfig;
|
||||
import org.geysermc.floodgate.platform.pluginmessage.PluginMessageUtils;
|
||||
import org.geysermc.floodgate.pluginmessage.PluginMessageChannel;
|
||||
|
||||
public class FormChannel implements PluginMessageChannel {
|
||||
private final FormDefinitions formDefinitions = FormDefinitions.instance();
|
||||
private final Short2ObjectMap<Form> storedForms = new Short2ObjectOpenHashMap<>();
|
||||
private final AtomicInteger nextFormId = new AtomicInteger(0);
|
||||
|
||||
@@ -103,10 +106,15 @@ public class FormChannel implements PluginMessageChannel {
|
||||
}
|
||||
storedForms.put(formId, form);
|
||||
|
||||
byte[] jsonData = form.getJsonData().getBytes(Charsets.UTF_8);
|
||||
FormDefinition<Form, ?, ?> definition = formDefinitions.definitionFor(form);
|
||||
|
||||
byte[] jsonData =
|
||||
definition.codec()
|
||||
.jsonData(form)
|
||||
.getBytes(Charsets.UTF_8);
|
||||
|
||||
byte[] data = new byte[jsonData.length + 3];
|
||||
data[0] = (byte) form.getType().ordinal();
|
||||
data[0] = (byte) definition.formType().ordinal();
|
||||
data[1] = (byte) (formId >> 8 & 0xFF);
|
||||
data[2] = (byte) (formId & 0xFF);
|
||||
System.arraycopy(jsonData, 0, data, 3, jsonData.length);
|
||||
@@ -117,7 +125,12 @@ public class FormChannel implements PluginMessageChannel {
|
||||
Form storedForm = storedForms.remove(getFormId(data));
|
||||
if (storedForm != null) {
|
||||
String responseData = new String(data, 2, data.length - 2, Charsets.UTF_8);
|
||||
storedForm.getResponseHandler().accept(responseData);
|
||||
try {
|
||||
formDefinitions.definitionFor(storedForm)
|
||||
.handleFormResponse(storedForm, responseData);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while processing form response!", e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user