[Un-Solved] PlayerCountMessage

Discussion in 'Plugin Development' started by SimplyCode, Jul 13, 2014.

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

    SimplyCode

    I've been making a PlayerCountMessagePlugin and it's been going okay, until I hit this bump.
    Java is saying that "PlayerCountMessage" is not resolved to a type.
    The error is accuring on line 56 of my code, any help?
    Code:java
    1. package me.jlsteelers.Packets;
    2.  
    3. import java.io.File;
    4. import java.io.IOException;
    5. import java.util.ArrayList;
    6. import java.util.Arrays;
    7. import java.util.List;
    8.  
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. import com.avaje.ebeaninternal.server.cluster.Packet;
    12. import com.comphenix.protocol.PacketType;
    13. import com.comphenix.protocol.ProtocolLibrary;
    14. import com.comphenix.protocol.events.ListenerOptions;
    15. import com.comphenix.protocol.events.ListenerPriority;
    16. import com.comphenix.protocol.events.PacketAdapter;
    17. import com.comphenix.protocol.events.PacketEvent;
    18. import com.comphenix.protocol.wrappers.WrappedGameProfile;
    19.  
    20. public class Main extends JavaPlugin {
    21.  
    22.  
    23.  
    24. private List<WrappedGameProfile> message = new ArrayList<WrappedGameProfile>();
    25.  
    26. public void onEnable() {
    27. if(!new File(getDataFolder(), "RESET.FILE").exists()) {
    28. try {
    29. getConfig().set("PlayerCountMessage", Arrays.asList("First Line", "Second Line"));
    30. new File(getDataFolder(),"RESET.FILE").createNewFile();
    31. } catch (IOException e) {
    32. e.printStackTrace();
    33. }
    34. }
    35. saveConfig();
    36.  
    37. for(String str : getConfig().getStringList("PlayerCountMessage"))
    38. message.add(new WrappedGameProfile("1", str));
    39.  
    40.  
    41. ProtocolLibrary
    42. .getProtocolManager()
    43. .addPacketListener
    44. (new PacketAdapter(
    45. this,
    46. ListenerPriority.NORMAL,
    47. Arrays.asList(new PacketType[] { PacketType.Status.Server.OUT_SERVER_INFO}),
    48. new ListenerOptions[] {ListenerOptions.ASYNC }) {
    49.  
    50. public void onPacketSending(PacketEvent event) {
    51.  
    52.  
    53. event.getPacket()
    54. .getServerPings()
    55. .read(0)
    56. .setPlayers(PlayerCountMessage.this.message);
    57. }
    58.  
    59. });
    60. }
    61. }
     
  2. Offline

    Flamedek

    SimplyCode Well.. exactly as it says, you never declared a variable called 'PlayerCountMessage', so how would it know what to do?
    If you mean to set the config path "PlayerCountMessage" you have to access the config like you did before, on line 29
     
  3. Offline

    SimplyCode


    Flamedek Did I not already set the path on line 29? I thought I did, and if not, would I just declare the same statement again, but without the first and second line part?

    I'm sorry if this is a bit nubbish, only been doing plugins for about 4 days.
     
  4. Offline

    Flamedek

    SimplyCode You don't 'set' the path, you set a value to a path. Basicly on line 29 you are saying 'set this list in the config on this location'. If you later want to change that value you have to tell it the same thing, just give a different value.

    Ive never worked with ProtocolLib so I'm not realy sure whats going on here but if you want to override that list you just do the exact same thing just use a different list.
     
  5. Offline

    SimplyCode

    Flamedek did I not do that on line 37?

    I'm quite confused, I understand that I havn't told the plugin what it is, but I'm confused on how to do it, mind giving me a strip of code maybe for example purposes and tell me what line and why it goes there? I really want to learn something from this, so sorry if this is being a but hard trying to teach me.

    Thanks for helping me so far.
     
Thread Status:
Not open for further replies.

Share This Page