I'm trying to check if the players exp is >= the exp set in config... This is what my code looks like... It says it takes 0 xp from the player. Like it doesnt even check if player has enough. Code (Java): if(player.getExp() >= CustomEnchant.config.getConfig().getInt("RandomBook.exp")){ RandomEnchant.giveRandomEnchant(player); player.setExp(player.getExp() - CustomEnchant.config.getConfig().getInt("RandomBook.exp")); player.sendMessage(ChatColor.GREEN + "You successfully bought a random book for " + CustomEnchant.config.getConfig().getInt("RandomBook.exp") + " exp!"); }else{ player.sendMessage(ChatColor.RED + "You don't have enough exp for this transaction!"); } Config... Code (YAML): RandomBook: exp: '1500'
O sorry... I forgot to put why it wasn't working... It says it takes 0 xp from the player. Like it doesnt even check if player has enough.
getInt() returns 0 by default in the event of improper formatting. Are you certain that the 1500 is an int, not a String?
Read the documentation https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#getExp() . getExp() returns a float from 0 to 1, not a raw amount of exp points
Pretty sure you don't put the int in a YAML file like exp: '1500'. If you still have the problem, try just putting exp: 1500