mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2025-08-09 14:03:18 +00:00
Added support for UUID-based player lookups in 1.7.5+
You could argue that ShadowRanger's conversion of everything to UUID is better, but that would result in us having to contact Mojang's servers simply to fetch a player by UUID for versions < 1.7.5. It seems excessive (not to mention that uncached contact can result in rate limiting) when the server itself will not remember who they are across name changes. If they can re-obtain everything in their inventory, they can re-run /ac.
This commit is contained in:
parent
d7eec528e4
commit
8a6b98614f
21 changed files with 286 additions and 2 deletions
|
@ -169,7 +169,7 @@ public class OpenInv extends JavaPlugin {
|
|||
* @return true if the server version is supported
|
||||
*/
|
||||
public boolean isSupportedVersion() {
|
||||
return accessor.isSupported();
|
||||
return this.accessor.isSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -311,6 +311,17 @@ public class OpenInv extends JavaPlugin {
|
|||
saveConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a unique identifier by which the OfflinePlayer can be referenced. Using the value
|
||||
* returned to look up a Player will generally be much faster for later implementations.
|
||||
*
|
||||
* @param offline the OfflinePlayer
|
||||
* @return the identifier
|
||||
*/
|
||||
public String getPlayerID(OfflinePlayer offline) {
|
||||
return this.playerLoader.getPlayerDataID(offline);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an OfflinePlayer by name.
|
||||
* <p>
|
||||
|
@ -333,12 +344,15 @@ public class OpenInv extends JavaPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
// Attempt exact offline match first - adds UUID support for later versions
|
||||
OfflinePlayer player = this.playerLoader.getPlayerByID(name);
|
||||
|
||||
// Ensure name is valid if server is in online mode to avoid unnecessary searching
|
||||
if (getServer().getOnlineMode() && !name.matches("[a-zA-Z0-9_]{3,16}")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
OfflinePlayer player = getServer().getPlayerExact(name);
|
||||
player = getServer().getPlayerExact(name);
|
||||
|
||||
if (player != null) {
|
||||
return player;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue