Archiviert
13
0

Let's be generous and clean up the injection before the other plugins.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2012-10-16 17:01:34 +02:00
Ursprung 94efb38324
Commit ecdc9b4b6c
4 geänderte Dateien mit 29 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -480,6 +480,12 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
try {
manager.registerEvents(new Listener() {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPrePlayerJoin(PlayerJoinEvent event) {
// Let's clean up the other injection first.
playerInjection.uninjectPlayer(event.getPlayer().getAddress());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent event) {
playerInjection.injectPlayer(event.getPlayer());

Datei anzeigen

@ -326,6 +326,20 @@ public class PlayerInjectionHandler {
}
}
/**
* Unregisters a player by the given address.
* @param address - address of the player to unregister.
*/
public void uninjectPlayer(InetSocketAddress address) {
if (!hasClosed && address != null) {
PlayerInjector injector = addressLookup.get(address);
// Clean up
if (injector != null)
uninjectPlayer(injector.getPlayer());
}
}
/**
* Send the given packet to the given reciever.
* @param reciever - the player receiver.

Datei anzeigen

@ -543,12 +543,15 @@ abstract class PlayerInjector {
public Player getPlayer() {
return player;
}
/**
* Set the associated player.
* @param player - associated player.
* Retrieve the hooked player object OR the more up-to-date player instance.
* @return The hooked player, or a more up-to-date instance.
*/
public void setPlayer(Player player) {
this.player = player;
public Player getUpdatedPlayer() {
if (updatedPlayer != null)
return updatedPlayer;
else
return player;
}
}

Datei anzeigen

@ -80,7 +80,7 @@ class TemporaryPlayerFactory {
if (methodName.equalsIgnoreCase("getName"))
return "UNKNOWN[" + injector.getSocket().getRemoteSocketAddress() + "]";
if (methodName.equalsIgnoreCase("getPlayer"))
return injector.getPlayer();
return injector.getUpdatedPlayer();
if (methodName.equalsIgnoreCase("getAddress"))
return injector.getSocket().getRemoteSocketAddress();
if (methodName.equalsIgnoreCase("getServer"))