com.github.theholywaffle.teamspeak3.api.wrapper.Permission Maven / Gradle / Ivy
Show all versions of teamspeak3-api Show documentation
package com.github.theholywaffle.teamspeak3.api.wrapper;
/*
* #%L
* TeamSpeak 3 Java API
* %%
* Copyright (C) 2014 Bert De Geyter
* %%
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
* #L%
*/
import java.util.Map;
/**
* Describes a permission that has been assigned to a client,
* a channel group or a server group.
*
* For a complete description of the TS3 permission system, refer to
*
* this post on the TeamSpeak forums.
*
*/
public class Permission extends Wrapper {
public Permission(Map map) {
super(map);
}
/**
* Gets the name of this permission.
*
* Boolean permissions are prefixed with {@code b_}
* Integer permissions are prefixed with {@code i_}
*
*
* @return this permission's name
*/
public String getName() {
return get("permsid");
}
/**
* Gets the value of this permission assignment.
*
* Please note that this value doesn't necessarily have to be
* the effective permission value for a client, as this assignment
* can be overridden by another assignment.
*
* Integer permissions usually have values between 0 and 100,
* but any integer value is theoretically valid.
*
* Boolean permissions have a value of {@code 0} to represent
* {@code false} and {@code 1} to represent {@code true}.
*
*
* @return the value of this permission assignment
*/
public int getValue() {
return getInt("permvalue");
}
/**
* Returns {@code true} if this permission is negated.
*
* Negated means that instead of the highest value, the lowest
* value will be selected for this permission instead.
*
*
* @return whether this permission is negated or not
*/
public boolean isNegated() {
return getBoolean("permnegated");
}
/**
* Returns {@code true} if this permission is skipped.
*
* Skipped only exists for server group and client permissions,
* therefore this value will always be false for channel group permissions.
*
* If a client permission is skipped, it won't be overridden by channel
* group permissions.
* If a server group permission is skipped, it won't be overridden by
* channel group or client permissions.
*
*
* @return whether this permission is negated or not
*/
public boolean isSkipped() {
return getBoolean("permskip");
}
}