Solved Implementing Issue

Discussion in 'Spigot Plugin Development' started by Joedon, Jun 10, 2016.

Thread Status:
Not open for further replies.
  1. Hi. With my version detector I have 4 classes for 4 different versions, along with the main class. All of them currently get the 'does not implement the requested interface' for NMS. Here is the some of the code for one of the classes which doesn't work:

    Code (Text):
    public class VersionDetector19 implements NMS{

          public TabListEdit plugin1;
         
             public VersionDetector19(TabListEdit plugin) {
                 this.plugin1 = plugin;
             }
     
             public VersionDetector19(VersionDetector19 plugin12) {
            }

            public void sendTabHF(Player player, String header, String footer) {
    ...
    }
    }
    And part of my main class:

    Code (Text):
    public VersionDetector18 plugin2;
    public VersionDetector19 plugin1;
    public VersionDetector194 plugin3;
    public VersionDetector110 plugin4;
    private NMS nmsInstance;

    public interface NMS {
        void sendTabHF(Player player, String header, String footer);
    }

        static Integer getVersion() {
            String ver = Bukkit.getServer().getClass().getPackage().getName();
            ver = ver.substring(ver.lastIndexOf('.') + 1);
            ver = ver.replaceAll("_", "");
            ver = ver.replaceAll("R", "");
            return Integer.parseInt(ver);
        }
     
        public void onEnable() {
     
            //tabName(this);
            tabHeader(this);
            tabFooter(this);
            tabRefresh(this);

              String implVersion;
                 try {
                     implVersion = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
                 } catch (ArrayIndexOutOfBoundsException e) {
                     implVersion = "unknown";
                 }
                 switch(implVersion) {
                     case "v1_8_R3":
                         this.nmsInstance= (NMS) new VersionDetector18(plugin2);
                         Bukkit.getServer().getPluginManager().registerEvents(this, this);
                        break;
                     case "v1_9_R1":
                         this.nmsInstance= (NMS) new VersionDetector19(plugin1);
                         Bukkit.getServer().getPluginManager().registerEvents(this, this);
                        break;
                     case "v1_9_R2":
                         this.nmsInstance= (NMS) new VersionDetector194(plugin3);
                         Bukkit.getServer().getPluginManager().registerEvents(this, this);
                         break;
                   //  case "v1_10_R1":
                        // this.nmsInstance= (NMS) new VersionDetector110(plugin4);
                     //    Bukkit.getServer().getPluginManager().registerEvents(this, this);
                     //    break;
                     default:
                          this.setEnabled(false);
                          return;
                 }
             }
       

    Thanks for any help. This was working before and I don't know what made it mess up. I am interacting with the version detectors with nmsInstance.sendTabHF(...);
     
  2. Well I only see a interface in the second code snippet and not your main class definition including the extends Javaplugin.
     
  3. I have this part in the extends JavaPlugin class, and implement it in my VersionDetector classes, but it says it isn't implemented with implements NMS:

    Code (Text):
    public interface NMS {
         void sendTabHF(Player player, String header, String footer);
    }
     
  4. What do you mean with this?
     
  5. Code (Text):
    java.lang.IncompatibleClassChangeError: Class me.JoeDon16.VersionDetector19 does
    not implement the requested interface me.JoeDon16.TabListEdit$NMS
            at me.JoeDon16.TabListEdit$4.run(TabListEdit.java:293) ~[?:?]
            at org.bukkit.craftbukkit.v1_9_R1.scheduler.CraftTask.run(CraftTask.java
    :71) ~[spigot-1.9.2.jar:git-Spigot-e000104-4cb3258]
            at org.bukkit.craftbukkit.v1_9_R1.scheduler.CraftScheduler.mainThreadHea
    rtbeat(CraftScheduler.java:350) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258]
            at net.minecraft.server.v1_9_R1.MinecraftServer.D(MinecraftServer.java:7
    29) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258]
            at net.minecraft.server.v1_9_R1.DedicatedServer.D(DedicatedServer.java:4
    00) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258]
            at net.minecraft.server.v1_9_R1.MinecraftServer.C(MinecraftServer.java:6
    60) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258]
            at net.minecraft.server.v1_9_R1.MinecraftServer.run(MinecraftServer.java
    :559) [spigot-1.9.2.jar:git-Spigot-e000104-4cb3258]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_65]

    That's the error I get. Sorry for not putting it in earlier ;3 - line 293 is using nmsInstance.sendTabHF(...);
     
    • Informative Informative x 1
Thread Status:
Not open for further replies.