Config.yml for this?

Discussion in 'Plugin Development' started by ProMCKingz, Jul 26, 2014.

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

    ProMCKingz

    Hey bukkit dev programmers,
    I am having troubles making this configurable, it seems to turn back to 1, whenever I save and reload the file and server.

    Main
    Code:java
    1. public void onEnable() {
    2. getLogger().info("Has Been Enabled!");
    3. getLogger().warning("You are using an older version of this plugin!");
    4. PluginManager pm = getServer().getPluginManager();
    5. pm.registerEvents(new Method(), this);
    6. pm.registerEvents(new Method2(), this);
    7. pm.registerEvents(new Method2Return(), this);
    8. pm.registerEvents(new StopPlace(), this);
    9. hrecipe();
    10. getConfig().options().copyDefaults(true);
    11. if(!getConfig().contains("Damage")){ //Checks if the config does not have "Damage" in it.
    12. getConfig().set("Damage", 0.75);
    13. }
    14. saveConfig();
    15. }

    Damage Listener Class
    Code:java
    1. package me.ProMCKingz.VIP;
    2.  
    3. import org.bukkit.Material;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.entity.EntityDamageByEntityEvent;
    8.  
    9. public class Damage implements Listener {
    10.  
    11. Main configGetter;
    12. public Damage(Main plugin){
    13. plugin.getServer().getPluginManager().registerEvents(this, plugin);
    14. configGetter = plugin;
    15. }
    16. double Damage = configGetter.getConfig().getDouble("Damage");
    17. @EventHandler
    18. public void onDamage(EntityDamageByEntityEvent e) {
    19. // First you should check if e.getEntity() is not a Player and just
    20. // return;
    21. // since it doesn't matter to you
    22. if (!(e.getEntity() instanceof Player))
    23. return;
    24. // Then as you are sure you have a Player being attacked, you can cast
    25. // entity to Player
    26. Player entity = (Player) e.getEntity();
    27. // check if he has a Piston in his hand
    28. if (entity.getItemInHand().getType() == Material.PISTON_STICKY_BASE) {
    29. e.setDamage(e.getDamage()*Damage);
    30.  
    31. }
    32. }
    33.  
    34. }
    35.  
     
  2. Offline

    _RAM_97

    Hey idk whats wrong but can you help me with this I have a plugin Draw My Thin and it has a screen on witch you can draw but if you draw at any other place besides the screen of wool it displays this http://prntscr.com/47hjgg
    Please help
     
Thread Status:
Not open for further replies.

Share This Page