How can I make a config File to change the int in the Float.valueOf(int)? Code: public void onEnable() { setBlockResistance(Block.STONE, Float.valueOf(104.F)); }
You are trying to get a float from the config right? Apparently there is no .getFloat("path") method, so you would have to use doubles instead (which only means you have more decimals). Say you have a config.yml like this: Code: blockResistance: 104.5 Then you get the blockResistance like this: Code:java float blockResistance = (float)getConfig().getDouble("blockResistance"); If you only want to change a regular int to float (if the method you want to use only accepts float), you can just cast it: Code:java float theFloat = (float)theInt;
So it looks like this? Code: public void onEnable() { float blockResistance = (float)getConfig().getDouble("Stone"); } and in the config.yml Stone: 104.5 And this works the same like this? Code: public void onEnable() { setBlockResistance(Block.STONE, Float.valueOf(104.F)); }
well 104.5 would get you 104.5 ... yea works the same. Besides, Code:java setBlockResistance(Block.STONE, 104f); would have done the same (just without the config), no need for Float.valueOf(something) :3
blockResistance is underlined with yellow color and the is the following sentence: the value of the local variable blockResistance is not used is that bad? Okay it don't work I have this: Code: float blockResistance = (float)getConfig().getDouble("Stone"); setBlockResistance(Block.STONE, 104f); But the Resistance are all the time 104 and if I change the number in the config it's the same. I think the Plugin can't change the number with the config :/ EDIT by Moderator: merged posts, please use the edit button instead of double posting.
yes, but you should do Code:java float blockResistance = (float)getConfig().getDouble("Stone");setBlockResistance(Block.STONE, blockResistance); ;3
Oh woow thanks a lot I have an other question. If I have the resistance 100, I have to wait for a long time until the block will drop. But I don't see the animation. How can I fix it, that the animation are slower too?
Oh okay I have no idea I'm a noob with java How can I change a string like 104.5 from the config to float? EDIT by Moderator: merged posts, please use the edit button instead of double posting.
F4BSE if you use .getDouble("path.to.float"); and cast it to float (by using '(float)'), you don't have to :3