player.openWorkbench & player.openEnchanting

Discussion in 'Spigot Plugin Help' started by Decaf1, Mar 15, 2020.

  1. Hello,

    I have 2 classes, one for opening Workbench and the other for Enchantment table

    The workbench table code is working perfect.
    Code (YAML):

    package me.decaf1.vanillacheat.commands;

    import me.decaf1.vanillacheat.VanillaCheat;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;

    public class workbench implements CommandExecutor {

        private VanillaCheat plugin;
        public workbench(VanillaCheat plugin) {
            this.plugin = plugin;
        }

        @Override
        public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
            if (commandSender instanceof Player) {
                Player player = (Player) commandSender;
                player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("workbench")));
                player.openWorkbench(null, true);
            }

            return true;
        }
    }
     

    The enchantment table code is working 50/50. The message is getting to player but does not open the Enchantment table, I do not get any errors.
    Code (YAML):

    package me.decaf1.vanillacheat.commands;

    import me.decaf1.vanillacheat.VanillaCheat;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;

    public class enchant implements CommandExecutor {

        private VanillaCheat plugin;
        public enchant(VanillaCheat plugin) {
            this.plugin = plugin;
        }
       
        @Override
        public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
            if (commandSender instanceof Player) {
                Player player = (Player) commandSender;
                player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("enchant")));
                player.openEnchanting(null, true);
            }
            return true;
        }
    }
     

    The plugin file is correct, permissions are working aswell
    The command is also registered in the Main class

    Thank you in advance,
    Decaf1 (Jeremy)
     
  2. I just noticed that I posted this in the wrong section. Im sorry.