Solved CraftPlayer is not a datatype?

Discussion in 'Plugin Development' started by Thrasherop, Aug 10, 2021.

Thread Status:
Not open for further replies.
  1. Offline

    Thrasherop

    Hey yall

    I'm trying to work with CraftPlayer to manage packets, but CraftPlayer isn't even showing up as a data type. I'm in Intellij using the "Minecraft Development Plugin" with build 2020.3-1.5.12. I'm not very experienced with bukkit development. Everywhere I see online makes it seem like CraftPlayer is just a normal included datatype with this plugin (such as Player or Material). I'm just looking for some noobish help on figuring out why I don't have this class, and/or how to get it properly added to my project.

    I've tried force importing, but org.bukkit.craftbukkit isn't a thing in my IDE

    I'll appreciate any help
     
    Last edited: Aug 10, 2021
  2. Offline

    davidclue

    Code:
    import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
    
    ((CraftPlayer) all).getHandle().b.sendPacket(packet);
    Make sure you have the craftbukkit jar imported, for this I'm using 1.17.1
     
  3. Offline

    KarimAKL

    @Thrasherop You are using the API, not the server. OBC (org.bukkit.craftbukkit) & NMS (net.minecraft.server) are only available when using the server. I would recommend using Maven to handle dependencies.
     
  4. Offline

    Thrasherop


    How do I import the craft bukkit jar? I'm also trying to do what karim said, but trying to search org.bukkit.craftbukkit isn't showing anything (see photos). What am I doing wrong? By server do you mean the actual bukkit jar? I'm very confused with this lol
    @KarimAKL
     

    Attached Files:

  5. Offline

    KarimAKL

    Yes. The server jar with the name "craftbukkit-1.17.jar" (or something like that).
     
  6. Offline

    Thrasherop

  7. Offline

    Shqep

    @Thrasherop
    A few helpful links:
    Managing dependencies in Maven
    Managing dependencies in Gradle

    Quick code, should be comprehensible on their own:
    pom.xml (open)

    Code:
    <dependency>
        <groupId>...</groupId>
        <artifactId>...</artifactId>
        <version>...</version>
        <scope>system</scope>
        <systemPath>path/to/the/craftbukkit/jar/you/should/know</systemPath>
    </dependency>
    


    build.gradle (open)

    Code:
    implementation files('path/to/the/craftbukkit/jar')
    
     
  8. Offline

    davidclue

    @Thrasherop
    Can't help you there I use Eclipse but just watch a video on how to import java libraries into Intellij it will take like 10 seconds to do. Make sure you are importing the actual craftbukkit server jar (The one you use to start the server). I don't use maven, it seems like coding with extra steps to me.
     
  9. Offline

    Thrasherop

    Awesome. Thank you guys all for the help. It seems to be importing properly which is hype. For any future people having this issue, specifically what I did was this:
    Code:
    <dependency>
                <groupId>...</groupId>
                <artifactId>...</artifactId>
                <version>...</version>
                <scope>system</scope>
                <systemPath>${java.home}\..\..\..\Users\<MyUserName>\Downloads\craftbukkit-1.17.1 (1).jar</systemPath>
            </dependency>
    The "\..\..\..\" jumping up to the root directory. Thanks again all of you guys. Cheers!
     
    Shqep likes this.
  10. Offline

    KarimAKL

    There is no reason to use the system scope; running BuildTools will install the jar in your local maven repository, so it should work fine with just groupId, artifactId, version, and optionally the provided scope.
     
  11. Offline

    Shqep

    Going off topic already but usually system scope is used in multiple people projects, who have a dedicated "libs" folder. There's kind of no reason to discourage the use of it.
    The only bad practice here I think is that the OP is using an absolute path, instead of a relative path to some sort of a "libs" folder.

    I'm probably misunderstanding but you sound somehow really annoyed when you say that there is no reason to use the system scope.
     
    KarimAKL likes this.
  12. Offline

    KarimAKL

    Oh, that was not my intention, sorry about that. :p
     
    Shqep likes this.
Thread Status:
Not open for further replies.

Share This Page