mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-05-15 01:51:18 +00:00
morle 😢
This commit is contained in:
parent
c8d686238c
commit
b1882a2a10
|
@ -16,7 +16,7 @@ import me.StevenLawson.TotalFreedomMod.httpd.HTTPDManager;
|
|||
import me.StevenLawson.TotalFreedomMod.listener.*;
|
||||
import me.StevenLawson.TotalFreedomMod.player.HeartBeat;
|
||||
import me.StevenLawson.TotalFreedomMod.player.PlayerList;
|
||||
import me.StevenLawson.TotalFreedomMod.player.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
||||
import me.StevenLawson.TotalFreedomMod.world.AdminWorld;
|
||||
import me.StevenLawson.TotalFreedomMod.world.FlatlandsWorld;
|
||||
|
|
|
@ -2,6 +2,16 @@ package me.StevenLawson.TotalFreedomMod.admin;
|
|||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Sets;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import me.StevenLawson.TotalFreedomMod.Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.commands.Command_logs;
|
||||
|
@ -10,8 +20,8 @@ import me.StevenLawson.TotalFreedomMod.config.ConfigurationEntry;
|
|||
import me.StevenLawson.TotalFreedomMod.config.MainConfig;
|
||||
import me.StevenLawson.TotalFreedomMod.deprecated.twitter.TwitterHandler;
|
||||
import me.StevenLawson.TotalFreedomMod.discord.sender.DiscordCommandSender;
|
||||
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.player.PlayerRank;
|
||||
import me.StevenLawson.TotalFreedomMod.player.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
||||
import me.StevenLawson.TotalFreedomMod.world.AdminWorld;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -20,12 +30,8 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
public class AdminList {
|
||||
|
||||
public class AdminList
|
||||
{
|
||||
public static final Function<Player, Boolean> SUPERADMIN_SERVICE;
|
||||
private static final Map<UUID, Admin> adminList;
|
||||
private static final Set<UUID> superUUIDs;
|
||||
|
@ -35,8 +41,7 @@ public class AdminList
|
|||
private static final Set<String> superIps;
|
||||
private static int cleanThreshold = 24 * 7; // 1 Week in hours
|
||||
|
||||
static
|
||||
{
|
||||
static {
|
||||
adminList = new HashMap<UUID, Admin>();
|
||||
superUUIDs = new HashSet<UUID>();
|
||||
telnetUUIDs = new HashSet<UUID>();
|
||||
|
@ -44,60 +49,48 @@ public class AdminList
|
|||
seniorConsoleNames = new HashSet<String>();
|
||||
superIps = new HashSet<String>();
|
||||
|
||||
SUPERADMIN_SERVICE = new Function<Player, Boolean>()
|
||||
{
|
||||
SUPERADMIN_SERVICE = new Function<Player, Boolean>() {
|
||||
|
||||
@Override
|
||||
public Boolean apply(Player f)
|
||||
{
|
||||
public Boolean apply(Player f) {
|
||||
return isSuperAdmin(f);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private AdminList()
|
||||
{
|
||||
private AdminList() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static Set<UUID> getSuperUUIDs()
|
||||
{
|
||||
public static Set<UUID> getSuperUUIDs() {
|
||||
return Collections.unmodifiableSet(superUUIDs);
|
||||
}
|
||||
|
||||
public static Set<UUID> getTelnetUUIDs()
|
||||
{
|
||||
public static Set<UUID> getTelnetUUIDs() {
|
||||
return Collections.unmodifiableSet(telnetUUIDs);
|
||||
}
|
||||
|
||||
public static Set<UUID> getSeniorUUIDs()
|
||||
{
|
||||
public static Set<UUID> getSeniorUUIDs() {
|
||||
return Collections.unmodifiableSet(seniorUUIDs);
|
||||
}
|
||||
|
||||
public static Set<String> getSeniorConsoleNames()
|
||||
{
|
||||
public static Set<String> getSeniorConsoleNames() {
|
||||
return Collections.unmodifiableSet(seniorConsoleNames);
|
||||
}
|
||||
|
||||
public static Set<String> getSuperadminIps()
|
||||
{
|
||||
public static Set<String> getSuperadminIps() {
|
||||
return Collections.unmodifiableSet(superIps);
|
||||
}
|
||||
|
||||
public static Set<Admin> getAllAdmins()
|
||||
{
|
||||
public static Set<Admin> getAllAdmins() {
|
||||
return Sets.newHashSet(adminList.values());
|
||||
}
|
||||
|
||||
public static Set<String> getSuperNames()
|
||||
{
|
||||
public static Set<String> getSuperNames() {
|
||||
final Set<String> names = new HashSet<String>();
|
||||
|
||||
for (Admin admin : adminList.values())
|
||||
{
|
||||
if (!admin.isActivated())
|
||||
{
|
||||
for (Admin admin : adminList.values()) {
|
||||
if (!admin.isActivated()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -107,14 +100,11 @@ public class AdminList
|
|||
return Collections.unmodifiableSet(names);
|
||||
}
|
||||
|
||||
public static Set<String> getLowercaseSuperNames()
|
||||
{
|
||||
public static Set<String> getLowercaseSuperNames() {
|
||||
final Set<String> names = new HashSet<String>();
|
||||
|
||||
for (Admin admin : adminList.values())
|
||||
{
|
||||
if (!admin.isActivated())
|
||||
{
|
||||
for (Admin admin : adminList.values()) {
|
||||
if (!admin.isActivated()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -124,17 +114,16 @@ public class AdminList
|
|||
return Collections.unmodifiableSet(names);
|
||||
}
|
||||
|
||||
public static void setUuid(Admin admin, UUID oldUuid, UUID newUuid)
|
||||
{
|
||||
if (!adminList.containsKey(oldUuid))
|
||||
{
|
||||
Log.warning("Could not set new UUID for admin " + admin.getLastLoginName() + ", admin is not loaded!");
|
||||
public static void setUuid(Admin admin, UUID oldUuid, UUID newUuid) {
|
||||
if (!adminList.containsKey(oldUuid)) {
|
||||
Log.warning("Could not set new UUID for admin " + admin.getLastLoginName()
|
||||
+ ", admin is not loaded!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldUuid.equals(newUuid))
|
||||
{
|
||||
Log.warning("could not set new UUID for admin " + admin.getLastLoginName() + ", UUIDs match.");
|
||||
if (oldUuid.equals(newUuid)) {
|
||||
Log.warning(
|
||||
"could not set new UUID for admin " + admin.getLastLoginName() + ", UUIDs match.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -153,39 +142,36 @@ public class AdminList
|
|||
|
||||
// Remove old entry
|
||||
adminList.remove(oldUuid);
|
||||
final Configuration config = new Configuration(TotalFreedomMod.plugin, TotalFreedomMod.SUPERADMIN_FILENAME, true);
|
||||
final Configuration config = new Configuration(TotalFreedomMod.plugin,
|
||||
TotalFreedomMod.SUPERADMIN_FILENAME, true);
|
||||
config.load();
|
||||
config.set("admins." + oldUuid, null);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public static void load()
|
||||
{
|
||||
public static void load() {
|
||||
adminList.clear();
|
||||
|
||||
final Configuration config = new Configuration(TotalFreedomMod.plugin, TotalFreedomMod.SUPERADMIN_FILENAME, true);
|
||||
final Configuration config = new Configuration(TotalFreedomMod.plugin,
|
||||
TotalFreedomMod.SUPERADMIN_FILENAME, true);
|
||||
config.load();
|
||||
|
||||
cleanThreshold = config.getInt("clean_threshold_hours", cleanThreshold);
|
||||
|
||||
// Parse old superadmins
|
||||
if (config.isConfigurationSection("superadmins"))
|
||||
{
|
||||
if (config.isConfigurationSection("superadmins")) {
|
||||
parseOldConfig(config);
|
||||
}
|
||||
|
||||
if (!config.isConfigurationSection("admins"))
|
||||
{
|
||||
if (!config.isConfigurationSection("admins")) {
|
||||
Log.warning("Missing admins section in superadmin.yml.");
|
||||
return;
|
||||
}
|
||||
|
||||
final ConfigurationSection section = config.getConfigurationSection("admins");
|
||||
|
||||
for (String uuidString : section.getKeys(false))
|
||||
{
|
||||
if (!Utilities.isUniqueId(uuidString))
|
||||
{
|
||||
for (String uuidString : section.getKeys(false)) {
|
||||
if (!Utilities.isUniqueId(uuidString)) {
|
||||
Log.warning("Invalid Unique ID: " + uuidString + " in superadmin.yml, ignoring");
|
||||
continue;
|
||||
}
|
||||
|
@ -198,21 +184,19 @@ public class AdminList
|
|||
|
||||
updateIndexLists();
|
||||
|
||||
Log.info("Loaded " + adminList.size() + " admins (" + superUUIDs.size() + " active) and " + superIps.size() + " IPs.");
|
||||
Log.info("Loaded " + adminList.size() + " admins (" + superUUIDs.size() + " active) and "
|
||||
+ superIps.size() + " IPs.");
|
||||
}
|
||||
|
||||
public static void updateIndexLists()
|
||||
{
|
||||
public static void updateIndexLists() {
|
||||
superUUIDs.clear();
|
||||
telnetUUIDs.clear();
|
||||
seniorUUIDs.clear();
|
||||
seniorConsoleNames.clear();
|
||||
superIps.clear();
|
||||
|
||||
for (Admin admin : adminList.values())
|
||||
{
|
||||
if (!admin.isActivated())
|
||||
{
|
||||
for (Admin admin : adminList.values()) {
|
||||
if (!admin.isActivated()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -220,23 +204,19 @@ public class AdminList
|
|||
|
||||
superUUIDs.add(uuid);
|
||||
|
||||
for (String ip : admin.getIps())
|
||||
{
|
||||
for (String ip : admin.getIps()) {
|
||||
superIps.add(ip);
|
||||
}
|
||||
|
||||
if (admin.isTelnetAdmin())
|
||||
{
|
||||
if (admin.isTelnetAdmin()) {
|
||||
telnetUUIDs.add(uuid);
|
||||
}
|
||||
|
||||
if (admin.isSeniorAdmin())
|
||||
{
|
||||
if (admin.isSeniorAdmin()) {
|
||||
seniorUUIDs.add(uuid);
|
||||
|
||||
seniorConsoleNames.add(admin.getLastLoginName());
|
||||
for (String alias : admin.getConsoleAliases())
|
||||
{
|
||||
for (String alias : admin.getConsoleAliases()) {
|
||||
seniorConsoleNames.add(alias.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
@ -245,8 +225,7 @@ public class AdminList
|
|||
AdminWorld.getInstance().wipeAccessCache();
|
||||
}
|
||||
|
||||
private static void parseOldConfig(Configuration config)
|
||||
{
|
||||
private static void parseOldConfig(Configuration config) {
|
||||
Log.info("Old superadmin configuration found, parsing...");
|
||||
|
||||
final ConfigurationSection section = config.getConfigurationSection("superadmins");
|
||||
|
@ -254,24 +233,27 @@ public class AdminList
|
|||
int counter = 0;
|
||||
int errors = 0;
|
||||
|
||||
for (String admin : config.getConfigurationSection("superadmins").getKeys(false))
|
||||
{
|
||||
for (String admin : config.getConfigurationSection("superadmins").getKeys(false)) {
|
||||
final UUID uuid = UUIDManager.getUniqueId(admin);
|
||||
|
||||
if (uuid == null)
|
||||
{
|
||||
if (uuid == null) {
|
||||
errors++;
|
||||
Log.warning("Could not convert admin " + admin + ", UUID could not be found!");
|
||||
continue;
|
||||
}
|
||||
|
||||
config.set("admins." + uuid + ".last_login_name", uuid);
|
||||
config.set("admins." + uuid + ".is_activated", section.getBoolean(admin + ".is_activated"));
|
||||
config.set("admins." + uuid + ".is_telnet_admin", section.getBoolean(admin + ".is_telnet_admin"));
|
||||
config.set("admins." + uuid + ".is_senior_admin", section.getBoolean(admin + ".is_senior_admin"));
|
||||
config.set("admins." + uuid + ".is_activated",
|
||||
section.getBoolean(admin + ".is_activated"));
|
||||
config.set("admins." + uuid + ".is_telnet_admin",
|
||||
section.getBoolean(admin + ".is_telnet_admin"));
|
||||
config.set("admins." + uuid + ".is_senior_admin",
|
||||
section.getBoolean(admin + ".is_senior_admin"));
|
||||
config.set("admins." + uuid + ".last_login", section.getString(admin + ".last_login"));
|
||||
config.set("admins." + uuid + ".custom_login_message", section.getString(admin + ".custom_login_message"));
|
||||
config.set("admins." + uuid + ".console_aliases", section.getStringList(admin + ".console_aliases"));
|
||||
config.set("admins." + uuid + ".custom_login_message",
|
||||
section.getString(admin + ".custom_login_message"));
|
||||
config.set("admins." + uuid + ".console_aliases",
|
||||
section.getStringList(admin + ".console_aliases"));
|
||||
config.set("admins." + uuid + ".ips", section.getStringList(admin + ".ips"));
|
||||
|
||||
counter++;
|
||||
|
@ -283,16 +265,15 @@ public class AdminList
|
|||
Log.info("Done! " + counter + " admins parsed, " + errors + " errors");
|
||||
}
|
||||
|
||||
public static void saveAll()
|
||||
{
|
||||
final Configuration config = new Configuration(TotalFreedomMod.plugin, TotalFreedomMod.SUPERADMIN_FILENAME, true);
|
||||
public static void saveAll() {
|
||||
final Configuration config = new Configuration(TotalFreedomMod.plugin,
|
||||
TotalFreedomMod.SUPERADMIN_FILENAME, true);
|
||||
config.load();
|
||||
|
||||
config.set("clean_threshold_hours", cleanThreshold);
|
||||
|
||||
final Iterator<Entry<UUID, Admin>> it = adminList.entrySet().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
while (it.hasNext()) {
|
||||
final Entry<UUID, Admin> pair = it.next();
|
||||
|
||||
final UUID uuid = pair.getKey();
|
||||
|
@ -302,24 +283,27 @@ public class AdminList
|
|||
config.set("admins." + uuid + ".is_activated", superadmin.isActivated());
|
||||
config.set("admins." + uuid + ".is_telnet_admin", superadmin.isTelnetAdmin());
|
||||
config.set("admins." + uuid + ".is_senior_admin", superadmin.isSeniorAdmin());
|
||||
config.set("admins." + uuid + ".last_login", Utilities.dateToString(superadmin.getLastLogin()));
|
||||
config.set("admins." + uuid + ".custom_login_message", superadmin.getCustomLoginMessage());
|
||||
config.set("admins." + uuid + ".console_aliases", Utilities.removeDuplicates(superadmin.getConsoleAliases()));
|
||||
config.set("admins." + uuid + ".last_login",
|
||||
Utilities.dateToString(superadmin.getLastLogin()));
|
||||
config.set("admins." + uuid + ".custom_login_message",
|
||||
superadmin.getCustomLoginMessage());
|
||||
config.set("admins." + uuid + ".console_aliases",
|
||||
Utilities.removeDuplicates(superadmin.getConsoleAliases()));
|
||||
config.set("admins." + uuid + ".ips", Utilities.removeDuplicates(superadmin.getIps()));
|
||||
}
|
||||
|
||||
config.save();
|
||||
}
|
||||
|
||||
public static void save(Admin admin)
|
||||
{
|
||||
if (!adminList.containsValue(admin))
|
||||
{
|
||||
Log.warning("Could not save admin " + admin.getLastLoginName() + ", admin is not loaded!");
|
||||
public static void save(Admin admin) {
|
||||
if (!adminList.containsValue(admin)) {
|
||||
Log.warning(
|
||||
"Could not save admin " + admin.getLastLoginName() + ", admin is not loaded!");
|
||||
return;
|
||||
}
|
||||
|
||||
final Configuration config = new Configuration(TotalFreedomMod.plugin, TotalFreedomMod.SUPERADMIN_FILENAME, true);
|
||||
final Configuration config = new Configuration(TotalFreedomMod.plugin,
|
||||
TotalFreedomMod.SUPERADMIN_FILENAME, true);
|
||||
config.load();
|
||||
|
||||
final UUID uuid = admin.getUniqueId();
|
||||
|
@ -330,62 +314,49 @@ public class AdminList
|
|||
config.set("admins." + uuid + ".is_senior_admin", admin.isSeniorAdmin());
|
||||
config.set("admins." + uuid + ".last_login", Utilities.dateToString(admin.getLastLogin()));
|
||||
config.set("admins." + uuid + ".custom_login_message", admin.getCustomLoginMessage());
|
||||
config.set("admins." + uuid + ".console_aliases", Utilities.removeDuplicates(admin.getConsoleAliases()));
|
||||
config.set("admins." + uuid + ".console_aliases",
|
||||
Utilities.removeDuplicates(admin.getConsoleAliases()));
|
||||
config.set("admins." + uuid + ".ips", Utilities.removeDuplicates(admin.getIps()));
|
||||
|
||||
config.save();
|
||||
}
|
||||
|
||||
public static Admin getEntry(Player player)
|
||||
{
|
||||
public static Admin getEntry(Player player) {
|
||||
return getEntry(UUIDManager.getUniqueId(player));
|
||||
}
|
||||
|
||||
public static Admin getEntry(UUID uuid)
|
||||
{
|
||||
public static Admin getEntry(UUID uuid) {
|
||||
return adminList.get(uuid);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Admin getEntry(String name)
|
||||
{
|
||||
for (UUID uuid : adminList.keySet())
|
||||
{
|
||||
if (adminList.get(uuid).getLastLoginName().equalsIgnoreCase(name))
|
||||
{
|
||||
public static Admin getEntry(String name) {
|
||||
for (UUID uuid : adminList.keySet()) {
|
||||
if (adminList.get(uuid).getLastLoginName().equalsIgnoreCase(name)) {
|
||||
return adminList.get(uuid);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Admin getEntryByIp(String ip)
|
||||
{
|
||||
public static Admin getEntryByIp(String ip) {
|
||||
return getEntryByIp(ip, false);
|
||||
}
|
||||
|
||||
public static Admin getEntryByIp(String needleIp, boolean fuzzy)
|
||||
{
|
||||
public static Admin getEntryByIp(String needleIp, boolean fuzzy) {
|
||||
Iterator<Entry<UUID, Admin>> it = adminList.entrySet().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
while (it.hasNext()) {
|
||||
final Entry<UUID, Admin> pair = it.next();
|
||||
final Admin superadmin = pair.getValue();
|
||||
|
||||
if (fuzzy)
|
||||
{
|
||||
for (String haystackIp : superadmin.getIps())
|
||||
{
|
||||
if (Utilities.fuzzyIpMatch(needleIp, haystackIp, 3))
|
||||
{
|
||||
if (fuzzy) {
|
||||
for (String haystackIp : superadmin.getIps()) {
|
||||
if (Utilities.fuzzyIpMatch(needleIp, haystackIp, 3)) {
|
||||
return superadmin;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (superadmin.getIps().contains(needleIp))
|
||||
{
|
||||
} else {
|
||||
if (superadmin.getIps().contains(needleIp)) {
|
||||
return superadmin;
|
||||
}
|
||||
}
|
||||
|
@ -393,11 +364,9 @@ public class AdminList
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void updateLastLogin(Player player)
|
||||
{
|
||||
public static void updateLastLogin(Player player) {
|
||||
final Admin admin = getEntry(player);
|
||||
if (admin == null)
|
||||
{
|
||||
if (admin == null) {
|
||||
return;
|
||||
}
|
||||
admin.setLastLogin(new Date());
|
||||
|
@ -405,10 +374,8 @@ public class AdminList
|
|||
saveAll();
|
||||
}
|
||||
|
||||
public static boolean isSuperAdminSafe(UUID uuid, String ip)
|
||||
{
|
||||
if (TotalFreedomMod.server.getOnlineMode() && uuid != null)
|
||||
{
|
||||
public static boolean isSuperAdminSafe(UUID uuid, String ip) {
|
||||
if (TotalFreedomMod.server.getOnlineMode() && uuid != null) {
|
||||
return AdminList.getSuperUUIDs().contains(uuid);
|
||||
}
|
||||
|
||||
|
@ -416,105 +383,87 @@ public class AdminList
|
|||
return admin != null && admin.isActivated();
|
||||
}
|
||||
|
||||
public static synchronized boolean isSuperAdminSync(CommandSender sender)
|
||||
{
|
||||
public static synchronized boolean isSuperAdminSync(CommandSender sender) {
|
||||
return isSuperAdmin(sender);
|
||||
}
|
||||
|
||||
public static boolean isSuperAdmin(CommandSender sender)
|
||||
{
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
public static boolean isSuperAdmin(CommandSender sender) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Player player = (Player) sender;
|
||||
|
||||
if (superIps.contains(Utilities.getIp(player)))
|
||||
{
|
||||
if (superIps.contains(Utilities.getIp(player))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return Bukkit.getOnlineMode() && superUUIDs.contains(UUIDManager.getUniqueId(player));
|
||||
}
|
||||
|
||||
public static boolean isTelnetAdmin(CommandSender sender, boolean verifySuperadmin)
|
||||
{
|
||||
if (verifySuperadmin)
|
||||
{
|
||||
if (!isSuperAdmin(sender))
|
||||
{
|
||||
public static boolean isTelnetAdmin(CommandSender sender, boolean verifySuperadmin) {
|
||||
if (verifySuperadmin) {
|
||||
if (!isSuperAdmin(sender)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Admin entry = getEntry((Player) sender);
|
||||
if (entry != null)
|
||||
{
|
||||
if (entry != null) {
|
||||
return entry.isTelnetAdmin();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isSeniorAdmin(CommandSender sender)
|
||||
{
|
||||
public static boolean isSeniorAdmin(CommandSender sender) {
|
||||
return isSeniorAdmin(sender, false);
|
||||
}
|
||||
|
||||
public static boolean isSeniorAdmin(CommandSender sender, boolean verifySuperadmin)
|
||||
{
|
||||
if (verifySuperadmin)
|
||||
{
|
||||
if (!isSuperAdmin(sender))
|
||||
{
|
||||
public static boolean isSeniorAdmin(CommandSender sender, boolean verifySuperadmin) {
|
||||
if (verifySuperadmin) {
|
||||
if (!isSuperAdmin(sender)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
if (!(sender instanceof Player)) {
|
||||
return seniorConsoleNames.contains(sender.getName())
|
||||
|| (MainConfig.getBoolean(ConfigurationEntry.CONSOLE_IS_SENIOR) && sender.getName().equals("CONSOLE"));
|
||||
|| (MainConfig.getBoolean(ConfigurationEntry.CONSOLE_IS_SENIOR) && sender.getName()
|
||||
.equals("CONSOLE"));
|
||||
}
|
||||
|
||||
if(sender instanceof DiscordCommandSender) {
|
||||
if (sender instanceof DiscordCommandSender) {
|
||||
PlayerRank rank = PlayerRank.fromSender(sender);
|
||||
|
||||
if(rank.equals(PlayerRank.SENIOR)) {
|
||||
if (rank.equals(PlayerRank.SENIOR)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
final Admin entry = getEntry((Player) sender);
|
||||
if (entry != null)
|
||||
{
|
||||
if (entry != null) {
|
||||
return entry.isSeniorAdmin();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isIdentityMatched(Player player)
|
||||
{
|
||||
if (!isSuperAdmin(player))
|
||||
{
|
||||
public static boolean isIdentityMatched(Player player) {
|
||||
if (!isSuperAdmin(player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Bukkit.getOnlineMode())
|
||||
{
|
||||
if (Bukkit.getOnlineMode()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Admin entry = getEntry(player);
|
||||
if (entry == null)
|
||||
{
|
||||
if (entry == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -522,40 +471,31 @@ public class AdminList
|
|||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean checkPartialSuperadminIp(String ip, String name)
|
||||
{
|
||||
public static boolean checkPartialSuperadminIp(String ip, String name) {
|
||||
ip = ip.trim();
|
||||
|
||||
if (superIps.contains(ip))
|
||||
{
|
||||
if (superIps.contains(ip)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
String matchIp = null;
|
||||
for (String testIp : superIps)
|
||||
{
|
||||
if (Utilities.fuzzyIpMatch(ip, testIp, 3))
|
||||
{
|
||||
for (String testIp : superIps) {
|
||||
if (Utilities.fuzzyIpMatch(ip, testIp, 3)) {
|
||||
matchIp = testIp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchIp != null)
|
||||
{
|
||||
if (matchIp != null) {
|
||||
final Admin entry = getEntryByIp(matchIp);
|
||||
|
||||
if (entry == null)
|
||||
{
|
||||
if (entry == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (entry.getLastLoginName().equalsIgnoreCase(name))
|
||||
{
|
||||
if (!entry.getIps().contains(ip))
|
||||
{
|
||||
if (entry.getLastLoginName().equalsIgnoreCase(name)) {
|
||||
if (!entry.getIps().contains(ip)) {
|
||||
entry.addIp(ip);
|
||||
}
|
||||
saveAll();
|
||||
|
@ -563,42 +503,34 @@ public class AdminList
|
|||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
} catch (Exception ex) {
|
||||
Log.severe(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isAdminImpostor(Player player)
|
||||
{
|
||||
if (superUUIDs.contains(UUIDManager.getUniqueId(player)))
|
||||
{
|
||||
public static boolean isAdminImpostor(Player player) {
|
||||
if (superUUIDs.contains(UUIDManager.getUniqueId(player))) {
|
||||
return !isSuperAdmin(player);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void addSuperadmin(OfflinePlayer player)
|
||||
{
|
||||
public static void addSuperadmin(OfflinePlayer player) {
|
||||
final UUID uuid = UUIDManager.getUniqueId(player);
|
||||
final String ip = Utilities.getIp(player);
|
||||
final boolean canSuperIp = !MainConfig.getList(ConfigurationEntry.NOADMIN_IPS).contains(ip);
|
||||
|
||||
if (adminList.containsKey(uuid))
|
||||
{
|
||||
if (adminList.containsKey(uuid)) {
|
||||
final Admin superadmin = adminList.get(uuid);
|
||||
superadmin.setActivated(true);
|
||||
|
||||
if (player.isOnline())
|
||||
{
|
||||
if (player.isOnline()) {
|
||||
superadmin.setLastLogin(new Date());
|
||||
|
||||
if (ip != null && canSuperIp)
|
||||
{
|
||||
if (ip != null && canSuperIp) {
|
||||
superadmin.addIp(ip);
|
||||
}
|
||||
}
|
||||
|
@ -608,15 +540,13 @@ public class AdminList
|
|||
return;
|
||||
}
|
||||
|
||||
if (ip == null)
|
||||
{
|
||||
if (ip == null) {
|
||||
Log.severe("Could not add superadmin: " + Utilities.formatPlayer(player));
|
||||
Log.severe("Could not retrieve IP!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canSuperIp)
|
||||
{
|
||||
if (!canSuperIp) {
|
||||
Log.warning("Could not add superadmin: " + Utilities.formatPlayer(player));
|
||||
Log.warning("IP " + ip + " may not be supered.");
|
||||
return;
|
||||
|
@ -638,12 +568,10 @@ public class AdminList
|
|||
updateIndexLists();
|
||||
}
|
||||
|
||||
public static void removeSuperadmin(OfflinePlayer player)
|
||||
{
|
||||
public static void removeSuperadmin(OfflinePlayer player) {
|
||||
final UUID uuid = UUIDManager.getUniqueId(player);
|
||||
|
||||
if (!adminList.containsKey(uuid))
|
||||
{
|
||||
if (!adminList.containsKey(uuid)) {
|
||||
Log.warning("Could not remove admin: " + Utilities.formatPlayer(player));
|
||||
Log.warning("Player is not an admin!");
|
||||
return;
|
||||
|
@ -657,27 +585,25 @@ public class AdminList
|
|||
updateIndexLists();
|
||||
}
|
||||
|
||||
public static void cleanSuperadminList(boolean verbose)
|
||||
{
|
||||
public static void cleanSuperadminList(boolean verbose) {
|
||||
Iterator<Entry<UUID, Admin>> it = adminList.entrySet().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
while (it.hasNext()) {
|
||||
final Entry<UUID, Admin> pair = it.next();
|
||||
final Admin superadmin = pair.getValue();
|
||||
|
||||
if (!superadmin.isActivated() || superadmin.isSeniorAdmin())
|
||||
{
|
||||
if (!superadmin.isActivated() || superadmin.isSeniorAdmin()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final Date lastLogin = superadmin.getLastLogin();
|
||||
final long lastLoginHours = TimeUnit.HOURS.convert(new Date().getTime() - lastLogin.getTime(), TimeUnit.MILLISECONDS);
|
||||
final long lastLoginHours = TimeUnit.HOURS.convert(
|
||||
new Date().getTime() - lastLogin.getTime(), TimeUnit.MILLISECONDS);
|
||||
|
||||
if (lastLoginHours > cleanThreshold)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
Utilities.adminAction("TotalFreedomMod", "Deactivating superadmin " + superadmin.getLastLoginName() + ", inactive for " + lastLoginHours + " hours.", true);
|
||||
if (lastLoginHours > cleanThreshold) {
|
||||
if (verbose) {
|
||||
Utilities.adminAction("TotalFreedomMod",
|
||||
"Deactivating superadmin " + superadmin.getLastLoginName()
|
||||
+ ", inactive for " + lastLoginHours + " hours.", true);
|
||||
}
|
||||
|
||||
superadmin.setActivated(false);
|
||||
|
|
|
@ -5,8 +5,8 @@ import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
|||
import me.StevenLawson.TotalFreedomMod.ban.Ban.BanType;
|
||||
import me.StevenLawson.TotalFreedomMod.config.Configuration;
|
||||
import me.StevenLawson.TotalFreedomMod.config.ConfigurationEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.player.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.player.UUIDManager.TFM_UuidResolver;
|
||||
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager.TFM_UuidResolver;
|
||||
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.commands;
|
|||
|
||||
import me.StevenLawson.TotalFreedomMod.ban.BanManager;
|
||||
import me.StevenLawson.TotalFreedomMod.player.PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.player.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
|
|
|
@ -6,7 +6,7 @@ import me.StevenLawson.TotalFreedomMod.ban.BanManager;
|
|||
import me.StevenLawson.TotalFreedomMod.config.ConfigurationEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.player.Player;
|
||||
import me.StevenLawson.TotalFreedomMod.player.PlayerList;
|
||||
import me.StevenLawson.TotalFreedomMod.player.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
|
|
|
@ -3,7 +3,7 @@ package me.StevenLawson.TotalFreedomMod.commands;
|
|||
import me.StevenLawson.TotalFreedomMod.ban.Ban;
|
||||
import me.StevenLawson.TotalFreedomMod.ban.BanManager;
|
||||
import me.StevenLawson.TotalFreedomMod.bridge.WorldEditBridge;
|
||||
import me.StevenLawson.TotalFreedomMod.player.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
||||
import me.StevenLawson.TotalFreedomMod.world.RollbackManager;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
|
|
@ -14,6 +14,7 @@ public class Command_myadmin extends FreedomCommand {
|
|||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel,
|
||||
String[] args, boolean senderIsConsole) {
|
||||
|
||||
final UUID uuid = sender_p.getUniqueId(); // Get the sender's uuid as a variable.
|
||||
|
||||
if (args.length == 1) {
|
||||
|
|
|
@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.commands;
|
|||
|
||||
import me.StevenLawson.TotalFreedomMod.ban.Ban;
|
||||
import me.StevenLawson.TotalFreedomMod.ban.BanManager;
|
||||
import me.StevenLawson.TotalFreedomMod.player.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
|
|
|
@ -2,7 +2,7 @@ package me.StevenLawson.TotalFreedomMod.commands;
|
|||
|
||||
import me.StevenLawson.TotalFreedomMod.ban.Ban;
|
||||
import me.StevenLawson.TotalFreedomMod.ban.BanManager;
|
||||
import me.StevenLawson.TotalFreedomMod.player.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.commands;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Commands {
|
||||
|
||||
public static void registerCommands(JavaPlugin plugin) {
|
||||
plugin.getCommand("adminmode").setExecutor(new Command_adminmode());
|
||||
plugin.getCommand("adminworld").setExecutor(new Command_adminworld());
|
||||
|
@ -108,5 +109,6 @@ public class Commands {
|
|||
plugin.getCommand("wipeuserdata").setExecutor(new Command_wipeuserdata());
|
||||
plugin.getCommand("whoami").setExecutor(new Command_whoami());
|
||||
plugin.getCommand("resetplayer").setExecutor(new Command_resetplayer());
|
||||
plugin.getCommand("vanish").setExecutor(new Command_vanish());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package me.StevenLawson.TotalFreedomMod.discord.bridge;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
import me.StevenLawson.TotalFreedomMod.Log;
|
||||
import me.StevenLawson.TotalFreedomMod.admin.AdminList;
|
||||
import me.StevenLawson.TotalFreedomMod.config.ConfigurationEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.config.MainConfig;
|
||||
import me.StevenLawson.TotalFreedomMod.discord.command.DiscordCommandManager;
|
||||
import me.StevenLawson.TotalFreedomMod.player.PlayerRank;
|
||||
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
|
@ -21,14 +25,9 @@ import org.javacord.api.entity.message.MessageAuthor;
|
|||
import org.javacord.api.entity.server.Server;
|
||||
import org.javacord.api.entity.user.User;
|
||||
import org.javacord.api.event.message.MessageCreateEvent;
|
||||
import org.javacord.api.event.message.MessageEvent;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DiscordBridge {
|
||||
|
||||
private static DiscordApi DISCORD_API;
|
||||
private static TextChannel CHANNEL;
|
||||
private static TextChannel ADMIN_CHANNEL;
|
||||
|
@ -38,30 +37,36 @@ public class DiscordBridge {
|
|||
boolean isAdmin = false;
|
||||
|
||||
try {
|
||||
isAdmin = message.getChannel().getIdAsString().equalsIgnoreCase(ADMIN_CHANNEL.getIdAsString());
|
||||
} catch (Exception ignored) {}
|
||||
isAdmin = message.getChannel().getIdAsString()
|
||||
.equalsIgnoreCase(ADMIN_CHANNEL.getIdAsString());
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
String content = message.getMessage().getReadableContent();
|
||||
String prefix = MainConfig.getString(ConfigurationEntry.DISCORD_PREFIX);
|
||||
MessageAuthor author = message.getMessage().getAuthor();
|
||||
|
||||
if (author.isBotUser() || !message.isServerMessage()) return;
|
||||
if (author.isBotUser() || !message.isServerMessage()) {
|
||||
return;
|
||||
}
|
||||
Optional<Server> server = message.getServer();
|
||||
Optional<User> user = author.asUser();
|
||||
|
||||
if(prefix == null) {
|
||||
if (prefix == null) {
|
||||
Log.severe("Bot prefix does not exist. Stopping bot...");
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!server.isPresent()) {
|
||||
Log.warning("Discord server wasn't present in message, this may be a sign you've not properly configured the intents for your bot.");
|
||||
if (!server.isPresent()) {
|
||||
Log.warning(
|
||||
"Discord server wasn't present in message, this may be a sign you've not properly configured the intents for your bot.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!user.isPresent()) {
|
||||
Log.warning("Unable to get user of message author. This may be a sign you've not properly configured the intents for your bot.");
|
||||
if (!user.isPresent()) {
|
||||
Log.warning(
|
||||
"Unable to get user of message author. This may be a sign you've not properly configured the intents for your bot.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -71,27 +76,31 @@ public class DiscordBridge {
|
|||
Optional<Message> referenced = message.getMessage().getReferencedMessage();
|
||||
|
||||
String reply = "";
|
||||
if(referenced.isPresent()) {
|
||||
if (referenced.isPresent()) {
|
||||
Message replyingTo = referenced.get();
|
||||
reply = String.format(ChatColor.GRAY + "┌ " + ChatColor.YELLOW + "%s" + ChatColor.GRAY + " %s\n" + ChatColor.WHITE, replyingTo.getAuthor().getDiscriminatedName(), replyingTo.getReadableContent());
|
||||
reply = String.format(
|
||||
ChatColor.GRAY + "┌ " + ChatColor.YELLOW + "%s" + ChatColor.GRAY + " %s\n"
|
||||
+ ChatColor.WHITE, replyingTo.getAuthor().getDiscriminatedName(),
|
||||
replyingTo.getReadableContent());
|
||||
}
|
||||
|
||||
String format = MainConfig.getString((isAdmin) ? ConfigurationEntry.DISCORD_ADMIN_FORMAT : ConfigurationEntry.DISCORD_FORMAT);
|
||||
String format = MainConfig.getString(
|
||||
(isAdmin) ? ConfigurationEntry.DISCORD_ADMIN_FORMAT : ConfigurationEntry.DISCORD_FORMAT);
|
||||
format = format.replace("{TAG}", author.getDiscriminatedName());
|
||||
format = format.replace("{USERNAME}", author.getName());
|
||||
BaseComponent[] components = TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', String.format(format, content)));
|
||||
BaseComponent[] components = TextComponent.fromLegacyText(
|
||||
ChatColor.translateAlternateColorCodes('&', String.format(format, content)));
|
||||
TextComponent component = new TextComponent(reply);
|
||||
|
||||
for (BaseComponent baseComponent : components) {
|
||||
component.addExtra(baseComponent);
|
||||
}
|
||||
component.addExtra(Utilities.fromBaseComponents(components));
|
||||
|
||||
if(message.getMessageAttachments().size() > 0) {
|
||||
if (message.getMessageAttachments().size() > 0) {
|
||||
int i = 0;
|
||||
for (MessageAttachment messageAttachment : message.getMessageAttachments()) {
|
||||
String url = messageAttachment.getProxyUrl().toString();
|
||||
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, url);
|
||||
TextComponent warningComponent = new TextComponent("WARNING: By clicking on this text, your client will open:\n\n");
|
||||
TextComponent warningComponent = new TextComponent(
|
||||
"WARNING: By clicking on this text, your client will open:\n\n");
|
||||
warningComponent.setColor(net.md_5.bungee.api.ChatColor.RED);
|
||||
warningComponent.setBold(true);
|
||||
TextComponent urlComponent = new TextComponent(url);
|
||||
|
@ -99,8 +108,10 @@ public class DiscordBridge {
|
|||
urlComponent.setUnderlined(true);
|
||||
urlComponent.setBold(false);
|
||||
warningComponent.addExtra(urlComponent);
|
||||
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new BaseComponent[]{warningComponent});
|
||||
TextComponent mediaComponent = new TextComponent((i == 0 && content.isEmpty()) ? "[Media]" : " [Media]");
|
||||
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new BaseComponent[]{warningComponent});
|
||||
TextComponent mediaComponent = new TextComponent(
|
||||
(i == 0 && content.isEmpty()) ? "[Media]" : " [Media]");
|
||||
mediaComponent.setColor(net.md_5.bungee.api.ChatColor.YELLOW);
|
||||
mediaComponent.setClickEvent(clickEvent);
|
||||
mediaComponent.setHoverEvent(hoverEvent);
|
||||
|
@ -109,11 +120,9 @@ public class DiscordBridge {
|
|||
}
|
||||
}
|
||||
|
||||
if(isAdmin) {
|
||||
for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (AdminList.isSuperAdmin(player))
|
||||
{
|
||||
if (isAdmin) {
|
||||
for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (AdminList.isSuperAdmin(player)) {
|
||||
player.spigot().sendMessage(component);
|
||||
}
|
||||
}
|
||||
|
@ -136,8 +145,10 @@ public class DiscordBridge {
|
|||
.login()
|
||||
.join();
|
||||
|
||||
Optional<TextChannel> channelFuture = DISCORD_API.getTextChannelById(MainConfig.getString(ConfigurationEntry.DISCORD_CHANNEL));
|
||||
Optional<TextChannel> adminChannelFuture = DISCORD_API.getTextChannelById(MainConfig.getString(ConfigurationEntry.DISCORD_ADMIN_CHANNEL));
|
||||
Optional<TextChannel> channelFuture = DISCORD_API.getTextChannelById(
|
||||
MainConfig.getString(ConfigurationEntry.DISCORD_CHANNEL));
|
||||
Optional<TextChannel> adminChannelFuture = DISCORD_API.getTextChannelById(
|
||||
MainConfig.getString(ConfigurationEntry.DISCORD_ADMIN_CHANNEL));
|
||||
|
||||
if (!channelFuture.isPresent()) {
|
||||
Log.warning("TFM 4.3 Reloaded could not find your channel, stopping!");
|
||||
|
@ -155,9 +166,11 @@ public class DiscordBridge {
|
|||
ADMIN_CHANNEL.addMessageCreateListener(DiscordBridge::onMessageCreateEvent);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.warning("Uh oh! It looks like TFM 4.3 Reloaded Discord couldn't start! Please check you have defined the bot's token & channel and also given it the correct permissions! (Read Messages and Send Messages)");
|
||||
Log.warning(
|
||||
"Uh oh! It looks like TFM 4.3 Reloaded Discord couldn't start! Please check you have defined the bot's token & channel and also given it the correct permissions! (Read Messages and Send Messages)");
|
||||
Log.warning("If you've already set that up however, you may to read the exception below.");
|
||||
Log.warning("If this is a bug with TFM 4.3 Reloaded, please report it at https://github.com/TheDeus-Group/TFM-4.3-Reloaded/issues or https://code.cat.casa/TheDeus-Group/TFM-4.3-Reloaded/issues");
|
||||
Log.warning(
|
||||
"If this is a bug with TFM 4.3 Reloaded, please report it at https://github.com/TheDeus-Group/TFM-4.3-Reloaded/issues or https://code.cat.casa/TheDeus-Group/TFM-4.3-Reloaded/issues");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
@ -183,7 +196,9 @@ public class DiscordBridge {
|
|||
}
|
||||
|
||||
public static void transmitMessage(String message, boolean disconnectAfterwards) {
|
||||
if (CHANNEL == null) return;
|
||||
if (CHANNEL == null) {
|
||||
return;
|
||||
}
|
||||
if (!disconnectAfterwards) {
|
||||
CHANNEL.sendMessage(sanitizeMessage(message));
|
||||
} else {
|
||||
|
@ -211,7 +226,9 @@ public class DiscordBridge {
|
|||
}
|
||||
|
||||
public static void transmitAdminMessage(String message, boolean disconnectAfterwards) {
|
||||
if (ADMIN_CHANNEL == null) return;
|
||||
if (ADMIN_CHANNEL == null) {
|
||||
return;
|
||||
}
|
||||
if (!disconnectAfterwards) {
|
||||
ADMIN_CHANNEL.sendMessage(sanitizeMessage(message));
|
||||
} else {
|
||||
|
@ -234,8 +251,7 @@ public class DiscordBridge {
|
|||
Log.info("TFM 4.3 Reloaded Discord stopped.");
|
||||
}
|
||||
|
||||
public static String fullySanitizeDiscordMessage(String message)
|
||||
{
|
||||
public static String fullySanitizeDiscordMessage(String message) {
|
||||
String partiallySanitized = sanitizeMessage(message);
|
||||
return partiallySanitized.replaceAll("([`_~*|\\\\])", "\\\\$1");
|
||||
}
|
||||
|
|
|
@ -80,7 +80,9 @@ public class PlayerListener implements Listener {
|
|||
"I love FreedomForever!", "I'm here to collect my cupcake.", "Do you have any cupcakes?",
|
||||
"I like pineapple pizza.", "Do you have any pineapple pizza?",
|
||||
"I dislike Cherry Pepsi Max.",
|
||||
"Guys, did you know my father is getting milk? He hasn't been back for hours, I'm worried...");
|
||||
"Guys, did you know my father is getting milk? He hasn't been back for hours, I'm worried...",
|
||||
"My wife's boyfriend is a nice guy.", "My wife's boyfriend got me a new Switch!",
|
||||
"My wife's boyfriend got me a new PS5!");
|
||||
public static final int MSG_PER_HEARTBEAT = 10;
|
||||
public static final int DEFAULT_PORT = 25565;
|
||||
public static final int MAX_XY_COORD = 30000000;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
package me.StevenLawson.TotalFreedomMod.player;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.admin.AdminList;
|
||||
import me.StevenLawson.TotalFreedomMod.bridge.EssentialsBridge;
|
||||
import me.StevenLawson.TotalFreedomMod.commands.AdminLevel;
|
||||
import me.StevenLawson.TotalFreedomMod.config.ConfigurationEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Arrow;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.google.common.collect.Sets;
|
|||
import me.StevenLawson.TotalFreedomMod.Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.config.Configuration;
|
||||
import me.StevenLawson.TotalFreedomMod.manager.UUIDManager;
|
||||
import me.StevenLawson.TotalFreedomMod.util.Utilities;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue