当前位置: 首页>>代码示例>>Java>>正文


Java Configuration类代码示例

本文整理汇总了Java中org.bukkit.configuration.Configuration的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Configuration类属于org.bukkit.configuration包,在下文中一共展示了Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveScoreboard

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
/**
 * Saves a scoreboard to a configuration file.
 *
 * @param config
 *            The configuration file.
 * @param scoreboard
 *            The scoreboard.
 */
public void saveScoreboard(Configuration config, Scoreboard scoreboard) {
	// Save teams
	ConfigurationSection teamsSection = config.createSection("teams");
	scoreboard.getTeams().forEach(team -> {
		ConfigurationSection teamSection = teamsSection.createSection(team.getName());
		saveTeam(teamSection, team);
	});

	// Save objectives
	ConfigurationSection objectivesSection = config.createSection("objectives");
	scoreboard.getObjectives().forEach(objective -> {
		ConfigurationSection objectiveSection = objectivesSection.createSection(objective.getName());
		objectiveSection.set("criteria", objective.getCriteria());
		objectiveSection.set("display_name", objective.getDisplayName());
		objectiveSection.set("display_slot", objective.getDisplaySlot().toString().toLowerCase());
	});

	// Save scores
	ConfigurationSection scoresSection = config.createSection("scores");
	scoreboard.getEntries().forEach(playerName -> {
		ConfigurationSection playerSection = scoresSection.createSection(playerName);
		scoreboard.getScores(playerName)
				.forEach(score -> playerSection.set(score.getObjective().getName(), score.getScore()));
	});
}
 
开发者ID:rutgerkok,项目名称:Pokkit,代码行数:34,代码来源:ScoreboardPersister.java

示例2: MatchManager

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
/**
 * Creates a new map manager with a specified map rotation.
 */
@Inject MatchManager(Loggers loggers,
                     @Named("pluginData") Path pluginDataFolder,
                     Provider<Configuration> config,
                     MapLibrary mapLibrary,
                     MapLoader mapLoader,
                     MapErrorTracker mapErrorTracker,
                     FileRotationProviderFactory fileRotationProviderFactory,
                     EventBus eventBus,
                     MatchLoader matchLoader) throws MapNotFoundException {

    this.pluginDataFolder = pluginDataFolder;
    this.mapErrorTracker = mapErrorTracker;
    this.fileRotationProviderFactory = fileRotationProviderFactory;
    this.log = loggers.get(getClass());
    this.config = config;
    this.mapLibrary = mapLibrary;
    this.mapLoader = mapLoader;
    this.eventBus = eventBus;
    this.matchLoader = matchLoader;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:24,代码来源:MatchManager.java

示例3: QuotaConfig

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
@Inject QuotaConfig(Configuration root) {
    this.config = root.getConfigurationSection("match-quotas");
    if(config == null) {
        quotas = new TreeSet<>();
    } else {
        quotas = new TreeSet<>(Collections2.transform(
            config.getKeys(false),
            new Function<String, Entry>() {
                @Override
                public Entry apply(@Nullable String key) {
                    return new Entry(config.getConfigurationSection(key));
                }
            }
        ));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:QuotaConfig.java

示例4: parse

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
public Set<RotationProviderInfo> parse(MapLibrary mapLibrary, Path dataPath, Configuration config) {
    ConfigurationSection base = config.getConfigurationSection("rotation.providers.file");
    if(base == null) return Collections.emptySet();

    Set<RotationProviderInfo> providers = new HashSet<>();
    for(String name : base.getKeys(false)) {
        ConfigurationSection provider = base.getConfigurationSection(name);

        Path rotationFile = Paths.get(provider.getString("path"));
        if(!rotationFile.isAbsolute()) rotationFile = dataPath.resolve(rotationFile);

        int priority = provider.getInt("priority", 0);

        if(Files.isRegularFile(rotationFile)) {
            providers.add(new RotationProviderInfo(new FileRotationProvider(mapLibrary, name, rotationFile, dataPath), name, priority));
        } else if(minecraftService.getLocalServer().startup_visibility() == ServerDoc.Visibility.PUBLIC) {
            // This is not a perfect way to decide whether or not to throw an error, but it's the best we can do right now
            mapLibrary.getLogger().severe("Missing rotation file: " + rotationFile);
        }
    }

    return providers;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:24,代码来源:FileRotationProviderFactory.java

示例5: loadConfig

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
public void loadConfig() {
    Configuration configuration = YamlConfiguration.loadConfiguration(configFile);
    ConfigurationSection bungeeSection;
    if (configuration.contains("bungee")){
        bungeeSection = configuration.getConfigurationSection("bungee");
    } else {
        getLogger().warning("The section 'bungee' in the configuration is not found, " +
                "defaults will be assumed. Delete the config file and restart to have a " +
                "clean valid configuration file.");
        bungeeSection = configuration.createSection("bungee");
    }
    boolean serverSocketEnabled = configuration.getBoolean("server-socket", true);
    boolean serverPortAuto = configuration.getBoolean("port-automatic", true);
    int serverPort = configuration.getInt("port", 3112);
    String host = bungeeSection.getString("host");
    int port = bungeeSection.getInt("port");
    char[] password = bungeeSection.getString("password", "").toCharArray();
    int heartbeatSeconds = bungeeSection.getInt("heartbeat-seconds", 30);
    int reconnectAttempts = bungeeSection.getInt("reconnect-attempts", 7);
    bungeeMasterSpigotConfig = new BungeeMasterSpigotConfig(serverSocketEnabled, serverPortAuto, serverPort, host, port, password, heartbeatSeconds, reconnectAttempts);
}
 
开发者ID:TonyMaster21,项目名称:BungeeMaster,代码行数:22,代码来源:BungeeMaster.java

示例6: checkConfigVersions

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
private void checkConfigVersions(Configuration config, Path dataFolder) {
    if (config.getInt("config-version", 0) < TradeConfiguration.CURRENT_CONFIG_VERSION) {
        Path configSource = dataFolder.resolve(TradeConfiguration.DESTINATION_FILE_NAME);
        Path configTarget = dataFolder.resolve("config_old.yml");

        try {
            Files.move(configSource, configTarget, StandardCopyOption.REPLACE_EXISTING);
            URL configResource = getClass().getResource(TradeConfiguration.CLASSPATH_RESOURCE_NAME);

            copyResource(configResource, configSource.toFile());

            ConsoleCommandSender sender = Bukkit.getConsoleSender();
            sender.sendMessage(ChatColor.RED + "Due to a SimpleTrading update your old configuration has been renamed");
            sender.sendMessage(ChatColor.RED + "to config_old.yml and a new one has been generated. Make sure to");
            sender.sendMessage(ChatColor.RED + "apply your old changes to the new config!");
        } catch (IOException e) {
            getLogger().log(Level.SEVERE, "Could not create updated configuration due to an IOException", e);
        }
    }
}
 
开发者ID:xaniox,项目名称:simple-trading,代码行数:21,代码来源:SimpleTrading.java

示例7: getJarConfig

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
/**
 * Gets a configuration file from the jar file.
 *
 * @param path
 *            Path in the jar file.
 * @return The configuration file.
 */
private Configuration getJarConfig(String path) {
    InputStream resource = getResource(path);
    if (resource == null) {
        // Not found
        return new YamlConfiguration();
    }
    Reader reader = new InputStreamReader(resource, Charsets.UTF_8);
    Configuration config = YamlConfiguration.loadConfiguration(reader);
    try {
        resource.close();
    } catch (IOException e) {
        getLogger().log(Level.SEVERE, "Failed to close stream", e);
    }
    return config;
}
 
开发者ID:rutgerkok,项目名称:BlockLocker,代码行数:23,代码来源:BlockLockerPluginImpl.java

示例8: loadTranslations

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
private Translator loadTranslations(String fileName) {
    File file = new File(getDataFolder(), fileName);
    Configuration config = YamlConfiguration.loadConfiguration(file);
    config.addDefaults(getJarConfig(Config.DEFAULT_TRANSLATIONS_FILE));

    ConfigTranslator translator = new ConfigTranslator(config);
    if (translator.needsSave()) {
        getLogger().info("Saving translations");
        try {
            translator.save(file);
        } catch (IOException e) {
            getLogger().log(Level.SEVERE, "Failed to save translation file", e);
        }
    }
    return translator;
}
 
开发者ID:rutgerkok,项目名称:BlockLocker,代码行数:17,代码来源:BlockLockerPluginImpl.java

示例9: ModConfig

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
/**
 * Initialize mod config based on the configuration file
 *
 * @param config
 */
public ModConfig(Configuration config) {
    m_isInitialized = false;
    if (config == null) {
        m_blocks = null;
        m_mobs = null;
        m_modIdRegex = null;
        m_textureRes = 0;
        m_versionRegex = null;
        return;
    }

    m_name = config.getString("DisplayName", null);
    m_blocks = config.getConfigurationSection("Blocks");
    m_mobs = config.getConfigurationSection("Mobs");
    m_modIdRegex = config.getString("ModId", null);
    m_alternativeId = config.getString("ModIdAlternative", null);
    m_versionRegex = config.getString("Version", null);
    m_textureRes = config.getInt("TextureRes", 0);
}
 
开发者ID:SBPrime,项目名称:MCPainter,代码行数:25,代码来源:ModConfig.java

示例10: load

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
/**
 * Load palette from file
 *
 * @param file
 * @return
 */
public static Palette load(File file) {
    Configuration config = YamlConfiguration.loadConfiguration(file);

    String name = config.getString("name", null);
    BlockEntry[] blockEntries = parseBlocksSection(config);
    
    if (name == null) {
        MCPainterMain.log("* " + file.getName() + "...invalid file format, no name palette defined.");
        return null;
    }
    
    name = name.toLowerCase();
    if (blockEntries == null || blockEntries.length < 2) {
        MCPainterMain.log("* " + name + "...invalid file format, minimum number of blocks in palette is 2.");
        return null;
    }
    
    MCPainterMain.log("* " + name + "..." + blockEntries.length + " blocks defined.");
    return new Palette(name, blockEntries);
}
 
开发者ID:SBPrime,项目名称:MCPainter,代码行数:27,代码来源:Palette.java

示例11: parseBlocksSection

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
/**
 * Parse blocks section entry
 *
 * @param configuration
 * @return
 */
private static BlockEntry[] parseBlocksSection(Configuration configuration) {
    List<BlockEntry> blocks = new ArrayList();
    for (String string : configuration.getStringList("blocks")) {
        try {
            BlockEntry entry = BlockEntry.parse(string);
            if (entry == null) {
                MCPainterMain.log("* Error parsing block entry: " + string);
            } else {
                blocks.add(entry);
            }
        } catch (Exception e) {
            MCPainterMain.log("* Error parsing block entry: " + string);
        }
    }
    return blocks.toArray(new BlockEntry[0]);
}
 
开发者ID:SBPrime,项目名称:MCPainter,代码行数:23,代码来源:Palette.java

示例12: load

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
public void load() {
    BukkitScheduler scheduler = plugin.getServer().getScheduler();
    if (task != null) {
        task.cancel();
        task = null;
    }
    ConfigurationSection arenaConfiguration = loadDataFile("arenas");
    load(arenaConfiguration);

    ConfigurationSection arenaData = loadDataFile("data");
    loadData(arenaData);

    plugin.reloadConfig();
    Configuration config = plugin.getConfig();
    pathTemplate = config.getString("path_template", pathTemplate);
    tickInterval = config.getInt("tick_interval", 40);

    task = scheduler.runTaskTimer(plugin, this, 1, tickInterval);
}
 
开发者ID:elBukkit,项目名称:MagicArenas,代码行数:20,代码来源:ArenaController.java

示例13: isSTBItem

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
@Override
public boolean isSTBItem(ItemStack stack, Class<? extends BaseSTBItem> c) {
    if (stack == null || !stack.hasItemMeta()) {
        return false;
    }
    ItemMeta im = stack.getItemMeta();
    if (im.hasLore()) {
        List<String> lore = im.getLore();
        if (!lore.isEmpty() && lore.get(0).startsWith(LORE_PREFIX)) {
            if (c != null) {
                Configuration conf = getItemAttributes(stack);
                ReflectionDetails details = reflectionDetailsMap.get(conf.getString("*TYPE"));
                return details != null && c.isAssignableFrom(details.clazz);
            } else {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:desht,项目名称:sensibletoolbox,代码行数:21,代码来源:STBItemRegistry.java

示例14: getItemAttributes

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
private Configuration getItemAttributes(ItemStack stack) {
    AttributeStorage storage = AttributeStorage.newTarget(stack, STB_ATTRIBUTE_ID);
    YamlConfiguration conf = new YamlConfiguration();
    try {
        String s = storage.getData("");
        if (s != null) {
            conf.loadFromString(s);
            if (Debugger.getInstance().getLevel() > 2) {
                Debugger.getInstance().debug(3, "get item attributes for " + STBUtil.describeItemStack(stack) + ":");
                for (String k : conf.getKeys(false)) {
                    Debugger.getInstance().debug(3, "- " + k + " = " + conf.get(k));
                }
            }
            return conf;
        } else {
            throw new IllegalStateException("ItemStack " + stack + " has no STB attribute data!");
        }
    } catch (InvalidConfigurationException e) {
        e.printStackTrace();
        return new MemoryConfiguration();
    }
}
 
开发者ID:desht,项目名称:sensibletoolbox,代码行数:23,代码来源:STBItemRegistry.java

示例15: loadCharacter

import org.bukkit.configuration.Configuration; //导入依赖的package包/类
private RpChar loadCharacter(File playerFile)
   {
       OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(playerFile.getName().substring(0, playerFile.getName().length() - 4)));
       RpChar character = new RpChar(player,plugin);

	Configuration playerConfig = YamlConfiguration.loadConfiguration(playerFile);
		
       for (Field field : plugin.getCharacterManager().getFields().values())
       {
           if (!playerConfig.isSet(field.getName()))
               continue;

           character.setField(field.getName(), playerConfig.getString(field.getName()));
       }

       return character;
}
 
开发者ID:AaronFoley,项目名称:CharacterCards,代码行数:18,代码来源:YMLCharacterStorage.java


注:本文中的org.bukkit.configuration.Configuration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。