mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-30 02:05:41 +00:00
Merge branch 'development' into Elmon11-patch-2
This commit is contained in:
commit
d7e2c0da42
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>me.totalfreedom</groupId>
|
||||
<artifactId>TotalFreedomMod</artifactId>
|
||||
<version>2021.02</version>
|
||||
<version>2021.02-Patch.01-RC01</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
|
@ -159,24 +159,20 @@ public class ChatManager extends FreedomService
|
||||
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
|
||||
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()))
|
||||
{
|
||||
String format = admin.getAcFormat();
|
||||
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));
|
||||
}
|
||||
Admin admin = plugin.al.getAdmin(player);
|
||||
if (!Strings.isNullOrEmpty(admin.getAcFormat())) {
|
||||
String format = admin.getAcFormat();
|
||||
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));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void reportAction(Player reporter, Player reported, String report)
|
||||
|
@ -25,17 +25,9 @@ public class Admin
|
||||
private boolean active = true;
|
||||
private Rank rank = Rank.ADMIN;
|
||||
private Date lastLogin = new Date();
|
||||
|
||||
|
||||
private Boolean commandSpy = false;
|
||||
|
||||
|
||||
private Boolean potionSpy = false;
|
||||
|
||||
|
||||
private String acFormat = null;
|
||||
|
||||
|
||||
private String pteroID = null;
|
||||
|
||||
public Admin(Player player)
|
||||
|
@ -1,11 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.bridge;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.*;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -228,11 +224,12 @@ public class CoreProtectBridge extends FreedomService
|
||||
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
|
||||
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
|
||||
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);
|
||||
|
||||
// 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;
|
||||
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
|
||||
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();
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -57,7 +57,7 @@ public enum ConfigEntry
|
||||
SERVER_LOGIN_SUBTITLE(String.class, "server.login_title.subtitle"),
|
||||
SERVER_OWNERS(List.class, "server.owners"),
|
||||
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_BAN_URL(String.class, "server.ban_url"),
|
||||
SERVER_INDEFBAN_URL(String.class, "server.indefban_url"),
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.discord;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
@ -22,6 +23,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class DiscordToAdminChatListener extends ListenerAdapter
|
||||
{
|
||||
|
||||
DiscordToMinecraftListener dtml = new DiscordToMinecraftListener();
|
||||
|
||||
public static net.md_5.bungee.api.ChatColor getColor(Displayable display)
|
||||
@ -36,59 +38,62 @@ public class DiscordToAdminChatListener extends ListenerAdapter
|
||||
{
|
||||
Member member = event.getMember();
|
||||
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();
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (TotalFreedomMod.getPlugin().al.isAdmin(player))
|
||||
{
|
||||
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(player);
|
||||
String format = admin.getAcFormat();
|
||||
if (format != null)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
String mediamessage = ChatColor.YELLOW + " [Media]";
|
||||
|
||||
StringBuilder logmessage = new StringBuilder(ChatColor.DARK_GRAY + "[" + ChatColor.DARK_AQUA + "Discord" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET);
|
||||
String lm = ChatColor.DARK_RED + member.getEffectiveName() + " "
|
||||
+ ChatColor.DARK_GRAY + tag + ChatColor.DARK_GRAY
|
||||
+ ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(msg.getContentDisplay());
|
||||
logmessage.append(lm);
|
||||
|
||||
ComponentBuilder builder = new ComponentBuilder(message.toString());
|
||||
if (!msg.getAttachments().isEmpty())
|
||||
{
|
||||
for (Message.Attachment attachment : msg.getAttachments())
|
||||
{
|
||||
if (attachment.getUrl() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
logmessage.append(mediamessage); // Actually for logging...
|
||||
|
||||
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));
|
||||
|
||||
}
|
||||
}
|
||||
FLog.info(message.toString());
|
||||
else
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,11 @@ public class RankManager extends FreedomService
|
||||
{
|
||||
return Title.EXECUTIVE;
|
||||
}
|
||||
|
||||
if (ConfigEntry.SERVER_ASSISTANT_EXECUTIVES.getList().contains(player.getName()) && plugin.al.isAdmin(player))
|
||||
{
|
||||
return Title.ASSTEXEC;
|
||||
}
|
||||
|
||||
if (plugin.al.isVerifiedAdmin(player))
|
||||
{
|
||||
@ -313,4 +318,4 @@ public class RankManager extends FreedomService
|
||||
team.addPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class FUtil
|
||||
|
||||
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)
|
||||
|
@ -139,7 +139,7 @@ public class WorldRestrictions extends FreedomService
|
||||
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.");
|
||||
event.setCancelled(true);
|
||||
|
Loading…
Reference in New Issue
Block a user