Merge branch 'development' into Elmon11-patch-2

This commit is contained in:
Nathan Curran 2021-04-07 11:52:16 +10:00 committed by GitHub
commit d7e2c0da42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 79 additions and 164 deletions

View File

@ -5,7 +5,7 @@
<groupId>me.totalfreedom</groupId> <groupId>me.totalfreedom</groupId>
<artifactId>TotalFreedomMod</artifactId> <artifactId>TotalFreedomMod</artifactId>
<version>2021.02</version> <version>2021.02-Patch.01-RC01</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>

View File

@ -159,24 +159,20 @@ public class ChatManager extends FreedomService
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true); FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message); plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message);
for (Player player : server.getOnlinePlayers()) server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player ->
{ {
if (plugin.al.isAdmin(player)) Admin admin = plugin.al.getAdmin(player);
{ if (!Strings.isNullOrEmpty(admin.getAcFormat())) {
Admin admin = plugin.al.getAdmin(player); String format = admin.getAcFormat();
if (!Strings.isNullOrEmpty(admin.getAcFormat())) ChatColor color = getColor(display);
{ String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
String format = admin.getAcFormat(); player.sendMessage(FUtil.colorize(msg));
ChatColor color = getColor(display);
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
player.sendMessage(FUtil.colorize(msg));
}
else
{
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
}
} }
} else
{
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
}
});
} }
public void reportAction(Player reporter, Player reported, String report) public void reportAction(Player reporter, Player reported, String report)

View File

@ -25,17 +25,9 @@ public class Admin
private boolean active = true; private boolean active = true;
private Rank rank = Rank.ADMIN; private Rank rank = Rank.ADMIN;
private Date lastLogin = new Date(); private Date lastLogin = new Date();
private Boolean commandSpy = false; private Boolean commandSpy = false;
private Boolean potionSpy = false; private Boolean potionSpy = false;
private String acFormat = null; private String acFormat = null;
private String pteroID = null; private String pteroID = null;
public Admin(Player player) public Admin(Player player)

View File

@ -1,11 +1,7 @@
package me.totalfreedom.totalfreedommod.bridge; package me.totalfreedom.totalfreedommod.bridge;
import java.io.File; import java.io.File;
import java.sql.Connection; import java.sql.*;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@ -228,11 +224,12 @@ public class CoreProtectBridge extends FreedomService
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString(); String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false"; String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
connection = DriverManager.getConnection("jdbc:sql://" + url); connection = DriverManager.getConnection("jdbc:sql://" + url);
final Statement statement = connection.createStatement(); final PreparedStatement statement = connection.prepareStatement("SELECT id FROM co_world WHERE world = ?");
statement.setQueryTimeout(30); statement.setQueryTimeout(30);
// Obtain world ID from CoreProtect database // Obtain world ID from CoreProtect database
ResultSet resultSet = statement.executeQuery("SELECT id FROM co_world WHERE world = '" + world.getName() + "'"); statement.setString(1, world.getName());
ResultSet resultSet = statement.executeQuery();
String worldID = null; String worldID = null;
while (resultSet.next()) while (resultSet.next())
{ {
@ -250,7 +247,10 @@ public class CoreProtectBridge extends FreedomService
// Iterate through each table and delete their data if the world ID matches // Iterate through each table and delete their data if the world ID matches
for (String table : tables) for (String table : tables)
{ {
statement.executeQuery("DELETE FROM " + table + " WHERE wid = " + worldID); final PreparedStatement statement1 = connection.prepareStatement("DELETE FROM ? WHERE wid = ?");
statement1.setString(1, table);
statement1.setString(2, worldID);
statement1.executeQuery();
} }
connection.close(); connection.close();

View File

@ -1,83 +0,0 @@
package me.totalfreedom.totalfreedommod.command;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FSync;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Validates if a given account is premium, or cracked.", usage = "/<command> <player>", aliases = "prem")
public class Command_premium extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
final Player player = getPlayer(args[0]);
final String name;
if (player != null)
{
name = player.getName();
}
else
{
name = args[0];
}
new BukkitRunnable()
{
@Override
public void run()
{
try
{
final URL getUrl = new URL("https://api.ashcon.app/mojang/v2/user/" + name);
final HttpURLConnection urlConnection = (HttpURLConnection)getUrl.openConnection();
urlConnection.setRequestProperty("User-Agent", "");
String message;
/*old code
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())))
//message = (!"PREMIUM".equalsIgnoreCase(in.readLine()) ? ChatColor.RED + "No" : ChatColor.DARK_GREEN + "Yes");
*/
try
{
if (urlConnection.getResponseCode() == 200)
{
message = ChatColor.GREEN + "Yes";
}
else
{
message = ChatColor.RED + "No";
}
FSync.playerMsg(sender, "Player " + name + " is premium: " + message);
}
catch (IOException e)
{
FSync.playerMsg(sender, ChatColor.RED + "There was an error on trying to connect to the API server");
}
}
catch (IOException ex)
{
FLog.severe(ex);
msg("There was an error querying the API server.", ChatColor.RED);
}
}
}.runTaskAsynchronously(plugin);
return true;
}
}

View File

@ -57,7 +57,7 @@ public enum ConfigEntry
SERVER_LOGIN_SUBTITLE(String.class, "server.login_title.subtitle"), SERVER_LOGIN_SUBTITLE(String.class, "server.login_title.subtitle"),
SERVER_OWNERS(List.class, "server.owners"), SERVER_OWNERS(List.class, "server.owners"),
SERVER_EXECUTIVES(List.class, "server.executives"), SERVER_EXECUTIVES(List.class, "server.executives"),
SERVER_ASSTISTANT_EXECUTIVES(List.class, "server.assistant_executives"), SERVER_ASSISTANT_EXECUTIVES(List.class, "server.assistant_executives"),
SERVER_MASTER_BUILDER_MANAGEMENT(List.class, "server.master_builder_management"), SERVER_MASTER_BUILDER_MANAGEMENT(List.class, "server.master_builder_management"),
SERVER_BAN_URL(String.class, "server.ban_url"), SERVER_BAN_URL(String.class, "server.ban_url"),
SERVER_INDEFBAN_URL(String.class, "server.indefban_url"), SERVER_INDEFBAN_URL(String.class, "server.indefban_url"),

View File

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod.discord; package me.totalfreedom.totalfreedommod.discord;
import com.google.common.base.Strings;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.admin.Admin; import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.config.ConfigEntry; import me.totalfreedom.totalfreedommod.config.ConfigEntry;
@ -22,6 +23,7 @@ import org.bukkit.entity.Player;
public class DiscordToAdminChatListener extends ListenerAdapter public class DiscordToAdminChatListener extends ListenerAdapter
{ {
DiscordToMinecraftListener dtml = new DiscordToMinecraftListener(); DiscordToMinecraftListener dtml = new DiscordToMinecraftListener();
public static net.md_5.bungee.api.ChatColor getColor(Displayable display) public static net.md_5.bungee.api.ChatColor getColor(Displayable display)
@ -36,59 +38,62 @@ public class DiscordToAdminChatListener extends ListenerAdapter
{ {
Member member = event.getMember(); Member member = event.getMember();
String tag = dtml.getDisplay(member); String tag = dtml.getDisplay(member);
StringBuilder message = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
Message msg = event.getMessage(); Message msg = event.getMessage();
for (Player player : Bukkit.getOnlinePlayers()) String mediamessage = ChatColor.YELLOW + " [Media]";
{
if (TotalFreedomMod.getPlugin().al.isAdmin(player)) StringBuilder logmessage = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
{ String lm = ChatColor.DARK_RED + member.getEffectiveName() + " "
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(player); + ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY
String format = admin.getAcFormat(); + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContentDisplay());
if (format != null) logmessage.append(lm);
{
Displayable display = TotalFreedomMod.getPlugin().rm.getDisplay(player);
net.md_5.bungee.api.ChatColor color = getColor(display);
String m = format.replace("%name%", member.getEffectiveName())
.replace("%rank%", getDisplay(member))
.replace("%rankcolor%", color.toString())
.replace("%msg%", FUtil.colorize(msg.getContentDisplay()));
message.append(FUtil.colorize(m));
}
else
{
String m = ChatColor.DARK_RED + member.getEffectiveName() + " "
+ ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY
+ ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContentDisplay());
message.append(m);
}
}
}
ComponentBuilder builder = new ComponentBuilder(message.toString());
if (!msg.getAttachments().isEmpty()) if (!msg.getAttachments().isEmpty())
{ {
for (Message.Attachment attachment : msg.getAttachments())
{ logmessage.append(mediamessage); // Actually for logging...
if (attachment.getUrl() == null)
{
continue;
}
TextComponent text = new TextComponent(ChatColor.YELLOW + "[Media]");
text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl()));
builder.append(text);
message.append("[Media]"); // for logging
}
} }
FLog.info(logmessage.toString());
for (Player player : Bukkit.getOnlinePlayers()) Bukkit.getOnlinePlayers().stream().filter(player -> TotalFreedomMod.getPlugin().al.isAdmin(player)).forEach(player ->
{ {
if (TotalFreedomMod.getPlugin().al.isAdmin(player)) StringBuilder message = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
ComponentBuilder builder = new ComponentBuilder(message.toString());
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(player);
String format = admin.getAcFormat();
if (!Strings.isNullOrEmpty(format))
{ {
player.spigot().sendMessage(builder.create()); Displayable display = TotalFreedomMod.getPlugin().rm.getDisplay(player);
net.md_5.bungee.api.ChatColor color = getColor(display);
String m = format.replace("%name%", member.getEffectiveName())
.replace("%rank%", getDisplay(member))
.replace("%rankcolor%", color.toString())
.replace("%msg%", FUtil.colorize(msg.getContentDisplay()));
builder.append(FUtil.colorize(m));
} }
} else
FLog.info(message.toString()); {
String m = ChatColor.DARK_RED + member.getEffectiveName() + " "
+ ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY
+ ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContentDisplay());
builder.append(m);
}
if (!msg.getAttachments().isEmpty())
{
for (Message.Attachment attachment : msg.getAttachments())
{
TextComponent text = new TextComponent(mediamessage);
text.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, attachment.getUrl()));
builder.append(text);
}
}
player.spigot().sendMessage(builder.create());
});
} }
} }
@ -132,4 +137,4 @@ public class DiscordToAdminChatListener extends ListenerAdapter
return Rank.OP.getAbbr(); return Rank.OP.getAbbr();
} }
} }
} }

View File

@ -61,6 +61,11 @@ public class RankManager extends FreedomService
{ {
return Title.EXECUTIVE; return Title.EXECUTIVE;
} }
if (ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getList().contains(player.getName()) && plugin.al.isAdmin(player))
{
return Title.ASSTEXEC;
}
if (plugin.al.isVerifiedAdmin(player)) if (plugin.al.isVerifiedAdmin(player))
{ {
@ -313,4 +318,4 @@ public class RankManager extends FreedomService
team.addPlayer(player); team.addPlayer(player);
} }
} }
} }

View File

@ -139,7 +139,7 @@ public class FUtil
public static boolean isExecutive(String name) public static boolean isExecutive(String name)
{ {
return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name) || ConfigEntry.SERVER_ASSTISTANT_EXECUTIVES.getStringList().contains(name); return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name) || ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getStringList().contains(name);
} }
public static boolean isDeveloper(Player player) public static boolean isDeveloper(Player player)

View File

@ -139,7 +139,7 @@ public class WorldRestrictions extends FreedomService
event.setCancelled(true); event.setCancelled(true);
} }
if (command.equals("coreprotect") || command.equals("core") || command.equals("co")) if (command.equalsIgnoreCase("coreprotect") || command.equalsIgnoreCase("core") || command.equalsIgnoreCase("co"))
{ {
player.sendMessage(ChatColor.RED + "Only " + allowed + " are allowed to use CoreProtect here."); player.sendMessage(ChatColor.RED + "Only " + allowed + " are allowed to use CoreProtect here.");
event.setCancelled(true); event.setCancelled(true);