Search in sources :

Example 1 with MessageDispatcher

use of mc.dragons.core.networking.MessageDispatcher in project DragonsOnline by UniverseCraft.

the class Dragons method onLoad.

@Override
public synchronized void onLoad() {
    FIXED_ENTITY_KEY = new NamespacedKey(this, "fixed");
    started = System.currentTimeMillis();
    getLogger().info("Searching for compatible version...");
    switch(BUKKIT_API_VERSION) {
        case "1_16_R3":
            bridge = new BridgeSpigot116R3();
            break;
        default:
            getLogger().severe("Incompatible server version (" + BUKKIT_API_VERSION + ")");
            getLogger().severe("Cannot run DragonsOnline.");
            getServer().getPluginManager().disablePlugin(this);
            return;
    }
    joinable = false;
    getLogger().info("Disabled player joins until Dragons startup completes");
    serverName = getConfig().getString("serverName");
    getLogger().info("Server instance name is " + serverName);
    getLogger().info("Initializing storage and registries...");
    saveDefaultConfig();
    mongoConfig = new MongoConfig(this);
    persistentStorageManager = new MongoStorageManager(this);
    localStorageManager = new LocalStorageManager();
    gameObjectRegistry = new GameObjectRegistry(this, persistentStorageManager);
    addonRegistry = new AddonRegistry(this);
    userHookRegistry = new UserHookRegistry();
    lightweightLoaderRegistry = new LightweightLoaderRegistry();
    sidebarManager = new SidebarManager(this);
    chatMessageRegistry = new ChatMessageRegistry();
    messageDispatcher = new MessageDispatcher(this);
    setCustomLoggingProvider(new CustomLoggingProvider(this));
    autoSaveRunnable = new AutoSaveTask(this);
    spawnEntityRunnable = new SpawnEntityTask(this);
    verifyGameIntegrityRunnable = new VerifyGameIntegrityTask(this);
    lagMeter = new LagMeter();
    lagMonitorTask = new LagMonitorTask();
    updateScoreboardTask = new UpdateScoreboardTask(this);
    serverOptions = new ServerOptions(this);
    serverOptions.setLogLevel(Level.parse(getConfig().getString("loglevel")));
    debug = getConfig().getBoolean("debug");
    if (debug) {
        if (serverOptions.getLogLevel().intValue() > Level.CONFIG.intValue()) {
            serverOptions.setLogLevel(Level.CONFIG);
        }
        serverOptions.setVerifyIntegrityEnabled(false);
        getLogger().warning("==========================================================");
        getLogger().warning("THIS SERVER IS IN DEVELOPMENT MODE.");
        getLogger().warning("GAME INTEGRITY WILL NOT BE VERIFIED AFTER INITIAL LOAD.");
        getLogger().warning("==========================================================");
    }
    customLoggingProvider.enableCustomLogging();
    enableDebugLogging();
    getLogger().info("Log token is " + customLoggingProvider.getCustomLogFilter().getLogEntryUUID());
}
Also used : LightweightLoaderRegistry(mc.dragons.core.storage.loader.LightweightLoaderRegistry) AddonRegistry(mc.dragons.core.addon.AddonRegistry) ChatMessageRegistry(mc.dragons.core.gameobject.user.chat.ChatMessageRegistry) SidebarManager(mc.dragons.core.gameobject.user.SidebarManager) LocalStorageManager(mc.dragons.core.storage.local.LocalStorageManager) UserHookRegistry(mc.dragons.core.gameobject.user.UserHookRegistry) LagMonitorTask(mc.dragons.core.tasks.LagMonitorTask) MongoConfig(mc.dragons.core.storage.mongo.MongoConfig) MongoStorageManager(mc.dragons.core.storage.mongo.MongoStorageManager) GameObjectRegistry(mc.dragons.core.gameobject.GameObjectRegistry) MessageDispatcher(mc.dragons.core.networking.MessageDispatcher) LagMeter(mc.dragons.core.tasks.LagMeter) AutoSaveTask(mc.dragons.core.tasks.AutoSaveTask) SpawnEntityTask(mc.dragons.core.tasks.SpawnEntityTask) NamespacedKey(org.bukkit.NamespacedKey) CustomLoggingProvider(mc.dragons.core.logging.CustomLoggingProvider) UpdateScoreboardTask(mc.dragons.core.tasks.UpdateScoreboardTask) VerifyGameIntegrityTask(mc.dragons.core.tasks.VerifyGameIntegrityTask) BridgeSpigot116R3(mc.dragons.core.bridge.impl.BridgeSpigot116R3)

Example 2 with MessageDispatcher

use of mc.dragons.core.networking.MessageDispatcher in project DragonsOnline by UniverseCraft.

the class PerformanceCommands method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!requirePermission(sender, PermissionLevel.DEVELOPER))
        return true;
    if (label.equalsIgnoreCase("worldperformance")) {
        sender.sendMessage(ChatColor.DARK_GREEN + "World performance statistics for " + dragons.getServerName() + " @ " + StringUtil.dateFormatNow());
        TableGenerator tg = new TableGenerator(Alignment.LEFT, Alignment.LEFT, Alignment.LEFT, Alignment.LEFT, Alignment.LEFT, Alignment.LEFT, Alignment.LEFT);
        tg.addRow(COL_FLOOR, COL_ENTITIES, COL_LIVING, COL_PLAYERS, COL_CHUNKS, COL_POPULATED, COL_RATIO);
        String floorPrefix = ChatColor.YELLOW + "";
        String dataPrefix = ChatColor.GRAY + "";
        for (World w : Bukkit.getWorlds()) {
            long populatedChunks = Arrays.stream(w.getLoadedChunks()).filter(ch -> Arrays.stream(ch.getEntities()).filter(e -> e.getType() == EntityType.PLAYER).count() > 0).count();
            tg.addRowEx("/worldmanager " + w.getName(), "Click to manage performance of " + w.getName(), floorPrefix + w.getName(), dataPrefix + w.getEntities().size(), dataPrefix + w.getLivingEntities().size(), dataPrefix + w.getPlayers().size(), dataPrefix + w.getLoadedChunks().length, dataPrefix + populatedChunks, dataPrefix + MathUtil.round(100 * (double) populatedChunks / w.getLoadedChunks().length) + "%");
        }
        tg.display(sender);
    } else if (label.equalsIgnoreCase("worldmanager")) {
        World w = args.length == 0 ? player(sender).getWorld() : Bukkit.getWorld(args[0]);
        if (w == null) {
            sender.sendMessage(ChatColor.RED + "No world named '" + args[0] + "'");
            return true;
        }
        sender.sendMessage(ChatColor.GREEN + "Manage world " + w.getName());
        sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + " [Manage Floor]", "/floor " + FloorLoader.fromWorld(w).getFloorName(), "Click to manage associated floor"), StringUtil.clickableHoverableText(ChatColor.GRAY + " [Unload Chunks]", "/unloadchunks " + w.getName(), "Click to unload all chunks from this world"), StringUtil.clickableHoverableText(ChatColor.GRAY + " [Reload Chunks]", "/reloadchunks " + w.getName(), "Click to reload all chunks from this world"), StringUtil.clickableHoverableText(ChatColor.GRAY + " [Clear Drops]", "/cleardrops " + w.getName(), "Click to remove all dropped items from this world"), StringUtil.clickableHoverableText(ChatColor.GRAY + " [Clear Mobs]", "/clearmobs " + w.getName(), "Click to remove all non-persistent mobs from this world"));
    } else if (label.equalsIgnoreCase("unloadchunks")) {
        World w = args.length == 0 ? player(sender).getWorld() : Bukkit.getWorld(args[0]);
        if (w == null) {
            sender.sendMessage(ChatColor.RED + "No world named '" + args[0] + "'");
            return true;
        }
        int success = 0;
        int total = 0;
        for (Chunk c : w.getLoadedChunks()) {
            if (c.unload(true))
                success++;
            total++;
        }
        sender.sendMessage(ChatColor.GREEN + "" + success + "/" + total + " chunks unloaded in " + w.getName());
    } else if (label.equalsIgnoreCase("reloadchunks")) {
        World w = args.length == 0 ? player(sender).getWorld() : Bukkit.getWorld(args[0]);
        if (w == null) {
            sender.sendMessage(ChatColor.RED + "No world named '" + args[0] + "'");
            return true;
        }
        int success = 0, total = 0;
        for (Chunk c : w.getLoadedChunks()) {
            if (c.unload(true))
                success++;
            c.load(false);
            total++;
        }
        sender.sendMessage(ChatColor.GREEN + "" + success + "/" + total + " chunks reloaded in " + w.getName());
    } else if (label.equalsIgnoreCase("cleardrops")) {
        World w = args.length == 0 ? player(sender).getWorld() : Bukkit.getWorld(args[0]);
        if (w == null) {
            sender.sendMessage(ChatColor.RED + "No world named '" + args[0] + "'");
            return true;
        }
        int total = 0;
        for (Entity e : w.getEntities()) {
            if (e.getType() == EntityType.DROPPED_ITEM) {
                e.remove();
                total++;
            }
        }
        sender.sendMessage(ChatColor.GREEN + "" + total + " drops cleared in " + w.getName());
    } else if (label.equalsIgnoreCase("clearmobs")) {
        World w = args.length == 0 ? player(sender).getWorld() : Bukkit.getWorld(args[0]);
        if (w == null) {
            sender.sendMessage(ChatColor.RED + "No world named '" + args[0] + "'");
            return true;
        }
        int total = 0;
        for (Entity e : w.getEntities()) {
            if (e instanceof Player || e instanceof Item || e instanceof ItemFrame)
                continue;
            if (e.getPersistentDataContainer().has(Dragons.FIXED_ENTITY_KEY, PersistentDataType.SHORT))
                continue;
            if (e.hasMetadata("allow"))
                continue;
            NPC npc = NPCLoader.fromBukkit(e);
            if (npc == null) {
                e.remove();
                total++;
            } else if (!npc.getNPCType().isPersistent()) {
                npc.remove();
                total++;
            }
        }
        sender.sendMessage(ChatColor.GREEN + "" + total + " mobs cleared in " + w.getName());
    } else if (label.equalsIgnoreCase("getsystemproperties")) {
        sender.sendMessage(ChatColor.GREEN + "Listing all system properties:");
        System.getProperties().forEach((key, value) -> {
            sender.sendMessage(ChatColor.GRAY + "" + key + " = " + value);
        });
    } else if (label.equalsIgnoreCase("serverperformance")) {
        new // some OperatingSystemMXBean operations lag the thread, so run asynchronously
        BukkitRunnable() {

            @Override
            public void run() {
                Properties props = System.getProperties();
                sender.sendMessage(ChatColor.DARK_GREEN + "Server performance statistics generated at " + StringUtil.dateFormatNow());
                sender.sendMessage(ChatColor.GREEN + "Bukkit Version: " + ChatColor.GRAY + Bukkit.getVersion());
                sender.sendMessage(ChatColor.GREEN + "Uptime: " + ChatColor.GRAY + StringUtil.parseSecondsToTimespan(dragons.getUptime() / 1000));
                sender.sendMessage(ChatColor.GREEN + "Estimated Current TPS: " + ChatColor.GRAY + LagMeter.getRoundedTPS());
                sender.sendMessage(ChatColor.GREEN + "Server Architecture: " + ChatColor.GRAY + props.getProperty("os.arch", "Unknown"));
                sender.sendMessage(ChatColor.GREEN + "Operating System: " + ChatColor.GRAY + props.getProperty("os.name", "Unknown") + " v" + props.getProperty("os.version", "Unknown") + " (" + props.getProperty("os.arch", "Unknown Architecture") + ")");
                sender.sendMessage(ChatColor.GREEN + "Java Version: " + ChatColor.GRAY + props.getProperty("java.version", "Unknown") + " (" + props.getProperty("java.vendor", "Unknown Vendor") + ")");
                sender.sendMessage(ChatColor.GREEN + "JVM Version: " + ChatColor.GRAY + props.getProperty("java.vm.name", "Unknown Name") + props.getProperty("java.vm.version", "Unknown") + " (" + props.getProperty("java.vm.vendor", "Unknown Vendor") + ")");
                try {
                    OperatingSystemMXBean osBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
                    sender.sendMessage(ChatColor.GREEN + "Available Processors: " + ChatColor.GRAY + osBean.getAvailableProcessors());
                    sender.sendMessage(ChatColor.GREEN + "Process Committed Virtual Memory: " + ChatColor.GRAY + (osBean.getCommittedVirtualMemorySize() / BYTES_IN_MB) + "MB");
                    // sender.sendMessage(ChatColor.GREEN + "Process Free Physical Memory: " + ChatColor.GRAY + (osBean.getFreePhysicalMemorySize() / BYTES_IN_MB) + "MB");
                    sender.sendMessage(ChatColor.GREEN + "Process CPU Load: " + ChatColor.GRAY + Math.round(100 * osBean.getProcessCpuLoad()) + "%");
                    sender.sendMessage(ChatColor.GREEN + "Process CPU Time: " + ChatColor.GRAY + (osBean.getProcessCpuTime() / NS_IN_MS) + "ms");
                    sender.sendMessage(ChatColor.GREEN + "Free Swap Space: " + ChatColor.GRAY + (osBean.getFreeSwapSpaceSize() / BYTES_IN_MB) + "MB");
                    // sender.sendMessage(ChatColor.GREEN + "Total Physical Memory: " + ChatColor.GRAY + (osBean.getTotalPhysicalMemorySize() / BYTES_IN_MB) + "MB");
                    // sender.sendMessage(ChatColor.GREEN + "System CPU Load: " + ChatColor.GRAY + Math.round(100 * osBean.getSystemCpuLoad()) + "%");
                    sender.sendMessage(ChatColor.GREEN + "System Load Average: " + ChatColor.GRAY + Math.round(100 * osBean.getSystemLoadAverage()) + "%");
                    ThreadMXBean threadBean = ManagementFactory.getPlatformMXBean(ThreadMXBean.class);
                    sender.sendMessage(ChatColor.GREEN + "Thread Count: " + ChatColor.GRAY + threadBean.getThreadCount());
                    sender.sendMessage(ChatColor.GREEN + "Daemon Thread Count: " + ChatColor.GRAY + threadBean.getDaemonThreadCount());
                    sender.sendMessage(ChatColor.GREEN + "Peak Thread Count: " + ChatColor.GRAY + threadBean.getPeakThreadCount());
                } catch (Exception e) {
                    sender.sendMessage(ChatColor.GRAY + "Some server statistics are unavailable for this platform: Unsupported MXBean(s)");
                }
            }
        }.runTaskAsynchronously(dragons);
    } else if (label.equalsIgnoreCase("tickperformance") || label.equalsIgnoreCase("tickperf")) {
        if (args.length == 0) {
            sender.sendMessage(ChatColor.RED + "/tickperformance start <recPeriodInSeconds>");
            sender.sendMessage(ChatColor.RED + "/tickperformance clear");
            sender.sendMessage(ChatColor.RED + "/tickperformance view [-verbose]" + ChatColor.GRAY + " (after data has been collected)");
        } else if (args[0].equalsIgnoreCase("start")) {
            if (args.length == 1) {
                sender.sendMessage(ChatColor.RED + "/tickperformance start <recPeriodInSeconds>");
                return true;
            }
            if (tickTimings.size() > 0) {
                sender.sendMessage(ChatColor.RED + "Please clear existing tick performance data before running this again! /tickperformance clear");
                return true;
            }
            Integer seconds = parseInt(sender, args[1]);
            if (seconds == null)
                return true;
            new BukkitRunnable() {

                long start = System.currentTimeMillis();

                @Override
                public void run() {
                    long now = System.currentTimeMillis();
                    tickTimings.add(now);
                    if ((now - start) / 1000 >= seconds) {
                        sender.sendMessage(ChatColor.GREEN + "Tick timings data collection has completed. Do /tickperformance view to view the data.");
                        cancel();
                    }
                }
            }.runTaskTimer(dragons, 1L, 1L);
            sender.sendMessage(ChatColor.GREEN + "Began tick timings data collection. Server may experience mild lag while this runs.");
        } else if (args[0].equalsIgnoreCase("clear")) {
            tickTimings.clear();
            sender.sendMessage(ChatColor.GREEN + "Cleared tick timings data.");
        } else if (args[0].equalsIgnoreCase("view")) {
            if (tickTimings.size() == 0) {
                sender.sendMessage(ChatColor.RED + "No tick performance data available! To gather data, do /tickperformance start <recPeriodInSeconds>");
                return true;
            }
            sender.sendMessage(ChatColor.DARK_GREEN + "Recorded tick data:");
            long prev = tickTimings.get(0);
            long longest = 0;
            long shortest = -1;
            long sum = 0;
            int nLong = 0;
            boolean verbose = args.length > 1 && args[1].equalsIgnoreCase("-verbose");
            for (int i = 1; i < tickTimings.size(); i++) {
                long ms = tickTimings.get(i) - prev;
                sum += ms;
                if (ms > longest)
                    longest = ms;
                if (shortest == -1 || ms < shortest)
                    shortest = ms;
                if (ms > 5 + 1000 / 20)
                    nLong++;
                if (verbose)
                    sender.sendMessage(ChatColor.GRAY + "#" + i + ": " + (ms <= 5 + 1000 / 20 ? ChatColor.GREEN : ChatColor.RED) + ms + "ms");
                prev = tickTimings.get(i);
            }
            double avg = (double) sum / (tickTimings.size() - 1);
            sender.sendMessage(ChatColor.GREEN + "Ticks Recorded: " + ChatColor.GRAY + (tickTimings.size() - 1));
            sender.sendMessage(ChatColor.GREEN + "Long Ticks: " + ChatColor.GRAY + nLong);
            sender.sendMessage(ChatColor.GREEN + "Shortest Tick: " + ChatColor.GRAY + shortest + "ms");
            sender.sendMessage(ChatColor.GREEN + "Longest Tick: " + ChatColor.GRAY + longest + "ms");
            sender.sendMessage(ChatColor.GREEN + "Average Tick: " + ChatColor.GRAY + MathUtil.round(avg) + "ms");
        }
    } else if (label.equalsIgnoreCase("getprocessid")) {
        if (!requirePermission(sender, SystemProfileFlag.DEVELOPMENT))
            return true;
        sender.sendMessage(ChatColor.GREEN + "Process ID: " + ChatColor.GRAY + ProcessHandle.current().pid());
    } else if (label.equalsIgnoreCase("getstacktrace")) {
        if (!requirePermission(sender, SystemProfileFlag.DEVELOPMENT))
            return true;
        UUID cid = LOGGER.newCID();
        Thread thread = Thread.currentThread();
        if (args.length > 0) {
            Integer id = parseInt(sender, args[0]);
            for (Thread test : Thread.getAllStackTraces().keySet()) {
                if (test.getId() == id) {
                    thread = test;
                    break;
                }
            }
        }
        LOGGER.info(cid, "Stack trace requested for thread " + thread.getId() + " " + thread.getName() + " (" + thread.getState() + ")");
        sender.sendMessage(ChatColor.GREEN + "Stack trace for thread " + thread.getId() + " " + thread.getName() + " (" + thread.getState() + ")");
        for (StackTraceElement elem : thread.getStackTrace()) {
            sender.sendMessage(ChatColor.GRAY + elem.toString());
            LOGGER.info(cid, elem.toString());
        }
        sender.sendMessage(ChatColor.YELLOW + "Stack trace logged with correlation ID " + StringUtil.toHdFont(cid.toString()));
    } else if (label.equalsIgnoreCase("getactivethreads")) {
        if (!requirePermission(sender, SystemProfileFlag.DEVELOPMENT))
            return true;
        sender.sendMessage(ChatColor.DARK_GREEN + "" + Thread.getAllStackTraces().size() + " active threads:");
        // adapted from https://stackoverflow.com/a/46979843/8463670
        Thread.getAllStackTraces().keySet().stream().collect(Collectors.groupingBy(Thread::getThreadGroup)).forEach((group, threads) -> {
            sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "GROUP " + group.getName() + " - " + group.activeCount() + " thr, " + group.activeGroupCount() + " sub" + ", par=" + (group.getParent() == null ? "none" : group.getParent().getName()) + ", maxpriority=" + group.getMaxPriority());
            TableGenerator tg = new TableGenerator(Alignment.LEFT, Alignment.LEFT, Alignment.LEFT, Alignment.LEFT, Alignment.LEFT);
            tg.addRow(COL_ID, COL_NAME, COL_STATE, COL_PRIORITY, COL_DAEMON);
            for (Thread thread : threads) {
                tg.addRowEx("/getstacktrace " + thread.getId(), "Click to view stack trace for thread #" + thread.getId() + " " + thread.getName() + " (" + thread.getState() + ")", "" + thread.getId(), StringUtil.truncateWithEllipsis(thread.getName(), 20), thread.getState().toString(), "" + thread.getPriority(), "" + thread.isDaemon());
            }
            tg.display(sender);
        });
    } else if (label.equalsIgnoreCase("requestgc")) {
        if (!requirePermission(sender, SystemProfileFlag.DEVELOPMENT))
            return true;
        long before = System.currentTimeMillis();
        System.gc();
        sender.sendMessage(ChatColor.GREEN + "Ran garbage collector in " + (System.currentTimeMillis() - before) + "ms");
    } else if (label.equalsIgnoreCase("generatedump")) {
        CommandSender console = Bukkit.getConsoleSender();
        dragons.getLogger().info("");
        dragons.getLogger().info("");
        dragons.getLogger().info("");
        dragons.getLogger().info("==== BEGIN FULL SERVER DATA DUMP ====");
        dragons.getLogger().info("");
        dragons.getLogger().info("=== BEGIN USER DUMP ===");
        for (User user : UserLoader.allUsers()) {
            if (user.getPlayer() == null) {
                dragons.getLogger().info("USER " + user.getName() + " - " + user + " - OFFLINE");
            } else {
                dragons.getLogger().info("USER " + user.getName() + " - " + user + " - World " + user.getPlayer().getWorld() + ", Loc " + StringUtil.locToString(user.getPlayer().getLocation()) + ", Access Level " + user.getActivePermissionLevel());
            }
        }
        dragons.getLogger().info("=== END USER DUMP ===");
        dragons.getLogger().info("");
        Bukkit.dispatchCommand(console, "debug dump gameobjects");
        dragons.getLogger().info("");
        Bukkit.dispatchCommand(console, "debug dump entities");
        dragons.getLogger().info("");
        Bukkit.dispatchCommand(console, "debug dump threads");
        dragons.getLogger().info("");
        Bukkit.dispatchCommand(console, "debug dump workers");
        dragons.getLogger().info("");
        Bukkit.dispatchCommand(console, "debug dump pendingtasks");
        dragons.getLogger().info("");
        Bukkit.dispatchCommand(console, "lag");
        dragons.getLogger().info("");
        Bukkit.dispatchCommand(console, "worldperformance");
        dragons.getLogger().info("");
        Bukkit.dispatchCommand(console, "serverperformance");
        dragons.getLogger().info("");
        dragons.getLogger().info("==== END FULL SERVER DATA DUMP ====");
        dragons.getLogger().info("");
        dragons.getLogger().info("");
        dragons.getLogger().info("");
    } else if (label.equalsIgnoreCase("clearnetworkmessagecache") || label.equalsIgnoreCase("clearnmc")) {
        if (!requirePermission(sender, SystemProfileFlag.DEVELOPMENT))
            return true;
        MongoCollection<Document> messages = dragons.getMongoConfig().getDatabase().getCollection(MessageConstants.MESSAGE_COLLECTION);
        if (args.length == 0) {
            DeleteResult result = messages.deleteMany(new Document());
            sender.sendMessage(ChatColor.GREEN + "Successfully cleared the network-wide message cache (n=" + result.getDeletedCount() + ")");
        } else {
            Integer seconds = parseInt(sender, args[0]);
            if (seconds == null)
                return true;
            DeleteResult result = messages.deleteMany(new Document("timestamp", new Document("$lt", System.currentTimeMillis() - seconds * 1000)));
            sender.sendMessage(ChatColor.GREEN + "Successfully removed " + result.getDeletedCount() + " messages from the cache");
        }
    } else if (label.equalsIgnoreCase("printnetworkmessages")) {
        if (!requirePermission(sender, SystemProfileFlag.DEVELOPMENT))
            return true;
        MessageDispatcher dispatcher = dragons.getMessageDispatcher();
        dispatcher.setDebug(!dispatcher.isDebug());
        sender.sendMessage(ChatColor.GREEN + (dispatcher.isDebug() ? "Enabled" : "Disabled") + " network message logging.");
    } else if (label.equalsIgnoreCase("manifest")) {
        Map<String, List<UUID>> manifest = User.getConnectionMessageHandler().getManifest();
        sender.sendMessage(ChatColor.DARK_GREEN + "Displaying network-wide user manifest.");
        manifest.forEach((server, users) -> {
            sender.sendMessage(ChatColor.YELLOW + "Server " + server + " - " + users.size() + " online");
            sender.sendMessage(ChatColor.GRAY + "  " + StringUtil.parseList(users.stream().map(uuid -> userLoader.loadObject(uuid).getName()).collect(Collectors.toList())));
        });
    }
    return true;
}
Also used : Document(org.bson.Document) NPCLoader(mc.dragons.core.gameobject.npc.NPCLoader) Arrays(java.util.Arrays) Alignment(mc.dragons.core.util.TableGenerator.Alignment) MongoCollection(com.mongodb.client.MongoCollection) MessageConstants(mc.dragons.core.networking.MessageConstants) Item(org.bukkit.entity.Item) ThreadMXBean(com.sun.management.ThreadMXBean) User(mc.dragons.core.gameobject.user.User) Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) MessageDispatcher(mc.dragons.core.networking.MessageDispatcher) DragonsCommandExecutor(mc.dragons.core.commands.DragonsCommandExecutor) PermissionLevel(mc.dragons.core.gameobject.user.permission.PermissionLevel) ItemFrame(org.bukkit.entity.ItemFrame) World(org.bukkit.World) Map(java.util.Map) Chunk(org.bukkit.Chunk) ManagementFactory(java.lang.management.ManagementFactory) Bukkit(org.bukkit.Bukkit) StringUtil(mc.dragons.core.util.StringUtil) CommandSender(org.bukkit.command.CommandSender) Properties(java.util.Properties) UserLoader(mc.dragons.core.gameobject.user.UserLoader) Entity(org.bukkit.entity.Entity) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) FloorLoader(mc.dragons.core.gameobject.floor.FloorLoader) UUID(java.util.UUID) EntityType(org.bukkit.entity.EntityType) SystemProfileFlag(mc.dragons.core.gameobject.user.permission.SystemProfile.SystemProfileFlags.SystemProfileFlag) Collectors(java.util.stream.Collectors) Dragons(mc.dragons.core.Dragons) List(java.util.List) OperatingSystemMXBean(com.sun.management.OperatingSystemMXBean) LagMeter(mc.dragons.core.tasks.LagMeter) TableGenerator(mc.dragons.core.util.TableGenerator) DeleteResult(com.mongodb.client.result.DeleteResult) ChatColor(org.bukkit.ChatColor) Command(org.bukkit.command.Command) MathUtil(mc.dragons.core.util.MathUtil) NPC(mc.dragons.core.gameobject.npc.NPC) PersistentDataType(org.bukkit.persistence.PersistentDataType) NPC(mc.dragons.core.gameobject.npc.NPC) Entity(org.bukkit.entity.Entity) User(mc.dragons.core.gameobject.user.User) ItemFrame(org.bukkit.entity.ItemFrame) World(org.bukkit.World) Properties(java.util.Properties) Document(org.bson.Document) Item(org.bukkit.entity.Item) MessageDispatcher(mc.dragons.core.networking.MessageDispatcher) ArrayList(java.util.ArrayList) List(java.util.List) UUID(java.util.UUID) ThreadMXBean(com.sun.management.ThreadMXBean) Player(org.bukkit.entity.Player) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) TableGenerator(mc.dragons.core.util.TableGenerator) Chunk(org.bukkit.Chunk) CommandSender(org.bukkit.command.CommandSender) OperatingSystemMXBean(com.sun.management.OperatingSystemMXBean) DeleteResult(com.mongodb.client.result.DeleteResult)

Aggregations

MessageDispatcher (mc.dragons.core.networking.MessageDispatcher)2 LagMeter (mc.dragons.core.tasks.LagMeter)2 MongoCollection (com.mongodb.client.MongoCollection)1 DeleteResult (com.mongodb.client.result.DeleteResult)1 OperatingSystemMXBean (com.sun.management.OperatingSystemMXBean)1 ThreadMXBean (com.sun.management.ThreadMXBean)1 ManagementFactory (java.lang.management.ManagementFactory)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Properties (java.util.Properties)1 UUID (java.util.UUID)1 Collectors (java.util.stream.Collectors)1 Dragons (mc.dragons.core.Dragons)1 AddonRegistry (mc.dragons.core.addon.AddonRegistry)1 BridgeSpigot116R3 (mc.dragons.core.bridge.impl.BridgeSpigot116R3)1 DragonsCommandExecutor (mc.dragons.core.commands.DragonsCommandExecutor)1 GameObjectRegistry (mc.dragons.core.gameobject.GameObjectRegistry)1 FloorLoader (mc.dragons.core.gameobject.floor.FloorLoader)1