moved a few files to api folder

This commit is contained in:
DarkGuardsman 2013-09-18 09:21:47 -04:00
parent efc89bbbb6
commit 528e0f465b
3 changed files with 105 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -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<UserAccess> 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<UserAccess> getUsersWithAcess(AccessLevel level);
}

View file

@ -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<String> getTerminalOuput();
/** Adds a string to the console. Server side only. */
public boolean addToConsole(String msg);
}