Skip to content

Commit 78a5eaa

Browse files
authored
Merge pull request #44 from SpigotMC/master
[pull] master from SpigotMC:master
2 parents 541109f + f8de305 commit 78a5eaa

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

api/src/main/java/net/md_5/bungee/api/event/CustomClickEvent.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.md_5.bungee.api.connection.ProxiedPlayer;
88
import net.md_5.bungee.api.plugin.Cancellable;
99
import net.md_5.bungee.api.plugin.Event;
10+
import org.jetbrains.annotations.ApiStatus;
1011

1112
/**
1213
* Called after a {@link ProxiedPlayer} runs a custom action from a chat event
@@ -15,6 +16,7 @@
1516
@Data
1617
@ToString(callSuper = false)
1718
@EqualsAndHashCode(callSuper = false)
19+
@ApiStatus.Experimental
1820
public class CustomClickEvent extends Event implements Cancellable
1921
{
2022

@@ -32,11 +34,19 @@ public class CustomClickEvent extends Event implements Cancellable
3234
*/
3335
private final String id;
3436
/**
35-
* Form data, may be null. If a form submission, usually contains a
37+
* The raw data as submitted.
38+
*/
39+
private final String rawData;
40+
/**
41+
* The parsed form data.
42+
* <br>
43+
* If a form submission, usually contains a
3644
* {@code CustomClickEvent.ACTION_KEY} key with the ID of the relevant
3745
* submission action.
46+
* <br>
47+
* If not a form submission, then may be null.
3848
*/
39-
private final Map<String, String> data;
49+
private final Map<String, String> parsedData;
4050
/**
4151
* Cancelled state.
4252
*/

proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,20 @@ public void handle(CustomClickAction customClickAction) throws Exception
394394
for ( String line : lines )
395395
{
396396
String[] split = line.split( "\t", 2 );
397-
parsed.put( split[0], ( split.length > 1 ) ? split[1] : "" );
397+
if ( split.length > 1 )
398+
{
399+
parsed.put( split[0], split[1] );
400+
}
401+
}
402+
data = parsed.buildOrThrow();
403+
404+
if ( data.isEmpty() )
405+
{
406+
data = null;
398407
}
399-
data = parsed.build();
400408
}
401409

402-
CustomClickEvent event = new CustomClickEvent( con, customClickAction.getId(), data );
410+
CustomClickEvent event = new CustomClickEvent( con, customClickAction.getId(), customClickAction.getData(), data );
403411
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
404412
{
405413
throw CancelSendSignal.INSTANCE;

0 commit comments

Comments
 (0)