Solved Multiplying strings and turning it into another string

Discussion in 'Plugin Development' started by ChessIndustries, Oct 18, 2017.

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

    ChessIndustries

    Alright, so currently I'm making a small little prison plugin of my own and wanted to add multipliers to the plugin. Basically, instead of mining items and then clicking a sign/npc/using a command, I want it to just destroy the block and give me money. So I got that part done and it worked great. But I came across an issue. For some reason, I get an error saying "The operator * is undefined for the argument type(s) String, int" when I try to multiply the booster number (taken from the config) by 10. Here's what I put:
    Code:
     
       String b = getConfig().getString("Booster/Multiplier Value");
       String v = b * 10;
    
    I'm not sure if I'm making a silly little mistake, or just completely doing it wrong. Help would be appreciated. :)
     
  2. You need to convert the string to an int
    int test = Integer.parseInt(b);
    Then do int v = test * 10
     
  3. Offline

    ChessIndustries

    Thanks! I didn't know you had to convert the string first. I spent 20 minutes staring at that code :)
     
  4. Offline

    Horsey

    Or use config#getInt("YourPath");
     
Thread Status:
Not open for further replies.

Share This Page