Fixes oversight where not having Essentials installed causes Discord reporting to fail

This commit is contained in:
Video 2022-09-11 16:14:31 -06:00
parent 575568cb05
commit 0cd2886e40

View File

@ -444,6 +444,8 @@ public class Discord extends FreedomService
embedBuilder.setDescription(reason); embedBuilder.setDescription(reason);
embedBuilder.setFooter("Reported by " + reporter.getName(), "https://minotar.net/helm/" + reporter.getName() + ".png"); embedBuilder.setFooter("Reported by " + reporter.getName(), "https://minotar.net/helm/" + reporter.getName() + ".png");
embedBuilder.setTimestamp(Instant.from(ZonedDateTime.now())); embedBuilder.setTimestamp(Instant.from(ZonedDateTime.now()));
if (plugin.esb.isEnabled())
{
com.earth2me.essentials.User user = plugin.esb.getEssentialsUser(reported.getName()); com.earth2me.essentials.User user = plugin.esb.getEssentialsUser(reported.getName());
String location = "World: " + Objects.requireNonNull(user.getLastLocation().getWorld()).getName() + ", X: " + user.getLastLocation().getBlockX() + ", Y: " + user.getLastLocation().getBlockY() + ", Z: " + user.getLastLocation().getBlockZ(); String location = "World: " + Objects.requireNonNull(user.getLastLocation().getWorld()).getName() + ", X: " + user.getLastLocation().getBlockX() + ", Y: " + user.getLastLocation().getBlockY() + ", Z: " + user.getLastLocation().getBlockZ();
embedBuilder.addField("Location", location, true); embedBuilder.addField("Location", location, true);
@ -452,6 +454,7 @@ public class Discord extends FreedomService
{ {
embedBuilder.addField("Nickname", user.getNickname(), true); embedBuilder.addField("Nickname", user.getNickname(), true);
} }
}
MessageEmbed embed = embedBuilder.build(); MessageEmbed embed = embedBuilder.build();
Message message = channel.sendMessage(embed).complete(); Message message = channel.sendMessage(embed).complete();
@ -481,12 +484,17 @@ public class Discord extends FreedomService
String location = "World: " + Objects.requireNonNull(reported.getLocation().getWorld()).getName() + ", X: " + reported.getLocation().getBlockX() + ", Y: " + reported.getLocation().getBlockY() + ", Z: " + reported.getLocation().getBlockZ(); String location = "World: " + Objects.requireNonNull(reported.getLocation().getWorld()).getName() + ", X: " + reported.getLocation().getBlockX() + ", Y: " + reported.getLocation().getBlockY() + ", Z: " + reported.getLocation().getBlockZ();
embedBuilder.addField("Location", location, true); embedBuilder.addField("Location", location, true);
embedBuilder.addField("Game Mode", WordUtils.capitalizeFully(reported.getGameMode().name()), true); embedBuilder.addField("Game Mode", WordUtils.capitalizeFully(reported.getGameMode().name()), true);
if (plugin.esb.isEnabled())
{
com.earth2me.essentials.User user = plugin.esb.getEssentialsUser(reported.getName()); com.earth2me.essentials.User user = plugin.esb.getEssentialsUser(reported.getName());
embedBuilder.addField("God Mode", WordUtils.capitalizeFully(String.valueOf(user.isGodModeEnabled())), true); embedBuilder.addField("God Mode", WordUtils.capitalizeFully(String.valueOf(user.isGodModeEnabled())), true);
if (user.getNickname() != null) if (user.getNickname() != null)
{ {
embedBuilder.addField("Nickname", user.getNickname(), true); embedBuilder.addField("Nickname", user.getNickname(), true);
} }
}
MessageEmbed embed = embedBuilder.build(); MessageEmbed embed = embedBuilder.build();
Message message = channel.sendMessage(embed).complete(); Message message = channel.sendMessage(embed).complete();