mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Whoops lol
This commit is contained in:
parent
ccf572315f
commit
922fa4a34f
@ -8,6 +8,13 @@ import me.totalfreedom.totalfreedommod.rank.Displayable;
|
|||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.format.StyleBuilderApplicable;
|
||||||
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.SoundCategory;
|
import org.bukkit.SoundCategory;
|
||||||
@ -150,7 +157,8 @@ public class ChatManager extends FreedomService
|
|||||||
Displayable display = plugin.rm.getDisplay(sender);
|
Displayable display = plugin.rm.getDisplay(sender);
|
||||||
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
|
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
|
||||||
|
|
||||||
if (plugin.dc != null) {
|
if (plugin.dc != null)
|
||||||
|
{
|
||||||
plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message);
|
plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,12 +168,16 @@ public class ChatManager extends FreedomService
|
|||||||
if (!Strings.isNullOrEmpty(admin.getAcFormat()))
|
if (!Strings.isNullOrEmpty(admin.getAcFormat()))
|
||||||
{
|
{
|
||||||
String format = 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.miniMessage(format,
|
||||||
player.sendMessage(FUtil.colorize(msg));
|
Placeholder.unparsed("name", sender.getName()),
|
||||||
|
Placeholder.unparsed("rank", display.getAbbr()),
|
||||||
|
TagResolver.resolver("rankcolor", Tag.styling(TextColor.color(getColor(display).getColor().getRGB()))),
|
||||||
|
Placeholder.unparsed("message", message)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// OH GOD, WHY ARE WE DOING THIS
|
||||||
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));
|
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));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -173,13 +185,17 @@ public class ChatManager extends FreedomService
|
|||||||
|
|
||||||
public void reportAction(Player reporter, String reportedName, String report)
|
public void reportAction(Player reporter, String reportedName, String report)
|
||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
messageAllAdmins("<red>[REPORTS]</red> <gold><reporter> has reported <reported> for <reason>.",
|
||||||
{
|
Placeholder.unparsed("reporter", reporter.getName()),
|
||||||
if (plugin.al.isAdmin(player))
|
Placeholder.unparsed("reported", reportedName),
|
||||||
{
|
Placeholder.unparsed("reason", report));
|
||||||
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reportedName + " for " + report);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
FLog.info("[REPORTS] " + reporter.getName() + " has reported " + reportedName + " for " + report);
|
public void messageAllAdmins(String message, TagResolver... placeholders)
|
||||||
|
{
|
||||||
|
Component parsed = FUtil.MINI_MESSAGE.deserialize(message, placeholders);
|
||||||
|
plugin.getComponentLogger().info(parsed);
|
||||||
|
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player ->
|
||||||
|
player.sendMessage(parsed));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -10,9 +11,11 @@ import me.totalfreedom.totalfreedommod.admin.Admin;
|
|||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FConverter;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -200,24 +203,21 @@ public class LoginProcess extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
for (String line : ConfigEntry.FIRST_JOIN_INFO.getStringList())
|
ConfigEntry.FIRST_JOIN_INFO.getStringList().forEach(line -> FUtil.playerMsgCooler(player, line));
|
||||||
{
|
|
||||||
player.sendMessage(FUtil.colorize(line));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 20);
|
}.runTaskLater(plugin, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendTitle(FUtil.colorize(ConfigEntry.SERVER_LOGIN_TITLE.getString()), FUtil.colorize(ConfigEntry.SERVER_LOGIN_SUBTITLE.getString()), 20, 100, 60);
|
FUtil.playerTitle(player, ConfigEntry.SERVER_LOGIN_TITLE.getString(), ConfigEntry.SERVER_LOGIN_SUBTITLE.getString());
|
||||||
|
|
||||||
if (TELEPORT_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_TP.getBoolean())
|
if (TELEPORT_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_TP.getBoolean())
|
||||||
{
|
{
|
||||||
int x = FUtil.randomInteger(-10000, 10000);
|
int x = FUtil.randomInteger(-10000, 10000);
|
||||||
int z = FUtil.randomInteger(-10000, 10000);
|
int z = FUtil.randomInteger(-10000, 10000);
|
||||||
int y = player.getWorld().getHighestBlockYAt(x, z);
|
int y = player.getWorld().getHighestBlockYAt(x, z) + 1;
|
||||||
Location location = new Location(player.getLocation().getWorld(), x, y, z);
|
Location location = new Location(player.getLocation().getWorld(), x, y, z);
|
||||||
PaperLib.teleportAsync(player, location);
|
PaperLib.teleportAsync(player, location);
|
||||||
player.sendMessage(ChatColor.AQUA + "You have been teleported to a random location automatically.");
|
FUtil.playerMsgCooler(player, "<aqua>You have been automatically teleported to a random location.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,18 +230,18 @@ public class LoginProcess extends FreedomService
|
|||||||
if (CLEAR_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_CLEAR.getBoolean())
|
if (CLEAR_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_CLEAR.getBoolean())
|
||||||
{
|
{
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
player.sendMessage(ChatColor.AQUA + "Your inventory has been cleared automatically.");
|
FUtil.playerMsgCooler(player, "<aqua>Your inventory has been automatically cleared.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ConfigEntry.SERVER_TABLIST_HEADER.getString().isEmpty())
|
if (!ConfigEntry.SERVER_TABLIST_HEADER.getString().isEmpty())
|
||||||
{
|
{
|
||||||
player.setPlayerListHeader(FUtil.colorize(ConfigEntry.SERVER_TABLIST_HEADER.getString()).replace("\\n", "\n"));
|
player.sendPlayerListHeader(FUtil.miniMessage(ConfigEntry.SERVER_TABLIST_HEADER.getString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ConfigEntry.SERVER_TABLIST_FOOTER.getString().isEmpty())
|
if (!ConfigEntry.SERVER_TABLIST_FOOTER.getString().isEmpty())
|
||||||
{
|
{
|
||||||
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
|
player.sendPlayerListFooter(FUtil.miniMessage(ConfigEntry.SERVER_TABLIST_FOOTER.getString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.al.isAdmin(player))
|
||||||
@ -255,10 +255,22 @@ public class LoginProcess extends FreedomService
|
|||||||
int noteCount = playerData.getNotes().size();
|
int noteCount = playerData.getNotes().size();
|
||||||
if (noteCount != 0)
|
if (noteCount != 0)
|
||||||
{
|
{
|
||||||
String noteMessage = "This player has " + noteCount + " admin note" + (noteCount > 1 ? "s" : "") + ".";
|
plugin.cm.messageAllAdmins("<gold>This player has <yellow><count> <gold>admin note<plural>.",
|
||||||
FLog.info(noteMessage);
|
Placeholder.unparsed("count", String.valueOf(noteCount)), Placeholder.unparsed("plural", noteCount > 1 ? "s" : ""));
|
||||||
plugin.al.messageAllAdmins(ChatColor.GOLD + noteMessage);
|
plugin.cm.messageAllAdmins("<gold>Do <yellow>/notes <player> list<gold> to view them.",
|
||||||
plugin.al.messageAllAdmins(ChatColor.GOLD + "Do " + ChatColor.YELLOW + "/notes " + player.getName() + " list" + ChatColor.GOLD + " to view them.");
|
Placeholder.unparsed("player", player.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Admin admin = plugin.al.getAdmin(player);
|
||||||
|
String format = admin.getAcFormat();
|
||||||
|
|
||||||
|
if (!Strings.isNullOrEmpty(format) && FConverter.needsConversion(admin.getAcFormat()))
|
||||||
|
{
|
||||||
|
player.sendMessage(FUtil.miniMessage("<green>Converting your admin chat format..."));
|
||||||
|
admin.setAcFormat(FConverter.convertAdminChatFormat(format));
|
||||||
|
plugin.al.save(admin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,12 +281,12 @@ public class LoginProcess extends FreedomService
|
|||||||
{
|
{
|
||||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + "Server is currently closed to non-admins.");
|
FUtil.playerMsgCooler(player, "<red>Server is currently closed to non-admins.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lockdownEnabled)
|
if (lockdownEnabled)
|
||||||
{
|
{
|
||||||
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
|
FUtil.playerMsgCooler(player, "<red>Warning: Server is currenty in lockdown-mode, new players will not be able to join!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 20L);
|
}.runTaskLater(plugin, 20L);
|
||||||
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -32,52 +33,35 @@ public class ServerPing extends FreedomService
|
|||||||
|
|
||||||
if (plugin.bm.isIpBanned(ip))
|
if (plugin.bm.isIpBanned(ip))
|
||||||
{
|
{
|
||||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_BAN_MOTD.getString()));
|
event.motd(FUtil.miniMessage(ConfigEntry.SERVER_BAN_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||||
{
|
{
|
||||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_ADMINMODE_MOTD.getString()));
|
event.motd(FUtil.miniMessage(ConfigEntry.SERVER_ADMINMODE_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LoginProcess.isLockdownEnabled())
|
if (LoginProcess.isLockdownEnabled())
|
||||||
{
|
{
|
||||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_LOCKDOWN_MOTD.getString()));
|
event.motd(FUtil.miniMessage(ConfigEntry.SERVER_LOCKDOWN_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bukkit.hasWhitelist())
|
if (Bukkit.hasWhitelist())
|
||||||
{
|
{
|
||||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_WHITELIST_MOTD.getString()));
|
event.motd(FUtil.miniMessage(ConfigEntry.SERVER_WHITELIST_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers())
|
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers())
|
||||||
{
|
{
|
||||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_FULL_MOTD.getString()));
|
event.motd(FUtil.miniMessage(ConfigEntry.SERVER_FULL_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", meta.id);
|
event.motd(FUtil.miniMessage(ConfigEntry.SERVER_MOTD.getString(), Placeholder.unparsed("version", meta.id)));
|
||||||
baseMotd = baseMotd.replace("\\n", "\n");
|
|
||||||
baseMotd = FUtil.colorize(baseMotd);
|
|
||||||
|
|
||||||
if (!ConfigEntry.SERVER_COLORFUL_MOTD.getBoolean())
|
|
||||||
{
|
|
||||||
event.setMotd(baseMotd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Colorful MOTD
|
|
||||||
final StringBuilder motd = new StringBuilder();
|
|
||||||
for (String word : baseMotd.split(" "))
|
|
||||||
{
|
|
||||||
motd.append(FUtil.randomChatColor()).append(word).append(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setMotd(motd.toString().trim());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class VersionMeta
|
private static class VersionMeta
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -39,8 +35,7 @@ public class VanishHandler extends FreedomService
|
|||||||
if (plugin.al.isVanished(player.getUniqueId()))
|
if (plugin.al.isVanished(player.getUniqueId()))
|
||||||
{
|
{
|
||||||
plugin.esb.setVanished(player.getName(), true);
|
plugin.esb.setVanished(player.getName(), true);
|
||||||
FLog.info(player.getName() + " joined while still vanished.");
|
plugin.cm.messageAllAdmins("<yellow><player> has joined silently.", Placeholder.unparsed("player", player.getName()));
|
||||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has joined silently.");
|
|
||||||
event.joinMessage(null);
|
event.joinMessage(null);
|
||||||
|
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
@ -50,7 +45,7 @@ public class VanishHandler extends FreedomService
|
|||||||
{
|
{
|
||||||
if (plugin.al.isVanished(player.getUniqueId()))
|
if (plugin.al.isVanished(player.getUniqueId()))
|
||||||
{
|
{
|
||||||
player.sendActionBar(Component.text("You are hidden from other players.").color(NamedTextColor.GOLD));
|
player.sendActionBar(FUtil.miniMessage("<gold>You are hidden from other players."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -69,8 +64,7 @@ public class VanishHandler extends FreedomService
|
|||||||
if (plugin.al.isVanished(player.getUniqueId()))
|
if (plugin.al.isVanished(player.getUniqueId()))
|
||||||
{
|
{
|
||||||
event.quitMessage(null);
|
event.quitMessage(null);
|
||||||
FLog.info(player.getName() + " left while still vanished.");
|
plugin.cm.messageAllAdmins("<yellow><player> has left silently.", Placeholder.unparsed("player", player.getName()));
|
||||||
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has left silently.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,9 +4,11 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FConverter;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -11,6 +11,7 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -67,6 +68,11 @@ public class AdminList extends FreedomService
|
|||||||
FLog.info("Loaded " + allAdmins.size() + " admins (" + uuidTable.size() + " active, " + ipTable.size() + " IPs)");
|
FLog.info("Loaded " + allAdmins.size() + " admins (" + uuidTable.size() + " active, " + ipTable.size() + " IPs)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void messageAllAdmins(Component message)
|
||||||
|
{
|
||||||
|
server.getOnlinePlayers().stream().filter(this::isAdmin).forEach(player -> player.sendMessage(message));
|
||||||
|
}
|
||||||
|
|
||||||
public void messageAllAdmins(String message)
|
public void messageAllAdmins(String message)
|
||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
@ -4,8 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
/* TODO This will have to be changed from com.github.atlasmediagroup.scissors to me.totalfreedom.scissors when we migrate to 1.19 */
|
import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
||||||
import com.github.atlasmediagroup.scissors.event.block.MasterBlockFireEvent;
|
|
||||||
import io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent;
|
import io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
@ -52,10 +52,9 @@ public enum ConfigEntry
|
|||||||
HTTPD_PORT(Integer.class, "httpd.port"),
|
HTTPD_PORT(Integer.class, "httpd.port"),
|
||||||
HTTPD_PUBLIC_FOLDER(String.class, "httpd.public_folder"),
|
HTTPD_PUBLIC_FOLDER(String.class, "httpd.public_folder"),
|
||||||
//
|
//
|
||||||
SERVER_COLORFUL_MOTD(Boolean.class, "server.colorful_motd"),
|
|
||||||
SERVER_NAME(String.class, "server.name"),
|
SERVER_NAME(String.class, "server.name"),
|
||||||
SERVER_ADDRESS(String.class, "server.address"),
|
SERVER_ADDRESS(String.class, "server.address"),
|
||||||
SERVER_MOTD(String.class, "server.motd"),
|
SERVER_MOTD(String.class, "server.motds.normal"),
|
||||||
SERVER_LOGIN_TITLE(String.class, "server.login_title.title"),
|
SERVER_LOGIN_TITLE(String.class, "server.login_title.title"),
|
||||||
SERVER_LOGIN_SUBTITLE(String.class, "server.login_title.subtitle"),
|
SERVER_LOGIN_SUBTITLE(String.class, "server.login_title.subtitle"),
|
||||||
SERVER_OWNERS(List.class, "server.owners"),
|
SERVER_OWNERS(List.class, "server.owners"),
|
||||||
|
@ -1,2 +1,32 @@
|
|||||||
package me.totalfreedom.totalfreedommod.util;public class FConverter {
|
package me.totalfreedom.totalfreedommod.util;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class FConverter
|
||||||
|
{
|
||||||
|
private static final Pattern godFuckingDamnit = Pattern.compile(".*(?i)(&((#[a-f0-9]{3,6})|([0-9a-fklmnopr]))|%[a-z]+%).*");
|
||||||
|
|
||||||
|
public static boolean needsConversion(String messageOrFormat)
|
||||||
|
{
|
||||||
|
return godFuckingDamnit.matcher(messageOrFormat).find();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String convertAdminChatFormat(String format)
|
||||||
|
{
|
||||||
|
// %name%
|
||||||
|
// %rank%
|
||||||
|
// %rankcolor%
|
||||||
|
// %msg%
|
||||||
|
|
||||||
|
return FUtil.MINI_MESSAGE.serialize(FUtil.LEGACY_AMPERSAND.deserialize(
|
||||||
|
format.replaceAll("%name%", "<name>")
|
||||||
|
.replaceAll("%rank%", "<rank>")
|
||||||
|
.replaceAll("%rankcolor%", "<rankcolor>")
|
||||||
|
.replaceAll("%msg%", "<message>")))
|
||||||
|
.replaceAll("\\\\<", "<"); // GOD FUCKING DAMMIT
|
||||||
|
|
||||||
|
//zTagResolver.resolver("rankcolor", Tag.styling(lol -> lol.color()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,12 @@ import com.earth2me.essentials.utils.DateUtil;
|
|||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import net.kyori.adventure.title.Title;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang.WordUtils;
|
import org.apache.commons.lang.WordUtils;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
@ -14,11 +19,13 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
import org.jetbrains.annotations.Contract;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.management.ManagementFactory;
|
import java.lang.management.ManagementFactory;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -74,6 +81,14 @@ public class FUtil
|
|||||||
"G6_",
|
"G6_",
|
||||||
"ayunami2000");
|
"ayunami2000");
|
||||||
public static final LegacyComponentSerializer LEGACY_AMPERSAND = LegacyComponentSerializer.legacyAmpersand();
|
public static final LegacyComponentSerializer LEGACY_AMPERSAND = LegacyComponentSerializer.legacyAmpersand();
|
||||||
|
public static final MiniMessage MINI_MESSAGE = MiniMessage.builder().tags(TagResolver.resolver(
|
||||||
|
StandardTags.color(),
|
||||||
|
StandardTags.rainbow(),
|
||||||
|
StandardTags.gradient(),
|
||||||
|
StandardTags.decorations(TextDecoration.ITALIC),
|
||||||
|
StandardTags.decorations(TextDecoration.BOLD),
|
||||||
|
StandardTags.decorations(TextDecoration.STRIKETHROUGH),
|
||||||
|
StandardTags.decorations(TextDecoration.UNDERLINED))).build();
|
||||||
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
|
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
|
||||||
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
|
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
|
||||||
ChatColor.DARK_RED,
|
ChatColor.DARK_RED,
|
||||||
@ -232,6 +247,24 @@ public class FUtil
|
|||||||
FUtil.bcastMsg(message, null, true);
|
FUtil.bcastMsg(message, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void playerTitle(CommandSender sender, String title, String subtitle, Title.Times times, TagResolver... placeholders)
|
||||||
|
{
|
||||||
|
Component compTitle = MINI_MESSAGE.deserialize(title, placeholders);
|
||||||
|
Component compSubtitle = MINI_MESSAGE.deserialize(subtitle, placeholders);
|
||||||
|
|
||||||
|
sender.showTitle(Title.title(compTitle, compSubtitle, times));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void playerTitle(CommandSender sender, String title, String subtitle, TagResolver... placeholders)
|
||||||
|
{
|
||||||
|
playerTitle(sender, title, subtitle, Title.Times.times(Duration.ofSeconds(1), Duration.ofSeconds(5), Duration.ofSeconds(3)), placeholders);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void playerMsgCooler(CommandSender sender, String message, TagResolver... placeholders)
|
||||||
|
{
|
||||||
|
sender.sendMessage(MINI_MESSAGE.deserialize(message, placeholders));
|
||||||
|
}
|
||||||
|
|
||||||
// Still in use by listeners
|
// Still in use by listeners
|
||||||
public static void playerMsg(CommandSender sender, String message, ChatColor color)
|
public static void playerMsg(CommandSender sender, String message, ChatColor color)
|
||||||
{
|
{
|
||||||
@ -460,6 +493,11 @@ public class FUtil
|
|||||||
return LEGACY_AMPERSAND.deserialize(string);
|
return LEGACY_AMPERSAND.deserialize(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Component miniMessage(String string, TagResolver... placeholders)
|
||||||
|
{
|
||||||
|
return MINI_MESSAGE.deserialize(string, placeholders);
|
||||||
|
}
|
||||||
|
|
||||||
public static String stripColors(String string)
|
public static String stripColors(String string)
|
||||||
{
|
{
|
||||||
return string.replaceAll("§", "");
|
return string.replaceAll("§", "");
|
||||||
|
@ -10,24 +10,19 @@ server:
|
|||||||
# The address your server is located at. Please do not include the port.
|
# The address your server is located at. Please do not include the port.
|
||||||
address: play.totalfreedom.me
|
address: play.totalfreedom.me
|
||||||
|
|
||||||
# Shown at the server list - Please note that support for %mcversion% has been withdrawn
|
|
||||||
motd: TotalFreedom &8- The Original All-Op Server!
|
|
||||||
|
|
||||||
# Every word in the MOTD will be a different color unless prefixed by a color code
|
|
||||||
colorful_motd: true
|
|
||||||
|
|
||||||
# MOTD Modification
|
# MOTD Modification
|
||||||
motds:
|
motds:
|
||||||
ban: '&cYou are banned.'
|
ban: '<red>You are banned.'
|
||||||
adminmode: '&cServer is closed.'
|
adminmode: '<red>Server is closed.'
|
||||||
lockdown: '&cServer is in lock-down.'
|
lockdown: '<red>Server is in lock-down.'
|
||||||
whitelist: '&cWhitelist enabled.'
|
whitelist: '<red>Whitelist enabled.'
|
||||||
full: '&cServer is full.'
|
full: '<red>Server is full.'
|
||||||
|
normal: '<gold>TotalFreedom</gold> <dark_gray>-</dark_gray> <yellow>The Original All-Op Server!'
|
||||||
|
|
||||||
# Shown on join as a title
|
# Shown on join as a title
|
||||||
login_title:
|
login_title:
|
||||||
title: '&7Welcome to &6TotalFreedom&7!'
|
title: '<gray>Welcome to <gold>TotalFreedom</gold>!'
|
||||||
subtitle: '&eThe Original All-Op Server!'
|
subtitle: '<yellow>The Original All-Op Server!'
|
||||||
|
|
||||||
# All players who show up as owner
|
# All players who show up as owner
|
||||||
owners:
|
owners:
|
||||||
@ -552,18 +547,17 @@ announcer:
|
|||||||
- 'Join our Discord server! https://discord.com/invite/PW4savJR9a'
|
- 'Join our Discord server! https://discord.com/invite/PW4savJR9a'
|
||||||
- 'Remember to save your hotbar, otherwise you may lose your items!'
|
- 'Remember to save your hotbar, otherwise you may lose your items!'
|
||||||
- 'Link your discord account with &6/linkdiscord for extra features!'
|
- 'Link your discord account with &6/linkdiscord for extra features!'
|
||||||
# - 'Check out our reddit at &6https://www.reddit.com/r/TotalFreedom/ &byou can even link your account!'
|
|
||||||
- 'Want to see cool builds? Check out our Master Builder World with &6/mbworld'
|
- 'Want to see cool builds? Check out our Master Builder World with &6/mbworld'
|
||||||
- 'Be sure to follow our twitter for all the latest updates. &6https://twitter.com/totalfreedommc'
|
- 'Be sure to follow our twitter for all the latest updates. &6https://twitter.com/totalfreedommc'
|
||||||
|
|
||||||
# What to display in the admininfo command.
|
# What to display in the admininfo command.
|
||||||
admininfo:
|
admininfo:
|
||||||
- '&bHow to apply for an admin position on the TotalFreedom Server:'
|
- '<aqua>How to apply for an admin position on the TotalFreedom Server:'
|
||||||
- ' &6- Do not ask for admin in game'
|
- ' <gold>- Do not ask for admin in game'
|
||||||
- ' &2- Be helpful within the server'
|
- ' <dark_green>- Be helpful within the server'
|
||||||
- ' &6- Report those breaking the rules'
|
- ' <gold>- Report those breaking the rules'
|
||||||
- ' &2- And apply on our forums at the link:'
|
- ' <dark_green>- And apply on our forums at the link:'
|
||||||
- '&9https://forum.totalfreedom.me/d/45-admin-application-template'
|
- '<blue>https://forum.totalfreedom.me/d/45-admin-application-template'
|
||||||
|
|
||||||
# What to display in the vote command.
|
# What to display in the vote command.
|
||||||
votinginfo:
|
votinginfo:
|
||||||
@ -579,20 +573,20 @@ votinginfo:
|
|||||||
|
|
||||||
# What to display in the Master Builder info command.
|
# What to display in the Master Builder info command.
|
||||||
masterbuilderinfo:
|
masterbuilderinfo:
|
||||||
- '&bHow to apply for Master Builder on the TotalFreedom Server:'
|
- '<aqua>How to apply for Master Builder on the TotalFreedom Server:'
|
||||||
- ' &6- Do not ask for Master Builder in game'
|
- ' <gold>- Do not ask for Master Builder in game'
|
||||||
- ' &2- Screenshot some of your previous builds (be ready to prove that the builds are yours)'
|
- ' <dark_green>- Screenshot some of your previous builds (be ready to prove that the builds are yours)'
|
||||||
- ' &6- Copy the template and create a thread on our forums'
|
- ' <gold>- Copy the template and create a thread on our forums'
|
||||||
- ' &2- Template:'
|
- ' <dark_gold>- Template:'
|
||||||
- '&9https://forum.totalfreedom.me/d/336-master-builder-application-process'
|
- '<blue>https://forum.totalfreedom.me/d/336-master-builder-application-process'
|
||||||
|
|
||||||
# What new players will see upon joining for the first time.
|
# What new players will see upon joining for the first time.
|
||||||
first_join_info:
|
first_join_info:
|
||||||
enabled: true
|
enabled: true
|
||||||
text:
|
text:
|
||||||
- "&6Welcome to TotalFreedom -- the original Free-OP server!"
|
- "<gold>Welcome to TotalFreedom -- the original Free-OP server!"
|
||||||
- "&eThe server's name doesn't mean we have no rules. Do &6/rules &efor a list of them."
|
- "<yellow>The server's name doesn't mean we have no rules. Do <gold>/rules</gold> for a list of them."
|
||||||
- "&aNeed help getting started? Do &2/help &aor a list of commands!"
|
- "<green>Need help getting started? Do <dark_green>/help</dark_green> for a list of commands!"
|
||||||
|
|
||||||
# Pet Protect - Prevent tamed pets from being killed.
|
# Pet Protect - Prevent tamed pets from being killed.
|
||||||
petprotect:
|
petprotect:
|
||||||
|
4
pom.xml
4
pom.xml
@ -102,8 +102,8 @@
|
|||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.totalfreedom.scissors</groupId>
|
<groupId>me.totalfreedom.scissors</groupId>
|
||||||
<artifactId>scissors-api</artifactId>
|
<artifactId>Scissors-API</artifactId>
|
||||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
<version>1.19.3-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user