org.bukkit.permissions.PermissionDefault Java Examples

The following examples show how to use org.bukkit.permissions.PermissionDefault. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PGMConfig.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
private static Permission getPermission(
    ConfigurationSection config, String id, PermissionDefault def, String realm) {
  final Map<String, Boolean> permissions = new HashMap<>();

  for (String permission : config.getStringList(realm)) {
    if (permission.startsWith("-")) {
      permissions.put(permission.substring(1), false);
    } else if (permission.startsWith("+")) {
      permissions.put(permission.substring(1), true);
    } else {
      permissions.put(permission, true);
    }
  }

  final String node =
      Permissions.GROUP
          + "."
          + id
          + (realm.contains("-") ? "-" + realm.substring(0, realm.indexOf('-')) : "");

  return Permissions.register(new Permission(node, def, permissions));
}
 
Example #2
Source File: DefaultPermissions.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public static Permission registerPermission(Permission perm, boolean withLegacy) {
    Permission result = perm;

    try {
        Bukkit.getPluginManager().addPermission(perm);
    } catch (IllegalArgumentException ex) {
        result = Bukkit.getPluginManager().getPermission(perm.getName());
    }

    if (withLegacy) {
        Permission legacy = new Permission(LEGACY_PREFIX + result.getName(), result.getDescription(), PermissionDefault.FALSE);
        legacy.getChildren().put(result.getName(), true);
        registerPermission(perm, false);
    }

    return result;
}
 
Example #3
Source File: ResourcePackListener.java    From AdditionsAPI with MIT License 6 votes vote down vote up
@EventHandler
public void onResourcestatusChange(PlayerResourcePackStatusEvent event) {
	if (ResourcePackManager.getForceResourcePack()) {
		Status status = event.getStatus();
		switch (status) {
		case DECLINED:
		case FAILED_DOWNLOAD:
			final Player player = event.getPlayer();
			if (!player.hasPermission(new Permission("additionsapi.resourcepack.bypass", PermissionDefault.FALSE)))
				Bukkit.getServer().getScheduler().runTask(AdditionsAPI.getInstance(),
						() -> player.kickPlayer(LangFileUtils.get("resource_pack_kick")));
			break;
		case ACCEPTED:
		case SUCCESSFULLY_LOADED:
		default:
			break;
		}
	}
}
 
Example #4
Source File: CommandPermissions.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public static Permission registerPermissions(Permission parent) {
    Permission commands = DefaultPermissions.registerPermission(ROOT, "Gives the user the ability to use all vanilla minecraft commands", parent);

    DefaultPermissions.registerPermission(PREFIX + "kill", "Allows the user to commit suicide", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "me", "Allows the user to perform a chat action", PermissionDefault.TRUE, commands);
    DefaultPermissions.registerPermission(PREFIX + "tell", "Allows the user to privately message another player", PermissionDefault.TRUE, commands);
    DefaultPermissions.registerPermission(PREFIX + "say", "Allows the user to talk as the console", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "give", "Allows the user to give items to players", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "teleport", "Allows the user to teleport players", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "kick", "Allows the user to kick players", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "stop", "Allows the user to stop the server", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "list", "Allows the user to list all online players", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "gamemode", "Allows the user to change the gamemode of another player", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "xp", "Allows the user to give themselves or others arbitrary values of experience", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "toggledownfall", "Allows the user to toggle rain on/off for a given world", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "defaultgamemode", "Allows the user to change the default gamemode of the server", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "seed", "Allows the user to view the seed of the world", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "effect", "Allows the user to add/remove effects on players", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "selector", "Allows the use of selectors", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "trigger", "Allows the use of the trigger command", PermissionDefault.TRUE, commands);

    commands.recalculatePermissibles();
    return commands;
}
 
Example #5
Source File: GlobalWarming.java    From GlobalWarming with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Economy (soft-dependency on Vault)
 * - If a Vault-based economy was not found, disable the bounty system
 */
private void setupEconomy() {
    if (Bukkit.getPluginManager().getPlugin("Vault") != null) {
        RegisteredServiceProvider<Economy> economyProvider = Bukkit.getServicesManager().getRegistration(Economy.class);
        if (economyProvider != null) {
            economy = economyProvider.getProvider();
        }
    }

    if (economy == null) {
        instance.getLogger().warning("Bounty-system [disabled], Vault economy not found");
        for (Permission permission : Bukkit.getPluginManager().getDefaultPermissions(false)) {
            if (permission.getName().startsWith("globalwarming.bounty")) {
                Bukkit.getPluginManager().getPermission(permission.getName())
                        .setDefault(PermissionDefault.FALSE);
            }
        }
    } else {
        instance.getLogger().info("Bounty-system [enabled], Vault economy found");
    }
}
 
Example #6
Source File: NicknameCommands.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@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);
    });
}
 
Example #7
Source File: Lobby.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@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));
}
 
Example #8
Source File: JyCommandExecutor.java    From minecraft-python with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
	if (!(sender instanceof Player))
		return false;
	Player player = (Player) sender;
	Permission p = new Permission("chatcommands", PermissionDefault.FALSE);
	if (!player.hasPermission(p)) {
		plugin.send(player, ChatColor.RED + "You don't have permission to use this command");
		return false;
	}
	
	if (cmd.getName().equals("py") && sender instanceof Player && args.length > 0) {
		String command = argsToString(args);
		plugin.send(player, ChatColor.AQUA + command);
		commandServer.command(player, command);
		return true;
	} else if (cmd.getName().equals("pyrestart") && sender instanceof Player) {
		plugin.send(player, "Restarting Python. Please wait...");
		commandServer.setupInterpreter(player);
		plugin.send(player, "Done!\n");
		return true;
	} else if (cmd.getName().equals("pyload") && sender instanceof Player && args.length == 1) {
		File match = MinecraftPyServerUtils.matchPythonFile(args[0]);
		if (match != null) {
			plugin.send(player, "Executing file: " + match.getName());
			commandServer.file(player, match);
			return true;
		} else {
			plugin.send(player, "Sorry, couldn't find this Python file");
		}
	}
	return false;
}
 
Example #9
Source File: PGMConfig.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
public Group(ConfigurationSection config) throws TextException {
  this.id = config.getName();
  final String prefix = config.getString("prefix");
  this.prefix = prefix == null ? null : parseComponentLegacy(prefix);
  final PermissionDefault def =
      id.equalsIgnoreCase("op")
          ? PermissionDefault.OP
          : id.equalsIgnoreCase("default") ? PermissionDefault.TRUE : PermissionDefault.FALSE;
  this.permission = getPermission(config, id, def, "permissions");
  this.observerPermission =
      getPermission(config, id, PermissionDefault.FALSE, "observer-permissions");
  this.participantPermission =
      getPermission(config, id, PermissionDefault.FALSE, "participant-permissions");
}
 
Example #10
Source File: RandomTeleport.java    From RandomTeleport with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add an option parser to this plugin
 * @param parser The parser to add
 */
public void addOptionParser(OptionParser parser) {
    optionParsers.add(parser);
    if (parser instanceof SimpleOptionParser) {
        Permission parent = getServer().getPluginManager().getPermission("randomteleport.manual.option.*");
        for (String alias : ((SimpleOptionParser) parser).getAliases()) {
            Permission perm = new Permission("randomteleport.manual.option." + alias, PermissionDefault.OP);
            perm.addParent(parent, true);
            try {
                getServer().getPluginManager().addPermission(perm);
            } catch (IllegalArgumentException ignored) {} // duplicate
        }
    }
}
 
Example #11
Source File: WorldResourcepacks.java    From ResourcepacksPlugins with GNU General Public License v3.0 5 votes vote down vote up
private void registerPackPermission(ResourcePack pack) {
    if (getServer().getPluginManager().getPermission(pack.getPermission()) == null) {
        Permission perm = new Permission(pack.getPermission());
        perm.setDefault(PermissionDefault.OP);
        perm.setDescription("Permission for access to the resourcepack " + pack.getName() + " via the usepack command and automatic sending.");
        try {
            getServer().getPluginManager().addPermission(perm);
        } catch (IllegalArgumentException ignored) {} // Permission already registered
    }
    for (ResourcePack variant : pack.getVariants()) {
        registerPackPermission(variant);
    }
}
 
Example #12
Source File: ListenerCombatChecks.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private boolean canBypass(Player player) {
    if(player == null) return false;

    FileConfiguration config = this.plugin.getConfig("config.yml");
    String bypassPermission = config.getString("combat.bypass-permission");
    if(bypassPermission == null || bypassPermission.isEmpty()) return false;
    
    Permission permission = new Permission(bypassPermission, "Bypass permission for CombatLogX.", PermissionDefault.FALSE);
    return player.hasPermission(permission);
}
 
Example #13
Source File: ConfigurableKit.java    From AnnihilationPro with MIT License 5 votes vote down vote up
@Override
public boolean Initialize()
{
	//TODO------Change all the class instances to use this one instance instead of KitConfig.getInstance()
	instance = KitConfig.getInstance();
	int x = 0;
	ConfigurationSection sec = instance.getKitSection(getInternalName());
	if(sec == null)
	{
		sec = instance.createKitSection(getInternalName());
		x++;
	}
	
	x += ConfigManager.setDefaultIfNotSet(sec, "Name", getInternalName());
	x += ConfigManager.setDefaultIfNotSet(sec, "Kit Description", getDefaultDescription());
	x += ConfigManager.setDefaultIfNotSet(sec, "Disable", false);
	x += ConfigManager.setDefaultIfNotSet(sec, "Free", false);
	x += setDefaults(sec);
	
	if(x > 0)
		instance.saveConfig();
	
	this.isFree = sec.getBoolean("Free");
	
	if(sec.getBoolean("Disable"))
		return false;
	
	loadKitStuff(sec);
	if(instance.useDefaultPermissions())
	{
		Permission perm = new Permission("Anni.Kits."+getName());
		perm.setDefault(PermissionDefault.FALSE);
		Bukkit.getPluginManager().addPermission(perm);
		perm.recalculatePermissibles();
	}
	icon = getIcon();
	setUp();
	this.loadout = getFinalLoadout().addNavCompass().finalizeLoadout();
	return true;
}
 
Example #14
Source File: ResourcePackListener.java    From AdditionsAPI with MIT License 5 votes vote down vote up
public static void sendResourcePack(Player player, String hostAddress) {
	Bukkit.getServer().getScheduler().runTaskLater(AdditionsAPI.getInstance(), () -> {
		if (ResourcePackManager.hasResource()
				&& ConfigFile.getInstance().getConfig().getBoolean("resource-pack.send-to-player")
				&& !player.hasPermission(
						new Permission("additionsapi.resourcepack.disable", PermissionDefault.FALSE))) {
			String link;
			if (!ConfigFile.getInstance().getConfig().getBoolean("resource-pack.use-minepack")) {
				if (hostAddress != null && hostAddress.equals("127.0.0.1")) {
					link = "http://" + ResourcePackServer.localhost + ":" + ResourcePackServer.port
							+ ResourcePackServer.path;
				} else {
					link = "http://" + ResourcePackServer.host + ":" + ResourcePackServer.port
							+ ResourcePackServer.path;
				}
			} else {
				link = MinePackInitializationMethod.resourcePack;
			}
			if (player != null && player.isOnline())
				if (ResourcePackManager.hasSendWithHash)
					try {
						player.setResourcePack(link, ResourcePackManager.resourcePackSha1Byte);
					} catch (NoSuchMethodError e) {
						ResourcePackManager.hasSendWithHash = false;
						player.setResourcePack(link);
					}
				else
					player.setResourcePack(link);

			Debug.saySuper("Sending Resource Pack Link to Player: " + link);
		}
	}, 20L);
}
 
Example #15
Source File: PermissionGroupListener.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
private boolean updatePermission(String name, Map<String, Boolean> before, Map<String, Boolean> after) {
    if(Objects.equals(before, after)) return false;

    final Permission perm = new Permission(name, PermissionDefault.FALSE, after);
    pluginManager.removePermission(perm);
    pluginManager.addPermission(perm);
    return true;
}
 
Example #16
Source File: RaindropManifest.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void configure() {
    requestStaticInjection(RaindropUtil.class);

    new PluginFacetBinder(binder())
        .register(RaindropCommands.class);

    final PermissionBinder permissions = new PermissionBinder(binder());
    for(int i = RaindropConstants.MULTIPLIER_MAX; i > 0; i = i - RaindropConstants.MULTIPLIER_INCREMENT) {
        permissions.bindPermission().toInstance(new Permission("raindrops.multiplier." + i, PermissionDefault.FALSE));
    }
}
 
Example #17
Source File: ChannelMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@Inject ChannelMatchModule(Match match, Plugin plugin) {
    this.matchListeningPermission = new Permission("pgm.chat.all." + match.getId() + ".receive", PermissionDefault.FALSE);

    final OnlinePlayerMapAdapter<Boolean> map = new OnlinePlayerMapAdapter<>(plugin);
    map.enable();
    this.teamChatters = new DefaultMapAdapter<>(map, true, false);
}
 
Example #18
Source File: TCommandHandler.java    From TabooLib with MIT License 5 votes vote down vote up
/**
 * 向服务端注册 BaseMainCommand 类
 *
 * @param command         命令全称(需在 plugin.yml 内注册)
 * @param baseMainCommand 命令对象
 * @return {@link BaseMainCommand}
 */
public static BaseMainCommand registerCommand(BaseCommand tCommand, String command, BaseMainCommand baseMainCommand, Plugin plugin) {
    if (Bukkit.getPluginCommand(command) == null) {
        String permission = tCommand.permission();
        if (tCommand.permissionDefault() == PermissionDefault.TRUE || tCommand.permissionDefault() == PermissionDefault.NOT_OP) {
            if (permission == null || permission.isEmpty()) {
                permission = plugin.getName().toLowerCase() + ".command.use";
            }
            if (Bukkit.getPluginManager().getPermission(permission) != null) {
                try {
                    Permission p = new Permission(permission, tCommand.permissionDefault());
                    Bukkit.getPluginManager().addPermission(p);
                    Bukkit.getPluginManager().recalculatePermissionDefaults(p);
                } catch (Throwable t) {
                    t.printStackTrace();
                }
            }
        }
        registerPluginCommand(
                plugin,
                command,
                ArrayUtil.skipEmpty(tCommand.description(), "Registered by TabooLib."),
                ArrayUtil.skipEmpty(tCommand.usage(), "/" + command),
                ArrayUtil.skipEmpty(ArrayUtil.asList(tCommand.aliases()), new ArrayList<>()),
                ArrayUtil.skipEmpty(tCommand.permission()),
                ArrayUtil.skipEmpty(tCommand.permissionMessage()),
                baseMainCommand,
                baseMainCommand);
    }
    return BaseMainCommand.createCommandExecutor(command, baseMainCommand);
}
 
Example #19
Source File: CommandPermissions.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public static Permission registerPermissions(Permission parent) {
    Permission commands = DefaultPermissions.registerPermission(ROOT, "Gives the user the ability to use all CraftBukkit commands", parent);

    DefaultPermissions.registerPermission(PREFIX + "help", "Allows the user to view the vanilla help menu", PermissionDefault.TRUE, commands);
    DefaultPermissions.registerPermission(PREFIX + "plugins", "Allows the user to view the list of plugins running on this server", PermissionDefault.TRUE, commands);
    DefaultPermissions.registerPermission(PREFIX + "reload", "Allows the user to reload the server settings", PermissionDefault.OP, commands);
    DefaultPermissions.registerPermission(PREFIX + "version", "Allows the user to view the version of the server", PermissionDefault.TRUE, commands);

    commands.recalculatePermissibles();
    return commands;
}
 
Example #20
Source File: SimplePluginManager.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
private void calculatePermissionDefault(Permission perm, boolean dirty) {
    if ((perm.getDefault() == PermissionDefault.OP) || (perm.getDefault() == PermissionDefault.TRUE)) {
        defaultPerms.get(true).add(perm);
        if (dirty) {
            dirtyPermissibles(true);
        }
    }
    if ((perm.getDefault() == PermissionDefault.NOT_OP) || (perm.getDefault() == PermissionDefault.TRUE)) {
        defaultPerms.get(false).add(perm);
        if (dirty) {
            dirtyPermissibles(false);
        }
    }
}
 
Example #21
Source File: ChannelMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
protected Permission createChannelPermission(Party party) {
    Permission permission = new Permission("pgm.chat.team." + this.match.getId() + '-' + party.hashCode() + ".receive", PermissionDefault.FALSE);
    getMatch().getPluginManager().addPermission(permission);
    permission.addParent(matchListeningPermission, true);
    return permission;
}
 
Example #22
Source File: CraftDefaultPermissions.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static void registerCorePermissions() {
    Permission parent = DefaultPermissions.registerPermission(ROOT, "Gives the user the ability to use all vanilla utilities and commands");
    CommandPermissions.registerPermissions(parent);
    DefaultPermissions.registerPermission(ROOT + ".autocraft", "Gives the user the ability to use autocraft functionality", PermissionDefault.OP, parent);
    parent.recalculatePermissibles();
}
 
Example #23
Source File: AdminChannel.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Inject AdminChannel(ConsoleCommandSender console, OnlinePlayers players, SettingManagerProvider settings) {
    super(FORMAT, BROADCAST_FORMAT, new Permission(PERM_RECEIVE, PermissionDefault.OP));
    this.players = players;
    this.settings = settings;
    this.console = console;
}
 
Example #24
Source File: DefaultPermissions.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static Permission registerPermission(String name, String desc, PermissionDefault def, Map<String, Boolean> children, Permission parent) {
    Permission perm = registerPermission(name, desc, def, children);
    parent.getChildren().put(perm.getName(), true);
    return perm;
}
 
Example #25
Source File: GroupData.java    From NametagEdit with GNU General Public License v3.0 4 votes vote down vote up
public void setPermission(String permission) {
    this.permission = permission;
    bukkitPermission = new Permission(permission, PermissionDefault.FALSE);
}
 
Example #26
Source File: DataDownloader.java    From NametagEdit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void run() {
    HashMap<String, String> settings = new HashMap<>();
    List<GroupData> groupDataUnordered = new ArrayList<>();
    final Map<UUID, PlayerData> playerData = new HashMap<>();

    try (Connection connection = hikari.getConnection()) {
        ResultSet results = connection.prepareStatement("SELECT `name`, `prefix`, `suffix`, `permission`, `priority` FROM " + DatabaseConfig.TABLE_GROUPS).executeQuery();

        while (results.next()) {
            groupDataUnordered.add(new GroupData(
                    results.getString("name"),
                    results.getString("prefix"),
                    results.getString("suffix"),
                    results.getString("permission"),
                    new Permission(results.getString("permission"), PermissionDefault.FALSE),
                    results.getInt("priority")
            ));
        }

        PreparedStatement select = connection.prepareStatement("SELECT `uuid`, `prefix`, `suffix`, `priority` FROM " + DatabaseConfig.TABLE_PLAYERS + " WHERE uuid=?");
        for (UUID uuid : players) {
            select.setString(1, uuid.toString());
            results = select.executeQuery();
            if (results.next()) {
                playerData.put(uuid, new PlayerData(
                        "",
                        uuid,
                        Utils.format(results.getString("prefix"), true),
                        Utils.format(results.getString("suffix"), true),
                        results.getInt("priority")
                ));
            }
        }

        results = connection.prepareStatement("SELECT `setting`,`value` FROM " + DatabaseConfig.TABLE_CONFIG).executeQuery();
        while (results.next()) {
            settings.put(results.getString("setting"), results.getString("value"));
        }

        select.close();
        results.close();
    } catch (SQLException e) {
        e.printStackTrace();
    } finally {
        // First order the groups before performing assignments
        String orderSetting = settings.get("order");
        if (orderSetting != null) {
            String[] order = orderSetting.split(" ");
            // This will be the order we will use
            List<GroupData> current = new ArrayList<>();
            // Determine order for current loaded groups
            for (String group : order) {
                Iterator<GroupData> itr = groupDataUnordered.iterator();
                while (itr.hasNext()) {
                    GroupData groupData = itr.next();
                    if (groupData.getGroupName().equalsIgnoreCase(group)) {
                        current.add(groupData);
                        itr.remove();
                        break;
                    }
                }
            }

            current.addAll(groupDataUnordered); // Add remaining entries (bad order, wasn't specified)
            groupDataUnordered = current; // Reassign the new group order
        }

        handler.assignData(groupDataUnordered, playerData); // Safely perform assignments
        new BukkitRunnable() {
            @Override
            public void run() {
                for (Player player : Utils.getOnline()) {
                    PlayerData data = playerData.get(player.getUniqueId());
                    if (data != null) {
                        data.setName(player.getName());
                    }
                }

                handler.applyTags();
            }
        }.runTask(handler.getPlugin());
    }
}
 
Example #27
Source File: DefaultPermissions.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static Permission registerPermission(String name, String desc, PermissionDefault def, Map<String, Boolean> children) {
    Permission perm = registerPermission(new Permission(name, desc, def, children));
    return perm;
}
 
Example #28
Source File: DefaultPermissions.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static Permission registerPermission(String name, String desc, PermissionDefault def, Permission parent) {
    Permission perm = registerPermission(name, desc, def);
    parent.getChildren().put(perm.getName(), true);
    return perm;
}
 
Example #29
Source File: DefaultPermissions.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static Permission registerPermission(String name, String desc, PermissionDefault def) {
    Permission perm = registerPermission(new Permission(name, desc, def));
    return perm;
}
 
Example #30
Source File: Main.java    From ce with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void writePermissions() {
    Permission mainNode = new Permission("ce.*", "The main permission node for Custom Enchantments.", PermissionDefault.OP);

    Permission runecrafting = new Permission("ce.runecrafting", "The permission for Runecrafting.", PermissionDefault.OP);
    runecrafting.addParent(mainNode, true);

    Permission cmdNode = new Permission("ce.cmd.*", "The permission node for CE's commands.", PermissionDefault.OP);
    Permission enchNode = new Permission("ce.ench.*", "The permission node for CE's EnchantManager.getEnchantments().", PermissionDefault.OP);
    Permission itemNode = new Permission("ce.item.*", "The permission node for CE's  items.", PermissionDefault.OP);

    cmdNode.addParent(mainNode, true);
    enchNode.addParent(mainNode, true);
    itemNode.addParent(mainNode, true);

    Permission cmdMenu = new Permission("ce.cmd.menu", "The permission for the CE command 'menu'");
    Permission cmdList = new Permission("ce.cmd.reload", "The permission for the CE command 'reload'");
    Permission cmdGive = new Permission("ce.cmd.give", "The permission for the CE command 'give'");
    Permission cmdChange = new Permission("ce.cmd.change", "The permission for the CE command 'change'");
    Permission cmdEnchant = new Permission("ce.cmd.enchant", "The permission for the CE command 'enchant'");
    Permission cmdRunecraft = new Permission("ce.cmd.runecrafting", "The permission for the CE command 'runecrafting'");

    cmdMenu.addParent(cmdNode, true);
    cmdList.addParent(cmdNode, true);
    cmdGive.addParent(cmdNode, true);
    cmdChange.addParent(cmdNode, true);
    cmdEnchant.addParent(cmdNode, true);
    cmdRunecraft.addParent(cmdNode, true);

    Bukkit.getServer().getPluginManager().addPermission(mainNode);

    Bukkit.getServer().getPluginManager().addPermission(runecrafting);

    Bukkit.getServer().getPluginManager().addPermission(cmdNode);
    Bukkit.getServer().getPluginManager().addPermission(enchNode);
    Bukkit.getServer().getPluginManager().addPermission(itemNode);

    Bukkit.getServer().getPluginManager().addPermission(cmdMenu);
    Bukkit.getServer().getPluginManager().addPermission(cmdList);
    Bukkit.getServer().getPluginManager().addPermission(cmdGive);
    Bukkit.getServer().getPluginManager().addPermission(cmdChange);
    Bukkit.getServer().getPluginManager().addPermission(cmdEnchant);
    Bukkit.getServer().getPluginManager().addPermission(cmdRunecraft);

    for (CItem ci : items) {
        Permission itemTemp = new Permission("ce.item." + ci.getPermissionName(), "The permission for the CE Item '" + ci.getOriginalName() + "'.");
        itemTemp.addParent(itemNode, true);
        Bukkit.getServer().getPluginManager().addPermission(itemTemp);
    }

    for (CEnchantment ce : EnchantManager.getEnchantments()) {
        Permission enchTemp = new Permission("ce.ench." + ce.getPermissionName(), "The permission for the CE Enchantment '" + ce.getOriginalName() + "'.");
        enchTemp.addParent(enchNode, true);
        Bukkit.getServer().getPluginManager().addPermission(enchTemp);
    }

}