extended API
This commit is contained in:
parent
b0d07bed96
commit
ecb9df2cfc
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>cz.gamesites.mc</groupId>
|
<groupId>cz.gamesites.mc</groupId>
|
||||||
<artifactId>AntiAFK</artifactId>
|
<artifactId>AntiAFK</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<name>AntiAFK</name>
|
<name>AntiAFK</name>
|
||||||
<description>AntiAFK Spigot plugin</description>
|
<description>AntiAFK Spigot plugin</description>
|
||||||
|
|
||||||
|
@ -30,9 +30,9 @@ import net.md_5.bungee.api.ChatColor;
|
|||||||
public class AntiAFK extends JavaPlugin implements Listener {
|
public class AntiAFK extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
// frequency of checks
|
// frequency of checks
|
||||||
private static final int CHECK_INTERVAL = 2 * 20;
|
public static final int CHECK_INTERVAL = 20 * 20;
|
||||||
// how many times a check has to fail in order to mark the player as AFK
|
// 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 = 3;
|
||||||
|
|
||||||
private static AntiAFK INSTANCE = null;
|
private static AntiAFK INSTANCE = null;
|
||||||
private HashMap<Player, int[]> lastPositions = new HashMap<>();
|
private HashMap<Player, int[]> lastPositions = new HashMap<>();
|
||||||
@ -159,7 +159,23 @@ 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() {
|
public static List<Player> getAwayPlayers() {
|
||||||
return INSTANCE.strikes.entrySet()
|
return INSTANCE.strikes.entrySet()
|
||||||
.stream()
|
.stream()
|
||||||
|
Loading…
Reference in New Issue
Block a user