From 9d3165694aa48db1d584cb65c21a154c78b1136e Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Fri, 17 Jun 2022 16:04:55 -0500 Subject: [PATCH 01/15] Update version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fd106e42..b426215f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ me.totalfreedom TotalFreedomMod - 2022.02 + 2022.06-RC1 jar From 4d98108a465d7ca364d5c31a710f5544bf2435c0 Mon Sep 17 00:00:00 2001 From: Allink <44676012+allinkdev@users.noreply.github.com> Date: Sun, 11 Sep 2022 12:31:52 +0100 Subject: [PATCH 02/15] Remove uptime command (#250) Codacy is struggling for no reason, merging anyway. --- .../discord/commands/UptimeCommand.java | 79 ------------------- 1 file changed, 79 deletions(-) delete mode 100644 src/main/java/me/totalfreedom/totalfreedommod/discord/commands/UptimeCommand.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/commands/UptimeCommand.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/commands/UptimeCommand.java deleted file mode 100644 index eedd4718..00000000 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/commands/UptimeCommand.java +++ /dev/null @@ -1,79 +0,0 @@ -package me.totalfreedom.totalfreedommod.discord.commands; - -import me.totalfreedom.totalfreedommod.discord.command.DiscordCommandImpl; -import me.totalfreedom.totalfreedommod.util.FLog; -import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.MessageBuilder; -import net.dv8tion.jda.api.entities.Member; - -import java.awt.*; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.Collections; -import java.util.List; - -public class UptimeCommand extends DiscordCommandImpl -{ - @Override - public String getCommandName() - { - return "uptime"; - } - - @Override - public String getDescription() - { - return "Returns the uptime of the host."; - } - - @Override - public String getCategory() - { - return "Server Commands"; - } - - @Override - public List getAliases() - { - return Collections.emptyList(); - } - - @Override - public boolean isAdmin() - { - return false; - } - - @Override - public MessageBuilder execute(Member member, List args) - { - final EmbedBuilder embedBuilder = new EmbedBuilder(); - - try - { - final Process uptimeProcess = Runtime.getRuntime().exec(new String[]{"uptime"}); - BufferedReader input = new BufferedReader(new InputStreamReader(uptimeProcess.getInputStream())); - String line = input.readLine(); - - if (line != null) - { - embedBuilder.setTitle("Host Uptime Information"); - embedBuilder.setDescription(line.trim()); - } - else - { - throw new IllegalStateException("No output from uptime command."); - } - } - catch (Exception e) - { - FLog.warning("Error while executing uptime Discord command"); - e.printStackTrace(); - embedBuilder.setTitle("Command error"); - embedBuilder.setColor(Color.RED); - embedBuilder.setDescription("Something went wrong"); - } - - return new MessageBuilder().setEmbed(embedBuilder.build()); - } -} From 0dd7bc06eba083bf5569703acf9139196c8a9347 Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 11 Sep 2022 06:04:01 -0600 Subject: [PATCH 03/15] FS-449 --- .../totalfreedommod/player/FPlayer.java | 17 ++++++----------- .../totalfreedommod/player/PlayerList.java | 8 ++++---- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java index 002b16f9..ced5a67a 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/player/FPlayer.java @@ -16,6 +16,7 @@ import org.bukkit.scheduler.BukkitTask; import java.util.ArrayList; import java.util.List; +import java.util.UUID; public class FPlayer { @@ -26,7 +27,7 @@ public class FPlayer private final TotalFreedomMod plugin; private final String name; - + private final UUID uuid; private final String ip; // private final FreezeData freezeData = new FreezeData(this); @@ -70,12 +71,13 @@ public class FPlayer public FPlayer(TotalFreedomMod plugin, Player player) { - this(plugin, player.getName(), FUtil.getIp(player)); + this(plugin, player.getUniqueId(), player.getName(), FUtil.getIp(player)); } - private FPlayer(TotalFreedomMod plugin, String name, String ip) + private FPlayer(TotalFreedomMod plugin, UUID uuid, String name, String ip) { this.plugin = plugin; + this.uuid = uuid; this.name = name; this.ip = ip; } @@ -94,14 +96,7 @@ public class FPlayer if (player == null) { - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) - { - if (FUtil.getIp(onlinePlayer).equals(ip)) - { - player = onlinePlayer; - break; - } - } + player = Bukkit.getPlayer(uuid); } return player; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java b/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java index 6cd3ad0b..b04960c2 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/player/PlayerList.java @@ -17,7 +17,7 @@ import org.bukkit.entity.Player; public class PlayerList extends FreedomService { - public final Map playerMap = Maps.newHashMap(); // ip,dataMap + public final Map playerMap = Maps.newHashMap(); // uuid, dataMap public final Map dataMap = Maps.newHashMap(); // uuid, data @Override @@ -107,14 +107,14 @@ public class PlayerList extends FreedomService // May not return null public FPlayer getPlayer(Player player) { - FPlayer tPlayer = playerMap.get(FUtil.getIp(player)); + FPlayer tPlayer = playerMap.get(player.getUniqueId()); if (tPlayer != null) { return tPlayer; } tPlayer = new FPlayer(plugin, player); - playerMap.put(FUtil.getIp(player), tPlayer); + playerMap.put(player.getUniqueId(), tPlayer); return tPlayer; } @@ -233,7 +233,7 @@ public class PlayerList extends FreedomService return player; } - public Map getPlayerMap() + public Map getPlayerMap() { return playerMap; } From c0f3712c8de9c2cfcf4ce5ca9db07e78f5dcfdcd Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 11 Sep 2022 06:35:32 -0600 Subject: [PATCH 04/15] Fixes several bugs caused by any potential issues in TFM's admin loading system --- .../totalfreedom/totalfreedommod/admin/Admin.java | 4 ++-- .../totalfreedommod/admin/AdminList.java | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java b/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java index e90b3c5f..535b5cd3 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java @@ -59,7 +59,7 @@ public class Admin { final StringBuilder output = new StringBuilder(); - output.append("Admin: ").append(getName()).append("\n") + output.append("Admin: ").append(getName() != null ? getName() : getUuid().toString()).append("\n") .append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n") .append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n") .append("- Rank: ").append(rank.getName()).append("\n") @@ -172,7 +172,7 @@ public class Admin setPotionSpy(false); Server server = Bukkit.getServer(); - Player player = server.getPlayer(getName()); + Player player = server.getPlayer(getUuid()); if (player != null) { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java b/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java index 639023b8..8073713c 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/admin/AdminList.java @@ -48,12 +48,18 @@ public class AdminList extends FreedomService try { ResultSet adminSet = plugin.sql.getAdminList(); + while (adminSet.next()) { - while (adminSet.next()) + try { Admin admin = new Admin(adminSet); allAdmins.add(admin); } + catch (Throwable ex) + { + FLog.warning("An error occurred whilst reading the admin entry at row #" + adminSet.getRow()); + FLog.warning(ex); + } } } catch (SQLException e) @@ -245,7 +251,10 @@ public class AdminList extends FreedomService activeAdmins.add(admin); uuidTable.put(admin.getUuid(), admin); - nameTable.put(admin.getName().toLowerCase(), admin); + if (admin.getName() != null) + { + nameTable.put(admin.getName().toLowerCase(), admin); + } for (String ip : admin.getIps()) { From 4564ad04492b2df8dadb3b3055325a7a6cb68074 Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 11 Sep 2022 11:34:16 -0600 Subject: [PATCH 05/15] Fix SAConfig NPE (originally by Allink) --- .../totalfreedom/totalfreedommod/command/Command_saconfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java index 78979d4e..6eb858ec 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java @@ -242,7 +242,6 @@ public class Command_saconfig extends FreedomCommand Player player = getPlayer(args[1]); Admin admin = player != null ? plugin.al.getAdmin(player) : plugin.al.getEntryByName(args[1]); - String adminName = admin.getName(); if (admin == null) { @@ -250,6 +249,8 @@ public class Command_saconfig extends FreedomCommand return true; } + String adminName = admin.getName(); + FUtil.adminAction(sender.getName(), "Removing " + admin.getName() + " from the admin list", true); admin.setActive(false); From 9e1aa5d34e051d255e26a48b1a193fb45fe7b40e Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 11 Sep 2022 11:36:21 -0600 Subject: [PATCH 06/15] Uplifts version to 2022.06-RC2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b426215f..302c8f82 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ me.totalfreedom TotalFreedomMod - 2022.06-RC1 + 2022.06-RC2 jar From 7a724c2f1385b14692b2842fde6ca8564374873f Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 11 Sep 2022 12:12:36 -0600 Subject: [PATCH 07/15] Fixes bug that prevented /saconfig add from working properly This popped up during testing right before RC2 was intended to be cut. --- .../totalfreedommod/command/Command_saconfig.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java index 6eb858ec..ee5c63b5 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_saconfig.java @@ -176,11 +176,10 @@ public class Command_saconfig extends FreedomCommand } // Find the old admin entry - String name = player.getName(); Admin admin = null; for (Admin loopAdmin : plugin.al.getAllAdmins()) { - if (loopAdmin.getName().equalsIgnoreCase(name) || loopAdmin.getIps().contains(FUtil.getIp(player))) + if (loopAdmin.getUuid().equals(player.getUniqueId())) { admin = loopAdmin; break; @@ -189,7 +188,6 @@ public class Command_saconfig extends FreedomCommand if (admin == null) // New admin { - FUtil.adminAction(sender.getName(), "Adding " + player.getName() + " to the admin list", true); admin = new Admin(player); From 26be5d0f4479f84ef2d5b97646c91913f89d2668 Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 11 Sep 2022 12:47:58 -0600 Subject: [PATCH 08/15] Fixes bug where adminchat messages were duplicated when sent from in-game Yet another bug discovered during testing before the release was to be cut --- .../me/totalfreedom/totalfreedommod/discord/Discord.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java index d2b6e909..7ec95ed0 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java @@ -374,12 +374,6 @@ public class Discord extends FreedomService CompletableFuture sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(sanitizedMessage).submit(true); sentMessages.add(sentMessage); } - - if (enabled && !chat_channel_id.isEmpty()) - { - CompletableFuture sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(deformat(message)).submit(true); - sentMessages.add(sentMessage); - } } public String formatBotTag() From 575568cb053fce1186de208defb846196427d9a8 Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 11 Sep 2022 15:33:05 -0600 Subject: [PATCH 09/15] Fixes severe bug where changes to player data wouldn't save --- src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java b/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java index 39bd1223..336c7934 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java @@ -152,7 +152,7 @@ public class SQLite extends FreedomService { try { - Object[] data = {key, player.getName()}; + Object[] data = {key, player.getUuid()}; PreparedStatement statement = connection.prepareStatement(MessageFormat.format("UPDATE players SET {0}=? WHERE uuid=''{1}''", data)); statement = setUnknownType(statement, 1, value); statement.executeUpdate(); From 0cd2886e40e4978b853b5c6d30dc7383c8f07213 Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 11 Sep 2022 16:14:31 -0600 Subject: [PATCH 10/15] Fixes oversight where not having Essentials installed causes Discord reporting to fail --- .../totalfreedommod/discord/Discord.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java index 7ec95ed0..77d1779c 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java @@ -444,13 +444,16 @@ public class Discord extends FreedomService embedBuilder.setDescription(reason); embedBuilder.setFooter("Reported by " + reporter.getName(), "https://minotar.net/helm/" + reporter.getName() + ".png"); embedBuilder.setTimestamp(Instant.from(ZonedDateTime.now())); - 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(); - embedBuilder.addField("Location", location, true); - embedBuilder.addField("God Mode", WordUtils.capitalizeFully(String.valueOf(user.isGodModeEnabled())), true); - if (user.getNickname() != null) + if (plugin.esb.isEnabled()) { - embedBuilder.addField("Nickname", user.getNickname(), true); + 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(); + embedBuilder.addField("Location", location, true); + embedBuilder.addField("God Mode", WordUtils.capitalizeFully(String.valueOf(user.isGodModeEnabled())), true); + if (user.getNickname() != null) + { + embedBuilder.addField("Nickname", user.getNickname(), true); + } } MessageEmbed embed = embedBuilder.build(); 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(); embedBuilder.addField("Location", location, true); embedBuilder.addField("Game Mode", WordUtils.capitalizeFully(reported.getGameMode().name()), true); - com.earth2me.essentials.User user = plugin.esb.getEssentialsUser(reported.getName()); - embedBuilder.addField("God Mode", WordUtils.capitalizeFully(String.valueOf(user.isGodModeEnabled())), true); - if (user.getNickname() != null) + + if (plugin.esb.isEnabled()) { - embedBuilder.addField("Nickname", user.getNickname(), true); + com.earth2me.essentials.User user = plugin.esb.getEssentialsUser(reported.getName()); + embedBuilder.addField("God Mode", WordUtils.capitalizeFully(String.valueOf(user.isGodModeEnabled())), true); + if (user.getNickname() != null) + { + embedBuilder.addField("Nickname", user.getNickname(), true); + } } + MessageEmbed embed = embedBuilder.build(); Message message = channel.sendMessage(embed).complete(); From 42458084d722cd3cb7edfb1627936789d1a30296 Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 11 Sep 2022 16:47:12 -0600 Subject: [PATCH 11/15] Untitled bugfix --- .../me/totalfreedom/totalfreedommod/command/Command_coins.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java index 3d0a812d..f1ffc80b 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_coins.java @@ -112,6 +112,9 @@ public class Command_coins extends FreedomCommand + ChatColor.GOLD + coinsToTransfer + ChatColor.GREEN + " coin" + (coinsToTransfer > 1 ? "s" : "") + " to " + ChatColor.GOLD + target.getName() + ChatColor.GREEN + ".", ChatColor.GREEN); + + plugin.pl.save(playerData); + plugin.pl.save(senderData); } return true; From 1eaaf5fcdb1792324cc1d1386c0123de3cf2f03c Mon Sep 17 00:00:00 2001 From: Video Date: Sun, 11 Sep 2022 22:10:57 -0600 Subject: [PATCH 12/15] Fixes bug where the whitelist wasn't working --- src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java index b1000767..f413a39c 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java @@ -179,7 +179,7 @@ public class LoginProcess extends FreedomService } // Whitelist - if (server.isWhitelistEnforced() && !player.isWhitelisted()) + if (server.hasWhitelist() && !player.isWhitelisted()) { event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server."); } From ebafc1c6691e5d00d1317c3f2372f7ab86a0c2cb Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 12 Sep 2022 22:54:44 +0100 Subject: [PATCH 13/15] Hopefully fixing it this time (#119) This is proving to be more of a PITA than I had expected. --- .github/workflows/downstream.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index b5e72dcc..33365e0b 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -17,10 +17,10 @@ jobs: steps: # Step 1: run a standard checkout action, provided by github - - name: Checkout main + - name: Checkout current development branch uses: actions/checkout@v2 with: - ref: main + ref: development # submodules: 'recursive' ### may be needed in your situation # Step 2: run this sync action - specify the upstream repo, upstream branch to sync with, and target sync branch From ec5aa0304e5223524474cb8f952ddd75c32d3186 Mon Sep 17 00:00:00 2001 From: Video Date: Mon, 12 Sep 2022 21:42:04 -0600 Subject: [PATCH 14/15] Uplifts version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 302c8f82..b08a6445 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ me.totalfreedom TotalFreedomMod - 2022.06-RC2 + 2022.06-RC3 jar From ae5038ef0f18e13b9d5d9e8aec1c09a85ff1a609 Mon Sep 17 00:00:00 2001 From: Video Date: Tue, 13 Sep 2022 21:54:42 -0600 Subject: [PATCH 15/15] Uplifts pom version to release --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b08a6445..a6d8a95e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ me.totalfreedom TotalFreedomMod - 2022.06-RC3 + 2022.06 jar