Skip to content

Commit

Permalink
Remove lombok to shut the #spongedev community up
Browse files Browse the repository at this point in the history
Version 0.1.1-SNAPSHOT
  • Loading branch information
CrushedPixel committed Mar 23, 2017
1 parent cd03417 commit 2209b39
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 25 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ plugins {
}

group = 'eu.crushedpixel.sponge'
version = '0.1'
version = '0.1.1-SNAPSHOT'

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile 'org.spongepowered:spongeapi:5.1.0'
compile 'org.projectlombok:lombok:1.16.4'
}

minecraft {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package eu.crushedpixel.sponge.packetgate.api.event;

import lombok.Getter;
import lombok.Setter;
import net.minecraft.network.Packet;

public class PacketEvent {
Expand All @@ -11,13 +9,29 @@ public PacketEvent(Packet packet, boolean outgoing) {
this.outgoing = outgoing;
}

@Getter @Setter
private Packet packet;

@Getter @Setter
private boolean cancelled = false;

@Getter
private final boolean outgoing;

public Packet getPacket() {
return packet;
}

public void setPacket(Packet packet) {
this.packet = packet;
}

public boolean isCancelled() {
return cancelled;
}

public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}

public boolean isOutgoing() {
return outgoing;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@

import eu.crushedpixel.sponge.packetgate.api.event.PacketEvent;
import eu.crushedpixel.sponge.packetgate.api.registry.PacketConnection;
import lombok.Data;

public interface PacketListener {

void onPacketRead(PacketEvent packetEvent, PacketConnection connection);

void onPacketWrite(PacketEvent packetEvent, PacketConnection connection);

@Data
public class PacketListenerData {
private final PacketListener packetListener;
private final ListenerPriority priority;

public PacketListenerData(PacketListener packetListener, ListenerPriority priority) {
this.packetListener = packetListener;
this.priority = priority;
}

public PacketListener getPacketListener() {
return packetListener;
}

public ListenerPriority getPriority() {
return priority;
}
}

public enum ListenerPriority {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@
import eu.crushedpixel.sponge.packetgate.api.listener.PacketListener;
import eu.crushedpixel.sponge.packetgate.api.listener.PacketListener.PacketListenerData;
import io.netty.channel.Channel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import net.minecraft.network.Packet;
import org.slf4j.Logger;

import java.util.List;
import java.util.UUID;

@RequiredArgsConstructor
public class PacketConnection extends ListenerOwner {

private final Logger logger;

@Getter
private final Channel channel;

@Getter @Setter
private UUID playerUUID;

public PacketConnection(Logger logger, Channel channel) {
this.logger = logger;
this.channel = channel;
}

public void sendPacket(Packet packet) {
channel.write(packet);
}
Expand All @@ -43,4 +42,15 @@ public void handlePacketEvent(PacketEvent event) {
}
}

public Channel getChannel() {
return channel;
}

public UUID getPlayerUUID() {
return playerUUID;
}

public void setPlayerUUID(UUID playerUUID) {
this.playerUUID = playerUUID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class PluginPacketGate {

static final String ID = "packetgate";
static final String VERSION = "0.1";
static final String VERSION = "0.1.1";

@Inject
private Logger logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import lombok.RequiredArgsConstructor;
import net.minecraft.network.login.server.SPacketLoginSuccess;

@RequiredArgsConstructor
@ChannelHandler.Sharable
class ConnectionHandler extends ChannelDuplexHandler {

Expand All @@ -18,6 +16,11 @@ class ConnectionHandler extends ChannelDuplexHandler {

private boolean injected = false;

public ConnectionHandler(PacketGate packetGate, PacketConnection connection) {
this.packetGate = packetGate;
this.connection = connection;
}

@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
if (!injected) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;

@RequiredArgsConstructor
public class CustomChannelInitializer extends ChannelInboundHandlerAdapter {

private final Logger logger;
private final PacketGate packetGate;

public CustomChannelInitializer(Logger logger, PacketGate packetGate) {
this.logger = logger;
this.packetGate = packetGate;
}

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
Channel channel = (Channel)msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
import eu.crushedpixel.sponge.packetgate.api.registry.PacketConnection;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.RequiredArgsConstructor;
import net.minecraft.network.Packet;

@RequiredArgsConstructor
class IncomingPacketHandler extends ChannelInboundHandlerAdapter {

private final PacketConnection packetConnection;

public IncomingPacketHandler(PacketConnection packetConnection) {
this.packetConnection = packetConnection;
}

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof Packet) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package eu.crushedpixel.sponge.packetgate.plugin.netty;

import eu.crushedpixel.sponge.packetgate.api.registry.PacketConnection;
import eu.crushedpixel.sponge.packetgate.api.event.PacketEvent;
import eu.crushedpixel.sponge.packetgate.api.registry.PacketConnection;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import lombok.RequiredArgsConstructor;
import net.minecraft.network.Packet;

@RequiredArgsConstructor
class OutgoingPacketHandler extends ChannelOutboundHandlerAdapter {

private final PacketConnection packetConnection;

public OutgoingPacketHandler(PacketConnection packetConnection) {
this.packetConnection = packetConnection;
}

@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (msg instanceof Packet) {
Expand Down

0 comments on commit 2209b39

Please sign in to comment.