Solved Getting Player ping in 1.16.4

Discussion in 'Plugin Development' started by qtimexdel, Nov 18, 2020.

  1. Offline

    qtimexdel

    Hey everyone
    I know that this got asked alot.
    I also found alot stuff for that.

    But for most of the time i found something like that:
    Code:
    ((CraftPlayer) player).getHandle().ping;
    so basically casting a player into a CraftPlayer and use getHandle().ping to get the players ping as integer.
    That also worked in some of my older plugins from 1.8 or something

    currently I'm using the version 1.16.4-R0.1-SNAPSHOT from the spigot-api
    But i can't find a CraftPlayer... has it got renamed or something?
    And in case that is outdated is there another way to get the players ping?

    Code:
        <repositories>
            <repository>
                <id>spigotmc-repo</id>
                <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
            </repository>
            <repository>
                <id>sonatype</id>
                <url>https://oss.sonatype.org/content/groups/public/</url>
            </repository>
        </repositories>
    
        <dependencies>
            <dependency>
                <groupId>org.spigotmc</groupId>
                <artifactId>spigot-api</artifactId>
                <version>1.16.4-R0.1-SNAPSHOT</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
     
    Last edited: Nov 19, 2020 at 12:46 AM
  2. Offline

    Kars

  3. Offline

    MrDaniel

    The CraftPlayer class still exists, but the import has been renamed.
     
  4. Offline

    qtimexdel

    Thank you guys for the response.

    @MrDaniel
    then what is the new name for CraftPlayer?
    I mean normaly its just changing by the version name

    But I still cant find it

    @Kars imma try that thank you
    But for me it looks like the is kinda doing the same as me but just with the addition that he imports the class via the version name of bukkit. For my plugin it can stay on that version but i cant import it so yea I think that should then also not work


    ok never mined that PingUtil worked fine for me :D thank you for the responses :D
     
    Last edited: Nov 19, 2020 at 2:30 PM

Share This Page