-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Pablo Herrera <[email protected]>
- Loading branch information
1 parent
4c7eb75
commit df8e82e
Showing
11 changed files
with
360 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package tc.oc.pgm.stats; | ||
|
||
import static net.kyori.adventure.text.Component.join; | ||
import static net.kyori.adventure.text.Component.text; | ||
import static net.kyori.adventure.text.JoinConfiguration.separator; | ||
|
||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.JoinConfiguration; | ||
|
||
public interface StatHolder { | ||
JoinConfiguration PIPE = separator(text(" | ")); | ||
JoinConfiguration SPACES = separator(text(" ")); | ||
|
||
Number getStat(StatType type); | ||
|
||
default Component pipeSeparated(StatType... types) { | ||
return getComponent(PIPE, types); | ||
} | ||
|
||
default Component spaceSeparated(StatType... types) { | ||
return getComponent(SPACES, types); | ||
} | ||
|
||
default Component getComponent(JoinConfiguration joining, StatType... types) { | ||
Component[] children = new Component[types.length]; | ||
for (int i = 0; i < types.length; i++) children[i] = types[i].component(this); | ||
return join(joining, children); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package tc.oc.pgm.stats; | ||
|
||
import static net.kyori.adventure.text.Component.translatable; | ||
import static net.kyori.adventure.text.format.NamedTextColor.*; | ||
import static tc.oc.pgm.stats.StatsMatchModule.damageComponent; | ||
import static tc.oc.pgm.util.text.NumberComponent.number; | ||
|
||
import java.util.Locale; | ||
import net.kyori.adventure.text.Component; | ||
|
||
public enum StatType { | ||
KILLS, | ||
DEATHS, | ||
ASSISTS, | ||
KILL_STREAK, | ||
BEST_KILL_STREAK, | ||
KILL_DEATH_RATIO, | ||
LONGEST_BOW_SHOT { | ||
private final String blocks = key + ".blocks"; | ||
|
||
@Override | ||
public Component makeNumber(Number number) { | ||
return translatable(blocks, number(number, YELLOW)); | ||
} | ||
}, | ||
DAMAGE { | ||
@Override | ||
public Component makeNumber(Number number) { | ||
return damageComponent(number.doubleValue(), GREEN); | ||
} | ||
}; | ||
|
||
public final String key = "match.stats.type." + name().toLowerCase(Locale.ROOT); | ||
public static final StatType[] VALUES = values(); | ||
|
||
public Component makeNumber(Number number) { | ||
return number(number, this == DEATHS ? RED : GREEN); | ||
} | ||
|
||
public Component component(StatHolder stats) { | ||
return translatable(key, makeNumber(stats.getStat(this))); | ||
} | ||
} |
Oops, something went wrong.