Changed CloseConnectionIntent to use Player instances

This commit is contained in:
Obique
2018-06-16 18:42:23 -05:00
parent c6058d2dc4
commit 22f12dde39
6 changed files with 17 additions and 34 deletions
@@ -27,36 +27,32 @@
package com.projectswg.holocore.intents.support.global.network;
import com.projectswg.holocore.resources.support.global.network.DisconnectReason;
import com.projectswg.holocore.resources.support.global.player.Player;
import me.joshlarson.jlcommon.control.Intent;
import org.jetbrains.annotations.NotNull;
public class CloseConnectionIntent extends Intent {
private long networkId;
private DisconnectReason reason;
private final Player player;
private final DisconnectReason reason;
public CloseConnectionIntent(long networkId, DisconnectReason reason) {
setNetworkId(networkId);
setDisconnectReason(reason);
}
public void setNetworkId(long networkId) {
this.networkId = networkId;
}
public void setDisconnectReason(DisconnectReason reason) {
public CloseConnectionIntent(@NotNull Player player, @NotNull DisconnectReason reason) {
this.player = player;
this.reason = reason;
}
public long getNetworkId() {
return networkId;
@NotNull
public Player getPlayer() {
return player;
}
@NotNull
public DisconnectReason getDisconnectReason() {
return reason;
}
public static void broadcast(long networkId, DisconnectReason reason) {
new CloseConnectionIntent(networkId, reason).broadcast();
public static void broadcast(@NotNull Player player, @NotNull DisconnectReason reason) {
new CloseConnectionIntent(player, reason).broadcast();
}
}
@@ -1,14 +0,0 @@
package com.projectswg.holocore.resources.support.global.commands.callbacks;
import com.projectswg.holocore.resources.support.global.commands.ICmdCallback;
import com.projectswg.holocore.resources.support.global.player.Player;
import com.projectswg.holocore.resources.support.objects.swg.SWGObject;
public final class ACmdCallbackTemplate implements ICmdCallback {
@Override
public void execute(Player player, SWGObject target, String args) {
}
}
@@ -31,5 +31,6 @@ public enum DisconnectReason {
OTHER_SIDE_TERMINATED,
APPLICATION,
NEW_CONNECTION_ATTEMPT,
CONNECTION_REFUSED
CONNECTION_REFUSED,
SUSPECTED_HACK
}
@@ -143,7 +143,7 @@ public class NetworkClientService extends Service {
@IntentHandler
private void handleCloseConnectionIntent(CloseConnectionIntent ccii) {
disconnect(ccii.getNetworkId());
disconnect(ccii.getPlayer().getNetworkId());
}
@IntentHandler
@@ -164,7 +164,7 @@ public class ConnectionService extends Service {
IntentChain.broadcastChain(
new PlayerEventIntent(p, PlayerEvent.PE_DISAPPEAR),
new PlayerEventIntent(p, PlayerEvent.PE_DESTROYED),
new CloseConnectionIntent(p.getNetworkId(), DisconnectReason.APPLICATION));
new CloseConnectionIntent(p, DisconnectReason.APPLICATION));
}
private void updatePlayTime(Player p) {
@@ -173,7 +173,7 @@ public class AwarenessService extends Service {
PlayerState state = player.getPlayerState();
boolean firstZone = (state == PlayerState.LOGGED_IN);
if (!firstZone && state != PlayerState.ZONED_IN) {
new CloseConnectionIntent(player.getNetworkId(), DisconnectReason.APPLICATION).broadcast();
CloseConnectionIntent.broadcast(player, DisconnectReason.SUSPECTED_HACK);
return;
}