Skip to content

Instantly share code, notes, and snippets.

@zhuowei
Forked from CruzBishop/Player.java
Created June 11, 2011 04:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhuowei/1020254 to your computer and use it in GitHub Desktop.
Save zhuowei/1020254 to your computer and use it in GitHub Desktop.
Permissions for Graham
import java.util.ArrayList;
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("*"))
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