From 98f4af7fabe5b5e026d75fb3e21870ad98162fb8 Mon Sep 17 00:00:00 2001 From: Seth <13510767+ZeroEpoch1969@users.noreply.github.com> Date: Thu, 9 Jul 2020 22:43:10 -0700 Subject: [PATCH] Hot fixes --- .../command/Command_donator.java | 9 +++++++-- .../command/Command_myinfo.java | 18 ++++++++++++++++++ .../discord/PrivateMessageListener.java | 7 +++++++ .../totalfreedommod/player/PlayerData.java | 9 ++++++--- 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_myinfo.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_donator.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_donator.java index 1c352851..d8a8dda4 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_donator.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_donator.java @@ -8,6 +8,7 @@ import me.totalfreedom.totalfreedommod.player.PlayerData; import me.totalfreedom.totalfreedommod.rank.Rank; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; +import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -49,6 +50,11 @@ public class Command_donator extends FreedomCommand plugin.pl.save(data); } + if (mode) + { + FUtil.bcastMsg(ChatColor.AQUA + name + ChatColor.GREEN + " has donated to the server!"); + } + Player player = getPlayer(name); if (player != null) @@ -72,8 +78,7 @@ public class Command_donator extends FreedomCommand try { - String result = FUtil.postRequestToEndpoint(url, "POST", headers, payload); - msg(result); + FUtil.postRequestToEndpoint(url, "POST", headers, payload); } catch (IOException e) { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myinfo.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myinfo.java new file mode 100644 index 00000000..0bd209ea --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myinfo.java @@ -0,0 +1,18 @@ +package me.totalfreedom.totalfreedommod.command; + +import me.totalfreedom.totalfreedommod.rank.Rank; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Check your personal data", usage = "/") +public class Command_myinfo extends FreedomCommand +{ + @Override + public boolean run(final CommandSender sender, final Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + msg(plugin.pl.getData(playerSender).toString()); + return true; + } +} \ No newline at end of file diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/PrivateMessageListener.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/PrivateMessageListener.java index f627f067..28f2d057 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/PrivateMessageListener.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/PrivateMessageListener.java @@ -1,6 +1,7 @@ package me.totalfreedom.totalfreedommod.discord; import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.player.PlayerData; import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; @@ -23,6 +24,12 @@ public class PrivateMessageListener extends ListenerAdapter player.setDiscordID(event.getMessage().getAuthor().getId()); player.setVerification(true); + Admin admin = TotalFreedomMod.plugin().al.getEntryByName(name); + if (admin != null) + { + Discord.syncRoles(admin, player.getDiscordID()); + } + TotalFreedomMod.plugin().pl.save(player); Discord.LINK_CODES.remove(code); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java b/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java index 30b44617..43963a76 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerData.java @@ -14,6 +14,7 @@ import me.totalfreedom.totalfreedommod.shop.ShopItem; import me.totalfreedom.totalfreedommod.util.FLog; import me.totalfreedom.totalfreedommod.util.FUtil; import org.apache.commons.lang.StringUtils; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; public class PlayerData @@ -61,6 +62,7 @@ public class PlayerData discordID = resultSet.getString("discord_id"); backupCodes.clear(); backupCodes.addAll(FUtil.stringToList(resultSet.getString("backup_codes"))); + donator = resultSet.getBoolean("donator"); masterBuilder = resultSet.getBoolean("master_builder"); verification = resultSet.getBoolean("verification"); rideMode = resultSet.getString("ride_mode"); @@ -95,12 +97,13 @@ public class PlayerData output.append("Player: ").append(name).append("\n") .append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n") .append("- Discord ID: ").append(discordID).append("\n") + .append("- Donator: ").append(donator).append("\n") .append("- Master Builder: ").append(masterBuilder).append("\n") .append("- Has Verification: ").append(verification).append("\n") .append("- Coins: ").append(coins).append("\n") .append("- Total Votes: ").append(totalVotes).append("\n") - .append("- Tag: ").append(tag).append("\n") - .append("- Ride Mode: ").append(rideMode) + .append("- Tag: ").append(FUtil.colorize(tag)).append(ChatColor.GRAY).append("\n") + .append("- Ride Mode: ").append(rideMode).append("\n") .append("- Backup Codes: ").append(backupCodes.size()).append("/10").append("\n"); return output.toString(); @@ -229,7 +232,7 @@ public class PlayerData put("tag", tag); put("discord_id", discordID); put("backup_codes", FUtil.listToString(backupCodes)); - put("donator", masterBuilder); + put("donator", donator); put("master_builder", masterBuilder); put("verification", verification); put("ride_mode", rideMode);