Solved Config help

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

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

    ZodiacTheories

    Hi, so for some reason, when all the booleans are all false, players still get the message.

    Here is my code:

    Code:java
    1. package org.zodiactheories.pluginrequests;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.block.Block;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.block.BlockBreakEvent;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class Core extends JavaPlugin implements Listener {
    13.  
    14. @Override
    15. public void onEnable() {
    16. getServer().getPluginManager().registerEvents(this, this);
    17. getConfig().options().copyDefaults(true);
    18. saveConfig();
    19. }
    20.  
    21. @EventHandler
    22. public void onBreak(BlockBreakEvent e) {
    23. Player p = e.getPlayer();
    24. Block b = e.getBlock();
    25. for(Player players : Bukkit.getOnlinePlayers()) {
    26. if(players.hasPermission("blocknotify.notify")) {
    27. switch(b.getType()) {
    28. case DIAMOND_ORE:
    29. if(getConfig().getBoolean("diamond-ore") == true)
    30. players.sendMessage(ChatColor.GREEN + p.getName() + " has found Diamond Ore!");
    31. break;
    32. case IRON_ORE:
    33. if(getConfig().getBoolean("iron-ore") == true)
    34. players.sendMessage(ChatColor.GREEN + p.getName() + " has found Iron Ore!");
    35. break;
    36. case LAPIS_ORE:
    37. if(getConfig().getBoolean("lapis-ore") == true)
    38. players.sendMessage(ChatColor.GREEN + p.getName() + " has found Lapis Ore!");
    39. break;
    40. case GOLD_ORE:
    41. if(getConfig().getBoolean("gold-ore") == true)
    42. players.sendMessage(ChatColor.GREEN + p.getName() + " has found Gold Ore!");
    43. break;
    44. case EMERALD_ORE:
    45. if(getConfig().getBoolean("emerald-ore") == true)
    46. players.sendMessage(ChatColor.GREEN + p.getName() + " has found Emerald Ore!");
    47. break;
    48. case COAL_ORE:
    49. if(getConfig().getBoolean("coal-ore") == true)
    50. players.sendMessage(ChatColor.GREEN + p.getName() + " has found Coal Ore!");
    51. break;
    52. case REDSTONE_ORE:
    53. if(getConfig().getBoolean("redstone-ore") == true)
    54. players.sendMessage(ChatColor.GREEN + p.getName() + " has found Redstone Ore!");
    55. break;
    56. case QUARTZ_ORE:
    57. if(getConfig().getBoolean("quartz-ore") == true)
    58. players.sendMessage(ChatColor.GREEN + p.getName() + " has found Quartz Ore!");
    59. break;
    60. default:
    61. break;
    62. }
    63. }
    64. }
    65. }
    66. }
    67.  
    68.  


    config.yml:

    Code:
    #If it is false, the players with the permission will not get the message
     
    diamond-ore: true
    iron-ore: true
    coal-ore: true
    lapis-ore: true
    emerald-ore: true
    gold-ore: true
    redstone-ore: true
    quartz-ore: true
    
    Thanks
     
  2. Offline

    xTigerRebornx

    @ZodiacTheoriesx How are you setting it to false? From what I can see, its set to true, and you have no code that reloads it into memory without a restart.
     
  3. Offline

    ZodiacTheories

    xTigerRebornx

    That is my problem, I don't know how to load it into memory
     
  4. Offline

    xTigerRebornx

    ZodiacTheories JavaPlugin#reloadConfig() reloads it from file, create a command to call it.
     
    ZodiacTheories likes this.
  5. Offline

    ZodiacTheories

Thread Status:
Not open for further replies.

Share This Page