3 Commits

Author SHA1 Message Date
c8262e87e6 switched to Java 8 2019-08-20 15:11:49 +02:00
ea0a650210 release 1.0 2019-08-20 14:57:35 +02:00
ecb9df2cfc extended API 2019-08-16 22:47:03 +02:00
2 changed files with 22 additions and 5 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>cz.gamesites.mc</groupId>
<artifactId>AntiAFK</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.0</version>
<name>AntiAFK</name>
<description>AntiAFK Spigot plugin</description>
@ -31,7 +31,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>12</release>
<target>8</target>
<source>1.8</source>
</configuration>
</plugin>
</plugins>

View File

@ -30,9 +30,9 @@ import net.md_5.bungee.api.ChatColor;
public class AntiAFK extends JavaPlugin implements Listener {
// frequency of checks
private static final int CHECK_INTERVAL = 2 * 20;
public static final int CHECK_INTERVAL = 60 * 20;
// how many times a check has to fail in order to mark the player as AFK
private static final int STRIKES_AFK = 3;
public static final int STRIKES_AFK = 30;
private static AntiAFK INSTANCE = null;
private HashMap<Player, int[]> lastPositions = new HashMap<>();
@ -160,6 +160,22 @@ public class AntiAFK extends JavaPlugin implements Listener {
}
}
public static boolean isAFKWarningMenu(Inventory inv) {
return INSTANCE.inventories.contains(inv);
}
public static boolean isPlayerAway(Player p) {
return INSTANCE.strikes.getOrDefault(p, 0) > STRIKES_AFK;
}
public static long getPlayerAwaySeconds(Player p) {
return INSTANCE.strikes.getOrDefault(p, 0) * CHECK_INTERVAL / 20;
}
public static void resetPlayerAwayTimer(Player p) {
INSTANCE.strikes.put(p, 0);
}
public static List<Player> getAwayPlayers() {
return INSTANCE.strikes.entrySet()
.stream()