title: Set int value in conditional statement after declaring string
body: <p>I have a string (<code>breakmsg</code>) that I would like to be the same for every <code>if</code> statement, with an integer <code>value</code> that needs to change depending on what it is declared as inside the <code>if</code> statement. How would I go about changing the value of the <code>value</code> variable after I have already declared the <code>breakmsg</code> string? Previous attempts are commented inside the code.</p>
  
  <p>Here is my current code:</p>
  
  <pre><code>private int value;
  
      public void setValue(int v){
          value = v;
      }
  
      @EventHandler
      public void onBlockBreak(BlockBreakEvent e) {
          Block b = e.getBlock();
          Player p = e.getPlayer();
  
          //int value = 0;
          String breakmsg = ChatColor.GREEN + "You gained " + ChatColor.GOLD + value + ChatColor.GREEN + " points for collecting " + ChatColor.AQUA + b.getType() + ChatColor.GREEN + ".";
  
          @SuppressWarnings("deprecation")
          int itemID = p.getItemInHand().getTypeId();
  
          if (b.getType() == Material.DIAMOND_ORE) {
              if (itemID == 257 || itemID == 278) {
                  //value = 5;
                  setValue(5);
                  int points = getConfig().getInt("players." + p.getUniqueId() + ".points");
                  getConfig().set("players." + p.getUniqueId() + ".points", points + value);
                  saveConfig();
                  startScoreboard();
                  e.getPlayer().sendMessage(breakmsg);
              }
          }
  
          if (b.getType() == Material.GOLD_ORE) {
              if (itemID == 257 || itemID == 285 || itemID == 278) {
                  //value = 3;
                  setValue(3);
                  int points = getConfig().getInt("players." + p.getUniqueId() + ".points");
                  getConfig().set("players." + p.getUniqueId() + ".points", points + value);
                  saveConfig();
                  startScoreboard();
                  e.getPlayer().sendMessage(breakmsg);
              }
          }
      }
  </code></pre>