Force a clear of transient nodes when a User quits, don't just rely on their instance being unloaded

This commit is contained in:
Luck 2018-01-21 20:25:00 +00:00
parent 72d4e5cf7a
commit f18d230ff6
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 31 additions and 2 deletions

View File

@ -202,6 +202,14 @@ public class BukkitConnectionListener extends AbstractLoginListener implements L
// Register with the housekeeper, so the User's instance will stick // Register with the housekeeper, so the User's instance will stick
// around for a bit after they disconnect // around for a bit after they disconnect
this.plugin.getUserManager().getHouseKeeper().registerUsage(player.getUniqueId()); this.plugin.getUserManager().getHouseKeeper().registerUsage(player.getUniqueId());
// force a clear of transient nodes
this.plugin.getScheduler().doAsync(() -> {
User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
if (user != null) {
user.clearTransientNodes();
}
});
} }
} }

View File

@ -132,9 +132,19 @@ public class BungeeConnectionListener extends AbstractLoginListener implements L
// Wait until the last priority to unload, so plugins can still perform permission checks on this event // Wait until the last priority to unload, so plugins can still perform permission checks on this event
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerQuit(PlayerDisconnectEvent e) { public void onPlayerQuit(PlayerDisconnectEvent e) {
ProxiedPlayer player = e.getPlayer();
// Register with the housekeeper, so the User's instance will stick // Register with the housekeeper, so the User's instance will stick
// around for a bit after they disconnect // around for a bit after they disconnect
this.plugin.getUserManager().getHouseKeeper().registerUsage(e.getPlayer().getUniqueId()); this.plugin.getUserManager().getHouseKeeper().registerUsage(player.getUniqueId());
// force a clear of transient nodes
this.plugin.getScheduler().doAsync(() -> {
User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
if (user != null) {
user.clearTransientNodes();
}
});
} }
} }

View File

@ -31,6 +31,7 @@ import me.lucko.luckperms.common.model.User;
import me.lucko.luckperms.common.utils.AbstractLoginListener; import me.lucko.luckperms.common.utils.AbstractLoginListener;
import me.lucko.luckperms.sponge.LPSpongePlugin; import me.lucko.luckperms.sponge.LPSpongePlugin;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener; import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.Order; import org.spongepowered.api.event.Order;
import org.spongepowered.api.event.filter.IsCancelled; import org.spongepowered.api.event.filter.IsCancelled;
@ -157,9 +158,19 @@ public class SpongeConnectionListener extends AbstractLoginListener {
@Listener(order = Order.POST) @Listener(order = Order.POST)
public void onClientLeave(ClientConnectionEvent.Disconnect e) { public void onClientLeave(ClientConnectionEvent.Disconnect e) {
Player player = e.getTargetEntity();
// Register with the housekeeper, so the User's instance will stick // Register with the housekeeper, so the User's instance will stick
// around for a bit after they disconnect // around for a bit after they disconnect
this.plugin.getUserManager().getHouseKeeper().registerUsage(e.getTargetEntity().getUniqueId()); this.plugin.getUserManager().getHouseKeeper().registerUsage(player.getUniqueId());
// force a clear of transient nodes
this.plugin.getScheduler().doAsync(() -> {
User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
if (user != null) {
user.clearTransientNodes();
}
});
} }
} }