Skip to content

Commit cebbd46

Browse files
authored
Merge pull request #40 from SpigotMC/master
[pull] master from SpigotMC:master
2 parents 10ae6a9 + 53365e4 commit cebbd46

File tree

67 files changed

+1531
-41
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1531
-41
lines changed

api/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
<version>${project.version}</version>
3737
<scope>compile</scope>
3838
</dependency>
39+
<dependency>
40+
<groupId>net.md-5</groupId>
41+
<artifactId>bungeecord-dialog</artifactId>
42+
<version>${project.version}</version>
43+
<scope>compile</scope>
44+
</dependency>
3945
<dependency>
4046
<groupId>net.md-5</groupId>
4147
<artifactId>bungeecord-event</artifactId>

api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import net.md_5.bungee.api.Title;
1313
import net.md_5.bungee.api.chat.BaseComponent;
1414
import net.md_5.bungee.api.config.ServerInfo;
15+
import net.md_5.bungee.api.dialog.Dialog;
1516
import net.md_5.bungee.api.event.ServerConnectEvent;
1617
import net.md_5.bungee.api.score.Scoreboard;
1718
import org.jetbrains.annotations.ApiStatus;
@@ -390,4 +391,23 @@ public enum MainHand
390391
* @return the brand of the client, or null if not received yet
391392
*/
392393
String getClientBrand();
394+
395+
/**
396+
* Clear the player's open dialog.
397+
*
398+
* @throws IllegalStateException if the players version is not at least
399+
* 1.21.6
400+
*/
401+
@ApiStatus.Experimental
402+
void clearDialog();
403+
404+
/**
405+
* Show a dialog to the player.
406+
*
407+
* @param dialog the dialog to show
408+
* @throws IllegalStateException if the players version is not at least
409+
* 1.21.6
410+
*/
411+
@ApiStatus.Experimental
412+
void showDialog(Dialog dialog);
393413
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package net.md_5.bungee.api.event;
2+
3+
import java.util.Map;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import lombok.ToString;
7+
import net.md_5.bungee.api.connection.ProxiedPlayer;
8+
import net.md_5.bungee.api.plugin.Cancellable;
9+
import net.md_5.bungee.api.plugin.Event;
10+
11+
/**
12+
* Called after a {@link ProxiedPlayer} runs a custom action from a chat event
13+
* or form submission.
14+
*/
15+
@Data
16+
@ToString(callSuper = false)
17+
@EqualsAndHashCode(callSuper = false)
18+
public class CustomClickEvent extends Event implements Cancellable
19+
{
20+
21+
/**
22+
* Map key containing the form action, if available.
23+
*/
24+
public static final String ACTION_KEY = "action";
25+
//
26+
/**
27+
* Player who clicked.
28+
*/
29+
private final ProxiedPlayer player;
30+
/**
31+
* Custom action ID.
32+
*/
33+
private final String id;
34+
/**
35+
* Form data, may be null. If a form submission, usually contains a
36+
* {@code CustomClickEvent.ACTION_KEY} key with the ID of the relevant
37+
* submission action.
38+
*/
39+
private final Map<String, String> data;
40+
/**
41+
* Cancelled state.
42+
*/
43+
private boolean cancelled;
44+
}

chat/src/main/java/net/md_5/bungee/api/chat/ClickEvent.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
import lombok.Getter;
55
import lombok.RequiredArgsConstructor;
66
import lombok.ToString;
7+
import org.jetbrains.annotations.ApiStatus;
78

89
@Getter
910
@ToString
1011
@EqualsAndHashCode
1112
@RequiredArgsConstructor
12-
public final class ClickEvent
13+
@ApiStatus.NonExtendable
14+
public class ClickEvent
1315
{
1416

1517
/**
@@ -52,11 +54,19 @@ public enum Action
5254
* {@link net.md_5.bungee.api.chat.ClickEvent#value} in a book.
5355
*/
5456
CHANGE_PAGE,
57+
/**
58+
* Must use subclass ShowDialogClickEvent.
59+
*/
60+
SHOW_DIALOG,
5561
/**
5662
* Copy the string given by
5763
* {@link net.md_5.bungee.api.chat.ClickEvent#value} into the player's
5864
* clipboard.
5965
*/
60-
COPY_TO_CLIPBOARD
66+
COPY_TO_CLIPBOARD,
67+
/**
68+
* Must use subclass {@link ClickEventCustom}.
69+
*/
70+
CUSTOM,
6171
}
6272
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package net.md_5.bungee.api.chat;
2+
3+
import lombok.Data;
4+
import lombok.EqualsAndHashCode;
5+
import lombok.ToString;
6+
7+
/**
8+
* Click event which sends a custom payload to the server.
9+
*/
10+
@Data
11+
@ToString(callSuper = true)
12+
@EqualsAndHashCode(callSuper = true)
13+
public class ClickEventCustom extends ClickEvent
14+
{
15+
16+
/**
17+
* The custom payload.
18+
*/
19+
private final String payload;
20+
21+
/**
22+
* @param id identifier for the event (lower case, no special characters)
23+
* @param payload custom payload
24+
*/
25+
public ClickEventCustom(String id, String payload)
26+
{
27+
super( ClickEvent.Action.CUSTOM, id );
28+
this.payload = payload;
29+
}
30+
}

chat/src/main/java/net/md_5/bungee/api/chat/HoverEvent.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import net.md_5.bungee.api.chat.hover.content.Entity;
1414
import net.md_5.bungee.api.chat.hover.content.Item;
1515
import net.md_5.bungee.api.chat.hover.content.Text;
16-
import net.md_5.bungee.chat.VersionedComponentSerializer;
1716
import org.jetbrains.annotations.ApiStatus;
1817

1918
@Getter
@@ -73,22 +72,6 @@ public HoverEvent(Action action, BaseComponent[] value)
7372
this.legacy = true;
7473
}
7574

76-
@Deprecated
77-
public BaseComponent[] getValue()
78-
{
79-
Content content = contents.get( 0 );
80-
if ( content instanceof Text && ( (Text) content ).getValue() instanceof BaseComponent[] )
81-
{
82-
return (BaseComponent[]) ( (Text) content ).getValue();
83-
}
84-
85-
TextComponent component = new TextComponent( VersionedComponentSerializer.getDefault().toString( content ) );
86-
return new BaseComponent[]
87-
{
88-
component
89-
};
90-
}
91-
9275
/**
9376
* Adds a content to this hover event.
9477
*

dialog/LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2025, SpigotMC Pty. Ltd.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

dialog/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
BungeeCord-Dialog
2+
=================
3+
4+
Highly experimental API, subject to breakage. All contributions welcome, including major refactors/design changes.
5+
6+
Sample Plugin
7+
-------------
8+
9+
```java
10+
private class TestCommand extends Command
11+
{
12+
13+
public TestCommand()
14+
{
15+
super( "btest" );
16+
}
17+
18+
@Override
19+
public void execute(CommandSender sender, String[] args)
20+
{
21+
ProxiedPlayer player = (ProxiedPlayer) sender;
22+
23+
Dialog notice = new NoticeDialog( new DialogBase( new ComponentBuilder( "Hello" ).color( ChatColor.RED ).build() ) );
24+
player.showDialog( notice );
25+
26+
notice = new SimpleInputFormDialog(
27+
new DialogBase( new ComponentBuilder( "Hello" ).color( ChatColor.RED ).build() ),
28+
new DialogSubmitAction( "submit", new CustomFormSubmission( "customform" ), new ComponentBuilder( "Submit Button" ).build() ),
29+
new TextInput( "first", new ComponentBuilder( "First" ).build() ),
30+
new TextInput( "second", new ComponentBuilder( "Second" ).build() )
31+
);
32+
player.sendMessage( new ComponentBuilder( "click me" ).event( new ShowDialogClickEvent( notice ) ).build() );
33+
}
34+
}
35+
```

dialog/nb-configuration.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-shared-configuration>
3+
<!--
4+
This file contains additional configuration written by modules in the NetBeans IDE.
5+
The configuration is intended to be shared among all the users of project and
6+
therefore it is assumed to be part of version control checkout.
7+
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
8+
-->
9+
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
10+
<!--
11+
Properties that influence various parts of the IDE, especially code formatting and the like.
12+
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
13+
That way multiple projects can share the same settings (useful for formatting rules for example).
14+
Any value defined here will override the pom.xml file value but is only applicable to the current project.
15+
-->
16+
<org-netbeans-modules-editor-indent.CodeStyle.usedProfile>project</org-netbeans-modules-editor-indent.CodeStyle.usedProfile>
17+
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement>
18+
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement>
19+
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement>
20+
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinMethodCallParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinMethodCallParens>
21+
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSwitchParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSwitchParens>
22+
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinCatchParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinCatchParens>
23+
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinTryParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinTryParens>
24+
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSynchronizedParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSynchronizedParens>
25+
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinArrayInitBrackets>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinArrayInitBrackets>
26+
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinParens>
27+
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinWhileParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinWhileParens>
28+
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinIfParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinIfParens>
29+
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinForParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinForParens>
30+
</properties>
31+
</project-shared-configuration>

dialog/pom.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>net.md-5</groupId>
8+
<artifactId>bungeecord-parent</artifactId>
9+
<version>1.21-R0.3-SNAPSHOT</version>
10+
<relativePath>../pom.xml</relativePath>
11+
</parent>
12+
13+
<groupId>net.md-5</groupId>
14+
<artifactId>bungeecord-dialog</artifactId>
15+
<version>1.21-R0.3-SNAPSHOT</version>
16+
<packaging>jar</packaging>
17+
18+
<name>BungeeCord-Dialog</name>
19+
<description>Minecraft dialog API intended for use with BungeeCord</description>
20+
<licenses>
21+
<license>
22+
<name>BSD-3-Clause</name>
23+
<url>https://github.com/SpigotMC/BungeeCord/blob/master/dialog/LICENSE</url>
24+
<distribution>repo</distribution>
25+
</license>
26+
</licenses>
27+
28+
<dependencies>
29+
<dependency>
30+
<groupId>net.md-5</groupId>
31+
<artifactId>bungeecord-chat</artifactId>
32+
<version>${project.version}</version>
33+
<scope>compile</scope>
34+
</dependency>
35+
</dependencies>
36+
</project>

0 commit comments

Comments
 (0)