Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c48d4f5c86 | ||
|
|
7f00bc104b | ||
|
|
133cebd1ec | ||
|
|
fc20c9a276 | ||
|
|
ea8e952108 | ||
|
|
3d010e4139 | ||
|
|
7cc7cca129 | ||
|
|
3bfd358e78 | ||
|
|
eb30750134 |
@@ -3,10 +3,10 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// compileOnly("com.alttd:Galaxy-API:1.21-R0.1-SNAPSHOT") {
|
// Cosmos
|
||||||
// exclude("net.kyori")
|
compileOnly("com.alttd.cosmos:cosmos-api:1.21.8-R0.1-SNAPSHOT") {
|
||||||
// }
|
isChanging = true
|
||||||
compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
|
}
|
||||||
compileOnly("org.spongepowered:configurate-yaml:4.2.0") // Configurate
|
compileOnly("org.spongepowered:configurate-yaml:4.2.0") // Configurate
|
||||||
compileOnly("net.luckperms:api:5.5") // Luckperms
|
compileOnly("net.luckperms:api:5.5") // Luckperms
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ public final class Config {
|
|||||||
CONFIGPATH = new File(File.separator + "mnt" + File.separator + "configs" + File.separator + "ChatPlugin");
|
CONFIGPATH = new File(File.separator + "mnt" + File.separator + "configs" + File.separator + "ChatPlugin");
|
||||||
CONFIG_FILE = new File(CONFIGPATH, "config.yml");
|
CONFIG_FILE = new File(CONFIGPATH, "config.yml");
|
||||||
configLoader = YamlConfigurationLoader.builder()
|
configLoader = YamlConfigurationLoader.builder()
|
||||||
.file(CONFIG_FILE)
|
.file(CONFIG_FILE)
|
||||||
.nodeStyle(NodeStyle.BLOCK)
|
.nodeStyle(NodeStyle.BLOCK)
|
||||||
.build();
|
.build();
|
||||||
if (!CONFIG_FILE.getParentFile().exists()) {
|
if (!CONFIG_FILE.getParentFile().exists()) {
|
||||||
if (!CONFIG_FILE.getParentFile().mkdirs()) {
|
if (!CONFIG_FILE.getParentFile().mkdirs()) {
|
||||||
return;
|
return;
|
||||||
@@ -182,11 +182,12 @@ public final class Config {
|
|||||||
|
|
||||||
private static void settings() {
|
private static void settings() {
|
||||||
PREFIXGROUPS = getList("settings.prefix-groups",
|
PREFIXGROUPS = getList("settings.prefix-groups",
|
||||||
Lists.newArrayList("discord", "socialmedia", "eventteam", "eventleader", "youtube", "twitch", "developer"));
|
Lists.newArrayList("discord", "socialmedia", "eventteam", "eventleader", "youtube", "twitch",
|
||||||
|
"developer"));
|
||||||
CONFLICTINGPREFIXGROUPS = getList("settings.prefix-conflicts-groups",
|
CONFLICTINGPREFIXGROUPS = getList("settings.prefix-conflicts-groups",
|
||||||
Lists.newArrayList("eventteam", "eventleader"));
|
Lists.newArrayList("eventteam", "eventleader"));
|
||||||
STAFFGROUPS = getList("settings.staff-groups",
|
STAFFGROUPS = getList("settings.staff-groups",
|
||||||
Lists.newArrayList("trainee", "moderator", "headmod", "admin", "manager", "owner"));
|
Lists.newArrayList("trainee", "moderator", "headmod", "admin", "manager", "owner"));
|
||||||
CONSOLENAME = getString("settings.console-name", CONSOLENAME);
|
CONSOLENAME = getString("settings.console-name", CONSOLENAME);
|
||||||
CONSOLEUUID = UUID.fromString(getString("settings.console-uuid", CONSOLEUUID.toString()));
|
CONSOLEUUID = UUID.fromString(getString("settings.console-uuid", CONSOLEUUID.toString()));
|
||||||
MINIMIUMSTAFFRANK = getString("settings.minimum-staff-rank", MINIMIUMSTAFFRANK);
|
MINIMIUMSTAFFRANK = getString("settings.minimum-staff-rank", MINIMIUMSTAFFRANK);
|
||||||
@@ -196,8 +197,10 @@ public final class Config {
|
|||||||
|
|
||||||
public static List<String> MESSAGECOMMANDALIASES = new ArrayList<>();
|
public static List<String> MESSAGECOMMANDALIASES = new ArrayList<>();
|
||||||
public static List<String> REPLYCOMMANDALIASES = new ArrayList<>();
|
public static List<String> REPLYCOMMANDALIASES = new ArrayList<>();
|
||||||
public static String MESSAGESENDER = "<hover:show_text:Click to reply><click:suggest_command:/msg <receivername> ><light_purple>(Me -> <gray><receiver></gray>)</hover> <message>";
|
public static String MESSAGESENDER =
|
||||||
public static String MESSAGERECIEVER = "<hover:show_text:Click to reply><click:suggest_command:/msg <sendername> ><light_purple>(<gray><sender></gray> on <server> -> Me)</hover> <message>";
|
"<hover:show_text:Click to reply><click:suggest_command:/msg <receivername> ><light_purple>(Me -> <gray><receiver></gray>)</hover> <message>";
|
||||||
|
public static String MESSAGERECIEVER =
|
||||||
|
"<hover:show_text:Click to reply><click:suggest_command:/msg <sendername> ><light_purple>(<gray><sender></gray> on <server> -> Me)</hover> <message>";
|
||||||
public static String MESSAGESPY = "<gray>(<gray><sendername></gray> -> <receivername>) <message>";
|
public static String MESSAGESPY = "<gray>(<gray><sendername></gray> -> <receivername>) <message>";
|
||||||
public static String RECEIVER_DOES_NOT_EXIST = "<red><player> is not a valid player.</red>";
|
public static String RECEIVER_DOES_NOT_EXIST = "<red><player> is not a valid player.</red>";
|
||||||
|
|
||||||
@@ -212,7 +215,8 @@ public final class Config {
|
|||||||
RECEIVER_DOES_NOT_EXIST = getString("commands.message.receiver-does-not-exist", RECEIVER_DOES_NOT_EXIST);
|
RECEIVER_DOES_NOT_EXIST = getString("commands.message.receiver-does-not-exist", RECEIVER_DOES_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String GCFORMAT = "<white><light_purple><prefix></light_purple> <gray><sender></gray> <hover:show_text:on <server>><yellow>to Global</yellow></hover><gray>: <message>";
|
public static String GCFORMAT =
|
||||||
|
"<white><light_purple><prefix></light_purple> <gray><sender></gray> <hover:show_text:on <server>><yellow>to Global</yellow></hover><gray>: <message>";
|
||||||
public static String GCPERMISSION = "proxy.globalchat";
|
public static String GCPERMISSION = "proxy.globalchat";
|
||||||
public static List<String> GCALIAS = new ArrayList<>();
|
public static List<String> GCALIAS = new ArrayList<>();
|
||||||
public static String GCNOTENABLED = "You don't have global chat enabled.";
|
public static String GCNOTENABLED = "You don't have global chat enabled.";
|
||||||
@@ -228,7 +232,8 @@ public final class Config {
|
|||||||
GCCOOLDOWN = getInt("commands.globalchat.cooldown", GCCOOLDOWN);
|
GCCOOLDOWN = getInt("commands.globalchat.cooldown", GCCOOLDOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String CHATFORMAT = "<white><light_purple><prefixall> <gray><hover:show_text:Click to message <sendername>><click:suggest_command:/msg <sendername> ><sender></hover>: <white><message>";
|
public static String CHATFORMAT =
|
||||||
|
"<white><light_purple><prefixall> <gray><hover:show_text:Click to message <sendername>><click:suggest_command:/msg <sendername> ><sender></hover>: <white><message>";
|
||||||
public static String URLFORMAT = "<click:OPEN_URL:<clickurl>><url></click>";
|
public static String URLFORMAT = "<click:OPEN_URL:<clickurl>><url></click>";
|
||||||
|
|
||||||
private static void Chat() {
|
private static void Chat() {
|
||||||
@@ -237,7 +242,8 @@ public final class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> GACECOMMANDALIASES = new ArrayList<>();
|
public static List<String> GACECOMMANDALIASES = new ArrayList<>();
|
||||||
public static String GACFORMAT = "<hover:show_text:Click to reply><click:suggest_command:/acg ><yellow>(<sender> on <server> -> Team)</hover> <message>";
|
public static String GACFORMAT =
|
||||||
|
"<hover:show_text:Click to reply><click:suggest_command:/acg ><yellow>(<sender> on <server> -> Team)</hover> <message>";
|
||||||
|
|
||||||
private static void globalAdminChat() {
|
private static void globalAdminChat() {
|
||||||
GACECOMMANDALIASES = getList("commands.globaladminchat.aliases", Lists.newArrayList("acg"));
|
GACECOMMANDALIASES = getList("commands.globaladminchat.aliases", Lists.newArrayList("acg"));
|
||||||
@@ -269,12 +275,14 @@ public final class Config {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String PARTY_FORMAT = "<dark_aqua>(<gray><sender></gray><hover:show_text:\"on <server>\"> → <party></hover>) <message>";
|
public static String PARTY_FORMAT =
|
||||||
public static String PARTY_SPY = "<i><gray>PC:</gray><dark_gray> <dark_gray><username></dark_gray>: <dark_gray><party></dark_gray> <message></dark_gray></i>";
|
"<dark_aqua>(<gray><sender></gray><hover:show_text:\"on <server>\"> → <party></hover>) <message>";
|
||||||
|
public static String PARTY_SPY =
|
||||||
|
"<i><gray>PC:</gray><dark_gray> <dark_gray><username></dark_gray>: <dark_gray><party></dark_gray> <message></dark_gray></i>";
|
||||||
public static String NO_PERMISSION = "<red>You don't have permission to use this command.</red>";
|
public static String NO_PERMISSION = "<red>You don't have permission to use this command.</red>";
|
||||||
public static String NO_CONSOLE = "<red>This command can not be used by console</red>";
|
public static String NO_CONSOLE = "<red>This command can not be used by console</red>";
|
||||||
public static String CREATED_PARTY = "<green>You created a chat party called: " +
|
public static String CREATED_PARTY = "<green>You created a chat party called: " +
|
||||||
"'<gold><party_name></gold>' with the password: '<gold><party_password></gold>'</green>";
|
"'<gold><party_name></gold>' with the password: '<gold><party_password></gold>'</green>";
|
||||||
public static String NOT_IN_A_PARTY = "<red>You're not in a chat party.</red>";
|
public static String NOT_IN_A_PARTY = "<red>You're not in a chat party.</red>";
|
||||||
public static String NOT_YOUR_PARTY = "<red>You don't own this chat party.</red>";
|
public static String NOT_YOUR_PARTY = "<red>You don't own this chat party.</red>";
|
||||||
public static String NOT_A_PARTY = "<red>This chat party does not exist.</red>";
|
public static String NOT_A_PARTY = "<red>This chat party does not exist.</red>";
|
||||||
@@ -284,9 +292,11 @@ public final class Config {
|
|||||||
public static String INVALID_PASSWORD = "<red>Invalid password.</red>";
|
public static String INVALID_PASSWORD = "<red>Invalid password.</red>";
|
||||||
public static String JOINED_PARTY = "<green>You joined <party_name>!</green>";
|
public static String JOINED_PARTY = "<green>You joined <party_name>!</green>";
|
||||||
public static String PLAYER_JOINED_PARTY = "<green><player_name> joined <party_name>!</green>";
|
public static String PLAYER_JOINED_PARTY = "<green><player_name> joined <party_name>!</green>";
|
||||||
public static String NOTIFY_FINDING_NEW_OWNER = "<dark_aqua>Since you own this chat party a new party owner will be chosen.<dark_aqua>";
|
public static String NOTIFY_FINDING_NEW_OWNER =
|
||||||
|
"<dark_aqua>Since you own this chat party a new party owner will be chosen.<dark_aqua>";
|
||||||
public static String LEFT_PARTY = "<green>You have left the chat party!</green>";
|
public static String LEFT_PARTY = "<green>You have left the chat party!</green>";
|
||||||
public static String OWNER_LEFT_PARTY = "<dark_aqua>[ChatParty]: <old_owner> left the chat party, the new party owner is <new_owner></dark_aqua>";
|
public static String OWNER_LEFT_PARTY =
|
||||||
|
"<dark_aqua>[ChatParty]: <old_owner> left the chat party, the new party owner is <new_owner></dark_aqua>";
|
||||||
public static String PLAYER_LEFT_PARTY = "<dark_aqua>[ChatParty]: <player_name> left the chat party!</dark_aqua>";
|
public static String PLAYER_LEFT_PARTY = "<dark_aqua>[ChatParty]: <player_name> left the chat party!</dark_aqua>";
|
||||||
public static String NEW_PARTY_OWNER = "<dark_aqua>[ChatParty]: <old_owner> transferred the party to <new_owner>!";
|
public static String NEW_PARTY_OWNER = "<dark_aqua>[ChatParty]: <old_owner> transferred the party to <new_owner>!";
|
||||||
public static String CANT_REMOVE_PARTY_OWNER = "<red>You can't remove yourself, please leave instead.</red>";
|
public static String CANT_REMOVE_PARTY_OWNER = "<red>You can't remove yourself, please leave instead.</red>";
|
||||||
@@ -297,14 +307,16 @@ public final class Config {
|
|||||||
public static String ALREADY_IN_THIS_PARTY = "<red>You're already in <party>!</red>";
|
public static String ALREADY_IN_THIS_PARTY = "<red>You're already in <party>!</red>";
|
||||||
public static String SENT_PARTY_INV = "<green>You send a chat party invite to <player>!</green>";
|
public static String SENT_PARTY_INV = "<green>You send a chat party invite to <player>!</green>";
|
||||||
public static String JOIN_PARTY_CLICK_MESSAGE = "<click:run_command:'/party join <party> <party_password>'>" +
|
public static String JOIN_PARTY_CLICK_MESSAGE = "<click:run_command:'/party join <party> <party_password>'>" +
|
||||||
"<dark_aqua>You received an invite to join <party>, click this message to accept.</dark_aqua></click>";
|
"<dark_aqua>You received an invite to join <party>, click this message to accept.</dark_aqua></click>";
|
||||||
public static String PARTY_MEMBER_LOGGED_ON = "<dark_aqua>[ChatParty] <player> joined Altitude...</dark_aqua>";
|
public static String PARTY_MEMBER_LOGGED_ON = "<dark_aqua>[ChatParty] <player> joined Altitude...</dark_aqua>";
|
||||||
public static String PARTY_MEMBER_LOGGED_OFF = "<dark_aqua>[ChatParty] <player> left Altitude...</dark_aqua>";
|
public static String PARTY_MEMBER_LOGGED_OFF = "<dark_aqua>[ChatParty] <player> left Altitude...</dark_aqua>";
|
||||||
public static String RENAMED_PARTY = "<dark_aqua>[ChatParty] <owner> changed the party name from <old_name> to <new_name>!</dark_aqua>";
|
public static String RENAMED_PARTY =
|
||||||
|
"<dark_aqua>[ChatParty] <owner> changed the party name from <old_name> to <new_name>!</dark_aqua>";
|
||||||
public static String CHANGED_PASSWORD = "<green>Password was set to <password></green>";
|
public static String CHANGED_PASSWORD = "<green>Password was set to <password></green>";
|
||||||
public static String DISBAND_PARTY_CONFIRM = "<green><bold>Are you sure you want to disband your party?</bold> " +
|
public static String DISBAND_PARTY_CONFIRM = "<green><bold>Are you sure you want to disband your party?</bold> " +
|
||||||
"Type <gold>/party disband confirm <party></gold> to confirm.";
|
"Type <gold>/party disband confirm <party></gold> to confirm.";
|
||||||
public static String DISBANDED_PARTY = "<dark_aqua>[ChatParty] <owner> has disbanded <party>, everyone has been removed.</dark_aqua>";
|
public static String DISBANDED_PARTY =
|
||||||
|
"<dark_aqua>[ChatParty] <owner> has disbanded <party>, everyone has been removed.</dark_aqua>";
|
||||||
public static String PARTY_INFO = """
|
public static String PARTY_INFO = """
|
||||||
<gold><bold>Chat party info</bold>:
|
<gold><bold>Chat party info</bold>:
|
||||||
</gold><green>Name: <dark_aqua><party></dark_aqua>
|
</gold><green>Name: <dark_aqua><party></dark_aqua>
|
||||||
@@ -353,16 +365,25 @@ public final class Config {
|
|||||||
|
|
||||||
public static String PARTY_HELP_WRAPPER = "<gold>ChatParty help:\n<commands></gold>";
|
public static String PARTY_HELP_WRAPPER = "<gold>ChatParty help:\n<commands></gold>";
|
||||||
public static String PARTY_HELP_HELP = "<green>Show this menu: <gold>/party help</gold></green>";
|
public static String PARTY_HELP_HELP = "<green>Show this menu: <gold>/party help</gold></green>";
|
||||||
public static String PARTY_HELP_CREATE = "<green>Create a party: <gold>/party create <party_name> <party_password></gold></green>";
|
public static String PARTY_HELP_CREATE =
|
||||||
public static String PARTY_HELP_INFO = "<green>Show info about your current party: <gold>/party info</gold></green>";
|
"<green>Create a party: <gold>/party create <party_name> <party_password></gold></green>";
|
||||||
public static String PARTY_HELP_INVITE = "<green>Invite a user to your party: <gold>/party invite <username></gold></green>";
|
public static String PARTY_HELP_INFO =
|
||||||
public static String PARTY_HELP_JOIN = "<green>Join a party: <gold>/party join <party_name> <party_password></gold></green>";
|
"<green>Show info about your current party: <gold>/party info</gold></green>";
|
||||||
|
public static String PARTY_HELP_INVITE =
|
||||||
|
"<green>Invite a user to your party: <gold>/party invite <username></gold></green>";
|
||||||
|
public static String PARTY_HELP_JOIN =
|
||||||
|
"<green>Join a party: <gold>/party join <party_name> <party_password></gold></green>";
|
||||||
public static String PARTY_HELP_LEAVE = "<green>Leave your current party: <gold>/party leave</gold></green>";
|
public static String PARTY_HELP_LEAVE = "<green>Leave your current party: <gold>/party leave</gold></green>";
|
||||||
public static String PARTY_HELP_NAME = "<green>Change the name of your party: <gold>/party name <new_name></gold></green>";
|
public static String PARTY_HELP_NAME =
|
||||||
public static String PARTY_HELP_OWNER = "<green>Change the owner of your party: <gold>/party owner <new_owner_name></gold></green>";
|
"<green>Change the name of your party: <gold>/party name <new_name></gold></green>";
|
||||||
public static String PARTY_HELP_PASSWORD = "<green>Change the password of your party: <gold>/party password <new_password></gold></green>";
|
public static String PARTY_HELP_OWNER =
|
||||||
public static String PARTY_HELP_REMOVE = "<green>Remove a member from your party: <gold>/party remove <member_name></gold></green>";
|
"<green>Change the owner of your party: <gold>/party owner <new_owner_name></gold></green>";
|
||||||
public static String PARTY_HELP_DISBAND = "<green>Remove everyone from your party and disband it: <gold>/party disband</gold></green>";
|
public static String PARTY_HELP_PASSWORD =
|
||||||
|
"<green>Change the password of your party: <gold>/party password <new_password></gold></green>";
|
||||||
|
public static String PARTY_HELP_REMOVE =
|
||||||
|
"<green>Remove a member from your party: <gold>/party remove <member_name></gold></green>";
|
||||||
|
public static String PARTY_HELP_DISBAND =
|
||||||
|
"<green>Remove everyone from your party and disband it: <gold>/party disband</gold></green>";
|
||||||
public static String PARTY_HELP_CHAT = "<green>Talk in party chat: <gold>/p <message></gold></green>";
|
public static String PARTY_HELP_CHAT = "<green>Talk in party chat: <gold>/p <message></gold></green>";
|
||||||
|
|
||||||
private static void partyHelp() {
|
private static void partyHelp() {
|
||||||
@@ -385,12 +406,14 @@ public final class Config {
|
|||||||
public static ComponentLike TOGGLED_ON = null;
|
public static ComponentLike TOGGLED_ON = null;
|
||||||
public static ComponentLike TOGGLED_OFF = null;
|
public static ComponentLike TOGGLED_OFF = null;
|
||||||
public static double LOCAL_DISTANCE;
|
public static double LOCAL_DISTANCE;
|
||||||
public static String CHANNEL_SPY = "<i><gray>SPY:</gray> <dark_gray>(<dark_gray><sender> → <channel>) <message></dark_gray>";
|
public static String CHANNEL_SPY =
|
||||||
|
"<i><gray>SPY:</gray> <dark_gray>(<dark_gray><sender> → <channel>) <message></dark_gray>";
|
||||||
|
|
||||||
private static void chatChannels() {
|
private static void chatChannels() {
|
||||||
ConfigurationNode node = getNode("chat-channels");
|
ConfigurationNode node = getNode("chat-channels");
|
||||||
if (node.empty()) {
|
if (node.empty()) {
|
||||||
getString("chat-channels.ac.format", "<white><gray><sender></gray> <hover:show_text:on <server>><yellow>to <channel></yellow></hover><gray>: <message>");
|
getString("chat-channels.ac.format",
|
||||||
|
"<white><gray><sender></gray> <hover:show_text:on <server>><yellow>to <channel></yellow></hover><gray>: <message>");
|
||||||
getList("chat-channels.ac.servers", List.of("lobby"));
|
getList("chat-channels.ac.servers", List.of("lobby"));
|
||||||
getBoolean("chat-channels.ac.proxy", false);
|
getBoolean("chat-channels.ac.proxy", false);
|
||||||
node = getNode("chat-channels");
|
node = getNode("chat-channels");
|
||||||
@@ -400,15 +423,17 @@ public final class Config {
|
|||||||
String channelName = Objects.requireNonNull(configurationNode.key()).toString();
|
String channelName = Objects.requireNonNull(configurationNode.key()).toString();
|
||||||
String key = "chat-channels." + channelName + ".";
|
String key = "chat-channels." + channelName + ".";
|
||||||
new CustomChannel(channelName,
|
new CustomChannel(channelName,
|
||||||
getString(key + "format", ""),
|
getString(key + "format", ""),
|
||||||
getList(key + "servers", Collections.EMPTY_LIST),
|
getList(key + "servers", Collections.EMPTY_LIST),
|
||||||
getBoolean(key + "proxy", false),
|
getList(key + "alias", Collections.EMPTY_LIST),
|
||||||
getBoolean(key + "local", false)
|
getBoolean(key + "proxy", false),
|
||||||
|
getBoolean(key + "local", false)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_CHANNEL_TOGGLED = getString("chat-channels-messages.channel-toggled", CUSTOM_CHANNEL_TOGGLED);
|
CUSTOM_CHANNEL_TOGGLED = getString("chat-channels-messages.channel-toggled", CUSTOM_CHANNEL_TOGGLED);
|
||||||
TOGGLED_ON = Utility.parseMiniMessage(getString("chat-channels-messages.channel-on", "<green>on</green><gray>"));
|
TOGGLED_ON =
|
||||||
|
Utility.parseMiniMessage(getString("chat-channels-messages.channel-on", "<green>on</green><gray>"));
|
||||||
TOGGLED_OFF = Utility.parseMiniMessage(getString("chat-channels-messages.channel-off", "<red>off</red><gray>"));
|
TOGGLED_OFF = Utility.parseMiniMessage(getString("chat-channels-messages.channel-off", "<red>off</red><gray>"));
|
||||||
LOCAL_DISTANCE = getDouble("chat-channels-messages.local-distance", 200.0);
|
LOCAL_DISTANCE = getDouble("chat-channels-messages.local-distance", 200.0);
|
||||||
CHANNEL_SPY = getString("chat-channels-messages.spy", CHANNEL_SPY);
|
CHANNEL_SPY = getString("chat-channels-messages.spy", CHANNEL_SPY);
|
||||||
@@ -443,12 +468,16 @@ public final class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String mailHeader = "===== List Mails ====='";
|
public static String mailHeader = "===== List Mails ====='";
|
||||||
public static String mailBody = "<white>From:</white> [<staffprefix>] <sender> <white><hover:show_text:'<date>'><time_ago> day(s) ago</hover>: </white><message>";
|
public static String mailBody =
|
||||||
|
"<white>From:</white> [<staffprefix>] <sender> <white><hover:show_text:'<date>'><time_ago> day(s) ago</hover>: </white><message>";
|
||||||
public static String mailFooter = "======================";
|
public static String mailFooter = "======================";
|
||||||
public static String mailNoUser = "<red>A player with this name hasn't logged in recently.";
|
public static String mailNoUser = "<red>A player with this name hasn't logged in recently.";
|
||||||
public static String mailReceived = "<yellow><click:run_command:/mail list unread>New mail from <sender>, click to view</click></yellow>";
|
public static String mailReceived =
|
||||||
public static String mailUnread = "<green><click:run_command:/mail list unread>You have <amount> unread mail, click to view it.</click></green>";
|
"<yellow><click:run_command:/mail list unread>New mail from <sender>, click to view</click></yellow>";
|
||||||
public static String mailSent = "<green>Successfully send mail to <player_name></green>: <#2e8b57><message></#2e8b57>";
|
public static String mailUnread =
|
||||||
|
"<green><click:run_command:/mail list unread>You have <amount> unread mail, click to view it.</click></green>";
|
||||||
|
public static String mailSent =
|
||||||
|
"<green>Successfully send mail to <player_name></green>: <#2e8b57><message></#2e8b57>";
|
||||||
public static List<String> mailCommandAlias = new ArrayList<>();
|
public static List<String> mailCommandAlias = new ArrayList<>();
|
||||||
public static int mailDisplayDelay = 5;
|
public static int mailDisplayDelay = 5;
|
||||||
|
|
||||||
@@ -464,8 +493,10 @@ public final class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String, Long> serverChannelId = new HashMap<>();
|
public static HashMap<String, Long> serverChannelId = new HashMap<>();
|
||||||
public static String REPORT_SENT = "<green>Your report was sent, staff will contact you asap to help resolve your issue!</green>";
|
public static String REPORT_SENT =
|
||||||
public static String REPORT_TOO_SHORT = "<red>Please ensure your report is descriptive. We require at least 3 words per report</red>";
|
"<green>Your report was sent, staff will contact you asap to help resolve your issue!</green>";
|
||||||
|
public static String REPORT_TOO_SHORT =
|
||||||
|
"<red>Please ensure your report is descriptive. We require at least 3 words per report</red>";
|
||||||
|
|
||||||
private static void loadChannelIds() {
|
private static void loadChannelIds() {
|
||||||
serverChannelId.clear();
|
serverChannelId.clear();
|
||||||
@@ -500,7 +531,8 @@ public final class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String HELP_REPORT = "<red>/report <message></red>";
|
public static String HELP_REPORT = "<red>/report <message></red>";
|
||||||
public static String FIRST_JOIN = "<green>* Welcome <light_purple><player></light_purple> to Altitude! They've joined for the first time.</green>";
|
public static String FIRST_JOIN =
|
||||||
|
"<green>* Welcome <light_purple><player></light_purple> to Altitude! They've joined for the first time.</green>";
|
||||||
|
|
||||||
private static void loadMessages() {
|
private static void loadMessages() {
|
||||||
HELP_REPORT = getString("settings.mail.mail-sent", HELP_REPORT);
|
HELP_REPORT = getString("settings.mail.mail-sent", HELP_REPORT);
|
||||||
@@ -509,7 +541,8 @@ public final class Config {
|
|||||||
|
|
||||||
public static String EMOTELIST_HEADER = "<bold>Available Chat Emotes</bold><newline>";
|
public static String EMOTELIST_HEADER = "<bold>Available Chat Emotes</bold><newline>";
|
||||||
public static String EMOTELIST_ITEM = "<insert:\"<regex>\"><gold><regex></gold> : <emote></insert><newline>";
|
public static String EMOTELIST_ITEM = "<insert:\"<regex>\"><gold><regex></gold> : <emote></insert><newline>";
|
||||||
public static String EMOTELIST_FOOTER = "<green>----<< <gray>Prev</gray> <page> <gray>/</gray> <pages> <gray>Next</gray> >>----";
|
public static String EMOTELIST_FOOTER =
|
||||||
|
"<green>----<< <gray>Prev</gray> <page> <gray>/</gray> <pages> <gray>Next</gray> >>----";
|
||||||
|
|
||||||
private static void emoteListCommand() {
|
private static void emoteListCommand() {
|
||||||
EMOTELIST_HEADER = getString("commands.emotelist.header", EMOTELIST_HEADER);
|
EMOTELIST_HEADER = getString("commands.emotelist.header", EMOTELIST_HEADER);
|
||||||
@@ -521,31 +554,41 @@ public final class Config {
|
|||||||
public static String NICK_CHANGED = "<yellow>Your nickname was changed to <nickname><yellow>.";
|
public static String NICK_CHANGED = "<yellow>Your nickname was changed to <nickname><yellow>.";
|
||||||
public static String NICK_NOT_CHANGED = "<yellow>Your nickname request was denied.";
|
public static String NICK_NOT_CHANGED = "<yellow>Your nickname request was denied.";
|
||||||
public static String NICK_RESET = "<yellow>Nickname changed back to normal.";
|
public static String NICK_RESET = "<yellow>Nickname changed back to normal.";
|
||||||
public static String NICK_CHANGED_OTHERS = "<gold><targetplayer><yellow>'s nickname was changed to <nickname><yellow>.";
|
public static String NICK_CHANGED_OTHERS =
|
||||||
public static String NICK_TARGET_NICK_CHANGE = "<yellow>Your nickname was changed to <nickname> <yellow>by <sendernick><yellow>";
|
"<gold><targetplayer><yellow>'s nickname was changed to <nickname><yellow>.";
|
||||||
|
public static String NICK_TARGET_NICK_CHANGE =
|
||||||
|
"<yellow>Your nickname was changed to <nickname> <yellow>by <sendernick><yellow>";
|
||||||
public static String NICK_RESET_OTHERS = "<gold><player><gold>'s <yellow>nickname was reset back to normal.";
|
public static String NICK_RESET_OTHERS = "<gold><player><gold>'s <yellow>nickname was reset back to normal.";
|
||||||
public static String NICK_INVALID_CHARACTERS = "<yellow>You can only use letters and numbers in nicknames.";
|
public static String NICK_INVALID_CHARACTERS = "<yellow>You can only use letters and numbers in nicknames.";
|
||||||
public static String NICK_INVALID_LENGTH = "<yellow>Nicknames need to be between 3 to 16 characters long.";
|
public static String NICK_INVALID_LENGTH = "<yellow>Nicknames need to be between 3 to 16 characters long.";
|
||||||
public static String NICK_PLAYER_NOT_ONLINE = "<red>That player is not online.";
|
public static String NICK_PLAYER_NOT_ONLINE = "<red>That player is not online.";
|
||||||
public static String NICK_BLOCKED_COLOR_CODES = "<yellow>You have blocked color codes in that nickname.";
|
public static String NICK_BLOCKED_COLOR_CODES = "<yellow>You have blocked color codes in that nickname.";
|
||||||
public static String NICK_USER_NOT_FOUND = "<red>Failed to set nickname from player, try again from a server this player has been on before.";
|
public static String NICK_USER_NOT_FOUND =
|
||||||
public static String NICK_ACCEPTED = "<green>You accepted <targetplayer><green>'s nickname. They are now called <newnick><green>.";
|
"<red>Failed to set nickname from player, try again from a server this player has been on before.";
|
||||||
public static String NICK_DENIED = "<green>You denied <targetplayer><green>'s nickname. They are still called <oldnick><green>.";
|
public static String NICK_ACCEPTED =
|
||||||
|
"<green>You accepted <targetplayer><green>'s nickname. They are now called <newnick><green>.";
|
||||||
|
public static String NICK_DENIED =
|
||||||
|
"<green>You denied <targetplayer><green>'s nickname. They are still called <oldnick><green>.";
|
||||||
public static String NICK_ALREADY_HANDLED = "<red><targetplayer><red>'s nickname was already accepted or denied.";
|
public static String NICK_ALREADY_HANDLED = "<red><targetplayer><red>'s nickname was already accepted or denied.";
|
||||||
public static String NICK_NO_LUCKPERMS = "<red>Due to an issue with LuckPerms /nick try won't work at the moment.";
|
public static String NICK_NO_LUCKPERMS = "<red>Due to an issue with LuckPerms /nick try won't work at the moment.";
|
||||||
public static String NICK_TOO_SOON = "<red>Please wait <time><red> until requesting a new nickname";
|
public static String NICK_TOO_SOON = "<red>Please wait <time><red> until requesting a new nickname";
|
||||||
public static String NICK_REQUEST_PLACED = "<green>Replaced your previous request <oldrequestednick><green> with <newrequestednick><green>.";
|
public static String NICK_REQUEST_PLACED =
|
||||||
|
"<green>Replaced your previous request <oldrequestednick><green> with <newrequestednick><green>.";
|
||||||
public static String NICK_REQUEST_NEW = "<green>New nickname request by <player><green>!";
|
public static String NICK_REQUEST_NEW = "<green>New nickname request by <player><green>!";
|
||||||
public static String NICK_TRYOUT = "<white><prefix><white> <nick><gray>: <white><click:suggest_command:/nick request <nickrequest>>Hi, this is what my new nickname could look like! Click this message to request.";
|
public static String NICK_TRYOUT =
|
||||||
public static String NICK_REQUESTED = "<green>Your requested to be nicknamed <nick><green> has been received. Staff will accept or deny this request asap!";
|
"<white><prefix><white> <nick><gray>: <white><click:suggest_command:/nick request <nickrequest>>Hi, this is what my new nickname could look like! Click this message to request.";
|
||||||
|
public static String NICK_REQUESTED =
|
||||||
|
"<green>Your requested to be nicknamed <nick><green> has been received. Staff will accept or deny this request asap!";
|
||||||
public static String NICK_REVIEW_WAITING = "<green>There are <amount> nicknames waiting for review!";
|
public static String NICK_REVIEW_WAITING = "<green>There are <amount> nicknames waiting for review!";
|
||||||
public static String NICK_TAKEN = "<red>Someone else already has this nickname, or has this name as their username.";
|
public static String NICK_TAKEN =
|
||||||
|
"<red>Someone else already has this nickname, or has this name as their username.";
|
||||||
public static String NICK_REQUESTS_ON_LOGIN = "<green>Current nick requests: <amount>";
|
public static String NICK_REQUESTS_ON_LOGIN = "<green>Current nick requests: <amount>";
|
||||||
public static long NICK_WAIT_TIME = 86400000;
|
public static long NICK_WAIT_TIME = 86400000;
|
||||||
public static List<String> NICK_ITEM_LORE = new ArrayList<>();
|
public static List<String> NICK_ITEM_LORE = new ArrayList<>();
|
||||||
public static List<String> NICK_BLOCKED_COLOR_CODESLIST = new ArrayList<>();
|
public static List<String> NICK_BLOCKED_COLOR_CODESLIST = new ArrayList<>();
|
||||||
public static List<String> NICK_ALLOWED_COLOR_CODESLIST = new ArrayList<>();
|
public static List<String> NICK_ALLOWED_COLOR_CODESLIST = new ArrayList<>();
|
||||||
public static String NICK_CURRENT = "<gold>Current nickname: <nickname><white>(<insert:\"<currentnickname>\"><currentnickname></insert>)";
|
public static String NICK_CURRENT =
|
||||||
|
"<gold>Current nickname: <nickname><white>(<insert:\"<currentnickname>\"><currentnickname></insert>)";
|
||||||
|
|
||||||
private static void nicknameSettings() {
|
private static void nicknameSettings() {
|
||||||
NICK_CHANGED = getString("nicknames.messages.nick-changed", NICK_CHANGED);
|
NICK_CHANGED = getString("nicknames.messages.nick-changed", NICK_CHANGED);
|
||||||
@@ -572,9 +615,13 @@ public final class Config {
|
|||||||
NICK_TAKEN = getString("nicknames.messages.nick-taken", NICK_TAKEN);
|
NICK_TAKEN = getString("nicknames.messages.nick-taken", NICK_TAKEN);
|
||||||
NICK_REQUESTS_ON_LOGIN = getString("nicknames.messages.nick-reauests-on-login", NICK_REQUESTS_ON_LOGIN);
|
NICK_REQUESTS_ON_LOGIN = getString("nicknames.messages.nick-reauests-on-login", NICK_REQUESTS_ON_LOGIN);
|
||||||
NICK_WAIT_TIME = getLong("nicknames.wait-time", NICK_WAIT_TIME);
|
NICK_WAIT_TIME = getLong("nicknames.wait-time", NICK_WAIT_TIME);
|
||||||
NICK_ITEM_LORE = getList("nicknames.item-lore", List.of("<aqua>New nick: <newnick>", "<aqua>Old nick: <oldnick>", "<aqua>Last changed: <lastchanged>", "<green>Left click to Accept <light_purple>| <red>Right click to Deny"));
|
NICK_ITEM_LORE = getList("nicknames.item-lore",
|
||||||
|
List.of("<aqua>New nick: <newnick>", "<aqua>Old nick: <oldnick>", "<aqua>Last changed: <lastchanged>",
|
||||||
|
"<green>Left click to Accept <light_purple>| <red>Right click to Deny"));
|
||||||
NICK_BLOCKED_COLOR_CODESLIST = getList("nicknames.blocked-color-codes", List.of("&k", "&l", "&n", "&m", "&o"));
|
NICK_BLOCKED_COLOR_CODESLIST = getList("nicknames.blocked-color-codes", List.of("&k", "&l", "&n", "&m", "&o"));
|
||||||
NICK_ALLOWED_COLOR_CODESLIST = getList("nicknames.allowed-color-codes", List.of("&0", "&1", "&2", "&3", "&4", "&5", "&6", "&7", "&8", "&9", "&a", "&b", "&c", "&d", "&e", "&f", "&r"));
|
NICK_ALLOWED_COLOR_CODESLIST = getList("nicknames.allowed-color-codes",
|
||||||
|
List.of("&0", "&1", "&2", "&3", "&4", "&5", "&6", "&7", "&8", "&9", "&a", "&b", "&c", "&d", "&e", "&f",
|
||||||
|
"&r"));
|
||||||
NICK_CURRENT = getString("nicknames.messages.nick-current", NICK_CURRENT);
|
NICK_CURRENT = getString("nicknames.messages.nick-current", NICK_CURRENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,7 +630,8 @@ public final class Config {
|
|||||||
|
|
||||||
private static void deathMessagesSettings() {
|
private static void deathMessagesSettings() {
|
||||||
DEATH_MESSAGES_MAX_PER_PERIOD = getInt("death-messages.max-per-period", DEATH_MESSAGES_MAX_PER_PERIOD);
|
DEATH_MESSAGES_MAX_PER_PERIOD = getInt("death-messages.max-per-period", DEATH_MESSAGES_MAX_PER_PERIOD);
|
||||||
DEATH_MESSAGES_LIMIT_PERIOD_MINUTES = getInt("death-messages.limit-period-minutes", DEATH_MESSAGES_LIMIT_PERIOD_MINUTES);
|
DEATH_MESSAGES_LIMIT_PERIOD_MINUTES =
|
||||||
|
getInt("death-messages.limit-period-minutes", DEATH_MESSAGES_LIMIT_PERIOD_MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long CHAT_LOG_DELETE_OLDER_THAN_DAYS = 31;
|
public static long CHAT_LOG_DELETE_OLDER_THAN_DAYS = 31;
|
||||||
|
|||||||
@@ -1,19 +1,27 @@
|
|||||||
package com.alttd.chat.objects.channels;
|
package com.alttd.chat.objects.channels;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.List;
|
||||||
|
|
||||||
public class CustomChannel extends Channel {
|
public class CustomChannel extends Channel {
|
||||||
private final List<String> servers;
|
private final List<String> servers;
|
||||||
|
private final List<String> aliases;
|
||||||
|
|
||||||
public CustomChannel(String channelName, String format, List<String> servers, boolean proxy, boolean local) {
|
public CustomChannel(String channelName, String format, List<String> servers, List<String> aliases, boolean proxy,
|
||||||
|
boolean local) {
|
||||||
super(channelName, format, proxy, local);
|
super(channelName, format, proxy, local);
|
||||||
this.permission = "chat.channel." + channelName.toLowerCase();
|
this.permission = "chat.channel." + channelName.toLowerCase();
|
||||||
this.channelName = channelName;
|
this.channelName = channelName;
|
||||||
this.format = format;
|
this.format = format;
|
||||||
this.servers = servers;
|
this.servers = servers;
|
||||||
this.proxy = proxy;
|
this.proxy = proxy;
|
||||||
|
this.aliases = aliases;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getServers() {
|
public List<String> getServers() {
|
||||||
return servers;
|
return servers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getAliases() {
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,18 @@ plugins {
|
|||||||
id("io.github.goooler.shadow")
|
id("io.github.goooler.shadow")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val nexusUser = providers.gradleProperty("alttdSnapshotUsername").orNull ?: System.getenv("NEXUS_USERNAME")
|
||||||
|
val nexusPass = providers.gradleProperty("alttdSnapshotPassword").orNull ?: System.getenv("NEXUS_PASSWORD")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":api")) // API
|
implementation(project(":api")) // API
|
||||||
compileOnly("com.alttd.cosmos:cosmos-api:1.21.6-R0.1-SNAPSHOT") {
|
compileOnly("com.alttd.cosmos:cosmos-api:1.21.8-R0.1-SNAPSHOT") {
|
||||||
isChanging = true
|
isChanging = true
|
||||||
}
|
}
|
||||||
compileOnly("com.gitlab.ruany:LiteBansAPI:0.6.1") // move to proxy
|
compileOnly("com.gitlab.ruany:LiteBansAPI:0.6.1") // move to proxy
|
||||||
compileOnly("org.apache.commons:commons-lang3:3.17.0") // needs an alternative, already removed from upstream api and will be removed in server
|
compileOnly("org.apache.commons:commons-lang3:3.17.0") // needs an alternative, already removed from upstream api and will be removed in server
|
||||||
compileOnly("net.luckperms:api:5.5") // Luckperms
|
compileOnly("net.luckperms:api:5.5") // Luckperms
|
||||||
|
implementation("com.alttd.inventory_gui:InventoryGUI:1.1.5-SNAPSHOT")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ChatChannel extends BukkitCommand {
|
public class ChatChannel extends BukkitCommand {
|
||||||
@@ -28,7 +27,7 @@ public class ChatChannel extends BukkitCommand {
|
|||||||
this.command = channel.getChannelName().toLowerCase();
|
this.command = channel.getChannelName().toLowerCase();
|
||||||
this.description = "Chat channel named " + channel.getChannelName() + ".";
|
this.description = "Chat channel named " + channel.getChannelName() + ".";
|
||||||
this.usageMessage = "/" + command + " <message>";
|
this.usageMessage = "/" + command + " <message>";
|
||||||
this.setAliases(Collections.emptyList());
|
this.setAliases(channel.getAliases());
|
||||||
activeCommands.add(this);
|
activeCommands.add(this);
|
||||||
this.toggleableForCustomChannel = new ToggleableForCustomChannel(channel);
|
this.toggleableForCustomChannel = new ToggleableForCustomChannel(channel);
|
||||||
}
|
}
|
||||||
@@ -43,7 +42,7 @@ public class ChatChannel extends BukkitCommand {
|
|||||||
player.sendRichMessage(Config.CUSTOM_CHANNEL_TOGGLED, TagResolver.resolver(
|
player.sendRichMessage(Config.CUSTOM_CHANNEL_TOGGLED, TagResolver.resolver(
|
||||||
Placeholder.unparsed("channel", channel.getChannelName()),
|
Placeholder.unparsed("channel", channel.getChannelName()),
|
||||||
Placeholder.component("status", toggleableForCustomChannel.toggle(player.getUniqueId())
|
Placeholder.component("status", toggleableForCustomChannel.toggle(player.getUniqueId())
|
||||||
? Config.TOGGLED_ON : Config.TOGGLED_OFF)));
|
? Config.TOGGLED_ON : Config.TOGGLED_OFF)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class PluginMessage implements PluginMessageListener {
|
|||||||
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
|
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
|
||||||
String subChannel = in.readUTF();
|
String subChannel = in.readUTF();
|
||||||
switch (subChannel) {
|
switch (subChannel) {
|
||||||
case "privatemessagein": {
|
case "privatemessagein" -> {
|
||||||
UUID uuid = UUID.fromString(in.readUTF());
|
UUID uuid = UUID.fromString(in.readUTF());
|
||||||
String target = in.readUTF();
|
String target = in.readUTF();
|
||||||
Player player = Bukkit.getPlayer(uuid);
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
@@ -49,14 +49,15 @@ public class PluginMessage implements PluginMessageListener {
|
|||||||
ChatUser chatUser = ChatUserManager.getChatUser(uuid);
|
ChatUser chatUser = ChatUserManager.getChatUser(uuid);
|
||||||
if (isTargetNotIgnored(chatUser, targetuuid)) {
|
if (isTargetNotIgnored(chatUser, targetuuid)) {
|
||||||
player.sendMessage(GsonComponentSerializer.gson().deserialize(message));
|
player.sendMessage(GsonComponentSerializer.gson().deserialize(message));
|
||||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1, 1); // todo load this from config
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1,
|
||||||
|
1); // todo load this from config
|
||||||
ChatUser user = ChatUserManager.getChatUser(uuid);
|
ChatUser user = ChatUserManager.getChatUser(uuid);
|
||||||
if (!user.getReplyContinueTarget().equalsIgnoreCase(target)) {
|
if (!user.getReplyContinueTarget().equalsIgnoreCase(target)) {
|
||||||
user.setReplyTarget(target);
|
user.setReplyTarget(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "privatemessageout": {
|
case "privatemessageout" -> {
|
||||||
UUID uuid = UUID.fromString(in.readUTF());
|
UUID uuid = UUID.fromString(in.readUTF());
|
||||||
String target = in.readUTF();
|
String target = in.readUTF();
|
||||||
Player player = Bukkit.getPlayer(uuid);
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
@@ -72,9 +73,8 @@ public class PluginMessage implements PluginMessageListener {
|
|||||||
// ChatUser user = ChatUserManager.getChatUser(uuid);
|
// ChatUser user = ChatUserManager.getChatUser(uuid);
|
||||||
// user.setReplyTarget(target);
|
// user.setReplyTarget(target);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "globalchat": {
|
case "globalchat" -> {
|
||||||
if (!ChatPlugin.getInstance().serverGlobalChatEnabled() || ChatPlugin.getInstance().serverMuted()) {
|
if (!ChatPlugin.getInstance().serverGlobalChatEnabled() || ChatPlugin.getInstance().serverMuted()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -88,31 +88,27 @@ public class PluginMessage implements PluginMessageListener {
|
|||||||
p.sendMessage(GsonComponentSerializer.gson().deserialize(message));
|
p.sendMessage(GsonComponentSerializer.gson().deserialize(message));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "ignore": {
|
case "ignore" -> {
|
||||||
ChatUser chatUser = ChatUserManager.getChatUser(UUID.fromString(in.readUTF()));
|
ChatUser chatUser = ChatUserManager.getChatUser(UUID.fromString(in.readUTF()));
|
||||||
UUID targetUUID = UUID.fromString(in.readUTF());
|
UUID targetUUID = UUID.fromString(in.readUTF());
|
||||||
|
|
||||||
if (!chatUser.getIgnoredPlayers().contains(targetUUID)) {
|
if (!chatUser.getIgnoredPlayers().contains(targetUUID)) {
|
||||||
chatUser.addIgnoredPlayers(targetUUID);
|
chatUser.addIgnoredPlayers(targetUUID);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "unignore": {
|
case "unignore" -> {
|
||||||
ChatUser chatUser = ChatUserManager.getChatUser(UUID.fromString(in.readUTF()));
|
ChatUser chatUser = ChatUserManager.getChatUser(UUID.fromString(in.readUTF()));
|
||||||
chatUser.removeIgnoredPlayers(UUID.fromString(in.readUTF()));
|
chatUser.removeIgnoredPlayers(UUID.fromString(in.readUTF()));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "chatchannel": {
|
case "chatchannel" -> {
|
||||||
if (ChatPlugin.getInstance().serverMuted()) {
|
if (ChatPlugin.getInstance().serverMuted()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
chatChannel(in);
|
chatChannel(in);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "tmppartyupdate": {
|
case "tmppartyupdate" -> {
|
||||||
int id = Integer.parseInt(in.readUTF());
|
int id = Integer.parseInt(in.readUTF());
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -120,9 +116,8 @@ public class PluginMessage implements PluginMessageListener {
|
|||||||
Queries.loadPartyUsers(id);
|
Queries.loadPartyUsers(id);
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "partylogin": {
|
case "partylogin" -> {
|
||||||
int id = Integer.parseInt(in.readUTF());
|
int id = Integer.parseInt(in.readUTF());
|
||||||
Party party = PartyManager.getParty(id);
|
Party party = PartyManager.getParty(id);
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
@@ -135,18 +130,19 @@ public class PluginMessage implements PluginMessageListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
PartyUser user = party.getPartyUser(uuid);
|
PartyUser user = party.getPartyUser(uuid);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
ComponentLike component = Utility.parseMiniMessage("<dark_aqua>* " + user.getPlayerName() + " logged in to Altitude.");
|
ComponentLike component = Utility.parseMiniMessage(
|
||||||
|
"<dark_aqua>* " + user.getPlayerName() + " logged in to Altitude.");
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().stream()
|
Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(p -> party.getPartyUsersUuid().contains(p.getUniqueId()))
|
.filter(p -> party.getPartyUsersUuid().contains(p.getUniqueId()))
|
||||||
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers().contains(uuid))
|
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers()
|
||||||
|
.contains(uuid))
|
||||||
.forEach(p -> p.sendMessage(component));
|
.forEach(p -> p.sendMessage(component));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "partylogout": {
|
case "partylogout" -> {
|
||||||
int id = Integer.parseInt(in.readUTF());
|
int id = Integer.parseInt(in.readUTF());
|
||||||
Party party = PartyManager.getParty(id);
|
Party party = PartyManager.getParty(id);
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
@@ -159,21 +155,20 @@ public class PluginMessage implements PluginMessageListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
PartyUser user = party.getPartyUser(uuid);
|
PartyUser user = party.getPartyUser(uuid);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
ComponentLike component = Utility.parseMiniMessage("<dark_aqua>* " + user.getPlayerName() + " logged out of Altitude.");
|
ComponentLike component = Utility.parseMiniMessage(
|
||||||
|
"<dark_aqua>* " + user.getPlayerName() + " logged out of Altitude.");
|
||||||
|
|
||||||
Bukkit.getOnlinePlayers().stream()
|
Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(p -> party.getPartyUsersUuid().contains(p.getUniqueId()))
|
.filter(p -> party.getPartyUsersUuid().contains(p.getUniqueId()))
|
||||||
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers().contains(uuid))
|
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers()
|
||||||
|
.contains(uuid))
|
||||||
.forEach(p -> p.sendMessage(component));
|
.forEach(p -> p.sendMessage(component));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "reloadconfig":
|
case "reloadconfig" -> ChatPlugin.getInstance().reloadConfig();
|
||||||
ChatPlugin.getInstance().reloadConfig();
|
case "chatpunishments" -> {
|
||||||
break;
|
|
||||||
case "chatpunishments":
|
|
||||||
UUID uuid = UUID.fromString(in.readUTF());
|
UUID uuid = UUID.fromString(in.readUTF());
|
||||||
boolean mute = in.readBoolean();
|
boolean mute = in.readBoolean();
|
||||||
ChatUser user = ChatUserManager.getChatUser(uuid);
|
ChatUser user = ChatUserManager.getChatUser(uuid);
|
||||||
@@ -181,9 +176,9 @@ public class PluginMessage implements PluginMessageListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.setMuted(mute);
|
user.setMuted(mute);
|
||||||
break;
|
}
|
||||||
default:
|
default -> {
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +215,8 @@ public class PluginMessage implements PluginMessageListener {
|
|||||||
public void run() {
|
public void run() {
|
||||||
Bukkit.getOnlinePlayers().stream()
|
Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(p -> p.hasPermission(finalChatChannel.getPermission()))
|
.filter(p -> p.hasPermission(finalChatChannel.getPermission()))
|
||||||
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers().contains(finalUuid))
|
.filter(p -> !ChatUserManager.getChatUser(p.getUniqueId()).getIgnoredPlayers()
|
||||||
|
.contains(finalUuid))
|
||||||
.forEach(p -> p.sendMessage(finalComponent));
|
.forEach(p -> p.sendMessage(finalComponent));
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||||
|
|||||||
@@ -45,89 +45,98 @@ public class Nicknames implements CommandExecutor, TabCompleter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||||
if (sender instanceof Player player) {
|
if (!(sender instanceof Player player)) {
|
||||||
if (args.length == 0) {
|
|
||||||
sender.sendRichMessage(helpMessage(sender, HelpType.ALL));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (args[0].toLowerCase()) {
|
|
||||||
case "set":
|
|
||||||
if (args.length == 2 && hasPermission(sender, "chat.command.nick.set")) {
|
|
||||||
handleNick(player, player, args[1]);
|
|
||||||
} else if (args.length == 3 && hasPermission(sender, "chat.command.nick.set.others")) {
|
|
||||||
OfflinePlayer offlinePlayer = sender.getServer().getOfflinePlayer(args[1]);
|
|
||||||
|
|
||||||
if (offlinePlayer.isOnline() || offlinePlayer.hasPlayedBefore()) {
|
|
||||||
handleNick(player, offlinePlayer, args[2]);
|
|
||||||
} else {
|
|
||||||
sender.sendRichMessage(helpMessage(sender, HelpType.SET_OTHERS));
|
|
||||||
}
|
|
||||||
} else if (args.length > 3) {
|
|
||||||
sender.sendRichMessage(helpMessage(sender, HelpType.SET_SELF, HelpType.SET_OTHERS));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "review":
|
|
||||||
if (args.length == 1 && hasPermission(sender, "chat.command.nick.review")) {
|
|
||||||
NicknamesGui nicknamesGui = new NicknamesGui();
|
|
||||||
ChatPlugin.getInstance().getServer().getPluginManager().registerEvents(nicknamesGui, ChatPlugin.getInstance());
|
|
||||||
nicknamesGui.openInventory(player);
|
|
||||||
} else {
|
|
||||||
sender.sendRichMessage(helpMessage(sender, HelpType.REVIEW));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "request":
|
|
||||||
if (args.length == 2 && hasPermission(sender, "chat.command.nick.request")) {
|
|
||||||
new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
handleNickRequest(player, args[1]);
|
|
||||||
}
|
|
||||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
|
||||||
} else {
|
|
||||||
sender.sendRichMessage(helpMessage(sender, HelpType.REQUEST));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "try":
|
|
||||||
if (args.length == 2 && hasPermission(sender, "chat.command.nick.try")) {
|
|
||||||
LuckPerms api = ChatAPI.get().getLuckPerms();
|
|
||||||
if (api != null) {
|
|
||||||
if (NickUtilities.validNick(player, player, args[1])) {
|
|
||||||
sender.sendRichMessage(Config.NICK_TRYOUT,
|
|
||||||
Placeholder.component("prefix", Utility.applyColor(api.getUserManager().getUser(player.getUniqueId())
|
|
||||||
.getCachedData().getMetaData().getPrefix())), // TODO pull this from chatuser?
|
|
||||||
Placeholder.component("nick", Utility.applyColor(args[1])),
|
|
||||||
Placeholder.unparsed("nickrequest", args[1]));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sender.sendRichMessage(Config.NICK_NO_LUCKPERMS);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sender.sendRichMessage(helpMessage(sender, HelpType.TRY));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "current":
|
|
||||||
if (hasPermission(sender, "chat.command.nick.current")) {
|
|
||||||
ChatUser chatUser = ChatUserManager.getChatUser(player.getUniqueId());
|
|
||||||
TagResolver placeholders = TagResolver.resolver(
|
|
||||||
Placeholder.component("nickname", chatUser.getDisplayName()),
|
|
||||||
Placeholder.parsed("currentnickname", chatUser.getNickNameString())
|
|
||||||
);
|
|
||||||
player.sendRichMessage(Config.NICK_CURRENT, placeholders);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "help":
|
|
||||||
sender.sendRichMessage(helpMessage(sender, HelpType.ALL)
|
|
||||||
+ "For more info on nicknames and how to use rgb colors go to: <aqua>https://alttd.com/nicknames<white>");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sender.sendRichMessage(helpMessage(sender, HelpType.ALL));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sender.sendMessage("Console commands are disabled.");
|
sender.sendMessage("Console commands are disabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args.length == 0) {
|
||||||
|
sender.sendRichMessage(helpMessage(sender, HelpType.ALL));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
switch (args[0].toLowerCase()) {
|
||||||
|
case "set" -> setNickname(sender, args, player);
|
||||||
|
case "review" -> reviewNickname(sender, args, player);
|
||||||
|
case "request" -> requestNickname(sender, args, player);
|
||||||
|
case "try" -> tryNickname(sender, args, player);
|
||||||
|
case "current" -> showCurrentNickname(sender, player);
|
||||||
|
case "help" ->
|
||||||
|
sender.sendRichMessage(helpMessage(sender, HelpType.ALL) + "For more info on nicknames and how to use rgb colors go to: <aqua>https://alttd.com/nicknames<white>");
|
||||||
|
default -> sender.sendRichMessage(helpMessage(sender, HelpType.ALL));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showCurrentNickname(@NotNull CommandSender sender, Player player) {
|
||||||
|
if (!hasPermission(sender, "chat.command.nick.current")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ChatUser chatUser = ChatUserManager.getChatUser(player.getUniqueId());
|
||||||
|
TagResolver placeholders = TagResolver.resolver(
|
||||||
|
Placeholder.component("nickname", chatUser.getDisplayName()),
|
||||||
|
Placeholder.parsed("currentnickname", chatUser.getNickNameString())
|
||||||
|
);
|
||||||
|
player.sendRichMessage(Config.NICK_CURRENT, placeholders);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tryNickname(@NotNull CommandSender sender, String[] args, Player player) {
|
||||||
|
if (args.length != 2 || !hasPermission(sender, "chat.command.nick.try")) {
|
||||||
|
sender.sendRichMessage(helpMessage(sender, HelpType.TRY));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LuckPerms api = ChatAPI.get().getLuckPerms();
|
||||||
|
if (api == null) {
|
||||||
|
sender.sendRichMessage(Config.NICK_NO_LUCKPERMS);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!NickUtilities.validNick(player, player, args[1])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sender.sendRichMessage(Config.NICK_TRYOUT,
|
||||||
|
Placeholder.component("prefix", Utility.applyColor(api.getUserManager().getUser(player.getUniqueId())
|
||||||
|
.getCachedData().getMetaData().getPrefix())), // TODO pull this from chatuser?
|
||||||
|
Placeholder.component("nick", Utility.applyColor(args[1])),
|
||||||
|
Placeholder.unparsed("nickrequest", args[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requestNickname(@NotNull CommandSender sender, String[] args, Player player) {
|
||||||
|
if (args.length != 2 || !hasPermission(sender, "chat.command.nick.request")) {
|
||||||
|
sender.sendRichMessage(helpMessage(sender, HelpType.REQUEST));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
handleNickRequest(player, args[1]);
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reviewNickname(@NotNull CommandSender sender, String[] args, Player player) {
|
||||||
|
if (args.length != 1 || !hasPermission(sender, "chat.command.nick.review")) {
|
||||||
|
sender.sendRichMessage(helpMessage(sender, HelpType.REVIEW));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NicknamesGui nicknamesGui = new NicknamesGui(player);
|
||||||
|
ChatPlugin.getInstance().getServer().getPluginManager().registerEvents(nicknamesGui, ChatPlugin.getInstance());
|
||||||
|
nicknamesGui.openInventory(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setNickname(@NotNull CommandSender sender, String[] args, Player player) {
|
||||||
|
if (args.length == 2 && hasPermission(sender, "chat.command.nick.set")) {
|
||||||
|
handleNick(player, player, args[1]);
|
||||||
|
} else if (args.length == 3 && hasPermission(sender, "chat.command.nick.set.others")) {
|
||||||
|
OfflinePlayer offlinePlayer = sender.getServer().getOfflinePlayer(args[1]);
|
||||||
|
|
||||||
|
if (offlinePlayer.isOnline() || offlinePlayer.hasPlayedBefore()) {
|
||||||
|
handleNick(player, offlinePlayer, args[2]);
|
||||||
|
} else {
|
||||||
|
sender.sendRichMessage(helpMessage(sender, HelpType.SET_OTHERS));
|
||||||
|
}
|
||||||
|
} else if (args.length > 3) {
|
||||||
|
sender.sendRichMessage(helpMessage(sender, HelpType.SET_SELF, HelpType.SET_OTHERS));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
List<String> completions = new ArrayList<>();
|
List<String> completions = new ArrayList<>();
|
||||||
@@ -136,49 +145,58 @@ public class Nicknames implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
List<String> choices = new ArrayList<>();
|
tabCompleteArgLengthOne(sender, args, completions);
|
||||||
if (sender.hasPermission("chat.command.nick.set")) {
|
|
||||||
choices.add("set");
|
|
||||||
}
|
|
||||||
if (sender.hasPermission("chat.command.nick.review")) {
|
|
||||||
choices.add("review");
|
|
||||||
}
|
|
||||||
if (sender.hasPermission("chat.command.nick.request")) {
|
|
||||||
choices.add("request");
|
|
||||||
}
|
|
||||||
if (sender.hasPermission("chat.command.nick.try")) {
|
|
||||||
choices.add("try");
|
|
||||||
}
|
|
||||||
if (sender.hasPermission("chat.command.nick.current")) {
|
|
||||||
choices.add("current");
|
|
||||||
}
|
|
||||||
choices.add("help");
|
|
||||||
|
|
||||||
for (String s : choices) {
|
|
||||||
if (s.startsWith(args[0])) {
|
|
||||||
completions.add(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
if (args[0].equalsIgnoreCase("set")) {
|
tabCompleteArgLengthTwo(sender, args, completions);
|
||||||
List<String> choices = new ArrayList<>();
|
|
||||||
List<String> onlinePlayers = new ArrayList<>();
|
|
||||||
Bukkit.getOnlinePlayers().forEach(a -> onlinePlayers.add(a.getName()));
|
|
||||||
|
|
||||||
if (sender.hasPermission("chat.command.nick.set.others")) {
|
|
||||||
choices.addAll(onlinePlayers);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String s : choices) {
|
|
||||||
if (s.startsWith(args[1])) {
|
|
||||||
completions.add(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return completions;
|
return completions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void tabCompleteArgLengthTwo(CommandSender sender, String[] args, List<String> completions) {
|
||||||
|
if (!args[0].equalsIgnoreCase("set")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<String> choices = new ArrayList<>();
|
||||||
|
List<String> onlinePlayers = new ArrayList<>();
|
||||||
|
Bukkit.getOnlinePlayers().forEach(a -> onlinePlayers.add(a.getName()));
|
||||||
|
|
||||||
|
if (sender.hasPermission("chat.command.nick.set.others")) {
|
||||||
|
choices.addAll(onlinePlayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String s : choices) {
|
||||||
|
if (s.startsWith(args[1])) {
|
||||||
|
completions.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void tabCompleteArgLengthOne(CommandSender sender, String[] args, List<String> completions) {
|
||||||
|
List<String> choices = new ArrayList<>();
|
||||||
|
if (sender.hasPermission("chat.command.nick.set")) {
|
||||||
|
choices.add("set");
|
||||||
|
}
|
||||||
|
if (sender.hasPermission("chat.command.nick.review")) {
|
||||||
|
choices.add("review");
|
||||||
|
}
|
||||||
|
if (sender.hasPermission("chat.command.nick.request")) {
|
||||||
|
choices.add("request");
|
||||||
|
}
|
||||||
|
if (sender.hasPermission("chat.command.nick.try")) {
|
||||||
|
choices.add("try");
|
||||||
|
}
|
||||||
|
if (sender.hasPermission("chat.command.nick.current")) {
|
||||||
|
choices.add("current");
|
||||||
|
}
|
||||||
|
choices.add("help");
|
||||||
|
|
||||||
|
for (String s : choices) {
|
||||||
|
if (s.startsWith(args[0])) {
|
||||||
|
completions.add(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void handleNickRequest(Player player, String nickName) {
|
private void handleNickRequest(Player player, String nickName) {
|
||||||
if (!NickUtilities.validNick(player, player, nickName)) {
|
if (!NickUtilities.validNick(player, player, nickName)) {
|
||||||
return;
|
return;
|
||||||
@@ -261,69 +279,75 @@ public class Nicknames implements CommandExecutor, TabCompleter {
|
|||||||
|
|
||||||
private void handleNick(Player sender, OfflinePlayer target, final String nickName) {
|
private void handleNick(Player sender, OfflinePlayer target, final String nickName) {
|
||||||
if (nickName.equalsIgnoreCase("off")) {
|
if (nickName.equalsIgnoreCase("off")) {
|
||||||
|
handleNickOff(sender, target);
|
||||||
try {
|
|
||||||
if (target.isOnline()) {
|
|
||||||
resetNick(Objects.requireNonNull(target.getPlayer()));
|
|
||||||
}
|
|
||||||
Queries.removePlayerFromDataBase(target.getUniqueId());
|
|
||||||
NickCache.remove(target.getUniqueId());
|
|
||||||
nickCacheUpdate.add(target.getUniqueId());
|
|
||||||
} catch (SQLException e) {
|
|
||||||
ALogger.error("Failed to remove nickname from database", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sender.equals(target)) {
|
|
||||||
sender.sendRichMessage(Config.NICK_RESET_OTHERS,
|
|
||||||
Placeholder.unparsed("player", Objects.requireNonNull(target.getName())));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target.isOnline() && target.getPlayer() != null) {
|
|
||||||
target.getPlayer().sendRichMessage(Config.NICK_RESET);
|
|
||||||
}
|
|
||||||
|
|
||||||
NickEvent nickEvent = new NickEvent(sender.getName(), target.getName(), null, NickEvent.NickEventType.RESET);
|
|
||||||
nickEvent.callEvent();
|
|
||||||
|
|
||||||
} else if (NickUtilities.validNick(sender, target, nickName)) {
|
} else if (NickUtilities.validNick(sender, target, nickName)) {
|
||||||
if (target.isOnline()) {
|
setValidNick(sender, target, nickName);
|
||||||
setNick(target.getPlayer(), nickName);
|
|
||||||
} else {
|
|
||||||
NickUtilities.bungeeMessageHandled(target.getUniqueId(), sender, "Set");
|
|
||||||
}
|
|
||||||
|
|
||||||
Queries.setNicknameInDatabase(target.getUniqueId(), nickName);
|
|
||||||
NickEvent nickEvent = new NickEvent(sender.getName(), target.getName(), nickName, NickEvent.NickEventType.SET);
|
|
||||||
nickEvent.callEvent();
|
|
||||||
|
|
||||||
if (NickCache.containsKey(target.getUniqueId())) {
|
|
||||||
Nick nick = NickCache.get(target.getUniqueId());
|
|
||||||
nick.setCurrentNick(nickName);
|
|
||||||
nick.setLastChangedDate(new Date().getTime());
|
|
||||||
setNick(target.getPlayer(), nickName);
|
|
||||||
} else {
|
|
||||||
NickCache.put(target.getUniqueId(), new Nick(target.getUniqueId(), nickName, new Date().getTime()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sender.equals(target)) {
|
|
||||||
sender.sendMessage(Utility.parseMiniMessage(Config.NICK_CHANGED_OTHERS,
|
|
||||||
Placeholder.unparsed("targetplayer", Objects.requireNonNull(target.getName())),
|
|
||||||
Placeholder.unparsed("nickname", nickName)));
|
|
||||||
if (target.isOnline()) {
|
|
||||||
Objects.requireNonNull(target.getPlayer())
|
|
||||||
.sendRichMessage(Config.NICK_TARGET_NICK_CHANGE,
|
|
||||||
Placeholder.unparsed("nickname", getNick(target.getPlayer())),
|
|
||||||
Placeholder.unparsed("sendernick", getNick(sender)),
|
|
||||||
Placeholder.unparsed("player", target.getName()));
|
|
||||||
}
|
|
||||||
} else if (target.isOnline()) {
|
|
||||||
Objects.requireNonNull(target.getPlayer())
|
|
||||||
.sendRichMessage(Config.NICK_CHANGED,
|
|
||||||
Placeholder.unparsed("nickname", getNick(target.getPlayer())));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setValidNick(Player sender, OfflinePlayer target, String nickName) {
|
||||||
|
if (target.isOnline()) {
|
||||||
|
setNick(target.getPlayer(), nickName);
|
||||||
|
} else {
|
||||||
|
NickUtilities.bungeeMessageHandled(target.getUniqueId(), sender, "Set");
|
||||||
|
}
|
||||||
|
|
||||||
|
Queries.setNicknameInDatabase(target.getUniqueId(), nickName);
|
||||||
|
NickEvent nickEvent = new NickEvent(sender.getName(), target.getName(), nickName, NickEvent.NickEventType.SET);
|
||||||
|
nickEvent.callEvent();
|
||||||
|
|
||||||
|
if (NickCache.containsKey(target.getUniqueId())) {
|
||||||
|
Nick nick = NickCache.get(target.getUniqueId());
|
||||||
|
nick.setCurrentNick(nickName);
|
||||||
|
nick.setLastChangedDate(new Date().getTime());
|
||||||
|
setNick(target.getPlayer(), nickName);
|
||||||
|
} else {
|
||||||
|
NickCache.put(target.getUniqueId(), new Nick(target.getUniqueId(), nickName, new Date().getTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sender.equals(target)) {
|
||||||
|
sender.sendMessage(Utility.parseMiniMessage(Config.NICK_CHANGED_OTHERS,
|
||||||
|
Placeholder.unparsed("targetplayer", Objects.requireNonNull(target.getName())),
|
||||||
|
Placeholder.unparsed("nickname", nickName)));
|
||||||
|
if (target.isOnline()) {
|
||||||
|
Objects.requireNonNull(target.getPlayer())
|
||||||
|
.sendRichMessage(Config.NICK_TARGET_NICK_CHANGE,
|
||||||
|
Placeholder.unparsed("nickname", getNick(target.getPlayer())),
|
||||||
|
Placeholder.unparsed("sendernick", getNick(sender)),
|
||||||
|
Placeholder.unparsed("player", target.getName()));
|
||||||
|
}
|
||||||
|
} else if (target.isOnline()) {
|
||||||
|
Objects.requireNonNull(target.getPlayer())
|
||||||
|
.sendRichMessage(Config.NICK_CHANGED,
|
||||||
|
Placeholder.unparsed("nickname", getNick(target.getPlayer())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleNickOff(Player sender, OfflinePlayer target) {
|
||||||
|
try {
|
||||||
|
if (target.isOnline()) {
|
||||||
|
resetNick(Objects.requireNonNull(target.getPlayer()));
|
||||||
|
}
|
||||||
|
Queries.removePlayerFromDataBase(target.getUniqueId());
|
||||||
|
NickCache.remove(target.getUniqueId());
|
||||||
|
nickCacheUpdate.add(target.getUniqueId());
|
||||||
|
} catch (SQLException e) {
|
||||||
|
ALogger.error("Failed to remove nickname from database", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sender.equals(target)) {
|
||||||
|
sender.sendRichMessage(Config.NICK_RESET_OTHERS,
|
||||||
|
Placeholder.unparsed("player", Objects.requireNonNull(target.getName())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target.isOnline() && target.getPlayer() != null) {
|
||||||
|
target.getPlayer().sendRichMessage(Config.NICK_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
NickEvent nickEvent = new NickEvent(sender.getName(), target.getName(), null, NickEvent.NickEventType.RESET);
|
||||||
|
nickEvent.callEvent();
|
||||||
|
}
|
||||||
|
|
||||||
private String helpMessage(final CommandSender sender, final HelpType... helpTypes) {
|
private String helpMessage(final CommandSender sender, final HelpType... helpTypes) {
|
||||||
StringBuilder message = new StringBuilder();
|
StringBuilder message = new StringBuilder();
|
||||||
for (HelpType helpType : helpTypes) {
|
for (HelpType helpType : helpTypes) {
|
||||||
|
|||||||
@@ -5,24 +5,22 @@ import com.alttd.chat.config.Config;
|
|||||||
import com.alttd.chat.database.Queries;
|
import com.alttd.chat.database.Queries;
|
||||||
import com.alttd.chat.events.NickEvent;
|
import com.alttd.chat.events.NickEvent;
|
||||||
import com.alttd.chat.objects.Nick;
|
import com.alttd.chat.objects.Nick;
|
||||||
|
import com.alttd.chat.util.ALogger;
|
||||||
import com.alttd.chat.util.Utility;
|
import com.alttd.chat.util.Utility;
|
||||||
|
import com.alttd.inventory_gui.click.GuiItem;
|
||||||
|
import com.alttd.inventory_gui.gui.InventoryGui;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
@@ -31,39 +29,45 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class NicknamesGui implements Listener {
|
public class NicknamesGui implements Listener {
|
||||||
|
|
||||||
private final Inventory inv;
|
public static final String UNKNOWN_PLAYER_NAME = "UNKNOWN PLAYER NAME";
|
||||||
private final int currentPage;
|
private final int currentPage;
|
||||||
|
private final ChatPlugin plugin = ChatPlugin.getInstance();
|
||||||
|
private final InventoryGui nicknamesGui;
|
||||||
|
|
||||||
public NicknamesGui() {
|
public NicknamesGui(Player player) {
|
||||||
// Create a new inventory, with no owner (as this isn't a real inventory)
|
nicknamesGui = InventoryGui.builder()
|
||||||
inv = Bukkit.createInventory(null, 36, Utility.parseMiniMessage("Nicknames GUI").asComponent());
|
.plugin(plugin)
|
||||||
|
.title(Component.text("Nicknames GUI"))
|
||||||
// Put the items into the inventory
|
.rows(6)
|
||||||
|
.build();
|
||||||
currentPage = 1;
|
currentPage = 1;
|
||||||
setItems(currentPage);
|
setItems(currentPage, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItems(int currentPage) {
|
public void setItems(int currentPage, Player player) {
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
inv.clear();
|
|
||||||
NickUtilities.updateCache();
|
NickUtilities.updateCache();
|
||||||
boolean hasNextPage = false;
|
boolean hasNextPage = false;
|
||||||
int i = (currentPage - 1) * 27; //TODO set to 1 or 2 to test
|
int i = (currentPage - 1) * 27; //TODO set to 1 or 2 to test
|
||||||
int limit = i / 27;
|
int limit = i / 27;
|
||||||
|
MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||||
|
|
||||||
for (Nick nick : Nicknames.getInstance().NickCache.values()) {
|
for (Nick nick : Nicknames.getInstance().NickCache.values()) {
|
||||||
if (nick.hasRequest()) {
|
if (nick.hasRequest()) {
|
||||||
if (limit >= i / 27) {
|
if (limit >= i / 27) {
|
||||||
inv.setItem(i % 27, createPlayerSkull(nick, Config.NICK_ITEM_LORE));
|
ItemStack playerSkull = createPlayerSkull(nick, Config.NICK_ITEM_LORE);
|
||||||
|
nicknamesGui.getRoot().setItem(i % 27, GuiItem.clickable(playerSkull, inventoryClickEvent ->
|
||||||
|
handleInventoryClick(nick, inventoryClickEvent, miniMessage, playerSkull)));
|
||||||
|
ALogger.info("Added nick " + i + " to gui: " + nick.getUuid());
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
|
ALogger.info("Reached end of nicknames gui page");
|
||||||
hasNextPage = true;
|
hasNextPage = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -71,20 +75,137 @@ public class NicknamesGui implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (currentPage != 1) {
|
if (currentPage != 1) {
|
||||||
inv.setItem(28, createGuiItem(Material.PAPER, "§bPrevious page",
|
ItemStack itemStack = createGuiItem(Material.PAPER, "§bPrevious page",
|
||||||
"§aCurrent page: %page%".replace("%page%", String.valueOf(currentPage)),
|
"§aCurrent page: %page%".replace("%page%", String.valueOf(currentPage)),
|
||||||
"§aPrevious page: %previousPage%".replace("%previousPage%", String.valueOf(currentPage - 1))));
|
"§aPrevious page: %previousPage%".replace("%previousPage%", String.valueOf(currentPage - 1)));
|
||||||
|
GuiItem previousPage = GuiItem.clickable(itemStack, e -> setItems(currentPage - 1, player));
|
||||||
|
nicknamesGui.getRoot().setItem(28, previousPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasNextPage) {
|
if (hasNextPage) {
|
||||||
inv.setItem(36, createGuiItem(Material.PAPER, "§bNext page",
|
ItemStack itemStack = createGuiItem(Material.PAPER, "§bNext page",
|
||||||
"§aCurrent page: %page%".replace("%page%", String.valueOf(currentPage)),
|
"§aCurrent page: %page%".replace("%page%", String.valueOf(currentPage)),
|
||||||
"§aNext page: §b%nextPage%".replace("%nextPage%", String.valueOf(currentPage + 1))));
|
"§aNext page: §b%nextPage%".replace("%nextPage%", String.valueOf(currentPage + 1)));
|
||||||
|
GuiItem nextPage = GuiItem.clickable(itemStack, e -> setItems(currentPage + 1, player));
|
||||||
|
nicknamesGui.getRoot().setItem(36, nextPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nicknamesGui.render(player);
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleInventoryClick(Nick nick, InventoryClickEvent inventoryClickEvent, MiniMessage miniMessage, ItemStack playerSkull) {
|
||||||
|
final Player playerWhoClicked = (Player) inventoryClickEvent.getWhoClicked();
|
||||||
|
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(nick.getUuid());
|
||||||
|
Component offlinePlayerName = miniMessage.deserialize(getOfflinePlayerName(offlinePlayer));
|
||||||
|
if (!nick.hasRequest()) {
|
||||||
|
playerWhoClicked.sendRichMessage(Config.NICK_ALREADY_HANDLED,
|
||||||
|
Placeholder.component("targetplayer", offlinePlayerName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (inventoryClickEvent.isLeftClick()) {
|
||||||
|
handleLeftClickPlayerSkull(nick, inventoryClickEvent, offlinePlayer, playerWhoClicked, offlinePlayerName, playerSkull);
|
||||||
|
} else if (inventoryClickEvent.isRightClick()) {
|
||||||
|
handleRightClickPlayerSkull(nick, inventoryClickEvent, offlinePlayer, playerWhoClicked, offlinePlayerName, playerSkull);
|
||||||
|
}
|
||||||
|
//TODO what do we do no click?
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleRightClickPlayerSkull(Nick nick, InventoryClickEvent inventoryClickEvent, OfflinePlayer offlinePlayer, Player playerWhoClicked, Component offlinePlayerName, ItemStack playerSkull) {
|
||||||
|
Queries.denyNewNickname(nick.getUuid());
|
||||||
|
|
||||||
|
String newNick = nick.getNewNick();
|
||||||
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
NickEvent nickEvent = new NickEvent(inventoryClickEvent.getWhoClicked().getName(), getOfflinePlayerName(offlinePlayer), newNick, NickEvent.NickEventType.DENIED);
|
||||||
|
nickEvent.callEvent();
|
||||||
|
}
|
||||||
|
}.runTask(ChatPlugin.getInstance());
|
||||||
|
|
||||||
|
playerWhoClicked.sendRichMessage(Config.NICK_DENIED,
|
||||||
|
Placeholder.unparsed("targetplayer", getOfflinePlayerName(offlinePlayer)),
|
||||||
|
Placeholder.component("newnick", Utility.applyColor(nick.getNewNick())),
|
||||||
|
Placeholder.component("oldnick", Utility.applyColor(nick.getCurrentNick() == null ? getOfflinePlayerName(offlinePlayer) : nick.getCurrentNick())));
|
||||||
|
|
||||||
|
if (Nicknames.getInstance().NickCache.containsKey(nick.getUuid())
|
||||||
|
&& Nicknames.getInstance().NickCache.get(nick.getUuid()).getCurrentNick() != null) {
|
||||||
|
nick.setNewNick(null);
|
||||||
|
nick.setRequestedDate(0);
|
||||||
|
Nicknames.getInstance().NickCache.put(nick.getUuid(), nick);
|
||||||
|
} else {
|
||||||
|
Nicknames.getInstance().NickCache.remove(nick.getUuid());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offlinePlayer.isOnline() && offlinePlayer.getPlayer() != null) {
|
||||||
|
Nicknames.getInstance().setNick(offlinePlayer.getPlayer(), nick.getCurrentNick() == null ? getOfflinePlayerName(offlinePlayer) : nick.getCurrentNick());
|
||||||
|
offlinePlayer.getPlayer().sendRichMessage(Config.NICK_NOT_CHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
NickUtilities.bungeeMessageHandled(nick.getUuid(), inventoryClickEvent.getWhoClicked().getServer().getPlayer(inventoryClickEvent.getWhoClicked().getName()), "Denied");
|
||||||
|
final ComponentLike messageDenied = MiniMessage.miniMessage().deserialize("<red><name>'s nickname was denied!",
|
||||||
|
Placeholder.unparsed("name", getOfflinePlayerName(offlinePlayer)));
|
||||||
|
ChatPlugin.getInstance().getServer().getOnlinePlayers().stream()
|
||||||
|
.filter(player -> player.hasPermission("chat.command.nick.review"))
|
||||||
|
.forEach(player -> player.sendMessage(messageDenied));
|
||||||
|
|
||||||
|
ItemStack completedNickRequestItem = createCompletedNickRequestItem(offlinePlayerName, playerSkull);
|
||||||
|
inventoryClickEvent.getInventory().setItem(inventoryClickEvent.getSlot(), completedNickRequestItem);
|
||||||
|
nicknamesGui.render(playerWhoClicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleLeftClickPlayerSkull(Nick nick, InventoryClickEvent inventoryClickEvent, OfflinePlayer offlinePlayer, Player playerWhoClicked, Component offlinePlayerName, ItemStack playerSkull) {
|
||||||
|
Queries.acceptNewNickname(nick.getUuid(), nick.getNewNick());
|
||||||
|
|
||||||
|
String newNick = nick.getNewNick();
|
||||||
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
NickEvent nickEvent = new NickEvent(inventoryClickEvent.getWhoClicked().getName(), getOfflinePlayerName(offlinePlayer), newNick, NickEvent.NickEventType.ACCEPTED);
|
||||||
|
nickEvent.callEvent();
|
||||||
|
}
|
||||||
|
}.runTask(ChatPlugin.getInstance());
|
||||||
|
|
||||||
|
playerWhoClicked.sendRichMessage(Config.NICK_ACCEPTED,
|
||||||
|
Placeholder.component("targetplayer", offlinePlayerName),
|
||||||
|
Placeholder.component("newnick", Utility.applyColor(nick.getNewNick())),
|
||||||
|
Placeholder.component("oldnick", nick.getCurrentNick() == null ? offlinePlayerName : Utility.applyColor(nick.getCurrentNick())));
|
||||||
|
|
||||||
|
Player affectedPlayer = offlinePlayer.getPlayer();
|
||||||
|
if (offlinePlayer.isOnline() && affectedPlayer != null) {
|
||||||
|
Nicknames.getInstance().setNick(affectedPlayer, nick.getNewNick());
|
||||||
|
}
|
||||||
|
|
||||||
|
NickUtilities.bungeeMessageHandled(nick.getUuid(), inventoryClickEvent.getWhoClicked().getServer().getPlayer(inventoryClickEvent.getWhoClicked().getName()), "Accepted");
|
||||||
|
|
||||||
|
nick.setCurrentNick(nick.getNewNick());
|
||||||
|
nick.setLastChangedDate(new Date().getTime());
|
||||||
|
nick.setNewNick(null);
|
||||||
|
nick.setRequestedDate(0);
|
||||||
|
|
||||||
|
Nicknames.getInstance().NickCache.put(nick.getUuid(), nick);
|
||||||
|
|
||||||
|
ItemStack completedNickRequestItem = createCompletedNickRequestItem(offlinePlayerName, playerSkull);
|
||||||
|
inventoryClickEvent.getInventory().setItem(inventoryClickEvent.getSlot(), completedNickRequestItem);
|
||||||
|
nicknamesGui.render(playerWhoClicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ItemStack createCompletedNickRequestItem(Component offlinePlayerName, ItemStack playerSkull) {
|
||||||
|
ItemStack itemStack = new ItemStack(Material.SKELETON_SKULL);
|
||||||
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
|
itemMeta.displayName(offlinePlayerName);
|
||||||
|
itemMeta.lore(playerSkull.lore());
|
||||||
|
itemStack.setItemMeta(itemMeta);
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getOfflinePlayerName(OfflinePlayer offlinePlayer) {
|
||||||
|
return offlinePlayer.getName() == null ? UNKNOWN_PLAYER_NAME : offlinePlayer.getName();
|
||||||
|
}
|
||||||
|
|
||||||
private ItemStack createPlayerSkull(Nick nick, List<String> lore) {
|
private ItemStack createPlayerSkull(Nick nick, List<String> lore) {
|
||||||
MiniMessage miniMessage = MiniMessage.miniMessage();
|
MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||||
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD);
|
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD);
|
||||||
@@ -94,9 +215,9 @@ public class NicknamesGui implements Listener {
|
|||||||
meta.setOwningPlayer(offlinePlayer);
|
meta.setOwningPlayer(offlinePlayer);
|
||||||
String name = offlinePlayer.getName();
|
String name = offlinePlayer.getName();
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
meta.displayName(miniMessage.deserialize("UNKNOWN PLAYER NAME"));
|
meta.displayName(miniMessage.deserialize("<red>" + getOfflinePlayerName(offlinePlayer) + "</red>"));
|
||||||
} else {
|
} else {
|
||||||
meta.displayName(miniMessage.deserialize(offlinePlayer.getName()));
|
meta.displayName(miniMessage.deserialize(getOfflinePlayerName(offlinePlayer)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TagResolver resolver = TagResolver.resolver(
|
TagResolver resolver = TagResolver.resolver(
|
||||||
@@ -128,185 +249,6 @@ public class NicknamesGui implements Listener {
|
|||||||
|
|
||||||
// You can open the inventory with this
|
// You can open the inventory with this
|
||||||
public void openInventory(final HumanEntity ent) {//Possibly with a boolean to show if it should get from cache or update cache
|
public void openInventory(final HumanEntity ent) {//Possibly with a boolean to show if it should get from cache or update cache
|
||||||
ent.openInventory(inv);
|
nicknamesGui.open(ent);
|
||||||
}
|
|
||||||
|
|
||||||
// Check for clicks on items
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
|
||||||
public void onInventoryClick(InventoryClickEvent e) {
|
|
||||||
if (e.getInventory() != inv) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
e.setCancelled(true);
|
|
||||||
|
|
||||||
final ItemStack clickedItem = e.getCurrentItem();
|
|
||||||
|
|
||||||
if (clickedItem == null || clickedItem.getType() == Material.AIR) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Player p = (Player) e.getWhoClicked();
|
|
||||||
|
|
||||||
if (clickedItem.getType().equals(Material.PAPER)) {
|
|
||||||
Component component = clickedItem.getItemMeta().displayName();
|
|
||||||
if (component == null) {
|
|
||||||
throw new IllegalStateException("Nicknames GUI: Item with no display name clicked!");
|
|
||||||
}
|
|
||||||
String serialize = PlainTextComponentSerializer.plainText().serialize(component);
|
|
||||||
if (serialize.equals("Next Page")) {
|
|
||||||
setItems(currentPage + 1);
|
|
||||||
}
|
|
||||||
} else if (clickedItem.getType().equals(Material.PLAYER_HEAD)) {
|
|
||||||
ItemMeta itemMeta = clickedItem.getItemMeta();
|
|
||||||
if (itemMeta == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SkullMeta meta = (SkullMeta) itemMeta;
|
|
||||||
if (meta.hasEnchants()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
OfflinePlayer owningPlayer = meta.getOwningPlayer();
|
|
||||||
|
|
||||||
if (owningPlayer == null) {
|
|
||||||
p.sendRichMessage(Config.NICK_USER_NOT_FOUND);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
NickUtilities.updateCache();
|
|
||||||
|
|
||||||
Nick nick;
|
|
||||||
UUID uniqueId = owningPlayer.getUniqueId();
|
|
||||||
if (Nicknames.getInstance().NickCache.containsKey(uniqueId)) {
|
|
||||||
nick = Nicknames.getInstance().NickCache.get(uniqueId);
|
|
||||||
} else {
|
|
||||||
nick = Queries.getNick(uniqueId);
|
|
||||||
}
|
|
||||||
Component itemDisplayName = itemMeta.displayName();
|
|
||||||
if (itemDisplayName == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nick == null || !nick.hasRequest()) {
|
|
||||||
p.sendRichMessage(Config.NICK_ALREADY_HANDLED,
|
|
||||||
Placeholder.component("targetplayer", itemDisplayName))
|
|
||||||
;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.isLeftClick()) {
|
|
||||||
if (owningPlayer.hasPlayedBefore()) {
|
|
||||||
Queries.acceptNewNickname(uniqueId, nick.getNewNick());
|
|
||||||
|
|
||||||
String newNick = nick.getNewNick();
|
|
||||||
|
|
||||||
new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
NickEvent nickEvent = new NickEvent(e.getWhoClicked().getName(), itemMeta.getDisplayName(), newNick, NickEvent.NickEventType.ACCEPTED);
|
|
||||||
nickEvent.callEvent();
|
|
||||||
}
|
|
||||||
}.runTask(ChatPlugin.getInstance());
|
|
||||||
|
|
||||||
p.sendRichMessage(Config.NICK_ACCEPTED,
|
|
||||||
Placeholder.component("targetplayer", itemDisplayName),
|
|
||||||
Placeholder.component("newnick", Utility.applyColor(nick.getNewNick())),
|
|
||||||
Placeholder.component("oldnick", Utility.applyColor(nick.getCurrentNick() == null ? itemMeta.getDisplayName() : nick.getCurrentNick())));
|
|
||||||
|
|
||||||
if (owningPlayer.isOnline() && owningPlayer.getPlayer() != null) {
|
|
||||||
Nicknames.getInstance().setNick(owningPlayer.getPlayer(), nick.getNewNick());
|
|
||||||
}
|
|
||||||
|
|
||||||
NickUtilities.bungeeMessageHandled(uniqueId, e.getWhoClicked().getServer().getPlayer(e.getWhoClicked().getName()), "Accepted");
|
|
||||||
|
|
||||||
nick.setCurrentNick(nick.getNewNick());
|
|
||||||
nick.setLastChangedDate(new Date().getTime());
|
|
||||||
nick.setNewNick(null);
|
|
||||||
nick.setRequestedDate(0);
|
|
||||||
|
|
||||||
Nicknames.getInstance().NickCache.put(uniqueId, nick);
|
|
||||||
|
|
||||||
ItemStack itemStack = new ItemStack(Material.SKELETON_SKULL);
|
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
itemMeta.displayName(itemMeta.displayName());
|
|
||||||
itemMeta.lore(clickedItem.lore());
|
|
||||||
itemStack.setItemMeta(itemMeta);
|
|
||||||
e.getInventory().setItem(e.getSlot(), itemStack);
|
|
||||||
p.updateInventory();
|
|
||||||
} else {
|
|
||||||
p.sendRichMessage(Config.NICK_PLAYER_NOT_ONLINE, Placeholder.component("player", itemDisplayName));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (e.isRightClick()) {
|
|
||||||
if (owningPlayer.hasPlayedBefore()) {
|
|
||||||
Queries.denyNewNickname(uniqueId);
|
|
||||||
|
|
||||||
String newNick = nick.getNewNick();
|
|
||||||
|
|
||||||
new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
NickEvent nickEvent = new NickEvent(e.getWhoClicked().getName(), itemMeta.getDisplayName(), newNick, NickEvent.NickEventType.DENIED);
|
|
||||||
nickEvent.callEvent();
|
|
||||||
}
|
|
||||||
}.runTask(ChatPlugin.getInstance());
|
|
||||||
|
|
||||||
p.sendMessage(MiniMessage.miniMessage().deserialize(Config.NICK_DENIED,
|
|
||||||
Placeholder.unparsed("targetplayer", owningPlayer.getName()),
|
|
||||||
Placeholder.component("newnick", Utility.applyColor(nick.getNewNick())),
|
|
||||||
Placeholder.component("oldnick", Utility.applyColor(nick.getCurrentNick() == null ? owningPlayer.getName() : nick.getCurrentNick()))));
|
|
||||||
|
|
||||||
if (Nicknames.getInstance().NickCache.containsKey(uniqueId)
|
|
||||||
&& Nicknames.getInstance().NickCache.get(uniqueId).getCurrentNick() != null) {
|
|
||||||
nick.setNewNick(null);
|
|
||||||
nick.setRequestedDate(0);
|
|
||||||
Nicknames.getInstance().NickCache.put(uniqueId, nick);
|
|
||||||
} else {
|
|
||||||
Nicknames.getInstance().NickCache.remove(uniqueId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (owningPlayer.isOnline() && owningPlayer.getPlayer() != null) {
|
|
||||||
Nicknames.getInstance().setNick(owningPlayer.getPlayer(), nick.getCurrentNick() == null ? owningPlayer.getName() : nick.getCurrentNick());
|
|
||||||
owningPlayer.getPlayer().sendRichMessage(Config.NICK_NOT_CHANGED);
|
|
||||||
}
|
|
||||||
|
|
||||||
NickUtilities.bungeeMessageHandled(uniqueId, e.getWhoClicked().getServer().getPlayer(e.getWhoClicked().getName()), "Denied");
|
|
||||||
final ComponentLike messageDenied = MiniMessage.miniMessage().deserialize("<red><name>'s nickname was denied!",
|
|
||||||
Placeholder.unparsed("name", owningPlayer.getName()));
|
|
||||||
ChatPlugin.getInstance().getServer().getOnlinePlayers().forEach(p -> {
|
|
||||||
if (p.hasPermission("chat.command.nick.review")) {
|
|
||||||
p.sendMessage(messageDenied);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ItemStack itemStack = new ItemStack(Material.SKELETON_SKULL);
|
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
|
||||||
itemMeta.displayName(itemDisplayName);
|
|
||||||
itemMeta.lore(clickedItem.lore());
|
|
||||||
itemStack.setItemMeta(itemMeta);
|
|
||||||
e.getInventory().setItem(e.getSlot(), itemStack);
|
|
||||||
p.updateInventory();
|
|
||||||
} else {
|
|
||||||
if (itemDisplayName == null) {
|
|
||||||
p.sendRichMessage(Config.NICK_PLAYER_NOT_ONLINE, Placeholder.parsed("player", "UNKNOWN PLAYER NAME"));
|
|
||||||
} else {
|
|
||||||
p.sendRichMessage(Config.NICK_PLAYER_NOT_ONLINE, Placeholder.component("player", itemDisplayName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cancel dragging in our inventory
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
|
||||||
public void onInventoryClick(InventoryDragEvent e) {
|
|
||||||
if (e.getInventory() == inv) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-4
@@ -9,13 +9,12 @@ val nexusPass = providers.gradleProperty("alttdSnapshotPassword").get()
|
|||||||
|
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
repositories {
|
repositories {
|
||||||
// mavenLocal()
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven("https://repo.destro.xyz/snapshots") // Altitude - Galaxy
|
maven("https://repo.alttd.com/snapshots") // Altitude - Galaxy
|
||||||
maven("https://oss.sonatype.org/content/groups/public/") // Adventure
|
maven("https://oss.sonatype.org/content/groups/public/") // Adventure
|
||||||
maven("https://oss.sonatype.org/content/repositories/snapshots/") // Minimessage
|
maven("https://oss.sonatype.org/content/repositories/snapshots/") // Minimessage
|
||||||
maven("https://nexus.velocitypowered.com/repository/") // Velocity
|
maven("https://repo.papermc.io/repository/maven-public/")
|
||||||
maven("https://nexus.velocitypowered.com/repository/maven-public/") // Velocity
|
|
||||||
maven("https://repo.spongepowered.org/maven") // Configurate
|
maven("https://repo.spongepowered.org/maven") // Configurate
|
||||||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") // Papi
|
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") // Papi
|
||||||
maven("https://jitpack.io")
|
maven("https://jitpack.io")
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ plugins {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":api")) // API
|
implementation(project(":api")) // API
|
||||||
compileOnly("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
|
compileOnly("com.velocitypowered:velocity-api:3.5.0-SNAPSHOT")
|
||||||
annotationProcessor("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
|
annotationProcessor("com.velocitypowered:velocity-api:3.5.0-SNAPSHOT")
|
||||||
implementation("mysql:mysql-connector-java:8.0.33") // mysql
|
implementation("mysql:mysql-connector-java:8.0.33") // mysql
|
||||||
implementation("org.spongepowered", "configurate-yaml", "4.2.0")
|
implementation("org.spongepowered", "configurate-yaml", "4.2.0")
|
||||||
compileOnly("net.kyori:adventure-text-minimessage:4.23.0")
|
compileOnly("net.kyori:adventure-text-minimessage:4.23.0")
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.alttd.chat.util.Utility;
|
|||||||
import com.alttd.velocitychat.VelocityChat;
|
import com.alttd.velocitychat.VelocityChat;
|
||||||
import com.alttd.velocitychat.events.GlobalAdminChatEvent;
|
import com.alttd.velocitychat.events.GlobalAdminChatEvent;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
@@ -19,7 +18,7 @@ public class ChatListener {
|
|||||||
plugin = VelocityChat.getPlugin();
|
plugin = VelocityChat.getPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.FIRST)
|
@Subscribe(priority = 0)
|
||||||
public void onGlobalStaffChat(GlobalAdminChatEvent event) {
|
public void onGlobalStaffChat(GlobalAdminChatEvent event) {
|
||||||
String senderName = Config.CONSOLENAME;
|
String senderName = Config.CONSOLENAME;
|
||||||
String serverName = "Altitude";
|
String serverName = "Altitude";
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.alttd.velocitychat.VelocityChat;
|
|||||||
import com.alttd.velocitychat.commands.vote_to_mute.ActiveVoteToMute;
|
import com.alttd.velocitychat.commands.vote_to_mute.ActiveVoteToMute;
|
||||||
import com.alttd.velocitychat.data.ServerWrapper;
|
import com.alttd.velocitychat.data.ServerWrapper;
|
||||||
import com.alttd.velocitychat.handlers.ServerHandler;
|
import com.alttd.velocitychat.handlers.ServerHandler;
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||||
import com.velocitypowered.api.event.connection.LoginEvent;
|
import com.velocitypowered.api.event.connection.LoginEvent;
|
||||||
@@ -34,7 +33,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
public class ProxyPlayerListener {
|
public class ProxyPlayerListener {
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.FIRST)
|
@Subscribe(priority = 0)
|
||||||
public void onPlayerLogin(LoginEvent event) {
|
public void onPlayerLogin(LoginEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
@@ -57,7 +56,7 @@ public class ProxyPlayerListener {
|
|||||||
ServerHandler.addPlayerUUID(player.getUsername(), uuid);
|
ServerHandler.addPlayerUUID(player.getUsername(), uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.LAST)
|
@Subscribe(priority = 4)
|
||||||
public void afterPlayerLogin(ServerPostConnectEvent event) {
|
public void afterPlayerLogin(ServerPostConnectEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
RegisteredServer previousServer = event.getPreviousServer();
|
RegisteredServer previousServer = event.getPreviousServer();
|
||||||
|
|||||||
Reference in New Issue
Block a user