weras2000
Пользователь
- Сообщения
- 27
- Решения
- 1
Основной класс
класс CheckCommand
Класс CheckListener
Ошибка
Error occurred while enabling CyberCheck v1.0-SNAPSHOT (Is it up to date?)
java.lang.NoClassDefFoundError: net/xorek/cybercheck/command/CheckCommand
at net.xorek.cybercheck.CyberCheck.onEnable(CyberCheck.java:12) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:596) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:309) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:293) ~[patched_1.16.5.jar:git-Purpur-1171]
at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.ClassNotFoundException: net.xorek.cybercheck.command.CheckCommand
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:155) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:114) ~[patched_1.16.5.jar:git-Purpur-1171]
at java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[?:?]
... 11 more
Java:
package net.xorek.cybercheck;
import net.xorek.cybercheck.command.CheckCommand;
import net.xorek.cybercheck.listener.CheckListener;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class CyberCheck extends JavaPlugin {
@Override
public void onEnable() {
CheckCommand checkCommand = new CheckCommand(this);
getCommand("check").setExecutor(checkCommand);
Bukkit.getPluginManager().registerEvents(new CheckListener(checkCommand), this);
getLogger().info("CheckPlugin включен!");
}
@Override
public void onDisable() {
getLogger().info("CheckPlugin выключен!");
}
}
класс CheckCommand
Код:
package net.xorek.cybercheck.command;
import net.xorek.cybercheck.CyberCheck;
import net.xorek.cybercheck.utils.CheckUtils;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.HashMap;
import java.util.Map;
public class CheckCommand implements CommandExecutor {
private final CyberCheck plugin;
private final Map<Player, BossBar> playerBossBars = new HashMap<>();
private final Map<Player, Integer> playerTimers = new HashMap<>();
private final Map<Player, Player> playerCheckers = new HashMap<>();
public CheckCommand(CyberCheck plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Эта команда доступна только игрокам.");
return true;
}
Player player = (Player) sender;
if (command.getName().equalsIgnoreCase("check")) {
if (args.length < 1) {
return true;
}
String action = args[0].toLowerCase();
if (action.equals("start")) {
return handleStartCommand(player, args);
} else if (action.equals("stop")) {
return handleStopCommand(player, args);
} else if (action.equals("confirm")) {
return handleConfirmCommand(player);
}
}
return false;
}
private boolean handleStartCommand(Player player, String[] args) {
if (!player.hasPermission("check.start")) {
player.sendMessage("У вас нет разрешения на использование этой команды.");
return true;
}
if (args.length < 2) {
player.sendMessage("Укажите игрока для проверки.");
return true;
}
Player target = Bukkit.getPlayer(args[1]);
if (target == null) {
player.sendMessage("Игрок не найден.");
return true;
}
if (playerBossBars.containsKey(target)) {
Player checker = playerCheckers.get(target);
player.sendMessage("Игрок " + target.getName() + " уже находится под проверкой игрока " + checker.getName() + ".");
return true;
}
teleportAndStartTimer(target, player);
player.sendMessage("Проверка для игрока " + target.getName() + " начата.");
return true;
}
private boolean handleStopCommand(Player player, String[] args) {
if (!player.hasPermission("check.stop")) {
player.sendMessage("У вас нет разрешения на использование этой команды.");
return true;
}
if (args.length < 2) {
player.sendMessage("Укажите игрока для остановки проверки.");
return true;
}
Player target = Bukkit.getPlayer(args[1]);
if (target == null) {
player.sendMessage("Игрок не найден.");
return true;
}
BossBar bossBar = playerBossBars.get(target);
if (bossBar == null) {
player.sendMessage("Игрок " + target.getName() + " не находится под проверкой.");
return true;
}
bossBar.removePlayer(target);
Integer taskId = playerTimers.get(target);
if (taskId != null) {
Bukkit.getScheduler().cancelTask(taskId);
playerTimers.remove(target);
}
playerBossBars.remove(target);
playerCheckers.remove(target);
target.removePotionEffect(PotionEffectType.BLINDNESS);
target.sendMessage("Ваша проверка была остановлена.");
player.sendMessage("Проверка для игрока " + target.getName() + " была остановлена.");
target.playSound(target.getLocation(), Sound.BLOCK_BEACON_ACTIVATE, 1.0f, 1.0f);
return true;
}
private boolean handleConfirmCommand(Player player) {
if (!playerBossBars.containsKey(player)) {
player.sendMessage("Вы не находитесь под проверкой.");
return true;
}
banPlayer(player, "14d", "Признание"); // Передаем срок бана и причину
player.sendMessage("Вы забанены");
return true;
}
private void teleportAndStartTimer(Player target, Player inspector) {
String command = String.format("mv tp %s spawn", target.getName());
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
BossBar bossBar = Bukkit.createBossBar("Время: 5:00", BarColor.RED, BarStyle.SEGMENTED_20);
bossBar.addPlayer(target);
playerBossBars.put(target, bossBar);
playerCheckers.put(target, inspector);
CheckUtils.sendCheckMessage(target, inspector, 300);
int[] taskId = new int[1];
taskId[0] = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
int timeLeft = playerTimers.getOrDefault(target, 300);
timeLeft--;
if (!playerBossBars.containsKey(target)) {
Bukkit.getScheduler().cancelTask(taskId[0]);
return;
}
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 300, 0, false, false));
target.playSound(target.getLocation(), "block.anvil.land", 1.0f, 1.0f);
target.sendTitle("§c§lПровiрка", "", 10, 40, 10);
if (timeLeft <= 0) {
bossBar.setVisible(false);
target.sendMessage("Время вышло!");
banPlayer(target, "30d", "Время вышло");
Bukkit.getScheduler().cancelTask(taskId[0]);
playerTimers.remove(target);
playerBossBars.remove(target);
target.removePotionEffect(PotionEffectType.BLINDNESS);
} else {
playerTimers.put(target, timeLeft);
int minutes = timeLeft / 60;
int seconds = timeLeft % 60;
double progress = (double) timeLeft / 300;
bossBar.setProgress(progress);
bossBar.setTitle(String.format("Время: %02d:%02d", minutes, seconds));
}
}, 0, 20).getTaskId();
playerTimers.put(target, 300);
}
public void banPlayer(Player player, String duration, String reason) {
String command = String.format("banip %s %s %s", player.getName(), duration, reason);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}
public Map<Player, BossBar> getPlayerBossBars() {
return playerBossBars;
}
public Map<Player, Integer> getPlayerTimers() {
return playerTimers;
}
}
Класс CheckListener
Код:
package net.xorek.cybercheck.listener;
import com.destroystokyo.paper.event.player.PlayerJumpEvent;
import net.xorek.cybercheck.CyberCheck;
import net.xorek.cybercheck.command.CheckCommand; // Импортируем CheckCommand
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.*;
import org.bukkit.entity.Player;
public class CheckListener implements Listener {
private final CheckCommand checkCommand;
public CheckListener(CheckCommand checkCommand) {
this.checkCommand = checkCommand;
}
@EventHandler
public void onPlayerJump(PlayerJumpEvent event) {
Player player = event.getPlayer();
if (checkCommand.getPlayerBossBars().containsKey(player)) {
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (checkCommand.getPlayerBossBars().containsKey(player)) {
if (event.getFrom().getX() != event.getTo().getX() || event.getFrom().getZ() != event.getTo().getZ()) {
event.setCancelled(true);
}
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
if (checkCommand.getPlayerBossBars().containsKey(player)) {
checkCommand.banPlayer(player, "30d", "Лив с проверки");
checkCommand.getPlayerBossBars().remove(player);
checkCommand.getPlayerTimers().remove(player);
}
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
if (checkCommand.getPlayerBossBars().containsKey(player)) {
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) {
Player player = event.getPlayer();
if (checkCommand.getPlayerBossBars().containsKey(player)) {
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
String message = event.getMessage().toLowerCase();
if (checkCommand.getPlayerBossBars().containsKey(player) && !message.equals("/check confirm")) {
event.setCancelled(true);
}
}
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Player) {
Player attacker = (Player) event.getDamager();
if (checkCommand.getPlayerBossBars().containsKey(attacker)) {
event.setCancelled(true);
}
}
}
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if (checkCommand.getPlayerBossBars().containsKey(player)) {
event.setCancelled(true);
}
}
}
}
Error occurred while enabling CyberCheck v1.0-SNAPSHOT (Is it up to date?)
java.lang.NoClassDefFoundError: net/xorek/cybercheck/command/CheckCommand
at net.xorek.cybercheck.CyberCheck.onEnable(CyberCheck.java:12) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:596) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:309) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Purpur-1171]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:293) ~[patched_1.16.5.jar:git-Purpur-1171]
at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.ClassNotFoundException: net.xorek.cybercheck.command.CheckCommand
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:155) ~[patched_1.16.5.jar:git-Purpur-1171]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:114) ~[patched_1.16.5.jar:git-Purpur-1171]
at java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[?:?]
... 11 more
Последнее редактирование: