Короче когда пишу команду из плагина сервер просто крашится и в консоль постоянно спамит такими ошибками:
вот код главного класса плагина:
вот обработчик команды:
и вот конфиг плагина:
Код:
[19:17:22 ERROR]: --- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH ---
[19:17:22 ERROR]: The server has not responded for 10 seconds! Creating thread dump
[19:17:22 ERROR]: ------------------------------
[19:17:22 ERROR]: Server thread dump (Look for plugins here before reporting to Paper!):
[19:17:22 ERROR]: ------------------------------
[19:17:22 ERROR]: Current Thread: Server thread
[19:17:22 ERROR]: PID: 42 | Suspended: false | Native: false | State: RUNNABLE
[19:17:22 ERROR]: Stack:
[19:17:22 ERROR]: app//org.bukkit.configuration.MemorySection.createPath(MemorySection.java:795)
[19:17:22 ERROR]: app//org.bukkit.configuration.MemorySection.createPath(MemorySection.java:774)
[19:17:22 ERROR]: app//org.bukkit.configuration.MemorySection.getDefault(MemorySection.java:716)
[19:17:22 ERROR]: app//org.bukkit.configuration.MemorySection.getList(MemorySection.java:365)
[19:17:22 ERROR]: org.example.paper.VStaffWork.cmds.StaffWorkCMD.onCommand(StaffWorkCMD.java:24)
[19:17:22 ERROR]: app//org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
[19:17:22 ERROR]: app//org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:152)
[19:17:22 ERROR]: app//org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:685)
[19:17:22 ERROR]: app//net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand(PlayerConnection.java:1492)
[19:17:22 ERROR]: app//net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1297)
[19:17:22 ERROR]: app//net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:45)
[19:17:22 ERROR]: app//net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:5)
[19:17:22 ERROR]: app//net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14)
[19:17:22 ERROR]: app//net.minecraft.server.v1_12_R1.PlayerConnectionUtils$$Lambda/0x000001d86203c7f0.run(Unknown Source)
[19:17:22 ERROR]: java.base@21.0.5/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
[19:17:22 ERROR]: java.base@21.0.5/java.util.concurrent.FutureTask.run(FutureTask.java:317)
[19:17:22 ERROR]: app//net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46)
[19:17:22 ERROR]: app//net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:850)
[19:17:22 ERROR]: app//net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:423)
[19:17:22 ERROR]: app//net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:774)
[19:17:22 ERROR]: app//net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:666)
[19:17:22 ERROR]: java.base@21.0.5/java.lang.Thread.runWith(Thread.java:1596)
[19:17:22 ERROR]: java.base@21.0.5/java.lang.Thread.run(Thread.java:1583)
[19:17:22 ERROR]: ------------------------------
[19:17:22 ERROR]: --- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH ---
вот код главного класса плагина:
Java:
package org.example.paper.VStaffWork;
import org.bukkit.plugin.java.JavaPlugin;
import org.example.paper.VStaffWork.cmds.StaffWorkCMD;
public final class Plugin extends JavaPlugin {
private static Plugin instance;
public static Plugin getInstance() {
return instance;
}
@Override
public void onEnable() {
instance = this;
this.getCommand("staffwork").setExecutor(new StaffWorkCMD());
}
@Override
public void onDisable() {
saveDefaultConfig();
}
}
вот обработчик команды:
Java:
package org.example.paper.VStaffWork.cmds;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.example.paper.VStaffWork.Plugin;
import org.example.paper.VStaffWork.utils.Utils;
import java.util.ArrayList;
import java.util.List;
public class StaffWorkCMD implements CommandExecutor {
FileConfiguration cfg = Plugin.getInstance().getConfig();
List<String> offGroups = (List<String>) cfg.getList("offGroups");
List<String> onGroups = (List<String>) cfg.getList("onGroups");
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
for (int i = 0; i < cfg.getList("offGroups").toArray().length; i++) {
offGroups.add((String) cfg.getList("offGroups").get(i));
}
for (int i = 0; i < cfg.getList("onGroups").toArray().length; i++) {
offGroups.add((String) cfg.getList("onGroups").get(i));
}
if (args.length == 0) {
Player player = (Player) sender;
if (Utils.getPlayerGroup(player, offGroups) == null) {
if (Utils.getPlayerGroup(player, onGroups) == null) {
sender.sendMessage(Utils.color(cfg.getString("messages.NotStaff")));
}
else {
String group = Utils.getPlayerGroup(player, onGroups);
CommandSender ConsoleCommandSender = Plugin.getInstance().getServer().getConsoleSender();
Plugin.getInstance().getServer().dispatchCommand(ConsoleCommandSender, "lp user " + player + " parent set off" + group);
Plugin.getInstance().getServer().broadcastMessage(Utils.color(cfg.getString("messages.StaffWorkOff")));
}
}
else {
String group = Utils.getPlayerGroup(player, offGroups);
CommandSender ConsoleCommandSender = Plugin.getInstance().getServer().getConsoleSender();
for (int i = 0; i < offGroups.toArray().length; i++) {
if (group == offGroups.get(i)) {
String setGroup = onGroups.get(i);
Plugin.getInstance().getServer().dispatchCommand(ConsoleCommandSender, "lp user " + player + " parent set " + setGroup);
Plugin.getInstance().getServer().broadcastMessage(Utils.color(cfg.getString("messages.StaffWorkOn")));
}
}
}
}
return false;
}
}
и вот конфиг плагина:
YAML:
messages:
StaffWorkOn: "&3&lStaffWork &8» &7Игрок &3{player} &7начал работу!"
StaffWorkOff: "&3&lStaffWork &8» &7Игрока &3{player} &7завершил работу!"
NotStaff: "&3&lStaffWork &8» "
offGroups: #Группы администраторов не в режиме работы
- "offhelper"
- "offsthelper"
onGroups: #Группы администраторов в режиме работы
- "helper"
- "sthelper"