From 45596a87a92c9f31de3f61ffa28e1f356957d5e7 Mon Sep 17 00:00:00 2001 From: Tim203 Date: Thu, 10 Dec 2020 22:57:48 +0100 Subject: [PATCH] Use Cumulus as form library --- common/pom.xml | 8 +- .../org/geysermc/common/form/CustomForm.java | 86 -------- .../java/org/geysermc/common/form/Form.java | 83 ------- .../org/geysermc/common/form/FormBuilder.java | 44 ---- .../org/geysermc/common/form/FormImage.java | 62 ------ .../org/geysermc/common/form/FormType.java | 51 ----- .../java/org/geysermc/common/form/Forms.java | 46 ---- .../org/geysermc/common/form/ModalForm.java | 47 ---- .../org/geysermc/common/form/SimpleForm.java | 61 ------ .../form/component/ButtonComponent.java | 47 ---- .../common/form/component/Component.java | 32 --- .../common/form/component/ComponentType.java | 61 ------ .../form/component/DropdownComponent.java | 63 ------ .../common/form/component/InputComponent.java | 46 ---- .../common/form/component/LabelComponent.java | 34 --- .../form/component/SliderComponent.java | 54 ----- .../form/component/StepSliderComponent.java | 71 ------ .../form/component/ToggleComponent.java | 40 ---- .../common/form/impl/CustomFormImpl.java | 179 --------------- .../geysermc/common/form/impl/FormImpl.java | 121 ---------- .../common/form/impl/ModalFormImpl.java | 105 --------- .../common/form/impl/SimpleFormImpl.java | 120 ---------- .../impl/component/ButtonComponentImpl.java | 52 ----- .../common/form/impl/component/Component.java | 45 ---- .../impl/component/DropdownComponentImpl.java | 102 --------- .../impl/component/InputComponentImpl.java | 56 ----- .../impl/component/LabelComponentImpl.java | 41 ---- .../impl/component/SliderComponentImpl.java | 76 ------- .../component/StepSliderComponentImpl.java | 118 ---------- .../impl/component/ToggleComponentImpl.java | 52 ----- .../impl/response/CustomFormResponseImpl.java | 207 ------------------ .../impl/response/ModalFormResponseImpl.java | 62 ------ .../impl/response/SimpleFormResponseImpl.java | 62 ------ .../common/form/impl/util/FormAdaptor.java | 129 ----------- .../common/form/impl/util/FormImageImpl.java | 46 ---- .../form/response/CustomFormResponse.java | 62 ------ .../common/form/response/FormResponse.java | 35 --- .../form/response/ModalFormResponse.java | 34 --- .../form/response/SimpleFormResponse.java | 34 --- connector/pom.xml | 1 - .../network/session/GeyserSession.java | 6 +- .../network/session/cache/FormCache.java | 14 +- ...edrockServerSettingsRequestTranslator.java | 3 +- .../java/JavaPluginMessageTranslator.java | 8 +- .../connector/utils/LoginEncryptionUtils.java | 8 +- .../connector/utils/SettingsUtils.java | 6 +- .../connector/utils/StatisticsUtils.java | 4 +- 47 files changed, 30 insertions(+), 2694 deletions(-) delete mode 100644 common/src/main/java/org/geysermc/common/form/CustomForm.java delete mode 100644 common/src/main/java/org/geysermc/common/form/Form.java delete mode 100644 common/src/main/java/org/geysermc/common/form/FormBuilder.java delete mode 100644 common/src/main/java/org/geysermc/common/form/FormImage.java delete mode 100644 common/src/main/java/org/geysermc/common/form/FormType.java delete mode 100644 common/src/main/java/org/geysermc/common/form/Forms.java delete mode 100644 common/src/main/java/org/geysermc/common/form/ModalForm.java delete mode 100644 common/src/main/java/org/geysermc/common/form/SimpleForm.java delete mode 100644 common/src/main/java/org/geysermc/common/form/component/ButtonComponent.java delete mode 100644 common/src/main/java/org/geysermc/common/form/component/Component.java delete mode 100644 common/src/main/java/org/geysermc/common/form/component/ComponentType.java delete mode 100644 common/src/main/java/org/geysermc/common/form/component/DropdownComponent.java delete mode 100644 common/src/main/java/org/geysermc/common/form/component/InputComponent.java delete mode 100644 common/src/main/java/org/geysermc/common/form/component/LabelComponent.java delete mode 100644 common/src/main/java/org/geysermc/common/form/component/SliderComponent.java delete mode 100644 common/src/main/java/org/geysermc/common/form/component/StepSliderComponent.java delete mode 100644 common/src/main/java/org/geysermc/common/form/component/ToggleComponent.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/CustomFormImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/FormImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/ModalFormImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/SimpleFormImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/component/ButtonComponentImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/component/Component.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/component/DropdownComponentImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/component/InputComponentImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/component/LabelComponentImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/component/SliderComponentImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/component/StepSliderComponentImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/component/ToggleComponentImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/response/CustomFormResponseImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/response/ModalFormResponseImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/response/SimpleFormResponseImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/util/FormAdaptor.java delete mode 100644 common/src/main/java/org/geysermc/common/form/impl/util/FormImageImpl.java delete mode 100644 common/src/main/java/org/geysermc/common/form/response/CustomFormResponse.java delete mode 100644 common/src/main/java/org/geysermc/common/form/response/FormResponse.java delete mode 100644 common/src/main/java/org/geysermc/common/form/response/ModalFormResponse.java delete mode 100644 common/src/main/java/org/geysermc/common/form/response/SimpleFormResponse.java diff --git a/common/pom.xml b/common/pom.xml index af5664ca1..0f4d5421b 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -11,11 +11,15 @@ common + + org.geysermc.cumulus + cumulus + 1.0-SNAPSHOT + com.google.code.gson gson - 2.8.5 - compile + 2.8.6 \ No newline at end of file diff --git a/common/src/main/java/org/geysermc/common/form/CustomForm.java b/common/src/main/java/org/geysermc/common/form/CustomForm.java deleted file mode 100644 index 41097b60e..000000000 --- a/common/src/main/java/org/geysermc/common/form/CustomForm.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form; - -import org.geysermc.common.form.component.Component; -import org.geysermc.common.form.component.DropdownComponent; -import org.geysermc.common.form.component.StepSliderComponent; -import org.geysermc.common.form.impl.CustomFormImpl; -import org.geysermc.common.form.response.CustomFormResponse; - -import java.util.List; - -public interface CustomForm extends Form { - static CustomForm.Builder builder() { - return new CustomFormImpl.Builder(); - } - - static CustomForm of(String title, FormImage icon, List content) { - return CustomFormImpl.of(title, icon, content); - } - - interface Builder extends FormBuilder { - Builder icon(FormImage.Type type, String data); - - Builder iconPath(String path); - - Builder iconUrl(String url); - - Builder component(Component component); - - Builder dropdown(DropdownComponent.Builder dropdownBuilder); - - Builder dropdown(String text, int defaultOption, String... options); - - Builder dropdown(String text, String... options); - - Builder input(String text, String placeholder, String defaultText); - - Builder input(String text, String placeholder); - - Builder input(String text); - - Builder label(String text); - - Builder slider(String text, float min, float max, int step, float defaultValue); - - Builder slider(String text, float min, float max, int step); - - Builder slider(String text, float min, float max, float defaultValue); - - Builder slider(String text, float min, float max); - - Builder stepSlider(StepSliderComponent.Builder stepSliderBuilder); - - Builder stepSlider(String text, int defaultStep, String... steps); - - Builder stepSlider(String text, String... steps); - - Builder toggle(String text, boolean defaultValue); - - Builder toggle(String text); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/Form.java b/common/src/main/java/org/geysermc/common/form/Form.java deleted file mode 100644 index 6fd1cbc2d..000000000 --- a/common/src/main/java/org/geysermc/common/form/Form.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form; - -import org.geysermc.common.form.response.FormResponse; - -import java.util.function.Consumer; - -/** - * Base class of all Forms. While it can be used it doesn't contain every data you could get when - * using the specific class of the form type. - * - * @param class provided by the specific form type. It understands the response data and makes - * the data easily accessible - */ -public interface Form { - /** - * Returns the form type of this specific instance. The valid form types can be found {@link - * FormType in the FormType class} - */ - FormType getType(); - - /** - * Returns the data that will be sent by Geyser to the Bedrock client - */ - String getJsonData(); - - /** - * Returns the handler that will be invoked once the form got a response from the Bedrock - * client - */ - Consumer getResponseHandler(); - - /** - * Sets the handler that will be invoked once the form got a response from the Bedrock client. - * This handler contains the raw data sent by the Bedrock client. See {@link - * #parseResponse(String)} if you want to turn the given data into something that's easier to - * handle. - * - * @param responseHandler the response handler - */ - void setResponseHandler(Consumer responseHandler); - - /** - * Parses the method into something provided by the form implementation, which will make the - * data given by the Bedrock client easier to handle. - * - * @param response the raw data given by the Bedrock client - * @return the data in an easy-to-handle class - */ - T parseResponse(String response); - - /** - * Checks if the given data by the Bedrock client is saying that the client closed the form. - * - * @param response the raw data given by the Bedrock client - * @return true if the raw data implies that the Bedrock client closed the form - */ - boolean isClosed(String response); -} diff --git a/common/src/main/java/org/geysermc/common/form/FormBuilder.java b/common/src/main/java/org/geysermc/common/form/FormBuilder.java deleted file mode 100644 index f5a1ce76d..000000000 --- a/common/src/main/java/org/geysermc/common/form/FormBuilder.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form; - -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.Consumer; - -public interface FormBuilder, F extends Form> { - T title(String title); - - T translator(BiFunction translator, String locale); - - T translator(BiFunction translator); - - T responseHandler(BiConsumer responseHandler); - - T responseHandler(Consumer responseHandler); - - F build(); -} diff --git a/common/src/main/java/org/geysermc/common/form/FormImage.java b/common/src/main/java/org/geysermc/common/form/FormImage.java deleted file mode 100644 index f5672923f..000000000 --- a/common/src/main/java/org/geysermc/common/form/FormImage.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form; - -import com.google.gson.annotations.SerializedName; -import lombok.RequiredArgsConstructor; -import org.geysermc.common.form.impl.util.FormImageImpl; - -public interface FormImage { - static FormImage of(Type type, String data) { - return FormImageImpl.of(type, data); - } - - static FormImage of(String type, String data) { - return FormImageImpl.of(type, data); - } - - Type getType(); - - String getData(); - - @RequiredArgsConstructor - enum Type { - @SerializedName("path") PATH, - @SerializedName("url") URL; - - private static final Type[] VALUES = values(); - - public static Type getByName(String name) { - String upper = name.toUpperCase(); - for (Type value : VALUES) { - if (value.name().equals(upper)) { - return value; - } - } - return null; - } - } -} diff --git a/common/src/main/java/org/geysermc/common/form/FormType.java b/common/src/main/java/org/geysermc/common/form/FormType.java deleted file mode 100644 index 064dec4b3..000000000 --- a/common/src/main/java/org/geysermc/common/form/FormType.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form; - -import com.google.gson.annotations.SerializedName; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.geysermc.common.form.impl.CustomFormImpl; -import org.geysermc.common.form.impl.ModalFormImpl; -import org.geysermc.common.form.impl.SimpleFormImpl; - -@Getter -@RequiredArgsConstructor -public enum FormType { - @SerializedName("form") - SIMPLE_FORM(SimpleFormImpl.class), - @SerializedName("modal") - MODAL_FORM(ModalFormImpl.class), - @SerializedName("custom_form") - CUSTOM_FORM(CustomFormImpl.class); - - private static final FormType[] VALUES = values(); - private final Class typeClass; - - public static FormType getByOrdinal(int ordinal) { - return ordinal < VALUES.length ? VALUES[ordinal] : null; - } -} diff --git a/common/src/main/java/org/geysermc/common/form/Forms.java b/common/src/main/java/org/geysermc/common/form/Forms.java deleted file mode 100644 index 1a1c0a4cb..000000000 --- a/common/src/main/java/org/geysermc/common/form/Forms.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import org.geysermc.common.form.impl.FormImpl; -import org.geysermc.common.form.impl.util.FormAdaptor; - -public final class Forms { - private static final Gson GSON = - new GsonBuilder() - .registerTypeAdapter(FormImpl.class, new FormAdaptor()) - .create(); - - public static Gson getGson() { - return GSON; - } - - public static > T fromJson(String json, Class formClass) { - return GSON.fromJson(json, formClass); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/ModalForm.java b/common/src/main/java/org/geysermc/common/form/ModalForm.java deleted file mode 100644 index 8e35bc8b0..000000000 --- a/common/src/main/java/org/geysermc/common/form/ModalForm.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form; - -import org.geysermc.common.form.impl.ModalFormImpl; -import org.geysermc.common.form.response.ModalFormResponse; - -public interface ModalForm extends Form { - static Builder builder() { - return new ModalFormImpl.Builder(); - } - - static ModalForm of(String title, String content, String button1, String button2) { - return ModalFormImpl.of(title, content, button1, button2); - } - - interface Builder extends FormBuilder { - Builder content(String content); - - Builder button1(String button1); - - Builder button2(String button2); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/SimpleForm.java b/common/src/main/java/org/geysermc/common/form/SimpleForm.java deleted file mode 100644 index dd11544b9..000000000 --- a/common/src/main/java/org/geysermc/common/form/SimpleForm.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form; - -import org.geysermc.common.form.component.ButtonComponent; -import org.geysermc.common.form.impl.SimpleFormImpl; -import org.geysermc.common.form.response.SimpleFormResponse; - -import java.util.List; - -/** - * - */ -public interface SimpleForm extends Form { - static Builder builder() { - return new SimpleFormImpl.Builder(); - } - - static SimpleForm of(String title, String content, List buttons) { - return SimpleFormImpl.of(title, content, buttons); - } - - String getTitle(); - - String getContent(); - - List getButtons(); - - interface Builder extends FormBuilder { - Builder content(String content); - - Builder button(String text, FormImage.Type type, String data); - - Builder button(String text, FormImage image); - - Builder button(String text); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/component/ButtonComponent.java b/common/src/main/java/org/geysermc/common/form/component/ButtonComponent.java deleted file mode 100644 index 3e8f5d438..000000000 --- a/common/src/main/java/org/geysermc/common/form/component/ButtonComponent.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.component; - -import org.geysermc.common.form.FormImage; -import org.geysermc.common.form.impl.component.ButtonComponentImpl; - -public interface ButtonComponent { - static ButtonComponent of(String text, FormImage image) { - return ButtonComponentImpl.of(text, image); - } - - static ButtonComponent of(String text, FormImage.Type type, String data) { - return ButtonComponentImpl.of(text, type, data); - } - - static ButtonComponent of(String text) { - return of(text, null); - } - - String getText(); - - FormImage getImage(); -} diff --git a/common/src/main/java/org/geysermc/common/form/component/Component.java b/common/src/main/java/org/geysermc/common/form/component/Component.java deleted file mode 100644 index 524d2a1a9..000000000 --- a/common/src/main/java/org/geysermc/common/form/component/Component.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.component; - -public interface Component { - ComponentType getType(); - - String getText(); -} diff --git a/common/src/main/java/org/geysermc/common/form/component/ComponentType.java b/common/src/main/java/org/geysermc/common/form/component/ComponentType.java deleted file mode 100644 index 898e10d07..000000000 --- a/common/src/main/java/org/geysermc/common/form/component/ComponentType.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.component; - -import com.google.gson.annotations.SerializedName; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor -public enum ComponentType { - @SerializedName("dropdown") - DROPDOWN(DropdownComponent.class), - @SerializedName("input") - INPUT(InputComponent.class), - @SerializedName("label") - LABEL(LabelComponent.class), - @SerializedName("slider") - SLIDER(SliderComponent.class), - @SerializedName("step_slider") - STEP_SLIDER(StepSliderComponent.class), - @SerializedName("toggle") - TOGGLE(ToggleComponent.class); - - private static final ComponentType[] VALUES = values(); - - private final String name = name().toLowerCase(); - private final Class componentClass; - - public static ComponentType getByName(String name) { - for (ComponentType type : VALUES) { - if (type.name.equals(name)) { - return type; - } - } - return null; - } -} diff --git a/common/src/main/java/org/geysermc/common/form/component/DropdownComponent.java b/common/src/main/java/org/geysermc/common/form/component/DropdownComponent.java deleted file mode 100644 index a68b3b1e2..000000000 --- a/common/src/main/java/org/geysermc/common/form/component/DropdownComponent.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.component; - -import org.geysermc.common.form.impl.component.DropdownComponentImpl; - -import java.util.List; -import java.util.function.Function; - -public interface DropdownComponent extends Component { - static DropdownComponent of(String text, List options, int defaultOption) { - return DropdownComponentImpl.of(text, options, defaultOption); - } - - static Builder builder() { - return new DropdownComponentImpl.Builder(); - } - - static Builder builder(String text) { - return builder().text(text); - } - - List getOptions(); - - int getDefaultOption(); - - interface Builder { - Builder text(String text); - - Builder option(String option, boolean isDefault); - - Builder option(String option); - - Builder defaultOption(int defaultOption); - - DropdownComponent build(); - - DropdownComponent translateAndBuild(Function translator); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/component/InputComponent.java b/common/src/main/java/org/geysermc/common/form/component/InputComponent.java deleted file mode 100644 index 4f054957c..000000000 --- a/common/src/main/java/org/geysermc/common/form/component/InputComponent.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.component; - -import org.geysermc.common.form.impl.component.InputComponentImpl; - -public interface InputComponent extends Component { - static InputComponent of(String text, String placeholder, String defaultText) { - return InputComponentImpl.of(text, placeholder, defaultText); - } - - static InputComponent of(String text, String placeholder) { - return InputComponentImpl.of(text, placeholder, ""); - } - - static InputComponent of(String text) { - return InputComponentImpl.of(text, "", ""); - } - - String getPlaceholder(); - - String getDefaultText(); -} diff --git a/common/src/main/java/org/geysermc/common/form/component/LabelComponent.java b/common/src/main/java/org/geysermc/common/form/component/LabelComponent.java deleted file mode 100644 index ed6f47029..000000000 --- a/common/src/main/java/org/geysermc/common/form/component/LabelComponent.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.component; - -import org.geysermc.common.form.impl.component.LabelComponentImpl; - -public interface LabelComponent extends Component { - static LabelComponent of(String text) { - return LabelComponentImpl.of(text); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/component/SliderComponent.java b/common/src/main/java/org/geysermc/common/form/component/SliderComponent.java deleted file mode 100644 index 9a0e3343e..000000000 --- a/common/src/main/java/org/geysermc/common/form/component/SliderComponent.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.component; - -import org.geysermc.common.form.impl.component.SliderComponentImpl; - -public interface SliderComponent extends Component { - static SliderComponent of(String text, float min, float max, int step, float defaultValue) { - return SliderComponentImpl.of(text, min, max, step, defaultValue); - } - - static SliderComponent of(String text, float min, float max, int step) { - return SliderComponentImpl.of(text, min, max, step); - } - - static SliderComponent of(String text, float min, float max, float defaultValue) { - return SliderComponentImpl.of(text, min, max, defaultValue); - } - - static SliderComponent of(String text, float min, float max) { - return SliderComponentImpl.of(text, min, max); - } - - float getMin(); - - float getMax(); - - int getStep(); - - float getDefaultValue(); -} diff --git a/common/src/main/java/org/geysermc/common/form/component/StepSliderComponent.java b/common/src/main/java/org/geysermc/common/form/component/StepSliderComponent.java deleted file mode 100644 index cda4e7acb..000000000 --- a/common/src/main/java/org/geysermc/common/form/component/StepSliderComponent.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.component; - -import org.geysermc.common.form.impl.component.StepSliderComponentImpl; - -import java.util.List; -import java.util.function.Function; - -public interface StepSliderComponent extends Component { - static StepSliderComponent of(String text, List steps, int defaultStep) { - return StepSliderComponentImpl.of(text, steps, defaultStep); - } - - static StepSliderComponent of(String text, int defaultStep, String... steps) { - return StepSliderComponentImpl.of(text, defaultStep, steps); - } - - static StepSliderComponent of(String text, String... steps) { - return StepSliderComponentImpl.of(text, steps); - } - - static Builder builder() { - return new StepSliderComponentImpl.Builder(); - } - - static Builder builder(String text) { - return builder().text(text); - } - - List getSteps(); - - int getDefaultStep(); - - interface Builder { - Builder text(String text); - - Builder step(String step, boolean defaultStep); - - Builder step(String step); - - Builder defaultStep(int defaultStep); - - StepSliderComponent build(); - - StepSliderComponent translateAndBuild(Function translator); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/component/ToggleComponent.java b/common/src/main/java/org/geysermc/common/form/component/ToggleComponent.java deleted file mode 100644 index e505e995b..000000000 --- a/common/src/main/java/org/geysermc/common/form/component/ToggleComponent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.component; - -import org.geysermc.common.form.impl.component.ToggleComponentImpl; - -public interface ToggleComponent extends Component { - static ToggleComponent of(String text, boolean defaultValue) { - return ToggleComponentImpl.of(text, defaultValue); - } - - static ToggleComponent of(String text) { - return ToggleComponentImpl.of(text); - } - - boolean getDefaultValue(); -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/CustomFormImpl.java b/common/src/main/java/org/geysermc/common/form/impl/CustomFormImpl.java deleted file mode 100644 index 4d1f80713..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/CustomFormImpl.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl; - -import com.google.gson.annotations.JsonAdapter; -import lombok.Getter; -import org.geysermc.common.form.CustomForm; -import org.geysermc.common.form.FormImage; -import org.geysermc.common.form.FormType; -import org.geysermc.common.form.component.*; -import org.geysermc.common.form.impl.response.CustomFormResponseImpl; -import org.geysermc.common.form.impl.util.FormAdaptor; -import org.geysermc.common.form.impl.util.FormImageImpl; -import org.geysermc.common.form.response.CustomFormResponse; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@Getter -@JsonAdapter(FormAdaptor.class) -public final class CustomFormImpl extends FormImpl implements CustomForm { - private final String title; - private final FormImage icon; - private final List content; - - private CustomFormImpl(String title, FormImage icon, List content) { - super(FormType.CUSTOM_FORM); - - this.title = title; - this.icon = icon; - this.content = Collections.unmodifiableList(content); - } - - public static CustomFormImpl of(String title, FormImage icon, List content) { - return new CustomFormImpl(title, icon, content); - } - - public CustomFormResponseImpl parseResponse(String data) { - if (isClosed(data)) { - return CustomFormResponseImpl.closed(); - } - return CustomFormResponseImpl.of(this, data); - } - - public static final class Builder extends FormImpl.Builder - implements CustomForm.Builder { - - private final List components = new ArrayList<>(); - private FormImage icon; - - public Builder icon(FormImage.Type type, String data) { - icon = FormImageImpl.of(type, data); - return this; - } - - public Builder iconPath(String path) { - return icon(FormImage.Type.PATH, path); - } - - public Builder iconUrl(String url) { - return icon(FormImage.Type.URL, url); - } - - public Builder component(Component component) { - components.add(component); - return this; - } - - public Builder dropdown(DropdownComponent.Builder dropdownBuilder) { - return component(dropdownBuilder.translateAndBuild(this::translate)); - } - - public Builder dropdown(String text, int defaultOption, String... options) { - List optionsList = new ArrayList<>(); - for (String option : options) { - optionsList.add(translate(option)); - } - return component(DropdownComponent.of(translate(text), optionsList, defaultOption)); - } - - public Builder dropdown(String text, String... options) { - return dropdown(text, -1, options); - } - - public Builder input(String text, String placeholder, String defaultText) { - return component(InputComponent.of( - translate(text), translate(placeholder), translate(defaultText) - )); - } - - public Builder input(String text, String placeholder) { - return component(InputComponent.of(translate(text), translate(placeholder))); - } - - public Builder input(String text) { - return component(InputComponent.of(translate(text))); - } - - public Builder label(String text) { - return component(LabelComponent.of(translate(text))); - } - - public Builder slider(String text, float min, float max, int step, float defaultValue) { - return component(SliderComponent.of(text, min, max, step, defaultValue)); - } - - public Builder slider(String text, float min, float max, int step) { - return slider(text, min, max, step, -1); - } - - public Builder slider(String text, float min, float max, float defaultValue) { - return slider(text, min, max, -1, defaultValue); - } - - public Builder slider(String text, float min, float max) { - return slider(text, min, max, -1, -1); - } - - public Builder stepSlider(StepSliderComponent.Builder stepSliderBuilder) { - return component(stepSliderBuilder.translateAndBuild(this::translate)); - } - - public Builder stepSlider(String text, int defaultStep, String... steps) { - List stepsList = new ArrayList<>(); - for (String option : steps) { - stepsList.add(translate(option)); - } - return component(StepSliderComponent.of(translate(text), stepsList, defaultStep)); - } - - public Builder stepSlider(String text, String... steps) { - return stepSlider(text, -1, steps); - } - - public Builder toggle(String text, boolean defaultValue) { - return component(ToggleComponent.of(translate(text), defaultValue)); - } - - public Builder toggle(String text) { - return component(ToggleComponent.of(translate(text))); - } - - @Override - public CustomFormImpl build() { - CustomFormImpl form = of(title, icon, components); - if (biResponseHandler != null) { - form.setResponseHandler(response -> biResponseHandler.accept(form, response)); - return form; - } - - form.setResponseHandler(responseHandler); - return form; - } - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/FormImpl.java b/common/src/main/java/org/geysermc/common/form/impl/FormImpl.java deleted file mode 100644 index e9d648b8b..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/FormImpl.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl; - -import com.google.gson.Gson; -import lombok.Getter; -import lombok.Setter; -import org.geysermc.common.form.Form; -import org.geysermc.common.form.FormBuilder; -import org.geysermc.common.form.FormType; -import org.geysermc.common.form.Forms; -import org.geysermc.common.form.response.FormResponse; - -import java.util.function.BiConsumer; -import java.util.function.BiFunction; -import java.util.function.Consumer; - -@Getter -public abstract class FormImpl implements Form { - protected static final Gson GSON = Forms.getGson(); - - private final FormType type; - protected String hardcodedJsonData = null; - @Setter protected Consumer responseHandler; - - public FormImpl(FormType type) { - this.type = type; - } - - @Override - public String getJsonData() { - if (hardcodedJsonData != null) { - return hardcodedJsonData; - } - return GSON.toJson(this); - } - - @Override - public boolean isClosed(String response) { - return response == null || response.isEmpty() || response.equalsIgnoreCase("null"); - } - - public static abstract class Builder, F extends Form> - implements FormBuilder { - - protected String title = ""; - - protected BiFunction translationHandler = null; - protected BiConsumer biResponseHandler; - protected Consumer responseHandler; - protected String locale; - - @Override - public T title(String title) { - this.title = translate(title); - return self(); - } - - @Override - public T translator(BiFunction translator, String locale) { - this.translationHandler = translator; - this.locale = locale; - return title(title); - } - - @Override - public T translator(BiFunction translator) { - return translator(translator, locale); - } - - @Override - public T responseHandler(BiConsumer responseHandler) { - biResponseHandler = responseHandler; - return self(); - } - - @Override - public T responseHandler(Consumer responseHandler) { - this.responseHandler = responseHandler; - return self(); - } - - @Override - public abstract F build(); - - protected String translate(String text) { - if (translationHandler != null && text != null && !text.isEmpty()) { - return translationHandler.apply(text, locale); - } - return text; - } - - @SuppressWarnings("unchecked") - protected T self() { - return (T) this; - } - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/ModalFormImpl.java b/common/src/main/java/org/geysermc/common/form/impl/ModalFormImpl.java deleted file mode 100644 index b047dc59d..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/ModalFormImpl.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl; - -import com.google.gson.annotations.JsonAdapter; -import lombok.Getter; -import org.geysermc.common.form.FormType; -import org.geysermc.common.form.ModalForm; -import org.geysermc.common.form.impl.response.ModalFormResponseImpl; -import org.geysermc.common.form.impl.util.FormAdaptor; -import org.geysermc.common.form.response.ModalFormResponse; - -@Getter -@JsonAdapter(FormAdaptor.class) -public final class ModalFormImpl extends FormImpl implements ModalForm { - private final String title; - private final String content; - private final String button1; - private final String button2; - - private ModalFormImpl(String title, String content, String button1, String button2) { - super(FormType.MODAL_FORM); - - this.title = title; - this.content = content; - this.button1 = button1; - this.button2 = button2; - } - - public static ModalFormImpl of(String title, String content, String button1, String button2) { - return new ModalFormImpl(title, content, button1, button2); - } - - public ModalFormResponse parseResponse(String data) { - if (isClosed(data)) { - return ModalFormResponseImpl.closed(); - } - data = data.trim(); - - if ("true".equals(data)) { - return ModalFormResponseImpl.of(0, button1); - } else if ("false".equals(data)) { - return ModalFormResponseImpl.of(1, button2); - } - return ModalFormResponseImpl.invalid(); - } - - public static final class Builder extends FormImpl.Builder - implements ModalForm.Builder { - - private String content = ""; - private String button1 = ""; - private String button2 = ""; - - public Builder content(String content) { - this.content = translate(content); - return this; - } - - public Builder button1(String button1) { - this.button1 = translate(button1); - return this; - } - - public Builder button2(String button2) { - this.button2 = translate(button2); - return this; - } - - @Override - public ModalForm build() { - ModalFormImpl form = of(title, content, button1, button2); - if (biResponseHandler != null) { - form.setResponseHandler(response -> biResponseHandler.accept(form, response)); - return form; - } - - form.setResponseHandler(responseHandler); - return form; - } - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/SimpleFormImpl.java b/common/src/main/java/org/geysermc/common/form/impl/SimpleFormImpl.java deleted file mode 100644 index d5633ec05..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/SimpleFormImpl.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl; - -import com.google.gson.annotations.JsonAdapter; -import lombok.Getter; -import org.geysermc.common.form.FormImage; -import org.geysermc.common.form.FormType; -import org.geysermc.common.form.SimpleForm; -import org.geysermc.common.form.component.ButtonComponent; -import org.geysermc.common.form.impl.component.ButtonComponentImpl; -import org.geysermc.common.form.impl.response.SimpleFormResponseImpl; -import org.geysermc.common.form.impl.util.FormAdaptor; -import org.geysermc.common.form.response.SimpleFormResponse; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@Getter -@JsonAdapter(FormAdaptor.class) -public final class SimpleFormImpl extends FormImpl implements SimpleForm { - private final String title; - private final String content; - private final List buttons; - - private SimpleFormImpl(String title, String content, List buttons) { - super(FormType.SIMPLE_FORM); - - this.title = title; - this.content = content; - this.buttons = Collections.unmodifiableList(buttons); - } - - public static SimpleFormImpl of(String title, String content, List buttons) { - return new SimpleFormImpl(title, content, buttons); - } - - public SimpleFormResponse parseResponse(String data) { - if (isClosed(data)) { - return SimpleFormResponseImpl.closed(); - } - data = data.trim(); - - int buttonId; - try { - buttonId = Integer.parseInt(data); - } catch (Exception exception) { - return SimpleFormResponseImpl.invalid(); - } - - if (buttonId >= buttons.size()) { - return SimpleFormResponseImpl.invalid(); - } - - return SimpleFormResponseImpl.of(buttonId, buttons.get(buttonId)); - } - - public static final class Builder extends FormImpl.Builder - implements SimpleForm.Builder { - - private final List buttons = new ArrayList<>(); - private String content = ""; - - public Builder content(String content) { - this.content = translate(content); - return this; - } - - public Builder button(String text, FormImage.Type type, String data) { - buttons.add(ButtonComponentImpl.of(translate(text), type, data)); - return this; - } - - public Builder button(String text, FormImage image) { - buttons.add(ButtonComponentImpl.of(translate(text), image)); - return this; - } - - public Builder button(String text) { - buttons.add(ButtonComponentImpl.of(translate(text))); - return this; - } - - @Override - public SimpleForm build() { - SimpleFormImpl form = of(title, content, buttons); - if (biResponseHandler != null) { - form.setResponseHandler(response -> biResponseHandler.accept(form, response)); - return form; - } - - form.setResponseHandler(responseHandler); - return form; - } - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/component/ButtonComponentImpl.java b/common/src/main/java/org/geysermc/common/form/impl/component/ButtonComponentImpl.java deleted file mode 100644 index 0efac1a6d..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/component/ButtonComponentImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl.component; - -import lombok.AccessLevel; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.geysermc.common.form.FormImage; -import org.geysermc.common.form.component.ButtonComponent; -import org.geysermc.common.form.impl.util.FormImageImpl; - -@Getter -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) -public final class ButtonComponentImpl implements ButtonComponent { - private final String text; - private final FormImageImpl image; - - public static ButtonComponentImpl of(String text, FormImage image) { - return new ButtonComponentImpl(text, (FormImageImpl) image); - } - - public static ButtonComponentImpl of(String text, FormImage.Type type, String data) { - return of(text, FormImageImpl.of(type, data)); - } - - public static ButtonComponentImpl of(String text) { - return of(text, null); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/component/Component.java b/common/src/main/java/org/geysermc/common/form/impl/component/Component.java deleted file mode 100644 index ff2f29f87..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/component/Component.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl.component; - -import lombok.Getter; -import org.geysermc.common.form.component.ComponentType; - -import java.util.Objects; - -@Getter -public abstract class Component { - private final ComponentType type; - private final String text; - - Component(ComponentType type, String text) { - Objects.requireNonNull(type, "Type cannot be null"); - Objects.requireNonNull(text, "Text cannot be null"); - - this.type = type; - this.text = text; - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/component/DropdownComponentImpl.java b/common/src/main/java/org/geysermc/common/form/impl/component/DropdownComponentImpl.java deleted file mode 100644 index ae175ab74..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/component/DropdownComponentImpl.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl.component; - -import com.google.gson.annotations.SerializedName; -import lombok.Getter; -import org.geysermc.common.form.component.ComponentType; -import org.geysermc.common.form.component.DropdownComponent; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.function.Function; - -@Getter -public final class DropdownComponentImpl extends Component implements DropdownComponent { - private final List options; - @SerializedName("default") - private final int defaultOption; - - private DropdownComponentImpl(String text, List options, int defaultOption) { - super(ComponentType.DROPDOWN, text); - this.options = Collections.unmodifiableList(options); - this.defaultOption = defaultOption; - } - - public static DropdownComponentImpl of(String text, List options, int defaultOption) { - if (defaultOption == -1 || defaultOption >= options.size()) { - defaultOption = 0; - } - return new DropdownComponentImpl(text, options, defaultOption); - } - - public static class Builder implements DropdownComponent.Builder { - private final List options = new ArrayList<>(); - private String text; - private int defaultOption = 0; - - @Override - public Builder text(String text) { - this.text = text; - return this; - } - - @Override - public Builder option(String option, boolean isDefault) { - options.add(option); - if (isDefault) { - defaultOption = options.size() - 1; - } - return this; - } - - @Override - public Builder option(String option) { - return option(option, false); - } - - @Override - public Builder defaultOption(int defaultOption) { - this.defaultOption = defaultOption; - return this; - } - - @Override - public DropdownComponentImpl build() { - return of(text, options, defaultOption); - } - - @Override - public DropdownComponentImpl translateAndBuild(Function translator) { - for (int i = 0; i < options.size(); i++) { - options.set(i, translator.apply(options.get(i))); - } - - return of(translator.apply(text), options, defaultOption); - } - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/component/InputComponentImpl.java b/common/src/main/java/org/geysermc/common/form/impl/component/InputComponentImpl.java deleted file mode 100644 index ba741304b..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/component/InputComponentImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl.component; - -import com.google.gson.annotations.SerializedName; -import lombok.Getter; -import org.geysermc.common.form.component.ComponentType; -import org.geysermc.common.form.component.InputComponent; - -@Getter -public final class InputComponentImpl extends Component implements InputComponent { - private final String placeholder; - @SerializedName("default") - private final String defaultText; - - private InputComponentImpl(String text, String placeholder, String defaultText) { - super(ComponentType.INPUT, text); - this.placeholder = placeholder; - this.defaultText = defaultText; - } - - public static InputComponentImpl of(String text, String placeholder, String defaultText) { - return new InputComponentImpl(text, placeholder, defaultText); - } - - public static InputComponentImpl of(String text, String placeholder) { - return new InputComponentImpl(text, placeholder, ""); - } - - public static InputComponentImpl of(String text) { - return new InputComponentImpl(text, "", ""); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/component/LabelComponentImpl.java b/common/src/main/java/org/geysermc/common/form/impl/component/LabelComponentImpl.java deleted file mode 100644 index 4dacb8406..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/component/LabelComponentImpl.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl.component; - -import lombok.Getter; -import org.geysermc.common.form.component.ComponentType; -import org.geysermc.common.form.component.LabelComponent; - -@Getter -public final class LabelComponentImpl extends Component implements LabelComponent { - private LabelComponentImpl(String text) { - super(ComponentType.LABEL, text); - } - - public static LabelComponentImpl of(String text) { - return new LabelComponentImpl(text); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/component/SliderComponentImpl.java b/common/src/main/java/org/geysermc/common/form/impl/component/SliderComponentImpl.java deleted file mode 100644 index 29fc18dc8..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/component/SliderComponentImpl.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl.component; - -import com.google.gson.annotations.SerializedName; -import lombok.Getter; -import org.geysermc.common.form.component.ComponentType; -import org.geysermc.common.form.component.SliderComponent; - -@Getter -public final class SliderComponentImpl extends Component implements SliderComponent { - private final float min; - private final float max; - private final int step; - @SerializedName("default") - private final float defaultValue; - - private SliderComponentImpl(String text, float min, float max, int step, float defaultValue) { - super(ComponentType.SLIDER, text); - this.min = min; - this.max = max; - this.step = step; - this.defaultValue = defaultValue; - } - - public static SliderComponentImpl of(String text, float min, float max, int step, - float defaultValue) { - min = Math.max(min, 0f); - max = Math.max(max, min); - - if (step < 1) { - step = 1; - } - - if (defaultValue == -1f) { - defaultValue = (int) Math.floor(min + max / 2D); - } - - return new SliderComponentImpl(text, min, max, step, defaultValue); - } - - public static SliderComponentImpl of(String text, float min, float max, int step) { - return of(text, min, max, step, -1); - } - - public static SliderComponentImpl of(String text, float min, float max, float defaultValue) { - return of(text, min, max, -1, defaultValue); - } - - public static SliderComponentImpl of(String text, float min, float max) { - return of(text, min, max, -1, -1); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/component/StepSliderComponentImpl.java b/common/src/main/java/org/geysermc/common/form/impl/component/StepSliderComponentImpl.java deleted file mode 100644 index dc87c54a5..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/component/StepSliderComponentImpl.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl.component; - -import com.google.gson.annotations.SerializedName; -import lombok.Getter; -import org.geysermc.common.form.component.ComponentType; -import org.geysermc.common.form.component.StepSliderComponent; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.function.Function; - -@Getter -public final class StepSliderComponentImpl extends Component implements StepSliderComponent { - private final List steps; - @SerializedName("default") - private final int defaultStep; - - private StepSliderComponentImpl(String text, List steps, int defaultStep) { - super(ComponentType.STEP_SLIDER, text); - this.steps = Collections.unmodifiableList(steps); - this.defaultStep = defaultStep; - } - - public static StepSliderComponentImpl of(String text, List steps, int defaultStep) { - if (text == null) { - text = ""; - } - - if (defaultStep >= steps.size() || defaultStep == -1) { - defaultStep = 0; - } - - return new StepSliderComponentImpl(text, steps, defaultStep); - } - - public static StepSliderComponentImpl of(String text, int defaultStep, String... steps) { - return of(text, Arrays.asList(steps), defaultStep); - } - - public static StepSliderComponentImpl of(String text, String... steps) { - return of(text, 0, steps); - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(String text) { - return builder().text(text); - } - - public static final class Builder implements StepSliderComponent.Builder { - private final List steps = new ArrayList<>(); - private String text; - private int defaultStep; - - public Builder text(String text) { - this.text = text; - return this; - } - - public Builder step(String step, boolean defaultStep) { - steps.add(step); - if (defaultStep) { - this.defaultStep = steps.size() - 1; - } - return this; - } - - public Builder step(String step) { - return step(step, false); - } - - public Builder defaultStep(int defaultStep) { - this.defaultStep = defaultStep; - return this; - } - - public StepSliderComponentImpl build() { - return of(text, steps, defaultStep); - } - - public StepSliderComponentImpl translateAndBuild(Function translator) { - for (int i = 0; i < steps.size(); i++) { - steps.set(i, translator.apply(steps.get(i))); - } - - return of(translator.apply(text), steps, defaultStep); - } - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/component/ToggleComponentImpl.java b/common/src/main/java/org/geysermc/common/form/impl/component/ToggleComponentImpl.java deleted file mode 100644 index 0e29462b3..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/component/ToggleComponentImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl.component; - -import com.google.gson.annotations.SerializedName; -import org.geysermc.common.form.component.ComponentType; -import org.geysermc.common.form.component.ToggleComponent; - -public final class ToggleComponentImpl extends Component implements ToggleComponent { - @SerializedName("default") - private final boolean defaultValue; - - private ToggleComponentImpl(String text, boolean defaultValue) { - super(ComponentType.TOGGLE, text); - this.defaultValue = defaultValue; - } - - public static ToggleComponentImpl of(String text, boolean defaultValue) { - return new ToggleComponentImpl(text, defaultValue); - } - - public static ToggleComponentImpl of(String text) { - return of(text, false); - } - - public boolean getDefaultValue() { - return defaultValue; - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/response/CustomFormResponseImpl.java b/common/src/main/java/org/geysermc/common/form/impl/response/CustomFormResponseImpl.java deleted file mode 100644 index cc0ce64b7..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/response/CustomFormResponseImpl.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl.response; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonPrimitive; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.ToString; -import org.geysermc.common.form.component.Component; -import org.geysermc.common.form.component.ComponentType; -import org.geysermc.common.form.impl.CustomFormImpl; -import org.geysermc.common.form.response.CustomFormResponse; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@Getter -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) -@ToString -public final class CustomFormResponseImpl implements CustomFormResponse { - private static final Gson GSON = new Gson(); - private static final CustomFormResponseImpl CLOSED = - new CustomFormResponseImpl(true, false, null, null); - private static final CustomFormResponseImpl INVALID = - new CustomFormResponseImpl(false, true, null, null); - private final boolean closed; - private final boolean invalid; - - private final JsonArray responses; - private final List componentTypes; - - private int index = -1; - - public static CustomFormResponseImpl closed() { - return CLOSED; - } - - public static CustomFormResponseImpl invalid() { - return INVALID; - } - - public static CustomFormResponseImpl of(CustomFormImpl form, String responseData) { - JsonArray responses = GSON.fromJson(responseData, JsonArray.class); - List types = new ArrayList<>(); - for (Component component : form.getContent()) { - types.add(component.getType()); - } - return of(types, responses); - } - - public static CustomFormResponseImpl of(List componentTypes, - JsonArray responses) { - if (componentTypes.size() != responses.size()) { - return invalid(); - } - - return new CustomFormResponseImpl(false, false, responses, - Collections.unmodifiableList(componentTypes)); - } - - @Override - @SuppressWarnings("unchecked") - public T next(boolean includeLabels) { - if (!hasNext()) { - return null; - } - - while (++index < responses.size()) { - ComponentType type = componentTypes.get(index); - if (type == ComponentType.LABEL && !includeLabels) { - continue; - } - return (T) getDataFromType(type, index); - } - return null; // we don't have anything to check anymore - } - - @Override - public T next() { - return next(false); - } - - @Override - public void skip(int amount) { - index += amount; - } - - @Override - public void skip() { - skip(1); - } - - @Override - public void index(int index) { - this.index = index; - } - - @Override - public boolean hasNext() { - return responses.size() > index + 1; - } - - @Override - public JsonPrimitive get(int index) { - try { - return responses.get(index).getAsJsonPrimitive(); - } catch (IllegalStateException exception) { - wrongType(index, "a primitive"); - return null; - } - } - - @Override - public int getDropdown(int index) { - JsonPrimitive primitive = get(index); - if (!primitive.isNumber()) { - wrongType(index, "dropdown"); - } - return primitive.getAsInt(); - } - - @Override - public String getInput(int index) { - JsonPrimitive primitive = get(index); - if (!primitive.isString()) { - wrongType(index, "input"); - } - return primitive.getAsString(); - } - - @Override - public float getSlider(int index) { - JsonPrimitive primitive = get(index); - if (!primitive.isNumber()) { - wrongType(index, "slider"); - } - return primitive.getAsFloat(); - } - - @Override - public int getStepSlide(int index) { - JsonPrimitive primitive = get(index); - if (!primitive.isNumber()) { - wrongType(index, "step slider"); - } - return primitive.getAsInt(); - } - - @Override - public boolean getToggle(int index) { - JsonPrimitive primitive = get(index); - if (!primitive.isBoolean()) { - wrongType(index, "toggle"); - } - return primitive.getAsBoolean(); - } - - private Object getDataFromType(ComponentType type, int index) { - switch (type) { - case DROPDOWN: - return getDropdown(index); - case INPUT: - return getInput(index); - case SLIDER: - return getSlider(index); - case STEP_SLIDER: - return getStepSlide(index); - case TOGGLE: - return getToggle(index); - default: - return null; // label e.g. is always null - } - } - - private void wrongType(int index, String expected) { - throw new IllegalStateException(String.format( - "Expected %s on %s, got %s", - expected, index, responses.get(index).toString())); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/response/ModalFormResponseImpl.java b/common/src/main/java/org/geysermc/common/form/impl/response/ModalFormResponseImpl.java deleted file mode 100644 index 6d20431cd..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/response/ModalFormResponseImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl.response; - -import lombok.AccessLevel; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.geysermc.common.form.response.FormResponse; -import org.geysermc.common.form.response.ModalFormResponse; - -@Getter -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) -public final class ModalFormResponseImpl implements ModalFormResponse { - private static final ModalFormResponseImpl CLOSED = - new ModalFormResponseImpl(true, false, -1, null); - private static final ModalFormResponseImpl INVALID = - new ModalFormResponseImpl(false, true, -1, null); - private final boolean closed; - private final boolean invalid; - - private final int clickedButtonId; - private final String clickedButtonText; - - public static ModalFormResponseImpl closed() { - return CLOSED; - } - - public static ModalFormResponseImpl invalid() { - return INVALID; - } - - public static ModalFormResponseImpl of(int clickedButtonId, String clickedButtonText) { - return new ModalFormResponseImpl(false, false, clickedButtonId, clickedButtonText); - } - - public boolean getResult() { - return clickedButtonId == 0; - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/response/SimpleFormResponseImpl.java b/common/src/main/java/org/geysermc/common/form/impl/response/SimpleFormResponseImpl.java deleted file mode 100644 index 24bc39366..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/response/SimpleFormResponseImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl.response; - -import lombok.AccessLevel; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.geysermc.common.form.component.ButtonComponent; -import org.geysermc.common.form.response.SimpleFormResponse; - -@Getter -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) -public final class SimpleFormResponseImpl implements SimpleFormResponse { - private static final SimpleFormResponseImpl CLOSED = - new SimpleFormResponseImpl(true, false, -1, null); - private static final SimpleFormResponseImpl INVALID = - new SimpleFormResponseImpl(false, true, -1, null); - private final boolean closed; - private final boolean invalid; - - private final int clickedButtonId; - private final ButtonComponent clickedButton; - - public static SimpleFormResponseImpl closed() { - return CLOSED; - } - - public static SimpleFormResponseImpl invalid() { - return INVALID; - } - - public static SimpleFormResponseImpl of(int clickedButtonId, ButtonComponent clickedButton) { - return new SimpleFormResponseImpl(false, false, clickedButtonId, clickedButton); - } - - public String getClickedButtonText() { - return clickedButton.getText(); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/util/FormAdaptor.java b/common/src/main/java/org/geysermc/common/form/impl/util/FormAdaptor.java deleted file mode 100644 index 11d7eefe4..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/util/FormAdaptor.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl.util; - -import com.google.gson.*; -import com.google.gson.reflect.TypeToken; -import org.geysermc.common.form.FormImage; -import org.geysermc.common.form.component.ButtonComponent; -import org.geysermc.common.form.component.Component; -import org.geysermc.common.form.component.ComponentType; -import org.geysermc.common.form.impl.CustomFormImpl; -import org.geysermc.common.form.impl.FormImpl; -import org.geysermc.common.form.impl.ModalFormImpl; -import org.geysermc.common.form.impl.SimpleFormImpl; -import org.geysermc.common.form.impl.component.ButtonComponentImpl; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.List; - -public final class FormAdaptor implements JsonDeserializer>, JsonSerializer> { - private static final Type LIST_BUTTON_TYPE = - new TypeToken>() {}.getType(); - - @Override - public FormImpl deserialize(JsonElement jsonElement, Type typeOfT, - JsonDeserializationContext context) - throws JsonParseException { - - if (!jsonElement.isJsonObject()) { - throw new JsonParseException("Form has to be a JsonObject"); - } - JsonObject json = jsonElement.getAsJsonObject(); - - if (typeOfT == SimpleFormImpl.class) { - String title = json.get("title").getAsString(); - String content = json.get("content").getAsString(); - List buttons = context - .deserialize(json.get("buttons"), LIST_BUTTON_TYPE); - return SimpleFormImpl.of(title, content, buttons); - } - - if (typeOfT == ModalFormImpl.class) { - String title = json.get("title").getAsString(); - String content = json.get("content").getAsString(); - String button1 = json.get("button1").getAsString(); - String button2 = json.get("button2").getAsString(); - return ModalFormImpl.of(title, content, button1, button2); - } - - if (typeOfT == CustomFormImpl.class) { - String title = json.get("title").getAsString(); - FormImage icon = context.deserialize(json.get("icon"), FormImageImpl.class); - List content = new ArrayList<>(); - - JsonArray contentArray = json.getAsJsonArray("content"); - for (JsonElement contentElement : contentArray) { - String typeName = contentElement.getAsJsonObject().get("type").getAsString(); - - ComponentType type = ComponentType.getByName(typeName); - if (type == null) { - throw new JsonParseException("Failed to find Component type " + typeName); - } - - content.add(context.deserialize(contentElement, type.getComponentClass())); - } - return CustomFormImpl.of(title, icon, content); - } - return null; - } - - @Override - public JsonElement serialize(FormImpl src, Type typeOfSrc, JsonSerializationContext context) { - JsonObject result = new JsonObject(); - result.add("type", context.serialize(src.getType())); - - if (typeOfSrc == SimpleFormImpl.class) { - SimpleFormImpl form = (SimpleFormImpl) src; - - result.addProperty("title", form.getTitle()); - result.addProperty("content", form.getContent()); - result.add("buttons", context.serialize(form.getButtons(), LIST_BUTTON_TYPE)); - return result; - } - - if (typeOfSrc == ModalFormImpl.class) { - ModalFormImpl form = (ModalFormImpl) src; - - result.addProperty("title", form.getTitle()); - result.addProperty("content", form.getContent()); - result.addProperty("button1", form.getButton1()); - result.addProperty("button2", form.getButton2()); - return result; - } - - if (typeOfSrc == CustomFormImpl.class) { - CustomFormImpl form = (CustomFormImpl) src; - - result.addProperty("title", form.getTitle()); - result.add("icon", context.serialize(form.getIcon())); - result.add("content", context.serialize(form.getContent())); - return result; - } - return null; - } -} diff --git a/common/src/main/java/org/geysermc/common/form/impl/util/FormImageImpl.java b/common/src/main/java/org/geysermc/common/form/impl/util/FormImageImpl.java deleted file mode 100644 index 4b8248e94..000000000 --- a/common/src/main/java/org/geysermc/common/form/impl/util/FormImageImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.impl.util; - -import lombok.AccessLevel; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import org.geysermc.common.form.FormImage; - -@Getter -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) -public final class FormImageImpl implements FormImage { - private final Type type; - private final String data; - - public static FormImageImpl of(Type type, String data) { - return new FormImageImpl(type, data); - } - - public static FormImageImpl of(String type, String data) { - return of(Type.getByName(type), data); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/response/CustomFormResponse.java b/common/src/main/java/org/geysermc/common/form/response/CustomFormResponse.java deleted file mode 100644 index d4d0fd99e..000000000 --- a/common/src/main/java/org/geysermc/common/form/response/CustomFormResponse.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.response; - -import com.google.gson.JsonArray; -import com.google.gson.JsonPrimitive; -import org.geysermc.common.form.component.ComponentType; - -import java.util.List; - -public interface CustomFormResponse extends FormResponse { - JsonArray getResponses(); - - List getComponentTypes(); - - T next(boolean includeLabels); - - T next(); - - void skip(int amount); - - void skip(); - - void index(int index); - - boolean hasNext(); - - JsonPrimitive get(int index); - - int getDropdown(int index); - - String getInput(int index); - - float getSlider(int index); - - int getStepSlide(int index); - - boolean getToggle(int index); -} diff --git a/common/src/main/java/org/geysermc/common/form/response/FormResponse.java b/common/src/main/java/org/geysermc/common/form/response/FormResponse.java deleted file mode 100644 index 7c62236f6..000000000 --- a/common/src/main/java/org/geysermc/common/form/response/FormResponse.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.response; - -public interface FormResponse { - boolean isClosed(); - boolean isInvalid(); - - default boolean isCorrect() { - return !isClosed() && !isInvalid(); - } -} diff --git a/common/src/main/java/org/geysermc/common/form/response/ModalFormResponse.java b/common/src/main/java/org/geysermc/common/form/response/ModalFormResponse.java deleted file mode 100644 index 6e594e0ee..000000000 --- a/common/src/main/java/org/geysermc/common/form/response/ModalFormResponse.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.response; - -public interface ModalFormResponse extends FormResponse { - int getClickedButtonId(); - - String getClickedButtonText(); - - boolean getResult(); -} diff --git a/common/src/main/java/org/geysermc/common/form/response/SimpleFormResponse.java b/common/src/main/java/org/geysermc/common/form/response/SimpleFormResponse.java deleted file mode 100644 index 528a79ed1..000000000 --- a/common/src/main/java/org/geysermc/common/form/response/SimpleFormResponse.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.common.form.response; - -import org.geysermc.common.form.component.ButtonComponent; - -public interface SimpleFormResponse extends FormResponse { - int getClickedButtonId(); - - ButtonComponent getClickedButton(); -} diff --git a/connector/pom.xml b/connector/pom.xml index 7c44ddfd2..3fb7634c0 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -15,7 +15,6 @@ org.geysermc common 1.2.0-SNAPSHOT - compile com.fasterxml.jackson.dataformat diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index 5f0a844b0..c461b1d07 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -57,8 +57,6 @@ import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; import lombok.Getter; import lombok.NonNull; import lombok.Setter; -import org.geysermc.common.form.Form; -import org.geysermc.common.form.FormBuilder; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.command.CommandSender; import org.geysermc.connector.common.AuthType; @@ -76,6 +74,8 @@ import org.geysermc.connector.network.translators.chat.MessageTranslator; import org.geysermc.connector.network.translators.inventory.EnchantmentInventoryTranslator; import org.geysermc.connector.network.translators.item.ItemRegistry; import org.geysermc.connector.utils.*; +import org.geysermc.cumulus.Form; +import org.geysermc.cumulus.util.FormBuilder; import org.geysermc.floodgate.crypto.FloodgateCipher; import org.geysermc.floodgate.util.BedrockData; @@ -607,7 +607,7 @@ public class GeyserSession implements CommandSender { return this.upstream.getAddress(); } - public void sendForm(Form form) { + public void sendForm(Form form) { formCache.showForm(form); } diff --git a/connector/src/main/java/org/geysermc/connector/network/session/cache/FormCache.java b/connector/src/main/java/org/geysermc/connector/network/session/cache/FormCache.java index 1f112e9ce..26589a82e 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/cache/FormCache.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/cache/FormCache.java @@ -31,8 +31,8 @@ import com.nukkitx.protocol.bedrock.packet.NetworkStackLatencyPacket; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import lombok.RequiredArgsConstructor; -import org.geysermc.common.form.Form; import org.geysermc.connector.network.session.GeyserSession; +import org.geysermc.cumulus.Form; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -41,16 +41,16 @@ import java.util.function.Consumer; @RequiredArgsConstructor public class FormCache { private final AtomicInteger formId = new AtomicInteger(0); - private final Int2ObjectMap> forms = new Int2ObjectOpenHashMap<>(); + private final Int2ObjectMap
forms = new Int2ObjectOpenHashMap<>(); private final GeyserSession session; - public int addForm(Form form) { + public int addForm(Form form) { int windowId = formId.getAndIncrement(); forms.put(windowId, form); return windowId; } - public int showForm(Form form) { + public int showForm(Form form) { int windowId = addForm(form); ModalFormRequestPacket formRequestPacket = new ModalFormRequestPacket(); @@ -62,15 +62,15 @@ public class FormCache { NetworkStackLatencyPacket latencyPacket = new NetworkStackLatencyPacket(); latencyPacket.setFromServer(true); latencyPacket.setTimestamp(-System.currentTimeMillis()); - session.getConnector().getGeneralThreadPool().schedule(() -> - session.sendUpstreamPacket(latencyPacket), + session.getConnector().getGeneralThreadPool().schedule( + () -> session.sendUpstreamPacket(latencyPacket), 500, TimeUnit.MILLISECONDS); return windowId; } public void handleResponse(ModalFormResponsePacket response) { - Form form = forms.get(response.getFormId()); + Form form = forms.get(response.getFormId()); if (form == null) { return; } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockServerSettingsRequestTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockServerSettingsRequestTranslator.java index 01bf07b9c..99dde0f6c 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockServerSettingsRequestTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockServerSettingsRequestTranslator.java @@ -27,15 +27,14 @@ package org.geysermc.connector.network.translators.bedrock; import com.nukkitx.protocol.bedrock.packet.ServerSettingsRequestPacket; import com.nukkitx.protocol.bedrock.packet.ServerSettingsResponsePacket; -import org.geysermc.common.form.CustomForm; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.Translator; import org.geysermc.connector.utils.SettingsUtils; +import org.geysermc.cumulus.CustomForm; @Translator(packet = ServerSettingsRequestPacket.class) public class BedrockServerSettingsRequestTranslator extends PacketTranslator { - @Override public void translate(ServerSettingsRequestPacket packet, GeyserSession session) { CustomForm window = SettingsUtils.buildForm(session); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaPluginMessageTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaPluginMessageTranslator.java index 57d64ac75..337dc0b74 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaPluginMessageTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaPluginMessageTranslator.java @@ -28,13 +28,13 @@ package org.geysermc.connector.network.translators.java; import com.github.steveice10.mc.protocol.packet.ingame.client.ClientPluginMessagePacket; import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPluginMessagePacket; import com.google.common.base.Charsets; -import org.geysermc.common.form.Form; -import org.geysermc.common.form.FormType; -import org.geysermc.common.form.Forms; import org.geysermc.connector.common.AuthType; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.Translator; +import org.geysermc.cumulus.Form; +import org.geysermc.cumulus.Forms; +import org.geysermc.cumulus.util.FormType; import java.nio.charset.StandardCharsets; @@ -63,7 +63,7 @@ public class JavaPluginMessageTranslator extends PacketTranslator form = Forms.fromJson(dataString, type.getTypeClass()); + Form form = Forms.fromJson(dataString, type); form.setResponseHandler(response -> { byte[] raw = response.getBytes(StandardCharsets.UTF_8); byte[] finalData = new byte[raw.length + 2]; diff --git a/connector/src/main/java/org/geysermc/connector/utils/LoginEncryptionUtils.java b/connector/src/main/java/org/geysermc/connector/utils/LoginEncryptionUtils.java index 84997deb6..af41a70ec 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/LoginEncryptionUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/LoginEncryptionUtils.java @@ -34,14 +34,14 @@ import com.nukkitx.network.util.Preconditions; import com.nukkitx.protocol.bedrock.packet.LoginPacket; import com.nukkitx.protocol.bedrock.packet.ServerToClientHandshakePacket; import com.nukkitx.protocol.bedrock.util.EncryptionUtils; -import org.geysermc.common.form.CustomForm; -import org.geysermc.common.form.SimpleForm; -import org.geysermc.common.form.response.CustomFormResponse; -import org.geysermc.common.form.response.SimpleFormResponse; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.auth.AuthData; import org.geysermc.connector.network.session.auth.BedrockClientData; +import org.geysermc.cumulus.CustomForm; +import org.geysermc.cumulus.SimpleForm; +import org.geysermc.cumulus.response.CustomFormResponse; +import org.geysermc.cumulus.response.SimpleFormResponse; import javax.crypto.SecretKey; import java.io.IOException; diff --git a/connector/src/main/java/org/geysermc/connector/utils/SettingsUtils.java b/connector/src/main/java/org/geysermc/connector/utils/SettingsUtils.java index d3d1c703b..e4d762a57 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/SettingsUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/SettingsUtils.java @@ -27,12 +27,12 @@ package org.geysermc.connector.utils; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.data.game.setting.Difficulty; -import org.geysermc.common.form.CustomForm; -import org.geysermc.common.form.component.DropdownComponent; -import org.geysermc.common.form.response.CustomFormResponse; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.world.WorldManager; +import org.geysermc.cumulus.CustomForm; +import org.geysermc.cumulus.component.DropdownComponent; +import org.geysermc.cumulus.response.CustomFormResponse; public class SettingsUtils { diff --git a/connector/src/main/java/org/geysermc/connector/utils/StatisticsUtils.java b/connector/src/main/java/org/geysermc/connector/utils/StatisticsUtils.java index 41084504a..ea0034c96 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/StatisticsUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/StatisticsUtils.java @@ -28,11 +28,11 @@ package org.geysermc.connector.utils; import com.github.steveice10.mc.protocol.data.MagicValues; import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType; import com.github.steveice10.mc.protocol.data.game.statistic.*; -import org.geysermc.common.form.SimpleForm; -import org.geysermc.common.form.response.SimpleFormResponse; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.item.ItemRegistry; import org.geysermc.connector.network.translators.world.block.BlockTranslator; +import org.geysermc.cumulus.SimpleForm; +import org.geysermc.cumulus.response.SimpleFormResponse; import java.util.Map; import java.util.regex.Matcher;