Return a dummy value instead of throwing an exception when an offline player is queried via Vault (#806)

This commit is contained in:
Luck 2018-03-01 10:08:09 +00:00
parent 8f82ef7eb4
commit 7549b3eb9e
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 394 additions and 171 deletions

View File

@ -33,6 +33,7 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.function.Function; import java.util.function.Function;
@ -73,18 +74,18 @@ public abstract class AbstractVaultChat extends Chat {
} }
// methods subclasses are expected to implement // methods subclasses are expected to implement
public abstract String getPlayerPrefix(String world, UUID uuid); public abstract String getUserChatPrefix(String world, UUID uuid);
public abstract String getPlayerSuffix(String world, UUID uuid); public abstract String getUserChatSuffix(String world, UUID uuid);
public abstract void setPlayerPrefix(String world, UUID uuid, String prefix); public abstract void setUserChatPrefix(String world, UUID uuid, String prefix);
public abstract void setPlayerSuffix(String world, UUID uuid, String suffix); public abstract void setUserChatSuffix(String world, UUID uuid, String suffix);
public abstract String getPlayerInfo(String world, UUID uuid, String key); public abstract String getUserMeta(String world, UUID uuid, String key);
public abstract void setPlayerInfo(String world, UUID uuid, String key, Object value); public abstract void setUserMeta(String world, UUID uuid, String key, Object value);
public abstract String getGroupsPrefix(String world, String name); // note "groups" not "group" public abstract String getGroupChatPrefix(String world, String name);
public abstract String getGroupsSuffix(String world, String name); // note "groups" not "group" public abstract String getGroupChatSuffix(String world, String name);
public abstract void setGroupsPrefix(String world, String name, String prefix); // note "groups" not "group" public abstract void setGroupChatPrefix(String world, String name, String prefix);
public abstract void setGroupsSuffix(String world, String name, String suffix); // note "groups" not "group" public abstract void setGroupChatSuffix(String world, String name, String suffix);
public abstract String getGroupInfo(String world, String name, String key); public abstract String getGroupMeta(String world, String name, String key);
public abstract void setGroupInfo(String world, String name, String key, Object value); public abstract void setGroupMeta(String world, String name, String key, Object value);
// utility methods for parsing metadata values from strings // utility methods for parsing metadata values from strings
@ -165,362 +166,482 @@ public abstract class AbstractVaultChat extends Chat {
@Override @Override
public String getPlayerPrefix(String world, String player) { public String getPlayerPrefix(String world, String player) {
return getPlayerPrefix(world(world), player(player)); Objects.requireNonNull(player, "player");
return getUserChatPrefix(world(world), player(player));
} }
@Override @Override
public String getPlayerPrefix(String world, OfflinePlayer player) { public String getPlayerPrefix(String world, OfflinePlayer player) {
return getPlayerPrefix(world(world), player(player)); Objects.requireNonNull(player, "player");
return getUserChatPrefix(world(world), player(player));
} }
@Override @Override
public String getPlayerPrefix(World world, String player) { public String getPlayerPrefix(World world, String player) {
return getPlayerPrefix(world(world), player(player)); Objects.requireNonNull(player, "player");
return getUserChatPrefix(world(world), player(player));
} }
@Override @Override
public String getPlayerPrefix(Player player) { public String getPlayerPrefix(Player player) {
return getPlayerPrefix(world(player), player(player)); Objects.requireNonNull(player, "player");
return getUserChatPrefix(world(player), player(player));
} }
@Override @Override
public void setPlayerPrefix(String world, String player, String prefix) { public void setPlayerPrefix(String world, String player, String prefix) {
setPlayerPrefix(world(world), player(player), prefix); Objects.requireNonNull(player, "player");
setUserChatPrefix(world(world), player(player), prefix);
} }
@Override @Override
public void setPlayerPrefix(String world, OfflinePlayer player, String prefix) { public void setPlayerPrefix(String world, OfflinePlayer player, String prefix) {
setPlayerPrefix(world(world), player(player), prefix); Objects.requireNonNull(player, "player");
setUserChatPrefix(world(world), player(player), prefix);
} }
@Override @Override
public void setPlayerPrefix(World world, String player, String prefix) { public void setPlayerPrefix(World world, String player, String prefix) {
setPlayerPrefix(world(world), player(player), prefix); Objects.requireNonNull(player, "player");
setUserChatPrefix(world(world), player(player), prefix);
} }
@Override @Override
public void setPlayerPrefix(Player player, String prefix) { public void setPlayerPrefix(Player player, String prefix) {
setPlayerPrefix(world(player), player(player), prefix); Objects.requireNonNull(player, "player");
setUserChatPrefix(world(player), player(player), prefix);
} }
@Override @Override
public String getPlayerSuffix(String world, String player) { public String getPlayerSuffix(String world, String player) {
return getPlayerSuffix(world(world), player(player)); Objects.requireNonNull(player, "player");
return getUserChatSuffix(world(world), player(player));
} }
@Override @Override
public String getPlayerSuffix(String world, OfflinePlayer player) { public String getPlayerSuffix(String world, OfflinePlayer player) {
return getPlayerSuffix(world(world), player(player)); Objects.requireNonNull(player, "player");
return getUserChatSuffix(world(world), player(player));
} }
@Override @Override
public String getPlayerSuffix(World world, String player) { public String getPlayerSuffix(World world, String player) {
return getPlayerSuffix(world(world), player(player)); Objects.requireNonNull(player, "player");
return getUserChatSuffix(world(world), player(player));
} }
@Override @Override
public String getPlayerSuffix(Player player) { public String getPlayerSuffix(Player player) {
return getPlayerSuffix(world(player), player(player)); Objects.requireNonNull(player, "player");
return getUserChatSuffix(world(player), player(player));
} }
@Override @Override
public void setPlayerSuffix(String world, String player, String suffix) { public void setPlayerSuffix(String world, String player, String suffix) {
setPlayerSuffix(world(world), player(player), suffix); Objects.requireNonNull(player, "player");
setUserChatSuffix(world(world), player(player), suffix);
} }
@Override @Override
public void setPlayerSuffix(String world, OfflinePlayer player, String suffix) { public void setPlayerSuffix(String world, OfflinePlayer player, String suffix) {
setPlayerSuffix(world(world), player(player), suffix); Objects.requireNonNull(player, "player");
setUserChatSuffix(world(world), player(player), suffix);
} }
@Override @Override
public void setPlayerSuffix(World world, String player, String suffix) { public void setPlayerSuffix(World world, String player, String suffix) {
setPlayerSuffix(world(world), player(player), suffix); Objects.requireNonNull(player, "player");
setUserChatSuffix(world(world), player(player), suffix);
} }
@Override @Override
public void setPlayerSuffix(Player player, String suffix) { public void setPlayerSuffix(Player player, String suffix) {
setPlayerSuffix(world(player), player(player), suffix); Objects.requireNonNull(player, "player");
setUserChatSuffix(world(player), player(player), suffix);
} }
@Override @Override
public String getGroupPrefix(String world, String group) { public String getGroupPrefix(String world, String group) {
return getGroupsPrefix(world(world), group); Objects.requireNonNull(group, "group");
return getGroupChatPrefix(world(world), group);
} }
@Override @Override
public String getGroupPrefix(World world, String group) { public String getGroupPrefix(World world, String group) {
return getGroupsPrefix(world(world), group); Objects.requireNonNull(group, "group");
return getGroupChatPrefix(world(world), group);
} }
@Override @Override
public void setGroupPrefix(String world, String group, String prefix) { public void setGroupPrefix(String world, String group, String prefix) {
setGroupsPrefix(world(world), group, prefix); Objects.requireNonNull(group, "group");
setGroupChatPrefix(world(world), group, prefix);
} }
@Override @Override
public void setGroupPrefix(World world, String group, String prefix) { public void setGroupPrefix(World world, String group, String prefix) {
setGroupsPrefix(world(world), group, prefix); Objects.requireNonNull(group, "group");
setGroupChatPrefix(world(world), group, prefix);
} }
@Override @Override
public String getGroupSuffix(String world, String group) { public String getGroupSuffix(String world, String group) {
return getGroupsSuffix(world(world), group); Objects.requireNonNull(group, "group");
return getGroupChatSuffix(world(world), group);
} }
@Override @Override
public String getGroupSuffix(World world, String group) { public String getGroupSuffix(World world, String group) {
return getGroupsSuffix(world(world), group); Objects.requireNonNull(group, "group");
return getGroupChatSuffix(world(world), group);
} }
@Override @Override
public void setGroupSuffix(String world, String group, String suffix) { public void setGroupSuffix(String world, String group, String suffix) {
setGroupsSuffix(world(world), group, suffix); Objects.requireNonNull(group, "group");
setGroupChatSuffix(world(world), group, suffix);
} }
@Override @Override
public void setGroupSuffix(World world, String group, String suffix) { public void setGroupSuffix(World world, String group, String suffix) {
setGroupsSuffix(world(world), group, suffix); Objects.requireNonNull(group, "group");
setGroupChatSuffix(world(world), group, suffix);
} }
@Override @Override
public int getPlayerInfoInteger(String world, OfflinePlayer player, String node, int defaultValue) { public int getPlayerInfoInteger(String world, OfflinePlayer player, String node, int defaultValue) {
return intConvert(getPlayerInfo(world(world), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return intConvert(getUserMeta(world(world), player(player), node), defaultValue);
} }
@Override @Override
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) { public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
return intConvert(getPlayerInfo(world(world), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return intConvert(getUserMeta(world(world), player(player), node), defaultValue);
} }
@Override @Override
public int getPlayerInfoInteger(World world, String player, String node, int defaultValue) { public int getPlayerInfoInteger(World world, String player, String node, int defaultValue) {
return intConvert(getPlayerInfo(world(world), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return intConvert(getUserMeta(world(world), player(player), node), defaultValue);
} }
@Override @Override
public int getPlayerInfoInteger(Player player, String node, int defaultValue) { public int getPlayerInfoInteger(Player player, String node, int defaultValue) {
return intConvert(getPlayerInfo(world(player), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return intConvert(getUserMeta(world(player), player(player), node), defaultValue);
} }
@Override @Override
public void setPlayerInfoInteger(String world, OfflinePlayer player, String node, int value) { public void setPlayerInfoInteger(String world, OfflinePlayer player, String node, int value) {
setPlayerInfo(world(world), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(world), player(player), node, value);
} }
@Override @Override
public void setPlayerInfoInteger(String world, String player, String node, int value) { public void setPlayerInfoInteger(String world, String player, String node, int value) {
setPlayerInfo(world(world), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(world), player(player), node, value);
} }
@Override @Override
public void setPlayerInfoInteger(World world, String player, String node, int value) { public void setPlayerInfoInteger(World world, String player, String node, int value) {
setPlayerInfo(world(world), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(world), player(player), node, value);
} }
@Override @Override
public void setPlayerInfoInteger(Player player, String node, int value) { public void setPlayerInfoInteger(Player player, String node, int value) {
setPlayerInfo(world(player), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(player), player(player), node, value);
} }
@Override @Override
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) { public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
return intConvert(getGroupInfo(world(world), group, node), defaultValue); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
return intConvert(getGroupMeta(world(world), group, node), defaultValue);
} }
@Override @Override
public int getGroupInfoInteger(World world, String group, String node, int defaultValue) { public int getGroupInfoInteger(World world, String group, String node, int defaultValue) {
return intConvert(getGroupInfo(world(world), group, node), defaultValue); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
return intConvert(getGroupMeta(world(world), group, node), defaultValue);
} }
@Override @Override
public void setGroupInfoInteger(String world, String group, String node, int value) { public void setGroupInfoInteger(String world, String group, String node, int value) {
setGroupInfo(world(world), group, node, value); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
setGroupMeta(world(world), group, node, value);
} }
@Override @Override
public void setGroupInfoInteger(World world, String group, String node, int value) { public void setGroupInfoInteger(World world, String group, String node, int value) {
setGroupInfo(world(world), group, node, value); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
setGroupMeta(world(world), group, node, value);
} }
@Override @Override
public double getPlayerInfoDouble(String world, OfflinePlayer player, String node, double defaultValue) { public double getPlayerInfoDouble(String world, OfflinePlayer player, String node, double defaultValue) {
return doubleConvert(getPlayerInfo(world(world), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return doubleConvert(getUserMeta(world(world), player(player), node), defaultValue);
} }
@Override @Override
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) { public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
return doubleConvert(getPlayerInfo(world(world), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return doubleConvert(getUserMeta(world(world), player(player), node), defaultValue);
} }
@Override @Override
public double getPlayerInfoDouble(World world, String player, String node, double defaultValue) { public double getPlayerInfoDouble(World world, String player, String node, double defaultValue) {
return doubleConvert(getPlayerInfo(world(world), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return doubleConvert(getUserMeta(world(world), player(player), node), defaultValue);
} }
@Override @Override
public double getPlayerInfoDouble(Player player, String node, double defaultValue) { public double getPlayerInfoDouble(Player player, String node, double defaultValue) {
return doubleConvert(getPlayerInfo(world(player), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return doubleConvert(getUserMeta(world(player), player(player), node), defaultValue);
} }
@Override @Override
public void setPlayerInfoDouble(String world, OfflinePlayer player, String node, double value) { public void setPlayerInfoDouble(String world, OfflinePlayer player, String node, double value) {
setPlayerInfo(world(world), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(world), player(player), node, value);
} }
@Override @Override
public void setPlayerInfoDouble(String world, String player, String node, double value) { public void setPlayerInfoDouble(String world, String player, String node, double value) {
setPlayerInfo(world(world), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(world), player(player), node, value);
} }
@Override @Override
public void setPlayerInfoDouble(World world, String player, String node, double value) { public void setPlayerInfoDouble(World world, String player, String node, double value) {
setPlayerInfo(world(world), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(world), player(player), node, value);
} }
@Override @Override
public void setPlayerInfoDouble(Player player, String node, double value) { public void setPlayerInfoDouble(Player player, String node, double value) {
setPlayerInfo(world(player), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(player), player(player), node, value);
} }
@Override @Override
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) { public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
return doubleConvert(getGroupInfo(world(world), group, node), defaultValue); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
return doubleConvert(getGroupMeta(world(world), group, node), defaultValue);
} }
@Override @Override
public double getGroupInfoDouble(World world, String group, String node, double defaultValue) { public double getGroupInfoDouble(World world, String group, String node, double defaultValue) {
return doubleConvert(getGroupInfo(world(world), group, node), defaultValue); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
return doubleConvert(getGroupMeta(world(world), group, node), defaultValue);
} }
@Override @Override
public void setGroupInfoDouble(String world, String group, String node, double value) { public void setGroupInfoDouble(String world, String group, String node, double value) {
setGroupInfo(world(world), group, node, value); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
setGroupMeta(world(world), group, node, value);
} }
@Override @Override
public void setGroupInfoDouble(World world, String group, String node, double value) { public void setGroupInfoDouble(World world, String group, String node, double value) {
setGroupInfo(world(world), group, node, value); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
setGroupMeta(world(world), group, node, value);
} }
@Override @Override
public boolean getPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean defaultValue) { public boolean getPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean defaultValue) {
return booleanConvert(getPlayerInfo(world(world), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return booleanConvert(getUserMeta(world(world), player(player), node), defaultValue);
} }
@Override @Override
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) { public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
return booleanConvert(getPlayerInfo(world(world), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return booleanConvert(getUserMeta(world(world), player(player), node), defaultValue);
} }
@Override @Override
public boolean getPlayerInfoBoolean(World world, String player, String node, boolean defaultValue) { public boolean getPlayerInfoBoolean(World world, String player, String node, boolean defaultValue) {
return booleanConvert(getPlayerInfo(world(world), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return booleanConvert(getUserMeta(world(world), player(player), node), defaultValue);
} }
@Override @Override
public boolean getPlayerInfoBoolean(Player player, String node, boolean defaultValue) { public boolean getPlayerInfoBoolean(Player player, String node, boolean defaultValue) {
return booleanConvert(getPlayerInfo(world(player), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return booleanConvert(getUserMeta(world(player), player(player), node), defaultValue);
} }
@Override @Override
public void setPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean value) { public void setPlayerInfoBoolean(String world, OfflinePlayer player, String node, boolean value) {
setPlayerInfo(world(world), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(world), player(player), node, value);
} }
@Override @Override
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) { public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
setPlayerInfo(world(world), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(world), player(player), node, value);
} }
@Override @Override
public void setPlayerInfoBoolean(World world, String player, String node, boolean value) { public void setPlayerInfoBoolean(World world, String player, String node, boolean value) {
setPlayerInfo(world(world), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(world), player(player), node, value);
} }
@Override @Override
public void setPlayerInfoBoolean(Player player, String node, boolean value) { public void setPlayerInfoBoolean(Player player, String node, boolean value) {
setPlayerInfo(world(player), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(player), player(player), node, value);
} }
@Override @Override
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) { public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
return booleanConvert(getGroupInfo(world(world), group, node), defaultValue); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
return booleanConvert(getGroupMeta(world(world), group, node), defaultValue);
} }
@Override @Override
public boolean getGroupInfoBoolean(World world, String group, String node, boolean defaultValue) { public boolean getGroupInfoBoolean(World world, String group, String node, boolean defaultValue) {
return booleanConvert(getGroupInfo(world(world), group, node), defaultValue); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
return booleanConvert(getGroupMeta(world(world), group, node), defaultValue);
} }
@Override @Override
public void setGroupInfoBoolean(String world, String group, String node, boolean value) { public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
setGroupInfo(world(world), group, node, value); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
setGroupMeta(world(world), group, node, value);
} }
@Override @Override
public void setGroupInfoBoolean(World world, String group, String node, boolean value) { public void setGroupInfoBoolean(World world, String group, String node, boolean value) {
setGroupInfo(world(world), group, node, value); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
setGroupMeta(world(world), group, node, value);
} }
@Override @Override
public String getPlayerInfoString(String world, OfflinePlayer player, String node, String defaultValue) { public String getPlayerInfoString(String world, OfflinePlayer player, String node, String defaultValue) {
return strConvert(getPlayerInfo(world(world), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return strConvert(getUserMeta(world(world), player(player), node), defaultValue);
} }
@Override @Override
public String getPlayerInfoString(String world, String player, String node, String defaultValue) { public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
return strConvert(getPlayerInfo(world(world), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return strConvert(getUserMeta(world(world), player(player), node), defaultValue);
} }
@Override @Override
public String getPlayerInfoString(World world, String player, String node, String defaultValue) { public String getPlayerInfoString(World world, String player, String node, String defaultValue) {
return strConvert(getPlayerInfo(world(world), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return strConvert(getUserMeta(world(world), player(player), node), defaultValue);
} }
@Override @Override
public String getPlayerInfoString(Player player, String node, String defaultValue) { public String getPlayerInfoString(Player player, String node, String defaultValue) {
return strConvert(getPlayerInfo(world(player), player(player), node), defaultValue); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
return strConvert(getUserMeta(world(player), player(player), node), defaultValue);
} }
@Override @Override
public void setPlayerInfoString(String world, OfflinePlayer player, String node, String value) { public void setPlayerInfoString(String world, OfflinePlayer player, String node, String value) {
setPlayerInfo(world(world), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(world), player(player), node, value);
} }
@Override @Override
public void setPlayerInfoString(String world, String player, String node, String value) { public void setPlayerInfoString(String world, String player, String node, String value) {
setPlayerInfo(world(world), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(world), player(player), node, value);
} }
@Override @Override
public void setPlayerInfoString(World world, String player, String node, String value) { public void setPlayerInfoString(World world, String player, String node, String value) {
setPlayerInfo(world(world), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(world), player(player), node, value);
} }
@Override @Override
public void setPlayerInfoString(Player player, String node, String value) { public void setPlayerInfoString(Player player, String node, String value) {
setPlayerInfo(world(player), player(player), node, value); Objects.requireNonNull(player, "player");
Objects.requireNonNull(node, "node");
setUserMeta(world(player), player(player), node, value);
} }
@Override @Override
public String getGroupInfoString(String world, String group, String node, String defaultValue) { public String getGroupInfoString(String world, String group, String node, String defaultValue) {
return strConvert(getGroupInfo(world(world), group, node), defaultValue); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
return strConvert(getGroupMeta(world(world), group, node), defaultValue);
} }
@Override @Override
public String getGroupInfoString(World world, String group, String node, String defaultValue) { public String getGroupInfoString(World world, String group, String node, String defaultValue) {
return strConvert(getGroupInfo(world(world), group, node), defaultValue); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
return strConvert(getGroupMeta(world(world), group, node), defaultValue);
} }
@Override @Override
public void setGroupInfoString(String world, String group, String node, String value) { public void setGroupInfoString(String world, String group, String node, String value) {
setGroupInfo(world(world), group, node, value); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
setGroupMeta(world(world), group, node, value);
} }
@Override @Override
public void setGroupInfoString(World world, String group, String node, String value) { public void setGroupInfoString(World world, String group, String node, String value) {
setGroupInfo(world(world), group, node, value); Objects.requireNonNull(group, "group");
Objects.requireNonNull(node, "node");
setGroupMeta(world(world), group, node, value);
} }
@Override @Override

View File

@ -33,6 +33,7 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.function.Function; import java.util.function.Function;
@ -81,14 +82,14 @@ public abstract class AbstractVaultPermission extends Permission {
} }
// methods subclasses are expected to implement // methods subclasses are expected to implement
public abstract boolean hasPermission(String world, UUID uuid, String permission); public abstract boolean userHasPermission(String world, UUID uuid, String permission);
public abstract boolean playerAddPermission(String world, UUID uuid, String permission); public abstract boolean userAddPermission(String world, UUID uuid, String permission);
public abstract boolean playerRemovePermission(String world, UUID uuid, String permission); public abstract boolean userRemovePermission(String world, UUID uuid, String permission);
public abstract boolean playerInGroup(String world, UUID uuid, String group); public abstract boolean userInGroup(String world, UUID uuid, String group);
public abstract boolean playerAddGroup(String world, UUID uuid, String group); public abstract boolean userAddGroup(String world, UUID uuid, String group);
public abstract boolean playerRemoveGroup(String world, UUID uuid, String group); public abstract boolean userRemoveGroup(String world, UUID uuid, String group);
public abstract String[] playerGetGroups(String world, UUID uuid); public abstract String[] userGetGroups(String world, UUID uuid);
public abstract String playerPrimaryGroup(String world, UUID uuid); public abstract String userGetPrimaryGroup(String world, UUID uuid);
public abstract boolean groupHasPermission(String world, String name, String permission); public abstract boolean groupHasPermission(String world, String name, String 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);
@ -129,207 +130,280 @@ public abstract class AbstractVaultPermission extends Permission {
@Override @Override
public boolean has(String world, String player, String permission) { public boolean has(String world, String player, String permission) {
return hasPermission(world(world), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userHasPermission(world(world), player(player), permission);
} }
@Override @Override
public boolean has(World world, String player, String permission) { public boolean has(World world, String player, String permission) {
return hasPermission(world(world), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userHasPermission(world(world), player(player), permission);
} }
@Override @Override
public boolean has(Player player, String permission) { public boolean has(Player player, String permission) {
return hasPermission(world(player), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userHasPermission(world(player), player(player), permission);
} }
@Override @Override
public boolean playerHas(String world, String player, String permission) { public boolean playerHas(String world, String player, String permission) {
return hasPermission(world(world), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userHasPermission(world(world), player(player), permission);
} }
@Override @Override
public boolean playerHas(World world, String player, String permission) { public boolean playerHas(World world, String player, String permission) {
return hasPermission(world(world), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userHasPermission(world(world), player(player), permission);
} }
@Override @Override
public boolean playerHas(String world, OfflinePlayer player, String permission) { public boolean playerHas(String world, OfflinePlayer player, String permission) {
return hasPermission(world(world), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userHasPermission(world(world), player(player), permission);
} }
@Override @Override
public boolean playerHas(Player player, String permission) { public boolean playerHas(Player player, String permission) {
return hasPermission(world(player), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userHasPermission(world(player), player(player), permission);
} }
@Override @Override
public boolean playerAdd(String world, String player, String permission) { public boolean playerAdd(String world, String player, String permission) {
return playerAddPermission(world(world), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userAddPermission(world(world), player(player), permission);
} }
@Override @Override
public boolean playerAdd(World world, String player, String permission) { public boolean playerAdd(World world, String player, String permission) {
return playerAddPermission(world(world), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userAddPermission(world(world), player(player), permission);
} }
@Override @Override
public boolean playerAdd(String world, OfflinePlayer player, String permission) { public boolean playerAdd(String world, OfflinePlayer player, String permission) {
return playerAddPermission(world(world), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userAddPermission(world(world), player(player), permission);
} }
@Override @Override
public boolean playerAdd(Player player, String permission) { public boolean playerAdd(Player player, String permission) {
return playerAddPermission(world(player), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userAddPermission(world(player), player(player), permission);
} }
@Override @Override
public boolean playerRemove(String world, String player, String permission) { public boolean playerRemove(String world, String player, String permission) {
return playerRemovePermission(world(world), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userRemovePermission(world(world), player(player), permission);
} }
@Override @Override
public boolean playerRemove(String world, OfflinePlayer player, String permission) { public boolean playerRemove(String world, OfflinePlayer player, String permission) {
return playerRemovePermission(world(world), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userRemovePermission(world(world), player(player), permission);
} }
@Override @Override
public boolean playerRemove(World world, String player, String permission) { public boolean playerRemove(World world, String player, String permission) {
return playerRemovePermission(world(world), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userRemovePermission(world(world), player(player), permission);
} }
@Override @Override
public boolean playerRemove(Player player, String permission) { public boolean playerRemove(Player player, String permission) {
return playerRemovePermission(world(player), player(player), permission); Objects.requireNonNull(player, "player");
Objects.requireNonNull(permission, "permission");
return userRemovePermission(world(player), player(player), permission);
} }
@Override @Override
public boolean groupHas(String world, String group, String permission) { public boolean groupHas(String world, String group, String permission) {
Objects.requireNonNull(group, "group");
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 boolean groupHas(World world, String group, String permission) {
Objects.requireNonNull(group, "group");
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 boolean groupAdd(String world, String group, String permission) {
Objects.requireNonNull(group, "group");
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 boolean groupAdd(World world, String group, String permission) {
Objects.requireNonNull(group, "group");
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 boolean groupRemove(String world, String group, String permission) {
Objects.requireNonNull(group, "group");
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 boolean groupRemove(World world, String group, String permission) {
Objects.requireNonNull(group, "group");
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 boolean playerInGroup(String world, String player, String group) {
return playerInGroup(world(world), player(player), group); Objects.requireNonNull(player, "player");
Objects.requireNonNull(group, "group");
return userInGroup(world(world), player(player), group);
} }
@Override @Override
public boolean playerInGroup(World world, String player, String group) { public boolean playerInGroup(World world, String player, String group) {
return playerInGroup(world(world), player(player), group); Objects.requireNonNull(player, "player");
Objects.requireNonNull(group, "group");
return userInGroup(world(world), player(player), group);
} }
@Override @Override
public boolean playerInGroup(String world, OfflinePlayer player, String group) { public boolean playerInGroup(String world, OfflinePlayer player, String group) {
return playerInGroup(world(world), player(player), group); Objects.requireNonNull(player, "player");
Objects.requireNonNull(group, "group");
return userInGroup(world(world), player(player), group);
} }
@Override @Override
public boolean playerInGroup(Player player, String group) { public boolean playerInGroup(Player player, String group) {
return playerInGroup(world(player), player(player), group); Objects.requireNonNull(player, "player");
Objects.requireNonNull(group, "group");
return userInGroup(world(player), player(player), group);
} }
@Override @Override
public boolean playerAddGroup(String world, String player, String group) { public boolean playerAddGroup(String world, String player, String group) {
return playerAddGroup(world(world), player(player), group); Objects.requireNonNull(player, "player");
Objects.requireNonNull(group, "group");
return userAddGroup(world(world), player(player), group);
} }
@Override @Override
public boolean playerAddGroup(World world, String player, String group) { public boolean playerAddGroup(World world, String player, String group) {
return playerAddGroup(world(world), player(player), group); Objects.requireNonNull(player, "player");
Objects.requireNonNull(group, "group");
return userAddGroup(world(world), player(player), group);
} }
@Override @Override
public boolean playerAddGroup(String world, OfflinePlayer player, String group) { public boolean playerAddGroup(String world, OfflinePlayer player, String group) {
return playerAddGroup(world(world), player(player), group); Objects.requireNonNull(player, "player");
Objects.requireNonNull(group, "group");
return userAddGroup(world(world), player(player), group);
} }
@Override @Override
public boolean playerAddGroup(Player player, String group) { public boolean playerAddGroup(Player player, String group) {
return playerAddGroup(world(player), player(player), group); Objects.requireNonNull(player, "player");
Objects.requireNonNull(group, "group");
return userAddGroup(world(player), player(player), group);
} }
@Override @Override
public boolean playerRemoveGroup(String world, String player, String group) { public boolean playerRemoveGroup(String world, String player, String group) {
return playerRemoveGroup(world(world), player(player), group); Objects.requireNonNull(player, "player");
Objects.requireNonNull(group, "group");
return userRemoveGroup(world(world), player(player), group);
} }
@Override @Override
public boolean playerRemoveGroup(World world, String player, String group) { public boolean playerRemoveGroup(World world, String player, String group) {
return playerRemoveGroup(world(world), player(player), group); Objects.requireNonNull(player, "player");
Objects.requireNonNull(group, "group");
return userRemoveGroup(world(world), player(player), group);
} }
@Override @Override
public boolean playerRemoveGroup(String world, OfflinePlayer player, String group) { public boolean playerRemoveGroup(String world, OfflinePlayer player, String group) {
return playerRemoveGroup(world(world), player(player), group); Objects.requireNonNull(player, "player");
Objects.requireNonNull(group, "group");
return userRemoveGroup(world(world), player(player), group);
} }
@Override @Override
public boolean playerRemoveGroup(Player player, String group) { public boolean playerRemoveGroup(Player player, String group) {
return playerRemoveGroup(world(player), player(player), group); Objects.requireNonNull(player, "player");
return userRemoveGroup(world(player), player(player), group);
} }
@Override @Override
public String[] getPlayerGroups(String world, String player) { public String[] getPlayerGroups(String world, String player) {
return playerGetGroups(world(world), player(player)); Objects.requireNonNull(player, "player");
return userGetGroups(world(world), player(player));
} }
@Override @Override
public String[] getPlayerGroups(World world, String player) { public String[] getPlayerGroups(World world, String player) {
return playerGetGroups(world(world), player(player)); Objects.requireNonNull(player, "player");
return userGetGroups(world(world), player(player));
} }
@Override @Override
public String[] getPlayerGroups(String world, OfflinePlayer player) { public String[] getPlayerGroups(String world, OfflinePlayer player) {
return playerGetGroups(world(world), player(player)); Objects.requireNonNull(player, "player");
return userGetGroups(world(world), player(player));
} }
@Override @Override
public String[] getPlayerGroups(Player player) { public String[] getPlayerGroups(Player player) {
return playerGetGroups(world(player), player(player)); Objects.requireNonNull(player, "player");
return userGetGroups(world(player), player(player));
} }
@Override @Override
public String getPrimaryGroup(String world, String player) { public String getPrimaryGroup(String world, String player) {
return playerPrimaryGroup(world(world), player(player)); Objects.requireNonNull(player, "player");
return userGetPrimaryGroup(world(world), player(player));
} }
@Override @Override
public String getPrimaryGroup(World world, String player) { public String getPrimaryGroup(World world, String player) {
return playerPrimaryGroup(world(world), player(player)); Objects.requireNonNull(player, "player");
return userGetPrimaryGroup(world(world), player(player));
} }
@Override @Override
public String getPrimaryGroup(String world, OfflinePlayer player) { public String getPrimaryGroup(String world, OfflinePlayer player) {
return playerPrimaryGroup(world(world), player(player)); Objects.requireNonNull(player, "player");
return userGetPrimaryGroup(world(world), player(player));
} }
@Override @Override
public String getPrimaryGroup(Player player) { public String getPrimaryGroup(Player player) {
return playerPrimaryGroup(world(player), player(player)); Objects.requireNonNull(player, "player");
return userGetPrimaryGroup(world(player), player(player));
} }
} }

View File

@ -84,8 +84,10 @@ public class VaultChatHook extends AbstractVaultChat {
} }
@Override @Override
public String getPlayerPrefix(String world, UUID uuid) { public String getUserChatPrefix(String world, UUID uuid) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return null;
}
User user = getUser(uuid); User user = getUser(uuid);
if (user == null) { if (user == null) {
return null; return null;
@ -94,14 +96,16 @@ public class VaultChatHook extends AbstractVaultChat {
MetaCache metaData = user.getCachedData().getMetaData(contexts); MetaCache metaData = user.getCachedData().getMetaData(contexts);
String ret = metaData.getPrefix(); String ret = metaData.getPrefix();
if (log()) { if (log()) {
logMsg("#getPlayerPrefix: %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), ret); logMsg("#getUserChatPrefix: %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), ret);
} }
return Strings.nullToEmpty(ret); return Strings.nullToEmpty(ret);
} }
@Override @Override
public String getPlayerSuffix(String world, UUID uuid) { public String getUserChatSuffix(String world, UUID uuid) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return null;
}
User user = getUser(uuid); User user = getUser(uuid);
if (user == null) { if (user == null) {
return null; return null;
@ -110,14 +114,16 @@ public class VaultChatHook extends AbstractVaultChat {
MetaCache metaData = user.getCachedData().getMetaData(contexts); MetaCache metaData = user.getCachedData().getMetaData(contexts);
String ret = metaData.getSuffix(); String ret = metaData.getSuffix();
if (log()) { if (log()) {
logMsg("#getPlayerSuffix: %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), ret); logMsg("#getUserChatSuffix: %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), ret);
} }
return Strings.nullToEmpty(ret); return Strings.nullToEmpty(ret);
} }
@Override @Override
public void setPlayerPrefix(String world, UUID uuid, String prefix) { public void setUserChatPrefix(String world, UUID uuid, String prefix) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return;
}
User user = getUser(uuid); User user = getUser(uuid);
if (user == null) { if (user == null) {
return; return;
@ -126,8 +132,10 @@ public class VaultChatHook extends AbstractVaultChat {
} }
@Override @Override
public void setPlayerSuffix(String world, UUID uuid, String suffix) { public void setUserChatSuffix(String world, UUID uuid, String suffix) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return;
}
User user = getUser(uuid); User user = getUser(uuid);
if (user == null) { if (user == null) {
return; return;
@ -136,8 +144,10 @@ public class VaultChatHook extends AbstractVaultChat {
} }
@Override @Override
public String getPlayerInfo(String world, UUID uuid, String key) { public String getUserMeta(String world, UUID uuid, String key) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return null;
}
Objects.requireNonNull(key, "key"); Objects.requireNonNull(key, "key");
User user = getUser(uuid); User user = getUser(uuid);
if (user == null) { if (user == null) {
@ -147,14 +157,16 @@ public class VaultChatHook extends AbstractVaultChat {
MetaCache metaData = user.getCachedData().getMetaData(contexts); MetaCache metaData = user.getCachedData().getMetaData(contexts);
String ret = metaData.getMeta().get(key); String ret = metaData.getMeta().get(key);
if (log()) { if (log()) {
logMsg("#getPlayerInfo: %s - %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), key, ret); logMsg("#getUserMeta: %s - %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), key, ret);
} }
return ret; return ret;
} }
@Override @Override
public void setPlayerInfo(String world, UUID uuid, String key, Object value) { public void setUserMeta(String world, UUID uuid, String key, Object value) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return;
}
Objects.requireNonNull(key, "key"); Objects.requireNonNull(key, "key");
User user = getUser(uuid); User user = getUser(uuid);
if (user == null) { if (user == null) {
@ -164,7 +176,7 @@ public class VaultChatHook extends AbstractVaultChat {
} }
@Override @Override
public String getGroupsPrefix(String world, String name) { public String getGroupChatPrefix(String world, String name) {
Objects.requireNonNull(name, "name"); Objects.requireNonNull(name, "name");
Group group = getGroup(name); Group group = getGroup(name);
if (group == null) { if (group == null) {
@ -180,7 +192,7 @@ public class VaultChatHook extends AbstractVaultChat {
} }
@Override @Override
public String getGroupsSuffix(String world, String name) { public String getGroupChatSuffix(String world, String name) {
Objects.requireNonNull(name, "name"); Objects.requireNonNull(name, "name");
Group group = getGroup(name); Group group = getGroup(name);
if (group == null) { if (group == null) {
@ -196,7 +208,7 @@ public class VaultChatHook extends AbstractVaultChat {
} }
@Override @Override
public void setGroupsPrefix(String world, String name, String prefix) { public void setGroupChatPrefix(String world, String name, String prefix) {
Objects.requireNonNull(name, "name"); Objects.requireNonNull(name, "name");
Group group = getGroup(name); Group group = getGroup(name);
if (group == null) { if (group == null) {
@ -206,7 +218,7 @@ public class VaultChatHook extends AbstractVaultChat {
} }
@Override @Override
public void setGroupsSuffix(String world, String name, String suffix) { public void setGroupChatSuffix(String world, String name, String suffix) {
Objects.requireNonNull(name, "name"); Objects.requireNonNull(name, "name");
Group group = getGroup(name); Group group = getGroup(name);
if (group == null) { if (group == null) {
@ -216,7 +228,7 @@ public class VaultChatHook extends AbstractVaultChat {
} }
@Override @Override
public String getGroupInfo(String world, String name, String key) { public String getGroupMeta(String world, String name, String key) {
Objects.requireNonNull(name, "name"); Objects.requireNonNull(name, "name");
Objects.requireNonNull(key, "key"); Objects.requireNonNull(key, "key");
Group group = getGroup(name); Group group = getGroup(name);
@ -227,13 +239,13 @@ public class VaultChatHook extends AbstractVaultChat {
MetaCache metaData = group.getCachedData().getMetaData(contexts); MetaCache metaData = group.getCachedData().getMetaData(contexts);
String ret = metaData.getMeta().get(key); String ret = metaData.getMeta().get(key);
if (log()) { if (log()) {
logMsg("#getGroupInfo: %s - %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), key, ret); logMsg("#getGroupMeta: %s - %s - %s - %s", group.getName(), contexts.getContexts().toMultimap(), key, ret);
} }
return ret; return ret;
} }
@Override @Override
public void setGroupInfo(String world, String name, String key, Object value) { public void setGroupMeta(String world, String name, String key, Object value) {
Objects.requireNonNull(name, "name"); Objects.requireNonNull(name, "name");
Objects.requireNonNull(key, "key"); Objects.requireNonNull(key, "key");
Group group = getGroup(name); Group group = getGroup(name);

View File

@ -116,8 +116,10 @@ public class VaultPermissionHook extends AbstractVaultPermission {
} }
@Override @Override
public boolean hasPermission(String world, UUID uuid, String permission) { public boolean userHasPermission(String world, UUID uuid, String permission) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return false;
}
Objects.requireNonNull(permission, "permission"); Objects.requireNonNull(permission, "permission");
User user = getUser(uuid); User user = getUser(uuid);
@ -130,14 +132,16 @@ public class VaultPermissionHook extends AbstractVaultPermission {
Tristate result = permissionData.getPermissionValue(permission, CheckOrigin.INTERNAL); Tristate result = permissionData.getPermissionValue(permission, CheckOrigin.INTERNAL);
if (log()) { if (log()) {
logMsg("#hasPermission: %s - %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), permission, result); logMsg("#userHasPermission: %s - %s - %s - %s", user.getFriendlyName(), contexts.getContexts().toMultimap(), permission, result);
} }
return result.asBoolean(); return result.asBoolean();
} }
@Override @Override
public boolean playerAddPermission(String world, UUID uuid, String permission) { public boolean userAddPermission(String world, UUID uuid, String permission) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return false;
}
Objects.requireNonNull(permission, "permission"); Objects.requireNonNull(permission, "permission");
User user = getUser(uuid); User user = getUser(uuid);
@ -150,8 +154,10 @@ public class VaultPermissionHook extends AbstractVaultPermission {
} }
@Override @Override
public boolean playerRemovePermission(String world, UUID uuid, String permission) { public boolean userRemovePermission(String world, UUID uuid, String permission) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return false;
}
Objects.requireNonNull(permission, "permission"); Objects.requireNonNull(permission, "permission");
User user = getUser(uuid); User user = getUser(uuid);
@ -164,29 +170,37 @@ public class VaultPermissionHook extends AbstractVaultPermission {
} }
@Override @Override
public boolean playerInGroup(String world, UUID uuid, String group) { public boolean userInGroup(String world, UUID uuid, String group) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return false;
}
Objects.requireNonNull(group, "group"); Objects.requireNonNull(group, "group");
return hasPermission(world, uuid, NodeFactory.groupNode(rewriteGroupName(group))); return userHasPermission(world, uuid, NodeFactory.groupNode(rewriteGroupName(group)));
} }
@Override @Override
public boolean playerAddGroup(String world, UUID uuid, String group) { public boolean userAddGroup(String world, UUID uuid, String group) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return false;
}
Objects.requireNonNull(group, "group"); Objects.requireNonNull(group, "group");
return checkGroupExists(group) && playerAddPermission(world, uuid, NodeFactory.groupNode(rewriteGroupName(group))); return checkGroupExists(group) && userAddPermission(world, uuid, NodeFactory.groupNode(rewriteGroupName(group)));
} }
@Override @Override
public boolean playerRemoveGroup(String world, UUID uuid, String group) { public boolean userRemoveGroup(String world, UUID uuid, String group) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return false;
}
Objects.requireNonNull(group, "group"); Objects.requireNonNull(group, "group");
return checkGroupExists(group) && playerRemovePermission(world, uuid, NodeFactory.groupNode(rewriteGroupName(group))); return checkGroupExists(group) && userRemovePermission(world, uuid, NodeFactory.groupNode(rewriteGroupName(group)));
} }
@Override @Override
public String[] playerGetGroups(String world, UUID uuid) { public String[] userGetGroups(String world, UUID uuid) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return new String[0];
}
User user = getUser(uuid); User user = getUser(uuid);
if (user == null) { if (user == null) {
@ -208,15 +222,17 @@ public class VaultPermissionHook extends AbstractVaultPermission {
.toArray(String[]::new); .toArray(String[]::new);
if (log()) { if (log()) {
logMsg("#playerGetGroups: %s - %s - %s", user.getFriendlyName(), contexts, Arrays.toString(ret)); logMsg("#userGetGroups: %s - %s - %s", user.getFriendlyName(), contexts, Arrays.toString(ret));
} }
return ret; return ret;
} }
@Override @Override
public String playerPrimaryGroup(String world, UUID uuid) { public String userGetPrimaryGroup(String world, UUID uuid) {
Objects.requireNonNull(uuid, "uuid"); if (uuid == null) {
return null;
}
User user = getUser(uuid); User user = getUser(uuid);
if (user == null) { if (user == null) {
@ -230,7 +246,7 @@ public class VaultPermissionHook extends AbstractVaultPermission {
} }
if (log()) { if (log()) {
logMsg("#playerPrimaryGroup: %s - %s - %s", user.getFriendlyName(), world, value); logMsg("#userGetPrimaryGroup: %s - %s - %s", user.getFriendlyName(), world, value);
} }
return value; return value;