Expand CustomClickEvent to have raw and parsed data
This commit is contained in:
parent
f1f5be18f9
commit
f8de305477
@ -7,6 +7,7 @@ import lombok.ToString;
|
|||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.plugin.Cancellable;
|
import net.md_5.bungee.api.plugin.Cancellable;
|
||||||
import net.md_5.bungee.api.plugin.Event;
|
import net.md_5.bungee.api.plugin.Event;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after a {@link ProxiedPlayer} runs a custom action from a chat event
|
* Called after a {@link ProxiedPlayer} runs a custom action from a chat event
|
||||||
@ -15,6 +16,7 @@ import net.md_5.bungee.api.plugin.Event;
|
|||||||
@Data
|
@Data
|
||||||
@ToString(callSuper = false)
|
@ToString(callSuper = false)
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@ApiStatus.Experimental
|
||||||
public class CustomClickEvent extends Event implements Cancellable
|
public class CustomClickEvent extends Event implements Cancellable
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -32,11 +34,19 @@ public class CustomClickEvent extends Event implements Cancellable
|
|||||||
*/
|
*/
|
||||||
private final String id;
|
private final String id;
|
||||||
/**
|
/**
|
||||||
* Form data, may be null. If a form submission, usually contains a
|
* The raw data as submitted.
|
||||||
|
*/
|
||||||
|
private final String rawData;
|
||||||
|
/**
|
||||||
|
* The parsed form data.
|
||||||
|
* <br>
|
||||||
|
* If a form submission, usually contains a
|
||||||
* {@code CustomClickEvent.ACTION_KEY} key with the ID of the relevant
|
* {@code CustomClickEvent.ACTION_KEY} key with the ID of the relevant
|
||||||
* submission action.
|
* submission action.
|
||||||
|
* <br>
|
||||||
|
* If not a form submission, then may be null.
|
||||||
*/
|
*/
|
||||||
private final Map<String, String> data;
|
private final Map<String, String> parsedData;
|
||||||
/**
|
/**
|
||||||
* Cancelled state.
|
* Cancelled state.
|
||||||
*/
|
*/
|
||||||
|
@ -394,12 +394,20 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
for ( String line : lines )
|
for ( String line : lines )
|
||||||
{
|
{
|
||||||
String[] split = line.split( "\t", 2 );
|
String[] split = line.split( "\t", 2 );
|
||||||
parsed.put( split[0], ( split.length > 1 ) ? split[1] : "" );
|
if ( split.length > 1 )
|
||||||
|
{
|
||||||
|
parsed.put( split[0], split[1] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data = parsed.buildOrThrow();
|
||||||
|
|
||||||
|
if ( data.isEmpty() )
|
||||||
|
{
|
||||||
|
data = null;
|
||||||
}
|
}
|
||||||
data = parsed.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomClickEvent event = new CustomClickEvent( con, customClickAction.getId(), data );
|
CustomClickEvent event = new CustomClickEvent( con, customClickAction.getId(), customClickAction.getData(), data );
|
||||||
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
if ( bungee.getPluginManager().callEvent( event ).isCancelled() )
|
||||||
{
|
{
|
||||||
throw CancelSendSignal.INSTANCE;
|
throw CancelSendSignal.INSTANCE;
|
||||||
|
Loading…
Reference in New Issue
Block a user