Fix test errors
This commit is contained in:
13 files changed
+224
-2
No files matched your search
+2
@@ -20,6 +20,7 @@ package com.github.retrooper.packetevents.protocol.attribute;
|
||||
|
||||
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
@@ -30,6 +31,7 @@ public final class AttributeDisplayTypes {
|
||||
private AttributeDisplayTypes() {
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static <T extends AttributeDisplay> AttributeDisplayType<T> define(
|
||||
String name, PacketWrapper.Reader<T> reader, PacketWrapper.Writer<T> writer
|
||||
) {
|
||||
|
||||
@@ -227,7 +227,7 @@ public final class Parsers {
|
||||
/**
|
||||
* Added with 1.21.6
|
||||
*/
|
||||
public static final Parser DIALOG = define("parser", null, null);
|
||||
public static final Parser DIALOG = define("dialog", null, null);
|
||||
|
||||
static {
|
||||
REGISTRY.unloadMappings();
|
||||
|
||||
+16
@@ -21,6 +21,7 @@ package com.github.retrooper.packetevents.protocol.chat.clickevent;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapDecoder;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapEncoder;
|
||||
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
@@ -31,6 +32,7 @@ public final class ClickEventActions {
|
||||
private ClickEventActions() {
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static <T extends ClickEvent> ClickEventAction<T> define(
|
||||
String name, boolean allowFromServer,
|
||||
NbtMapDecoder<T> decoder, NbtMapEncoder<T> encoder
|
||||
@@ -49,10 +51,24 @@ public final class ClickEventActions {
|
||||
OpenFileClickEvent::decode, OpenFileClickEvent::encode);
|
||||
public static final ClickEventAction<RunCommandClickEvent> RUN_COMMAND = define("run_command", true,
|
||||
RunCommandClickEvent::decode, RunCommandClickEvent::encode);
|
||||
/**
|
||||
* Removed in 1.9
|
||||
*/
|
||||
@ApiStatus.Obsolete
|
||||
public static final ClickEventAction<TwitchUserInfoClickEvent> TWITCH_USER_INFO = define("twitch_user_info", false,
|
||||
TwitchUserInfoClickEvent::decode, TwitchUserInfoClickEvent::encode);
|
||||
public static final ClickEventAction<SuggestCommandClickEvent> SUGGEST_COMMAND = define("suggest_command", true,
|
||||
SuggestCommandClickEvent::decode, SuggestCommandClickEvent::encode);
|
||||
|
||||
/**
|
||||
* Added with 1.8
|
||||
*/
|
||||
public static final ClickEventAction<ChangePageClickEvent> CHANGE_PAGE = define("change_page", true,
|
||||
ChangePageClickEvent::decode, ChangePageClickEvent::encode);
|
||||
|
||||
/**
|
||||
* Added with 1.15
|
||||
*/
|
||||
public static final ClickEventAction<CopyToClipboardClickEvent> COPY_TO_CLIPBOARD = define("copy_to_clipboard", true,
|
||||
CopyToClipboardClickEvent::decode, CopyToClipboardClickEvent::encode);
|
||||
|
||||
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* This file is part of packetevents - https://github.com/retrooper/packetevents
|
||||
* Copyright (C) 2025 retrooper and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.chat.clickevent;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTString;
|
||||
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
/**
|
||||
* Removed in 1.9
|
||||
*/
|
||||
@NullMarked
|
||||
@ApiStatus.Obsolete
|
||||
public class TwitchUserInfoClickEvent implements ClickEvent {
|
||||
|
||||
private final String value;
|
||||
|
||||
public TwitchUserInfoClickEvent(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static TwitchUserInfoClickEvent decode(NBTCompound compound, PacketWrapper<?> wrapper) {
|
||||
String value = compound.getStringTagValueOrThrow("value");
|
||||
return new TwitchUserInfoClickEvent(value);
|
||||
}
|
||||
|
||||
public static void encode(NBTCompound compound, PacketWrapper<?> wrapper, TwitchUserInfoClickEvent clickEvent) {
|
||||
compound.setTag("value", new NBTString(clickEvent.value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClickEventAction<?> getAction() {
|
||||
return ClickEventActions.TWITCH_USER_INFO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.kyori.adventure.text.event.ClickEvent asAdventure() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
+4
@@ -36,6 +36,10 @@ public class ConfirmationDialog extends AbstractMappedEntity implements Dialog {
|
||||
private final ActionButton yesButton;
|
||||
private final ActionButton noButton;
|
||||
|
||||
public ConfirmationDialog(CommonDialogData common, ActionButton yesButton, ActionButton noButton) {
|
||||
this(null, common, yesButton, noButton);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ConfirmationDialog(
|
||||
@Nullable TypesBuilderData data, CommonDialogData common,
|
||||
|
||||
+9
@@ -41,6 +41,15 @@ public class DialogListDialog extends AbstractMappedEntity implements Dialog {
|
||||
private final int columns;
|
||||
private final int buttonWidth;
|
||||
|
||||
public DialogListDialog(
|
||||
CommonDialogData common,
|
||||
MappedEntityRefSet<Dialog> dialogs,
|
||||
@Nullable ActionButton exitAction,
|
||||
int columns, int buttonWidth
|
||||
) {
|
||||
this(null, common, dialogs, exitAction, columns, buttonWidth);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public DialogListDialog(
|
||||
@Nullable TypesBuilderData data,
|
||||
|
||||
+3
-1
@@ -21,6 +21,7 @@ package com.github.retrooper.packetevents.protocol.dialog;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapDecoder;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapEncoder;
|
||||
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
@@ -35,11 +36,12 @@ public final class DialogTypes {
|
||||
return REGISTRY;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static <T extends Dialog> DialogType<T> define(String name, NbtMapDecoder<T> decoder, NbtMapEncoder<T> encoder) {
|
||||
return REGISTRY.define(name, data -> new StaticDialogType<>(data, decoder, encoder));
|
||||
}
|
||||
|
||||
public static final DialogType<NoticeDialog> NOTICE = define("dialog",
|
||||
public static final DialogType<NoticeDialog> NOTICE = define("notice",
|
||||
NoticeDialog::decode, NoticeDialog::encode);
|
||||
public static final DialogType<ServerLinksDialog> SERVER_LINKS = define("server_links",
|
||||
ServerLinksDialog::decode, ServerLinksDialog::encode);
|
||||
|
||||
@@ -18,21 +18,83 @@
|
||||
|
||||
package com.github.retrooper.packetevents.protocol.dialog;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.dialog.button.ActionButton;
|
||||
import com.github.retrooper.packetevents.protocol.dialog.button.CommonButtonData;
|
||||
import com.github.retrooper.packetevents.protocol.mapper.MappedEntitySet;
|
||||
import com.github.retrooper.packetevents.resources.ResourceLocation;
|
||||
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@NullMarked
|
||||
public final class Dialogs {
|
||||
|
||||
private static final ActionButton DEFAULT_BACK_BUTTON = new ActionButton(
|
||||
new CommonButtonData(Component.translatable("gui.back"), null, 200),
|
||||
null);
|
||||
|
||||
private static final VersionedRegistry<Dialog> REGISTRY = new VersionedRegistry<>("dialog");
|
||||
|
||||
private Dialogs() {
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static Dialog define(String name, Dialog dialog) {
|
||||
return REGISTRY.define(name, dialog::copy);
|
||||
}
|
||||
|
||||
public static VersionedRegistry<Dialog> getRegistry() {
|
||||
return REGISTRY;
|
||||
}
|
||||
|
||||
public static final Dialog SERVER_LINKS = define("server_links", new ServerLinksDialog(
|
||||
new CommonDialogData(
|
||||
Component.translatable("menu.server_links.title"),
|
||||
Component.translatable("menu.server_links"),
|
||||
true,
|
||||
true,
|
||||
DialogAction.CLOSE,
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList()
|
||||
),
|
||||
DEFAULT_BACK_BUTTON,
|
||||
1,
|
||||
310
|
||||
));
|
||||
public static final Dialog CUSTOM_OPTIONS = define("custom_options", new DialogListDialog(
|
||||
new CommonDialogData(
|
||||
Component.translatable("menu.custom_options.title"),
|
||||
Component.translatable("menu.custom_options"),
|
||||
true,
|
||||
true,
|
||||
DialogAction.CLOSE,
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList()
|
||||
),
|
||||
new MappedEntitySet<>(new ResourceLocation("pause_screen_additions")),
|
||||
DEFAULT_BACK_BUTTON,
|
||||
1,
|
||||
310
|
||||
));
|
||||
public static final Dialog QUICK_ACTIONS = define("quick_actions", new DialogListDialog(
|
||||
new CommonDialogData(
|
||||
Component.translatable("menu.quick_actions.title"),
|
||||
Component.translatable("menu.quick_actions"),
|
||||
true,
|
||||
true,
|
||||
DialogAction.CLOSE,
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList()
|
||||
),
|
||||
new MappedEntitySet<>(new ResourceLocation("quick_actions")),
|
||||
DEFAULT_BACK_BUTTON,
|
||||
1,
|
||||
310
|
||||
));
|
||||
|
||||
static {
|
||||
REGISTRY.unloadMappings();
|
||||
}
|
||||
|
||||
+9
@@ -39,6 +39,15 @@ public class MultiActionDialog extends AbstractMappedEntity implements Dialog {
|
||||
private final @Nullable ActionButton exitAction;
|
||||
private final int columns;
|
||||
|
||||
public MultiActionDialog(
|
||||
CommonDialogData common,
|
||||
List<ActionButton> actions,
|
||||
@Nullable ActionButton exitAction,
|
||||
int columns
|
||||
) {
|
||||
this(null, common, actions, exitAction, columns);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public MultiActionDialog(
|
||||
@Nullable TypesBuilderData data,
|
||||
|
||||
@@ -42,6 +42,10 @@ public class NoticeDialog extends AbstractMappedEntity implements Dialog {
|
||||
private final CommonDialogData common;
|
||||
private final ActionButton action;
|
||||
|
||||
public NoticeDialog(CommonDialogData common, ActionButton action) {
|
||||
this(null, common, action);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public NoticeDialog(@Nullable TypesBuilderData data, CommonDialogData common, ActionButton action) {
|
||||
super(data);
|
||||
|
||||
+8
@@ -38,6 +38,14 @@ public class ServerLinksDialog extends AbstractMappedEntity implements Dialog {
|
||||
private final int columns;
|
||||
private final int buttonWidth;
|
||||
|
||||
public ServerLinksDialog(
|
||||
CommonDialogData common,
|
||||
@Nullable ActionButton exitAction,
|
||||
int columns, int buttonWidth
|
||||
) {
|
||||
this(null, common, exitAction, columns, buttonWidth);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public ServerLinksDialog(
|
||||
@Nullable TypesBuilderData data,
|
||||
|
||||
+2
@@ -21,6 +21,7 @@ package com.github.retrooper.packetevents.protocol.dialog.action;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapDecoder;
|
||||
import com.github.retrooper.packetevents.protocol.util.NbtMapEncoder;
|
||||
import com.github.retrooper.packetevents.util.mappings.VersionedRegistry;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
|
||||
@NullMarked
|
||||
@@ -31,6 +32,7 @@ public final class ActionTypes {
|
||||
private ActionTypes() {
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static <T extends Action> ActionType<T> define(String name, NbtMapDecoder<T> decoder, NbtMapEncoder<T> encoder) {
|
||||
return REGISTRY.define(name, data -> new StaticActionType<>(data, decoder, encoder));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"V_1_21_6": [
|
||||
"open_url",
|
||||
"open_file",
|
||||
"run_command",
|
||||
"suggest_command",
|
||||
"show_dialog",
|
||||
"change_page",
|
||||
"copy_to_clipboard",
|
||||
"custom"
|
||||
],
|
||||
"V_1_15": [
|
||||
"open_url",
|
||||
"open_file",
|
||||
"run_command",
|
||||
"suggest_command",
|
||||
"change_page",
|
||||
"copy_to_clipboard"
|
||||
],
|
||||
"V_1_9": [
|
||||
"open_url",
|
||||
"open_file",
|
||||
"run_command",
|
||||
"suggest_command",
|
||||
"change_page"
|
||||
],
|
||||
"V_1_8": [
|
||||
"open_url",
|
||||
"open_file",
|
||||
"run_command",
|
||||
"twitch_user_info",
|
||||
"suggest_command",
|
||||
"change_page"
|
||||
],
|
||||
"V_1_7_10": [
|
||||
"open_url",
|
||||
"open_file",
|
||||
"run_command",
|
||||
"twitch_user_info",
|
||||
"suggest_command"
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user