Merge pull request #122 from itHotL/1.8

1.8
This commit is contained in:
Elise 2022-10-01 13:24:02 +02:00 committed by GitHub
commit 6678778e8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 22 deletions

View File

@ -4,7 +4,7 @@
<groupId>io.github.ithotl</groupId>
<artifactId>PlayerStats</artifactId>
<name>PlayerStats</name>
<version>1.7.2</version>
<version>1.8</version>
<description>Statistics Plugin</description>
<url>https://www.spigotmc.org/resources/playerstats.102347/</url>
<developers>
@ -120,7 +120,7 @@
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<phase>deploy</phase>
<goals>
<goal>sign</goal>
</goals>

View File

@ -6,7 +6,7 @@
<groupId>io.github.ithotl</groupId>
<artifactId>PlayerStats</artifactId>
<version>1.7.2</version>
<version>1.8</version>
<name>PlayerStats</name>
<description>Statistics Plugin</description>
@ -214,7 +214,7 @@
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<phase>deploy</phase>
<goals>
<goal>sign</goal>
</goals>

View File

@ -30,6 +30,19 @@ public interface PlayerStats {
return Main.getPlayerStatsAPI();
}
/**
* Gets the current version of PlayerStatsAPI.
* Use this method to ensure the correct version of
* PlayerStats is running on the server before
* accessing further API methods, to prevent
* <code>ClassDefNotFoundExceptions</code>.
*
* @return the version of PlayerStatsAPI present on the server
*/
default String getVersion() {
return "1.8";
}
StatManager getStatManager();
ApiFormatter getFormatter();

View File

@ -31,7 +31,9 @@ public final class ComponentUtils {
return "";
}
else if (LanguageKeyHandler.isKeyForEntityKilledBy(trans.key()) ||
LanguageKeyHandler.isKeyForKillEntity(trans.key())) {
LanguageKeyHandler.isAlternativeKeyForEntityKilledBy(trans.key()) ||
LanguageKeyHandler.isKeyForKillEntity(trans.key()) ||
LanguageKeyHandler.isAlternativeKeyForKillEntity(trans.key())) {
TextComponent.Builder temp = Component.text();
trans.iterator(ComponentIteratorType.DEPTH_FIRST, ComponentIteratorFlag.INCLUDE_TRANSLATABLE_COMPONENT_ARGUMENTS)

View File

@ -61,19 +61,27 @@ public final class LanguageKeyHandler {
}
/**
* Checks if a given Key is the language key "stat_type.minecraft.killed"
* or "commands.kill.success.single" (which results in "Killed %s").
* Checks if a given Key is the language key "stat_type.minecraft.killed".
*
* @param statKey the Key to check
* @return true if this Key is key for kill-entity
*/
public static boolean isKeyForKillEntity(String statKey) {
return statKey.equalsIgnoreCase("stat_type.minecraft.killed") ||
statKey.equalsIgnoreCase("commands.kill.success.single");
return statKey.equalsIgnoreCase("stat_type.minecraft.killed");
}
/**
* Returns a language key to replace the default Statistic.Kill_Entity key.
* Checks if a given Key is the language key for "commands.kill.success.single",
* which results in "Killed %s".
* @param statKey the Key to check
* @return true if this Key is key for commands.kill.success.single
*/
public static boolean isAlternativeKeyForKillEntity(String statKey) {
return statKey.equalsIgnoreCase("commands.kill.success.single");
}
/**
* Returns a language key to replace the default "stat_type.minecraft.killed" key.
*
* @return the key "commands.kill.success.single", which results in "Killed %s"
*/
@ -82,19 +90,26 @@ public final class LanguageKeyHandler {
}
/**
* Checks if a given Key is the language key "stat_type.minecraft.killed_by"
* or "stat.minecraft.deaths" (which results in "Number of Deaths").
* Checks if a given Key is the language key "stat_type.minecraft.killed_by".
*
* @param statKey the Key to check
* @return true if this Key is a key for entity-killed-by
*/
public static boolean isKeyForEntityKilledBy(String statKey) {
return statKey.equalsIgnoreCase("stat_type.minecraft.killed_by") ||
statKey.equalsIgnoreCase("stat.minecraft.deaths");
return statKey.equalsIgnoreCase("stat_type.minecraft.killed_by");
}
/**
* Returns a language key to replace the default Statistic.Entity_Killed_By key.
* Checks if a given Key is the language key "stat.minecraft.deaths".
* @param statKey the Key to check
* @return true if this Key is key for stat.minecraft.deaths
*/
public static boolean isAlternativeKeyForEntityKilledBy(String statKey) {
return statKey.equalsIgnoreCase("stat.minecraft.deaths");
}
/**
* Returns a language key to replace the default stat_type.minecraft.killed_by key.
*
* @return the key "stat.minecraft.deaths", which results in "Number of Deaths"
* (meant to be followed by {@link #getAlternativeKeyForEntityKilledByArg()})
@ -135,8 +150,8 @@ public final class LanguageKeyHandler {
return "times_killed";
} else if (isKeyForEntityKilledBy(key)) {
return "number_of_times_killed_by";
} else if (isKeyForEntityKilledByArg(key)) { //this one returns nothing, because the previous one returns the full text
return "";
} else if (isKeyForEntityKilledByArg(key)) { //this one returns nothing, because it's an extra key I added
return ""; //to make the TranslatableComponent work
}
String toReplace = "";
if (key.contains("stat")) {
@ -145,8 +160,8 @@ public final class LanguageKeyHandler {
} else {
toReplace = "stat";
}
} else if (key.contains("entity")) { //for the two entity-related ones, put brackets around it to make up for the multiple-keys/args-serializer issues
toReplace = "entity";
} else if (key.contains("entity")) { //for the two entity-related ones, put brackets around it to
toReplace = "entity"; //make up for the multiple-keys/args-serializer issues
} else if (key.contains("block")) {
toReplace = "block";
} else if (key.contains("item")) {

View File

@ -54,7 +54,6 @@ public final class RequestSettings {
* <br>- Target target = {@link Target#TOP}
* <br>- int topListSize = 10
* <br>- boolean playerFlag = false
* <br>- boolean isAPIRequest
*
* @param sender the CommandSender who prompted this RequestGenerator
*/
@ -112,7 +111,7 @@ public final class RequestSettings {
return playerFlag;
}
public void setTarget(Target target) {
public void setTarget(@NotNull Target target) {
this.target = target;
}

View File

@ -1,6 +1,6 @@
main: com.artemis.the.gr8.playerstats.Main
name: PlayerStats
version: 1.7.2
version: 1.8
api-version: 1.13
description: adds commands to view player statistics in chat
author: Artemis_the_gr8