Managing and organizing scripts with folders
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
let module = requireScript("Modules/ExampleModule.js");
// Run functions in main thread because scripts run on an async thread by default
task.main(function() {
log.info("Total players: " + module.getTotalPlayers());
log.info("Total entities: " + module.getTotalEntities());
log.info("Total worlds: " + module.getWorldCount());
})var Bukkit = org.bukkit.Bukkit
return {
getTotalPlayers: function() {
try {
return Bukkit.getOnlinePlayers().size();
} catch (error) {
log.error("Error getting player count: " + error);
return 0;
}
},
getTotalEntities: function() {
var totalEntities = 0;
try {
var worlds = Bukkit.getWorlds();
for (var i = 0; i < worlds.size(); i++) {
var world = worlds.get(i);
var entities = world.getEntities();
totalEntities += entities.size();
}
return totalEntities;
} catch (error) {
log.error("Error getting entity count: " + error);
return 0;
}
},
getWorldCount: function() {
return Bukkit.getWorlds().size();
}
}