1.8.8 I don't know what happend?

Discussion in 'Spigot Plugin Development' started by fangshenghan, Feb 9, 2020.

  1. I used a plugin's code.
    but there are something i don't understand,and it's waring.
    Code (Java):
    public enum PackageType
    {
         MINECRAFT_SERVER("net.minecraft.server." + getServerVersion()),
         //WARINGSTART
         CRAFTBUKKIT("org.bukkit.craftbukkit." + getServerVersion()),
         CRAFTBUKKIT_BLOCK((String)CRAFTBUKKIT, "block"),
         CRAFTBUKKIT_CHUNKIO((String)CRAFTBUKKIT, "chunkio"),
         CRAFTBUKKIT_COMMAND((String)CRAFTBUKKIT, "command"),
         CRAFTBUKKIT_CONVERSATIONS((String)CRAFTBUKKIT, "conversations"),
       CRAFTBUKKIT_ENCHANTMENS((String)CRAFTBUKKIT, "enchantments"),
         CRAFTBUKKIT_ENTITY((String)CRAFTBUKKIT, "entity"),
         CRAFTBUKKIT_EVENT((String)CRAFTBUKKIT, "event"),
         CRAFTBUKKIT_GENERATOR((String)CRAFTBUKKIT, "generator"),
         CRAFTBUKKIT_HELP((String)CRAFTBUKKIT, "help"),
         CRAFTBUKKIT_INVENTORY((String)CRAFTBUKKIT, "inventory"),
         CRAFTBUKKIT_MAP((String)CRAFTBUKKIT, "map"),
         CRAFTBUKKIT_METADATA((String)CRAFTBUKKIT, "metadata"),
         CRAFTBUKKIT_POTION((String)CRAFTBUKKIT, "potion"),
    CRAFTBUKKIT_PROJECTILES((String)CRAFTBUKKIT, "projectiles"),
    CRAFTBUKKIT_SCHEDULER((String)CRAFTBUKKIT, "scheduler"),
    CRAFTBUKKIT_SCOREBOARD((String)CRAFTBUKKIT, "scoreboard"),
        CRAFTBUKKIT_UPDATER((String)CRAFTBUKKIT, "updater"),
         CRAFTBUKKIT_UTIL((String)CRAFTBUKKIT, "util");
       //WARINGEND
         private final String path;
     
         PackageType(String path) { this.path = path; }
     
         public String getPath() { return this.path; }
           public Class<?> getClass(String className) throws ClassNotFoundException { return Class.forName(this + "." + className); }
     
         public String toString() { return this.path; }
    public static String getServerVersion() { return Bukkit.getServer().getClass().getPackage().getName().substring(23); }
    }
    Cannot cast from ReflectionUtils.PackageType to String
    Exception:
    Code (Text):
    Task #1768 for cuilian v1.4 generated an exception
    java.lang.Error: Unresolved compilation problem:

            at cc.toin.cuilian.lizi.ReflectionUtils$PackageType.getServerVersion(ReflectionUtils.java:296) ~[?:?]
            at cc.toin.cuilian.lizi.ParticleEffect$ParticlePacket.initialize(ParticleEffect.java:633) ~[?:?]
            at cc.toin.cuilian.lizi.ParticleEffect$ParticlePacket.<init>(ParticleEffect.java:596) ~[?:?]
            at cc.toin.cuilian.lizi.ParticleEffect.display(ParticleEffect.java:223) ~[?:?]
            at cc.toin.cuilian.lizi.Jianting.run(Jianting.java:76) ~[?:?]
            at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) ~[PaperSpigot-1.8.8.jar:git-PaperSpigot-f6fba00-9935adc]
            at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [PaperSpigot-1.8.8.jar:git-PaperSpigot-f6fba00-9935adc]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:779) [PaperSpigot-1.8.8.jar:git-PaperSpigot-f6fba00-9935adc]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378) [PaperSpigot-1.8.8.jar:git-PaperSpigot-f6fba00-9935adc]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:710) [PaperSpigot-1.8.8.jar:git-PaperSpigot-f6fba00-9935adc]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:613) [PaperSpigot-1.8.8.jar:git-PaperSpigot-f6fba00-9935adc]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
    ReflectionUtils.java:296 -
    public static String getServerVersion() { return Bukkit.getServer().getClass().getPackage().getName().substring(23); }
     
    #1 fangshenghan, Feb 9, 2020
    Last edited: Feb 9, 2020
  2. Do not copy code that you do not understand.
     
  3. You shouldn’t be copying a plugins code without the authors permission and knowledge of java
    What plugin is it and why are you copying it?