Solved 1.15 Plugin

Discussion in 'Spigot Plugin Development' started by DarkKnights22, Jan 8, 2020.

  1. I've no idea if it's my plugin or my server, but when I use the command /tokens on my 1.8.8 server, it works, and sends the message. When I use it on my 1.15 server it doesn't. Same exact jar. Funny thing is, /tokenshop works in 1.15 which is another command in the same plugin.
     
  2. Edit: Wasn't what i first thought.
     
    #2 Bobcatsss, Jan 8, 2020
    Last edited: Jan 8, 2020
  3. No I'm not, it's my own plugin.
     
  4. Okay. Is there any error when you run the command, if so please post the error and code for the section that is causing the problem.
     
  5. I mean... some API is deprecated/ got changed since 1.8.8
     
  6. No, that's why I'm asking here..
    No errors upon compiling against 1.15.1.
     
  7. Have you specified an api version in the plugin.yml?

    Code (Text):
    api-version: 1.15
     
  8. Yes.
     
  9. What do you mean not working, at all? Any errors?
     
  10. No. Literally nothing happens at all.
     
  11. Make sure to check for errors in your console (and ingame).
    Also make sure that you are registering the command the right way: bukkit method, plugin.yml.

    If you did all that and it all turns out fine, you can try adding debug messages in your code for that command.
    For example, before every if-statement, you print to the console a number / just what has been checked.

    Maybe sending your command code could help us solve your problem.
    Put it in a paste and send it to us: https://my.gaagjescraft.net/paste
     
  12. Make sure your plugin got loaded. Also check for errors on startup.
     
  13. I've said multiple times there are no errors. It loads correctly and I've also said that /tokenshop works. The code is just sending a message onCommand
     
  14. Have you tried changing the command name to something else?
    Or perhaps, adding an alias and trying that?
     
  15. drgsgsrrrrrrrrrrrrrrrrrrr
    Could you still send the code please. If you don't want it to be public, you can also DM it to me.
     
  16. if it's your own plugin, you should start tracing it...
     
  17. Code (Text):
    @Override
        public boolean onCommand(CommandSender sender, Command cmd, String s, String[] args) {
            if (sender.isOp()) {
                if (args.length == 0) {
                    sendHelp(sender);
                    return true;
                } else if (args[0].equalsIgnoreCase("give")) {
                    if (args.length != 3) {
                        sender.sendMessage(Chat.color("&c&l(!) &cIncorrect command usage! Do &c&n/tokens help&c for a list of commands"));
                        return true;
                    }
                    Player player = Bukkit.getPlayer(args[1]);
                    if (args.length == 3) {
                        player.getInventory().addItem(pl.rift.getRiftToken(Integer.parseInt(args[2])));
                    }
                    return true;
                } else if (args[0].equalsIgnoreCase("reload")) {
                    pl.reloadConfig();
                    sender.sendMessage(ChatColor.GREEN + "You successfully reloaded the PlatinumTokens configuration files!");
                    return true;
                } else if (args[0].equalsIgnoreCase("help")) {
                    sendHelp(sender);
                    return true;
                }
            }
            return true;
        }
     
  18. Code above (alone) works completely fine; I just had to replace sendHelp and Chat.color since I didn't have those. The issue may be in those individual methods or, could it just be you're not opped? I tried them from the console and they worked, so maybe give that a go.
     
  19. is tokenshop an alias by any chance? How do you go about making both commands execute same class? You are giving us nothing to go on. Please give us more details to help you.
     
  20. I see a number of ways this can break and not work properly, firstly, how does your plugin.yml look? what does your command registry look like? also see some issues in the method itself, you've missed a check after you assigned the Bukkit#getPlayer, it could return null, and a try-catch block, so you'll get a NumberFormatException if you pass anything but a valid number as the amount, that could be something to look into.