本文整理汇总了Java中org.bukkit.configuration.file.FileConfiguration.getString方法的典型用法代码示例。如果您正苦于以下问题:Java FileConfiguration.getString方法的具体用法?Java FileConfiguration.getString怎么用?Java FileConfiguration.getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.configuration.file.FileConfiguration
的用法示例。
在下文中一共展示了FileConfiguration.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEnable
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
@Override
public void onEnable() {
defaultConfig = getConfig();
instance = this;
FileConfiguration config = getConfig();
config.addDefault(PROTECTION_KEY, false);
config.addDefault(PLAYER_KICK_KEY, "Please verify that you're not a robot. Visit %s");
config.addDefault(WHITELIST_KEY, new ArrayList<String>());
config.addDefault(VERIFICATION_ROOT_KEY, "http://yourdomain.com/");
config.addDefault(WIPE_KEY, "secret");
config.options().copyDefaults(true);
saveConfig();
getServer().getPluginManager().registerEvents(new EventListener(), this);
EventListener.protection = config.getBoolean(PROTECTION_KEY);
EventListener.kickMessage = config.getString(PLAYER_KICK_KEY);
this.getCommand("antibots").setExecutor(new CommandAntibots());
getLogger().log(Level.INFO, "Plugin successfully enabled. Default protection is " + config.getBoolean(PROTECTION_KEY));
}
示例2: initiateArenas
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
private void initiateArenas() {
FileConfiguration config = ManagerHandler.getConfig().getArenasConfig().getConfig();
if (!config.contains("arenas")) return;
for (String name : config.getConfigurationSection("arenas").getKeys(false)) {
try {
String displayName = config.getString("arenas." + name + ".display-name");
Integer displayOrder = config.getInt("arenas." + name + ".display-order");
Location location1 = LocationUtils.getLocation(config.getString("arenas." + name + ".location1"));
Location location2 = LocationUtils.getLocation(config.getString("arenas." + name + ".location2"));
Arena arena = new Arena(name, displayName, displayOrder, location1, location2);
this.arenas.put(name, arena);
}
catch (Exception e) {
PracticePlugin.getInstance().getLogger().severe("Failed to load arena '" + name + "', stack trace below:");
PracticePlugin.getInstance().getLogger().severe("------------------------------------------------------");
e.printStackTrace();
PracticePlugin.getInstance().getLogger().severe("------------------------------------------------------");
}
}
}
示例3: signJoinLoad
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public void signJoinLoad() {
File signJoinFile = new File(SkyWarsReloaded.get().getDataFolder(), "signJoinGames.yml");
if (!signJoinFile.exists()) {
SkyWarsReloaded.get().saveResource("signJoinGames.yml", false);
}
if (signJoinFile.exists()) {
FileConfiguration storage = YamlConfiguration.loadConfiguration(signJoinFile);
try {
for (String gameNumber : storage.getConfigurationSection("games.").getKeys(false)) {
String mapName = storage.getString("games." + gameNumber + ".map");
String world = storage.getString("games." + gameNumber + ".world");
if (mapName != null && world != null) {
GameSign gs = new GameSign(storage.getInt("games." + gameNumber + ".x"), storage.getInt("games." + gameNumber + ".y"), storage.getInt("games." + gameNumber + ".z"), world, mapName);
signJoinGames.put(Integer.valueOf(gameNumber), gs);
createGame(Integer.valueOf(gameNumber), gs);
}
}
} catch (NullPointerException e) {
}
}
}
示例4: onEnable
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public void onEnable()
{
//ignore
getLogger();
String protocol;
String name;
String ip;
int port;
FileConfiguration config = getConfig();
config.addDefault("settings.protocol", valueOf("TCP"));
config.addDefault("settings.name", valueOf("minecraft"));
config.addDefault("settings.ipaddress", valueOf("0.0.0.0"));
config.addDefault("settings.port", 25565);
config.options().copyDefaults(true);
protocol = config.getString("settings.protocol");
name = config.getString("settings.name");
ip = config.getString("settings.ipaddress");
port = config.getInt("settings.port");
saveConfig();
openPort(ip, port, name, protocol);
}
示例5: loadConfig
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
private void loadConfig() {
FileConfiguration config = new YamlConfiguration();
try {
config.load(new File(getDataFolder(), "config.yml"));
config.options().copyDefaults(true);
String user = config.getString("jdbc-username", "root");
String password = config.getString("jdbc-password", "password");
String jdbcUrl = config.getString("jdbc-url", "jdbc:mysql://localhost:3306/minecraft");
databaseManager = new DatabaseManager(jdbcUrl, user, password);
databaseManager.connect();
ConfigurationSection definitions = config.getConfigurationSection("definitions");
for (String definitionKey : definitions.getKeys(false)) {
ConfigurationSection definition = definitions.getConfigurationSection(definitionKey);
int priority = definition.getInt("priority", 1);
ImageType type = ImageType.valueOf(definition.getString("type", ImageType.OVERLAY.name()));
String permission = definition.getString("permission");
List<String> images = definition.getStringList("images");
SpigotImageDetails imageDetails = new SpigotImageDetails(priority, type, permission, images);
imageHandler.addImage(imageDetails);
}
config.save(new File(getDataFolder(), "config.yml"));
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
}
示例6: BanRequest
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public BanRequest(int _id) {
id = _id;
FileConfiguration c = Main.getInstance().getConfig();
timeOpened = c.getLong("ban_requests." + id + ".timeOpened");
timeClosed = c.getLong("ban_requests." + id + ".timeClosed");
openerUUID = c.getString("ban_requests." + id + ".openerUUID");
closerUUID = c.getString("ban_requests." + id + ".closerUUID");
timeOpenedFormatted = c.getString("ban_requests." + id + ".timeOpenedFormatted");
timeClosedFormatted = c.getString("ban_requests." + id + ".timeClosedFormatted");
closed = c.getBoolean("ban_requests." + id + ".closed");
accepted = c.getBoolean("ban_requests." + id + ".accepted");
denied = c.getBoolean("ban_requests." + id + ".denied");
banReason = c.getString("ban_requests." + id + ".banReason");
playerToBanUUID = c.getString("ban_requests." + id + ".playerToBanUUID");
}
示例7: DataProvider
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
private DataProvider() {
FileConfiguration config = Main.config();
this.protection = config.getBoolean(Main.PROTECTION_KEY);
this.kickMessage = config.getString(Main.PLAYER_KICK_KEY);
String root = config.getString(Main.VERIFICATION_ROOT_KEY);
if (!root.endsWith("/")) root += '/';
root = root.replace('\\', '/');
this.verificationRoot = root;
this.wipeKey = config.getString(Main.WIPE_KEY);
this.whitelist = config.getStringList(Main.WHITELIST_KEY);
this.formattedMessage = String.format(ChatColor.translateAlternateColorCodes('&', getKickMessage()), root);
}
示例8: addSignJoinGame
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public boolean addSignJoinGame(Location loc, String mapName) {
if (SkyWarsReloaded.getMC().mapRegistered(mapName)) {
String world = loc.getWorld().getName().toString();
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
GameSign gs = new GameSign(x, y, z, world, mapName);
gameNumber = -1;
File signJoinFile = new File(SkyWarsReloaded.get().getDataFolder(), "signJoinGames.yml");
if (!signJoinFile.exists()) {
SkyWarsReloaded.get().saveResource("signJoinGames.yml", false);
}
if (signJoinFile.exists()) {
FileConfiguration storage = YamlConfiguration.loadConfiguration(signJoinFile);
for (int i = 1; i < 1000; i++) {
if (storage.getString("games." + i + ".map") == null) {
gameNumber = i;
break;
}
}
storage.set("games." + gameNumber + ".x", x);
storage.set("games." + gameNumber + ".y", y);
storage.set("games." + gameNumber + ".z", z);
storage.set("games." + gameNumber + ".world", world);
storage.set("games." + gameNumber + ".map", mapName);
try {
storage.save(signJoinFile);
} catch (IOException e) {
e.printStackTrace();
}
signJoinGames.put(gameNumber, gs);
createGame(gameNumber, gs);
return true;
} else {
return false;
}
}
return false;
}
示例9: signRemoved
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
@EventHandler
public void signRemoved(BlockBreakEvent event) {
Location blockLocation = event.getBlock().getLocation();
World w = blockLocation.getWorld();
Block b = w.getBlockAt(blockLocation);
if(b.getType() == Material.WALL_SIGN || b.getType() == Material.SIGN_POST){
Sign sign = (Sign) b.getState();
String line1 = ChatColor.stripColor(sign.getLine(0));
if (line1.equalsIgnoreCase(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', new Messaging.MessageFormatter().format("signJoinSigns.line1"))))) {
String world = blockLocation.getWorld().getName().toString();
int x = blockLocation.getBlockX();
int y = blockLocation.getBlockY();
int z = blockLocation.getBlockZ();
File signJoinFile = new File(SkyWarsReloaded.get().getDataFolder(), "signJoinGames.yml");
if (signJoinFile.exists()) {
FileConfiguration storage = YamlConfiguration.loadConfiguration(signJoinFile);
for (String gameNumber : storage.getConfigurationSection("games.").getKeys(false)) {
String world1 = storage.getString("games." + gameNumber + ".world");
int x1 = storage.getInt("games." + gameNumber + ".x");
int y1 = storage.getInt("games." + gameNumber + ".y");
int z1 = storage.getInt("games." + gameNumber + ".z");
if (x1 == x && y1 == y && z1 == z && world.equalsIgnoreCase(world1)) {
if (event.getPlayer().hasPermission("swr.signs")) {
SkyWarsReloaded.getGC().removeSignJoinGame(gameNumber);
} else {
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.RED + "YOU DO NOT HAVE PERMISSION TO DESTROY SWR SIGNS");
}
}
}
}
}
}
}
示例10: getRemoveItem
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
private ItemStack getRemoveItem(Player p){
ConfigManager.load();
FileConfiguration config = ConfigManager.get();
Material mat = config.getString("gui.gui-item.item") != null ?
Material.valueOf(config.getString("gui.gui-item.item")) : Material.PAPER;
ItemStack is = new ItemStack(mat);
is.setDurability(Short.valueOf(ConfigManager.getInt("gui.gui-item.data")+""));
ItemMeta im = is.getItemMeta();
ArrayList<String> lore = new ArrayList<>();
String title = ColorUtil.translate(ConfigManager.getString("gui.gui-item.name"));
String id = StorageHandler.getPlayerTag(p) != null ? StorageHandler.getPlayerTag(p) : "No";
title = title.replace("%id%", WordUtils.capitalizeFully(id.toLowerCase()));
im.setDisplayName(title);
for(String l : config.getStringList("gui.gui-item.lore")){
lore.add(ColorUtil.translate(l));
}
im.setLore(lore);
is.setItemMeta(im);
return is;
}
示例11: onCommand
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
@Subcommand("DeluxeTags") @CommandCompletion("deluxetags")
public void onCommand(CommandSender sender){
if(!sender.hasPermission("dogtags.convert")) {sender.sendMessage(TagLang.NO_PERMISSION.get()); return; }
File f = new File(DogTags.getInstance().getDataFolder().getParentFile().getPath() + File.separator + "DeluxeTags", "config.yml");
if(!f.exists()) return;
FileConfiguration fc = YamlConfiguration.loadConfiguration(f);
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(DogTags.getInstance().getDataFolder(), "config.yml"));
for(String tags : fc.getConfigurationSection("deluxetags").getKeys(false)){
String prefix = fc.getString("deluxetags."+tags+".tag");
String description = fc.getString("deluxetags."+tags+".description");
if (DogTags.getStorage() == StorageEnum.FLATFILE) {
config.set("dogtags."+tags+".prefix", prefix);
config.set("dogtags."+tags+".description", description);
config.set("dogtags."+tags+".permission", true);
}else{
DogTags.getConnection().insertTag(tags, prefix, description, true);
}
LogUtil.outputMsg("Converted "+tags+" with prefix "+prefix + " and description "+description);
}
// config.save(new File(DogTags.getInstance().getDataFolder(), "config.yml"));
DogTags.getInstance().handleReload();
if(sender instanceof Player) sender.sendMessage("§6[§eDogTags§6] §fCheck Console for Information.");
}
示例12: onEnable
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public void onEnable() {
plugin = this;
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "" + ChatColor.STRIKETHROUGH + "--------------------------------------------------");
Bukkit.getServer().getLogger().info(ChatColor.YELLOW + "██╗ ██╗██╗ ████████╗██████╗ █████╗ ██████╗ ██████╗ ██████╗ ███████╗");
Bukkit.getServer().getLogger().info(ChatColor.YELLOW + "██║ ██║██║ ╚══██╔══╝██╔══██╗██╔══██╗██╔════╝██╔═══██╗██╔══██╗██╔════╝");
Bukkit.getServer().getLogger().info(ChatColor.YELLOW + "██║ ██║██║ ██║ ██████╔╝███████║██║ ██║ ██║██████╔╝█████╗ ");
Bukkit.getServer().getLogger().info(ChatColor.YELLOW + "██║ ██║██║ ██║ ██╔══██╗██╔══██║██║ ██║ ██║██╔══██╗██╔══╝ ");
Bukkit.getServer().getLogger().info(ChatColor.YELLOW + "╚██████╔╝███████╗██║ ██║ ██║██║ ██║╚██████╗╚██████╔╝██║ ██║███████╗");
Bukkit.getServer().getLogger().info(ChatColor.YELLOW + " ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "" + ChatColor.STRIKETHROUGH + "--------------------------------------------------");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "166" + ChatColor.YELLOW + "Commands have been loaded");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "205" + ChatColor.YELLOW + "Permissions have been loaded");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "ProtocalLib" + ChatColor.YELLOW + "has been Hooked");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "PlaceholderAPI" + ChatColor.YELLOW + "has been Hooked");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "Vault" + ChatColor.YELLOW + "has been Hooked");
Bukkit.getServer().getLogger().info(ChatColor.GRAY + "[" + ChatColor.RED + "UltraCore v1" + ChatColor.GRAY + "]" + ChatColor.AQUA + " Has beeen Loaded and Enabled");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "" + ChatColor.STRIKETHROUGH + "--------------------------------------------------");
Bukkit.getServer().getPluginManager().registerEvents(new Events(), this);
getServer().getPluginManager().registerEvents(new TeleportMenu(), this);
getServer().getPluginManager().registerEvents(new AdminMenu(), this);
getCommand("core").setExecutor(new Core());
getCommand("teleport").setExecutor(new Teleport());
getCommand("tp").setExecutor(new TP());
getCommand("tpo").setExecutor(new TPO());
getCommand("tppos").setExecutor(new Tppos());
getCommand("tphere").setExecutor(new Tphere());
getCommand("tpa").setExecutor(new Tpa());
getCommand("tpaccept").setExecutor(new Tpa());
getCommand("tpdeny").setExecutor(new Tpa());
File f = new File("plugins/UltraCore/", "messages.yml");
FileConfiguration cfg = YamlConfiguration.loadConfiguration(f);
cfg.set("this.is.the.file.structure", "this_is_the_string");
try {
cfg.save(f);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String s = cfg.getString("this.is.the.file.structure");
final FileConfiguration config = this.getConfig();
config.addDefault("toggle.freezetime", "false");
config.addDefault("toggle.noweather", "false");
config.addDefault("toggle.nopvp", "false");
config.addDefault("toggle.joinandleave", "false");
config.addDefault("toggle.spawn", "false");
config.addDefault("toggle.motd", "false");
config.addDefault("toggle.chat", "false");
config.addDefault("toggle.tablist", "false");
config.addDefault("toggle.firstjoinkit", "false");
config.options().copyDefaults(true);
saveConfig();
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
@Override
public void run() {
if (plugin.getConfig().getString("toggle.freezetime").equals(true)) {
for(World w : Bukkit.getServer().getWorlds()){
w.setTime(0L);
}
}
}
}, 0L, 10000L);
}
示例13: onEnable
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public void onEnable() {
plugin = this;
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "" + ChatColor.STRIKETHROUGH + "--------------------------------------------------");
Bukkit.getServer().getLogger().info(ChatColor.YELLOW + "██╗ ██╗██╗ ████████╗██████╗ █████╗ ██████╗ ██████╗ ██████╗ ███████╗");
Bukkit.getServer().getLogger().info(ChatColor.YELLOW + "██║ ██║██║ ╚��██╔���██╔��██╗██╔��██╗██╔�����██╔���██╗██╔��██╗██╔�����");
Bukkit.getServer().getLogger().info(ChatColor.YELLOW + "██║ ██║██║ ██║ ██████╔�███████║██║ ██║ ██║██████╔�█████╗ ");
Bukkit.getServer().getLogger().info(ChatColor.YELLOW + "██║ ██║██║ ██║ ██╔��██╗██╔��██║██║ ██║ ██║██╔��██╗██╔��� ");
Bukkit.getServer().getLogger().info(ChatColor.YELLOW + "╚██████╔�███████╗██║ ██║ ██║██║ ██║╚██████╗╚██████╔�██║ ██║███████╗");
Bukkit.getServer().getLogger().info(ChatColor.YELLOW + " ╚������ ╚�������╚�� ╚�� ╚��╚�� ╚�� ╚������ ╚������ ╚�� ╚��╚�������");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "" + ChatColor.STRIKETHROUGH + "--------------------------------------------------");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "166" + ChatColor.YELLOW + "Commands have been loaded");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "205" + ChatColor.YELLOW + "Permissions have been loaded");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "ProtocalLib" + ChatColor.YELLOW + "has been Hooked");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "PlaceholderAPI" + ChatColor.YELLOW + "has been Hooked");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "Vault" + ChatColor.YELLOW + "has been Hooked");
Bukkit.getServer().getLogger().info(ChatColor.GRAY + "[" + ChatColor.RED + "UltraCore v1" + ChatColor.GRAY + "]" + ChatColor.AQUA + " Has beeen Loaded and Enabled");
Bukkit.getServer().getLogger().info(ChatColor.GREEN + "" + ChatColor.STRIKETHROUGH + "--------------------------------------------------");
Bukkit.getServer().getPluginManager().registerEvents(new Events(), this);
getServer().getPluginManager().registerEvents(new TeleportMenu(), this);
getServer().getPluginManager().registerEvents(new AdminMenu(), this);
getServer().getPluginCommand("tpa").setExecutor(new Tpa());
Tpa tpa = new Tpa ();
getCommand("tpaccept").setExecutor(tpa);
getCommand("tpdeny").setExecutor(tpa);
getCommand("core").setExecutor(new Core());
getCommand("teleport").setExecutor(new Teleport());
getCommand("tp").setExecutor(new TP());
getCommand("tpo").setExecutor(new TPO());
getCommand("tppos").setExecutor(new Tppos());
getCommand("tphere").setExecutor(new Tphere());
getCommand("setspawn").setExecutor(new Spawn());
getCommand("spawn").setExecutor(new Spawn());
File f = new File("plugins/UltraCore/", "messages.yml");
FileConfiguration cfg = YamlConfiguration.loadConfiguration(f);
cfg.set("this.is.the.file.structure", "this_is_the_string");
try {
cfg.save(f);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String s = cfg.getString("this.is.the.file.structure");
final FileConfiguration config = this.getConfig();
config.addDefault("toggle.freezetime", "false");
config.addDefault("toggle.noweather", "false");
config.addDefault("toggle.nopvp", "false");
config.addDefault("toggle.joinandleave", "false");
config.addDefault("toggle.spawn", "false");
config.addDefault("toggle.motd", "false");
config.addDefault("toggle.chat", "false");
config.addDefault("toggle.tablist", "false");
config.addDefault("toggle.firstjoinkit", "false");
config.options().copyDefaults(true);
saveConfig();
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
if (plugin.getConfig().getString("toggle.freezetime").equals(true)) {
for (World w : Bukkit.getServer().getWorlds()) {
w.setTime(0L);
}
}
}
}, 0L, 10000L);
}
示例14: getClass
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public static String getClass(String p) {
File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
String className = pConfig.getString("Class");
return className;
}
示例15: getPlayerName
import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public String getPlayerName(String p) {
File pFile = new File(Main.getInstance().getDataFolder(), "Players/" + p.toLowerCase() + ".yml");
FileConfiguration pConfig = YamlConfiguration.loadConfiguration(pFile);
String name = pConfig.getString("User");
return name;
}