Let's be generous and clean up the injection before the other plugins.
Dieser Commit ist enthalten in:
Ursprung
94efb38324
Commit
ecdc9b4b6c
@ -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());
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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"))
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren