A timer in minecraft

270 Views Asked by At

I think this means that the plugin isnt loaded properly. Ive made a timer in minecraft but suddendly it wasnt working at all. The command /timer sends the "usage" message I've added but when I use more arguments it wont work and it says "An internal error occured while attempting to perform this command"

Main Class

package tv.bebaeb.mcplugion;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import tv.bebaeb.mcplugion.timer.Timer;
import tv.bebaeb.mcplugion.commands.HealCommand;
import tv.bebaeb.mcplugion.commands.TimerCommand;
import tv.bebaeb.mcplugion.listeners.JoinListener;
import tv.bebaeb.mcplugion.listeners.QuitListener;
import tv.bebaeb.mcplugion.tablist.TablistManager;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;

public final class Mcplugion extends JavaPlugin {



    private  static Mcplugion instance;

    private TablistManager tablistManager;

    private Timer timer;

    @Override
    public void onLoad() {
        instance = this;
    }

    @Override
    public void onEnable() {
        Bukkit.getConsoleSender().sendMessage(ChatColor.BLUE + "\n\n\n\n\nMcPlugion\n\nM\nC\nP\nL\nU\nG\nI\nO\nN\n\nMcPlugion\n\n\n\n\n");

        PluginManager manager = Bukkit.getPluginManager();
        manager.registerEvents(new JoinListener(), this);
        manager.registerEvents(new QuitListener(), this);

        getCommand("timer").setExecutor(new TimerCommand());
        getCommand("heal").setExecutor(new HealCommand());

        timer = new Timer(false,  0, 0, 0, 0);
        tablistManager = new TablistManager();
    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }

    public static Mcplugion getInstance() {
        return instance;
    }

    public Timer getTimer() {
        return  timer;
    }

    public TablistManager getTablistManager() {
        return tablistManager;
    }
}

TimerCommand Class

package tv.bebaeb.mcplugion.commands;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import tv.bebaeb.mcplugion.Mcplugion;
import tv.bebaeb.mcplugion.timer.Timer;

import java.util.MissingFormatArgumentException;

public class TimerCommand implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage(ChatColor.RED + "Only players can use this command.");
            return true;
        }

        Player player = (Player) sender;
        Mcplugion plugin = Mcplugion.getInstance();
        Timer timer = Mcplugion.getInstance().getTimer();

        if (args.length == 0){
            sender.sendMessage(ChatColor.RED+"a"+ChatColor.GRAY + "Usage" + ChatColor.GRAY + ": " + ChatColor.BLUE + "/timer resume, /timer reverse, /timer pause, /timer set <Days> <Hours> <Minutes> <Seconds>, /timer reset, /timer time");
        }

        if (args[0].equalsIgnoreCase("resume")) {


            if (timer.isRunning()) {
                sender.sendMessage(ChatColor.RED + "The timer is already running.");
                return false;
            } else if (!timer.isRunning()) {
                timer.setRunback(false);
                timer.setRunning(true);
                sender.sendMessage(ChatColor.GREEN + "The timer has started.");
            }
        }

        if (args[0].equalsIgnoreCase("reverse")) {

            if (timer.isRunning()) {
                sender.sendMessage(ChatColor.RED + "The timer is already running.");
                return false;
            }
            if (!timer.isRunning()) {
                timer.setRunback(true);
                timer.setRunning(true);
                sender.sendMessage(ChatColor.GREEN + "The timer has started reversing.");
            }
        }

        if (args[0].equalsIgnoreCase("pause")) {

            if (!timer.isRunning()) {
                sender.sendMessage(ChatColor.RED + "The timer is not running.");
                return false;
            }

            timer.setRunning(true);
            sender.sendMessage(ChatColor.GRAY + "The timer has stopped.");
            return false;
        }
        if (args[0].equalsIgnoreCase("set")) {

            try {
                timer.setRunning(false);
                timer.setTimeD(Integer.parseInt(args[1]));
                timer.setTimeH(Integer.parseInt(args[2]));
                timer.setTimeM(Integer.parseInt(args[3]));
                timer.setTimeS(Integer.parseInt(args[4]));
                if (timer.getTimeH() < 24) {
                    if (timer.getTimeM() < 60) {
                        if (timer.getTimeS() < 60) {
                            sender.sendMessage(ChatColor.GRAY + "The timer has been set to " + args[1] + " days, " + args[2] + " hours, " + args[3] + " minutes, " + args[4] + " seconds.");
                        }
                    }
                }
            } catch (MissingFormatArgumentException e) {
                sender.sendMessage(ChatColor.RED + "You need to use the right format: Days, Hours, Minutes, Seconds");
            }
            return false;
        }

        if (args[0].equalsIgnoreCase("reset")) {
            timer.setRunning(false);
            timer.setRunback(false);
            timer.setTimeS(0);
            timer.setTimeM(0);
            timer.setTimeH(0);
            timer.setTimeD(0);
            sender.sendMessage(ChatColor.GRAY + "The timer has been reset.");
            return false;
        }

        if (args[0].equalsIgnoreCase("time")) {

            sender.sendMessage(timer.getTimeD() + "d, " + timer.getTimeH() + "h, " + timer.getTimeM() + "m, " + timer.getTimeS() + "s");
        }

        if (args[0].equalsIgnoreCase("toggle")) {

            if (timer.isRunning()) {
                timer.setRunning(false);
                sender.sendMessage(ChatColor.RED + "The timer is not running.");
            } else {
                timer.setRunning(true);
                sender.sendMessage(ChatColor.GREEN + "The timer has started.");
            }
        }

        return true;
    }
}

Timer Class

package tv.bebaeb.mcplugion.timer;

import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import tv.bebaeb.mcplugion.Mcplugion;

public class Timer {

    private boolean running; // true or false

    private boolean runback;
    private  int timeS;
    private  int timeM;
    private  int timeH;
    private  int timeD;



    public Timer(boolean running, int timeS, int timeM, int timeH, int timeD) {
        this.running = running;
        this.timeS = timeS;
        this.timeM = timeM;
        this.timeH = timeH;
        this.timeD = timeD;

        run();
    }

    public boolean isRunning() {
        return running;
    }

    public boolean isRunback() {
        return runback;
    }

    public void setRunning(boolean running) {
        this.running = running;
    }

    public void setRunback(boolean runback) {
        this.runback = runback;
    }

    public int getTimeS() {
        return timeS;
    }
    public int getTimeM() {
        return timeM;
    }
    public int getTimeH() {
        return timeH;
    }
    public int getTimeD() {
        return timeD;
    }
    public void setTimeS(int time) {
        this.timeS = time;
    }
    public void setTimeM(int time) {
        this.timeM = time;
    }
    public void setTimeH(int time) {
        this.timeH = time;
    }
    public void setTimeD(int time) {
        this.timeD = time;
    }
    public void sendActionBar() {

        for (Player player : Bukkit.getOnlinePlayers()) {

            if (!isRunning()) {
                    player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.RED +
                            "Timer paused"));
                    continue;
            }

            if (isRunning()) {
                if (getTimeM() == 0) {
                    player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.WHITE.toString() +
                            ChatColor.BOLD + String.format("%ds", getTimeS())));
                } else if (getTimeH() == 0) {
                    player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.WHITE.toString() +
                            ChatColor.BOLD + String.format("%dm %ds", getTimeM(), getTimeS())));
                } else if (getTimeD() == 0) {
                    player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.WHITE.toString() +
                            ChatColor.BOLD + String.format("%dh %dm %ds", getTimeH(), getTimeM(), getTimeS())));
                } else if (getTimeD() > 0) {
                    player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.WHITE.toString() +
                            ChatColor.BOLD + String.format("%dd %dh %dm %ds", getTimeD(), getTimeH(), getTimeM(), getTimeS())));
                }
            }
        }
    }



    private  void  run() {
        new BukkitRunnable() {
            @Override
            public void run() {
                sendActionBar();

                if (!isRunning()) {
                    return;
                }

                if (isRunback()) {

                    if (getTimeS() > 0) {
                        setTimeS(getTimeS() - 1);
                    } else {
                        if (getTimeM() > 0) {
                            setTimeS(59);
                            setTimeM(getTimeM() - 1);
                        } else {
                            if (getTimeH() > 0) {
                                setTimeM(59);
                                setTimeS(59);
                                setTimeH(getTimeH() - 1);
                            } else {
                                if (getTimeD() > 0) {
                                    setTimeH(23);
                                    setTimeM(59);
                                    setTimeS(59);
                                    setTimeD(getTimeD() - 1);
                                } else {
                                    sendActionBar();
                                    setRunning(false);
                                }
                            }
                        }
                    }

                } else {

                if (getTimeS() < 60) {
                    setTimeS(getTimeS() + 1);
                }

                if (getTimeS() > 59) {
                    setTimeS(0);
                    setTimeM(getTimeM() + 1);
                }

                if (getTimeM() > 59) {
                    setTimeM(0);
                    setTimeH(getTimeH() + 1);
                }

                if (getTimeH() > 23) {
                    setTimeH(0);
                    setTimeD(getTimeD() + 1);
                }
            }

            }
        }.runTaskTimer(Mcplugion.getInstance(), 20, 20);

    }

}

The error message:

 [20:56:22] [Server thread/INFO]: Bebaeb issued server command: /timer toggle
[20:56:22] [Server thread/ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'timer' in plugin mcplugion v1.0-SNAPSHOT
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[spigot-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R1.CraftServer.dispatchCommand(CraftServer.java:875) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at org.bukkit.craftbukkit.v1_20_R1.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:50) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:265) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.commands.CommandDispatcher.performCommand(CommandDispatcher.java:314) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.commands.CommandDispatcher.a(CommandDispatcher.java:298) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1962) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.server.network.PlayerConnection.lambda$18(PlayerConnection.java:1924) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.util.thread.IAsyncTaskHandler.b(SourceFile:67) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
        at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:156) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1152) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:1) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.util.thread.IAsyncTaskHandler.x(SourceFile:130) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.server.MinecraftServer.bg(MinecraftServer.java:1131) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1124) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.util.thread.IAsyncTaskHandler.c(SourceFile:139) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.server.MinecraftServer.p_(MinecraftServer.java:1108) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1019) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.20.1-R0.1-SNAPSHOT.jar:3859-Spigot-94e187b-f70a7b6]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.NoClassDefFoundError: tv/bebaeb/mcplugion/timer/Timer
        at tv.bebaeb.mcplugion.commands.TimerCommand.onCommand(TimerCommand.java:107) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        ... 23 more
Caused by: java.lang.ClassNotFoundException: tv.bebaeb.mcplugion.timer.Timer
        at tv.bebaeb.mcplugion.commands.TimerCommand.onCommand(TimerCommand.java:107) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        ... 23 more

The error while starting the server:

Sat, 09 Sep 2023 14:31:20 +0200: Starting Gameserver
[Nitrado] Starting Gameserver now...
Starting org.bukkit.craftbukkit.Main
[Log4jPatcher] [INFO] Transforming org/apache/logging/log4j/core/pattern/MessagePatternConverter
[Log4jPatcher] [WARN]  Unable to find noLookups:Z field in org/apache/logging/log4j/core/pattern/MessagePatternConverter
[Log4jPatcher] [INFO] Transforming org/apache/logging/log4j/core/lookup/JndiLookup
*** Warning, you've not updated in a while! ***
*** Please download a new build as per instructions from https://papermc.io/downloads/paper ***
System Info: Java 17 (OpenJDK 64-Bit Server VM 17.0.1+12) Host: Linux 5.8.15-301.fc33.x86_64 (amd64)
Loading libraries, please wait...
[12:31:26 INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
[12:31:27 INFO]: Loaded 7 recipes
[12:31:27 INFO]: Starting minecraft server version 1.20.1
[12:31:27 INFO]: Loading properties
[12:31:27 INFO]: This server is running Paper version git-Paper-19 (MC: 1.20.1) (Implementing API version 1.20.1-R0.1-SNAPSHOT) (Git: 837cc25)
[12:31:27 WARN]: Couldn't load server icon
java.lang.IllegalArgumentException: BufferedImage must be 64 pixels wide (225)
    at com.google.common.base.Preconditions.checkArgument(Preconditions.java:193) ~[guava-31.1-jre.jar:?]
    at org.bukkit.craftbukkit.v1_20_R1.CraftServer.loadServerIcon0(CraftServer.java:2362) ~[paper-1.20.1.jar:git-Paper-19]
    at org.bukkit.craftbukkit.v1_20_R1.CraftServer.loadServerIcon0(CraftServer.java:2352) ~[paper-1.20.1.jar:git-Paper-19]
    at org.bukkit.craftbukkit.v1_20_R1.CraftServer.loadIcon(CraftServer.java:1079) ~[paper-1.20.1.jar:git-Paper-19]
    at org.bukkit.craftbukkit.v1_20_R1.CraftServer.<init>(CraftServer.java:384) ~[paper-1.20.1.jar:git-Paper-19]
    at net.minecraft.server.players.PlayerList.<init>(PlayerList.java:171) ~[paper-1.20.1.jar:git-Paper-19]
    at net.minecraft.server.dedicated.DedicatedPlayerList.<init>(DedicatedPlayerList.java:16) ~[paper-1.20.1.jar:git-Paper-19]
    at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:203) ~[paper-1.20.1.jar:git-Paper-19]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1101) ~[paper-1.20.1.jar:git-Paper-19]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[paper-1.20.1.jar:git-Paper-19]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]
[12:31:27 INFO]: Server Ping Player Sample Count: 12
[12:31:27 INFO]: Using 4 threads for Netty based IO
[12:31:27 WARN]: [!] The timings profiler has been enabled but has been scheduled for removal from Paper in the future.
    We recommend installing the spark profiler as a replacement: https://spark.lucko.me/
    For more information please visit: https://github.com/PaperMC/Paper/issues/8948
[12:31:27 INFO]: [ChunkTaskScheduler] Chunk system is using 1 I/O threads, 28 worker threads, and gen parallelism of 28 threads
[12:31:28 INFO]: Default game type: SURVIVAL
[12:31:28 INFO]: Generating keypair
[12:31:28 INFO]: Starting Minecraft server on 5.83.164.146:53600
[12:31:28 INFO]: Using epoll channel type
[12:31:28 INFO]: Paper: Using libdeflate (Linux x86_64) compression from Velocity.
[12:31:28 INFO]: Paper: Using OpenSSL 1.1.x (Linux x86_64) cipher from Velocity.
[12:31:28 INFO]: [blubbub] Loading server plugin blubbub v1.0-SNAPSHOT
[12:31:28 INFO]: [mcplugion] Loading server plugin mcplugion v1.0-SNAPSHOT
[12:31:28 INFO]: Server permissions file permissions.yml is empty, ignoring it
[12:31:28 INFO]: Preparing level "world"
[12:31:28 INFO]: Preparing start region for dimension minecraft:overworld
[12:31:28 INFO]: Time elapsed: 139 ms
[12:31:28 INFO]: Preparing start region for dimension minecraft:the_nether
[12:31:29 INFO]: Time elapsed: 32 ms
[12:31:29 INFO]: Preparing start region for dimension minecraft:the_end
[12:31:29 INFO]: Time elapsed: 12 ms
[12:31:29 INFO]: [blubbub] Enabling blubbub v1.0-SNAPSHOT
[12:31:29 INFO]: [mcplugion] Enabling mcplugion v1.0-SNAPSHOT
[12:31:29 INFO]: 
McPlugion
M
C
P
L
U
G
I
O
N
McPlugion
[12:31:29 ERROR]: Error occurred while enabling mcplugion v1.0-SNAPSHOT (Is it up to date?)
java.lang.NoClassDefFoundError: tv/bebaeb/mcplugion/timer/Timer
    at tv.bebaeb.mcplugion.Mcplugion.onEnable(Mcplugion.java:40) ~[mcplugion-1.0-SNAPSHOT-shaded.jar:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:281) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
    at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:189) ~[paper-1.20.1.jar:git-Paper-19]
    at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[paper-1.20.1.jar:git-Paper-19]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:507) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.craftbukkit.v1_20_R1.CraftServer.enablePlugin(CraftServer.java:562) ~[paper-1.20.1.jar:git-Paper-19]
    at org.bukkit.craftbukkit.v1_20_R1.CraftServer.enablePlugins(CraftServer.java:473) ~[paper-1.20.1.jar:git-Paper-19]
    at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:636) ~[paper-1.20.1.jar:git-Paper-19]
    at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:435) ~[paper-1.20.1.jar:git-Paper-19]
    at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:308) ~[paper-1.20.1.jar:git-Paper-19]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1101) ~[paper-1.20.1.jar:git-Paper-19]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[paper-1.20.1.jar:git-Paper-19]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ClassNotFoundException: tv.bebaeb.mcplugion.timer.Timer
    at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:183) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:150) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
    ... 13 more
[12:31:29 INFO]: [mcplugion] Disabling mcplugion v1.0-SNAPSHOT
[12:31:29 INFO]: Starting GS4 status listener
[12:31:29 INFO]: Thread Query Listener started
[12:31:29 INFO]: Query running on 5.83.164.146:53601
[12:31:29 ERROR]: Couldn't load server icon
java.lang.IllegalStateException: Must be 64 pixels wide
    at com.google.common.base.Preconditions.checkState(Preconditions.java:502) ~[guava-31.1-jre.jar:?]
    at net.minecraft.server.MinecraftServer.lambda$loadStatusIcon$12(MinecraftServer.java:1355) ~[paper-1.20.1.jar:git-Paper-19]
    at java.util.Optional.flatMap(Optional.java:289) ~[?:?]
    at net.minecraft.server.MinecraftServer.loadStatusIcon(MinecraftServer.java:1351) ~[paper-1.20.1.jar:git-Paper-19]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1106) ~[paper-1.20.1.jar:git-Paper-19]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[paper-1.20.1.jar:git-Paper-19]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]
[12:31:29 INFO]: Running delayed init tasks
[12:31:29 INFO]: Done (1.511s)! For help, type "help"
[12:31:29 INFO]: Timings Reset
2

There are 2 best solutions below

3
Elikill58 On

The return of this method say if it should show the command usage. So return true means it will show it.

You're always returning true.

Else, you have an issue. You are checking if args is empty, then you are checking if first content of args is equals to something. This can't work. You should do like:

if(args.length == 0) {
   // here send help/usage message
} else if(args[0].equalsIgnoreCase("something")) {
   // here it's fine
}

You can also use return with like:

if(args.length == 0) {
   // here send help/usage message
   return false; // here you're stoping the method
}

if(args[0].equalsIgnoreCase("something")) {
   // here it's fine
}
0
Sprax On

The error you are seeing should already point you into the right direction: NoClassDefFoundError and ClassNotFoundException

This looks like some kind of issue at your build process that produces the final plugin .jar file.

I'd suggest opening the .jar file as a ZIP archive (for example in 7-zip or WinRar) and checking if the class file in question is actually inside it. The class com.stackoverflow.Foo would normally be in com/stackoverflow.Foo.class.

Make sure that if you are using Maven or Gradle that no optimization step is removing your classes by accident.

If you export to a jar file manually, make sure


PS: Your plugin is shown red in the list because it is not enabled. The server knows about it but this usually means it has been disabled because of an error (or manually).

You can see that happening in your log file:

[12:31:29 INFO]: [mcplugion] Enabling mcplugion v1.0-SNAPSHOT

[Your messages and the large error]

[12:31:29 INFO]: [mcplugion] Disabling mcplugion v1.0-SNAPSHOT