Linegrite
Пользователь
- Сообщения
- 9
Привет всем!
Возникла нужда в нескольких конфигах, полез на ютуб смотреть что, да как. Сделал все по
Код:
Дополняю, в начале всей этой бурды, спигот пишет что-то такое:
Возникла нужда в нескольких конфигах, полез на ютуб смотреть что, да как. Сделал все по
Авторизуйтесь для просмотра ссылок.
, запустил сервер, пытаюсь вытащить строку из конфига, консоль начинает дико фулдить этим:at org.bukkit.configuration.MemorySection.get(MemorySection.java:207) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.configuration.MemorySection.getDefault(MemorySection.java:716) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.configuration.MemorySection.get(MemorySection.java:207) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.configuration.MemorySection.getDefault(MemorySection.java:716) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.configuration.MemorySection.get(MemorySection.java:207) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.configuration.MemorySection.getDefault(MemorySection.java:716) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.configuration.MemorySection.getDefault(MemorySection.java:716) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.configuration.MemorySection.get(MemorySection.java:207) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.configuration.MemorySection.getDefault(MemorySection.java:716) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.configuration.MemorySection.get(MemorySection.java:207) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.configuration.MemorySection.getDefault(MemorySection.java:716) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
Код:
Java:
package ru.linegrite.bmgcheck.utils.configs;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import ru.linegrite.bmgcheck.Main;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.logging.Level;
public class Config {
private Main plugin;
private FileConfiguration config = null;
private File configFile = null;
public Config(Main plugin) {
this.plugin = plugin;
saveDefaultConfig();
}
public void reloadConfig() {
if (this.configFile == null) {
this.configFile = new File(this.plugin.getDataFolder(), "config.yml");
}
this.config = YamlConfiguration.loadConfiguration(this.configFile);
InputStream defaultStream = this.plugin.getResource("config.yml");
if (defaultStream != null) {
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultStream));
this.config.setDefaults(config);
}
}
public FileConfiguration getConfig() {
if (this.config == null) reloadConfig();
return this.config;
}
public void saveConfig() {
if (this.config == null || this.configFile == null) return;
try {
this.getConfig().save(this.configFile);
} catch (IOException e) {
plugin.getLogger().log(Level.SEVERE, "Could not save config to " + this.configFile, e);
}
}
public void saveDefaultConfig() {
if (this.configFile == null) this.configFile = new File(this.plugin.getDataFolder(), "config.yml");
if (!this.configFile.exists()) {
this.plugin.saveResource("config.yml", false);
}
}
}
Java:
public class CommandBmgCheck implements CommandExecutor {
public Config config;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
this.config = new Config(Main.plugin);
if (sender instanceof Player) {
sender.sendMessage(config.getConfig().getString("test"));
}
return true;
}
}
Дополняю, в начале всей этой бурды, спигот пишет что-то такое:
[12:16:06 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'bcheck' in plugin BmgCheck v2.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:648) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand(PlayerConnection.java:1399) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1234) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at java.lang.Thread.run(Thread.java:832) [?:?]
org.bukkit.command.CommandException: Unhandled exception executing command 'bcheck' in plugin BmgCheck v2.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:648) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand(PlayerConnection.java:1399) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1234) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at java.lang.Thread.run(Thread.java:832) [?:?]
Последнее редактирование: