本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
示例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();
}
示例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;
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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++;
}
}
示例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);
}
示例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);
}