Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# User-specific stuff
.idea/

*.iml
*.ipr
*.iws

# IntelliJ
out/

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

target/

pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next

release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml

# Common working directory
run/
10 changes: 10 additions & 0 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>william278.net</id>
<url>https://repo.william278.net/releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
Expand Down Expand Up @@ -209,6 +213,12 @@
<version>24.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.william278.husksync</groupId>
<artifactId>husksync-bukkit</artifactId>
<version>3.8.7+1.21.8</version>
<scope>provided</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>
Expand Down
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
<id>placeholderapi</id> <!-- Placeholder API -->
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>

<repository>
<id>william278.net</id> <!-- HuskSync -->
<url>https://repo.william278.net/releases</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -142,6 +147,13 @@
<artifactId>annotations</artifactId>
<version>24.0.1</version>
</dependency>

<dependency>
<groupId>net.william278.husksync</groupId>
<artifactId>husksync-bukkit</artifactId>
<version>3.8.7+1.21.8</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.artemis.the.gr8.playerstats.api;

import java.util.LinkedHashMap;
import java.util.concurrent.CompletableFuture;

public interface StatManager {

Expand Down Expand Up @@ -31,7 +32,7 @@ public interface StatManager {
* @see PlayerStats
* @see StatResult
*/
StatResult<Integer> executePlayerStatRequest(StatRequest<Integer> request);
CompletableFuture<StatResult<Integer>> executePlayerStatRequest(StatRequest<Integer> request);

/** Gets a RequestGenerator that can be used to create a ServerStatRequest.
* This RequestGenerator will make sure all default settings
Expand All @@ -49,7 +50,7 @@ public interface StatManager {
* @see PlayerStats
* @see StatResult
*/
StatResult<Long> executeServerStatRequest(StatRequest<Long> request);
CompletableFuture<StatResult<Long>> executeServerStatRequest(StatRequest<Long> request);

/** Gets a RequestGenerator that can be used to create a TopStatRequest
* for a top-list of the specified size. This RequestGenerator will
Expand All @@ -76,5 +77,5 @@ public interface StatManager {
* @see PlayerStats
* @see StatResult
*/
StatResult<LinkedHashMap<String, Integer>> executeTopRequest(StatRequest<LinkedHashMap<String, Integer>> request);
CompletableFuture<StatResult<LinkedHashMap<String, Integer>>> executeTopRequest(StatRequest<LinkedHashMap<String, Integer>> request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ public void run() throws IllegalStateException {
}

try {
StatResult<?> result = StatRequestManager.execute(statRequest);
outputManager.sendToCommandSender(statRequester, result.formattedComponent());
}
catch (ConcurrentModificationException e) {
StatRequestManager.execute(statRequest).thenAccept(result -> {
StatResult<?> statResult = (StatResult<?>) result; // I really shouldn't do this.
outputManager.sendToCommandSender(statRequester, statResult.formattedComponent());
});
} catch (ConcurrentModificationException e) {
if (!statRequest.getSettings().isConsoleSender()) {
outputManager.sendFeedbackMsg(statRequester, StandardMessage.UNKNOWN_ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jetbrains.annotations.NotNull;

import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ForkJoinPool;
import java.util.stream.Collectors;
Expand All @@ -36,36 +37,36 @@ public BukkitProcessor(OutputManager outputManager) {
}

@Override
public @NotNull StatResult<Integer> processPlayerRequest(StatRequest<?> playerStatRequest) {
public @NotNull CompletableFuture<StatResult<Integer>> processPlayerRequest(StatRequest<?> playerStatRequest) {
StatRequest.Settings requestSettings = playerStatRequest.getSettings();
int stat = getPlayerStat(requestSettings);
FormattingFunction formattingFunction = outputManager.formatPlayerStat(requestSettings, stat);
TextComponent formattedResult = processFunction(requestSettings.getCommandSender(), formattingFunction);
String resultAsString = outputManager.textComponentToString(formattedResult);

return new StatResult<>(stat, formattedResult, resultAsString);
return CompletableFuture.completedFuture(new StatResult<>(stat, formattedResult, resultAsString));
}

@Override
public @NotNull StatResult<Long> processServerRequest(StatRequest<?> serverStatRequest) {
public @NotNull CompletableFuture<StatResult<Long>> processServerRequest(StatRequest<?> serverStatRequest) {
StatRequest.Settings requestSettings = serverStatRequest.getSettings();
long stat = getServerStat(requestSettings);
FormattingFunction formattingFunction = outputManager.formatServerStat(requestSettings, stat);
TextComponent formattedResult = processFunction(requestSettings.getCommandSender(), formattingFunction);
String resultAsString = outputManager.textComponentToString(formattedResult);

return new StatResult<>(stat, formattedResult, resultAsString);
return CompletableFuture.completedFuture(new StatResult<>(stat, formattedResult, resultAsString));
}

@Override
public @NotNull StatResult<LinkedHashMap<String, Integer>> processTopRequest(StatRequest<?> topStatRequest) {
public @NotNull CompletableFuture<StatResult<LinkedHashMap<String, Integer>>> processTopRequest(StatRequest<?> topStatRequest) {
StatRequest.Settings requestSettings = topStatRequest.getSettings();
LinkedHashMap<String, Integer> stats = getTopStats(requestSettings);
FormattingFunction formattingFunction = outputManager.formatTopStats(requestSettings, stats);
TextComponent formattedResult = processFunction(requestSettings.getCommandSender(), formattingFunction);
String resultAsString = outputManager.textComponentToString(formattedResult);

return new StatResult<>(stats, formattedResult, resultAsString);
return CompletableFuture.completedFuture(new StatResult<>(stats, formattedResult, resultAsString));
}

private int getPlayerStat(@NotNull StatRequest.Settings requestSettings) {
Expand Down
Loading