Skip to content

Commit 25f7e13

Browse files
author
games647
committed
Check inventory authentication status only on cache
Fixes #2212 In #2112, we found out that in configurations with disabled cache (like Bungee), this adapter will perform blocking queries on the main thread which impacts the performance. The original code (81cf14f) is in place to preserve the inventory for unregistered and configurations without enforcing a registration (#1830, #1752). Alternatives are: 1. Send the inventory on registration like p.updateInventory() * Still hides it before for unregistered 2. Checking for the enforce registration setting would mean it hides also the inventory for unregistered players 3. Get a notification on player status changes * Requires a complex setup to propagate the changes across spigot servers or different solution for web interfaces * Refresh events, when the status is updated within the plugin itself would be possible, however requires previous queries like registration/login requests. Instant reports about registration will still be complicated. Example: Every time we make queries, save the result locally and fire an event for our components to check for potential changes without making the same query again. Nevertheless this again delays changes if there is no need to that.
1 parent 7a1411c commit 25f7e13

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/main/java/fr/xephi/authme/listener/protocollib/InventoryPacketAdapter.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,20 @@ public void register(BukkitService bukkitService) {
8383
}
8484

8585
private boolean shouldHideInventory(String playerName) {
86-
return !playerCache.isAuthenticated(playerName) && dataSource.isAuthAvailable(playerName);
86+
if (playerCache.isAuthenticated(playerName)) {
87+
// fully logged in - no need to protect it
88+
return false;
89+
}
90+
91+
if (dataSource.isCached()) {
92+
// load from cache or only request once
93+
return dataSource.isAuthAvailable(playerName);
94+
}
95+
96+
// data source is not cached - this means queries would run blocking
97+
// Assume the player is registered would mean the inventory will be protected
98+
// and any potential information leak can be prevented
99+
return true;
87100
}
88101

89102
public void unregister() {

0 commit comments

Comments
 (0)