use of com.djrapitops.plan.storage.database.transactions.events.PingStoreTransaction in project Plan by plan-player-analytics.
the class BungeePingCounter method run.
@Override
public void run() {
long time = System.currentTimeMillis();
Iterator<Map.Entry<UUID, Long>> starts = startRecording.entrySet().iterator();
while (starts.hasNext()) {
Map.Entry<UUID, Long> start = starts.next();
if (time >= start.getValue()) {
addPlayer(start.getKey());
starts.remove();
}
}
Iterator<Map.Entry<UUID, List<DateObj<Integer>>>> iterator = playerHistory.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<UUID, List<DateObj<Integer>>> entry = iterator.next();
UUID uuid = entry.getKey();
List<DateObj<Integer>> history = entry.getValue();
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
if (player != null) {
int ping = getPing(player);
if (ping <= -1 || ping > TimeUnit.SECONDS.toMillis(8L)) {
// Don't accept bad values
continue;
}
history.add(new DateObj<>(time, ping));
if (history.size() >= 30) {
dbSystem.getDatabase().executeTransaction(new PingStoreTransaction(uuid, serverInfo.getServerUUID(), new ArrayList<>(history)));
history.clear();
}
} else {
iterator.remove();
}
}
}
use of com.djrapitops.plan.storage.database.transactions.events.PingStoreTransaction in project Plan by plan-player-analytics.
the class SpongePingCounter method run.
@Override
public void run() {
long time = System.currentTimeMillis();
Iterator<Map.Entry<UUID, Long>> starts = startRecording.entrySet().iterator();
while (starts.hasNext()) {
Map.Entry<UUID, Long> start = starts.next();
if (time >= start.getValue()) {
addPlayer(start.getKey());
starts.remove();
}
}
Iterator<Map.Entry<UUID, List<DateObj<Integer>>>> iterator = playerHistory.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<UUID, List<DateObj<Integer>>> entry = iterator.next();
UUID uuid = entry.getKey();
List<DateObj<Integer>> history = entry.getValue();
Optional<Player> player = Sponge.getServer().getPlayer(uuid);
if (player.isPresent()) {
int ping = getPing(player.get());
if (ping <= -1 || ping > TimeUnit.SECONDS.toMillis(8L)) {
// Don't accept bad values
continue;
}
history.add(new DateObj<>(time, ping));
if (history.size() >= 30) {
dbSystem.getDatabase().executeTransaction(new PingStoreTransaction(uuid, serverInfo.getServerUUID(), new ArrayList<>(history)));
history.clear();
}
} else {
iterator.remove();
}
}
}
use of com.djrapitops.plan.storage.database.transactions.events.PingStoreTransaction in project Plan by plan-player-analytics.
the class FabricPingCounter method run.
@Override
public void run() {
if (!this.isEnabled) {
return;
}
long time = System.currentTimeMillis();
Iterator<Map.Entry<UUID, Long>> starts = startRecording.entrySet().iterator();
while (starts.hasNext()) {
Map.Entry<UUID, Long> start = starts.next();
if (time >= start.getValue()) {
addPlayer(start.getKey());
starts.remove();
}
}
Iterator<Map.Entry<UUID, List<DateObj<Integer>>>> iterator = playerHistory.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<UUID, List<DateObj<Integer>>> entry = iterator.next();
UUID uuid = entry.getKey();
List<DateObj<Integer>> history = entry.getValue();
ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid);
if (player != null) {
int ping = getPing(player);
if (ping <= -1 || ping > TimeUnit.SECONDS.toMillis(8L)) {
// Don't accept bad values
continue;
}
history.add(new DateObj<>(time, ping));
if (history.size() >= 30) {
dbSystem.getDatabase().executeTransaction(new PingStoreTransaction(uuid, serverInfo.getServerUUID(), new ArrayList<>(history)));
history.clear();
}
} else {
iterator.remove();
}
}
}
use of com.djrapitops.plan.storage.database.transactions.events.PingStoreTransaction in project Plan by plan-player-analytics.
the class BukkitPingCounter method run.
@Override
public void run() {
long time = System.currentTimeMillis();
Iterator<Map.Entry<UUID, Long>> starts = startRecording.entrySet().iterator();
while (starts.hasNext()) {
Map.Entry<UUID, Long> start = starts.next();
if (time >= start.getValue()) {
addPlayer(start.getKey());
starts.remove();
}
}
Iterator<Map.Entry<UUID, List<DateObj<Integer>>>> iterator = playerHistory.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<UUID, List<DateObj<Integer>>> entry = iterator.next();
UUID uuid = entry.getKey();
List<DateObj<Integer>> history = entry.getValue();
Player player = Bukkit.getPlayer(uuid);
if (player != null) {
int ping = getPing(player);
if (ping <= -1 || ping > TimeUnit.SECONDS.toMillis(8L)) {
// Don't accept bad values
continue;
}
history.add(new DateObj<>(time, ping));
if (history.size() >= 30) {
dbSystem.getDatabase().executeTransaction(new PingStoreTransaction(uuid, serverInfo.getServerUUID(), new ArrayList<>(history)));
history.clear();
}
} else {
iterator.remove();
}
}
}
use of com.djrapitops.plan.storage.database.transactions.events.PingStoreTransaction in project Plan by plan-player-analytics.
the class NukkitPingCounter method run.
@Override
public void run() {
long time = System.currentTimeMillis();
Iterator<Map.Entry<UUID, Long>> starts = startRecording.entrySet().iterator();
while (starts.hasNext()) {
Map.Entry<UUID, Long> start = starts.next();
if (time >= start.getValue()) {
addPlayer(start.getKey());
starts.remove();
}
}
Iterator<Map.Entry<UUID, List<DateObj<Integer>>>> iterator = playerHistory.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<UUID, List<DateObj<Integer>>> entry = iterator.next();
UUID uuid = entry.getKey();
List<DateObj<Integer>> history = entry.getValue();
Optional<Player> player = Server.getInstance().getPlayer(uuid);
if (player.isPresent()) {
int ping = player.get().getPing();
if (ping <= -1 || ping > TimeUnit.SECONDS.toMillis(8L)) {
// Don't accept bad values
continue;
}
history.add(new DateObj<>(time, ping));
if (history.size() >= 30) {
dbSystem.getDatabase().executeTransaction(new PingStoreTransaction(uuid, serverInfo.getServerUUID(), new ArrayList<>(history)));
history.clear();
}
} else {
iterator.remove();
}
}
}
Aggregations