I think the first one is generally fine but you should just use the shorthand if/else on what is actually affected by it, like so:
Code:
player.getPackets().sendIComponentText(788, 18, (burnedLogs ? "<col=008000>" : <col=DF0101>") + "Burn 100 yew logs"); //only color is within scope of if/else
As for the rest, I don't know how all your achievement stuff is done, but you can establish a utility object/enum to attach to content that uses difficulty as a defining factor. It can help with organizing, readability and expression (messages)
like so:
Code:
public enum Difficulty {
EASY,
MEDIUM,
HARD,
ELITE
;
@Override
public String toString() {
return name().substring(0, 1) + name().substring(1).toLowerCase(); //such as "Easy" as opposed to "EASY"
}
}
Then you can attach a reference to a Difficulty to whichever objects would benefit from it, such as your task object, a basic example would be:
Code:
public class AchievementTask {
public int progress;
public Difficulty difficulty; //may want to store ordinal or something instead (for serialization sake), up to you, just an example
}
Then you can reduce that switch statement to one line, and use other switch statements based on difficulties in a more readable and finalized fashion.. like determining points rewarded for example.
Code:
public class AchievementTask {
public int progress;
public Difficulty difficulty;
public void sendCompletionMessage() {
player.getPackets().sendGameMessage("<col=FF0000>Well done! You have completed a " + difficulty.toString() + " task. Your Achievement Diary has been updated.");
}
public int getCompletionPoints() {
switch (difficulty) {
case EASY: //a lot more readable and debugable than using integers as keys
return 5;
case MEDIUM:
return 10;
case HARD:
return 15;
case ELITE:
return 20;
default:
return 0;
}
}