Skip to content

Instantly share code, notes, and snippets.

@CruzBishop
Created June 11, 2011 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save CruzBishop/1020218 to your computer and use it in GitHub Desktop.
Save CruzBishop/1020218 to your computer and use it in GitHub Desktop.
Permissions for Graham
public class Player extends LivingEntity {
private ArrayList<String> permissions = new ArrayList<String>();
//(Load the permissions, of course. I used Json and Yaml in two projects, but I'm sure you'll have something better)
public boolean hasPermission(string requestedPermission) {
if (permissions.contains("*")) //Is this correct in Java? I think it might be a fragment of C#
return true;
for (string permission : this.permissions) {
if (permission.startsWith(requestedPermission))
return true;
}
return false;
}
//And your other code, of course
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment