-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sidebar and Tab improvements, session stats remake (#845)
tab rework, sidebar imrovements, new top system and session statistics
- Loading branch information
1 parent
22ec7e5
commit 6f4433a
Showing
76 changed files
with
9,580 additions
and
1,513 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
29 changes: 29 additions & 0 deletions
29
bedwars-api/src/main/java/com/andrei1058/bedwars/api/arena/stats/DefaultStatistics.java
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 com.andrei1058.bedwars.api.arena.stats; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
@SuppressWarnings("SpellCheckingInspection") | ||
public enum DefaultStatistics { | ||
|
||
KILLS("kills", true), | ||
KILLS_FINAL("finalKills", true), | ||
DEATHS("deaths", true), | ||
DEATHS_FINAL("finalDeaths", true), | ||
BEDS_DESTROYED("bedsDestroyed", true); | ||
|
||
private final String id; | ||
private final boolean incrementable; | ||
DefaultStatistics(String id, boolean incrementable) { | ||
this.id = id; | ||
this.incrementable = incrementable; | ||
} | ||
|
||
@Override | ||
public @NotNull String toString() { | ||
return id; | ||
} | ||
|
||
public boolean isIncrementable() { | ||
return incrementable; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
bedwars-api/src/main/java/com/andrei1058/bedwars/api/arena/stats/GameStatistic.java
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 com.andrei1058.bedwars.api.arena.stats; | ||
|
||
import com.andrei1058.bedwars.api.language.Language; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Game statistic. | ||
* @param <T> statistic type. We usually work with integers. | ||
*/ | ||
public interface GameStatistic<T> extends Comparable<GameStatistic<T>> { | ||
|
||
/** | ||
* Current value. | ||
*/ | ||
T getValue(); | ||
|
||
/** | ||
* Value displayed in tops etc. | ||
* @param language - message receiver. | ||
*/ | ||
String getDisplayValue(@Nullable Language language); | ||
|
||
/** | ||
* Comparison for tops. | ||
* @param o the object to be compared. | ||
*/ | ||
int compareTo(@NotNull GameStatistic<T> o); | ||
} |
30 changes: 30 additions & 0 deletions
30
bedwars-api/src/main/java/com/andrei1058/bedwars/api/arena/stats/GameStatisticProvider.java
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,30 @@ | ||
package com.andrei1058.bedwars.api.arena.stats; | ||
|
||
import com.andrei1058.bedwars.api.language.Language; | ||
import org.bukkit.plugin.Plugin; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public interface GameStatisticProvider<T extends GameStatistic<?>> { | ||
|
||
/** | ||
* Unique statistic identifier. | ||
*/ | ||
String getIdentifier(); | ||
|
||
/** | ||
* Plugin provider. | ||
* @return statistic owner. | ||
*/ | ||
Plugin getOwner(); | ||
|
||
/** | ||
* Default value used when initializing game stats. | ||
*/ | ||
T getDefault(); | ||
|
||
/** | ||
* Display value for undetermined values. | ||
* @param language desired translation. | ||
*/ | ||
String getVoidReplacement(@Nullable Language language); | ||
} |
96 changes: 96 additions & 0 deletions
96
bedwars-api/src/main/java/com/andrei1058/bedwars/api/arena/stats/GameStatsHolder.java
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,96 @@ | ||
package com.andrei1058.bedwars.api.arena.stats; | ||
|
||
import com.andrei1058.bedwars.api.arena.IArena; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
@SuppressWarnings("unused") | ||
public interface GameStatsHolder { | ||
|
||
IArena getArena(); | ||
|
||
/** | ||
* Register statistic. | ||
* Throws a runtime exception if statistic is already registered. | ||
* @param statistic new statistic. | ||
*/ | ||
void register(@NotNull GameStatisticProvider<?> statistic); | ||
|
||
/** | ||
* Initialize game session stats for given player. | ||
* @param player stats holder. | ||
*/ | ||
PlayerGameStats init(Player player); | ||
|
||
/** | ||
* Remove player tracked data. | ||
* @param uuid holder. | ||
*/ | ||
void unregisterPlayer(UUID uuid); | ||
|
||
/** | ||
* Get existing or initialize statistic for given player. | ||
* @param holder player holder. | ||
* @return Existing or new statistic. | ||
*/ | ||
@NotNull PlayerGameStats getCreate(@NotNull Player holder); | ||
|
||
/** | ||
* Get existing or initialize statistic for given player. | ||
* @param holder player holder. | ||
* @return Existing or new statistic. | ||
*/ | ||
Optional<PlayerGameStats> get(@NotNull UUID holder); | ||
|
||
/** | ||
* Get existing or initialize statistic for given player. | ||
* @param holder player holder. | ||
* @return Existing or new statistic. | ||
*/ | ||
default Optional<PlayerGameStats> get(@NotNull Player holder) { | ||
return get(holder.getUniqueId()); | ||
} | ||
|
||
/** | ||
* Get tracked players. | ||
* | ||
* @return Unmodifiable list of tracked players. | ||
*/ | ||
Collection<Optional<PlayerGameStats>> getTrackedPlayers(); | ||
|
||
|
||
/** | ||
* @param statistic Order collection by given statistic. | ||
* @return top list. | ||
*/ | ||
default Collection<Optional<PlayerGameStats>> getOrderedBy(@NotNull DefaultStatistics statistic) { | ||
return getOrderedBy(statistic.toString()); | ||
} | ||
|
||
/** | ||
* @param statistic Order collection by given statistic. | ||
* @return top list. | ||
*/ | ||
List<Optional<PlayerGameStats>> getOrderedBy(@NotNull String statistic); | ||
|
||
/** | ||
* Check if given statistic is registered. | ||
*/ | ||
boolean hasStatistic(String orderBy); | ||
|
||
/** | ||
* @return unmodifiable list of registered game statistics. | ||
*/ | ||
List<String> getRegistered(); | ||
|
||
/** | ||
* Get statistic provider. | ||
*/ | ||
@Nullable GameStatisticProvider<?> getProvider(String registered); | ||
} |
6 changes: 6 additions & 0 deletions
6
bedwars-api/src/main/java/com/andrei1058/bedwars/api/arena/stats/Incrementable.java
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,6 @@ | ||
package com.andrei1058.bedwars.api.arena.stats; | ||
|
||
public interface Incrementable { | ||
|
||
void increment(); | ||
} |
39 changes: 39 additions & 0 deletions
39
bedwars-api/src/main/java/com/andrei1058/bedwars/api/arena/stats/PlayerGameStats.java
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,39 @@ | ||
package com.andrei1058.bedwars.api.arena.stats; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Player stats container for a game. | ||
*/ | ||
public interface PlayerGameStats { | ||
|
||
@NotNull UUID getPlayer(); | ||
|
||
/** | ||
* @return player display name. | ||
*/ | ||
@NotNull String getDisplayPlayer(); | ||
|
||
/** | ||
* @return player username. | ||
*/ | ||
@NotNull String getUsername(); | ||
|
||
void registerStatistic(@NotNull String id, @NotNull GameStatistic<?> defaultValue); | ||
|
||
Optional<GameStatistic<?>> getStatistic(@NotNull String id); | ||
|
||
default Optional<GameStatistic<?>> getStatistic(@NotNull DefaultStatistics id) { | ||
return getStatistic(id.toString()); | ||
} | ||
|
||
/** | ||
* List of registered statistics. | ||
*/ | ||
@SuppressWarnings("unused") | ||
List<String> getRegistered(); | ||
} |
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 |
---|---|---|
|
@@ -38,6 +38,11 @@ | |
|
||
public interface ITeam { | ||
|
||
/** | ||
* Runtime identifier. | ||
*/ | ||
UUID getIdentity(); | ||
|
||
/** | ||
* Get team color. | ||
*/ | ||
|
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
Oops, something went wrong.