Package com.sk89q.commandbook.session

Examples of com.sk89q.commandbook.session.UserSession


    }

    public void messagePlayer(CommandSender sender, String target, String message) throws CommandException {
        CommandSender receiver =
                InputUtil.PlayerParser.matchPlayerOrConsole(sender, target);
        UserSession receiverSession = sessions.getSession(UserSession.class, receiver);
        AFKComponent.AFKSession afkSession = sessions.getSession(AFKComponent.AFKSession.class, receiver);
        if (afkSession.isAFK()) {
            String status = afkSession.getIdleStatus();
            sender.sendMessage(config.pmColor + ChatUtil.toColoredName(receiver, config.pmColor) + " is afk. "
                    + "They might not see your message."
                    + (status.trim().length() == 0 ? "" : " (" + status + ")"));
        }

        receiver.sendMessage(config.pmColor + "(From "
                + ChatUtil.toColoredName(sender, config.pmColor) + "): "
                + config.pmTextColor + message);

        sender.sendMessage(config.pmColor + "(To "
                + ChatUtil.toColoredName(receiver, config.pmColor) + "): "
                + config.pmTextColor + message);

        CommandBook.logger().info("(PM) " + ChatUtil.toColoredName(sender, ChatColor.RESET) + " -> "
                + ChatUtil.toColoredName(receiver, ChatColor.RESET) + ": " + message);

        sessions.getSession(UserSession.class, sender).setLastRecipient(receiver);

        // If the receiver hasn't had any player talk to them yet or hasn't
        // send a message, then we add it to the receiver's last message target
        // so s/he can /reply easily
        receiverSession.setNewLastRecipient(sender);
    }
View Full Code Here

TOP

Related Classes of com.sk89q.commandbook.session.UserSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.