mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Reduced performance impact of BukkitTPSCountTimer #639
This commit is contained in:
parent
94b5d0d393
commit
94247cdcad
@ -5,6 +5,7 @@ import com.djrapitops.plan.data.container.TPS;
|
||||
import com.djrapitops.plan.system.tasks.TPSCountTimer;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.OperatingSystemMXBean;
|
||||
@ -107,7 +108,11 @@ public class BukkitTPSCountTimer extends TPSCountTimer<Plan> {
|
||||
* @return amount of loaded chunks
|
||||
*/
|
||||
private int getLoadedChunks() {
|
||||
return plugin.getServer().getWorlds().stream().mapToInt(world -> world.getLoadedChunks().length).sum();
|
||||
int sum = 0;
|
||||
for (World world : plugin.getServer().getWorlds()) {
|
||||
sum += world.getLoadedChunks().length;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,6 +121,10 @@ public class BukkitTPSCountTimer extends TPSCountTimer<Plan> {
|
||||
* @return amount of entities
|
||||
*/
|
||||
protected int getEntityCount() {
|
||||
return plugin.getServer().getWorlds().stream().mapToInt(world -> world.getEntities().size()).sum();
|
||||
int sum = 0;
|
||||
for (World world : plugin.getServer().getWorlds()) {
|
||||
sum += world.getEntityCount();
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user