當前位置: 首頁>>代碼示例>>Java>>正文


Java Permission類代碼示例

本文整理匯總了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);
		}
	}
}
 
開發者ID:benfah,項目名稱:Bags2,代碼行數:27,代碼來源:CraftListener.java

示例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));
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:23,代碼來源:Lobby.java

示例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);
    });
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:18,代碼來源:NicknameCommands.java

示例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"));
		}
	}
}
 
開發者ID:Maximuspayne,項目名稱:NavyCraft2-Lite,代碼行數:22,代碼來源:PermissionInterface.java

示例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;
	}
}
 
開發者ID:OverloadedCore,項目名稱:behave,代碼行數:23,代碼來源:MainPart.java

示例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));
        }
    }
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:17,代碼來源:ChildPermissionProvider.java

示例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);
        }
    }
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:20,代碼來源:ChildPermissionProvider.java

示例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);
        }
    }
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:20,代碼來源:DefaultsProvider.java

示例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());
    }
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:18,代碼來源:LPPermissible.java

示例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());
    }
}
 
開發者ID:lucko,項目名稱:LuckPerms,代碼行數:18,代碼來源:LPPermissible.java

示例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();
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:16,代碼來源:UpdateChecker.java

示例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);
    }
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:10,代碼來源:DownloadableUpdateChecker.java

示例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);
    }
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:15,代碼來源:FunctionCommand.java

示例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;
}
 
開發者ID:upperlevel,項目名稱:uppercore,代碼行數:28,代碼來源:FunctionCommandParameter.java

示例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;
	}
}
 
開發者ID:benfah,項目名稱:Bags2,代碼行數:13,代碼來源:BagBase.java


注:本文中的org.bukkit.permissions.Permission類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。