mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-08-06 11:14:08 +00:00
Typo's and formatting
This commit is contained in:
parent
0f67d42c99
commit
0731de53b4
|
@ -58,7 +58,8 @@ public class GlobalGroups {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param haveGroupsChanged the haveGroupsChanged to set
|
||||
* @param haveGroupsChanged
|
||||
* the haveGroupsChanged to set
|
||||
*/
|
||||
public void setGroupsChanged(boolean haveGroupsChanged) {
|
||||
this.haveGroupsChanged = haveGroupsChanged;
|
||||
|
@ -71,14 +72,12 @@ public class GlobalGroups {
|
|||
groups = new HashMap<String, Group>();
|
||||
|
||||
// READ globalGroups FILE
|
||||
File GlobalGroupsFile = new File(plugin.getDataFolder(),
|
||||
"globalgroups.yml");
|
||||
File GlobalGroupsFile = new File(plugin.getDataFolder(), "globalgroups.yml");
|
||||
|
||||
if (!GlobalGroupsFile.exists()) {
|
||||
try {
|
||||
// Create a new file if it doesn't exist.
|
||||
Tasks.copy(plugin.getResourceAsStream("globalgroups.yml"),
|
||||
GlobalGroupsFile);
|
||||
Tasks.copy(plugin.getResourceAsStream("globalgroups.yml"), GlobalGroupsFile);
|
||||
} catch (IOException ex) {
|
||||
GroupManager.logger.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
@ -87,21 +86,17 @@ public class GlobalGroups {
|
|||
try {
|
||||
GGroups.load(GlobalGroupsFile);
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalArgumentException(
|
||||
"The following file couldn't pass on Parser.\n"
|
||||
+ GlobalGroupsFile.getPath(), ex);
|
||||
throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + GlobalGroupsFile.getPath(), ex);
|
||||
}
|
||||
|
||||
// Read all global groups
|
||||
Map<String, Object> allGroups = (Map<String, Object>) GGroups
|
||||
.getConfigurationSection("groups").getValues(false);
|
||||
Map<String, Object> allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false);
|
||||
|
||||
// Load each groups permissions list.
|
||||
if (allGroups != null)
|
||||
for (String groupName : allGroups.keySet()) {
|
||||
Group newGroup = new Group(groupName.toLowerCase());
|
||||
Object permissions = GGroups.get("groups." + groupName
|
||||
+ ".permissions");
|
||||
Object permissions = GGroups.get("groups." + groupName + ".permissions");
|
||||
|
||||
if (permissions instanceof List) {
|
||||
for (String permission : (List<String>) permissions) {
|
||||
|
@ -120,15 +115,12 @@ public class GlobalGroups {
|
|||
}
|
||||
|
||||
/**
|
||||
* Write a dataHolder in a specified file
|
||||
* @param ph
|
||||
* @param groupsFile
|
||||
* Write the globalgroups.yml file
|
||||
*/
|
||||
|
||||
public void writeGroups() {
|
||||
|
||||
File GlobalGroupsFile = new File(plugin.getDataFolder(),
|
||||
"globalgroups.yml");
|
||||
File GlobalGroupsFile = new File(plugin.getDataFolder(), "globalgroups.yml");
|
||||
|
||||
Map<String, Object> root = new HashMap<String, Object>();
|
||||
|
||||
|
@ -186,7 +178,6 @@ public class GlobalGroups {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the Global Group exists in the globalgroups.yml
|
||||
*
|
||||
|
@ -209,8 +200,7 @@ public class GlobalGroups {
|
|||
if (!hasGroup(groupName.toLowerCase()))
|
||||
return false;
|
||||
|
||||
return groups.get(groupName.toLowerCase()).hasSamePermissionNode(
|
||||
permissionNode);
|
||||
return groups.get(groupName.toLowerCase()).hasSamePermissionNode(permissionNode);
|
||||
|
||||
}
|
||||
|
||||
|
@ -222,8 +212,7 @@ public class GlobalGroups {
|
|||
* @param permissionNode
|
||||
* @return
|
||||
*/
|
||||
public PermissionCheckResult checkPermission(String groupName,
|
||||
String permissionNode) {
|
||||
public PermissionCheckResult checkPermission(String groupName, String permissionNode) {
|
||||
|
||||
PermissionCheckResult result = new PermissionCheckResult();
|
||||
result.askedPermission = permissionNode;
|
||||
|
|
|
@ -82,7 +82,8 @@ public class GroupManager extends JavaPlugin {
|
|||
WorldEvents = null;
|
||||
BukkitPermissions = null;
|
||||
|
||||
// EXAMPLE: Custom code, here we just output some info so we can check all is well
|
||||
// EXAMPLE: Custom code, here we just output some info so we can check
|
||||
// all is well
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is disabled!");
|
||||
GroupManager.logger.removeHandler(ch);
|
||||
|
@ -111,15 +112,16 @@ public class GroupManager extends JavaPlugin {
|
|||
throw new IllegalStateException("An error ocurred while loading GroupManager");
|
||||
}
|
||||
|
||||
// Initialize the world listener and bukkit permissions to handle events.
|
||||
// Initialize the world listener and bukkit permissions to handle
|
||||
// events.
|
||||
WorldEvents = new GMWorldListener(this);
|
||||
BukkitPermissions = new BukkitPermissions(this);
|
||||
|
||||
enableScheduler();
|
||||
|
||||
/*
|
||||
* Schedule a Bukiit Permissions update for 1 tick later.
|
||||
* All plugins will be loaded by then
|
||||
* Schedule a Bukiit Permissions update for 1 tick later. All plugins
|
||||
* will be loaded by then
|
||||
*/
|
||||
|
||||
if (getServer().getScheduler().scheduleSyncDelayedTask(this, new BukkitPermsUpdateTask(), 1) == -1) {
|
||||
|
@ -130,8 +132,6 @@ public class GroupManager extends JavaPlugin {
|
|||
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean isLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
|
@ -188,8 +188,7 @@ public class GroupManager extends JavaPlugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* Use the WorldsHolder saveChanges directly instead
|
||||
* Saves the data on file
|
||||
* Use the WorldsHolder saveChanges directly instead Saves the data on file
|
||||
*/
|
||||
@Deprecated
|
||||
public void commit() {
|
||||
|
@ -199,8 +198,7 @@ public class GroupManager extends JavaPlugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* Use worlds holder to reload a specific world
|
||||
* Reloads the data
|
||||
* Use worlds holder to reload a specific world Reloads the data
|
||||
*/
|
||||
@Deprecated
|
||||
public void reload() {
|
||||
|
@ -213,6 +211,7 @@ public class GroupManager extends JavaPlugin {
|
|||
|
||||
/**
|
||||
* The handler in the interface created by AnjoCaido
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -223,6 +222,7 @@ public class GroupManager extends JavaPlugin {
|
|||
/**
|
||||
* A simple interface, for ones that don't want to mess with overloading.
|
||||
* Yet it is affected by overloading. But seamless.
|
||||
*
|
||||
* @return the dataholder with all information
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -232,6 +232,7 @@ public class GroupManager extends JavaPlugin {
|
|||
|
||||
/**
|
||||
* Use this if you want to play with overloading.
|
||||
*
|
||||
* @return a dataholder with overloading interface
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -241,6 +242,7 @@ public class GroupManager extends JavaPlugin {
|
|||
|
||||
/**
|
||||
* Called when a command registered by this plugin is received.
|
||||
*
|
||||
* @param sender
|
||||
* @param cmd
|
||||
* @param args
|
||||
|
@ -255,7 +257,6 @@ public class GroupManager extends JavaPlugin {
|
|||
User senderUser = null;
|
||||
boolean isOpOverride = config.isOpOverride();
|
||||
|
||||
|
||||
// DETERMINING PLAYER INFORMATION
|
||||
if (sender instanceof Player) {
|
||||
senderPlayer = (Player) sender;
|
||||
|
@ -290,7 +291,6 @@ public class GroupManager extends JavaPlugin {
|
|||
|
||||
// VARIABLES USED IN COMMANDS
|
||||
|
||||
|
||||
int count;
|
||||
PermissionCheckResult permissionResult = null;
|
||||
ArrayList<User> removeList = null;
|
||||
|
@ -381,7 +381,8 @@ public class GroupManager extends JavaPlugin {
|
|||
sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' group to '" + auxGroup.getName() + "'.");
|
||||
|
||||
targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
||||
if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer);
|
||||
if (targetPlayer != null)
|
||||
BukkitPermissions.updatePermissions(targetPlayer);
|
||||
|
||||
return true;
|
||||
// break;
|
||||
|
@ -418,7 +419,8 @@ public class GroupManager extends JavaPlugin {
|
|||
sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' to default settings.");
|
||||
|
||||
targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
||||
if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer);
|
||||
if (targetPlayer != null)
|
||||
BukkitPermissions.updatePermissions(targetPlayer);
|
||||
|
||||
return true;
|
||||
case manuaddsub:
|
||||
|
@ -462,7 +464,8 @@ public class GroupManager extends JavaPlugin {
|
|||
sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' group to '" + auxGroup.getName() + "'.");
|
||||
|
||||
targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
||||
if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer);
|
||||
if (targetPlayer != null)
|
||||
BukkitPermissions.updatePermissions(targetPlayer);
|
||||
|
||||
return true;
|
||||
case manudelsub:
|
||||
|
@ -504,7 +507,8 @@ public class GroupManager extends JavaPlugin {
|
|||
sender.sendMessage(ChatColor.YELLOW + "You removed subgroup '" + auxGroup.getName() + "' from player '" + auxUser.getName() + "' list.");
|
||||
|
||||
targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
||||
if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer);
|
||||
if (targetPlayer != null)
|
||||
BukkitPermissions.updatePermissions(targetPlayer);
|
||||
|
||||
return true;
|
||||
case mangadd:
|
||||
|
@ -580,8 +584,7 @@ public class GroupManager extends JavaPlugin {
|
|||
return false;
|
||||
}
|
||||
permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]);
|
||||
if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
|
||||
|| permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
|
||||
if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND) || permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't add a permission you don't have.");
|
||||
return false;
|
||||
}
|
||||
|
@ -615,7 +618,8 @@ public class GroupManager extends JavaPlugin {
|
|||
sender.sendMessage(ChatColor.YELLOW + "You added '" + args[1] + "' to player '" + auxUser.getName() + "' permissions.");
|
||||
|
||||
targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
||||
if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer);
|
||||
if (targetPlayer != null)
|
||||
BukkitPermissions.updatePermissions(targetPlayer);
|
||||
|
||||
return true;
|
||||
// break;
|
||||
|
@ -648,8 +652,7 @@ public class GroupManager extends JavaPlugin {
|
|||
return false;
|
||||
}
|
||||
permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]);
|
||||
if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
|
||||
|| permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
|
||||
if (!isConsole && !isOpOverride && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND) || permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't remove a permission you don't have.");
|
||||
return false;
|
||||
}
|
||||
|
@ -669,7 +672,8 @@ public class GroupManager extends JavaPlugin {
|
|||
sender.sendMessage(ChatColor.YELLOW + "You removed '" + args[1] + "' from player '" + auxUser.getName() + "' permissions.");
|
||||
|
||||
targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
||||
if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer);
|
||||
if (targetPlayer != null)
|
||||
BukkitPermissions.updatePermissions(targetPlayer);
|
||||
|
||||
return true;
|
||||
// break;
|
||||
|
@ -739,7 +743,6 @@ public class GroupManager extends JavaPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
case manucheckp:
|
||||
// VALIDANDO ESTADO DO SENDER
|
||||
|
@ -774,7 +777,8 @@ public class GroupManager extends JavaPlugin {
|
|||
return false;
|
||||
}
|
||||
// PARECE OK
|
||||
//auxString = permissionHandler.checkUserOnlyPermission(auxUser, args[1]);
|
||||
// auxString =
|
||||
// permissionHandler.checkUserOnlyPermission(auxUser, args[1]);
|
||||
if (permissionResult.owner instanceof User) {
|
||||
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) {
|
||||
sender.sendMessage(ChatColor.RED + "The user has directly a negation node for that permission.");
|
||||
|
@ -796,7 +800,6 @@ public class GroupManager extends JavaPlugin {
|
|||
sender.sendMessage(ChatColor.YELLOW + "SuperPerms reports Node: " + targetPlayer.hasPermission(args[1]));
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
case mangaddp:
|
||||
// VALIDANDO ESTADO DO SENDER
|
||||
|
@ -816,8 +819,7 @@ public class GroupManager extends JavaPlugin {
|
|||
}
|
||||
// VALIDANDO SUA PERMISSAO
|
||||
permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]);
|
||||
if (!isConsole && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
|
||||
|| permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
|
||||
if (!isConsole && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND) || permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't add a permission you don't have.");
|
||||
return false;
|
||||
}
|
||||
|
@ -871,8 +873,7 @@ public class GroupManager extends JavaPlugin {
|
|||
}
|
||||
// VALIDANDO SUA PERMISSAO
|
||||
permissionResult = permissionHandler.checkFullUserPermission(senderUser, args[1]);
|
||||
if (!isConsole && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)
|
||||
|| permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
|
||||
if (!isConsole && (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND) || permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION))) {
|
||||
sender.sendMessage(ChatColor.RED + "Can't remove a permission you don't have.");
|
||||
return false;
|
||||
}
|
||||
|
@ -965,7 +966,8 @@ public class GroupManager extends JavaPlugin {
|
|||
return false;
|
||||
}
|
||||
// PARECE OK
|
||||
//auxString = permissionHandler.checkUserOnlyPermission(auxUser, args[1]);
|
||||
// auxString =
|
||||
// permissionHandler.checkUserOnlyPermission(auxUser, args[1]);
|
||||
if (permissionResult.owner instanceof Group) {
|
||||
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) {
|
||||
sender.sendMessage(ChatColor.RED + "The group inherits the a negation permission from group: " + permissionResult.owner.getName());
|
||||
|
@ -1607,7 +1609,8 @@ public class GroupManager extends JavaPlugin {
|
|||
sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + ".");
|
||||
|
||||
targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
||||
if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer);
|
||||
if (targetPlayer != null)
|
||||
BukkitPermissions.updatePermissions(targetPlayer);
|
||||
|
||||
return true;
|
||||
// break;
|
||||
|
@ -1666,7 +1669,8 @@ public class GroupManager extends JavaPlugin {
|
|||
sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + ".");
|
||||
|
||||
targetPlayer = this.getServer().getPlayer(auxUser.getName());
|
||||
if (targetPlayer != null) BukkitPermissions.updatePermissions(targetPlayer);
|
||||
if (targetPlayer != null)
|
||||
BukkitPermissions.updatePermissions(targetPlayer);
|
||||
|
||||
return true;
|
||||
// break;
|
||||
|
@ -1769,11 +1773,9 @@ public class GroupManager extends JavaPlugin {
|
|||
}
|
||||
|
||||
/**
|
||||
* Send confirmation of a group change.
|
||||
* using permission nodes...
|
||||
* Send confirmation of a group change. using permission nodes...
|
||||
*
|
||||
* groupmanager.notify.self
|
||||
* groupmanager.notify.other
|
||||
* groupmanager.notify.self groupmanager.notify.other
|
||||
*
|
||||
* @param name
|
||||
* @param msg
|
||||
|
@ -1786,8 +1788,7 @@ public class GroupManager extends JavaPlugin {
|
|||
if (!test.equals(player)) {
|
||||
if (test.hasPermission("groupmanager.notify.other"))
|
||||
test.sendMessage(ChatColor.YELLOW + name + " was" + msg);
|
||||
} else
|
||||
if ((player != null) && ((player.hasPermission("groupmanager.notify.self")) || (player.hasPermission("groupmanager.notify.other"))))
|
||||
} else if ((player != null) && ((player.hasPermission("groupmanager.notify.self")) || (player.hasPermission("groupmanager.notify.other"))))
|
||||
player.sendMessage(ChatColor.YELLOW + "You were" + msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* It needs a WorldDataHolder to work with.
|
||||
*
|
||||
* @param holder
|
||||
*/
|
||||
public AnjoPermissionsHandler(WorldDataHolder holder) {
|
||||
|
@ -42,6 +43,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* A short name method, for permission method.
|
||||
*
|
||||
* @param player
|
||||
* @param permission
|
||||
* @return
|
||||
|
@ -53,6 +55,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Checks if a player can use that permission node.
|
||||
*
|
||||
* @param player
|
||||
* @param permission
|
||||
* @return
|
||||
|
@ -64,6 +67,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Checks if a player can use that permission node.
|
||||
*
|
||||
* @param playerName
|
||||
* @param permission
|
||||
* @return
|
||||
|
@ -74,6 +78,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Returns the name of the group of that player name.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
|
@ -83,7 +88,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns All permissions (including inheritance and sub groups) for the player.
|
||||
* Returns All permissions (including inheritance and sub groups) for the
|
||||
* player.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
|
@ -133,16 +139,15 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Verify if player is in suck group.
|
||||
* It will check it's groups inheritance.
|
||||
* Verify if player is in suck group. It will check it's groups inheritance.
|
||||
*
|
||||
* So if you have a group Admin > Moderator
|
||||
*
|
||||
* And verify the player 'MyAdmin', which is Admin, it will return true for both
|
||||
* Admin or Moderator groups.
|
||||
* And verify the player 'MyAdmin', which is Admin, it will return true for
|
||||
* both Admin or Moderator groups.
|
||||
*
|
||||
* Mas if you have a player 'MyModerator', which is Moderator,
|
||||
* it will give false if you pass Admin in group parameter.
|
||||
* Mas if you have a player 'MyModerator', which is Moderator, it will give
|
||||
* false if you pass Admin in group parameter.
|
||||
*
|
||||
* @param name
|
||||
* @param group
|
||||
|
@ -162,11 +167,13 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the appropriate prefix for the user.
|
||||
* This method is a utility method for chat plugins to get the user's prefix
|
||||
* without having to look at every one of the user's ancestors.
|
||||
* Returns an empty string if user has no parent groups.
|
||||
* @param user Player's name
|
||||
* Gets the appropriate prefix for the user. This method is a utility method
|
||||
* for chat plugins to get the user's prefix without having to look at every
|
||||
* one of the user's ancestors. Returns an empty string if user has no
|
||||
* parent groups.
|
||||
*
|
||||
* @param user
|
||||
* Player's name
|
||||
* @return Player's prefix
|
||||
*/
|
||||
@Override
|
||||
|
@ -181,11 +188,13 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the appropriate prefix for the user.
|
||||
* This method is a utility method for chat plugins to get the user's prefix
|
||||
* without having to look at every one of the user's ancestors.
|
||||
* Returns an empty string if user has no parent groups.
|
||||
* @param user Player's name
|
||||
* Gets the appropriate prefix for the user. This method is a utility method
|
||||
* for chat plugins to get the user's prefix without having to look at every
|
||||
* one of the user's ancestors. Returns an empty string if user has no
|
||||
* parent groups.
|
||||
*
|
||||
* @param user
|
||||
* Player's name
|
||||
* @return Player's prefix
|
||||
*/
|
||||
@Override
|
||||
|
@ -201,10 +210,12 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets name of the primary group of the user.
|
||||
* Returns the name of the default group if user has no parent groups,
|
||||
* or "Default" if there is no default group for that world.
|
||||
* @param user Player's name
|
||||
* Gets name of the primary group of the user. Returns the name of the
|
||||
* default group if user has no parent groups, or "Default" if there is no
|
||||
* default group for that world.
|
||||
*
|
||||
* @param user
|
||||
* Player's name
|
||||
* @return Name of player's primary group
|
||||
*/
|
||||
public String getPrimaryGroup(String user) {
|
||||
|
@ -215,8 +226,11 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Check if user can build.
|
||||
* @param world Player's world
|
||||
* @param user Player's name
|
||||
*
|
||||
* @param world
|
||||
* Player's world
|
||||
* @param user
|
||||
* Player's name
|
||||
* @return Whether the user can build
|
||||
*/
|
||||
public boolean canUserBuild(String user) {
|
||||
|
@ -232,6 +246,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Returns the String prefix for the given group
|
||||
*
|
||||
* @param groupName
|
||||
* @return empty string if found none.
|
||||
*/
|
||||
|
@ -246,6 +261,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Return the suffix for the given group name
|
||||
*
|
||||
* @param groupName
|
||||
* @return
|
||||
*/
|
||||
|
@ -273,8 +289,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* It returns a string variable value, set in the INFO node of the group.
|
||||
* It will harvest inheritance for value.
|
||||
* It returns a string variable value, set in the INFO node of the group. It
|
||||
* will harvest inheritance for value.
|
||||
*
|
||||
* @param groupName
|
||||
* @param variable
|
||||
* @return null if no group with that variable is found.
|
||||
|
@ -293,8 +310,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* It returns a Integer variable value
|
||||
* It will harvest inheritance for value.
|
||||
* It returns a Integer variable value It will harvest inheritance for
|
||||
* value.
|
||||
*
|
||||
* @param groupName
|
||||
* @param variable
|
||||
* @return -1 if none found or not parseable.
|
||||
|
@ -313,8 +331,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean for given variable in INFO node.
|
||||
* It will harvest inheritance for value.
|
||||
* Returns a boolean for given variable in INFO node. It will harvest
|
||||
* inheritance for value.
|
||||
*
|
||||
* @param group
|
||||
* @param variable
|
||||
* @return false if not found/not parseable.
|
||||
|
@ -333,8 +352,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a double value for the given variable name in INFO node.
|
||||
* It will harvest inheritance for value.
|
||||
* Returns a double value for the given variable name in INFO node. It will
|
||||
* harvest inheritance for value.
|
||||
*
|
||||
* @param group
|
||||
* @param variable
|
||||
* @return -1 if not found / not parseable.
|
||||
|
@ -354,6 +374,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Returns the variable value of the user, in INFO node.
|
||||
*
|
||||
* @param user
|
||||
* @param variable
|
||||
* @return
|
||||
|
@ -369,6 +390,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Returns the variable value of the user, in INFO node.
|
||||
*
|
||||
* @param user
|
||||
* @param variable
|
||||
* @return
|
||||
|
@ -384,6 +406,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Returns the variable value of the user, in INFO node.
|
||||
*
|
||||
* @param user
|
||||
* @param variable
|
||||
* @return
|
||||
|
@ -399,6 +422,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Returns the variable value of the user, in INFO node.
|
||||
*
|
||||
* @param user
|
||||
* @param variable
|
||||
* @return
|
||||
|
@ -413,9 +437,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the variable value of the user, in INFO node.
|
||||
* If not found, it will search for his Group variables.
|
||||
* It will harvest the inheritance.
|
||||
* Returns the variable value of the user, in INFO node. If not found, it
|
||||
* will search for his Group variables. It will harvest the inheritance.
|
||||
*
|
||||
* @param user
|
||||
* @param variable
|
||||
* @return empty string if not found
|
||||
|
@ -442,9 +466,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the variable value of the user, in INFO node.
|
||||
* If not found, it will search for his Group variables.
|
||||
* It will harvest the inheritance.
|
||||
* Returns the variable value of the user, in INFO node. If not found, it
|
||||
* will search for his Group variables. It will harvest the inheritance.
|
||||
*
|
||||
* @param user
|
||||
* @param variable
|
||||
* @return -1 if not found
|
||||
|
@ -471,9 +495,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the variable value of the user, in INFO node.
|
||||
* If not found, it will search for his Group variables.
|
||||
* It will harvest the inheritance.
|
||||
* Returns the variable value of the user, in INFO node. If not found, it
|
||||
* will search for his Group variables. It will harvest the inheritance.
|
||||
*
|
||||
* @param user
|
||||
* @param variable
|
||||
* @return false if not found or not parseable to true.
|
||||
|
@ -500,9 +524,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the variable value of the user, in INFO node.
|
||||
* If not found, it will search for his Group variables.
|
||||
* It will harvest the inheritance.
|
||||
* Returns the variable value of the user, in INFO node. If not found, it
|
||||
* will search for his Group variables. It will harvest the inheritance.
|
||||
*
|
||||
* @param user
|
||||
* @param variable
|
||||
* @return -1 if not found.
|
||||
|
@ -530,6 +554,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Does not include User's group permission
|
||||
*
|
||||
* @param user
|
||||
* @param permission
|
||||
* @return
|
||||
|
@ -557,8 +582,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the node responsible for that permission.
|
||||
* Does not include User's group permission.
|
||||
* Returns the node responsible for that permission. Does not include User's
|
||||
* group permission.
|
||||
*
|
||||
* @param group
|
||||
* @param permission
|
||||
* @return the node if permission is found. if not found, return null
|
||||
|
@ -587,14 +613,14 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Check permissions, including it's group and inheritance.
|
||||
*
|
||||
* @param user
|
||||
* @param permission
|
||||
* @return true if permission was found. false if not, or was negated.
|
||||
*/
|
||||
public boolean checkUserPermission(User user, String permission) {
|
||||
PermissionCheckResult result = checkFullUserPermission(user, permission);
|
||||
if (result.resultType.equals(PermissionCheckResult.Type.EXCEPTION)
|
||||
|| result.resultType.equals(PermissionCheckResult.Type.FOUND)) {
|
||||
if (result.resultType.equals(PermissionCheckResult.Type.EXCEPTION) || result.resultType.equals(PermissionCheckResult.Type.FOUND)) {
|
||||
return true;
|
||||
}
|
||||
if (Bukkit.getPlayer(user.getName()).hasPermission(permission))
|
||||
|
@ -604,7 +630,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Do what checkUserPermission did before. But now returning a PermissionCheckResult.
|
||||
* Do what checkUserPermission did before. But now returning a
|
||||
* PermissionCheckResult.
|
||||
*
|
||||
* @param user
|
||||
* @param targetPermission
|
||||
* @return
|
||||
|
@ -657,7 +685,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
* @param variable
|
||||
* @param alreadyChecked
|
||||
* @return returns the closest inherited group with the variable.
|
||||
* @deprecated use now nextGroupWithVariable(Group start, String targetVariable)
|
||||
* @deprecated use now nextGroupWithVariable(Group start, String
|
||||
* targetVariable)
|
||||
*/
|
||||
@Deprecated
|
||||
public Group nextGroupWithVariable(Group start, String variable, List<Group> alreadyChecked) {
|
||||
|
@ -670,8 +699,10 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
*
|
||||
* It does Breadth-first search
|
||||
*
|
||||
* @param start the starting group to look for
|
||||
* @param targetVariable the variable name
|
||||
* @param start
|
||||
* the starting group to look for
|
||||
* @param targetVariable
|
||||
* the variable name
|
||||
* @return The group if found. Null if not.
|
||||
*/
|
||||
public Group nextGroupWithVariable(Group start, String targetVariable) {
|
||||
|
@ -704,11 +735,15 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
* redirected to the other method. this is deprecated now. and will be gone
|
||||
* in the future releases.
|
||||
*
|
||||
* @param start The group to start the search.
|
||||
* @param askedGroup Name of the group you're looking for
|
||||
* @param alreadyChecked groups to ignore(pass null on it, please)
|
||||
* @param start
|
||||
* The group to start the search.
|
||||
* @param askedGroup
|
||||
* Name of the group you're looking for
|
||||
* @param alreadyChecked
|
||||
* groups to ignore(pass null on it, please)
|
||||
* @return true if it inherits the group.
|
||||
* @deprecated prefer using hasGroupInInheritance(Group start, String askedGroup)
|
||||
* @deprecated prefer using hasGroupInInheritance(Group start, String
|
||||
* askedGroup)
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean searchGroupInInheritance(Group start, String askedGroup, List<Group> alreadyChecked) {
|
||||
|
@ -720,8 +755,10 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
*
|
||||
* It does Breadth-first search
|
||||
*
|
||||
* @param start The group to start the search.
|
||||
* @param askedGroup Name of the group you're looking for
|
||||
* @param start
|
||||
* The group to start the search.
|
||||
* @param askedGroup
|
||||
* Name of the group you're looking for
|
||||
* @return true if it inherits the group.
|
||||
*/
|
||||
public boolean hasGroupInInheritance(Group start, String askedGroup) {
|
||||
|
@ -750,30 +787,30 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Check if the group has given permission. Including it's inheritance
|
||||
*
|
||||
* @param start
|
||||
* @param permission
|
||||
* @param alreadyChecked
|
||||
* @return true if PermissionCheckResult is EXCEPTION or FOUND
|
||||
* @deprecated use the other checkGroupPermissionWithInheritance for everything
|
||||
* @deprecated use the other checkGroupPermissionWithInheritance for
|
||||
* everything
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean checkGroupPermissionWithInheritance(Group start, String permission, List<Group> alreadyChecked) {
|
||||
PermissionCheckResult result = checkGroupPermissionWithInheritance(start, permission);
|
||||
if (result.resultType.equals(Type.EXCEPTION)
|
||||
|| result.resultType.equals(Type.FOUND)) {
|
||||
if (result.resultType.equals(Type.EXCEPTION) || result.resultType.equals(Type.FOUND)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the result of permission check. Including inheritance.
|
||||
* If found anything, the PermissionCheckResult that retuns will
|
||||
* include the Group name, and the result type.
|
||||
* Result types will be EXCEPTION, NEGATION, FOUND.
|
||||
* Returns the result of permission check. Including inheritance. If found
|
||||
* anything, the PermissionCheckResult that retuns will include the Group
|
||||
* name, and the result type. Result types will be EXCEPTION, NEGATION,
|
||||
* FOUND.
|
||||
*
|
||||
* If returned type NOTFOUND, the owner will be null,
|
||||
* and ownerType too.
|
||||
* If returned type NOTFOUND, the owner will be null, and ownerType too.
|
||||
*
|
||||
* It does Breadth-first search
|
||||
*
|
||||
|
@ -810,8 +847,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* It uses checkGroupPermissionWithInheritance
|
||||
* and cast the owner to Group type if result type was EXCEPTION or FOUND.
|
||||
* It uses checkGroupPermissionWithInheritance and cast the owner to Group
|
||||
* type if result type was EXCEPTION or FOUND.
|
||||
*
|
||||
* @param start
|
||||
* @param permission
|
||||
|
@ -822,8 +859,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
@Deprecated
|
||||
public Group nextGroupWithPermission(Group start, String permission, List<Group> alreadyChecked) {
|
||||
PermissionCheckResult result = checkGroupPermissionWithInheritance(start, permission);
|
||||
if (result.resultType.equals(Type.EXCEPTION)
|
||||
|| result.resultType.equals(Type.FOUND)) {
|
||||
if (result.resultType.equals(Type.EXCEPTION) || result.resultType.equals(Type.FOUND)) {
|
||||
return (Group) checkGroupPermissionWithInheritance(start, permission).owner;
|
||||
}
|
||||
return null;
|
||||
|
@ -833,8 +869,8 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
* Return whole list of names of groups in a inheritance chain. Including a
|
||||
* starting group.
|
||||
*
|
||||
* it now redirects to the other method. but get away from this one,
|
||||
* it will disappear in a future release.
|
||||
* it now redirects to the other method. but get away from this one, it will
|
||||
* disappear in a future release.
|
||||
*
|
||||
* @param start
|
||||
* @param alreadyChecked
|
||||
|
@ -878,17 +914,17 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
|
||||
/**
|
||||
* Compare a user permission like 'myplugin.*' against a full plugin
|
||||
* permission name, like 'myplugin.dosomething'.
|
||||
* As the example above, will return true.
|
||||
* permission name, like 'myplugin.dosomething'. As the example above, will
|
||||
* return true.
|
||||
*
|
||||
* Please sort permissions before sending them here. So negative tokens
|
||||
* get priority.
|
||||
* Please sort permissions before sending them here. So negative tokens get
|
||||
* priority.
|
||||
*
|
||||
* You must test if it start with negative outside this method. It will
|
||||
* only tell if the nodes are matching or not.
|
||||
* You must test if it start with negative outside this method. It will only
|
||||
* tell if the nodes are matching or not.
|
||||
*
|
||||
* Every '-' or '+' in the beginning is ignored. It will match only
|
||||
* node names.
|
||||
* Every '-' or '+' in the beginning is ignored. It will match only node
|
||||
* names.
|
||||
*
|
||||
* @param userAcessLevel
|
||||
* @param fullPermissionName
|
||||
|
@ -912,7 +948,6 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
fullPermissionName = fullPermissionName.substring(1);
|
||||
}
|
||||
|
||||
|
||||
StringTokenizer levelATokenizer = new StringTokenizer(userAcessLevel, ".");
|
||||
StringTokenizer levelBTokenizer = new StringTokenizer(fullPermissionName, ".");
|
||||
while (levelATokenizer.hasMoreTokens() && levelBTokenizer.hasMoreTokens()) {
|
||||
|
@ -944,6 +979,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
* Returns a list of all groups.
|
||||
*
|
||||
* Including subgroups.
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
|
@ -961,8 +997,9 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
/**
|
||||
* A Breadth-first search thru inheritance model.
|
||||
*
|
||||
* Just a model to copy and paste.
|
||||
* This will guarantee the closer groups will be checked first.
|
||||
* Just a model to copy and paste. This will guarantee the closer groups
|
||||
* will be checked first.
|
||||
*
|
||||
* @param start
|
||||
* @param targerPermission
|
||||
* @return
|
||||
|
@ -979,8 +1016,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
while (!stack.isEmpty()) {
|
||||
Group now = stack.pop();
|
||||
PermissionCheckResult resultNow = checkGroupOnlyPermission(now, targerPermission);
|
||||
if (resultNow.resultType.equals(PermissionCheckResult.Type.EXCEPTION)
|
||||
|| resultNow.resultType.equals(PermissionCheckResult.Type.FOUND)) {
|
||||
if (resultNow.resultType.equals(PermissionCheckResult.Type.EXCEPTION) || resultNow.resultType.equals(PermissionCheckResult.Type.FOUND)) {
|
||||
return now;
|
||||
}
|
||||
if (resultNow.resultType.equals(PermissionCheckResult.Type.NEGATION)) {
|
||||
|
@ -1003,8 +1039,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getInfoString(String entryName, String path,
|
||||
boolean isGroup) {
|
||||
public String getInfoString(String entryName, String path, boolean isGroup) {
|
||||
if (isGroup) {
|
||||
Group data = ph.getGroup(entryName);
|
||||
if (data == null) {
|
||||
|
@ -1021,8 +1056,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getInfoInteger(String entryName, String path,
|
||||
boolean isGroup) {
|
||||
public int getInfoInteger(String entryName, String path, boolean isGroup) {
|
||||
if (isGroup) {
|
||||
Group data = ph.getGroup(entryName);
|
||||
if (data == null) {
|
||||
|
@ -1039,8 +1073,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public double getInfoDouble(String entryName, String path,
|
||||
boolean isGroup) {
|
||||
public double getInfoDouble(String entryName, String path, boolean isGroup) {
|
||||
if (isGroup) {
|
||||
Group data = ph.getGroup(entryName);
|
||||
if (data == null) {
|
||||
|
@ -1058,8 +1091,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean getInfoBoolean(String entryName, String path,
|
||||
boolean isGroup) {
|
||||
public boolean getInfoBoolean(String entryName, String path, boolean isGroup) {
|
||||
if (isGroup) {
|
||||
Group data = ph.getGroup(entryName);
|
||||
if (data == null) {
|
||||
|
|
Loading…
Reference in a new issue