本文整理汇总了Java中org.bukkit.configuration.file.YamlConfiguration.contains方法的典型用法代码示例。如果您正苦于以下问题:Java YamlConfiguration.contains方法的具体用法?Java YamlConfiguration.contains怎么用?Java YamlConfiguration.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.configuration.file.YamlConfiguration
的用法示例。
在下文中一共展示了YamlConfiguration.contains方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: StringToItemStack
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static ItemStack StringToItemStack(String string) {
if (string == null) {
return null;
}
YamlConfiguration yaml = new YamlConfiguration();
try {
yaml.loadFromString(string);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
if (yaml.contains("item")) {
return yaml.getItemStack("item", null);
} else {
return yaml.getItemStack("i", null);
}
}
示例3: get
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public MComponent get(String type, String node) {
if(node == null)
return Void;
MComponent result = super.get(node, false);
if(result!=null)return result;
else{
YamlConfiguration config = this.config.get(VanillaPlusCore.getDefaultLang());
if(config.contains(node)){
ErrorLogger.addPrefix(node);
result = create(type, VanillaPlusCore.getDefaultLang(), config.getString(node));
ErrorLogger.removePrefix();
}
if(result!=null){
addLangs(result, node);
super.register(node, result, false);
return result;
}
else{
Error.MISSING_NODE.add(node);
return Void;
}
}
}
示例4: copyDefaultNode
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public static void copyDefaultNode(YamlConfiguration configFile, Plugin plugin, String path, String nodPath){
configFile.createSection(nodPath);
path = fixPath(path);
InputStream file = plugin.getResource(path.replace(File.separatorChar, '/'));
if(file!=null){
YamlConfiguration defaultFile = YamlConfiguration.loadConfiguration(new InputStreamReader(file));
if(defaultFile.contains(nodPath))
configFile.set(nodPath, defaultFile.get(path));
else
configFile.set(nodPath, Error.MISSING_NODE.getMessage());
}
File temp = new File(plugin.getDataFolder(), path);
try {
configFile.save(temp);
} catch (IOException e) {
e.printStackTrace();
ErrorLogger.addError("I/O Exception for file : " + temp.getAbsolutePath());
}
}
示例5: 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++;
}
}
示例6: addLangs
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
public void addLangs(MComponent message, String node){
for(Localizer loc : VanillaPlusCore.getLangs()){
if(loc == VanillaPlusCore.getDefaultLang())
continue;
YamlConfiguration config = this.config.get(loc);
if(config.contains(node)){
message.addLang(loc, config.getString(node));
}else{
message.addLang(loc, Error.MISSING_NODE.add(" " + loc.getCode() + " => " + node));
}
}
}
示例7: mergeInDefaultConfig
import org.bukkit.configuration.file.YamlConfiguration; //导入方法依赖的package包/类
private void mergeInDefaultConfig(YamlConfiguration c) {
for (Map.Entry<String, Object> defaultConfigItem : defaults.entrySet()) {
if (!c.contains(defaultConfigItem.getKey())) {
c.set(defaultConfigItem.getKey(), defaultConfigItem.getValue());
}
}
}