Think this is a good way to manage events, since many will be targeted between specific nodes. It is expected for developers to cast as needed.
This commit is contained in:
parent
434b950a92
commit
4f0a02dcca
@ -0,0 +1,8 @@
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
/**
|
||||
* Represents a user attempting to log into the proxy.
|
||||
*/
|
||||
public interface PendingConnection extends Connection
|
||||
{
|
||||
}
|
@ -1,28 +1,33 @@
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import net.md_5.bungee.api.Connection;
|
||||
import net.md_5.bungee.api.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Cancellable;
|
||||
|
||||
/**
|
||||
* Event called when a player sends a message to a server, or a server sends a
|
||||
* message to a player.
|
||||
*/
|
||||
@Data
|
||||
public class ChatEvent implements Cancellable
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ChatEvent extends TargetedEvent implements Cancellable
|
||||
{
|
||||
|
||||
/**
|
||||
* Cancelled state.
|
||||
*/
|
||||
private boolean cancelled;
|
||||
/**
|
||||
* Where this message is being sent to.
|
||||
*/
|
||||
private final Connection destination;
|
||||
/**
|
||||
* User involved with sending or receiving this message.
|
||||
*/
|
||||
private final ProxiedPlayer player;
|
||||
/**
|
||||
* Text contained in this chat.
|
||||
*/
|
||||
private String message;
|
||||
|
||||
public ChatEvent(Connection sender, Connection receiver, String message)
|
||||
{
|
||||
super(sender, receiver);
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import lombok.Data;
|
||||
import net.md_5.bungee.api.PendingConnection;
|
||||
import net.md_5.bungee.api.plugin.Cancellable;
|
||||
|
||||
/**
|
||||
@ -20,15 +20,7 @@ public class LoginEvent implements Cancellable
|
||||
*/
|
||||
private String cancelReason;
|
||||
/**
|
||||
* Username which the player wishes to use.
|
||||
* Connection attempting to login.
|
||||
*/
|
||||
private final String username;
|
||||
/**
|
||||
* IP address of the remote connection.
|
||||
*/
|
||||
private final InetAddress address;
|
||||
/**
|
||||
* Hostname which the user tried to connect to.
|
||||
*/
|
||||
private final String hostname;
|
||||
private final PendingConnection connection;
|
||||
}
|
||||
|
@ -1,29 +1,24 @@
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import net.md_5.bungee.api.Connection;
|
||||
import net.md_5.bungee.api.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Cancellable;
|
||||
|
||||
/**
|
||||
* Event called when a plugin message is sent to the client or server.
|
||||
*/
|
||||
@Data
|
||||
public class PluginMessageEvent implements Cancellable
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PluginMessageEvent extends TargetedEvent implements Cancellable
|
||||
{
|
||||
|
||||
/**
|
||||
* Cancelled state.
|
||||
*/
|
||||
private boolean cancelled;
|
||||
/**
|
||||
* Dispatcher of this message.
|
||||
*/
|
||||
private final Connection sender;
|
||||
/**
|
||||
* Player involved with sending or receiving this message.
|
||||
*/
|
||||
private final ProxiedPlayer player;
|
||||
/**
|
||||
* Tag specified for this plugin message.
|
||||
*/
|
||||
@ -32,4 +27,11 @@ public class PluginMessageEvent implements Cancellable
|
||||
* Data contained in this plugin message.
|
||||
*/
|
||||
private byte[] data;
|
||||
|
||||
public PluginMessageEvent(Connection sender, Connection receiver, String tag, byte[] data)
|
||||
{
|
||||
super(sender, receiver);
|
||||
this.tag = tag;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import net.md_5.bungee.api.Connection;
|
||||
|
||||
/**
|
||||
* An event which occurs in the communication between two nodes. It is not
|
||||
* recommended to call {@link #setSender(net.md_5.bungee.api.Connection)} or
|
||||
* {@link #setReceiver(net.md_5.bungee.api.Connection)} and the results of doing
|
||||
* so are undefined.
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public abstract class TargetedEvent
|
||||
{
|
||||
|
||||
private Connection sender;
|
||||
private Connection receiver;
|
||||
}
|
Loading…
Reference in New Issue
Block a user