Documentation & fully implement info nodes

This commit is contained in:
Morgan 2011-06-29 18:24:59 -04:00
parent b5ae8f58d1
commit f841feb128
4 changed files with 280 additions and 48 deletions

View File

@ -27,41 +27,249 @@ public interface Permission {
public static final Logger log = Logger.getLogger("Minecraft");
/**
* Gets name of permission method
* @return Name of Permission Method
*/
public String getName();
/**
* Checks if permission method is enabled.
* @return
*/
public boolean isEnabled();
public boolean hasPermission(Player player, String permission);
public boolean userAddPermission(String worldName, String playerName, String permission);
public boolean userRemovePermission(String worldName, String playerName, String permission);
/**
* Checks if player has a permission node.
* @param player Player instance
* @param permission Permission node
* @return
*/
public boolean playerHasPermission(Player player, String permission);
/**
* Add permission to a player.
* @param worldName Name of World
* @param playerName Name of Player
* @param permission Permission node
* @return
*/
public boolean playerAddPermission(String worldName, String playerName, String permission);
/**
* Remove permission from a player.
* @param worldName Name of World
* @param playerName Name of Player
* @param permission Permission node
* @return
*/
public boolean playerRemovePermission(String worldName, String playerName, String permission);
/**
* Checks if group has a permission node.
* @param worldName Name of World
* @param groupName Name of Group
* @param permission Permission node
* @return
*/
public boolean groupHasPermission(String worldName, String groupName, String permission);
/**
* Add permission to a group.
* @param worldName Name of World
* @param groupName Name of Group
* @param permission Permission node
* @return
*/
public boolean groupAddPermission(String worldName, String groupName, String permission);
/**
* Remove permission from a group.
* @param worldName Name of World
* @param groupName Name of Group
* @param permission Permission node
* @return
*/
public boolean groupRemovePermission(String worldName, String groupName, String permission);
public boolean inGroup(String worldName, String playerName, String groupName);
public boolean userAddGroup(String worldName, String playerName, String groupName);
public boolean userRemoveGroup(String worldName, String playerName, String groupName);
/**
* Check if player is member of a group.
* @param worldName Name of World
* @param playerName Name of Player
* @param groupName Name of Group
* @return
*/
public boolean playerInGroup(String worldName, String playerName, String groupName);
public int getUserInfoInteger(String world, String playerName, String node, int defaultValue);
public void setUserInfoInteger(String world, String playerName, String node, int value);
/**
* Add player to a group.
* @param worldName Name of World
* @param playerName Name of Player
* @param groupName Name of Group
* @return
*/
public boolean playerAddGroup(String worldName, String playerName, String groupName);
/**
* Remove player from a group.
* @param worldName Name of World
* @param playerName Name of Player
* @param groupName Name of Group
* @return
*/
public boolean playerRemoveGroup(String worldName, String playerName, String groupName);
/**
* Get a players informational node (Integer) value
* @param world Name of World
* @param playerName Name of Player
* @param node Permission node
* @param defaultValue Default value (if node is not defined)
* @return
*/
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue);
/**
* Set a players informational node (Integer) value
* @param world Name of World
* @param playerName Name of Player
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoInteger(String world, String playerName, String node, int value);
/**
* Get a groups informational node (Integer) value
* @param world Name of World
* @param groupName Name of Group
* @param node Permission node
* @param defaultValue Default value (if node is not defined)
* @return
*/
public int getGroupInfoInteger(String world, String groupName, String node, int defaultValue);
/**
* Set a groups informational node (Integer) value
* @param world Name of World
* @param groupName Name of Group
* @param node Permission node
* @param value Value to set
*/
public void setGroupInfoInteger(String world, String groupName, String node, int value);
public double getUserInfoDouble(String world, String playerName, String node, double defaultValue);
public void setUserInfoDouble(String world, String playerName, String node, double value);
/**
* Get a players informational node (Double) value
* @param world Name of World
* @param playerName Name of Group
* @param node Permission node
* @param defaultValue Default value (if node is not defined)
* @return
*/
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue);
/**
* Set a players informational node (Double) value
* @param world Name of World
* @param playerName Name of Group
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoDouble(String world, String playerName, String node, double value);
/**
* Get a groups informational node (Double) value
* @param world Name of World
* @param groupName Name of Group
* @param node Permission node
* @param defaultValue Default value (if node is not defined)
* @return
*/
public double getGroupInfoDouble(String world, String groupName, String node, double defaultValue);
/**
* Set a groups informational node (Double) value
* @param world Name of World
* @param groupName Name of Group
* @param node Permission node
* @param value Value to set
*/
public void setGroupInfoDouble(String world, String groupName, String node, double value);
public boolean getUserInfoBoolean(String world, String playerName, String node, boolean defaultValue);
public void setUserInfoBoolean(String world, String playerName, String node, boolean value);
/**
* Get a players informational node (Boolean) value
* @param world Name of World
* @param playerName Name of Player
* @param node Permission node
* @param defaultValue Default value (if node is not defined)
* @return
*/
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue);
/**
* Set a players informational node (Boolean) value
* @param world Name of World
* @param playerName Name of Player
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value);
/**
* Get a groups informational node (Boolean) value
* @param world Name of World
* @param groupName Name of Group
* @param node Permission node
* @param defaultValue Default value (if node is not defined)
* @return
*/
public boolean getGroupInfoBoolean(String world, String groupName, String node, boolean defaultValue);
/**
* Set a groups informational node (Boolean) value
* @param world Name of World
* @param groupName Name of Group
* @param node Permission node
* @param value Value to set
*/
public void setGroupInfoBoolean(String world, String groupName, String node, boolean value);
public String getUserInfoString(String world, String playerName, String node, String defaultValue);
public void setUserInfoString(String world, String playerName, String node, String value);
/**
* Get a players informational node (String) value
* @param world Name of World
* @param playerName Name of Player
* @param node Permission node
* @param defaultValue Default value (if node is not defined)
* @return
*/
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue);
/**
* Set a players informational node (String) value
* @param world Name of World
* @param playerName Name of Player
* @param node Permission node
* @param value Value to set
*/
public void setPlayerInfoString(String world, String playerName, String node, String value);
/**
* Get a groups informational node (String) value
* @param world Name of World
* @param groupName Name of Group
* @param node Permission node
* @param defaultValue Default value (if node is not defined)
* @return
*/
public String getGroupInfoString(String world, String groupName, String node, String defaultValue);
/**
* Set a groups informational node (String) value
* @param world Name of World
* @param groupName Name of Group
* @param node Permission node
* @param value Value to set
*/
public void setGroupInfoString(String world, String groupName, String node, String value);
}

View File

@ -98,7 +98,7 @@ public class PermissionManager {
public boolean hasPermission(Player player, String permission, boolean def) {
Permission p = getPermission();
if(p != null) {
return p.hasPermission(player, permission);
return p.playerHasPermission(player, permission);
} else {
if(player.isOp()) {
return true;
@ -118,7 +118,7 @@ public class PermissionManager {
public boolean inGroup(String worldName, String playerName, String groupName) {
Permission p = getPermission();
if(p != null) {
return p.inGroup(worldName, playerName, groupName);
return p.playerInGroup(worldName, playerName, groupName);
} else {
return false;
}
@ -134,7 +134,7 @@ public class PermissionManager {
public int getInfoInt(String world, String playerName, String node, int defaultValue) {
Permission p = getPermission();
if(p != null) {
return p.getUserInfoInteger(world, playerName, node, defaultValue);
return p.getPlayerInfoInteger(world, playerName, node, defaultValue);
} else {
return defaultValue;
}
@ -150,7 +150,7 @@ public class PermissionManager {
public double getInfoBoolean(String world, String playerName, String node, double defaultValue) {
Permission p = getPermission();
if(p != null) {
return p.getUserInfoDouble(world, playerName, node, defaultValue);
return p.getPlayerInfoDouble(world, playerName, node, defaultValue);
} else {
return defaultValue;
}
@ -166,7 +166,7 @@ public class PermissionManager {
public boolean getInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
Permission p = getPermission();
if(p != null) {
return p.getUserInfoBoolean(world, playerName, node, defaultValue);
return p.getPlayerInfoBoolean(world, playerName, node, defaultValue);
} else {
return defaultValue;
}
@ -182,7 +182,7 @@ public class PermissionManager {
public String getInfoBoolean(String world, String playerName, String node, String defaultValue) {
Permission p = getPermission();
if(p != null) {
return p.getUserInfoString(world, playerName, node, defaultValue);
return p.getPlayerInfoString(world, playerName, node, defaultValue);
} else {
return defaultValue;
}

View File

@ -30,6 +30,9 @@ import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import ru.tehkode.permissions.PermissionGroup;
import com.nijiko.permissions.Group;
import com.nijikokun.bukkit.Permissions.Permissions;
public class Permission_Permissions implements Permission {
@ -70,12 +73,12 @@ public class Permission_Permissions implements Permission {
}
@Override
public boolean hasPermission(Player player, String permission) {
public boolean playerHasPermission(Player player, String permission) {
return this.permission.getHandler().has(player, permission);
}
@Override
public boolean inGroup(String worldName, String playerName, String groupName) {
public boolean playerInGroup(String worldName, String playerName, String groupName) {
return this.permission.getHandler().inGroup(worldName, playerName, groupName);
}
@ -115,45 +118,45 @@ public class Permission_Permissions implements Permission {
}
@Override
public int getUserInfoInteger(String world, String playerName, String node, int defaultValue) {
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
return this.permission.getHandler().getInfoInteger(world, playerName, node, false);
}
@Override
public double getUserInfoDouble(String world, String playerName, String node, double defaultValue) {
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
return this.permission.getHandler().getInfoDouble(world, playerName, node, false);
}
@Override
public boolean getUserInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
return this.permission.getHandler().getInfoBoolean(world, playerName, node, false);
}
@Override
public String getUserInfoString(String world, String playerName, String node, String defaultValue) {
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
return this.permission.getHandler().getInfoString(world, playerName, node, false);
}
@Override
public boolean userAddGroup(String worldName, String playerName, String groupName) {
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
// Not certain if this is possible in P3
return false;
}
@Override
public boolean userRemoveGroup(String worldName, String playerName, String groupName) {
public boolean playerRemoveGroup(String worldName, String playerName, String groupName) {
// Not certain if this is possible in P3
return false;
}
@Override
public boolean userAddPermission(String worldName, String playerName, String permission) {
public boolean playerAddPermission(String worldName, String playerName, String permission) {
this.permission.getHandler().addUserPermission(worldName, playerName, permission);
return true;
}
@Override
public boolean userRemovePermission(String worldName, String playerName, String permission) {
public boolean playerRemovePermission(String worldName, String playerName, String permission) {
this.permission.getHandler().removeUserPermission(worldName, playerName, permission);
return true;
}
@ -171,7 +174,7 @@ public class Permission_Permissions implements Permission {
}
@Override
public void setUserInfoInteger(String world, String playerName, String node, int value) {
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
try {
this.permission.getHandler().safeGetUser(world, playerName).setData(node, value);
} catch(Exception e) {
@ -180,7 +183,7 @@ public class Permission_Permissions implements Permission {
}
@Override
public void setUserInfoDouble(String world, String playerName, String node, double value) {
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
try {
this.permission.getHandler().safeGetUser(world, playerName).setData(node, value);
} catch(Exception e) {
@ -189,7 +192,7 @@ public class Permission_Permissions implements Permission {
}
@Override
public void setUserInfoBoolean(String world, String playerName, String node, boolean value) {
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
try {
this.permission.getHandler().safeGetUser(world, playerName).setData(node, value);
} catch(Exception e) {
@ -198,7 +201,7 @@ public class Permission_Permissions implements Permission {
}
@Override
public void setUserInfoString(String world, String playerName, String node, String value) {
public void setPlayerInfoString(String world, String playerName, String node, String value) {
try {
this.permission.getHandler().safeGetUser(world, playerName).setData(node, value);
} catch(Exception e) {
@ -261,4 +264,15 @@ public class Permission_Permissions implements Permission {
// lolwut?
}
}
@Override
public boolean groupHasPermission(String worldName, String groupName, String permission) {
try {
Group group = this.permission.getHandler().safeGetGroup(worldName, groupName);
return group.hasPermission(permission);
} catch (Exception e) {
// lowut?
return false;
}
}
}

View File

@ -73,12 +73,12 @@ public class Permission_PermissionsEx implements Permission {
}
@Override
public boolean hasPermission(Player player, String permission) {
public boolean playerHasPermission(Player player, String permission) {
return this.permission.has(player, permission);
}
@Override
public boolean inGroup(String worldName, String playerName, String groupName) {
public boolean playerInGroup(String worldName, String playerName, String groupName) {
//Try catch the check because we don't know if the objects will actually exist Good Job on the crap Permissions plugin, why do we support this again?
try {
PermissionUser[] userList = PermissionsEx.getPermissionManager().getGroup(groupName).getUsers();
@ -130,27 +130,27 @@ public class Permission_PermissionsEx implements Permission {
}
@Override
public int getUserInfoInteger(String world, String playerName, String node, int defaultValue) {
public int getPlayerInfoInteger(String world, String playerName, String node, int defaultValue) {
return PermissionsEx.getPermissionManager().getUser(playerName).getOptionInteger(node, world, defaultValue);
}
@Override
public double getUserInfoDouble(String world, String playerName, String node, double defaultValue) {
public double getPlayerInfoDouble(String world, String playerName, String node, double defaultValue) {
return PermissionsEx.getPermissionManager().getUser(playerName).getOptionDouble(node, world, defaultValue);
}
@Override
public boolean getUserInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
public boolean getPlayerInfoBoolean(String world, String playerName, String node, boolean defaultValue) {
return PermissionsEx.getPermissionManager().getUser(playerName).getOptionBoolean(node, world, defaultValue);
}
@Override
public String getUserInfoString(String world, String playerName, String node, String defaultValue) {
public String getPlayerInfoString(String world, String playerName, String node, String defaultValue) {
return PermissionsEx.getPermissionManager().getUser(playerName).getOption(node, world, defaultValue);
}
@Override
public boolean userAddGroup(String worldName, String playerName, String groupName) {
public boolean playerAddGroup(String worldName, String playerName, String groupName) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if(group == null || user == null) {
@ -162,7 +162,7 @@ public class Permission_PermissionsEx implements Permission {
}
@Override
public boolean userRemoveGroup(String worldName, String playerName, String groupName) {
public boolean playerRemoveGroup(String worldName, String playerName, String groupName) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if(group == null || user == null) {
@ -174,7 +174,7 @@ public class Permission_PermissionsEx implements Permission {
}
@Override
public boolean userAddPermission(String worldName, String playerName, String permission) {
public boolean playerAddPermission(String worldName, String playerName, String permission) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if(user == null) {
return false;
@ -185,7 +185,7 @@ public class Permission_PermissionsEx implements Permission {
}
@Override
public boolean userRemovePermission(String worldName, String playerName, String permission) {
public boolean playerRemovePermission(String worldName, String playerName, String permission) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if(user == null) {
return false;
@ -218,7 +218,7 @@ public class Permission_PermissionsEx implements Permission {
}
@Override
public void setUserInfoInteger(String world, String playerName, String node, int value) {
public void setPlayerInfoInteger(String world, String playerName, String node, int value) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if(user != null) {
user.setOption(node, String.valueOf(value), world);
@ -226,7 +226,7 @@ public class Permission_PermissionsEx implements Permission {
}
@Override
public void setUserInfoDouble(String world, String playerName, String node, double value) {
public void setPlayerInfoDouble(String world, String playerName, String node, double value) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if(user != null) {
user.setOption(node, String.valueOf(value), world);
@ -234,7 +234,7 @@ public class Permission_PermissionsEx implements Permission {
}
@Override
public void setUserInfoBoolean(String world, String playerName, String node, boolean value) {
public void setPlayerInfoBoolean(String world, String playerName, String node, boolean value) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if(user != null) {
user.setOption(node, String.valueOf(value), world);
@ -242,7 +242,7 @@ public class Permission_PermissionsEx implements Permission {
}
@Override
public void setUserInfoString(String world, String playerName, String node, String value) {
public void setPlayerInfoString(String world, String playerName, String node, String value) {
PermissionUser user = PermissionsEx.getPermissionManager().getUser(playerName);
if(user != null) {
user.setOption(node, String.valueOf(value), world);
@ -329,4 +329,14 @@ public class Permission_PermissionsEx implements Permission {
}
}
@Override
public boolean groupHasPermission(String worldName, String groupName, String permission) {
PermissionGroup group = PermissionsEx.getPermissionManager().getGroup(groupName);
if(group == null) {
return false;
} else {
return group.has(permission, worldName);
}
}
}