Solved Creating configurable pitch doesn't work?

Discussion in 'Spigot Plugin Development' started by Cervinakuy, May 26, 2016.

  1. Hey guys!

    So I have a plugin that plays sounds, and I want to make the pitch configurable, but for some reason, when I try to do so, when testing the sound doesn't play at all.

    Here is the code that does work:

    Code (Text):
    p.playSound(p.getLocation(), Sound.valueOf(plugin.getConfig().getString("GlobalJoinSound.Sound")), 20, 1);
    Here is the code that doesn't work

    Code (Text):
    p.playSound(p.getLocation(), Sound.valueOf(plugin.getConfig().getString("GlobalJoinSound.Sound")), 20, plugin.getConfig().getInt("GlobalJoinSound.Pitch"));
    What could be the problem?

    Thanks,
    - Cervinakuy
     
  2. I tried this already, but it didn't work.

    Code (Text):
    p.playSound(p.getLocation(), Sound.valueOf(plugin.getConfig().getString("GlobalJoinSound.Sound")), 20, (float)plugin.getConfig().getInt("GlobalJoinSound.Pitch"));
     
  3. You could just use getConfig().getFloat() instead of casting an int to a float :p

    Edit: Nevermind! That doesn't appear to be a thing. :oops:
     
  4. I don't believe that exists...?

    EDIT: Nevermind, I saw that edit.
     
  5. have you tried doing Float.valueOf(cfg.getdouble(pitch));

    ?
     
  6. there are 2 situations
    Code (Java):
    double = plugin.getConfig().getDouble(pitch);
    (float) double;
    or this way

    Code (Java):
    plugin.getConfig().getFloat(pitch);
     
  7. I tried this, it didn't work.

    Here's what I did for that method:

    Code (Text):
    p.playSound(p.getLocation(), Sound.valueOf(plugin.getConfig().getString("GlobalJoinSound.Sound")), 20, Float.valueOf("GlobalJoinSound.Pitch"));
    I also tried specifically what you suggested as well, but that didn't work either, I also casted it to float since eclipse didn't like the way you had set it up.

    Code (Text):
    p.playSound(p.getLocation(), Sound.valueOf(plugin.getConfig().getString("GlobalJoinSound.Sound")), 20, Float.valueOf((float) plugin.getConfig().getDouble("GlobalJoinSound.Pitch")));
    I also tried your method:

    And sadly, it didn't work either, but here's what I did:

    Code (Text):
    double pitch = plugin.getConfig().getDouble("GlobalJoinSound.Pitch");
                               
                                p.playSound(p.getLocation(), Sound.valueOf(plugin.getConfig().getString("GlobalJoinSound.Sound")), 20, (float)pitch );
    The second you listed didn't work.
     
  8. Still looking for some help :(.
     
  9. The pitch must be between 0.0 and 2.0 (inclusive). Maybe that is the case?
     
  10. I simply used it like this.
    Code (Java):
    p.playSound(Location loc, Sound sound, 10, 10);
     
  11. Use (float) getConfig#getDouble
     
  12. Yes.. I know that, but it still doesn't work..

    This doesn't work for me either.

    Tried it earlier, again, didn't work.

    Nothing is working :(.

    - Cervinakuy
     
  13. double is already downcasted/autoboxed to float automatically. That's not the issue here.

    Print what you are receiving from the config for every single value here, and return with the results.
     
  14. I think I understand what you're saying here... but in that case.. what would be the proper way to fix this issue?
     
  15. its really strange try to debug your code.
     
  16. I don't know, that's why I asked for debug output.
     
  17. if you already understand him why you have to ask him for something to fix the issue ?
     
  18. Does it work when NOT getting any values from the config file. As in just to test, put 1,2,3,4 etc...