Search in sources :

Example 1 with MessageData

use of mc.dragons.core.gameobject.user.chat.MessageData in project DragonsOnline by UniverseCraft.

the class PrivateMessageHandler method doLocalReceive.

private void doLocalReceive(User to, User from, String message) {
    MessageData messageData = new MessageData(from, to, message);
    registry.register(messageData);
    to.getPlayer().spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GOLD + "[" + from.getName() + " -> " + to.getName() + "] " + ChatColor.GRAY + message, "/chatreport " + messageData.getId() + " --id", ChatColor.YELLOW + "Click to report this message"));
    to.setLastReceivedMessageFrom(from.getName());
    to.getSeenMessages().add(messageData);
}
Also used : MessageData(mc.dragons.core.gameobject.user.chat.MessageData)

Example 2 with MessageData

use of mc.dragons.core.gameobject.user.chat.MessageData in project DragonsOnline by UniverseCraft.

the class ChatReportCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!requirePlayer(sender))
        return true;
    if (args.length == 0) {
        sender.sendMessage(ChatColor.RED + "/chatreport <player> or click on a chat message to report it.");
        return true;
    }
    User reporter = user(sender);
    boolean queryId = StringUtil.getFlagIndex(args, "--id", 1) != -1;
    /* /chatreport <player> */
    if (!queryId) {
        User target = lookupUser(sender, args[0]);
        if (target == null)
            return true;
        if (target.equals(reporter) && !reporter.getLocalData().getBoolean("canSelfReport", false)) {
            sender.sendMessage(ChatColor.RED + "You can't report your own message!");
            return true;
        }
        sender.sendMessage(ChatColor.DARK_GREEN + "Report a message by " + target.getName());
        int i = 0;
        for (MessageData message : reporter.getSeenMessages()) {
            if (message.getSender().equals(target) && (!message.isPrivate() || message.isPrivate() && message.getTo().equals(reporter))) {
                sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + "- " + ChatColor.RESET + message.getMessage() + (message.isPrivate() ? ChatColor.GRAY + " (Private)" : ""), "/chatreport " + message.getId() + " --id", "Click to report this message"));
                i++;
                if (i >= 10)
                    break;
            }
        }
        if (i == 0) {
            sender.sendMessage(ChatColor.RED + "There are no messages by that user to report!");
        } else {
            sender.sendMessage(ChatColor.YELLOW + "Click on a message above to report it.");
        }
        return true;
    }
    /* /chatreport <messageId> */
    Integer messageId = parseInt(sender, args[0]);
    if (messageId == null)
        return true;
    MessageData messageData = chatMessageRegistry.get(messageId);
    if (messageData == null || (messageData.isPrivate() && !messageData.getTo().equals(reporter))) {
        sender.sendMessage(ChatColor.RED + "No data found for the specified message!");
        return true;
    }
    if (messageData.getSender().equals(reporter) && !reporter.getLocalData().getBoolean("canSelfReport", false)) {
        sender.sendMessage(ChatColor.RED + "You can't report your own message!");
        return true;
    }
    if (args.length < 3 || !args[2].equals(CONFIRMATION_FLAG)) {
        sender.sendMessage(" ");
        sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "Please review your chat report before submitting.");
        sender.sendMessage(ChatColor.GREEN + "Reporting: " + ChatColor.GRAY + messageData.getSender().getName());
        sender.sendMessage(ChatColor.GREEN + "Message: " + ChatColor.GRAY + messageData.getMessage());
        sender.sendMessage(ChatColor.GREEN + "Type: " + ChatColor.GRAY + (messageData.isPrivate() ? "Private Message" : "Public Chat"));
        sender.sendMessage(" ");
        sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.DARK_GREEN + "" + ChatColor.BOLD + "[Submit]", "/chatreport " + args[0] + " --id " + CONFIRMATION_FLAG, "By submitting, you confirm that this report is accurate to the best of your knowledge."), new TextComponent(" "), StringUtil.hoverableText(ChatColor.GRAY + "" + ChatColor.BOLD + "[Cancel]", "You can always create a new chat report by clicking on a chat message."));
        sender.sendMessage(" ");
        return true;
    }
    reportLoader.fileChatReport(messageData.getSender(), reporter, messageData);
    sender.sendMessage(ChatColor.GREEN + "Chat report filed successfully. A staff member will review it as soon as possible." + (reporter.isVerified() ? " As a verified user, your reports are prioritized for review." : ""));
    sender.spigot().sendMessage(StringUtil.clickableHoverableText(ChatColor.GRAY + " [Click to Block Player]", "/block " + messageData.getSender().getName(), "Click to block " + messageData.getSender().getName()));
    return true;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) User(mc.dragons.core.gameobject.user.User) MessageData(mc.dragons.core.gameobject.user.chat.MessageData)

Example 3 with MessageData

use of mc.dragons.core.gameobject.user.chat.MessageData in project DragonsOnline by UniverseCraft.

the class ChatOptionsCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    User user = user(sender);
    if (label.equals("chatoptions")) {
        if (args.length == 0)
            return true;
        Integer id = parseInt(sender, args[0]);
        if (id == null)
            return true;
        MessageData msg = dragons.getChatMessageRegistry().get(id);
        if (!user.getSeenMessages().contains(msg)) {
            sender.sendMessage(ChatColor.RED + "Nope!");
            return true;
        }
        messageTxn.put(user, msg);
        sender.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + msg.getSender().getName() + " - " + msg.getMessage());
        TextComponent replyText = StringUtil.plainText("");
        if (!msg.isPrivate()) {
            replyText = StringUtil.clickableHoverableText(ChatColor.GREEN + " [Reply]", "/chatreply ", true, "Reply to this message");
        }
        sender.spigot().sendMessage(replyText, StringUtil.clickableHoverableText(ChatColor.YELLOW + " [Report]", "/chatreport " + id + " --id", "Report this message"));
    } else if (label.equals("chatreply")) {
        if (args.length == 0 || !messageTxn.containsKey(user)) {
            sender.sendMessage(ChatColor.RED + "Click on a chat message and select [Reply] to reply to it");
            sender.sendMessage(ChatColor.GRAY + " This will move you to the channel the message was sent on");
            return true;
        }
        MessageData msg = messageTxn.get(user);
        if (user.getSpeakingChannel() != msg.getChannel()) {
            sender.sendMessage(ChatColor.GREEN + "Now speaking on " + msg.getChannel());
            user.setSpeakingChannel(msg.getChannel());
        }
        sender.sendMessage(" ");
        user.chat(StringUtil.concatArgs(args, 0), msg.getId());
    }
    return true;
}
Also used : TextComponent(net.md_5.bungee.api.chat.TextComponent) User(mc.dragons.core.gameobject.user.User) MessageData(mc.dragons.core.gameobject.user.chat.MessageData)

Aggregations

MessageData (mc.dragons.core.gameobject.user.chat.MessageData)3 User (mc.dragons.core.gameobject.user.User)2 TextComponent (net.md_5.bungee.api.chat.TextComponent)2