mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
First Event!
This commit is contained in:
parent
58819ea9ce
commit
f0551727ca
12 changed files with 232 additions and 14 deletions
32
api/src/main/java/org/geysermc/api/events/EventHandler.java
Normal file
32
api/src/main/java/org/geysermc/api/events/EventHandler.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package org.geysermc.api.events;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* The annotation to put on all methods that are events.
|
||||
*/
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface EventHandler {
|
||||
|
||||
/**
|
||||
* @return the order to execute events.
|
||||
* @see EventPriority
|
||||
*/
|
||||
EventPriority value() default EventPriority.NORMAL;
|
||||
|
||||
/**
|
||||
* When an eventHandler should be run.
|
||||
* The names mostly explain.
|
||||
*/
|
||||
enum EventPriority {
|
||||
FIRST,
|
||||
NORMAL,
|
||||
LAST,
|
||||
READ_ONLY;
|
||||
}
|
||||
}
|
8
api/src/main/java/org/geysermc/api/events/Listener.java
Normal file
8
api/src/main/java/org/geysermc/api/events/Listener.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package org.geysermc.api.events;
|
||||
|
||||
/**
|
||||
* A marker class which says that a specific class uses events.
|
||||
* @see EventHandler
|
||||
*/
|
||||
public interface Listener {
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package org.geysermc.api.events.player;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PingEvent {
|
||||
public PingEvent(InetSocketAddress address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
private InetSocketAddress address;
|
||||
|
||||
private String edition;
|
||||
private String motd;
|
||||
private int protocolVersion;
|
||||
private String version;
|
||||
private int playerCount;
|
||||
private int maximumPlayerCount;
|
||||
private long serverId;
|
||||
private String subMotd;
|
||||
private String gameType;
|
||||
private boolean nintendoLimited;
|
||||
}
|
|
@ -33,6 +33,8 @@ import lombok.Setter;
|
|||
* The first init point is the constructor, followed by onLoad, and finally onEnable.
|
||||
*/
|
||||
public class Plugin {
|
||||
protected String name;
|
||||
protected String version;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -60,9 +62,18 @@ public class Plugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* Called when th server is reloaded
|
||||
* Called when the server is reloaded
|
||||
*/
|
||||
public void onReload() {
|
||||
|
||||
}
|
||||
|
||||
public final String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String toString() {
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
package org.geysermc.api.plugin;
|
||||
|
||||
import org.geysermc.api.events.Listener;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface PluginManager {
|
||||
|
@ -63,4 +65,23 @@ public interface PluginManager {
|
|||
* @return a set of the loaded plugins
|
||||
*/
|
||||
Set<Plugin> getPlugins();
|
||||
|
||||
/**
|
||||
* @param name The name of the plugin you want to get.
|
||||
* @return The plugin with the String name in the parameters.
|
||||
*/
|
||||
Plugin getPluginByName(String name);
|
||||
|
||||
/**
|
||||
* Registers a listener to be run when an event is executed
|
||||
* @param plugin the plugin registering the listener
|
||||
* @param listener the listener which will contain the event methods
|
||||
*/
|
||||
void registerEventListener(Plugin plugin, Listener listener);
|
||||
|
||||
/**
|
||||
* Run an event
|
||||
* @param o the event object.
|
||||
*/
|
||||
void runEvent(Object o);
|
||||
}
|
||||
|
|
9
api/src/main/java/org/geysermc/api/session/AuthData.java
Normal file
9
api/src/main/java/org/geysermc/api/session/AuthData.java
Normal file
|
@ -0,0 +1,9 @@
|
|||
package org.geysermc.api.session;
|
||||
|
||||
public interface AuthData {
|
||||
void getXUID();
|
||||
|
||||
void getUUID();
|
||||
|
||||
void getName();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue