Solved trying to use GuardianBeamAPI, but nothing happens

Discussion in 'Spigot Plugin Development' started by guid118, Jul 10, 2021.

  1. Did you copy the code from the .java file or copy the file as a whole?

    Sent from my SM-A715F using Tapatalk
     
  2. Any error messages appearing on the console?
     
  3. Copied the code to a file with the exact same name

    No, just the fact that I issued the command

    I have seen many tutorials before, and before I rewrote the class, it all worked fine.
     
  4. Can you add a debug message with a Bukkit.broadcastMessage or something to verify that your command executor is well registered ? Your onCommand method seems to be right but I'm almost sure that the problem comes from your class.

    Is "Main" your main class that load everything ? I really don't understand why you want it to extend JavaPlugin... That's not how you add a command properly.
     
    • Like Like x 1
    • Agree Agree x 1
  5. i've made a complete rewrite of the plugin, now with a new class that will only execute the command and a main class that will register commands on enable (this was all not the issue, i was a moron and made the args length 8, while the last arg is number 8, so args length should be 9). but now i get this massive error, which i would usually be able to read, but i cant understand any of it (https://pastebin.com/D1m9BvTk)
    also, here is my now updated plugin (https://github.com/guid118/GuardianBeamRewrite).
    What would be the issue in this code?
     
  6. Yeah now it looks better. I think your error is an issue from laser command. First I saw you didn't copy the entire class, you should do so lines match from your copied file and the original file, but I don't think this is the reason of why the error occurs. Let take me a look I come back after my own testing (weird thing because I ran on 1.17 and 1.17.1 and nothing weird happened for me)
     
    • Like Like x 1
  7. You are correct, I did remove the duration in ticks, because that is what switches it on and off, and I want it to be always on.
     
  8. There was an error in 1.17.1, I sent a pull request on his github project (*poke* @SkytAsul). You can check what was wrong there :

    https://github.com/SkytAsul/GuardianBeam/pull/2

    You can already do the same modifications to fix this or wait for SkytAsul to merge the PR.

    I didn't test in 1.17.1 but only in 1.17, so I didn't see the error, my bad
     
    • Friendly Friendly x 1
  9. So, because spigot is still a snapshot for 1.17, it didn't work?
     
  10. I don't know exactly why SkytAsul changed the way he gets the minor version between 1.17 and other, currently it's :
    Code (Java):
    if (version >= 17) {
        versions = Bukkit.getBukkitVersion().split("-R")[0].split("\\.");
        versionMinor = versions.length <= 2 ? 0 : Integer.parseInt(versions[2]);
    }else versionMinor = Integer.parseInt(versions[2].substring(1)); // 1.X.Y
    The thing is Bukkit.getBukkitVersion() returns 1.17.1-R0.1-SNAPSHOT but every version of Spigot or Paper need "SNAPSHOT".

    For example, with paper you import the dependency :
    Code (Java):
            <dependency>
                <groupId>io.papermc.paper</groupId>
                <artifactId>paper-api</artifactId>
                <version>1.17.1-R0.1-SNAPSHOT</version>
                <scope>provided</scope>
            </dependency>
    With Spigot :
    Code (Java):
        <dependency>
               <groupId>org.spigotmc</groupId>
               <artifactId>spigot-api</artifactId>
               <version>1.16.5-R0.1-SNAPSHOT</version>
               <scope>provided</scope>
        </dependency>
    It's like that even if the version is 1.16, 1.15 or 1.17. All versions are named "snapshot".

    The error here occurs because method Bukkit.getBukkitVersion() is not in the same format than Bukkit.getServer().getClass().getPackage().getName() and that changes the way you get the major and minor versions. It's only split and string manipulation.
     
    • Like Like x 1
  11. So, now I can copy the code you from your PR into the Laser.java and remove the old code and it should work?
     
  12. #14 cricri_21, Jul 11, 2021
    Last edited: Jul 11, 2021
    • Like Like x 1