mirror of
https://github.com/itHotL/PlayerStats.git
synced 2024-11-25 12:25:36 +01:00
Added more documentation (#100)
This commit is contained in:
parent
20fa697eab
commit
5eb4a1705c
13
pom.xml
13
pom.xml
@ -206,6 +206,19 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -3,18 +3,13 @@ package com.github.artemis.the.gr8.playerstats.api;
|
||||
import com.github.artemis.the.gr8.playerstats.enums.Unit;
|
||||
import com.github.artemis.the.gr8.playerstats.msg.components.ComponentUtils;
|
||||
import com.github.artemis.the.gr8.playerstats.msg.msgutils.NumberFormatter;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import com.github.artemis.the.gr8.playerstats.statistic.result.StatResult;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.bukkit.Statistic;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/** Formats messages meant for usage outside PlayerStats.
|
||||
|
||||
The output is ready to be sent to a Minecraft client or console with the Adventure library.
|
||||
To send a Component, you need to get a {@link BukkitAudiences} object. Normally you would
|
||||
have to add the library as a dependency, but since the library is included in PlayerStats, you can
|
||||
access it directly. Information on how to get and use the BukkitAudiences object can be found on
|
||||
<a href="https://docs.adventure.kyori.net/platform/bukkit.html">Adventure's website</a>.*/
|
||||
/** Formats messages meant for usage outside PlayerStats. For more information about
|
||||
the default formatting PlayerStats uses, see the class description of {@link StatResult}.*/
|
||||
public interface ApiFormatter {
|
||||
|
||||
/** Turns a TextComponent into its String representation. This method is equipped
|
||||
|
@ -28,9 +28,11 @@ public interface StatManager {
|
||||
RequestGenerator<LinkedHashMap<String, Integer>> topStatRequest(int topListSize);
|
||||
|
||||
/** Gets a RequestGenerator that can be used to create a TopStatRequest
|
||||
for all offline players on the server. This RequestGenerator will make sure
|
||||
for all offline players on the server (those that are included by
|
||||
PlayerStats' settings). This RequestGenerator will make sure
|
||||
all default settings for a top-statistic-lookup are configured.
|
||||
|
||||
|
||||
@return the RequestGenerator*/
|
||||
RequestGenerator<LinkedHashMap<String, Integer>> totalTopStatRequest();
|
||||
}
|
||||
|
@ -54,7 +54,8 @@ public final class NumberFormatter {
|
||||
}
|
||||
}
|
||||
|
||||
/** The unit of time-based statistics is ticks by default.*/
|
||||
/** The unit of time-based statistics is ticks by default.
|
||||
@return a String with the form "1D 2H 3M 4S" (depending on the Unit range selected)*/
|
||||
public String formatTimeNumber(long number, Unit bigUnit, Unit smallUnit) { //5 statistics
|
||||
if (number == 0) {
|
||||
return "-";
|
||||
|
@ -7,6 +7,10 @@ import org.bukkit.Statistic;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/** Holds all the information PlayerStats needs to perform a lookup, and can be executed
|
||||
to get the results. Calling {@link #execute()} on a Top- or ServerRequest can take some
|
||||
time (especially if there is a substantial amount of OfflinePlayers on this particular server),
|
||||
so I strongly advice you to call this asynchronously! */
|
||||
public abstract class StatRequest<T> {
|
||||
|
||||
protected final RequestSettings requestSettings;
|
||||
@ -15,25 +19,38 @@ public abstract class StatRequest<T> {
|
||||
requestSettings = request;
|
||||
}
|
||||
|
||||
/** Don't call this from the Main Thread!*/
|
||||
/** Executes this StatRequest. Don't call this from the Main Thread!
|
||||
@return a StatResult containing the value of this lookup, both as numerical value
|
||||
and as formatted message*/
|
||||
public abstract StatResult<T> execute();
|
||||
|
||||
/** @return the Statistic this StatRequest will get the data of */
|
||||
public Statistic getStatisticSetting() {
|
||||
return requestSettings.getStatistic();
|
||||
}
|
||||
|
||||
/** If the Statistic setting for this StatRequest is of Type.Block,
|
||||
this will get the Material that was set
|
||||
@return a Material for which #isBlock is true, or null if no Material was set*/
|
||||
public @Nullable Material getBlockSetting() {
|
||||
return requestSettings.getBlock();
|
||||
}
|
||||
|
||||
/** If the Statistic setting for this StatRequest is of Type.Item,
|
||||
this will get the Material that was set
|
||||
@return a Material for which #isItem is true, or null if no Material was set*/
|
||||
public @Nullable Material getItemSetting() {
|
||||
return requestSettings.getItem();
|
||||
}
|
||||
|
||||
/** If the Statistic setting for this StatRequest is of Type.Entity,
|
||||
this will get the EntityType that was set
|
||||
@return an EntityType, or null if no EntityType was set*/
|
||||
public @Nullable EntityType getEntitySetting() {
|
||||
return requestSettings.getEntity();
|
||||
}
|
||||
|
||||
/** @return the Target for this lookup (either Player, Server or Top)*/
|
||||
public Target getTargetSetting() {
|
||||
return requestSettings.getTarget();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user