mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-05 23:33:36 +00:00
fancydialogs: Fixed player getting kicked when no button or action is defined
Updated version to 1.0.1
This commit is contained in:
@@ -1,7 +1 @@
|
||||
- Create dialogs using the [JSON schema](https://docs.fancyinnovations.com/fancydialogs/tutorials/json-schema/)
|
||||
- PlaceholderAPI and MiniMessage support in dialog texts
|
||||
- Execute actions when dialog buttons are clicked
|
||||
- Open a dialog when the user joins the server for the first time (see `welcome_dialog_id` in the config)
|
||||
- A quick actions dialog which can be opened with the `/qa` or `/quickactions` commands
|
||||
- FancyNpcs ingegration to open dialogs when interacting with NPCs (see [docs](https://docs.fancyinnovations.com/fancydialogs/tutorials/open-dialog-npc-action/))
|
||||
- API for other plugins to open dialogs (see [docs](https://docs.fancyinnovations.com/fancydialogs/api/getting-started/))
|
||||
- Fixed player kick issue when no button or action is defined. ([#147](https://github.com/FancyInnovations/FancyPlugins/issues/147))
|
||||
@@ -1 +1 @@
|
||||
1.0.0
|
||||
1.0.1
|
||||
@@ -10,6 +10,7 @@ import com.fancyinnovations.fancydialogs.api.data.inputs.DialogInput;
|
||||
import com.fancyinnovations.fancydialogs.api.data.inputs.DialogSelect;
|
||||
import com.fancyinnovations.fancydialogs.api.data.inputs.DialogTextField;
|
||||
import de.oliver.fancysitula.api.dialogs.FS_CommonDialogData;
|
||||
import de.oliver.fancysitula.api.dialogs.FS_Dialog;
|
||||
import de.oliver.fancysitula.api.dialogs.FS_DialogAction;
|
||||
import de.oliver.fancysitula.api.dialogs.actions.FS_CommonButtonData;
|
||||
import de.oliver.fancysitula.api.dialogs.actions.FS_DialogActionButton;
|
||||
@@ -18,6 +19,7 @@ import de.oliver.fancysitula.api.dialogs.body.FS_DialogBody;
|
||||
import de.oliver.fancysitula.api.dialogs.body.FS_DialogTextBody;
|
||||
import de.oliver.fancysitula.api.dialogs.inputs.*;
|
||||
import de.oliver.fancysitula.api.dialogs.types.FS_MultiActionDialog;
|
||||
import de.oliver.fancysitula.api.dialogs.types.FS_NoticeDialog;
|
||||
import de.oliver.fancysitula.api.entities.FS_RealPlayer;
|
||||
import de.oliver.fancysitula.factories.FancySitula;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -35,7 +37,7 @@ public class DialogImpl extends Dialog {
|
||||
super(id, data);
|
||||
}
|
||||
|
||||
private FS_MultiActionDialog buildForPlayer(Player player) {
|
||||
private FS_Dialog buildForPlayer(Player player) {
|
||||
List<FS_DialogBody> body = new ArrayList<>();
|
||||
for (DialogBodyData bodyData : data.body()) {
|
||||
FS_DialogTextBody fsDialogTextBody = new FS_DialogTextBody(
|
||||
@@ -109,6 +111,30 @@ public class DialogImpl extends Dialog {
|
||||
actions.add(fsDialogActionButton);
|
||||
}
|
||||
|
||||
if (actions.isEmpty()) {
|
||||
return new FS_NoticeDialog(
|
||||
new FS_CommonDialogData(
|
||||
ChatColorHandler.translate(data.title(), player, ParserTypes.placeholder()),
|
||||
ChatColorHandler.translate(data.title(), player, ParserTypes.placeholder()),
|
||||
data.canCloseWithEscape(),
|
||||
false,
|
||||
FS_DialogAction.CLOSE,
|
||||
body,
|
||||
inputs
|
||||
),
|
||||
new FS_DialogActionButton(
|
||||
new FS_CommonButtonData(
|
||||
"Close",
|
||||
null,
|
||||
150 // default button width
|
||||
),
|
||||
new FS_DialogCustomAction(
|
||||
"fancydialogs_dialog_action--none",
|
||||
Map.of())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return new FS_MultiActionDialog(
|
||||
new FS_CommonDialogData(
|
||||
ChatColorHandler.translate(data.title(), player, ParserTypes.placeholder()),
|
||||
@@ -118,53 +144,6 @@ public class DialogImpl extends Dialog {
|
||||
FS_DialogAction.CLOSE,
|
||||
body,
|
||||
inputs
|
||||
// List.of(
|
||||
// new FS_DialogInput(
|
||||
// "input1",
|
||||
// new FS_DialogTextInput(
|
||||
// 200,
|
||||
// "Enter something",
|
||||
// true,
|
||||
// "default text",
|
||||
// 100,
|
||||
// null
|
||||
// )
|
||||
// ),
|
||||
// new FS_DialogInput(
|
||||
// "input2",
|
||||
// new FS_DialogBooleanInput(
|
||||
// "input2",
|
||||
// false,
|
||||
// "true",
|
||||
// "false"
|
||||
// )
|
||||
// ),
|
||||
// new FS_DialogInput(
|
||||
// "input3",
|
||||
// new FS_DialogNumberRangeInput(
|
||||
// 200,
|
||||
// "Number Input",
|
||||
// "options.generic_value",
|
||||
// 0,
|
||||
// 100,
|
||||
// 50.f,
|
||||
// 1.0f
|
||||
// )
|
||||
// ),
|
||||
// new FS_DialogInput(
|
||||
// "input4",
|
||||
// new FS_DialogSingleOptionInput(
|
||||
// 200,
|
||||
// List.of(
|
||||
// new FS_DialogSingleOptionInput.Entry("option1", "Option 1", true),
|
||||
// new FS_DialogSingleOptionInput.Entry("option2", "Option 2", false),
|
||||
// new FS_DialogSingleOptionInput.Entry("option3", "Option 3", false)
|
||||
// ),
|
||||
// "Select an option",
|
||||
// true
|
||||
// )
|
||||
// )
|
||||
// )
|
||||
),
|
||||
actions, // actions
|
||||
null,
|
||||
|
||||
@@ -46,6 +46,10 @@ public class CustomClickActionPacketListener {
|
||||
String dialogId = packet.getPayload().get("dialog_id");
|
||||
String buttonId = packet.getPayload().get("button_id");
|
||||
|
||||
if (dialogId == null || buttonId == null) {
|
||||
return; // Missing necessary information
|
||||
}
|
||||
|
||||
new DialogButtonClickedEvent(event.player(), dialogId, buttonId, packet.getPayload()).callEvent();
|
||||
|
||||
if (dialogId.startsWith("confirmation_dialog_")) {
|
||||
|
||||
Reference in New Issue
Block a user