當前位置: 首頁>>代碼示例>>Java>>正文


Java YamlConfiguration.getString方法代碼示例

本文整理匯總了Java中org.bukkit.configuration.file.YamlConfiguration.getString方法的典型用法代碼示例。如果您正苦於以下問題:Java YamlConfiguration.getString方法的具體用法?Java YamlConfiguration.getString怎麽用?Java YamlConfiguration.getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.configuration.file.YamlConfiguration的用法示例。


在下文中一共展示了YamlConfiguration.getString方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadPlayersFromDisk

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
public void loadPlayersFromDisk() {
	file = new PluginFile("players", FileType.YAML);
	YamlConfiguration config = file.returnYaml();

	for (String key : config.getConfigurationSection("").getKeys(false)) {
		UUID uuid = UUID.fromString(key);
		Frequency freq = main.getFrequencyManager().getPublicRadioCompany().getFrequencyRange().get(0);
		PlayerObject pObject = new PlayerObject(uuid, config.getString(key + ".current-cellphone-recipient"), freq);
		
		pObject.setReceiveNotificationSound(config.getBoolean(key +".notification-sound"));
		pObject.setContacts(config.getStringList(key + ".contacts"));
		players.put(uuid, pObject);
		
	}

}
 
開發者ID:kadeska,項目名稱:MT_Communication,代碼行數:17,代碼來源:PlayerManager.java

示例2: initFile

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
/**
 * 初始化配置文件
 *
 * @param config
 *            配置文件
 * @throws IOException
 */
private static void initFile(final YamlConfiguration config) throws IOException {
    if (config.getString("guid") == null) {
        config.options().header("YUMC數據中心 http://www.yumc.pw 收集的數據僅用於統計插件使用情況").copyDefaults(true);
        config.set("guid", UUID.randomUUID().toString());
        config.set("debug", false);
        config.save(configfile);
    }
    if (!config.contains("YumAccount")) {
        config.set("YumAccount.username", "Username Not Set");
        config.set("YumAccount.password", "Password NotSet");
        config.save(configfile);
    }
    if (!config.contains("TellrawManualHandle")) {
        config.set("TellrawManualHandle", false);
        config.save(configfile);
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:25,代碼來源:YUMCStatistics.java

示例3: LoggingModule

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
public LoggingModule() throws DataException {
	setInstance(this);
	YamlConfiguration bukkitYml = YamlConfiguration
			.loadConfiguration(new File(Bukkit.getWorldContainer().getAbsoluteFile(), "bukkit.yml"));
	DB_URL = KingdomFactionsPlugin.getInstance().getDataManager().getString("Database.Logging.url").replace("{NAME}", DB_NAME);
	USERNAME = bukkitYml.getString("database.username");
	PASSWORD = bukkitYml.getString("database.password");
	datasource = new HikariDataSource();
	datasource.setMaximumPoolSize(25);
	datasource.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
	datasource.addDataSourceProperty("url", DB_URL);
	datasource.addDataSourceProperty("port", 3306);
	datasource.addDataSourceProperty("databaseName", DB_NAME);
	datasource.addDataSourceProperty("user", USERNAME);
	datasource.addDataSourceProperty("password", PASSWORD);
	insertQuery("CREATE DATABASE IF NOT EXISTS " + DB_NAME);
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:18,代碼來源:LoggingModule.java

示例4: MySQLModule

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
public MySQLModule() {
	setInstance(this);
	YamlConfiguration bukkitYml = YamlConfiguration
			.loadConfiguration(new File(Bukkit.getWorldContainer().getAbsoluteFile(), "bukkit.yml"));
	DB_URL = bukkitYml.getString("database.url").replace("{NAME}", DB_NAME);
	USERNAME = bukkitYml.getString("database.username");
	PASSWORD = bukkitYml.getString("database.password");
	datasource = new HikariDataSource();
	datasource.setMaximumPoolSize(25);
	datasource.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
	datasource.addDataSourceProperty("url", DB_URL);
	datasource.addDataSourceProperty("port", 3306);
	datasource.addDataSourceProperty("databaseName", DB_NAME);
	datasource.addDataSourceProperty("user", USERNAME);
	datasource.addDataSourceProperty("password", PASSWORD);
	insertQuery("CREATE DATABASE IF NOT EXISTS " + DB_NAME);
	new PlayerDatabase();
	new FactionDatabase();
	new NexusDatabase();
	new KingdomDatabase();
	new BuildingDatabase();
	new FactionHomeDatabase();
	
	new ShopDatabase();
	new ShopLogDatabase();
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:27,代碼來源:MySQLModule.java

示例5: getPlayerData

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
/**
 * ��ȡPlayerData
 * @param rs ����·��
 * @param p Player����
 * @return PlayerData����
 */
public static PlayerData getPlayerData(Player p){
	File data=new File(rs.getDataFolder()+File.separator+"PlayerDatas"+File.separator+p.getUniqueId().toString()+".yml");
	PlayerData pd;
	if(!data.exists()){
		try {data.createNewFile();} catch (IOException e) {}
		pd=new PlayerData(p.getUniqueId(),p.getWorld().getName(), rs.getSleepMax(), 
											rs.getThirstMax(), 0, 37,0, rs.getPhysical_strength());
		return pd;
	}
	YamlConfiguration dataC=YamlConfiguration.loadConfiguration(data);
	HashMap<String,Object[]> sickKind=new HashMap<String,Object[]>();
	for(String temp:dataC.getStringList("rSickKind")){
		List<String> l=dataC.getStringList("sickKind."+temp);
		sickKind.put(temp,new Object[]{l.get(0),l.get(1),l.get(2),l.get(3)} );
	}
	pd=new PlayerData( p.getUniqueId(),dataC.getString("world"), dataC.getDouble("sleep"),
			dataC.getDouble("thirst"), dataC.getDouble("temperature"), dataC.getDouble("weight"), 
			dataC.getDouble("physical_strength"),dataC.getBoolean("sick"), 
			dataC.getBoolean("isSleep"),Byte.parseByte(dataC.getString("light")),sickKind);
	return pd;
}
 
開發者ID:SchoolUniform,項目名稱:RealSurvival,代碼行數:28,代碼來源:Utils.java

示例6: BMetrics

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
/**
 * Class constructor.
 *
 * @param plugin The plugin which stats should be submitted.
 */
public BMetrics() {
    // Get the config file
    File bStatsFolder = new File(getConfigFile(), "bStats");
    File configFile = new File(bStatsFolder, "config.yml");
    YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);

    // Check if the config file exists
    if (!config.isSet("serverUuid")) {

        // Add default values
        config.addDefault("enabled", true);
        // Every server gets it's unique random id.
        config.addDefault("serverUuid", UUID.randomUUID().toString());
        // Should failed request be logged?
        config.addDefault("logFailedRequests", false);

        // Inform the server owners about bStats
        config.options().header(
                "bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
                        "To honor their work, you should not disable it.\n" +
                        "This has nearly no effect on the server performance!\n" +
                        "Check out https://bStats.org/ to learn more :)"
        ).copyDefaults(true);
        try {
            config.save(configFile);
        } catch (IOException ignored) { }
    }

    // Load the data
    serverUUID = config.getString("serverUuid");
    logFailedRequests = config.getBoolean("logFailedRequests", false);
    if (config.getBoolean("enabled", true)) {
        startSubmitting();
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:41,代碼來源:BMetrics.java

示例7: readConfig

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
public void readConfig(YamlConfiguration config) {
    for (String name : config.getStringList("blacklists")) {
        ProxyBlacklist blacklist = null;
        String blacklistType = config.getString("blacklists." + name + ".type");
        if (blacklistType.equals("A")) {
            blacklist = new ProxyBlacklist(config.getString("blacklists." + name + ".address"), name, (bl, inetAddress) -> {
                if (inetAddress instanceof Inet4Address) {
                    String addr = inetAddress.getHostAddress();
                    String[] segs = addr.split(".");
                    StringBuilder builder = new StringBuilder();
                    for (int i = segs.length - 1; i >= 0; i--) {
                        builder.append(segs[i]);
                        builder.append(".");
                    }
                    builder.append(bl);
                    String lookup = builder.toString();
                    try {
                        InetAddress.getByName(lookup);
                    } catch (UnknownHostException e) {
                        return false;
                    }
                    return true;
                } else {
                    plugin.getLogger().warning("Inet Address " + inetAddress.getCanonicalHostName() + " is not IPv4, somehow.");
                    return false;
                }
            }, config.getString("blacklists." + name + ".on-match"));
            plugin.getLogger().info("Registered blacklist " + blacklist.getName() + " with address " + blacklist.getRootAddress());
        }
        plugin.addProxyBlacklist(blacklist);
    }
}
 
開發者ID:0x277F,項目名稱:mopm,代碼行數:33,代碼來源:MopmConfiguration.java

示例8: onLoad

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
@Override
public void onLoad() {
    try {
        Path data = getDataFolder().toPath();
        Path resolve = data.resolve("config.yml");
        if (!resolve.toFile().exists()) {
            getLogger().warning("Configuration file does not exist! Recreating!");
            List<String> lines = new ArrayList<>();
            lines.add("# RManager configuration file");
            lines.add("");
            lines.add("# Server ID, used for identification purposes");
            lines.add("server-id: 'foo_bar'");
            lines.add("");
            lines.add("# Database information, points to a valid Redis server");
            lines.add("# Database-id selects the database number provided, if unsure, leave as 0");
            lines.add("hostname: 'localhost'");
            lines.add("password: 'password'");
            lines.add("port: 6379");
            lines.add("database-id: 0");
            if (!data.toFile().exists())
                Files.createDirectory(data);
            Files.write(resolve, lines, StandardOpenOption.CREATE);
        }
        getLogger().info("Loading configuration file...");
        YamlConfiguration configuration = YamlConfiguration.loadConfiguration(resolve.toFile());
        String serverID = configuration.getString("server-id");
        String hostname = configuration.getString("hostname");
        String password = configuration.getString("password");
        int port = configuration.getInt("port");
        int dbID = configuration.getInt("database-id");
        getLogger().info("Success! Initializing database as '" + serverID + "'! (" + hostname + ":" + port + "/" + dbID + ")");
        Database.initDatabase(serverID, hostname, password, port, dbID);
    } catch (Exception e) {
        throw new RuntimeException("Error loading configuration: ", e);
    }
}
 
開發者ID:RedEpicness,項目名稱:RManager,代碼行數:37,代碼來源:Main.java

示例9: onChat

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
@EventHandler
public void onChat(AsyncPlayerChatEvent e) {
	String[] words = e.getMessage().split(" ");
	if (pit.contains(e.getPlayer().getName())) {
		executeBSC(e.getPlayer(), e.getMessage());
		e.setCancelled(true);
		return;
	}
	if (haulted) {
		if (!e.getPlayer().isOp()) {
			e.getPlayer().sendMessage(TAG + ChatColor.RED + "Server Haulted!");
			e.setCancelled(true);
			return;
		}
	}
	Player player = (Player) e.getPlayer();
	String msg = e.getMessage().toLowerCase().replaceAll(" ", "");
	if (msg.contains("(.)") || msg.contains(".net") || msg.contains(".com") || msg.contains(".co")
			|| msg.contains(" . ")) {
		player.kickPlayer(TAG + ChatColor.RED + "Possible advertising");
		return;
	}
	// detecting variables
	YamlConfiguration varConf = YamlConfiguration.loadConfiguration(varFile);
	int word = 0;
	for (String s : words) {
		if ((!(s.length() < 3)) && s.startsWith("%") && s.endsWith("%")) {
			String ss = s.replace("%", "");
			if (varConf.contains(ss)) {
				words[word] = varConf.getString(ss);
				String newText = "";
				for (int i = 0; i < words.length; i++) {
					newText = newText + words[i] + " ";
				}
				e.setMessage(newText);
			}
		}
		word++;
	}
}
 
開發者ID:OverloadedCore,項目名稱:behave,代碼行數:41,代碼來源:MainPart.java

示例10: sanitizeConfig

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
private void sanitizeConfig(YamlConfiguration c) {
    int lineStartsAt = c.getInt(CONFIG_LINE_STARTS_AT);
    if (lineStartsAt < 0 || lineStartsAt > 1) setDefaultConfig(CONFIG_LINE_STARTS_AT);

    String clicking = c.getString(CONFIG_CLICKING);
    if (clicking == null ||
            !(clicking.equalsIgnoreCase("true") ||
            clicking.equalsIgnoreCase("false") ||
            clicking.equalsIgnoreCase("auto"))) setDefaultConfig(CONFIG_CLICKING);
}
 
開發者ID:Deltik,項目名稱:SignEdit,代碼行數:11,代碼來源:Configuration.java

示例11: enable

import org.bukkit.configuration.file.YamlConfiguration; //導入方法依賴的package包/類
@Override
protected void enable() {
    SqlProvider sqlProvider = getService(SqlProvider.class);
    if (sqlProvider == null) {
        throw new RuntimeException("Unable to obtain SqlProvider!");
    }

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

    // init the table
    tableName = config.getString("table-name", "helper_profiles");
    try (Connection c = sql.getConnection()) {
        try (Statement s = c.createStatement()) {
            s.execute(replaceTableName(CREATE));
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }

    // preload data
    int preloadAmount = config.getInt("preload-amount", 2000);
    if (preloadAmount > 0) {
        getLogger().info("Preloading the most recent " + preloadAmount + " entries...");
        long start = System.currentTimeMillis();
        int found = preload(preloadAmount);
        long time = System.currentTimeMillis() - start;
        getLogger().info("Preloaded " + found + " profiles into the cache! - took " + time + "ms");
    }

    // observe logins
    Events.subscribe(PlayerLoginEvent.class, EventPriority.MONITOR)
            .filter(e -> e.getResult() == PlayerLoginEvent.Result.ALLOWED)
            .handler(e -> {
                ImmutableProfile profile = new ImmutableProfile(e.getPlayer().getUniqueId(), e.getPlayer().getName());
                updateCache(profile);
                Scheduler.runAsync(() -> saveProfile(profile));
            })
            .bindWith(this);

    // provide the ProfileRepository service
    provideService(ProfileRepository.class, this);
}
 
開發者ID:lucko,項目名稱:helper,代碼行數:49,代碼來源:ProfilesPlugin.java


注:本文中的org.bukkit.configuration.file.YamlConfiguration.getString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。