First Event!

This commit is contained in:
EOT3000 2019-07-22 10:20:49 -04:00
parent 58819ea9ce
commit f0551727ca
12 changed files with 232 additions and 14 deletions

View 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;
}
}

View 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 {
}

View file

@ -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;
}

View file

@ -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();
}
}

View file

@ -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);
}

View file

@ -0,0 +1,9 @@
package org.geysermc.api.session;
public interface AuthData {
void getXUID();
void getUUID();
void getName();
}