本文整理匯總了Java中org.bukkit.permissions.Permission類的典型用法代碼示例。如果您正苦於以下問題:Java Permission類的具體用法?Java Permission怎麽用?Java Permission使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Permission類屬於org.bukkit.permissions包,在下文中一共展示了Permission類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCraft
import org.bukkit.permissions.Permission; //導入依賴的package包/類
@EventHandler
public void onCraft(CraftItemEvent e)
{
Player p = (Player) e.getWhoClicked();
if(e.getRecipe() instanceof ShapedRecipe)
{
ShapedRecipe sr = (ShapedRecipe) e.getRecipe();
if(Bukkit.getBukkitVersion().contains("1.11"))
{
for(BagBase bb : Util.getBags())
{
if(((ShapedRecipe)bb.getRecipe()).getShape().equals(sr.getShape()))
{
if(!hasPermission(new Permission("bag.craft." + bb.getName(), PermissionDefault.TRUE), p))
e.setCancelled(true);
}
}
}
else
if(sr.getKey().getNamespace().startsWith("bag_"))
{
if(!hasPermission(new Permission("bag.craft." + sr.getKey().getKey(), PermissionDefault.TRUE), p))
e.setCancelled(true);
}
}
}
示例2: onEnable
import org.bukkit.permissions.Permission; //導入依賴的package包/類
@Override
public void onEnable() {
// Ensure parsing errors show in the console on Lobby servers,
// since PGM is not around to do that.
mapdevLogger.setUseParentHandlers(true);
this.getServer().getPluginManager().registerEvents(new EnvironmentControlListener(), this);
this.getServer().getPluginManager().registerEvents(new Gizmos(), this);
this.getServer().getMessenger().registerOutgoingPluginChannel(this, BUNGEE_CHANNEL);
this.setupScoreboard();
this.loadConfig();
for(Gizmo gizmo : Gizmos.gizmos) {
Bukkit.getPluginManager().addPermission(new Permission(gizmo.getPermissionNode(), PermissionDefault.FALSE));
}
Settings settings = new Settings(this);
settings.register();
navigatorInterface.setOpenButtonSlot(Slot.Hotbar.forPosition(0));
}
示例3: enable
import org.bukkit.permissions.Permission; //導入依賴的package包/類
@Override
public void enable() {
final PermissionAttachment attachment = Bukkit.getConsoleSender().addAttachment(plugin);
Stream.of(
PERMISSION,
PERMISSION_GET,
PERMISSION_SET,
PERMISSION_ANY,
PERMISSION_ANY_GET,
PERMISSION_ANY_SET,
PERMISSION_IMMEDIATE
).forEach(name -> {
final Permission permission = new Permission(name, PermissionDefault.FALSE);
pluginManager.addPermission(permission);
attachment.setPermission(permission, true);
});
}
示例4: setupPermissions
import org.bukkit.permissions.Permission; //導入依賴的package包/類
public static void setupPermissions(NavyCraft p) {
plugin = p;
PluginManager pm = NavyCraft.instance.getServer().getPluginManager();
if(pm != null) {
pm.addPermission(new Permission("navycraft.periscope.use"));
pm.addPermission(new Permission("navycraft.aa-gun.use"));
pm.addPermission(new Permission("navycraft.periscope.create"));
pm.addPermission(new Permission("navycraft.aa-gun.create"));
for (CraftType type : CraftType.craftTypes)
{
pm.addPermission(new Permission("navycraft." + type.name + ".release"));
pm.addPermission(new Permission("navycraft." + type.name + ".info"));
pm.addPermission(new Permission("navycraft." + type.name + ".takeover"));
pm.addPermission(new Permission("navycraft." + type.name + ".start"));
pm.addPermission(new Permission("navycraft." + type.name + ".create"));
pm.addPermission(new Permission("navycraft." + type.name + ".sink"));
pm.addPermission(new Permission("navycraft." + type.name + ".remove"));
}
}
}
示例5: execBeh
import org.bukkit.permissions.Permission; //導入依賴的package包/類
private boolean execBeh(String beh){
String[] arr = beh.split(" ");
String cmd = arr[0];
String[] args = Arrays.copyOfRange(arr, 1, arr.length);
String argsas = "";
for(String a : args){
argsas = argsas + a + " ";
}
switch(cmd){
case "print":
getLogger().info(argsas);
return true;
case "addperm":
PluginManager pm = Bukkit.getServer().getPluginManager();
pm.addPermission(new Permission(argsas));
return true;
case "//":
return true;
default:
return false;
}
}
示例6: resolve
import org.bukkit.permissions.Permission; //導入依賴的package包/類
private static void resolve(ImmutableMap.Builder<Map.Entry<String, Boolean>, ImmutableMap<String, Boolean>> accumulator, Permission permission, boolean value) {
// accumulator for the child permissions being looked up
Map<String, Boolean> children = new HashMap<>();
// resolve children for the permission, so pass a map containing just the permission being looked up.
resolveChildren(children, Collections.singletonMap(permission.getName(), value), false);
// remove self
children.remove(permission.getName(), value);
// only register the children if there are any.
if (!children.isEmpty()) {
accumulator.put(Maps.immutableEntry(permission.getName().toLowerCase(), value), ImmutableMap.copyOf(children));
}
}
示例7: resolveChildren
import org.bukkit.permissions.Permission; //導入依賴的package包/類
private static void resolveChildren(Map<String, Boolean> accumulator, Map<String, Boolean> children, boolean invert) {
// iterate through the current known children.
// the first time this method is called for a given permission, the children map will contain only the permission itself.
for (Map.Entry<String, Boolean> e : children.entrySet()) {
if (accumulator.containsKey(e.getKey())) {
continue; // Prevent infinite loops
}
// xor the value using the parent (bukkit logic, not mine)
boolean value = e.getValue() ^ invert;
accumulator.put(e.getKey().toLowerCase(), value);
// lookup any deeper children & resolve if present
Permission perm = Bukkit.getServer().getPluginManager().getPermission(e.getKey());
if (perm != null) {
resolveChildren(accumulator, perm.getChildren(), !value);
}
}
}
示例8: calculateChildPermissions
import org.bukkit.permissions.Permission; //導入依賴的package包/類
private static void calculateChildPermissions(Map<String, Boolean> accumulator, DummyPermissible p, Map<String, Boolean> children, boolean invert) {
for (Map.Entry<String, Boolean> e : children.entrySet()) {
if (accumulator.containsKey(e.getKey())) {
continue; // Prevent infinite loops
}
// xor the value using the parent (bukkit logic, not mine)
boolean value = e.getValue() ^ invert;
accumulator.put(e.getKey().toLowerCase(), value);
pm().subscribeToPermission(e.getKey(), p);
// lookup any deeper children & resolve if present
Permission perm = pm().getPermission(e.getKey());
if (perm != null) {
calculateChildPermissions(accumulator, p, perm.getChildren(), !value);
}
}
}
示例9: isPermissionSet
import org.bukkit.permissions.Permission; //導入依賴的package包/類
@Override
public boolean isPermissionSet(Permission permission) {
if (permission == null) {
throw new NullPointerException("permission");
}
Tristate ts = this.user.getCachedData().getPermissionData(calculateContexts()).getPermissionValue(permission.getName(), CheckOrigin.PLATFORM_LOOKUP_CHECK);
if (ts != Tristate.UNDEFINED) {
return true;
}
if (!this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUKKIT_DEFAULT_PERMISSIONS)) {
return Permission.DEFAULT_PERMISSION.getValue(isOp());
} else {
return permission.getDefault().getValue(isOp());
}
}
示例10: hasPermission
import org.bukkit.permissions.Permission; //導入依賴的package包/類
@Override
public boolean hasPermission(Permission permission) {
if (permission == null) {
throw new NullPointerException("permission");
}
Tristate ts = this.user.getCachedData().getPermissionData(calculateContexts()).getPermissionValue(permission.getName(), CheckOrigin.PLATFORM_PERMISSION_CHECK);
if (ts != Tristate.UNDEFINED) {
return ts.asBoolean();
}
if (!this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUKKIT_DEFAULT_PERMISSIONS)) {
return Permission.DEFAULT_PERMISSION.getValue(isOp());
} else {
return permission.getDefault().getValue(isOp());
}
}
示例11: UpdateChecker
import org.bukkit.permissions.Permission; //導入依賴的package包/類
public UpdateChecker(Plugin plugin, String spigotFullId) {
this.plugin = plugin;
this.spigotId = spigotFullId;
try {
this.spigotUrl = new URL("https://www.spigotmc.org/resources/" + spigotId + "/");
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Invalid spigot id: " + spigotId);
}
this.logger = plugin.getLogger();
permission = new Permission(plugin.getName() + ".update");
permission.setDefault(PermissionDefault.OP);
Bukkit.getPluginManager().addPermission(permission);
setInterval(20*60*30);//30 minutes
message = buildMessage();
}
示例12: calcPermissions
import org.bukkit.permissions.Permission; //導入依賴的package包/類
@Override
public void calcPermissions() {
Permission perm = DownloadableUpdateChecker.this.getPermission();
if(perm != null) {
setPermission(perm);
if (getParent() != null)
perm.addParent(getParent().getAnyPerm(), true);
}
}
示例13: calculatePermissions
import org.bukkit.permissions.Permission; //導入依賴的package包/類
public void calculatePermissions() {
WithPermission perm = getClass().getAnnotation(WithPermission.class);
if (perm != null) {
String path;
if (parent != null) {
if (parent.getPermission() == null)
return;
path = parent.getPermission().getName() + '.' + perm.value();
} else path = perm.value();
permission = new Permission(path, perm.value(), perm.defaultPermission().get(this));
if (parent != null)
permission.addParent(parent.getAnyPerm(), true);
}
}
示例14: FunctionCommandParameter
import org.bukkit.permissions.Permission; //導入依賴的package包/類
public FunctionCommandParameter(FunctionCommand command, Parameter parameter) {
super(command);
WithName nameAnnotation = parameter.getAnnotation(WithName.class);
if (nameAnnotation != null) {
setName(nameAnnotation.value());
}
WithOptional optionalAnnotation = parameter.getAnnotation(WithOptional.class);
if (optionalAnnotation != null) {
setOptional(true);
setDefaultValue(optionalAnnotation.value());
}
WithPermission permissionAnnotation = parameter.getAnnotation(WithPermission.class);
if (permissionAnnotation != null) {
StringJoiner path = new StringJoiner(".");
if (command.getPermission() != null) {
path.add(command.getPermission().getName());
}
path.add(permissionAnnotation.value());
Permission permission = new Permission(path.toString());
if (command.getPermission() != null) {
permission.addParent(command.getPermission(), true);
}
permission.setDescription(permissionAnnotation.value());
setPermission(permission);
}
this.parameter = parameter;
}
示例15: hasPermission
import org.bukkit.permissions.Permission; //導入依賴的package包/類
public boolean hasPermission(Permission perm, Player p)
{
if(p.hasPermission(perm))
{
return true;
}
else
{
p.sendMessage(Translation.get("not_allowed"));
return false;
}
}