mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-12-22 22:14:57 +00:00
morle 😢
This commit is contained in:
parent
c8d686238c
commit
b1882a2a10
15 changed files with 1922 additions and 2081 deletions
|
@ -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;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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,110 +3,112 @@ 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());
|
||||
plugin.getCommand("blockcmd").setExecutor(new Command_blockcmd());
|
||||
plugin.getCommand("cage").setExecutor(new Command_cage());
|
||||
plugin.getCommand("cake").setExecutor(new Command_cake());
|
||||
plugin.getCommand("cartsit").setExecutor(new Command_cartsit());
|
||||
plugin.getCommand("cbtool").setExecutor(new Command_cbtool());
|
||||
plugin.getCommand("cmdlist").setExecutor(new Command_cmdlist());
|
||||
plugin.getCommand("cmdspy").setExecutor(new Command_cmdspy());
|
||||
plugin.getCommand("colorme").setExecutor(new Command_colorme());
|
||||
plugin.getCommand("creative").setExecutor(new Command_creative());
|
||||
plugin.getCommand("csay").setExecutor(new Command_csay());
|
||||
plugin.getCommand("deafen").setExecutor(new Command_deafen());
|
||||
plugin.getCommand("debug").setExecutor(new Command_debug());
|
||||
plugin.getCommand("denick").setExecutor(new Command_denick());
|
||||
plugin.getCommand("deop").setExecutor(new Command_deop());
|
||||
plugin.getCommand("deopall").setExecutor(new Command_deopall());
|
||||
plugin.getCommand("dispfill").setExecutor(new Command_dispfill());
|
||||
plugin.getCommand("doom").setExecutor(new Command_doom());
|
||||
plugin.getCommand("enchant").setExecutor(new Command_enchant());
|
||||
plugin.getCommand("ender").setExecutor(new Command_ender());
|
||||
plugin.getCommand("expel").setExecutor(new Command_expel());
|
||||
plugin.getCommand("findip").setExecutor(new Command_findip());
|
||||
plugin.getCommand("flatlands").setExecutor(new Command_flatlands());
|
||||
plugin.getCommand("fr").setExecutor(new Command_fr());
|
||||
plugin.getCommand("fuckoff").setExecutor(new Command_fuckoff());
|
||||
plugin.getCommand("gadmin").setExecutor(new Command_gadmin());
|
||||
plugin.getCommand("gcmd").setExecutor(new Command_gcmd());
|
||||
plugin.getCommand("glist").setExecutor(new Command_glist());
|
||||
plugin.getCommand("gtfo").setExecutor(new Command_gtfo());
|
||||
plugin.getCommand("halt").setExecutor(new Command_halt());
|
||||
plugin.getCommand("health").setExecutor(new Command_health());
|
||||
plugin.getCommand("invis").setExecutor(new Command_invis());
|
||||
plugin.getCommand("jumppads").setExecutor(new Command_jumppads());
|
||||
plugin.getCommand("kicknoob").setExecutor(new Command_kicknoob());
|
||||
plugin.getCommand("landmine").setExecutor(new Command_landmine());
|
||||
plugin.getCommand("lastcmd").setExecutor(new Command_lastcmd());
|
||||
plugin.getCommand("list").setExecutor(new Command_list());
|
||||
plugin.getCommand("localspawn").setExecutor(new Command_localspawn());
|
||||
plugin.getCommand("lockup").setExecutor(new Command_lockup());
|
||||
plugin.getCommand("logs").setExecutor(new Command_logs());
|
||||
plugin.getCommand("moblimiter").setExecutor(new Command_moblimiter());
|
||||
plugin.getCommand("mp").setExecutor(new Command_mp());
|
||||
plugin.getCommand("mp44").setExecutor(new Command_mp44());
|
||||
plugin.getCommand("myadmin").setExecutor(new Command_myadmin());
|
||||
plugin.getCommand("nether").setExecutor(new Command_nether());
|
||||
plugin.getCommand("nf").setExecutor(new Command_nf());
|
||||
plugin.getCommand("nickclean").setExecutor(new Command_nickclean());
|
||||
plugin.getCommand("nicknyan").setExecutor(new Command_nicknyan());
|
||||
plugin.getCommand("o").setExecutor(new Command_o());
|
||||
plugin.getCommand("onlinemode").setExecutor(new Command_onlinemode());
|
||||
plugin.getCommand("op").setExecutor(new Command_op());
|
||||
plugin.getCommand("opall").setExecutor(new Command_opall());
|
||||
plugin.getCommand("opme").setExecutor(new Command_opme());
|
||||
plugin.getCommand("ops").setExecutor(new Command_ops());
|
||||
plugin.getCommand("orbit").setExecutor(new Command_orbit());
|
||||
plugin.getCommand("overlord").setExecutor(new Command_overlord());
|
||||
plugin.getCommand("permban").setExecutor(new Command_permban());
|
||||
plugin.getCommand("plugincontrol").setExecutor(new Command_plugincontrol());
|
||||
plugin.getCommand("potion").setExecutor(new Command_potion());
|
||||
plugin.getCommand("premium").setExecutor(new Command_premium());
|
||||
plugin.getCommand("protectarea").setExecutor(new Command_protectarea());
|
||||
plugin.getCommand("purgeall").setExecutor(new Command_purgeall());
|
||||
plugin.getCommand("qdeop").setExecutor(new Command_qdeop());
|
||||
plugin.getCommand("qop").setExecutor(new Command_qop());
|
||||
plugin.getCommand("radar").setExecutor(new Command_radar());
|
||||
plugin.getCommand("rank").setExecutor(new Command_rank());
|
||||
plugin.getCommand("rawsay").setExecutor(new Command_rawsay());
|
||||
plugin.getCommand("rd").setExecutor(new Command_rd());
|
||||
plugin.getCommand("report").setExecutor(new Command_report());
|
||||
plugin.getCommand("ro").setExecutor(new Command_ro());
|
||||
plugin.getCommand("rollback").setExecutor(new Command_rollback());
|
||||
plugin.getCommand("saconfig").setExecutor(new Command_saconfig());
|
||||
plugin.getCommand("say").setExecutor(new Command_say());
|
||||
plugin.getCommand("setl").setExecutor(new Command_setl());
|
||||
plugin.getCommand("setlevel").setExecutor(new Command_setlevel());
|
||||
plugin.getCommand("setlever").setExecutor(new Command_setlever());
|
||||
plugin.getCommand("setspawnworld").setExecutor(new Command_setspawnworld());
|
||||
plugin.getCommand("smite").setExecutor(new Command_smite());
|
||||
plugin.getCommand("spectator").setExecutor(new Command_spectator());
|
||||
plugin.getCommand("status").setExecutor(new Command_status());
|
||||
plugin.getCommand("stfu").setExecutor(new Command_stfu());
|
||||
plugin.getCommand("stop").setExecutor(new Command_stop());
|
||||
plugin.getCommand("survival").setExecutor(new Command_survival());
|
||||
plugin.getCommand("tag").setExecutor(new Command_tag());
|
||||
plugin.getCommand("tagnyan").setExecutor(new Command_tagnyan());
|
||||
plugin.getCommand("tban").setExecutor(new Command_tban());
|
||||
plugin.getCommand("tempban").setExecutor(new Command_tempban());
|
||||
plugin.getCommand("tfbanlist").setExecutor(new Command_tfbanlist());
|
||||
plugin.getCommand("tfipbanlist").setExecutor(new Command_tfipbanlist());
|
||||
plugin.getCommand("tfm").setExecutor(new Command_tfm());
|
||||
plugin.getCommand("toggle").setExecutor(new Command_toggle());
|
||||
plugin.getCommand("tossmob").setExecutor(new Command_tossmob());
|
||||
plugin.getCommand("trail").setExecutor(new Command_trail());
|
||||
plugin.getCommand("updatetfm").setExecutor(new Command_updatetfm());
|
||||
plugin.getCommand("uuid").setExecutor(new Command_uuid());
|
||||
plugin.getCommand("warn").setExecutor(new Command_warn());
|
||||
plugin.getCommand("whitelist").setExecutor(new Command_whitelist());
|
||||
plugin.getCommand("whohas").setExecutor(new Command_whohas());
|
||||
plugin.getCommand("wildcard").setExecutor(new Command_wildcard());
|
||||
plugin.getCommand("wipeflatlands").setExecutor(new Command_wipeflatlands());
|
||||
plugin.getCommand("wipeuserdata").setExecutor(new Command_wipeuserdata());
|
||||
plugin.getCommand("whoami").setExecutor(new Command_whoami());
|
||||
plugin.getCommand("resetplayer").setExecutor(new Command_resetplayer());
|
||||
}
|
||||
|
||||
public static void registerCommands(JavaPlugin plugin) {
|
||||
plugin.getCommand("adminmode").setExecutor(new Command_adminmode());
|
||||
plugin.getCommand("adminworld").setExecutor(new Command_adminworld());
|
||||
plugin.getCommand("blockcmd").setExecutor(new Command_blockcmd());
|
||||
plugin.getCommand("cage").setExecutor(new Command_cage());
|
||||
plugin.getCommand("cake").setExecutor(new Command_cake());
|
||||
plugin.getCommand("cartsit").setExecutor(new Command_cartsit());
|
||||
plugin.getCommand("cbtool").setExecutor(new Command_cbtool());
|
||||
plugin.getCommand("cmdlist").setExecutor(new Command_cmdlist());
|
||||
plugin.getCommand("cmdspy").setExecutor(new Command_cmdspy());
|
||||
plugin.getCommand("colorme").setExecutor(new Command_colorme());
|
||||
plugin.getCommand("creative").setExecutor(new Command_creative());
|
||||
plugin.getCommand("csay").setExecutor(new Command_csay());
|
||||
plugin.getCommand("deafen").setExecutor(new Command_deafen());
|
||||
plugin.getCommand("debug").setExecutor(new Command_debug());
|
||||
plugin.getCommand("denick").setExecutor(new Command_denick());
|
||||
plugin.getCommand("deop").setExecutor(new Command_deop());
|
||||
plugin.getCommand("deopall").setExecutor(new Command_deopall());
|
||||
plugin.getCommand("dispfill").setExecutor(new Command_dispfill());
|
||||
plugin.getCommand("doom").setExecutor(new Command_doom());
|
||||
plugin.getCommand("enchant").setExecutor(new Command_enchant());
|
||||
plugin.getCommand("ender").setExecutor(new Command_ender());
|
||||
plugin.getCommand("expel").setExecutor(new Command_expel());
|
||||
plugin.getCommand("findip").setExecutor(new Command_findip());
|
||||
plugin.getCommand("flatlands").setExecutor(new Command_flatlands());
|
||||
plugin.getCommand("fr").setExecutor(new Command_fr());
|
||||
plugin.getCommand("fuckoff").setExecutor(new Command_fuckoff());
|
||||
plugin.getCommand("gadmin").setExecutor(new Command_gadmin());
|
||||
plugin.getCommand("gcmd").setExecutor(new Command_gcmd());
|
||||
plugin.getCommand("glist").setExecutor(new Command_glist());
|
||||
plugin.getCommand("gtfo").setExecutor(new Command_gtfo());
|
||||
plugin.getCommand("halt").setExecutor(new Command_halt());
|
||||
plugin.getCommand("health").setExecutor(new Command_health());
|
||||
plugin.getCommand("invis").setExecutor(new Command_invis());
|
||||
plugin.getCommand("jumppads").setExecutor(new Command_jumppads());
|
||||
plugin.getCommand("kicknoob").setExecutor(new Command_kicknoob());
|
||||
plugin.getCommand("landmine").setExecutor(new Command_landmine());
|
||||
plugin.getCommand("lastcmd").setExecutor(new Command_lastcmd());
|
||||
plugin.getCommand("list").setExecutor(new Command_list());
|
||||
plugin.getCommand("localspawn").setExecutor(new Command_localspawn());
|
||||
plugin.getCommand("lockup").setExecutor(new Command_lockup());
|
||||
plugin.getCommand("logs").setExecutor(new Command_logs());
|
||||
plugin.getCommand("moblimiter").setExecutor(new Command_moblimiter());
|
||||
plugin.getCommand("mp").setExecutor(new Command_mp());
|
||||
plugin.getCommand("mp44").setExecutor(new Command_mp44());
|
||||
plugin.getCommand("myadmin").setExecutor(new Command_myadmin());
|
||||
plugin.getCommand("nether").setExecutor(new Command_nether());
|
||||
plugin.getCommand("nf").setExecutor(new Command_nf());
|
||||
plugin.getCommand("nickclean").setExecutor(new Command_nickclean());
|
||||
plugin.getCommand("nicknyan").setExecutor(new Command_nicknyan());
|
||||
plugin.getCommand("o").setExecutor(new Command_o());
|
||||
plugin.getCommand("onlinemode").setExecutor(new Command_onlinemode());
|
||||
plugin.getCommand("op").setExecutor(new Command_op());
|
||||
plugin.getCommand("opall").setExecutor(new Command_opall());
|
||||
plugin.getCommand("opme").setExecutor(new Command_opme());
|
||||
plugin.getCommand("ops").setExecutor(new Command_ops());
|
||||
plugin.getCommand("orbit").setExecutor(new Command_orbit());
|
||||
plugin.getCommand("overlord").setExecutor(new Command_overlord());
|
||||
plugin.getCommand("permban").setExecutor(new Command_permban());
|
||||
plugin.getCommand("plugincontrol").setExecutor(new Command_plugincontrol());
|
||||
plugin.getCommand("potion").setExecutor(new Command_potion());
|
||||
plugin.getCommand("premium").setExecutor(new Command_premium());
|
||||
plugin.getCommand("protectarea").setExecutor(new Command_protectarea());
|
||||
plugin.getCommand("purgeall").setExecutor(new Command_purgeall());
|
||||
plugin.getCommand("qdeop").setExecutor(new Command_qdeop());
|
||||
plugin.getCommand("qop").setExecutor(new Command_qop());
|
||||
plugin.getCommand("radar").setExecutor(new Command_radar());
|
||||
plugin.getCommand("rank").setExecutor(new Command_rank());
|
||||
plugin.getCommand("rawsay").setExecutor(new Command_rawsay());
|
||||
plugin.getCommand("rd").setExecutor(new Command_rd());
|
||||
plugin.getCommand("report").setExecutor(new Command_report());
|
||||
plugin.getCommand("ro").setExecutor(new Command_ro());
|
||||
plugin.getCommand("rollback").setExecutor(new Command_rollback());
|
||||
plugin.getCommand("saconfig").setExecutor(new Command_saconfig());
|
||||
plugin.getCommand("say").setExecutor(new Command_say());
|
||||
plugin.getCommand("setl").setExecutor(new Command_setl());
|
||||
plugin.getCommand("setlevel").setExecutor(new Command_setlevel());
|
||||
plugin.getCommand("setlever").setExecutor(new Command_setlever());
|
||||
plugin.getCommand("setspawnworld").setExecutor(new Command_setspawnworld());
|
||||
plugin.getCommand("smite").setExecutor(new Command_smite());
|
||||
plugin.getCommand("spectator").setExecutor(new Command_spectator());
|
||||
plugin.getCommand("status").setExecutor(new Command_status());
|
||||
plugin.getCommand("stfu").setExecutor(new Command_stfu());
|
||||
plugin.getCommand("stop").setExecutor(new Command_stop());
|
||||
plugin.getCommand("survival").setExecutor(new Command_survival());
|
||||
plugin.getCommand("tag").setExecutor(new Command_tag());
|
||||
plugin.getCommand("tagnyan").setExecutor(new Command_tagnyan());
|
||||
plugin.getCommand("tban").setExecutor(new Command_tban());
|
||||
plugin.getCommand("tempban").setExecutor(new Command_tempban());
|
||||
plugin.getCommand("tfbanlist").setExecutor(new Command_tfbanlist());
|
||||
plugin.getCommand("tfipbanlist").setExecutor(new Command_tfipbanlist());
|
||||
plugin.getCommand("tfm").setExecutor(new Command_tfm());
|
||||
plugin.getCommand("toggle").setExecutor(new Command_toggle());
|
||||
plugin.getCommand("tossmob").setExecutor(new Command_tossmob());
|
||||
plugin.getCommand("trail").setExecutor(new Command_trail());
|
||||
plugin.getCommand("updatetfm").setExecutor(new Command_updatetfm());
|
||||
plugin.getCommand("uuid").setExecutor(new Command_uuid());
|
||||
plugin.getCommand("warn").setExecutor(new Command_warn());
|
||||
plugin.getCommand("whitelist").setExecutor(new Command_whitelist());
|
||||
plugin.getCommand("whohas").setExecutor(new Command_whohas());
|
||||
plugin.getCommand("wildcard").setExecutor(new Command_wildcard());
|
||||
plugin.getCommand("wipeflatlands").setExecutor(new Command_wipeflatlands());
|
||||
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,222 +25,234 @@ 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;
|
||||
public static DiscordCommandManager COMMAND_MANAGER;
|
||||
|
||||
private static void onMessageCreateEvent(MessageCreateEvent message) {
|
||||
boolean isAdmin = false;
|
||||
private static DiscordApi DISCORD_API;
|
||||
private static TextChannel CHANNEL;
|
||||
private static TextChannel ADMIN_CHANNEL;
|
||||
public static DiscordCommandManager COMMAND_MANAGER;
|
||||
|
||||
private static void onMessageCreateEvent(MessageCreateEvent message) {
|
||||
boolean isAdmin = false;
|
||||
|
||||
try {
|
||||
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;
|
||||
}
|
||||
Optional<Server> server = message.getServer();
|
||||
Optional<User> user = author.asUser();
|
||||
|
||||
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.");
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (content.toLowerCase().startsWith(prefix)) {
|
||||
COMMAND_MANAGER.parse(content, user.get(), server.get(), message.getChannel(), prefix);
|
||||
} else {
|
||||
Optional<Message> referenced = message.getMessage().getReferencedMessage();
|
||||
|
||||
String reply = "";
|
||||
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());
|
||||
}
|
||||
|
||||
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)));
|
||||
TextComponent component = new TextComponent(reply);
|
||||
|
||||
component.addExtra(Utilities.fromBaseComponents(components));
|
||||
|
||||
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");
|
||||
warningComponent.setColor(net.md_5.bungee.api.ChatColor.RED);
|
||||
warningComponent.setBold(true);
|
||||
TextComponent urlComponent = new TextComponent(url);
|
||||
urlComponent.setColor(net.md_5.bungee.api.ChatColor.DARK_AQUA);
|
||||
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]");
|
||||
mediaComponent.setColor(net.md_5.bungee.api.ChatColor.YELLOW);
|
||||
mediaComponent.setClickEvent(clickEvent);
|
||||
mediaComponent.setHoverEvent(hoverEvent);
|
||||
component.addExtra(mediaComponent);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (isAdmin) {
|
||||
for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (AdminList.isSuperAdmin(player)) {
|
||||
player.spigot().sendMessage(component);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Bukkit.spigot().broadcast(component);
|
||||
}
|
||||
Log.info(component.toPlainText());
|
||||
}
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
|
||||
if (Boolean.FALSE.equals(MainConfig.getBoolean(ConfigurationEntry.DISCORD_IS_ENABLED))) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DISCORD_API = new DiscordApiBuilder()
|
||||
.setToken(MainConfig.getString(ConfigurationEntry.DISCORD_TOKEN))
|
||||
.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));
|
||||
|
||||
if (!channelFuture.isPresent()) {
|
||||
Log.warning("TFM 4.3 Reloaded could not find your channel, stopping!");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
CHANNEL = channelFuture.get();
|
||||
adminChannelFuture.ifPresent(textChannel -> ADMIN_CHANNEL = textChannel);
|
||||
COMMAND_MANAGER = new DiscordCommandManager();
|
||||
COMMAND_MANAGER.init();
|
||||
|
||||
CHANNEL.addMessageCreateListener(DiscordBridge::onMessageCreateEvent);
|
||||
if (adminChannelFuture.isPresent()) {
|
||||
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("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");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.info("TFM 4.3 Reloaded Discord started.");
|
||||
|
||||
transmitMessage("**Server has started**");
|
||||
}
|
||||
|
||||
public static String sanitizeMessage(String message) {
|
||||
Pattern colors = Pattern.compile("§.", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
|
||||
Pattern pings = Pattern.compile("@", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
|
||||
|
||||
if (message.length() > 2000) {
|
||||
message = message.substring(0, 2000);
|
||||
}
|
||||
|
||||
return message.replaceAll(colors.pattern(), "").replaceAll(pings.pattern(), "@\u200B");
|
||||
}
|
||||
|
||||
public static void transmitMessage(String message) {
|
||||
transmitMessage(message, false);
|
||||
}
|
||||
|
||||
public static void transmitMessage(String message, boolean disconnectAfterwards) {
|
||||
if (CHANNEL == null) {
|
||||
return;
|
||||
}
|
||||
if (!disconnectAfterwards) {
|
||||
CHANNEL.sendMessage(sanitizeMessage(message));
|
||||
} else {
|
||||
try {
|
||||
CHANNEL.sendMessage(sanitizeMessage(message)).get();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
CountDownLatch shutdownWaiter = new CountDownLatch(1);
|
||||
|
||||
Thread t = new Thread(() -> {
|
||||
DISCORD_API.addLostConnectionListener(lostConnectionEvent -> shutdownWaiter.countDown());
|
||||
DISCORD_API.disconnect();
|
||||
|
||||
try {
|
||||
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;
|
||||
Optional<Server> server = message.getServer();
|
||||
Optional<User> user = author.asUser();
|
||||
|
||||
if(prefix == null) {
|
||||
Log.severe("Bot prefix does not exist. Stopping bot...");
|
||||
stop();
|
||||
return;
|
||||
shutdownWaiter.await(30, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
public static void transmitAdminMessage(String message) {
|
||||
transmitAdminMessage(message, false);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
public static void transmitAdminMessage(String message, boolean disconnectAfterwards) {
|
||||
if (ADMIN_CHANNEL == null) {
|
||||
return;
|
||||
}
|
||||
if (!disconnectAfterwards) {
|
||||
ADMIN_CHANNEL.sendMessage(sanitizeMessage(message));
|
||||
} else {
|
||||
try {
|
||||
ADMIN_CHANNEL.sendMessage(sanitizeMessage(message)).get();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
DISCORD_API.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
if (content.toLowerCase().startsWith(prefix)) {
|
||||
COMMAND_MANAGER.parse(content, user.get(), server.get(), message.getChannel(), prefix);
|
||||
} else {
|
||||
Optional<Message> referenced = message.getMessage().getReferencedMessage();
|
||||
public static void stop() {
|
||||
|
||||
String reply = "";
|
||||
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());
|
||||
}
|
||||
|
||||
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)));
|
||||
TextComponent component = new TextComponent(reply);
|
||||
|
||||
for (BaseComponent baseComponent : components) {
|
||||
component.addExtra(baseComponent);
|
||||
}
|
||||
|
||||
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");
|
||||
warningComponent.setColor(net.md_5.bungee.api.ChatColor.RED);
|
||||
warningComponent.setBold(true);
|
||||
TextComponent urlComponent = new TextComponent(url);
|
||||
urlComponent.setColor(net.md_5.bungee.api.ChatColor.DARK_AQUA);
|
||||
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]");
|
||||
mediaComponent.setColor(net.md_5.bungee.api.ChatColor.YELLOW);
|
||||
mediaComponent.setClickEvent(clickEvent);
|
||||
mediaComponent.setHoverEvent(hoverEvent);
|
||||
component.addExtra(mediaComponent);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if(isAdmin) {
|
||||
for (org.bukkit.entity.Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (AdminList.isSuperAdmin(player))
|
||||
{
|
||||
player.spigot().sendMessage(component);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Bukkit.spigot().broadcast(component);
|
||||
}
|
||||
Log.info(component.toPlainText());
|
||||
}
|
||||
if (Boolean.FALSE.equals(MainConfig.getBoolean(ConfigurationEntry.DISCORD_IS_ENABLED))) {
|
||||
return;
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
transmitMessage("**Server has stopped**", true);
|
||||
|
||||
if (Boolean.FALSE.equals(MainConfig.getBoolean(ConfigurationEntry.DISCORD_IS_ENABLED))) {
|
||||
return;
|
||||
}
|
||||
Log.info("TFM 4.3 Reloaded Discord stopped.");
|
||||
}
|
||||
|
||||
try {
|
||||
DISCORD_API = new DiscordApiBuilder()
|
||||
.setToken(MainConfig.getString(ConfigurationEntry.DISCORD_TOKEN))
|
||||
.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));
|
||||
|
||||
if (!channelFuture.isPresent()) {
|
||||
Log.warning("TFM 4.3 Reloaded could not find your channel, stopping!");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
CHANNEL = channelFuture.get();
|
||||
adminChannelFuture.ifPresent(textChannel -> ADMIN_CHANNEL = textChannel);
|
||||
COMMAND_MANAGER = new DiscordCommandManager();
|
||||
COMMAND_MANAGER.init();
|
||||
|
||||
CHANNEL.addMessageCreateListener(DiscordBridge::onMessageCreateEvent);
|
||||
if (adminChannelFuture.isPresent()) {
|
||||
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("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");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.info("TFM 4.3 Reloaded Discord started.");
|
||||
|
||||
transmitMessage("**Server has started**");
|
||||
}
|
||||
|
||||
public static String sanitizeMessage(String message) {
|
||||
Pattern colors = Pattern.compile("§.", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
|
||||
Pattern pings = Pattern.compile("@", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
|
||||
|
||||
if (message.length() > 2000) {
|
||||
message = message.substring(0, 2000);
|
||||
}
|
||||
|
||||
return message.replaceAll(colors.pattern(), "").replaceAll(pings.pattern(), "@\u200B");
|
||||
}
|
||||
|
||||
public static void transmitMessage(String message) {
|
||||
transmitMessage(message, false);
|
||||
}
|
||||
|
||||
public static void transmitMessage(String message, boolean disconnectAfterwards) {
|
||||
if (CHANNEL == null) return;
|
||||
if (!disconnectAfterwards) {
|
||||
CHANNEL.sendMessage(sanitizeMessage(message));
|
||||
} else {
|
||||
try {
|
||||
CHANNEL.sendMessage(sanitizeMessage(message)).get();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
CountDownLatch shutdownWaiter = new CountDownLatch(1);
|
||||
|
||||
Thread t = new Thread(() -> {
|
||||
DISCORD_API.addLostConnectionListener(lostConnectionEvent -> shutdownWaiter.countDown());
|
||||
DISCORD_API.disconnect();
|
||||
|
||||
try {
|
||||
shutdownWaiter.await(30, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
}
|
||||
}
|
||||
|
||||
public static void transmitAdminMessage(String message) {
|
||||
transmitAdminMessage(message, false);
|
||||
}
|
||||
|
||||
public static void transmitAdminMessage(String message, boolean disconnectAfterwards) {
|
||||
if (ADMIN_CHANNEL == null) return;
|
||||
if (!disconnectAfterwards) {
|
||||
ADMIN_CHANNEL.sendMessage(sanitizeMessage(message));
|
||||
} else {
|
||||
try {
|
||||
ADMIN_CHANNEL.sendMessage(sanitizeMessage(message)).get();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
DISCORD_API.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public static void stop() {
|
||||
|
||||
if (Boolean.FALSE.equals(MainConfig.getBoolean(ConfigurationEntry.DISCORD_IS_ENABLED))) {
|
||||
return;
|
||||
}
|
||||
|
||||
transmitMessage("**Server has stopped**", true);
|
||||
|
||||
Log.info("TFM 4.3 Reloaded Discord stopped.");
|
||||
}
|
||||
|
||||
public static String fullySanitizeDiscordMessage(String message)
|
||||
{
|
||||
String partiallySanitized = sanitizeMessage(message);
|
||||
return partiallySanitized.replaceAll("([`_~*|\\\\])", "\\\\$1");
|
||||
}
|
||||
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