Solved Anyway to make code look cleaner

Discussion in 'Plugin Development' started by plisov, Jun 23, 2017.

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

    plisov

    Hai. I made a small method that works great however I have a feeling I can make it look neater and/or make it do the same thing a different, more efficient way.
     
    Last edited: Jun 25, 2017
  2. Offline

    Zombie_Striker

    @plisov
    Try this:
    Code:
    String rank = "Error";
    
    String[] ranks = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","Type " + ChatColor.RED + "/prestige"};
    
    //Go through each rank. If the current rank is equal to that rank, get the next rank (except for the last one)
    for(int i = 0; i < ranks.length-1; i++){
       if(ranks[i].equals(currentRank))
         rank = ranks[i+1]
    }
    
     
  3. Offline

    Horsey

    You could also use a switch, it's a lot faster than if/else if statements.

    Also don't use the bungee ChatColor, use the Bukkit one.

    Are you sure the first group is a player's 'rank'? They could be in many different groups.
     
    RcExtract likes this.
  4. Offline

    plisov

    Completely forgot I could make a for loop. Thanks!
     
Thread Status:
Not open for further replies.

Share This Page