Skip to content

Commit

Permalink
Improve documentation and better integrate event and plugin hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
bundabrg committed Jul 29, 2020
1 parent 64c94f2 commit 796f042
Show file tree
Hide file tree
Showing 18 changed files with 175 additions and 207 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,31 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.geysermc.connector.event.Cancellable;
import org.geysermc.connector.event.GeyserEvent;
import org.geysermc.connector.event.Session;
import org.geysermc.connector.network.session.GeyserSession;

/**
* Triggered when a new session is connected
*
* If cancelled then the session will be disconnected with {@code message} as the disconnection message
*/
@Data
@EqualsAndHashCode(callSuper = true)
@SuppressWarnings("JavaDoc")
public class SessionConnectEvent extends GeyserEvent implements Session {
public class SessionConnectEvent extends GeyserEvent implements Cancellable, Session {
private boolean cancelled;

@NonNull
private final GeyserSession session;

/**
* Message returned to client if connection is cancelled
*
* @param message set the message
* @return get current message
*/
@NonNull
private String message;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,29 @@

package org.geysermc.connector.event.events.network;

import com.nukkitx.network.util.DisconnectReason;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.geysermc.connector.event.GeyserEvent;
import org.geysermc.connector.event.Session;
import org.geysermc.connector.network.session.GeyserSession;

/**
* Triggered when a session is disconnected
*/
@Data
@EqualsAndHashCode(callSuper = true)
@SuppressWarnings("JavaDoc")
public class SessionDisconnectEvent extends GeyserEvent {
public class SessionDisconnectEvent extends GeyserEvent implements Session {
@NonNull
private final GeyserSession session;

/**
* The reason for the disconnection
*
* @return the reason
*/
@NonNull
private final DisconnectReason disconnectReason;
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public abstract class UpstreamPacketReceiveEvent<T extends BedrockPacket> extend
* @param packet the packet to wrap
* @return an instantiated class that inherits from this one
*/
public static <T extends BedrockPacket> UpstreamPacketReceiveEvent<T> of(GeyserSession session, T packet) {
public static <T extends BedrockPacket, P extends UpstreamPacketReceiveEvent<T>> P of(GeyserSession session, T packet) {
Class<?> cls = classMap.get(packet.getClass());
if (cls == null) {
try {
Expand All @@ -82,7 +82,7 @@ public static <T extends BedrockPacket> UpstreamPacketReceiveEvent<T> of(GeyserS

try {
//noinspection unchecked
return (UpstreamPacketReceiveEvent<T>) cls.getConstructor(GeyserSession.class, BedrockPacket.class).newInstance(session, packet);
return (P) cls.getConstructor(GeyserSession.class, BedrockPacket.class).newInstance(session, packet);
} catch (InstantiationException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,26 @@

package org.geysermc.connector.event.events.registry;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.geysermc.connector.event.GeyserEvent;

import java.util.Set;

/**
* Triggered when registering Packet Translators
*/
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@Data
@EqualsAndHashCode(callSuper = true)
@SuppressWarnings("JavaDoc")
public class BlockEntityRegistryEvent extends GeyserEvent {
/**
* List of registered translators
*
* @param registeredTranslators set the translators
* @return get the translators
*/
@NonNull
private Set<Class<?>> registeredTranslators;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,24 @@
package org.geysermc.connector.event.events.registry;

import com.github.steveice10.mc.protocol.data.game.window.WindowType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.geysermc.connector.event.GeyserEvent;
import org.geysermc.connector.network.translators.inventory.InventoryTranslator;

import java.util.Map;

@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@SuppressWarnings("JavaDoc")
public class InventoryTranslatorRegistryEvent extends GeyserEvent {
/**
* List of registered translators
*
* @param registeredTranslators set the translators
* @return get the translators
*/
@NonNull
Map<WindowType, InventoryTranslator> registeredTranslators;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,26 @@

package org.geysermc.connector.event.events.registry;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.geysermc.connector.event.GeyserEvent;

import java.util.Set;

/**
* Triggered when registering Item Remapper Translators
*/
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@Data
@EqualsAndHashCode(callSuper = true)
@SuppressWarnings("JavaDoc")
public class ItemRemapperRegistryEvent extends GeyserEvent {
/**
* List of registered translators
*
* @param registeredTranslators set the translators
* @return get the translators
*/
@NonNull
private Set<Class<?>> registeredTranslators;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,26 @@

package org.geysermc.connector.event.events.registry;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.geysermc.connector.event.GeyserEvent;

import java.util.Set;

/**
* Triggered when registering Packet Translators
*/
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@Data
@EqualsAndHashCode(callSuper = true)
@SuppressWarnings("JavaDoc")
public class PacketTranslatorRegistryEvent extends GeyserEvent {
/**
* List of registered translators
*
* @param registeredTranslators set the translators
* @return get the translators
*/
@NonNull
private Set<Class<?>> registeredTranslators;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,26 @@

package org.geysermc.connector.event.events.registry;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.geysermc.connector.event.GeyserEvent;

import java.util.Set;

/**
* Triggered when registering Sound Handlers
*/
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@Data
@EqualsAndHashCode(callSuper = true)
@SuppressWarnings("JavaDoc")
public class SoundHandlerRegistryEvent extends GeyserEvent {
/**
* List of registered translators
*
* @param registeredTranslators set the translators
* @return get the translators
*/
@NonNull
private Set<Class<?>> registeredTranslators;
}
Loading

0 comments on commit 796f042

Please sign in to comment.