Skip to content

Commit 0cbb394

Browse files
committed
Update version to 26.2-R0.1-SNAPSHOT and improve dialog handling
- Bumped version in pom.xml to 26.2-R0.1-SNAPSHOT. - Enhanced PaperUniDialogPlatform to handle null or empty titles and bodies. - Added checks for button nullability and improved text retrieval.
1 parent 9573282 commit 0cbb394

2 files changed

Lines changed: 37 additions & 22 deletions

File tree

SimpleAPI/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
<dependency>
159159
<groupId>org.spigotmc</groupId>
160160
<artifactId>spigot-api</artifactId>
161-
<version>26.1.2-R0.1-SNAPSHOT</version>
161+
<version>26.2-R0.1-SNAPSHOT</version>
162162
<scope>provided</scope>
163163
</dependency>
164164
<dependency>

SimpleAPI/src/main/java/com/bencodez/simpleapi/dialog/PaperUniDialogPlatform.java

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -117,41 +117,56 @@ public void showConfirmation(Player player, UniDialogConfirmationRequest request
117117
public void showMultiAction(Player player, UniDialogMultiActionRequest request) {
118118
String namespace = resolveNamespace(request.getNamespace());
119119

120-
PaperMultiActionDialog dialog = manager.createMultiActionDialog().title(request.getTitle())
121-
.body(builder -> builder.text().text(request.getBody())).columns(request.getColumns());
120+
PaperMultiActionDialog dialog = manager.createMultiActionDialog()
121+
.title(getTextOrEmpty(request.getTitle()))
122+
.columns(Math.max(1, request.getColumns()));
122123

123-
applyInputs(dialog, request.getInputs());
124+
if (request.getBody() != null && !request.getBody().isEmpty()) {
125+
dialog.body(builder -> builder.text().text(request.getBody()));
126+
}
124127

125-
for (UniDialogButton button : request.getButtons()) {
126-
String actionId = resolveActionId(button.getActionId());
128+
applyInputs(dialog, request.getInputs());
127129

128-
if (button.getCallback() != null) {
129-
registerCustomAction(namespace, actionId, button.getCallback());
130-
}
130+
if (request.getButtons() != null) {
131+
for (UniDialogButton button : request.getButtons()) {
132+
if (button == null) {
133+
continue;
134+
}
131135

132-
dialog.action(action -> {
133-
action.label(button.getText());
136+
String actionId = resolveActionId(button.getActionId());
134137

135-
if (button.getTooltip() != null && !button.getTooltip().isEmpty()) {
136-
action.tooltip(button.getTooltip());
138+
if (button.getCallback() != null) {
139+
registerCustomAction(namespace, actionId, button.getCallback());
137140
}
138141

139-
Integer width = button.getWidth();
140-
if (width == null) {
141-
width = request.getButtonWidth();
142-
}
142+
dialog.action(action -> {
143+
action.label(getTextOrEmpty(button.getText()));
143144

144-
if (width != null) {
145-
action.width(width.intValue());
146-
}
145+
if (button.getTooltip() != null && !button.getTooltip().isEmpty()) {
146+
action.tooltip(button.getTooltip());
147+
}
148+
149+
Integer width = button.getWidth();
150+
if (width == null) {
151+
width = request.getButtonWidth();
152+
}
153+
154+
if (width != null && width.intValue() > 0) {
155+
action.width(width.intValue());
156+
}
147157

148-
action.dynamicCustom(namespace, actionId);
149-
});
158+
action.dynamicCustom(namespace, actionId);
159+
});
160+
}
150161
}
151162

152163
dialog.opener().open(player.getUniqueId());
153164
}
154165

166+
private String getTextOrEmpty(String text) {
167+
return text == null ? "" : text;
168+
}
169+
155170
private void applyInputs(PaperNoticeDialog dialog, Iterable<UniDialogInput> inputs) {
156171
if (inputs == null) {
157172
return;

0 commit comments

Comments
 (0)