示例#1
0
 public int GetMaxLimit() {
   limit = -1;
   PermissionsResolverManager p = PermissionsResolverManager.getInstance();
   if (p != null) {
     Player player = module.getPlugin().getServer().getPlayer(uuid);
     PermissionUser user = PermissionsEx.getUser(player);
     String[] groups = user.getGroupsNames(); // get all groups the player is in
     HashMap<String, Integer> m = module.GetMaxLimitRanks(); // get the rank keys.
     for (int g = 0; g < groups.length; g++) {
       String lowerG = groups[g].toLowerCase(); // lowercase to match anything ;3
       if (m.containsKey(lowerG)) {
         Integer li = m.get(lowerG);
         if (li == -1) { // if we find group with -1, don't bother with the rest.
           limit = li;
           return limit;
         }
         // get the highest limit from all groups.
         if (li > limit) { // if key is the same as a group the player is in, then compare if it is
           // higher.
           limit = li;
         }
       }
     }
   }
   // return -1 so all nonconfig ranks are unlimited.
   return limit;
 }
示例#2
0
  /** Called on plugin enable. */
  @Override
  public void onEnable() {
    final String pluginYmlVersion = getDescription().getVersion();
    final String manifestVersion = WorldEdit.getVersion();

    if (!manifestVersion.equalsIgnoreCase(pluginYmlVersion)) {
      WorldEdit.setVersion(manifestVersion + " (" + pluginYmlVersion + ")");
    }

    // Make the data folders that WorldEdit uses
    getDataFolder().mkdirs();

    // Create the default configuration file
    createDefaultConfiguration("config.yml");

    // Set up configuration and such, including the permissions
    // resolver
    config =
        new BukkitConfiguration(
            new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), this);
    PermissionsResolverManager.initialize(this);

    // Load the configuration
    config.load();

    // Setup interfaces
    server = new BukkitServerInterface(this, getServer());
    controller = new WorldEdit(server, config);
    WorldEdit.getInstance().logger.setParent(Bukkit.getLogger());
    api = new WorldEditAPI(this);
    getServer()
        .getMessenger()
        .registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this));
    getServer().getMessenger().registerOutgoingPluginChannel(this, CUI_PLUGIN_CHANNEL);
    // Now we can register events!
    getServer().getPluginManager().registerEvents(new WorldEditListener(this), this);

    getServer()
        .getScheduler()
        .scheduleAsyncRepeatingTask(this, new SessionTimer(controller, getServer()), 120, 120);
  }
 @Override
 public String[] getGroups() {
   return PermissionsResolverManager.getInstance().getGroups(player);
 }
 @Override
 public boolean hasGroup(String group) {
   return PermissionsResolverManager.getInstance().inGroup(player, group);
 }
示例#5
0
 /**
  * Get the permissions resolver in use.
  *
  * @return
  */
 public PermissionsResolverManager getPermissionsResolver() {
   return PermissionsResolverManager.getInstance();
 }