Search in sources :

Example 6 with PermissionGroup

use of de.dytanic.cloudnet.lib.player.permission.PermissionGroup in project CloudNet by Dytanic.

the class VaultPermissionImpl method groupAdd.

@Override
public boolean groupAdd(String s, String s1, String s2) {
    PermissionGroup permissionGroup = CloudAPI.getInstance().getPermissionGroup(s1);
    permissionGroup.getPermissions().put(s2, true);
    CloudAPI.getInstance().updatePermissionGroup(permissionGroup);
    return true;
}
Also used : PermissionGroup(de.dytanic.cloudnet.lib.player.permission.PermissionGroup)

Example 7 with PermissionGroup

use of de.dytanic.cloudnet.lib.player.permission.PermissionGroup in project CloudNet by Dytanic.

the class VaultPermissionImpl method groupRemove.

@Override
public boolean groupRemove(String s, String s1, String s2) {
    PermissionGroup permissionGroup = CloudAPI.getInstance().getPermissionGroup(s1);
    permissionGroup.getPermissions().remove(s2);
    CloudAPI.getInstance().updatePermissionGroup(permissionGroup);
    return true;
}
Also used : PermissionGroup(de.dytanic.cloudnet.lib.player.permission.PermissionGroup)

Example 8 with PermissionGroup

use of de.dytanic.cloudnet.lib.player.permission.PermissionGroup in project CloudNet by Dytanic.

the class ChatListener method handle.

@EventHandler
public void handle(AsyncPlayerChatEvent e) {
    PermissionGroup permissionGroup = permissionService ? CloudServer.getInstance().getCachedPlayer(e.getPlayer().getUniqueId()).getPermissionEntity().getHighestPermissionGroup(CloudAPI.getInstance().getPermissionPool()) : null;
    e.setFormat(ChatColor.translateAlternateColorCodes('&', ChatPlugin.getPlugin(ChatPlugin.class).getConfig().getString("format").replace("%display%", ChatColor.translateAlternateColorCodes('&', (permissionService ? permissionGroup.getDisplay() : ""))).replace("%prefix%", ChatColor.translateAlternateColorCodes('&', (permissionService ? permissionGroup.getPrefix() : ""))).replace("%suffix%", ChatColor.translateAlternateColorCodes('&', (permissionService ? permissionGroup.getSuffix() : ""))).replace("%group%", (permissionService ? permissionGroup.getName() : "")).replace("%player%", e.getPlayer().getName()).replace("%message%", e.getPlayer().hasPermission("cloudnet.chat.color") ? ChatColor.translateAlternateColorCodes('&', e.getMessage().replace("%", "%%")) : ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', e.getMessage().replace("%", "%%"))))));
}
Also used : PermissionGroup(de.dytanic.cloudnet.lib.player.permission.PermissionGroup) EventHandler(org.bukkit.event.EventHandler)

Example 9 with PermissionGroup

use of de.dytanic.cloudnet.lib.player.permission.PermissionGroup in project CloudNet by Dytanic.

the class ConfigPermissions method read.

public Map<String, PermissionGroup> read(Configuration configuration) {
    Map<String, PermissionGroup> maps = new LinkedHashMap<>();
    Configuration section = configuration.getSection("groups");
    for (String key : section.getKeys()) {
        Configuration group = section.getSection(key);
        HashMap<String, Boolean> permissions = new HashMap<>();
        List<String> permissionSection = group.getStringList("permissions");
        for (String entry : permissionSection) {
            permissions.put(entry.replaceFirst("-", ""), (!entry.startsWith("-")));
        }
        HashMap<String, List<String>> permissionsGroups = new HashMap<>();
        Configuration permissionSectionGroups = group.getSection("serverGroupPermissions");
        for (String entry : permissionSectionGroups.getKeys()) {
            permissionsGroups.put(entry, permissionSectionGroups.getStringList(entry));
        }
        PermissionGroup permissionGroup = new PermissionGroup(key, group.getString("prefix"), group.getString("suffix"), group.getString("display"), group.getInt("tagId"), group.getInt("joinPower"), group.getBoolean("defaultGroup"), permissions, permissionsGroups, group.getSection("options").self, group.getStringList("implements"));
        maps.put(permissionGroup.getName(), permissionGroup);
    }
    return maps;
}
Also used : YamlConfiguration(net.md_5.bungee.config.YamlConfiguration) Configuration(net.md_5.bungee.config.Configuration) PermissionGroup(de.dytanic.cloudnet.lib.player.permission.PermissionGroup) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 10 with PermissionGroup

use of de.dytanic.cloudnet.lib.player.permission.PermissionGroup in project CloudNet by Dytanic.

the class PacketInUpdatePermissionGroup method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    PermissionGroup permissionGroup = data.getObject("permissionGroup", new TypeToken<PermissionGroup>() {
    }.getType());
    PermissionModule.getInstance().getConfigPermission().updatePermissionGroup(permissionGroup);
    CloudNet.getInstance().getNetworkManager().reload();
    CloudNet.getInstance().getNetworkManager().updateAll0();
}
Also used : TypeToken(com.google.gson.reflect.TypeToken) PermissionGroup(de.dytanic.cloudnet.lib.player.permission.PermissionGroup)

Aggregations

PermissionGroup (de.dytanic.cloudnet.lib.player.permission.PermissionGroup)10 OfflinePlayer (de.dytanic.cloudnet.lib.player.OfflinePlayer)2 PermissionPool (de.dytanic.cloudnet.lib.player.permission.PermissionPool)2 TypeToken (com.google.gson.reflect.TypeToken)1 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)1 DefaultPermissionGroup (de.dytanic.cloudnet.lib.player.permission.DefaultPermissionGroup)1 GroupEntityData (de.dytanic.cloudnet.lib.player.permission.GroupEntityData)1 PacketOutUpdateOfflinePlayer (de.dytanic.cloudnetcore.network.packet.out.PacketOutUpdateOfflinePlayer)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 UUID (java.util.UUID)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Configuration (net.md_5.bungee.config.Configuration)1 YamlConfiguration (net.md_5.bungee.config.YamlConfiguration)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1