Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to 1.20.4 #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.extendedclip.papi.expansion.mcstatistics</groupId>
<artifactId>statistics-expansion</artifactId>
<version>2.0.1</version>
<name>PAPI-Expansion-Statistic</name>
<name>Expansion-statistic</name>
<description>PlaceholderAPI expansion for minecraft statistic placeholders</description>

<repositories>
Expand All @@ -23,13 +23,13 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.10.8-DEV-86</version>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand All @@ -55,8 +55,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<target>1.8</target>
<source>1.8</source>
<target>17</target>
<source>17</source>
<encoding>UTF-8</encoding>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ public String onRequest(OfflinePlayer player, String identifier) {
return "";
}

if (!ServerVersion.SUPPORT_OFFLINE_PLAYERS && !player.isOnline()) {
return "";
}

switch (identifier.toLowerCase()) {
case "mine_block": {
return calculateTotal(player, Statistic.MINE_BLOCK);
Expand Down Expand Up @@ -161,7 +157,7 @@ public String onRequest(OfflinePlayer player, String identifier) {
final Optional<Statistic> statisticOptional = Enums.getIfPresent(Statistic.class, statisticIdentifier);

if (!statisticOptional.isPresent()) {
return "Unknown statistic '" + statisticIdentifier + "', check " + StatisticsUtils.JAVADOC_BASE_LINK + "/org/bukkit/Statistic.html for more info";
return "Unknown statistic '" + statisticIdentifier;
}

final Statistic statistic = statisticOptional.get();
Expand All @@ -178,7 +174,7 @@ public String onRequest(OfflinePlayer player, String identifier) {
}

try {
return Integer.toString(ServerVersion.SUPPORT_OFFLINE_PLAYERS ? player.getStatistic(statistic, material.get()) : player.getPlayer().getStatistic(statistic, material.get()));
return Integer.toString(player.getStatistic(statistic, material.get()));
} catch (IllegalArgumentException e) {
errorLog("Could not get the statistic '" + statistic.name() + "' for '" + material.get().name() + "'", e);
return "Could not get the statistic '" + statistic.name() + "' for '" + material.get().name() + "'";
Expand All @@ -193,7 +189,7 @@ public String onRequest(OfflinePlayer player, String identifier) {
}

try {
return Integer.toString(ServerVersion.SUPPORT_OFFLINE_PLAYERS ? player.getStatistic(statistic, entityType.get()) : player.getPlayer().getStatistic(statistic, entityType.get()));
return Integer.toString(player.getStatistic(statistic, entityType.get()));
} catch (IllegalArgumentException e) {
errorLog("Could not get the statistic '" + statistic.name() + "' for '" + entityType.get().name() + "'", e);
return "Could not get the statistic '" + statistic.name() + "' for '" + entityType.get().name() + "'";
Expand All @@ -220,7 +216,7 @@ public String onRequest(OfflinePlayer player, String identifier) {
}

try {
total.addAndGet(ServerVersion.SUPPORT_OFFLINE_PLAYERS ? player.getStatistic(statistic, material.get()) : player.getPlayer().getStatistic(statistic, material.get()));
total.addAndGet(player.getStatistic(statistic, material.get()));
} catch (IllegalArgumentException e) {
errorLog("Could not get the statistic '" + statistic.name() + "' for '" + material.get().name() + "'", e);
break;
Expand All @@ -239,7 +235,7 @@ public String onRequest(OfflinePlayer player, String identifier) {
}

try {
total.addAndGet(ServerVersion.SUPPORT_OFFLINE_PLAYERS ? player.getStatistic(statistic, entityType.get()) : player.getPlayer().getStatistic(statistic, entityType.get()));
total.addAndGet(player.getStatistic(statistic, entityType.get()));
} catch (IllegalArgumentException e) {
errorLog("Could not get the statistic '" + statistic.name() + "' for '" + entityType.get().name() + "'", e);
break;
Expand Down Expand Up @@ -269,7 +265,7 @@ private String calculateTotal(final OfflinePlayer player, final Statistic statis
}

try {
total.addAndGet(ServerVersion.SUPPORT_OFFLINE_PLAYERS ? player.getStatistic(statistic, material) : player.getPlayer().getStatistic(statistic, material));
total.addAndGet(player.getStatistic(statistic, material));
} catch (IllegalArgumentException ignored) {
ignoredMaterials.put(statistic, material);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,105 +30,37 @@

public class StatisticsUtils {

private static final Statistic SECONDS_PLAYED_STATISTIC = ServerVersion.IS_LEGACY ? Statistic.valueOf("PLAY_ONE_TICK") : Statistic.PLAY_ONE_MINUTE;
private static final Statistic SECONDS_SINCE_LAST_DEATH_STATISTIC = ServerVersion.IS_LEGACY ? Statistic.valueOf("TIME_SINCE_DEATH") : Statistic.TIME_SINCE_DEATH;
private static final Statistic SECONDS_PLAYED_STATISTIC = Statistic.PLAY_ONE_MINUTE;
private static final Statistic SECONDS_SINCE_LAST_DEATH_STATISTIC = Statistic.TIME_SINCE_DEATH;

public static final String JAVADOC_BASE_LINK = ServerVersion.IS_LATEST ? "https://hub.spigotmc.org/javadocs/spigot" : "https://docs.docdex.helpch.at/" + ServerVersion.AS_STRING;
//public static final String JAVADOC_BASE_LINK = ServerVersion.IS_LATEST ? "https://hub.spigotmc.org/javadocs/spigot" : "https://docs.docdex.helpch.at/" + ServerVersion.AS_STRING;

public static int getSecondsPlayed(final OfflinePlayer player) {
return (ServerVersion.SUPPORT_OFFLINE_PLAYERS ? player.getStatistic(SECONDS_PLAYED_STATISTIC) : player.getPlayer().getStatistic(SECONDS_PLAYED_STATISTIC)) / 20;
return player.getStatistic(SECONDS_PLAYED_STATISTIC) / 20;
}

public static int getSecondsSinceLastDeath(final OfflinePlayer player) {
return (ServerVersion.SUPPORT_OFFLINE_PLAYERS ? player.getStatistic(SECONDS_SINCE_LAST_DEATH_STATISTIC) : player.getPlayer().getStatistic(SECONDS_SINCE_LAST_DEATH_STATISTIC)) / 20;
return player.getStatistic(SECONDS_SINCE_LAST_DEATH_STATISTIC) / 20;
}

@SuppressWarnings("Guava")
public static String getStatistic(final OfflinePlayer player, final String identifier) {
final Optional<Statistic> optional = Enums.getIfPresent(Statistic.class, identifier.toUpperCase());

if(!ServerVersion.SUPPORT_OFFLINE_PLAYERS && !player.isOnline()) {
return "Cannot get statistic, player is offline";
}

if (!optional.isPresent()) {
return "Unknown statistic '" + identifier + "', check " + JAVADOC_BASE_LINK + "/org/bukkit/Statistic.html for more info";
return "Unknown statistic '" + identifier;
}

final Statistic statistic = optional.get();

if (statistic.getType() != Statistic.Type.UNTYPED) {
return "The statistic '" + identifier + "' require an argument, check " + JAVADOC_BASE_LINK + "/org/bukkit/Statistic.Type.html for more info" ;
return "The statistic '" + identifier + "' require an argument";
}

int value = ServerVersion.SUPPORT_OFFLINE_PLAYERS ? player.getStatistic(statistic) : player.getPlayer().getStatistic(statistic);
int value = player.getStatistic(statistic) ;
return Integer.toString(value);
}

public static boolean isItem(final Material material, final boolean isLegacy) {
if (isLegacy) {
switch (material.name()) {
case "ACACIA_DOOR":
case "BED_BLOCK":
case "BEETROOT_BLOCK":
case "BIRCH_DOOR":
case "BREWING_STAND":
case "BURNING_FURNACE":
case "CAKE_BLOCK":
case "CARROT":
case "CAULDRON":
case "COCOA":
case "CROPS":
case "DARK_OAK_DOOR":
case "DAYLIGHT_DETECTOR_INVERTED":
case "DIODE_BLOCK_OFF":
case "DIODE_BLOCK_ON":
case "DOUBLE_STEP":
case "DOUBLE_STONE_SLAB2":
case "ENDER_PORTAL":
case "END_GATEWAY":
case "FIRE":
case "FLOWER_POT":
case "FROSTED_ICE":
case "GLOWING_REDSTONE_ORE":
case "IRON_DOOR_BLOCK":
case "JUNGLE_DOOR":
case "LAVA":
case "MELON_STEM":
case "NETHER_WARTS":
case "PISTON_EXTENSION":
case "PISTON_MOVING_PIECE":
case "PORTAL":
case "POTATO":
case "PUMPKIN_STEM":
case "PURPUR_DOUBLE_SLAB":
case "REDSTONE_COMPARATOR_OFF":
case "REDSTONE_COMPARATOR_ON":
case "REDSTONE_LAMP_ON":
case "REDSTONE_TORCH_OFF":
case "REDSTONE_WIRE":
case "SIGN_POST":
case "SKULL":
case "SPRUCE_DOOR":
case "STANDING_BANNER":
case "STATIONARY_LAVA":
case "STATIONARY_WATER":
case "SUGAR_CANE_BLOCK":
case "TRIPWIRE":
case "WALL_BANNER":
case "WALL_SIGN":
case "WATER":
case "WOODEN_DOOR":
case "WOOD_DOUBLE_STEP":
return false;
default:
return true;
}
} else {
return material.isItem();
}
}

/**
* @author Sxtanna
*/
Expand Down
Binary file removed target/PAPI-Expansion-Statistic.jar
Binary file not shown.