API PingAPI: Listen for and modify outgoing ping responses

Discussion in 'Resources' started by Skionz, Feb 7, 2015.

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

    Skionz

  2. Offline

    567legodude

    @Skionz Yeah, the one from spigot.
     
  3. Offline

    Skionz

    @567legodude Can you post your entire stack-trace and class? Also, check which version of PingAPI your using.
     
  4. Offline

    567legodude

    @Skionz
    Entire error:
    Code:
    User 567legodude has disconnected, reason: Internal Exception: java.lang.NoClassDefFoundError: net/minecraft/server/v1_8_R1/PacketStatusOutPong
    Code:
    Code:
    package package.name;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import org.bukkit.ChatColor;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scheduler.BukkitRunnable;
    
    import com.skionz.pingapi.PingAPI;
    import com.skionz.pingapi.PingEvent;
    import com.skionz.pingapi.PingListener;
    import com.skionz.pingapi.PingReply;
    import com.skionz.pingapi.ServerInfoPacket;
    
    public class main extends JavaPlugin {
      
        @Override
        public void onEnable() {
            PingAPI.registerListener(new PingListener() {
                public void onPing(PingEvent event) {
                    PingReply reply = event.getReply();
                    reply.setProtocolVersion(-1);
                    reply.setProtocolName(ChatColor.GRAY + "lol");
                    reply.setMOTD("This is le motd");
                    List<String> sample = new ArrayList<String>();
                    sample.add(ChatColor.WHITE + "Players Online:");
                    sample.add(ChatColor.RED + "guy1");
                    sample.add(ChatColor.LIGHT_PURPLE + "guy2");
                    sample.add(ChatColor.AQUA + "guy3");
                    reply.setPlayerSample(sample);
                    ServerInfoPacket packet = event.createNewPacket(event.getReply());
                    packet.setPingReply(reply);
                    packet.send();
                    event.setCancelled(true);
                }
            });
        }
    
        @Override
        public void onDisable() {
        }
    
    }
    Not sure what version it is but I got it like 12 hours ago.
     
  5. @567legodude There is a 1.7 and 1.8 version, make sure you download the 1.8 version
     
  6. Offline

    567legodude

    @bwfcwalshy @Skionz The latest version (0.1.4) is what I got.
    Which one is for 1.7 and which version is for 1.8?
     
  7. Offline

    Skionz

    This works perfectly fine for me when running 0.1.4. Can you post the entire startup log?
     
  8. Offline

    Sm0oth_kriminal

    @Skionz
    Will there be any support for bungee cord? How can we use it with that?
     
  9. @Sm0oth_kriminal
     
  10. Offline

    BrickBoy55

    I can't get the GameProfile to work, it says "GameProfile cannot be resolved to a type."
     
  11. Offline

    Skionz

    Last edited: Feb 17, 2015
  12. Offline

    BrickBoy55

    Yes, that might be easier.

    I can't seem to find a solution, can you show a string list example. :/

    @Skionz
    Does the latest update have it as a String List or are you going to do an update?
     
    Last edited by a moderator: Feb 18, 2015
  13. Offline

    Skionz

    PingReply#setPlayerSample() takes a String List in the newer versions.
     
  14. Offline

    BrickBoy55

    @Skionz
    Thanks! Also, you should put in the description how to make an animated MOTD.
     
  15. Offline

    Skionz

    @BrickBoy55
    I did in the OP. "Sending multiple PacketStatusOutServerInfo packets"
     
  16. Offline

    BrickBoy55

    I keep getting this same error and I have no idea how to fix it:

    Class:
    Show Spoiler

    Code:
    public void onEnable() {
            PingAPI.registerListener(new PingListener() {
                public void onPing(PingEvent event) {
                    List<String> list = new ArrayList<String>();
                    list.add("§9§lChaos MC");
                    list.add("§8§l============================");
                    list.add("§6§lA chaotic custom minigame!");
                    event.getReply().setPlayerSample(list);
                    event.getReply().setMOTD("§8§l[]-<()>-[] §9§lChaos MC §8§l[]-<()>-[]\n§6§lA chaotic custom minigame!");
                }
            });
        }
    


    Error:
    Show Spoiler

    [19:29:07] [Server thread/ERROR]: Error occurred while enabling ChaosEssentials v1.0 (Is it up to date?)
    java.lang.ClassCastException: org.brick.chaosessentials.Main cannot be cast to com.skionz.pingapi.PingListener
    at org.brick.chaosessentials.Main.onEnable(Main.java:14) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot.jar:git-Spigot-952179b-0cf233d]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:335) [spigot.jar:git-Spigot-952179b-0cf233d]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-952179b-0cf233d]
    at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugin(CraftServer.java:356) [spigot.jar:git-Spigot-952179b-0cf233d]
    at org.bukkit.craftbukkit.v1_8_R1.CraftServer.enablePlugins(CraftServer.java:316) [spigot.jar:git-Spigot-952179b-0cf233d]
    at net.minecraft.server.v1_8_R1.MinecraftServer.q(MinecraftServer.java:402) [spigot.jar:git-Spigot-952179b-0cf233d]
    at net.minecraft.server.v1_8_R1.MinecraftServer.k(MinecraftServer.java:370) [spigot.jar:git-Spigot-952179b-0cf233d]
    at net.minecraft.server.v1_8_R1.MinecraftServer.a(MinecraftServer.java:325) [spigot.jar:git-Spigot-952179b-0cf233d]
    at net.minecraft.server.v1_8_R1.DedicatedServer.init(DedicatedServer.java:211) [spigot.jar:git-Spigot-952179b-0cf233d]
    at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:494) [spigot.jar:git-Spigot-952179b-0cf233d]
    at java.lang.Thread.run(Thread.java:745) [?:1.7.0_55]
     
  17. Offline

    Skionz

  18. Offline

    BrickBoy55

    Sure:

    Show Spoiler

    Code:
    package org.brick.chaosessentials;
    
    import java.util.ArrayList;
    import java.util.List;
    
    import org.bukkit.plugin.java.JavaPlugin;
    
    import com.skionz.pingapi.PingAPI;
    import com.skionz.pingapi.PingEvent;
    import com.skionz.pingapi.PingListener;
    
    public class Main extends JavaPlugin {
        public void onEnable() {
            PingAPI.registerListener(new PingListener() {
                public void onPing(PingEvent event) {
                    List<String> list = new ArrayList<String>();
                    list.add("§9§lChaos MC");
                    list.add("§8§l============================");
                    list.add("§6§lA chaotic custom minigame!");
                    event.getReply().setPlayerSample(list);
                    event.getReply().setMOTD("§8§l[]-<()>-[] §9§lChaos MC §8§l[]-<()>-[]\n§6§lA chaotic custom minigame!");
                }
            });
        }
    }
    
     
  19. Offline

    Skionz

    @BrickBoy55 It worked perfectly for me. Are you positive that stack-trace is the one corresponding to the code you posted? The plugin may not be updating when you export it. Try adding some debug lines.
     
  20. Offline

    BrickBoy55

    Ok. That's literally everything in my plugin though, so I have no idea.

    EDIT AFTER TESTING: It's not even firing the onEnable() method :I
     
  21. Offline

    Skionz

    @BrickBoy55
    EDIT: The plugin probably is not updating and you are exporting it incorrectly.
     
    Last edited: Feb 19, 2015
  22. Offline

    NetherSky

    ??
    error (open)
    [06:41:07] [Server thread/INFO]: [PingAPI] Enabling PingAPI v0.1.5
    [06:41:07] [Server thread/WARN]: java.lang.ClassNotFoundException: com.skionz.pingapi.v1_7_R1.PingInjector
    [06:41:07] [Server thread/WARN]: at java.net.URLClassLoader$1.run(Unknown Source)
    [06:41:07] [Server thread/WARN]: at java.net.URLClassLoader$1.run(Unknown Source)
    [06:41:07] [Server thread/WARN]: at java.security.AccessController.doPrivileged(Native Method)
    [06:41:07] [Server thread/WARN]: at java.net.URLClassLoader.findClass(Unknown Source)
    [06:41:07] [Server thread/WARN]: at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:80)
    [06:41:07] [Server thread/WARN]: at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53)
    [06:41:07] [Server thread/WARN]: at java.lang.ClassLoader.loadClass(Unknown Source)
    [06:41:07] [Server thread/WARN]: at java.lang.ClassLoader.loadClass(Unknown Source)
    [06:41:07] [Server thread/WARN]: at java.lang.Class.forName0(Native Method)
    [06:41:07] [Server thread/WARN]: at java.lang.Class.forName(Unknown Source)
    [06:41:07] [Server thread/WARN]: at com.skionz.pingapi.PingAPI.onEnable(PingAPI.java:18)
    [06:41:07] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:218)
    [06:41:07] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
    [06:41:07] [Server thread/WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:384)
    [06:41:07] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugin(CraftServer.java:298)
    [06:41:07] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_7_R1.CraftServer.enablePlugins(CraftServer.java:280)
    [06:41:07] [Server thread/WARN]: at net.minecraft.server.v1_7_R1.MinecraftServer.m(MinecraftServer.java:342)
    [06:41:07] [Server thread/WARN]: at net.minecraft.server.v1_7_R1.MinecraftServer.g(MinecraftServer.java:319)
    [06:41:07] [Server thread/WARN]: at net.minecraft.server.v1_7_R1.MinecraftServer.a(MinecraftServer.java:275)
    [06:41:07] [Server thread/WARN]: at net.minecraft.server.v1_7_R1.DedicatedServer.init(DedicatedServer.java:175)
    [06:41:07] [Server thread/WARN]: at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:424)
    [06:41:07] [Server thread/WARN]: at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617)
     
  23. Offline

    Skionz

    @NetherSky Only 1.7.9, 1.7.10, and 1.8 are supported.
     
  24. Offline

    _Filip

    ??
    error (open)
     
    Skionz likes this.
  25. Offline

    UniqueNameDen

    Hmhm,
    ServerConnection conn = this.server.getServerConnection();
    does not exist...?

    Spigot_1.8.jar from buildtools.jar
    CraftBukkit_1.8.jar from buildtools.jar

    @Skionz
     
  26. Offline

    CoderRyan

    Works on private host but doesn't work on public server though?

    It just pings the server and nothing happens. Any reason why?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 7, 2015
  27. Offline

    Skionz

    @CoderRyan Post the class and stack-trace (if there is one)
     
  28. Offline

    UniqueNameDen

    -Ignore my TOP post, it works with the latest version of spigot from BuildTools.jar

    @Skionz
    No errors,

    Debug log:
    stuff:null
    PacketReply: com.skionz.pingapi.PingReply@e81e955
    Get Current Packet: com.skionz.pingapi.v1_8_R1.ServerInfoPacketHandler@bcb90d9
    PacketReply: com.skionz.pingapi.PingReply@e81e955
    Get Current Packet: com.skionz.pingapi.v1_8_R1.ServerInfoPacketHandler@bcb90d9

    Code:
    http://pastebin.com/pdubeRHU

    The if (timeLeft == 0) {}
    part doesn't work, it does not update MOTD...?

    RESULT:
    http://i.gyazo.com/2b6c1c9490960cd162e66c492bd4b748.png

    and the result should be:
    PING STATUS: CLOSED
     
    Last edited: Feb 22, 2015
  29. Offline

    Skionz

  30. Offline

    CoderRyan

    @Skionz Unfortunately there is no stacked trace. It works fine on my private server but on a public server it doesn't? Really weird haha
     
Thread Status:
Not open for further replies.

Share This Page