Why wont it work O.O?

Discussion in 'Plugin Development' started by omnee, Sep 12, 2011.

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

    omnee

    My LoginLogout plugin http://forums.bukkit.org/threads/ch...n-and-logout-messages-1060.35966/#post-661471

    Is going to have a new feature, show the world where the player logs in... and there is a boolean at config that I added that is called Show.World, Its supose so if you set it to false then it doesnt show the world where the player logs in but if I set it to false, it keeps showing in what world the player logged in, why???
    Code:java
    1. config.setProperty("Show.World", "true");

    That is how I setted up the boolean
    and
    Code:java
    1. public void onPlayerJoin(PlayerJoinEvent event) {
    2. plugin.config.load();
    3. boolean useworld = plugin.config.getBoolean("Show.World", true);
    4. Player player = event.getPlayer();
    5. String world = player.getWorld().getName();
    6. event.setJoinMessage(null);
    7. if (useworld) {
    8. if (!event.getPlayer().isOp()) {
    9. plugin.config.load();
    10. event.setJoinMessage(colorizeText(plugin.config
    11. .getString("prefix.Player")
    12. + player.getName()
    13. + plugin.config.getString("Join.Player")
    14. + " @ "
    15. + world));
    16. } else {
    17. plugin.config.load();
    18. event.setJoinMessage(colorizeText(plugin.config
    19. .getString("prefix.Op")
    20. + player.getName()
    21. + plugin.config.getString("Join.Op") + " @ " + world));
    22. }
    23. } else {
    24. if (!event.getPlayer().isOp()) {
    25. plugin.config.load();
    26. event.setJoinMessage(colorizeText(plugin.config
    27. .getString("prefix.Player")
    28. + player.getName()
    29. + plugin.config.getString("Join.Player")));
    30. } else {
    31. plugin.config.load();
    32. event.setJoinMessage(colorizeText(plugin.config
    33. .getString("prefix.Op")
    34. + player.getName()
    35. + plugin.config.getString("Join.Op")));
    36. }
    37. }
    38. }
    39.  

    this is the playerjoinevent

    what is wrong with it >:mad:

    finished typing the post (finally :D)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 19, 2016
  2. Offline

    Sagacious_Zed Bukkit Docs

    Where is the setProperty call? if it is in the onEnable of your main class and not surrounded with a proper conditional statement, it will keep setting the property to true no matter what it is set to, so when the onPlayerJoin event fires it will only read the true value.
     
  3. Offline

    Tahkeh

    Pretty much what @Sagacious_Zed said. Change setProperty to getBoolean. If there is no "Show.World" property, it will create one and use true as the default value.

    That is, of course, untested. But I assume it works.
     
  4. Offline

    Sagacious_Zed Bukkit Docs

    Yes you can make calls to getBoolean that way. If the node does not exist it will return the given default. In fact, if config.yml does not exist it will return the default. The pitfall here is if you don't call getConfiguration().load() to actually load the config file from disk, it will always return the default.
     
  5. Offline

    omnee

    thanks... i will test it out and hope it works :p


    edit: worked ty very much :D
     
  6. Offline

    emericask8ur

    How did you get your code backround to be black and everything in threads? hahaha
     
  7. Code:
    [syntax=java]...[/syntax]
     
    emericask8ur likes this.
Thread Status:
Not open for further replies.

Share This Page