mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 11:38:40 +01:00
Improve the way Vault lookups for offline players are handled (#1150)
1) The behaviour of online player lookups is unchanged - this only affects offline player data lookups. 2) If a 'offline player' request is made from an async task, it is executed normally. (the data is loaded) 3) If a 'offline player' request that cannot be immediately fulfilled is made from the main server thread, an exception is thrown. The exception thrown as a result of 3) can be disabled in the config. In this case, the query is performed anyway. The main server thread will block until the request is complete.
This commit is contained in:
parent
56df15caf8
commit
56c55d71fe
@ -26,9 +26,7 @@
|
|||||||
package me.lucko.luckperms.bukkit.vault;
|
package me.lucko.luckperms.bukkit.vault;
|
||||||
|
|
||||||
import net.milkbowl.vault.chat.Chat;
|
import net.milkbowl.vault.chat.Chat;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -60,15 +58,15 @@ public abstract class AbstractVaultChat extends Chat {
|
|||||||
protected Function<String, String> worldMappingFunction = Function.identity();
|
protected Function<String, String> worldMappingFunction = Function.identity();
|
||||||
|
|
||||||
// the permission api instance
|
// the permission api instance
|
||||||
private final Permission permissionApi;
|
private final AbstractVaultPermission permissionApi;
|
||||||
|
|
||||||
public AbstractVaultChat(Permission permissionApi) {
|
public AbstractVaultChat(AbstractVaultPermission permissionApi) {
|
||||||
super(permissionApi);
|
super(permissionApi);
|
||||||
this.permissionApi = permissionApi;
|
this.permissionApi = permissionApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public final boolean isEnabled() {
|
||||||
// always return true
|
// always return true
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -130,22 +128,6 @@ public abstract class AbstractVaultChat extends Chat {
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility methods for upgrading legacy requests
|
|
||||||
|
|
||||||
private static UUID player(String player) {
|
|
||||||
if (player == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return player(Bukkit.getPlayerExact(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static UUID player(OfflinePlayer player) {
|
|
||||||
if (player == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return player.getUniqueId();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String world(String world) {
|
private String world(String world) {
|
||||||
return this.worldMappingFunction.apply(world);
|
return this.worldMappingFunction.apply(world);
|
||||||
}
|
}
|
||||||
@ -165,547 +147,547 @@ public abstract class AbstractVaultChat extends Chat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerPrefix(String world, String player) {
|
public final String getPlayerPrefix(String world, String player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return getUserChatPrefix(world(world), player(player));
|
return getUserChatPrefix(world(world), this.permissionApi.lookupUuid(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerPrefix(String world, OfflinePlayer player) {
|
public final String getPlayerPrefix(String world, OfflinePlayer player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return getUserChatPrefix(world(world), player(player));
|
return getUserChatPrefix(world(world), player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerPrefix(World world, String player) {
|
public final String getPlayerPrefix(World world, String player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return getUserChatPrefix(world(world), player(player));
|
return getUserChatPrefix(world(world), this.permissionApi.lookupUuid(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerPrefix(Player player) {
|
public final String getPlayerPrefix(Player player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return getUserChatPrefix(world(player), player(player));
|
return getUserChatPrefix(world(player), ((OfflinePlayer) player).getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
public final void setPlayerPrefix(String world, String player, String prefix) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
setUserChatPrefix(world(world), player(player), prefix);
|
setUserChatPrefix(world(world), this.permissionApi.lookupUuid(player), prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerPrefix(String world, OfflinePlayer player, String prefix) {
|
public final void setPlayerPrefix(String world, OfflinePlayer player, String prefix) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
setUserChatPrefix(world(world), player(player), prefix);
|
setUserChatPrefix(world(world), player.getUniqueId(), prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerPrefix(World world, String player, String prefix) {
|
public final void setPlayerPrefix(World world, String player, String prefix) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
setUserChatPrefix(world(world), player(player), prefix);
|
setUserChatPrefix(world(world), this.permissionApi.lookupUuid(player), prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerPrefix(Player player, String prefix) {
|
public final void setPlayerPrefix(Player player, String prefix) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
setUserChatPrefix(world(player), player(player), prefix);
|
setUserChatPrefix(world(player), ((OfflinePlayer) player).getUniqueId(), prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerSuffix(String world, String player) {
|
public final String getPlayerSuffix(String world, String player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return getUserChatSuffix(world(world), player(player));
|
return getUserChatSuffix(world(world), this.permissionApi.lookupUuid(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerSuffix(String world, OfflinePlayer player) {
|
public final String getPlayerSuffix(String world, OfflinePlayer player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return getUserChatSuffix(world(world), player(player));
|
return getUserChatSuffix(world(world), player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerSuffix(World world, String player) {
|
public final String getPlayerSuffix(World world, String player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return getUserChatSuffix(world(world), player(player));
|
return getUserChatSuffix(world(world), this.permissionApi.lookupUuid(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerSuffix(Player player) {
|
public final String getPlayerSuffix(Player player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return getUserChatSuffix(world(player), player(player));
|
return getUserChatSuffix(world(player), ((OfflinePlayer) player).getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
public final void setPlayerSuffix(String world, String player, String suffix) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
setUserChatSuffix(world(world), player(player), suffix);
|
setUserChatSuffix(world(world), this.permissionApi.lookupUuid(player), suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerSuffix(String world, OfflinePlayer player, String suffix) {
|
public final void setPlayerSuffix(String world, OfflinePlayer player, String suffix) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
setUserChatSuffix(world(world), player(player), suffix);
|
setUserChatSuffix(world(world), player.getUniqueId(), suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerSuffix(World world, String player, String suffix) {
|
public final void setPlayerSuffix(World world, String player, String suffix) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
setUserChatSuffix(world(world), player(player), suffix);
|
setUserChatSuffix(world(world), this.permissionApi.lookupUuid(player), suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerSuffix(Player player, String suffix) {
|
public final void setPlayerSuffix(Player player, String suffix) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
setUserChatSuffix(world(player), player(player), suffix);
|
setUserChatSuffix(world(player), ((OfflinePlayer) player).getUniqueId(), suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGroupPrefix(String world, String group) {
|
public final String getGroupPrefix(String world, String group) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return getGroupChatPrefix(world(world), group);
|
return getGroupChatPrefix(world(world), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGroupPrefix(World world, String group) {
|
public final String getGroupPrefix(World world, String group) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return getGroupChatPrefix(world(world), group);
|
return getGroupChatPrefix(world(world), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupPrefix(String world, String group, String prefix) {
|
public final void setGroupPrefix(String world, String group, String prefix) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
setGroupChatPrefix(world(world), group, prefix);
|
setGroupChatPrefix(world(world), group, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupPrefix(World world, String group, String prefix) {
|
public final void setGroupPrefix(World world, String group, String prefix) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
setGroupChatPrefix(world(world), group, prefix);
|
setGroupChatPrefix(world(world), group, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGroupSuffix(String world, String group) {
|
public final String getGroupSuffix(String world, String group) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return getGroupChatSuffix(world(world), group);
|
return getGroupChatSuffix(world(world), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGroupSuffix(World world, String group) {
|
public final String getGroupSuffix(World world, String group) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return getGroupChatSuffix(world(world), group);
|
return getGroupChatSuffix(world(world), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupSuffix(String world, String group, String suffix) {
|
public final void setGroupSuffix(String world, String group, String suffix) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
setGroupChatSuffix(world(world), group, suffix);
|
setGroupChatSuffix(world(world), group, suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupSuffix(World world, String group, String suffix) {
|
public final void setGroupSuffix(World world, String group, String suffix) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
setGroupChatSuffix(world(world), group, suffix);
|
setGroupChatSuffix(world(world), group, suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerInfoInteger(String world, OfflinePlayer player, String node, int defaultValue) {
|
public final int getPlayerInfoInteger(String world, OfflinePlayer player, String node, int defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return intConvert(getUserMeta(world(world), player(player), node), defaultValue);
|
return intConvert(getUserMeta(world(world), player.getUniqueId(), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
public final int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return intConvert(getUserMeta(world(world), player(player), node), defaultValue);
|
return intConvert(getUserMeta(world(world), this.permissionApi.lookupUuid(player), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerInfoInteger(World world, String player, String node, int defaultValue) {
|
public final int getPlayerInfoInteger(World world, String player, String node, int defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return intConvert(getUserMeta(world(world), player(player), node), defaultValue);
|
return intConvert(getUserMeta(world(world), this.permissionApi.lookupUuid(player), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPlayerInfoInteger(Player player, String node, int defaultValue) {
|
public final int getPlayerInfoInteger(Player player, String node, int defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return intConvert(getUserMeta(world(player), player(player), node), defaultValue);
|
return intConvert(getUserMeta(world(player), ((OfflinePlayer) player).getUniqueId(), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoInteger(String world, OfflinePlayer player, String node, int value) {
|
public final void setPlayerInfoInteger(String world, OfflinePlayer player, String node, int value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(world), player(player), node, value);
|
setUserMeta(world(world), player.getUniqueId(), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
public final void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(world), player(player), node, value);
|
setUserMeta(world(world), this.permissionApi.lookupUuid(player), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoInteger(World world, String player, String node, int value) {
|
public final void setPlayerInfoInteger(World world, String player, String node, int value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(world), player(player), node, value);
|
setUserMeta(world(world), this.permissionApi.lookupUuid(player), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoInteger(Player player, String node, int value) {
|
public final void setPlayerInfoInteger(Player player, String node, int value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(player), player(player), node, value);
|
setUserMeta(world(player), ((OfflinePlayer) player).getUniqueId(), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
public final int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return intConvert(getGroupMeta(world(world), group, node), defaultValue);
|
return intConvert(getGroupMeta(world(world), group, node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getGroupInfoInteger(World world, String group, String node, int defaultValue) {
|
public final int getGroupInfoInteger(World world, String group, String node, int defaultValue) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return intConvert(getGroupMeta(world(world), group, node), defaultValue);
|
return intConvert(getGroupMeta(world(world), group, node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
public final void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setGroupMeta(world(world), group, node, value);
|
setGroupMeta(world(world), group, node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupInfoInteger(World world, String group, String node, int value) {
|
public final void setGroupInfoInteger(World world, String group, String node, int value) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setGroupMeta(world(world), group, node, value);
|
setGroupMeta(world(world), group, node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getPlayerInfoDouble(String world, OfflinePlayer player, String node, double defaultValue) {
|
public final double getPlayerInfoDouble(String world, OfflinePlayer player, String node, double defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return doubleConvert(getUserMeta(world(world), player(player), node), defaultValue);
|
return doubleConvert(getUserMeta(world(world), player.getUniqueId(), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
public final double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return doubleConvert(getUserMeta(world(world), player(player), node), defaultValue);
|
return doubleConvert(getUserMeta(world(world), this.permissionApi.lookupUuid(player), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getPlayerInfoDouble(World world, String player, String node, double defaultValue) {
|
public final double getPlayerInfoDouble(World world, String player, String node, double defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return doubleConvert(getUserMeta(world(world), player(player), node), defaultValue);
|
return doubleConvert(getUserMeta(world(world), this.permissionApi.lookupUuid(player), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getPlayerInfoDouble(Player player, String node, double defaultValue) {
|
public final double getPlayerInfoDouble(Player player, String node, double defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return doubleConvert(getUserMeta(world(player), player(player), node), defaultValue);
|
return doubleConvert(getUserMeta(world(player), ((OfflinePlayer) player).getUniqueId(), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoDouble(String world, OfflinePlayer player, String node, double value) {
|
public final void setPlayerInfoDouble(String world, OfflinePlayer player, String node, double value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(world), player(player), node, value);
|
setUserMeta(world(world), player.getUniqueId(), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
public final void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(world), player(player), node, value);
|
setUserMeta(world(world), this.permissionApi.lookupUuid(player), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoDouble(World world, String player, String node, double value) {
|
public final void setPlayerInfoDouble(World world, String player, String node, double value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(world), player(player), node, value);
|
setUserMeta(world(world), this.permissionApi.lookupUuid(player), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoDouble(Player player, String node, double value) {
|
public final void setPlayerInfoDouble(Player player, String node, double value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(player), player(player), node, value);
|
setUserMeta(world(player), ((OfflinePlayer) player).getUniqueId(), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
public final double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return doubleConvert(getGroupMeta(world(world), group, node), defaultValue);
|
return doubleConvert(getGroupMeta(world(world), group, node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getGroupInfoDouble(World world, String group, String node, double defaultValue) {
|
public final double getGroupInfoDouble(World world, String group, String node, double defaultValue) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return doubleConvert(getGroupMeta(world(world), group, node), defaultValue);
|
return doubleConvert(getGroupMeta(world(world), group, node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
public final void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setGroupMeta(world(world), group, node, value);
|
setGroupMeta(world(world), group, node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupInfoDouble(World world, String group, String node, double value) {
|
public final void setGroupInfoDouble(World world, String group, String node, double value) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setGroupMeta(world(world), group, node, value);
|
setGroupMeta(world(world), group, node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean defaultValue) {
|
public final boolean getPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return booleanConvert(getUserMeta(world(world), player(player), node), defaultValue);
|
return booleanConvert(getUserMeta(world(world), player.getUniqueId(), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
public final boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return booleanConvert(getUserMeta(world(world), player(player), node), defaultValue);
|
return booleanConvert(getUserMeta(world(world), this.permissionApi.lookupUuid(player), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getPlayerInfoBoolean(World world, String player, String node, boolean defaultValue) {
|
public final boolean getPlayerInfoBoolean(World world, String player, String node, boolean defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return booleanConvert(getUserMeta(world(world), player(player), node), defaultValue);
|
return booleanConvert(getUserMeta(world(world), this.permissionApi.lookupUuid(player), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getPlayerInfoBoolean(Player player, String node, boolean defaultValue) {
|
public final boolean getPlayerInfoBoolean(Player player, String node, boolean defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return booleanConvert(getUserMeta(world(player), player(player), node), defaultValue);
|
return booleanConvert(getUserMeta(world(player), ((OfflinePlayer) player).getUniqueId(), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean value) {
|
public final void setPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(world), player(player), node, value);
|
setUserMeta(world(world), player.getUniqueId(), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
public final void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(world), player(player), node, value);
|
setUserMeta(world(world), this.permissionApi.lookupUuid(player), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoBoolean(World world, String player, String node, boolean value) {
|
public final void setPlayerInfoBoolean(World world, String player, String node, boolean value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(world), player(player), node, value);
|
setUserMeta(world(world), this.permissionApi.lookupUuid(player), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoBoolean(Player player, String node, boolean value) {
|
public final void setPlayerInfoBoolean(Player player, String node, boolean value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(player), player(player), node, value);
|
setUserMeta(world(player), ((OfflinePlayer) player).getUniqueId(), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
public final boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return booleanConvert(getGroupMeta(world(world), group, node), defaultValue);
|
return booleanConvert(getGroupMeta(world(world), group, node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getGroupInfoBoolean(World world, String group, String node, boolean defaultValue) {
|
public final boolean getGroupInfoBoolean(World world, String group, String node, boolean defaultValue) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return booleanConvert(getGroupMeta(world(world), group, node), defaultValue);
|
return booleanConvert(getGroupMeta(world(world), group, node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
public final void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setGroupMeta(world(world), group, node, value);
|
setGroupMeta(world(world), group, node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupInfoBoolean(World world, String group, String node, boolean value) {
|
public final void setGroupInfoBoolean(World world, String group, String node, boolean value) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setGroupMeta(world(world), group, node, value);
|
setGroupMeta(world(world), group, node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerInfoString(String world, OfflinePlayer player, String node, String defaultValue) {
|
public final String getPlayerInfoString(String world, OfflinePlayer player, String node, String defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return strConvert(getUserMeta(world(world), player(player), node), defaultValue);
|
return strConvert(getUserMeta(world(world), player.getUniqueId(), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
public final String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return strConvert(getUserMeta(world(world), player(player), node), defaultValue);
|
return strConvert(getUserMeta(world(world), this.permissionApi.lookupUuid(player), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerInfoString(World world, String player, String node, String defaultValue) {
|
public final String getPlayerInfoString(World world, String player, String node, String defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return strConvert(getUserMeta(world(world), player(player), node), defaultValue);
|
return strConvert(getUserMeta(world(world), this.permissionApi.lookupUuid(player), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerInfoString(Player player, String node, String defaultValue) {
|
public final String getPlayerInfoString(Player player, String node, String defaultValue) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return strConvert(getUserMeta(world(player), player(player), node), defaultValue);
|
return strConvert(getUserMeta(world(player), ((OfflinePlayer) player).getUniqueId(), node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoString(String world, OfflinePlayer player, String node, String value) {
|
public final void setPlayerInfoString(String world, OfflinePlayer player, String node, String value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(world), player(player), node, value);
|
setUserMeta(world(world), player.getUniqueId(), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
public final void setPlayerInfoString(String world, String player, String node, String value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(world), player(player), node, value);
|
setUserMeta(world(world), this.permissionApi.lookupUuid(player), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoString(World world, String player, String node, String value) {
|
public final void setPlayerInfoString(World world, String player, String node, String value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(world), player(player), node, value);
|
setUserMeta(world(world), this.permissionApi.lookupUuid(player), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPlayerInfoString(Player player, String node, String value) {
|
public final void setPlayerInfoString(Player player, String node, String value) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setUserMeta(world(player), player(player), node, value);
|
setUserMeta(world(player), ((OfflinePlayer) player).getUniqueId(), node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
public final String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return strConvert(getGroupMeta(world(world), group, node), defaultValue);
|
return strConvert(getGroupMeta(world(world), group, node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getGroupInfoString(World world, String group, String node, String defaultValue) {
|
public final String getGroupInfoString(World world, String group, String node, String defaultValue) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
return strConvert(getGroupMeta(world(world), group, node), defaultValue);
|
return strConvert(getGroupMeta(world(world), group, node), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
public final void setGroupInfoString(String world, String group, String node, String value) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setGroupMeta(world(world), group, node, value);
|
setGroupMeta(world(world), group, node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupInfoString(World world, String group, String node, String value) {
|
public final void setGroupInfoString(World world, String group, String node, String value) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(node, "node");
|
Objects.requireNonNull(node, "node");
|
||||||
setGroupMeta(world(world), group, node, value);
|
setGroupMeta(world(world), group, node, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerInGroup(String world, OfflinePlayer player, String group) {
|
public final boolean playerInGroup(String world, OfflinePlayer player, String group) {
|
||||||
return this.permissionApi.playerInGroup(world, player, group);
|
return this.permissionApi.playerInGroup(world, player, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerInGroup(String world, String player, String group) {
|
public final boolean playerInGroup(String world, String player, String group) {
|
||||||
return this.permissionApi.playerInGroup(world, player, group);
|
return this.permissionApi.playerInGroup(world, player, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerInGroup(World world, String player, String group) {
|
public final boolean playerInGroup(World world, String player, String group) {
|
||||||
return this.permissionApi.playerInGroup(world, player, group);
|
return this.permissionApi.playerInGroup(world, player, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerInGroup(Player player, String group) {
|
public final boolean playerInGroup(Player player, String group) {
|
||||||
return this.permissionApi.playerInGroup(player, group);
|
return this.permissionApi.playerInGroup(player, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getPlayerGroups(String world, OfflinePlayer player) {
|
public final String[] getPlayerGroups(String world, OfflinePlayer player) {
|
||||||
return this.permissionApi.getPlayerGroups(world, player);
|
return this.permissionApi.getPlayerGroups(world, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getPlayerGroups(String world, String player) {
|
public final String[] getPlayerGroups(String world, String player) {
|
||||||
return this.permissionApi.getPlayerGroups(world, player);
|
return this.permissionApi.getPlayerGroups(world, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getPlayerGroups(World world, String player) {
|
public final String[] getPlayerGroups(World world, String player) {
|
||||||
return this.permissionApi.getPlayerGroups(world, player);
|
return this.permissionApi.getPlayerGroups(world, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getPlayerGroups(Player player) {
|
public final String[] getPlayerGroups(Player player) {
|
||||||
return this.permissionApi.getPlayerGroups(player);
|
return this.permissionApi.getPlayerGroups(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrimaryGroup(String world, OfflinePlayer player) {
|
public final String getPrimaryGroup(String world, OfflinePlayer player) {
|
||||||
return this.permissionApi.getPrimaryGroup(world, player);
|
return this.permissionApi.getPrimaryGroup(world, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrimaryGroup(String world, String player) {
|
public final String getPrimaryGroup(String world, String player) {
|
||||||
return this.permissionApi.getPrimaryGroup(world, player);
|
return this.permissionApi.getPrimaryGroup(world, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrimaryGroup(World world, String player) {
|
public final String getPrimaryGroup(World world, String player) {
|
||||||
return this.permissionApi.getPrimaryGroup(world, player);
|
return this.permissionApi.getPrimaryGroup(world, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrimaryGroup(Player player) {
|
public final String getPrimaryGroup(Player player) {
|
||||||
return this.permissionApi.getPrimaryGroup(player);
|
return this.permissionApi.getPrimaryGroup(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getGroups() {
|
public final String[] getGroups() {
|
||||||
return this.permissionApi.getGroups();
|
return this.permissionApi.getGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ package me.lucko.luckperms.bukkit.vault;
|
|||||||
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -64,24 +63,25 @@ public abstract class AbstractVaultPermission extends Permission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnabled() {
|
public final boolean isEnabled() {
|
||||||
// always return true
|
// always return true
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSuperPermsCompat() {
|
public final boolean hasSuperPermsCompat() {
|
||||||
// always return true
|
// always return true
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasGroupSupport() {
|
public final boolean hasGroupSupport() {
|
||||||
// always return true
|
// always return true
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// methods subclasses are expected to implement
|
// methods subclasses are expected to implement
|
||||||
|
public abstract UUID lookupUuid(String player);
|
||||||
public abstract boolean userHasPermission(String world, UUID uuid, String permission);
|
public abstract boolean userHasPermission(String world, UUID uuid, String permission);
|
||||||
public abstract boolean userAddPermission(String world, UUID uuid, String permission);
|
public abstract boolean userAddPermission(String world, UUID uuid, String permission);
|
||||||
public abstract boolean userRemovePermission(String world, UUID uuid, String permission);
|
public abstract boolean userRemovePermission(String world, UUID uuid, String permission);
|
||||||
@ -94,22 +94,6 @@ public abstract class AbstractVaultPermission extends Permission {
|
|||||||
public abstract boolean groupAddPermission(String world, String name, String permission);
|
public abstract boolean groupAddPermission(String world, String name, String permission);
|
||||||
public abstract boolean groupRemovePermission(String world, String name, String permission);
|
public abstract boolean groupRemovePermission(String world, String name, String permission);
|
||||||
|
|
||||||
// utility methods for upgrading legacy requests
|
|
||||||
|
|
||||||
private static UUID player(String player) {
|
|
||||||
if (player == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return player(Bukkit.getPlayerExact(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static UUID player(OfflinePlayer player) {
|
|
||||||
if (player == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return player.getUniqueId();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String world(String world) {
|
private String world(String world) {
|
||||||
return this.worldMappingFunction.apply(world);
|
return this.worldMappingFunction.apply(world);
|
||||||
}
|
}
|
||||||
@ -129,281 +113,281 @@ public abstract class AbstractVaultPermission extends Permission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean has(String world, String player, String permission) {
|
public final boolean has(String world, String player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userHasPermission(world(world), player(player), permission);
|
return userHasPermission(world(world), lookupUuid(player), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean has(World world, String player, String permission) {
|
public final boolean has(World world, String player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userHasPermission(world(world), player(player), permission);
|
return userHasPermission(world(world), lookupUuid(player), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean has(Player player, String permission) {
|
public final boolean has(Player player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userHasPermission(world(player), player(player), permission);
|
return player.hasPermission(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerHas(String world, String player, String permission) {
|
public final boolean playerHas(String world, String player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userHasPermission(world(world), player(player), permission);
|
return userHasPermission(world(world), lookupUuid(player), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerHas(World world, String player, String permission) {
|
public final boolean playerHas(World world, String player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userHasPermission(world(world), player(player), permission);
|
return userHasPermission(world(world), lookupUuid(player), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerHas(String world, OfflinePlayer player, String permission) {
|
public final boolean playerHas(String world, OfflinePlayer player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userHasPermission(world(world), player(player), permission);
|
return userHasPermission(world(world), player.getUniqueId(), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerHas(Player player, String permission) {
|
public final boolean playerHas(Player player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userHasPermission(world(player), player(player), permission);
|
return player.hasPermission(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerAdd(String world, String player, String permission) {
|
public final boolean playerAdd(String world, String player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userAddPermission(world(world), player(player), permission);
|
return userAddPermission(world(world), lookupUuid(player), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerAdd(World world, String player, String permission) {
|
public final boolean playerAdd(World world, String player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userAddPermission(world(world), player(player), permission);
|
return userAddPermission(world(world), lookupUuid(player), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerAdd(String world, OfflinePlayer player, String permission) {
|
public final boolean playerAdd(String world, OfflinePlayer player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userAddPermission(world(world), player(player), permission);
|
return userAddPermission(world(world), player.getUniqueId(), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerAdd(Player player, String permission) {
|
public final boolean playerAdd(Player player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userAddPermission(world(player), player(player), permission);
|
return userAddPermission(world(player), ((OfflinePlayer) player).getUniqueId(), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerRemove(String world, String player, String permission) {
|
public final boolean playerRemove(String world, String player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userRemovePermission(world(world), player(player), permission);
|
return userRemovePermission(world(world), lookupUuid(player), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerRemove(String world, OfflinePlayer player, String permission) {
|
public final boolean playerRemove(String world, OfflinePlayer player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userRemovePermission(world(world), player(player), permission);
|
return userRemovePermission(world(world), player.getUniqueId(), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerRemove(World world, String player, String permission) {
|
public final boolean playerRemove(World world, String player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userRemovePermission(world(world), player(player), permission);
|
return userRemovePermission(world(world), lookupUuid(player), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerRemove(Player player, String permission) {
|
public final boolean playerRemove(Player player, String permission) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return userRemovePermission(world(player), player(player), permission);
|
return userRemovePermission(world(player), ((OfflinePlayer) player).getUniqueId(), permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean groupHas(String world, String group, String permission) {
|
public final boolean groupHas(String world, String group, String permission) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return groupHasPermission(world(world), group, permission);
|
return groupHasPermission(world(world), group, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean groupHas(World world, String group, String permission) {
|
public final boolean groupHas(World world, String group, String permission) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return groupHasPermission(world(world), group, permission);
|
return groupHasPermission(world(world), group, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean groupAdd(String world, String group, String permission) {
|
public final boolean groupAdd(String world, String group, String permission) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return groupAddPermission(world(world), group, permission);
|
return groupAddPermission(world(world), group, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean groupAdd(World world, String group, String permission) {
|
public final boolean groupAdd(World world, String group, String permission) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return groupAddPermission(world(world), group, permission);
|
return groupAddPermission(world(world), group, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean groupRemove(String world, String group, String permission) {
|
public final boolean groupRemove(String world, String group, String permission) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return groupRemovePermission(world(world), group, permission);
|
return groupRemovePermission(world(world), group, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean groupRemove(World world, String group, String permission) {
|
public final boolean groupRemove(World world, String group, String permission) {
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
return groupRemovePermission(world(world), group, permission);
|
return groupRemovePermission(world(world), group, permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerInGroup(String world, String player, String group) {
|
public final boolean playerInGroup(String world, String player, String group) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return userInGroup(world(world), player(player), group);
|
return userInGroup(world(world), lookupUuid(player), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerInGroup(World world, String player, String group) {
|
public final boolean playerInGroup(World world, String player, String group) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return userInGroup(world(world), player(player), group);
|
return userInGroup(world(world), lookupUuid(player), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerInGroup(String world, OfflinePlayer player, String group) {
|
public final boolean playerInGroup(String world, OfflinePlayer player, String group) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return userInGroup(world(world), player(player), group);
|
return userInGroup(world(world), player.getUniqueId(), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerInGroup(Player player, String group) {
|
public final boolean playerInGroup(Player player, String group) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return userInGroup(world(player), player(player), group);
|
return userInGroup(world(player), ((OfflinePlayer) player).getUniqueId(), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerAddGroup(String world, String player, String group) {
|
public final boolean playerAddGroup(String world, String player, String group) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return userAddGroup(world(world), player(player), group);
|
return userAddGroup(world(world), lookupUuid(player), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerAddGroup(World world, String player, String group) {
|
public final boolean playerAddGroup(World world, String player, String group) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return userAddGroup(world(world), player(player), group);
|
return userAddGroup(world(world), lookupUuid(player), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerAddGroup(String world, OfflinePlayer player, String group) {
|
public final boolean playerAddGroup(String world, OfflinePlayer player, String group) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return userAddGroup(world(world), player(player), group);
|
return userAddGroup(world(world), player.getUniqueId(), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerAddGroup(Player player, String group) {
|
public final boolean playerAddGroup(Player player, String group) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return userAddGroup(world(player), player(player), group);
|
return userAddGroup(world(player), ((OfflinePlayer) player).getUniqueId(), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerRemoveGroup(String world, String player, String group) {
|
public final boolean playerRemoveGroup(String world, String player, String group) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return userRemoveGroup(world(world), player(player), group);
|
return userRemoveGroup(world(world), lookupUuid(player), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerRemoveGroup(World world, String player, String group) {
|
public final boolean playerRemoveGroup(World world, String player, String group) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return userRemoveGroup(world(world), player(player), group);
|
return userRemoveGroup(world(world), lookupUuid(player), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerRemoveGroup(String world, OfflinePlayer player, String group) {
|
public final boolean playerRemoveGroup(String world, OfflinePlayer player, String group) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return userRemoveGroup(world(world), player(player), group);
|
return userRemoveGroup(world(world), player.getUniqueId(), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerRemoveGroup(Player player, String group) {
|
public final boolean playerRemoveGroup(Player player, String group) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return userRemoveGroup(world(player), player(player), group);
|
return userRemoveGroup(world(player), ((OfflinePlayer) player).getUniqueId(), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getPlayerGroups(String world, String player) {
|
public final String[] getPlayerGroups(String world, String player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return userGetGroups(world(world), player(player));
|
return userGetGroups(world(world), lookupUuid(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getPlayerGroups(World world, String player) {
|
public final String[] getPlayerGroups(World world, String player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return userGetGroups(world(world), player(player));
|
return userGetGroups(world(world), lookupUuid(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getPlayerGroups(String world, OfflinePlayer player) {
|
public final String[] getPlayerGroups(String world, OfflinePlayer player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return userGetGroups(world(world), player(player));
|
return userGetGroups(world(world), player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getPlayerGroups(Player player) {
|
public final String[] getPlayerGroups(Player player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return userGetGroups(world(player), player(player));
|
return userGetGroups(world(player), ((OfflinePlayer) player).getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrimaryGroup(String world, String player) {
|
public final String getPrimaryGroup(String world, String player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return userGetPrimaryGroup(world(world), player(player));
|
return userGetPrimaryGroup(world(world), lookupUuid(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrimaryGroup(World world, String player) {
|
public final String getPrimaryGroup(World world, String player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return userGetPrimaryGroup(world(world), player(player));
|
return userGetPrimaryGroup(world(world), lookupUuid(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrimaryGroup(String world, OfflinePlayer player) {
|
public final String getPrimaryGroup(String world, OfflinePlayer player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return userGetPrimaryGroup(world(world), player(player));
|
return userGetPrimaryGroup(world(world), player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrimaryGroup(Player player) {
|
public final String getPrimaryGroup(Player player) {
|
||||||
Objects.requireNonNull(player, "player");
|
Objects.requireNonNull(player, "player");
|
||||||
return userGetPrimaryGroup(world(player), player(player));
|
return userGetPrimaryGroup(world(player), ((OfflinePlayer) player).getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,13 +56,10 @@ import java.util.UUID;
|
|||||||
* time to execute. (database queries, re-population of caches, etc) In these cases, the
|
* time to execute. (database queries, re-population of caches, etc) In these cases, the
|
||||||
* methods will return immediately and the change will be executed asynchronously.
|
* methods will return immediately and the change will be executed asynchronously.
|
||||||
*
|
*
|
||||||
* Users of the Vault API expect these methods to be "main thread friendly", so unfortunately,
|
* Methods that have to query data from the database will throw exceptions when called
|
||||||
* we have to favour so called "performance" for consistency. The Vault API really wasn't designed
|
* from the main thread. Users of the Vault API expect these methods to be "main thread friendly",
|
||||||
* with database backed permission plugins in mind. :(
|
* which they simply cannot be, as LP utilises databases for data storage. Server admins
|
||||||
*
|
* willing to take the risk of lagging their server can disable these exceptions in the config file.
|
||||||
* The methods which query offline players will explicitly FAIL if the corresponding player is not online.
|
|
||||||
* We cannot risk blocking the main thread to load in their data. Again, this is due to crap Vault
|
|
||||||
* design. There is nothing I can do about it.
|
|
||||||
*/
|
*/
|
||||||
public class VaultChatHook extends AbstractVaultChat {
|
public class VaultChatHook extends AbstractVaultChat {
|
||||||
|
|
||||||
@ -86,13 +83,9 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUserChatPrefix(String world, UUID uuid) {
|
public String getUserChatPrefix(String world, UUID uuid) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return null;
|
|
||||||
}
|
User user = this.permissionHook.lookupUser(uuid);
|
||||||
User user = getUser(uuid);
|
|
||||||
if (user == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
||||||
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getPrefix();
|
String ret = metaData.getPrefix();
|
||||||
@ -104,13 +97,9 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUserChatSuffix(String world, UUID uuid) {
|
public String getUserChatSuffix(String world, UUID uuid) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return null;
|
|
||||||
}
|
User user = this.permissionHook.lookupUser(uuid);
|
||||||
User user = getUser(uuid);
|
|
||||||
if (user == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
||||||
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getSuffix();
|
String ret = metaData.getSuffix();
|
||||||
@ -122,38 +111,26 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUserChatPrefix(String world, UUID uuid, String prefix) {
|
public void setUserChatPrefix(String world, UUID uuid, String prefix) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return;
|
|
||||||
}
|
User user = this.permissionHook.lookupUser(uuid);
|
||||||
User user = getUser(uuid);
|
|
||||||
if (user == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setChatMeta(user, ChatMetaType.PREFIX, prefix, world);
|
setChatMeta(user, ChatMetaType.PREFIX, prefix, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUserChatSuffix(String world, UUID uuid, String suffix) {
|
public void setUserChatSuffix(String world, UUID uuid, String suffix) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return;
|
|
||||||
}
|
User user = this.permissionHook.lookupUser(uuid);
|
||||||
User user = getUser(uuid);
|
|
||||||
if (user == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setChatMeta(user, ChatMetaType.SUFFIX, suffix, world);
|
setChatMeta(user, ChatMetaType.SUFFIX, suffix, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUserMeta(String world, UUID uuid, String key) {
|
public String getUserMeta(String world, UUID uuid, String key) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Objects.requireNonNull(key, "key");
|
Objects.requireNonNull(key, "key");
|
||||||
User user = getUser(uuid);
|
|
||||||
if (user == null) {
|
User user = this.permissionHook.lookupUser(uuid);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
Contexts contexts = this.permissionHook.contextForLookup(user, world);
|
||||||
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
MetaCache metaData = user.getCachedData().getMetaData(contexts);
|
||||||
String ret = metaData.getMeta().get(key);
|
String ret = metaData.getMeta().get(key);
|
||||||
@ -165,14 +142,10 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUserMeta(String world, UUID uuid, String key, Object value) {
|
public void setUserMeta(String world, UUID uuid, String key, Object value) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return;
|
|
||||||
}
|
|
||||||
Objects.requireNonNull(key, "key");
|
Objects.requireNonNull(key, "key");
|
||||||
User user = getUser(uuid);
|
|
||||||
if (user == null) {
|
User user = this.permissionHook.lookupUser(uuid);
|
||||||
return;
|
|
||||||
}
|
|
||||||
setMeta(user, key, value, world);
|
setMeta(user, key, value, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,10 +231,6 @@ public class VaultChatHook extends AbstractVaultChat {
|
|||||||
|
|
||||||
// utility methods for getting user and group instances
|
// utility methods for getting user and group instances
|
||||||
|
|
||||||
private User getUser(UUID uuid) {
|
|
||||||
return this.plugin.getUserManager().getIfLoaded(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Group getGroup(String name) {
|
private Group getGroup(String name) {
|
||||||
return this.plugin.getGroupManager().getByDisplayName(name);
|
return this.plugin.getGroupManager().getByDisplayName(name);
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ import me.lucko.luckperms.common.verbose.CheckOrigin;
|
|||||||
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -62,13 +63,10 @@ import java.util.concurrent.Executors;
|
|||||||
* time to execute. (database queries, re-population of caches, etc) In these cases, the
|
* time to execute. (database queries, re-population of caches, etc) In these cases, the
|
||||||
* methods will return immediately and the change will be executed asynchronously.
|
* methods will return immediately and the change will be executed asynchronously.
|
||||||
*
|
*
|
||||||
* Users of the Vault API expect these methods to be "main thread friendly", so unfortunately,
|
* Methods that have to query data from the database will throw exceptions when called
|
||||||
* we have to favour so called "performance" for consistency. The Vault API really wasn't designed
|
* from the main thread. Users of the Vault API expect these methods to be "main thread friendly",
|
||||||
* with database backed permission plugins in mind. :(
|
* which they simply cannot be, as LP utilises databases for data storage. Server admins
|
||||||
*
|
* willing to take the risk of lagging their server can disable these exceptions in the config file.
|
||||||
* The methods which query offline players will explicitly FAIL if the corresponding player is not online.
|
|
||||||
* We cannot risk blocking the main thread to load in their data. Again, this is due to crap Vault
|
|
||||||
* design. There is nothing I can do about it.
|
|
||||||
*/
|
*/
|
||||||
public class VaultPermissionHook extends AbstractVaultPermission {
|
public class VaultPermissionHook extends AbstractVaultPermission {
|
||||||
|
|
||||||
@ -97,16 +95,66 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
return "LuckPerms";
|
return "LuckPerms";
|
||||||
}
|
}
|
||||||
|
|
||||||
// override this check to delegate to Player#hasPermission
|
|
||||||
@Override
|
@Override
|
||||||
public boolean has(Player player, String permission) {
|
public UUID lookupUuid(String player) {
|
||||||
return player.hasPermission(permission);
|
Objects.requireNonNull(player, "player");
|
||||||
|
|
||||||
|
// are they online?
|
||||||
|
Player onlinePlayer = Bukkit.getPlayerExact(player);
|
||||||
|
if (onlinePlayer != null) {
|
||||||
|
return onlinePlayer.getUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
// are we on the main thread?
|
||||||
|
if (Bukkit.isPrimaryThread() && !this.plugin.getConfiguration().get(ConfigKeys.VAULT_UNSAFE_LOOKUPS)) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Unable to lookup a UUID for '" + player + "'. \n" +
|
||||||
|
"This request was made on the main server thread. \n" +
|
||||||
|
"It is not safe to execute a request to load username data from the database in this context. \n" +
|
||||||
|
"If you are a plugin author, please either make your request asynchronously, \n" +
|
||||||
|
"or provide an 'OfflinePlayer' object with the UUID already populated. \n" +
|
||||||
|
"Server admins can disable this catch by setting 'vault-unsafe-lookups' to true in the LP config, \n" +
|
||||||
|
"but should consider the consequences (lag) before doing so."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// lookup a username from the database
|
||||||
|
UUID uuid = plugin.getStorage().getPlayerUuid(player.toLowerCase()).join();
|
||||||
|
if (uuid == null) {
|
||||||
|
uuid = plugin.getBootstrap().lookupUuid(player).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// unable to find a user, throw an exception
|
||||||
|
if (uuid == null) {
|
||||||
|
throw new IllegalArgumentException("Unable to find a UUID for player '" + player + "'.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// override this check to delegate to Player#hasPermission
|
public User lookupUser(UUID uuid) {
|
||||||
@Override
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
public boolean playerHas(Player player, String permission) {
|
|
||||||
return player.hasPermission(permission);
|
// loaded already?
|
||||||
|
User user = this.plugin.getUserManager().getIfLoaded(uuid);
|
||||||
|
if (user != null) {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// are we on the main thread?
|
||||||
|
if (Bukkit.isPrimaryThread() && !this.plugin.getConfiguration().get(ConfigKeys.VAULT_UNSAFE_LOOKUPS)) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Unable to obtain user data for '" + uuid + "'. \n" +
|
||||||
|
"This request was made on the main server thread. \n" +
|
||||||
|
"It is not safe to execute a request to load user data from the database in this context. \n" +
|
||||||
|
"If you are a plugin author, please consider making your request asynchronously. \n" +
|
||||||
|
"Server admins can disable this catch by setting 'vault-unsafe-lookups' to true in the LP config, \n" +
|
||||||
|
"but should consider the consequences (lag) before doing so."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// load an instance from the DB
|
||||||
|
return this.plugin.getStorage().loadUser(uuid, null).join();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -118,16 +166,10 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean userHasPermission(String world, UUID uuid, String permission) {
|
public boolean userHasPermission(String world, UUID uuid, String permission) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
|
|
||||||
User user = getUser(uuid);
|
User user = lookupUser(uuid);
|
||||||
if (user == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Contexts contexts = contextForLookup(user, world);
|
Contexts contexts = contextForLookup(user, world);
|
||||||
PermissionCache permissionData = user.getCachedData().getPermissionData(contexts);
|
PermissionCache permissionData = user.getCachedData().getPermissionData(contexts);
|
||||||
|
|
||||||
@ -140,74 +182,50 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean userAddPermission(String world, UUID uuid, String permission) {
|
public boolean userAddPermission(String world, UUID uuid, String permission) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
|
|
||||||
User user = getUser(uuid);
|
User user = lookupUser(uuid);
|
||||||
if (user == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
holderAddPermission(user, permission, world);
|
holderAddPermission(user, permission, world);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean userRemovePermission(String world, UUID uuid, String permission) {
|
public boolean userRemovePermission(String world, UUID uuid, String permission) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Objects.requireNonNull(permission, "permission");
|
Objects.requireNonNull(permission, "permission");
|
||||||
|
|
||||||
User user = getUser(uuid);
|
User user = lookupUser(uuid);
|
||||||
if (user == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
holderRemovePermission(user, permission, world);
|
holderRemovePermission(user, permission, world);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean userInGroup(String world, UUID uuid, String group) {
|
public boolean userInGroup(String world, UUID uuid, String group) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return userHasPermission(world, uuid, NodeFactory.groupNode(rewriteGroupName(group)));
|
return userHasPermission(world, uuid, NodeFactory.groupNode(rewriteGroupName(group)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean userAddGroup(String world, UUID uuid, String group) {
|
public boolean userAddGroup(String world, UUID uuid, String group) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return checkGroupExists(group) && userAddPermission(world, uuid, NodeFactory.groupNode(rewriteGroupName(group)));
|
return checkGroupExists(group) && userAddPermission(world, uuid, NodeFactory.groupNode(rewriteGroupName(group)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean userRemoveGroup(String world, UUID uuid, String group) {
|
public boolean userRemoveGroup(String world, UUID uuid, String group) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Objects.requireNonNull(group, "group");
|
Objects.requireNonNull(group, "group");
|
||||||
return checkGroupExists(group) && userRemovePermission(world, uuid, NodeFactory.groupNode(rewriteGroupName(group)));
|
return checkGroupExists(group) && userRemovePermission(world, uuid, NodeFactory.groupNode(rewriteGroupName(group)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] userGetGroups(String world, UUID uuid) {
|
public String[] userGetGroups(String world, UUID uuid) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
User user = getUser(uuid);
|
|
||||||
if (user == null) {
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
User user = lookupUser(uuid);
|
||||||
ContextSet contexts = contextForLookup(user, world).getContexts();
|
ContextSet contexts = contextForLookup(user, world).getContexts();
|
||||||
|
|
||||||
String[] ret = user.enduringData().immutable().values().stream()
|
String[] ret = user.enduringData().immutable().values().stream()
|
||||||
@ -231,15 +249,9 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String userGetPrimaryGroup(String world, UUID uuid) {
|
public String userGetPrimaryGroup(String world, UUID uuid) {
|
||||||
if (uuid == null) {
|
Objects.requireNonNull(uuid, "uuid");
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
User user = getUser(uuid);
|
|
||||||
if (user == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
User user = lookupUser(uuid);
|
||||||
String value = user.getPrimaryGroup().getValue();
|
String value = user.getPrimaryGroup().getValue();
|
||||||
Group group = getGroup(value);
|
Group group = getGroup(value);
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
@ -303,10 +315,6 @@ public class VaultPermissionHook extends AbstractVaultPermission {
|
|||||||
|
|
||||||
// utility methods for getting user and group instances
|
// utility methods for getting user and group instances
|
||||||
|
|
||||||
private User getUser(UUID uuid) {
|
|
||||||
return this.plugin.getUserManager().getIfLoaded(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Group getGroup(String name) {
|
private Group getGroup(String name) {
|
||||||
return this.plugin.getGroupManager().getByDisplayName(name);
|
return this.plugin.getGroupManager().getByDisplayName(name);
|
||||||
}
|
}
|
||||||
|
@ -480,6 +480,17 @@ commands-allow-op: true
|
|||||||
# | Vault integration settings | #
|
# | Vault integration settings | #
|
||||||
# +----------------------------------------------------------------------------------------------+ #
|
# +----------------------------------------------------------------------------------------------+ #
|
||||||
|
|
||||||
|
# If Vault lookups for offline players on the main server thread should be enabled.
|
||||||
|
#
|
||||||
|
# LuckPerms has a "catch" for plugins attempting to perform unsafe offline player data lookups
|
||||||
|
# from the main server thread. This catch raises an exception (causes an error to occur) when unsafe
|
||||||
|
# lookups are made, instead of allowing the lookup to happen, which would likely cause the server
|
||||||
|
# to lag.
|
||||||
|
#
|
||||||
|
# However, if you're willing to accept the consequences, the catch can be disabled by setting this
|
||||||
|
# option to 'true.
|
||||||
|
vault-unsafe-lookups: false
|
||||||
|
|
||||||
# If the vault-server option below should be used.
|
# If the vault-server option below should be used.
|
||||||
#
|
#
|
||||||
# - When this option is set to false, the server value defined above under "server" is used.
|
# - When this option is set to false, the server value defined above under "server" is used.
|
||||||
|
@ -321,6 +321,11 @@ public final class ConfigKeys {
|
|||||||
*/
|
*/
|
||||||
public static final ConfigKey<Boolean> COMMANDS_ALLOW_OP = EnduringKey.wrap(BooleanKey.of("commands-allow-op", true));
|
public static final ConfigKey<Boolean> COMMANDS_ALLOW_OP = EnduringKey.wrap(BooleanKey.of("commands-allow-op", true));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If Vault lookups for offline players on the main server thread should be enabled
|
||||||
|
*/
|
||||||
|
public static final ConfigKey<Boolean> VAULT_UNSAFE_LOOKUPS = BooleanKey.of("vault-unsafe-lookups", false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the vault server option should be used
|
* If the vault server option should be used
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user