diff --git a/src/dark/api/AccessLevel.java b/src/dark/api/AccessLevel.java new file mode 100644 index 000000000..50c9cbcc0 --- /dev/null +++ b/src/dark/api/AccessLevel.java @@ -0,0 +1,45 @@ +package dark.api; + +public enum AccessLevel +{ + NONE("None"), + BASIC("Basic"), + USER("Standard"), + ADMIN("Admin"), + OWNER("Owner"); + + public String displayName; + + private AccessLevel(String name) + { + displayName = name; + } + + /** Gets the access level in varies ways + * + * @return AccessLevel NONE instead of null if correct level can't be found. */ + public static AccessLevel get(Object ob) + { + if (ob instanceof String) + { + for (AccessLevel access : AccessLevel.values()) + { + if (access.displayName.equalsIgnoreCase((String) ob) || access.name().equalsIgnoreCase((String) ob)) + { + return access; + } + } + } + if (ob instanceof Integer) + { + int i = (Integer) ob; + + if (i >= 0 && i < AccessLevel.values().length) + { + return AccessLevel.values()[i]; + } + } + + return NONE; + } +} diff --git a/src/dark/api/ISpecialAccess.java b/src/dark/api/ISpecialAccess.java new file mode 100644 index 000000000..7f39ebe43 --- /dev/null +++ b/src/dark/api/ISpecialAccess.java @@ -0,0 +1,41 @@ +package dark.api; + +import java.util.List; + +import dark.core.prefab.access.UserAccess; + +/** Used by any object that needs to restrict access to it by a set of usernames + * + * @author DarkGuardsman */ +public interface ISpecialAccess +{ + /** Gets the player's access level on the machine he is using + * + * @return access level of the player, make sure to return no access if the player doesn't have + * any */ + public AccessLevel getUserAccess(String username); + + /** gets the access list for the machine + * + * @return hasMap of players and there access levels */ + public List getUsers(); + + /** sets the players access level in the access map + * + * @param player + * @return true if the level was set false if something went wrong */ + public boolean addUserAccess(String username, AccessLevel level, boolean save); + + /** Removes the user from the access list + * + * @param username + * @return */ + public boolean removeUserAccess(String username); + + /** Gets a list of users with this specified access level. + * + * @param level + * @return */ + List getUsersWithAcess(AccessLevel level); + +} diff --git a/src/dark/api/ITerminal.java b/src/dark/api/ITerminal.java new file mode 100644 index 000000000..d9e667fe4 --- /dev/null +++ b/src/dark/api/ITerminal.java @@ -0,0 +1,19 @@ +package dark.api; + +import java.util.List; + +import dark.core.interfaces.IScroll; + +/** Basic methods to make it easier to construct or interact with a terminal based tile. Recommend to + * be used by tiles that want to mimic computer command line like interfaces. As well to restrict + * access to the tile in the same way a computer would + * + * @author DarkGuardsmsan */ +public interface ITerminal extends ISpecialAccess, IScroll +{ + /** Gets an output of the string stored in the console. */ + public List getTerminalOuput(); + + /** Adds a string to the console. Server side only. */ + public boolean addToConsole(String msg); +}