Fixed time conversion being from seconds to millis instead of minutes to milis and npe for last kicked tracker
This commit is contained in:
parent
dd80712fee
commit
d943ce999e
|
|
@ -1,6 +1,7 @@
|
|||
package com.alttd.afkdectector;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.alttd.afkdectector.afkplayer.AFKPlayer;
|
||||
import com.alttd.afkdectector.config.Config;
|
||||
|
|
@ -54,7 +55,7 @@ public class AFKCheckTimer extends BukkitRunnable{
|
|||
}
|
||||
}
|
||||
long standingTime = afkplayer.getstandingTime();
|
||||
if(System.currentTimeMillis() - standingTime > Config.TOGGLETIME * 60 * 1000 && !afkplayer.isafk()) {
|
||||
if(!afkplayer.isafk() && System.currentTimeMillis() - standingTime > TimeUnit.MINUTES.toMillis(Config.TOGGLETIME)) {
|
||||
afkplayer.setafk(true);
|
||||
player.setSleepingIgnored(true);
|
||||
//player.setCanPickupItems(false);
|
||||
|
|
@ -67,7 +68,7 @@ public class AFKCheckTimer extends BukkitRunnable{
|
|||
Bukkit.broadcast(component, "afkdetector.notify");
|
||||
}
|
||||
}
|
||||
if(System.currentTimeMillis() - standingTime > afkplayer.getafkTime() * 60 * 1000) {
|
||||
if(System.currentTimeMillis() - standingTime > TimeUnit.MINUTES.toMillis(afkplayer.getafkTime())) {
|
||||
MessageTimer currentTimer = plugin.messageTimers.get(uuid);
|
||||
if(currentTimer == null) {
|
||||
currentTimer = new MessageTimer(plugin, afkplayer, Config.MESSAGEREPEATS);
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ public class AFKDetector extends JavaPlugin implements Listener{
|
|||
}
|
||||
|
||||
long lastKick = AutoJoinTracker.getInstance().getLastKick(uuid);
|
||||
if (lastKick + TimeUnit.SECONDS.toMillis(Config.MAXREJOINFORTRACKING) > new Date().getTime()) {
|
||||
if (lastKick + TimeUnit.MINUTES.toMillis(Config.MAXREJOINFORTRACKING) > new Date().getTime()) {
|
||||
SuspiciousKickTracker skt = SuspiciousKickTracker.getInstance();
|
||||
skt.addSuspiciousKick(uuid);
|
||||
int suspiciousKickCount = skt.getSuspiciousKickCount(uuid);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.alttd.afkdectector;
|
|||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.alttd.afkdectector.afkplayer.AFKPlayer;
|
||||
import com.alttd.afkdectector.config.Config;
|
||||
|
|
@ -31,7 +32,7 @@ public class MessageTimer extends BukkitRunnable {
|
|||
}
|
||||
|
||||
public void init() {
|
||||
runTaskTimer(plugin, 0, Config.MESSAGEDELAY * 20);
|
||||
runTaskTimer(plugin, 0, Config.MESSAGEDELAY * 20L);
|
||||
}
|
||||
|
||||
// TODO get a better string builder
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class AutoJoinTracker {
|
|||
}
|
||||
|
||||
synchronized public long getLastKick(UUID uuid) {
|
||||
return lastKickedMap.get(uuid);
|
||||
return lastKickedMap.getOrDefault(uuid, 0L);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user