Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/main/java/me/bariahq/bariahqmod/command/Command_report.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package me.bariahq.bariahqmod.command;

import me.bariahq.bariahqmod.config.ConfigEntry;
import me.bariahq.bariahqmod.discord.Discord;
import me.bariahq.bariahqmod.rank.Rank;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.entities.TextChannel;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.awt.*;

@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME, blockHostConsole = true)
@CommandParameters(description = "Report a player for staff members to see.", usage = "/<command> <player> <reason>")
public class Command_report extends FreedomCommand
Expand Down Expand Up @@ -46,6 +52,21 @@ public boolean run(CommandSender sender, Player playerSender, Command cmd, Strin

String report = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
plugin.cm.reportAction(playerSender, player, report);
//
TextChannel channel = Discord.bot.getTextChannelById(ConfigEntry.DISCORD_REPORTS_CHANNELID.getString());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a check to see if discord is enabled and running.

EmbedBuilder eb = new EmbedBuilder();
eb.setTitle("New Report");
eb.setAuthor(sender.getName());
eb.addBlankField(true);
eb.setThumbnail(Discord.bot.getTextChannelById(ConfigEntry.DISCORD_REPORTS_CHANNELID.getString()).getGuild().getIconUrl());
eb.addField("Reported User", player.getName(), true);
eb.addField("Reason", report, true);
eb.addField("Reported Player's World", player.getWorld().getName(), true);
eb.addField("Reporter's World", playerSender.getWorld().getName(), true);
eb.addField("Reported Player's Coords", player.getLocation().getX() + ", " + player.getLocation().getY() + ", " + player.getLocation().getZ(), true);
eb.setColor(Color.red);
channel.sendMessage(eb.build()).queue();
//feature coming later on to enable or disable this discord report system via config

msg(ChatColor.GREEN + "Thank you, all online staff members have been notified." + ChatColor.RED + "Please note that only the current online admins will see it" + ChatColor.GREEN + ".");

Expand Down