本文整理汇总了Java中org.bukkit.configuration.InvalidConfigurationException类的典型用法代码示例。如果您正苦于以下问题:Java InvalidConfigurationException类的具体用法?Java InvalidConfigurationException怎么用?Java InvalidConfigurationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InvalidConfigurationException类属于org.bukkit.configuration包,在下文中一共展示了InvalidConfigurationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onLeave
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
@EventHandler
public void onLeave(PlayerQuitEvent event){
Player p = event.getPlayer();
if(Files.user.contains("Users." + p.getName())){
try{
Files.user.save(Files.users);
Files.user.load(Files.users);
}catch(IOException | InvalidConfigurationException e){
// TODO Auto-generated catch block
e.printStackTrace();
}
if(manager.isInPvP(p)){
p.setHealth(0D);
Bukkit.broadcastMessage(Message.prefix + ChatColor.GRAY + " ¡" + ChatColor.GOLD + p.getName() + Message.leave_in_pvp);
}
}
}
示例2: loadMessage
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
static public void loadMessage(){
File messageFile = new File("plugins" + File.separator + "PVPAsWantedManager" + File.separator + "message.yml");
if(!messageFile.exists()){
if(Config.getConfig("language").equals("CN")){
createCNMessage();
}else if(Config.getConfig("language").equals("EN")){
//TODO createENMessage();
}else{
createCNMessage();
}
}else{
Bukkit.getConsoleSender().sendMessage("§8[§6PVPAsWantedManager§8] §aFind Message.yml");
}
messages = new YamlConfiguration();
try {messages.load(messageFile);} catch (IOException | InvalidConfigurationException e) {e.printStackTrace();Bukkit.getConsoleSender().sendMessage("§8[§6PVPAsWantedManager§8] §a读取message时发生错误");}
}
示例3: onJoin
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
@EventHandler
public void onJoin(PlayerJoinEvent event){
Player p = event.getPlayer();
if(!Files.user.contains("Users." + p.getName())){
Files.user.set("Users." + p.getName() + ".pvp", false);
manager.addNewbie(p);
try{
Files.user.save(Files.users);
Files.user.load(Files.users);
}catch(IOException | InvalidConfigurationException e){
e.printStackTrace();
}
return;
}
}
示例4: saveFiles
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
public void saveFiles(){
try{
config.save(fileConfig);
users.save(fileUsers);
fl.save(fileFL);
casino.save(fileCasino);
rain.save(fileRain);
config.load(fileConfig);
users.load(fileUsers);
fl.load(fileFL);
casino.load(fileCasino);
rain.load(fileRain);
}catch (java.io.IOException | InvalidConfigurationException e){
e.printStackTrace();
}
}
示例5: StringToItemStack
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的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);
}
}
示例6: load
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
private void load(JavaPlugin plugin) {
try {
final FileConfiguration configuration = new YamlConfiguration();
final File file = new File(plugin.getDataFolder(), "bungeecord_signs.yml");
if (!file.exists()) {
if (!file.createNewFile()) {
Bukkit.getLogger().log(Level.WARNING, "File cannot get created.");
}
}
configuration.load(file);
if (configuration.getConfigurationSection("signs") != null) {
final Map<String, Object> data = configuration.getConfigurationSection("signs").getValues(false);
for (final String s : data.keySet()) {
this.signs.add(new BungeeCordSignInfo.Container(((ConfigurationSection) data.get(s)).getValues(true)));
}
}
} catch (IOException | InvalidConfigurationException e) {
Bukkit.getLogger().log(Level.WARNING, "Save load location.", e);
}
}
示例7: save
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
void save(Arena item) {
if (item != null && item.getName() != null) {
try {
final FileConfiguration configuration = new YamlConfiguration();
final File file = new File(this.getFolder(), "arena_" + item.getName() + ".yml");
if (file.exists()) {
if (!file.delete())
throw new IllegalStateException("Cannot delete file!");
}
if (!file.createNewFile())
throw new IllegalStateException("Cannot create file!");
configuration.load(file);
final Map<String, Object> data = item.serialize();
for (final String key : data.keySet()) {
configuration.set("arena." + key, data.get(key));
}
configuration.save(file);
} catch (IOException | InvalidConfigurationException ex) {
Bukkit.getLogger().log(Level.WARNING,"Cannot save arena." ,ex.getMessage());
}
}
}
示例8: create
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
public static void create() throws IOException{
File pluginFolder = DogTags.getInstance().getDataFolder();
f = new File(pluginFolder, "config.yml");
if(!f.exists()){
f.getParentFile().mkdirs();
DogTags.getInstance().saveResource(f.getName(), false);
LogUtil.outputMsg("File &6%file% &fdoesn't exist, creating file!".replace("%file%", f.getName()));
}
fc = new YamlConfiguration();
try {
fc.load(f);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
}
示例9: getConfig
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
/**Static method to get a modules config alone, returns null if failed.
* The loading is tested during the initial yml test and should therefore work during DunGen runtime.
* @param parent The parent plugin
* @param name The modules name for witch the config should be loaded (file 'name'.yml)
* @return The config object. Returns null if errors occured and sets plugin state to ERROR.
*/
public static YamlConfiguration getConfig(DunGen parent, String name) {
File confFile = new File(parent.getDataFolder(),name+".yml");
if (!confFile.exists()) {
parent.setStateAndNotify(State.ERROR, "Config file for module " + name + " could not be found!");
return null;
}
YamlConfiguration conf = new YamlConfiguration();
try {
conf.load(confFile);
}catch (IOException | InvalidConfigurationException e) {
parent.setStateAndNotify(State.ERROR, "Loading of config file for module " + name + " failed:");
e.printStackTrace();
return null;
}
// everything ok, if code reached here.
parent.getLogger().info("YML file for module " + name + " loaded.");
return conf;
}
示例10: finishHandshake
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
private void finishHandshake(ChannelHandlerContext ctx, FullHttpResponse response) {
if (response.getStatus().equals(HttpResponseStatus.SWITCHING_PROTOCOLS)) {
try {
handshaker.finishHandshake(ctx.channel(), response);
connection.handshakeFuture.setSuccess();
logger.info("Successfully connected to AudioConnect server!");
return;
} catch (Exception e) {
connection.handshakeFuture.setFailure(e);
}
} else {
connection.handshakeFuture.setFailure(new InvalidConfigurationException());
}
String responseMsg = response.content().toString(StandardCharsets.UTF_8);
logger.severe("Failed to Connect with AudioConnect server: " + responseMsg);
logger.severe("Stopping client event loop due to failure to establish connection with AudioConnect server");
disconnect();
}
示例11: createFile
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
/**
* Creates the config file if it doesn't exist yet.
* If there are exceptions the stacktrace will be printed.
*/
private void createFile() {
if (file == null) {
new InvalidConfigurationException("File cannot be null!").printStackTrace();
}
try {
if (!file.exists()) {
if (file.getParentFile() != null) {
file.getParentFile().mkdirs();
}
file.createNewFile();
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例12: load
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
/**
* Load the config file in to memory.
* The value of all fields will be set with the config values.
*/
public void load() {
if (file != null) {
try {
if (!file.exists()) {
if (file.getParentFile() != null) {
file.getParentFile().mkdirs();
}
file.createNewFile();
}
conf.load(file);
if (fields == null) {
onLoad(conf);
} else {
onLoad(conf, fields);
}
conf.save(file);
} catch (Exception e) {
e.printStackTrace();
}
} else {
new InvalidConfigurationException("File cannot be null!").printStackTrace();
}
}
示例13: save
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
/**
* Save the config file to disk.
* All values from the fields will be placed in the config.
*/
public void save() {
if (file != null) {
try {
if (!file.exists()) {
if (file.getParentFile() != null) {
file.getParentFile().mkdirs();
}
file.createNewFile();
}
if (fields == null) {
onSave(conf);
} else {
onSave(conf, fields);
}
conf.save(file);
} catch (Exception e) {
e.printStackTrace();
}
} else {
new InvalidConfigurationException("File cannot be null!").printStackTrace();
}
}
示例14: getTemporaryStorage
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
public List<ItemStack> getTemporaryStorage(OfflinePlayer player) {
Query<TempStorageRepo> result = query(TempStorageRepo.class).whereEq("player_id", player.getUniqueId().toString());
if (result == null || result.count() == 0) return Collections.emptyList();
YamlConfiguration cfg = new YamlConfiguration();
try {
cfg.loadFromString(result.selectUnique().yaml);
} catch (InvalidConfigurationException ex) {
ex.printStackTrace();
return Collections.emptyList();
}
List<ItemStack> ret = new ArrayList<>();
for (String key : cfg.getKeys(false)) {
ret.add(cfg.getItemStack(key));
}
return ret;
}
示例15: loadItems
import org.bukkit.configuration.InvalidConfigurationException; //导入依赖的package包/类
public List<ShopItem> loadItems(String path) {
YamlConfiguration configuration = new YamlConfiguration();
try {
configuration.loadFromString(this.yaml);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
ArrayList<ShopItem> list = new ArrayList<>();
if (configuration.isConfigurationSection(path)) {
ConfigurationSection section = configuration.getConfigurationSection(path);
for (String k : section.getKeys(false)) {
list.add(new ShopItem(section.getConfigurationSection(k)));
}
}
return list;
}