diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml
index ea613917..93fed296 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
- uses: actions/checkout@v3
+ - 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
diff --git a/pom.xml b/pom.xml
index ca46364a..cd579a65 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
me.totalfreedom
TotalFreedomMod
- 2022.02
+ 2022.06
jar
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.");
}
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())
{
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;
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..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);
@@ -242,7 +240,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 +247,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);
diff --git a/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java b/src/main/java/me/totalfreedom/totalfreedommod/discord/Discord.java
index d2b6e909..77d1779c 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()
@@ -450,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();
@@ -487,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();
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());
- }
-}
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;
}
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();