Question in title.. Code: Code (Text): player.sendMessage("" + config.getInt("RedPercentage") + config.getInt("GreenPercentage")); Config: Code (Text): RedPercentage: 49 GreenPercentage: 2 I get 492 instead of 51.. why?
thats easy to solve: "" is a string. you add 49 to a string and get "49" you add 2 to that and get "492". what you want is to add 49 and 2 and then make a string out out that. so you can just add some brackets around your int addition so that it gets executed first
Oh... wait.. So i can't do it like this? Code (Text): int red = config.getInt("RedPercentage"); int green = config.getInt("GreenPercentage"); player.sendmessage("" + red + green); That did not work but this worked: Code (Text): int red = config.getInt("RedPercentage") + config.getInt("GreenPercentage");
In string you are appending objects to the preview part of the string, you cannot add an int specifically from a string.
not that but do that player.sendmessage("" + (red + green)); or that player.sendmessage(red + green + "");
Forgot about that I've been taking a break off java for a bit, and using c#, the naming conventions with it suggest method/variables to start with upper case(disgusting, I still use java conventions ) because c# is like java, it's not to hard to switch between the two for a bit)
(Maths) new String("i love cake as i ate " + 200 + 200); If outputted: i love cake as i ate 200200 new String("i love cake as i ate " + (200 + 200)); If outputted: i love cake as i ate 400