Помогите Ошибка при выводе текста с конфига

DaunOfMine

Новичок
Пользователь
Баллы
11
Вот такая ошибка, при доставания текста с конфига.
Но ошибка только при первом сообщении.
Код:
[09:01:16 ERROR]: [Auth] Cannot load configuration from jar
org.bukkit.configuration.InvalidConfigurationException: Top level is not a Map.
        at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:59) ~[spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.java.JavaPlugin.reloadConfig(JavaPlugin.java:214) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.java.JavaPlugin.getConfig(JavaPlugin.java:162) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at top.cd.ru.main.onBreak(main.java:47) [auth.jar:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_144]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PlayerInteractManager.breakBlock(PlayerInteractManager.java:286) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PlayerInteractManager.a(PlayerInteractManager.java:215) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:637) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PacketPlayInBlockDig.a(SourceFile:40) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PacketPlayInBlockDig.a(SourceFile:10) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_144]
        at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_144]
        at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8-R0.1-SNAPSHOT-latest.jar:git-Spigot-db6de12-18fbb24]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_144]
А вот мой говно-код:
Код:
package top.cd.ru;

import java.util.ArrayList;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class main extends JavaPlugin implements Listener {
    public static JavaPlugin p;
    public void onEnable() {
        p = this;
        getServer().getPluginManager().registerEvents(this, this);
        this.saveDefaultConfig();
        infoplayer.create();

    }

    ArrayList<String> players = new ArrayList<>();

    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
        Player p = e.getPlayer();
        this.players.add(p.getName());
       

    }

    @EventHandler
    public void onMove(PlayerMoveEvent e) {
        Player p = e.getPlayer();
        if (players.contains(p.getName())) {

            p.teleport(p.getLocation());

        }
    }

    @EventHandler
    public void onBreak(BlockBreakEvent e) {
        Player p = e.getPlayer();
        if (players.contains(p.getName())) {
            p.sendMessage("" + getConfig().getString("BlockBreak").replace("&", "§"));
            e.setCancelled(true);
            return;
        }

    }
    public void loadconfig() {
       
    }
}
 
1. У тебя проблема с конфигом. Где то ты ошибся при его заполнение. Об этом свидетельствует
InvalidConfigurationException.
2. infoplayer.create(); - что это?
3. Ошибка указывает, что ты пытаешься получить не тот тип из конфига, который там есть в действительности.
4. Если тебе не важен порядок игроков в листе, то используй HashSet<Player> players = new HashSet<>(); он значительно быстрей.
 
1. У тебя проблема с конфигом. Где то ты ошибся при его заполнение. Об этом свидетельствует
InvalidConfigurationException.
2. infoplayer.create(); - что это?
3. Ошибка указывает, что ты пытаешься получить не тот тип из конфига, который там есть в действительности.
4. Если тебе не важен порядок игроков в листе, то используй HashSet<Player> players = new HashSet<>(); он значительно быстрей.
1. Странно, создание конфига я скопипастил, потому что я криворукий и у меня всё время конфиги не спавнились.
2. Это класс, где происходит создание дополнительного конфига(players.yml).
3. В конфиге 1 строчка. BlockBreak: adasdsad
4. Так точно)
Большое спасибо за нормальный ответ)
 
1. Странно, создание конфига я скопипастил, потому что я криворукий и у меня всё время конфиги не спавнились.
2. Это класс, где происходит создание дополнительного конфига(players.yml).
3. В конфиге 1 строчка. BlockBreak: adasdsad
4. Так точно)
Большое спасибо за нормальный ответ)
Кидай код, только полный и на пастбин залей. Заодно и конфиг
 
Назад
Верх