mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Merge pull request #274 from AtlasMediaGroup/main
Merge Main --> Development for 2022.06 Release.
This commit is contained in:
commit
612499ff0a
6
.github/workflows/downstream.yml
vendored
6
.github/workflows/downstream.yml
vendored
@ -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
|
||||
|
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>TotalFreedomMod</artifactId>
|
||||
<version>2022.02</version>
|
||||
<version>2022.06</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
|
@ -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.");
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -48,12 +48,18 @@ public class AdminList extends FreedomService
|
||||
try
|
||||
{
|
||||
ResultSet adminSet = plugin.sql.getAdminList();
|
||||
{
|
||||
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);
|
||||
if (admin.getName() != null)
|
||||
{
|
||||
nameTable.put(admin.getName().toLowerCase(), admin);
|
||||
}
|
||||
|
||||
for (String ip : admin.getIps())
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -374,12 +374,6 @@ public class Discord extends FreedomService
|
||||
CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(sanitizedMessage).submit(true);
|
||||
sentMessages.add(sentMessage);
|
||||
}
|
||||
|
||||
if (enabled && !chat_channel_id.isEmpty())
|
||||
{
|
||||
CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(deformat(message)).submit(true);
|
||||
sentMessages.add(sentMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public String formatBotTag()
|
||||
@ -450,6 +444,8 @@ 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()));
|
||||
if (plugin.esb.isEnabled())
|
||||
{
|
||||
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);
|
||||
@ -458,6 +454,7 @@ public class Discord extends FreedomService
|
||||
{
|
||||
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);
|
||||
|
||||
if (plugin.esb.isEnabled())
|
||||
{
|
||||
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();
|
||||
|
||||
|
@ -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<String> getAliases()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAdmin()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageBuilder execute(Member member, List<String> 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());
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -17,7 +17,7 @@ import org.bukkit.entity.Player;
|
||||
public class PlayerList extends FreedomService
|
||||
{
|
||||
|
||||
public final Map<String, FPlayer> playerMap = Maps.newHashMap(); // ip,dataMap
|
||||
public final Map<UUID, FPlayer> playerMap = Maps.newHashMap(); // uuid, dataMap
|
||||
public final Map<UUID, PlayerData> 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<String, FPlayer> getPlayerMap()
|
||||
public Map<UUID, FPlayer> getPlayerMap()
|
||||
{
|
||||
return playerMap;
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user