package com.namelessmc.plugin.sponge;

import com.namelessmc.plugin.common.NamelessPlayer;
import com.namelessmc.plugin.common.NamelessPlugin;
import com.namelessmc.plugin.common.event.ServerJoinEvent;
import com.namelessmc.plugin.common.event.ServerQuitEvent;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.network.ClientConnectionEvent;

import java.util.Objects;

public class SpongeEventProxy {

	private final @NotNull NamelessPlugin plugin;

	SpongeEventProxy(final @NotNull NamelessPlugin plugin) {
		this.plugin = plugin;
	}

	@Listener
	public void onJoin(ClientConnectionEvent.Join event) {
		final NamelessPlayer player = Objects.requireNonNull(
				plugin.audiences().player(event.getTargetEntity().getUniqueId()));
		final ServerJoinEvent event2 = new ServerJoinEvent(player);
		this.plugin.events().post(event2);
	}

	@Listener
	public void onQuit(ClientConnectionEvent.Disconnect event) {
		final ServerQuitEvent event2 = new ServerQuitEvent(event.getTargetEntity().getUniqueId());
		this.plugin.events().post(event2);
	}

}

@@ -78,20 +78,20 @@
 melessPl
-ayer
+ugin
 ;%0Aimport
@@ -112,32 +112,42 @@
 c.plugin.common.
+audiences.
 NamelessPlugin;%0A
@@ -132,36 +132,36 @@
 ences.NamelessPl
-ugin
+ayer
 ;%0Aimport com.nam
@@ -192,77 +192,20 @@
 ent.
-ServerJoinEvent;%0Aimport com.namelessmc.plugin.common.event.ServerQuit
+NamelessJoin
 Even
@@ -337,22 +337,26 @@
 network.
-Client
+ServerSide
 Connecti
@@ -369,35 +369,8 @@
 t;%0A%0A
-import java.util.Objects;%0A%0A
 publ
@@ -563,22 +563,26 @@
  onJoin(
-Client
+ServerSide
 Connecti
@@ -639,411 +639,177 @@
 r = 
-Objects.requireNonNull(%0A%09%09%09%09plugin.audiences().player(event.getTargetEntity().getUniqueId()));%0A%09%09final ServerJoinEvent event2 = new ServerJoinEvent(player);%0A%09%09this.plugin.events().post(event2);%0A%09%7D%0A%0A%09@Listener%0A%09public void onQuit(ClientConnectionEvent.Disconnect event) %7B%0A%09%09final ServerQuitEvent event2 = new ServerQuitEvent(event.getTargetEntity().getUniqueId());%0A%09%09this.plugin.events().post(event2);%0A%09%7D
+new NamelessPlayer(event.player(), event.player().uniqueId(), event.player().name());%0A%09%09this.plugin.events().post(new NamelessJoinEvent(player));%0A%09%7D%0A%0A%09// TODO quit event
 %0A%0A%7D%0A

Implement join event