org.bukkit.configuration.file.YamlConfiguration Java Examples

The following examples show how to use org.bukkit.configuration.file.YamlConfiguration. 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: McStatsMetrics.java    From BedwarsRel with GNU General Public License v3.0 6 votes vote down vote up
public McStatsMetrics(final Plugin plugin) throws IOException {
  if (plugin == null) {
    throw new IllegalArgumentException("Plugin cannot be null");
  }

  this.plugin = plugin;

  // load the config
  configurationFile = getConfigFile();
  configuration = YamlConfiguration.loadConfiguration(configurationFile);

  // add some defaults
  configuration.addDefault("opt-out", false);
  configuration.addDefault("guid", UUID.randomUUID().toString());
  configuration.addDefault("debug", false);

  // Do we need to create the file?
  if (configuration.get("guid", null) == null) {
    configuration.options().header("http://mcstats.org").copyDefaults(true);
    configuration.save(configurationFile);
  }

  // Load the guid then
  guid = configuration.getString("guid");
  debug = configuration.getBoolean("debug", false);
}
 
Example #2
Source File: TrMenuLoader.java    From TrMenu with MIT License 6 votes vote down vote up
private void updateConfig() {
    TConfig oldCfg = TrMenu.SETTINGS;
    YamlConfiguration newCfg = YamlConfiguration.loadConfiguration(new InputStreamReader(TrMenu.getPlugin().getResource("settings.yml")));
    if (newCfg.getInt("CONFIG-VERSION") == TrMenu.SETTINGS.getInt("CONFIG-VERSION")) {
        return;
    }
    oldCfg.set("CONFIG-VERSION", newCfg.getInt("CONFIG-VERSION"));
    oldCfg.getKeys(true).forEach(key -> {
        if (!newCfg.contains(key)) {
            oldCfg.set(key, null);
        }
    });
    newCfg.getKeys(true).forEach(key -> {
        if (!oldCfg.contains(key)) {
            oldCfg.set(key, newCfg.get(key));
        }
    });
    oldCfg.saveToFile();
}
 
Example #3
Source File: MCStats.java    From FunnyGuilds with Apache License 2.0 6 votes vote down vote up
public MCStats(Plugin plugin) throws IOException {
    if (plugin == null) {
        throw new IllegalArgumentException("Plugin cannot be null");
    }

    this.plugin = plugin;

    // load the config
    configurationFile = getConfigFile();
    configuration = YamlConfiguration.loadConfiguration(configurationFile);

    // add some defaults
    configuration.addDefault("opt-out", false);
    configuration.addDefault("guid", UUID.randomUUID().toString());
    configuration.addDefault("debug", false);

    // Do we need to create the file?
    if (configuration.get("guid", null) == null) {
        configuration.options().header("http://mcstats.org").copyDefaults(true);
        configuration.save(configurationFile);
    }

    // Load the guid then
    guid = configuration.getString("guid");
    debug = configuration.getBoolean("debug", false);
}
 
Example #4
Source File: UCConfig.java    From UltimateChat with GNU General Public License v3.0 6 votes vote down vote up
private static YamlConfiguration updateFile(File saved) {
    YamlConfiguration finalyml = new YamlConfiguration();
    YamlConfiguration tempProts = new YamlConfiguration();
    try {
        finalyml.load(saved);

        tempProts.load(new InputStreamReader(UChat.get().getResource("assets/ultimatechat/protections.yml"), StandardCharsets.UTF_8));
    } catch (Exception e) {
        e.printStackTrace();
    }

    for (String key : tempProts.getKeys(true)) {
        Object obj = tempProts.get(key);
        if (finalyml.get(key) != null) {
            obj = finalyml.get(key);
        }
        finalyml.set(key, obj);
    }
    return finalyml;
}
 
Example #5
Source File: ExploitFixer.java    From ExploitFixer with GNU General Public License v3.0 6 votes vote down vote up
public void reload() {
	final Server server = getServer();

	server.getMessenger().unregisterIncomingPluginChannel(this);

	createConfigurations();

	final YamlConfiguration configYml = this.configurationUtil.getConfiguration("%datafolder%/config.yml");
	final YamlConfiguration messagesYml = this.configurationUtil.getConfiguration("%datafolder%/messages.yml");
	final YamlConfiguration spigotYml = this.configurationUtil.getConfiguration("%datafolder%/../spigot.yml");

	moduleManager.reload(configYml, messagesYml, spigotYml);

	registerCommands();
	registerListeners();

	if (checkHamsterAPI()) {
		registerHamsterApi();
	}
}
 
Example #6
Source File: ListenerLogin.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
private void punish(Player player) {
    if(player == null) return;

    NPCManager npcManager = this.expansion.getNPCManager();
    YamlConfiguration data = npcManager.getData(player);
    if(!data.getBoolean("citizens-compatibility.punish-next-join")) return;
    
    Logger logger = this.expansion.getLogger();
    logger.info("Player Data Config: " + data.saveToString());
    
    npcManager.loadLocation(player);
    double health = npcManager.loadHealth(player);
    
    if(health > 0.0D) {
        npcManager.loadInventory(player);
        npcManager.loadTagStatus(player);
    }
    
    data.set("citizens-compatibility.punish-next-join", false);
    data.set("citizens-compatibility.last-location", null);
    data.set("citizens-compatibility.last-health", null);
    data.set("citizens-compatibility.last-inventory", null);
    data.set("citizens-compatibility.last-armor", null);
    npcManager.setData(player, data);
}
 
Example #7
Source File: CommandListener.java    From Carbon with GNU Lesser General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
  FileConfiguration spigot = YamlConfiguration.loadConfiguration(new File(Bukkit.getServer().getWorldContainer(), "spigot.yml"));
  if (event.getMessage().equalsIgnoreCase("/reload") && event.getPlayer().hasPermission("bukkit.command.reload")) {
    // Restarts server if server is set up for it.
    if (spigot.getBoolean("settings.restart-on-crash")) {
      Bukkit.getLogger().severe("[Carbon] Restarting server due to reload command!");
      Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "restart");
    } else {
      // Call to server shutdown on disable.
      // Won't hurt if server already disables itself, but will prevent plugin unload/reload.
      Bukkit.getLogger().severe("[Carbon] Stopping server due to reload command!");
      Bukkit.shutdown();
    }
  }
  }
 
Example #8
Source File: GuildHandler.java    From Guilds with MIT License 6 votes vote down vote up
/**
 * Load all the roles
 */
private void loadRoles() {
    final YamlConfiguration conf = YamlConfiguration.loadConfiguration(new File(guildsPlugin.getDataFolder(), "roles.yml"));
    final ConfigurationSection roleSec = conf.getConfigurationSection("roles");

    for (String s : roleSec.getKeys(false)) {
        final String path = s + ".permissions.";
        final String name = roleSec.getString(s + ".name");
        final String perm = roleSec.getString(s + ".permission-node");
        final int level = Integer.parseInt(s);

        final GuildRole role = new GuildRole(name, perm, level);

        for (GuildRolePerm rolePerm: GuildRolePerm.values()) {
            final String valuePath = path + rolePerm.name().replace("_", "-").toLowerCase();
            if (roleSec.getBoolean(valuePath)) {
                role.addPerm(rolePerm);
            }
        }
        this.roles.add(role);
    }
}
 
Example #9
Source File: CommentedYaml.java    From ScoreboardStats with MIT License 6 votes vote down vote up
/**
 * Gets the YAML file configuration from the disk while loading it
 * explicit with UTF-8. This allows umlauts and other UTF-8 characters
 * for all Bukkit versions.
 * <p>
 * Bukkit add also this feature since
 * https://github.com/Bukkit/Bukkit/commit/24883a61704f78a952e948c429f63c4a2ab39912
 * To be allow the same feature for all Bukkit version, this method was
 * created.
 *
 * @return the loaded file configuration
 */
public FileConfiguration getConfigFromDisk() {
    Path file = dataFolder.resolve(FILE_NAME);

    YamlConfiguration newConf = new YamlConfiguration();
    newConf.setDefaults(getDefaults());
    try {
        //UTF-8 should be available on all java running systems
        List<String> lines = Files.readAllLines(file);
        load(lines, newConf);
    } catch (InvalidConfigurationException | IOException ex) {
        logger.error("Couldn't load the configuration", ex);
    }

    return newConf;
}
 
Example #10
Source File: GunYMLLoader.java    From QualityArmory with GNU General Public License v3.0 6 votes vote down vote up
public static void loadGuns(QAMain main) {
	if (new File(main.getDataFolder(), "newGuns").exists()) {
		int items = 0;
		for (File f : new File(main.getDataFolder(), "newGuns").listFiles()) {
			FileConfiguration f2 = YamlConfiguration.loadConfiguration(f);
			if (CrackshotLoader.isCrackshotGun(f2)) {
				main.getLogger().info("-Converting Crackshot: " + f.getName());
				List<Gun> guns = CrackshotLoader.loadCrackshotGuns(f2);
				CrackshotLoader.createYMLForGuns(guns, main.getDataFolder());
				continue;
			}
			loadGuns(main, f);
			items++;
		}
		if(!QAMain.verboseLoadingLogging)
			main.getLogger().info("-Loaded "+items+" Gun types.");
	}
}
 
Example #11
Source File: Messaging.java    From SkyWarsReloaded with GNU General Public License v3.0 6 votes vote down vote up
public Messaging(Plugin plugin) {
    File storageFile = new File(plugin.getDataFolder(), "messages.yml");

    if (!storageFile.exists()) {
        plugin.saveResource("messages.yml", false);
    }

    copyDefaults(storageFile);
    storage = YamlConfiguration.loadConfiguration(storageFile);
}
 
Example #12
Source File: CustomGunItem.java    From QualityArmory with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void initIronsights(File dataFolder) {
	File ironsights = new File(dataFolder, "default_ironsightstoggleitem.yml");
	YamlConfiguration ironconfig = YamlConfiguration.loadConfiguration(ironsights);
	if (!ironconfig.contains("displayname")) {
		ironconfig.set("material", Material.CROSSBOW.name());
		ironconfig.set("id", 68);
		ironconfig.set("displayname", IronsightsHandler.ironsightsDisplay);
		try {
			ironconfig.save(ironsights);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	IronsightsHandler.ironsightsMaterial = Material.matchMaterial(ironconfig.getString("material"));
	IronsightsHandler.ironsightsData = ironconfig.getInt("id");
	IronsightsHandler.ironsightsDisplay = ironconfig.getString("displayname");

}
 
Example #13
Source File: TownManager.java    From Civs with GNU General Public License v3.0 6 votes vote down vote up
public void loadAllTowns() {
    File townFolder = new File(Civs.dataLocation, "towns");
    if (!townFolder.exists()) {
        townFolder.mkdir();
    }
    try {
        for (File file : townFolder.listFiles()) {
            FileConfiguration config = new YamlConfiguration();
            try {
                config.load(file);

                loadTown(config);
            } catch (Exception e) {
                Civs.logger.warning("Unable to read from towns/" + file.getName());
                e.printStackTrace();
            }
        }
    } catch (NullPointerException npe) {
        Civs.logger.severe("Unable to read from town folder!");
    }
}
 
Example #14
Source File: ConfigLoader.java    From StackMob-3 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean updateConfig(){
    // Get the latest version of the file from the jar.
    InputStream is = sm.getResource(filename +  ".yml");
    BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
    FileConfiguration includedFile = YamlConfiguration.loadConfiguration(reader);
    // Load a copy of the current file to check for later.
    FileConfiguration originalFile = YamlConfiguration.loadConfiguration(file);
    // Loop through the values of the latest version and set any that are not present.
    for(String key : includedFile.getKeys(true)){
        if(!(getCustomConfig().contains(key))){
            getCustomConfig().set(key, includedFile.get(key));
        }
    }
    // Save the changes made, copy the default file.
    if(!(getCustomConfig().saveToString().equals(originalFile.saveToString()))){
        try {
            copyDefault();
            fc.save(file);
            return true;
        }catch (IOException e){
            return false;
        }
    }
    return false;
}
 
Example #15
Source File: YamlIncompleteTranslationTest.java    From NovaGuilds with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testMessageEnum() throws Exception {
	File motherLangFile = new File(langDir, "en-en.yml");
	YamlConfiguration motherConfiguration = YamlConfiguration.loadConfiguration(motherLangFile);
	int missingCount = 0;

	for(MessageWrapper message : Message.values()) {
		if(!motherConfiguration.contains(message.getPath())) {
			System.out.println(" - " + message.getPath());
			missingCount++;
		}
	}

	if(missingCount == 0) {
		System.out.println("Result: No missing keys");
	}
	else {
		throw new Exception("Found " + missingCount + " missing keys in en-en file that are present in Message class");
	}
}
 
Example #16
Source File: Utils.java    From NametagEdit with GNU General Public License v3.0 6 votes vote down vote up
public static YamlConfiguration getConfig(File file, String resource, Plugin plugin) {
    try {
        if (!file.exists()) {
            file.createNewFile();
            InputStream inputStream = plugin.getResource(resource);
            OutputStream outputStream = new FileOutputStream(file);
            byte[] buffer = new byte[1024];
            int bytesRead;
            while ((bytesRead = inputStream.read(buffer)) != -1) {
                outputStream.write(buffer, 0, bytesRead);
            }
            inputStream.close();
            outputStream.flush();
            outputStream.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    return YamlConfiguration.loadConfiguration(file);
}
 
Example #17
Source File: CombatManager.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
private void checkKill(Player player) {
    FileConfiguration config = this.plugin.getConfig("config.yml");
    String killOption = Optional.ofNullable(config.getString("punishments.kill-time")).orElse("QUIT");

    if(killOption.equals("QUIT")) {
        player.setHealth(0.0D);
        this.plugin.getCustomDeathListener().add(player);
        return;
    }

    if(killOption.equals("KILL")) {
        YamlConfiguration playerData = this.plugin.getDataFile(player);
        playerData.set("kill-on-join", true);
        this.plugin.saveDataFile(player, playerData);
        // return;
    }

    // NEVER or unknown option means do nothing
}
 
Example #18
Source File: NMSUtilsHologramInteraction.java    From BedWars with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void updateHologramDatabase() {
    try {
        // update hologram-database file
        File file = new File(Main.getInstance().getDataFolder(), "holodb.yml");
        YamlConfiguration config = new YamlConfiguration();

        if (!file.exists()) {
            file.createNewFile();
        }

        config.set("locations", hologramLocations);
        config.save(file);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
Example #19
Source File: ExpansionClassLoader.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
private ExpansionDescription createDescription(YamlConfiguration config) throws IllegalStateException {
    String mainClassName = config.getString("main");
    if(mainClassName == null) throw new IllegalStateException("'main' is required in expansion.yml");
    
    String unlocalizedName = config.getString("name");
    if(unlocalizedName == null) throw new IllegalStateException("'name' is required in expansion.yml");
    
    String version = config.getString("version");
    if(version == null) throw new IllegalStateException("'version' is required in expansion.yml");
    
    String displayName = config.getString("display-name", null);
    String description = config.getString("description", null);
    List<String> authorList = config.getStringList("authors");
    
    String author = config.getString("author", null);
    if(author != null) authorList.add(author);
    
    Builder builder = new Builder(mainClassName, unlocalizedName, version)
            .setDescription(description)
            .setDisplayName(displayName)
            .setAuthors(authorList.toArray(new String[0]));
    return new ExpansionDescription(builder);
}
 
Example #20
Source File: Language.java    From iDisguise with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
public void loadData() {
	File languageFile = new File(plugin.getDataFolder(), "language.yml");
	FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(languageFile);
	try {
		int fileVersion = UpdateCheck.extractVersionNumber(fileConfiguration.getString("version", "iDisguise 5.7.3"));
		for(Field field : getClass().getDeclaredFields()) {
			if(field.getType().equals(String.class)) {
				if((!field.isAnnotationPresent(LastUpdated.class) || field.getAnnotation(LastUpdated.class).value() <= fileVersion) && fileConfiguration.isString(field.getName().toLowerCase(Locale.ENGLISH).replace('_', '-'))) {
					field.set(this, fileConfiguration.getString(field.getName().toLowerCase(Locale.ENGLISH).replace('_', '-')));
				}
			}
		}
	} catch(Exception e) {
		plugin.getLogger().log(Level.SEVERE, "An error occured while loading the language file.", e);
	}
}
 
Example #21
Source File: InternalEventsTest.java    From uSkyBlock with GNU General Public License v3.0 6 votes vote down vote up
@Before
public void setUp() {
    fakePlugin = spy(mock(uSkyBlock.class));
    internalEvents = new InternalEvents(fakePlugin);

    YamlConfiguration config = new YamlConfiguration();
    config.set("options.party.join-commands", Arrays.asList("lets", "test", "this"));
    config.set("options.party.leave-commands", Arrays.asList("dont", "stop", "me", "now"));
    doReturn(config).when(fakePlugin).getConfig();

    fakeBlockLimitLogic = spy(mock(BlockLimitLogic.class));
    doNothing().when(fakeBlockLimitLogic).updateBlockCount(any(), any());
    doReturn(fakeBlockLimitLogic).when(fakePlugin).getBlockLimitLogic();

    doReturn(true).when(fakePlugin).restartPlayerIsland(any(), any(), any());
    doNothing().when(fakePlugin).createIsland(any(), any());
    doNothing().when(fakePlugin).calculateScoreAsync(any(), any(), any());
}
 
Example #22
Source File: Leaderboard.java    From SkyWarsReloaded with GNU General Public License v3.0 6 votes vote down vote up
private void getSigns(LeaderType type) {
File leaderboardsFile = new File(SkyWarsReloaded.get().getDataFolder(), "leaderboards.yml");

   if (!leaderboardsFile.exists()) {
      SkyWarsReloaded.get().saveResource("leaderboards.yml", false);
   }

   if (leaderboardsFile.exists()) {
     	FileConfiguration storage = YamlConfiguration.loadConfiguration(leaderboardsFile);
     	for (int i = 1; i < 11; i++) {
     		List<String> locations = storage.getStringList(type.toString().toLowerCase() + ".signs." + i);
     		if (locations != null) {
     			ArrayList<Location> locs = new ArrayList<>();
     			for (String location: locations) {
     				Location loc = Util.get().stringToLocation(location);
     				locs.add(loc);
     			}
     			signs.get(type).put(i, locs);
     		}
     	}
   }
 	
 }
 
Example #23
Source File: HelperProfilesPlugin.java    From helper with MIT License 6 votes vote down vote up
@Override
protected void enable() {
    SqlProvider sqlProvider = getService(SqlProvider.class);
    Sql sql;

    // load sql instance
    YamlConfiguration config = loadConfig("config.yml");
    if (config.getBoolean("use-global-credentials", true)) {
        sql = sqlProvider.getSql();
    } else {
        sql = sqlProvider.getSql(DatabaseCredentials.fromConfig(config));
    }

    // init the table
    String tableName = config.getString("table-name", "helper_profiles");
    int preloadAmount = config.getInt("preload-amount", 2000);

    // provide the ProfileRepository service
    provideService(ProfileRepository.class, bindModule(new HelperProfileRepository(sql, tableName, preloadAmount)));
}
 
Example #24
Source File: WorldBorder.java    From Carbon with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void save() {
	for (Entry<World, WorldBorder> entry : worldsWorldBorder.entrySet()) {
		WorldBorder worldborder = entry.getValue();
		YamlConfiguration config = new YamlConfiguration();
		config.set("x", worldborder.x);
		config.set("z", worldborder.z);
		config.set("damageAmount", worldborder.damageAmount);
		config.set("damageBuffer", worldborder.damageBuffer);
		config.set("warningBlocks", worldborder.warningBlocks);
		config.set("warningTime", worldborder.warningTime);
		if (worldborder.getStatus() != EnumWorldBorderStatus.STATIONARY) {
			config.set("lerpTime", worldborder.lerpEndTime - worldborder.lerpStartTime);
			config.set("currentRadius", worldborder.currentRadius);
		}
		config.set("oldRadius", worldborder.oldRadius);
		try {
			config.save(new File(entry.getKey().getWorldFolder(), "worldborder.yml"));
		} catch (IOException e) {
                         e.printStackTrace(System.out);
		}
	}
}
 
Example #25
Source File: FallbackConfigUtil.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
public static FileConfiguration getConfigFullPath(File originalFile, String url) {
    FileConfiguration config = new YamlConfiguration();
    try {
        InputStream inputStream = FallbackConfigUtil.class.getResourceAsStream(url);
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
        config.load(reader);
        if (originalFile != null && originalFile.exists()) {
            FileConfiguration configOverride = new YamlConfiguration();
            configOverride.load(originalFile);
            for (String key : configOverride.getKeys(true)) {
                if (configOverride.get(key) instanceof ConfigurationSection) {
                    continue;
                }
                config.set(key, configOverride.get(key));
            }
        }
    } catch (Exception e) {
        if (originalFile != null) {
            Civs.logger.log(Level.SEVERE, "File name: {0}", originalFile.getName());
        }
        if (url != null) {
            Civs.logger.log(Level.SEVERE, "Resource path: {0}", url);
        }
        Civs.logger.log(Level.SEVERE, "Unable to load config", e);
    }

    return config;
}
 
Example #26
Source File: TownTests.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
public static void loadTownTypeTribe() {
    FileConfiguration config = new YamlConfiguration();
    config.set("name", "Tribe");
    config.set("type", "town");
    ArrayList<String> critReqs = new ArrayList<>();
    critReqs.add("cobble");
    config.set("build-reqs", critReqs);
    config.set("critical-build-reqs", critReqs);
    config.set("build-radius", 25);
    config.set("max-power", 500);
    ItemManager.getInstance().loadTownType(config, "tribe");
}
 
Example #27
Source File: TownTests.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
public static void loadTownTypeTribe2() {
    FileConfiguration config = new YamlConfiguration();
    config.set("name", "Tribe");
    config.set("type", "town");
    ArrayList<String> critReqs = new ArrayList<>();
    critReqs.add("cobble");
    ArrayList<String> preReqs = new ArrayList<>();
    preReqs.add("tribe:population=5");
    config.set("pre-reqs", preReqs);
    config.set("child", "hamlet2");
    config.set("build-reqs", critReqs);
    config.set("critical-build-reqs", critReqs);
    config.set("build-radius", 25);
    ItemManager.getInstance().loadTownType(config, "tribe");
}
 
Example #28
Source File: LangFile.java    From AdditionsAPI with MIT License 5 votes vote down vote up
/**
 * This method is run when the plugin is enabled and when reloading. Not
 * meant to be used in any other occasion.
 */
public LangFile setup() {
	file = new File(plugin.getDataFolder(), "lang.yml");
	YamlConfiguration data = YamlConfiguration.loadConfiguration(file);
	data.options().copyDefaults(true);
	LangFile.data = data;
	saveLang();
	return this;
}
 
Example #29
Source File: Utils.java    From NametagEdit with GNU General Public License v3.0 5 votes vote down vote up
public static YamlConfiguration getConfig(File file) {
    try {
        if (!file.exists()) {
            file.createNewFile();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    return YamlConfiguration.loadConfiguration(file);
}
 
Example #30
Source File: PermissionConsistencyTest.java    From AuthMeReloaded with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns all permission entries from the plugin.yml file.
 *
 * @return map with the permission entries by permission node
 */
private static Map<String, PermissionDefinition> getPermissionsFromPluginYmlFile() {
    FileConfiguration pluginFile = YamlConfiguration.loadConfiguration(getJarFile("/plugin.yml"));
    MemorySection permsList = (MemorySection) pluginFile.get("permissions");

    Map<String, PermissionDefinition> permissions = new HashMap<>();
    addChildren(permsList, permissions);
    return ImmutableMap.copyOf(permissions);
}