ServerListPingEvent Icon

Discussion in 'Plugin Development' started by MOMOTHEREAL, Jan 7, 2014.

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

    MOMOTHEREAL

    Hello!
    I am just wondering how to use the ServerListPingEvent's .setServerIcon() method.
    How can I use the CachedServerIcon class? Docs do not seem to be updated yet.

    ~Momo
     
  2. Offline

    Garris0n

  3. Offline

    MOMOTHEREAL

    Garris0n Oh, didn't realize that :p
    Imma search around too :)

    ~Momo
     
  4. Offline

    Garris0n

  5. Offline

    MOMOTHEREAL

    Garris0n This is what I came up too. Untested yet, what do you think about it?
    Code:java
    1. try {
    2. CachedServerIcon icon = Bukkit.loadServerIcon(new File("/icons/test.png"));
    3. event.setServerIcon(icon);
    4. } catch (Exception e) {
    5. e.printStackTrace();
    6. }
     
  6. Offline

    Garris0n

    It should work.
     
  7. Offline

    MOMOTHEREAL

    Seems to work! :D
    Just had to remove the first "/" in the file name
    Code:java
    1. try {
    2. CachedServerIcon icon = Bukkit.loadServerIcon(new File("icons/test.png"));
    3. event.setServerIcon(icon);
    4. } catch (Exception e) {
    5. e.printStackTrace();
    6. }
     
  8. Offline

    Garris0n

    Note that it will fail on windows if you don't use File.separator as the separator.
     
  9. Offline

    MOMOTHEREAL

  10. Offline

    Garris0n

    Windows and osx/linux use different file separators.
     
  11. Offline

    xTigerRebornx

    MOMOTHEREAL Windows reads the file location differently, File.separator will just put a "/" that is friendly for most OS's

    EDIT: Ninja'd
     
  12. Offline

    MOMOTHEREAL

    Garris0n xTigerRebornx
    Well my server runs on Windows so I wont really need it for my plugin, but could be useful when creating public plugins :)

    ~Resolved~
     
Thread Status:
Not open for further replies.

Share This Page