mirror of
https://github.com/plexusorg/Module-Guilds.git
synced 2026-06-04 02:36:54 +00:00
Update for Plex 2.0
This commit is contained in:
+9
-9
@@ -16,21 +16,21 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.projectlombok:lombok:1.18.38")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.38")
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.7-R0.1-SNAPSHOT")
|
||||
implementation("org.apache.commons:commons-lang3:3.17.0")
|
||||
compileOnly("dev.plex:server:1.5")
|
||||
compileOnly("org.json:json:20250517")
|
||||
implementation("org.jetbrains:annotations:26.0.2")
|
||||
compileOnly("org.projectlombok:lombok:1.18.46")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.46")
|
||||
compileOnly("io.papermc.paper:paper-api:26.1.2.build.+")
|
||||
implementation("org.apache.commons:commons-lang3:3.20.0")
|
||||
compileOnly("dev.plex:api:2.0-SNAPSHOT")
|
||||
compileOnly("org.json:json:20251224")
|
||||
implementation("org.jetbrains:annotations:26.1.0")
|
||||
}
|
||||
|
||||
group = "dev.plex"
|
||||
version = "1.5"
|
||||
version = "2.0-SNAPSHOT"
|
||||
description = "The Guilds module for Plex"
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+3
-1
@@ -1,7 +1,9 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -57,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -86,8 +86,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -115,7 +114,6 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -173,7 +171,6 @@ fi
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
@@ -206,15 +203,14 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+10
-22
@@ -23,8 +23,8 @@
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||
setlocal EnableExtensions
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@@ -51,7 +51,7 @@ echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
"%COMSPEC%" /c exit 1
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
@@ -65,30 +65,18 @@ echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
"%COMSPEC%" /c exit 1
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||
@rem which allows us to clear the local environment before executing the java command
|
||||
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
:exitWithErrorLevel
|
||||
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||
|
||||
@@ -6,7 +6,6 @@ import dev.plex.data.SQLGuildManager;
|
||||
import dev.plex.data.SQLManager;
|
||||
import dev.plex.guild.GuildHolder;
|
||||
import dev.plex.module.PlexModule;
|
||||
import dev.plex.util.PlexLog;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@@ -25,6 +24,8 @@ public class Guilds extends PlexModule
|
||||
module = this;
|
||||
config = new ModuleConfig(this, "guilds/config.yml", "config.yml");
|
||||
config.load();
|
||||
loadMessages("guilds/messages.yml");
|
||||
this.registerCommand(new GuildCommand());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,56 +35,29 @@ public class Guilds extends PlexModule
|
||||
sqlGuildManager = new SQLGuildManager();
|
||||
sqlGuildManager.getGuilds().whenComplete((guilds, throwable) ->
|
||||
{
|
||||
PlexLog.debug("Finished loading {0} guilds", guilds.size());
|
||||
if (throwable != null)
|
||||
{
|
||||
getLogger().error("Failed to load guilds", throwable);
|
||||
return;
|
||||
}
|
||||
if (guilds == null)
|
||||
{
|
||||
getLogger().error("Failed to load guilds");
|
||||
return;
|
||||
}
|
||||
api().logging().debug("Finished loading {0} guilds", guilds.size());
|
||||
guilds.forEach(guildHolder::addGuild);
|
||||
this.registerCommand(new GuildCommand());
|
||||
});
|
||||
|
||||
//Plex.get().setChat(new ChatHandlerImpl());
|
||||
|
||||
addDefaultMessage("guildsHelpCommand", "<gradient:gold:yellow>======</gradient>Guild Menu<gradient:gold:yellow>======</gradient><newline><newline>{0}", "0 - The commands list");
|
||||
addDefaultMessage("guildsCommandDisplay", "<gold>{0} <yellow>{1}", "0 - The command name", "1 - The command description");
|
||||
addDefaultMessage("guildCommandNotFound", "<red>'<gold>{0}</gold>'<red> is not a valid sub command!", "0 - The sub command");
|
||||
addDefaultMessage("guildNotFound", "<red>You're currently not a part of a guild!");
|
||||
addDefaultMessage("guildInThis", "<red>You're currently a part of this guild!");
|
||||
addDefaultMessage("alreadyInGuild", "<red>You're currently in a guild. Please do <gold>/guild leave<red> if you're a member, or if you're an owner with members, <gold>/guild promote <player><red> then <gold>/guild leave<red>, or just an owner, <gold>/guild disband<red>.");
|
||||
addDefaultMessage("guildNotOwner", "<red>You're not the owner of this guild!");
|
||||
addDefaultMessage("guildMemberNotFound", "<red>This guild member could not be found!");
|
||||
addDefaultMessage("guildOwnerSet", "<green>You have successfully promoted <dark_green>{0}<green> to be the new guild owner. You have been set to a default guild member.");
|
||||
|
||||
addDefaultMessage("guildPrefixSet", "<green>You have changed the guild prefix to '<gold>{0}</gold><green>'", "0 - The new prefix");
|
||||
addDefaultMessage("guildPrefixCleared", "<green>Your guild's prefix has been cleared.");
|
||||
|
||||
addDefaultMessage("guildWarpAlphanumeric", "<red>Warp names may only contain alphabetical and/or numerical characters.");
|
||||
addDefaultMessage("guildWarpExists", "<red>'<gold>{0}</gold>'<red> is already an existing warp!", "0 - The warp name");
|
||||
addDefaultMessage("guildWarpNotFound", "<red>'<gold>{0}</gold>'<red> is not a valid warp!", "0 - The warp name");
|
||||
addDefaultMessage("guildWarpCreated", "<green>You have created a warp called '<dark_green>{0}</dark_green><green>'", "0 - The warp name");
|
||||
|
||||
addDefaultMessage("guildHomeRemoved", "<green>You have removed the guild's home!");
|
||||
addDefaultMessage("guildHomeSet", "<green>You have changed the guild's home!");
|
||||
addDefaultMessage("guildHomeNotFound", "<red>This guild currently has no home set.");
|
||||
|
||||
addDefaultMessage("guildChatMessage", "<blue>[GUILD] <aqua>{0} <yellow>{1}", "0 - The player name", "1 - The message");
|
||||
addDefaultMessage("guildChatToggled", "<green>Your chat has been toggled {0}", "0 - On / Off");
|
||||
addDefaultMessage("guildChatConsoleLog", "<blue>[GUILD - {0}:{1}] <aqua>{2} <yellow>{3}", "0 - The guild name", "1 - The guild unique identifier", "2 - The player name", "3 - The message");
|
||||
|
||||
addDefaultMessage("guildNoInvite", "<red>You don't have any pending invitations!");
|
||||
addDefaultMessage("guildNotValidInvite", "<red>You don't have an invite from this guild!");
|
||||
addDefaultMessage("guildInviteExists", "<red>You've already sent an invite to this person!");
|
||||
addDefaultMessage("guildInviteSent", "<green>You have sent an invite to <dark_green>{0}", "0 - The invitee");
|
||||
addDefaultMessage("guildInviteReceived", "<gold>You have received an invite from <yellow>{0}<gold> for the guild <yellow>{1}<newline><newline><green><bold><click:run_command:/guild invite accept {1}>[ACCEPT]<newline><newline><!bold><gold>You may also run <yellow>/guild invite accept {1}<gold> to accept this invite. It will expire in 5 minutes", "0 - The inviter", "1 - The guild name");
|
||||
addDefaultMessage("guildMemberJoined", "<green>{0} has joined the guild!", "0 - The player who joined");
|
||||
addDefaultMessage("guildMemberLeft", "<green>{0} has left the guild!", "0 - The player who left");
|
||||
addDefaultMessage("guildDisbandNeeded", "<red>You need to disband your guild using <gold>/guild disband<red> or promote a new owner using <gold>/guild owner <player>");
|
||||
addDefaultMessage("guildAutoDisbanded", "<green>Auto-disbanding your guild since there were no members");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable()
|
||||
{
|
||||
// Unregistering listeners / commands is handled by Plex
|
||||
this.getGuildHolder().getGuilds().forEach(sqlGuildManager::updateGuild);
|
||||
//this.getPlex().setChat(new ChatListener.PlexChatRenderer());
|
||||
if (sqlGuildManager != null)
|
||||
{
|
||||
this.getGuildHolder().getGuilds().forEach(sqlGuildManager::updateGuild);
|
||||
}
|
||||
}
|
||||
|
||||
public static Guilds get()
|
||||
|
||||
@@ -2,11 +2,9 @@ package dev.plex.command;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.command.sub.*;
|
||||
import dev.plex.util.GuildUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -20,32 +18,28 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@CommandParameters(name = "guild", description = "Guild menu", aliases = "guilds,g")
|
||||
@CommandPermissions(permission = "plex.guilds.guild")
|
||||
public class GuildCommand extends PlexCommand
|
||||
public class GuildCommand extends SimplePlexCommand
|
||||
{
|
||||
private final List<PlexCommand> subCommands = Lists.newArrayList();
|
||||
private final List<SimplePlexCommand> subCommands = Lists.newArrayList();
|
||||
|
||||
public GuildCommand()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.registerSubCommand(new CreateSubCommand());
|
||||
this.registerSubCommand(new InfoSubCommand());
|
||||
this.registerSubCommand(new PrefixSubCommand());
|
||||
this.registerSubCommand(new SetWarpSubCommand());
|
||||
this.registerSubCommand(new WarpSubCommand());
|
||||
this.registerSubCommand(new WarpListSubCommand());
|
||||
this.registerSubCommand(new ChatSubCommand());
|
||||
this.registerSubCommand(new SetHomeSubCommand());
|
||||
this.registerSubCommand(new HomeSubCommand());
|
||||
this.registerSubCommand(new OwnerSubCommand());
|
||||
this.registerSubCommand(new InviteSubCommand());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
GuildUtil.throwExceptionSync(e);
|
||||
}
|
||||
super(command("guild")
|
||||
.description("Guild menu")
|
||||
.aliases("guilds,g")
|
||||
.permission("plex.guilds.guild")
|
||||
.build());
|
||||
this.registerSubCommand(new CreateSubCommand());
|
||||
this.registerSubCommand(new InfoSubCommand());
|
||||
this.registerSubCommand(new PrefixSubCommand());
|
||||
this.registerSubCommand(new SetWarpSubCommand());
|
||||
this.registerSubCommand(new WarpSubCommand());
|
||||
this.registerSubCommand(new WarpListSubCommand());
|
||||
this.registerSubCommand(new ChatSubCommand());
|
||||
this.registerSubCommand(new SetHomeSubCommand());
|
||||
this.registerSubCommand(new HomeSubCommand());
|
||||
this.registerSubCommand(new OwnerSubCommand());
|
||||
this.registerSubCommand(new InviteSubCommand());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,83 +60,78 @@ public class GuildCommand extends PlexCommand
|
||||
{
|
||||
return messageComponent("guildCommandNotFound", args[1]);
|
||||
}
|
||||
CommandPermissions permissions = subCommand.getClass().getDeclaredAnnotation(CommandPermissions.class);
|
||||
return mmString("<gradient:gold:yellow>========<newline>").append(mmString("<gold>Command Name: <yellow>" + subCommand.getName())).append(Component.newline())
|
||||
.append(mmString("<gold>Command Aliases: <yellow>" + StringUtils.join(subCommand.getAliases(), ", "))).append(Component.newline())
|
||||
.append(mmString("<gold>Description: <yellow>" + subCommand.getDescription())).append(Component.newline())
|
||||
.append(mmString("<gold>Permission: <yellow>" + permissions.permission())).append(Component.newline())
|
||||
.append(mmString("<gold>Required Source: <yellow>" + permissions.source().name()));
|
||||
.append(mmString("<gold>Permission: <yellow>" + subCommand.getPermission())).append(Component.newline())
|
||||
.append(mmString("<gold>Required Source: <yellow>" + subCommand.getRequiredSource().name()));
|
||||
}
|
||||
PlexCommand subCommand = getSubCommand(args[0]);
|
||||
SimplePlexCommand subCommand = getSubCommand(args[0]);
|
||||
if (subCommand == null)
|
||||
{
|
||||
return messageComponent("guildCommandNotFound", args[0]);
|
||||
}
|
||||
|
||||
CommandPermissions permissions = subCommand.getClass().getDeclaredAnnotation(CommandPermissions.class);
|
||||
if (permissions.source() == RequiredCommandSource.CONSOLE && commandSender instanceof Player)
|
||||
if (subCommand.getRequiredSource() == RequiredCommandSource.CONSOLE && commandSender instanceof Player)
|
||||
{
|
||||
return messageComponent("noPermissionInGame");
|
||||
}
|
||||
|
||||
if (permissions.source() == RequiredCommandSource.IN_GAME && commandSender instanceof ConsoleCommandSender)
|
||||
if (subCommand.getRequiredSource() == RequiredCommandSource.IN_GAME && commandSender instanceof ConsoleCommandSender)
|
||||
{
|
||||
return messageComponent("noPermissionConsole");
|
||||
}
|
||||
|
||||
checkPermission(player, permissions.permission());
|
||||
checkPermission(commandSender, subCommand.getPermission());
|
||||
|
||||
return subCommand.execute(commandSender, player, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
|
||||
private PlexCommand getSubCommand(String label)
|
||||
private SimplePlexCommand getSubCommand(String label)
|
||||
{
|
||||
return subCommands.stream().filter(cmd ->
|
||||
{
|
||||
CommandParameters commandParameters = cmd.getClass().getDeclaredAnnotation(CommandParameters.class);
|
||||
return commandParameters.name().equalsIgnoreCase(label) || Arrays.stream(commandParameters.aliases().split(",")).anyMatch(s -> s.equalsIgnoreCase(label));
|
||||
}).findFirst().orElse(null);
|
||||
return subCommands.stream()
|
||||
.filter(cmd -> cmd.getName().equalsIgnoreCase(label) || cmd.getAliases().stream().anyMatch(alias -> alias.equalsIgnoreCase(label)))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private void registerSubCommand(PlexCommand subCommand)
|
||||
private void registerSubCommand(SimplePlexCommand subCommand)
|
||||
{
|
||||
if (!subCommand.getClass().isAnnotationPresent(CommandPermissions.class))
|
||||
if (Guilds.get() != null)
|
||||
{
|
||||
throw new RuntimeException("CommandPermissions annotation for guild sub command " + subCommand.getName() + " could not be found!");
|
||||
}
|
||||
|
||||
if (!subCommand.getClass().isAnnotationPresent(CommandParameters.class))
|
||||
{
|
||||
throw new RuntimeException("CommandParameters annotation for guild sub command " + subCommand.getName() + " could not be found!");
|
||||
subCommand.bindModule(Guilds.get());
|
||||
if (Guilds.get().api() != null)
|
||||
{
|
||||
subCommand.bindApi(Guilds.get().api());
|
||||
}
|
||||
}
|
||||
this.subCommands.add(subCommand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
protected @NotNull List<String> suggestions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
List<String> possibleCommands = Lists.newArrayList();
|
||||
if (!args[0].isEmpty())
|
||||
subCommands.forEach(plexCommand ->
|
||||
{
|
||||
subCommands.forEach(plexCommand ->
|
||||
plexCommand.getAliases().stream()
|
||||
.filter(s -> s.toLowerCase(Locale.ROOT).startsWith(args[0].toLowerCase(Locale.ROOT)))
|
||||
.forEach(possibleCommands::add);
|
||||
if (plexCommand.getName().toLowerCase(Locale.ROOT).startsWith(args[0].toLowerCase(Locale.ROOT)))
|
||||
{
|
||||
plexCommand.getAliases().stream().filter(s -> s.toLowerCase(Locale.ROOT).startsWith(args[0].toLowerCase(Locale.ROOT))).forEach(possibleCommands::add);
|
||||
if (plexCommand.getName().toLowerCase(Locale.ROOT).startsWith(args[0].toLowerCase(Locale.ROOT)))
|
||||
{
|
||||
possibleCommands.add(plexCommand.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
possibleCommands.add(plexCommand.getName());
|
||||
}
|
||||
});
|
||||
return possibleCommands;
|
||||
}
|
||||
if (args.length >= 2)
|
||||
{
|
||||
PlexCommand subCommand = getSubCommand(args[0]);
|
||||
SimplePlexCommand subCommand = getSubCommand(args[0]);
|
||||
if (subCommand != null)
|
||||
{
|
||||
return subCommand.tabComplete(sender, alias, Arrays.copyOfRange(args, 1, args.length));
|
||||
return subCommand.suggestions(sender, alias, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
}
|
||||
return ImmutableList.of();
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package dev.plex.command.sub;
|
||||
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.guild.data.Member;
|
||||
import java.util.Collections;
|
||||
@@ -18,13 +16,16 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "chat", usage = "/guild <command> [message]", description = "Toggles guild chat or sends a guild chat message")
|
||||
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.chat")
|
||||
public class ChatSubCommand extends PlexCommand
|
||||
public class ChatSubCommand extends SimplePlexCommand
|
||||
{
|
||||
public ChatSubCommand()
|
||||
{
|
||||
super(false);
|
||||
super(command("chat")
|
||||
.description("Toggles guild chat or sends a guild chat message")
|
||||
.usage("/guild <command> [message]")
|
||||
.permission("plex.guilds.chat")
|
||||
.source(RequiredCommandSource.IN_GAME)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,7 +45,7 @@ public class ChatSubCommand extends PlexCommand
|
||||
{
|
||||
send(player1, messageComponent("guildChatMessage", player.getName(), StringUtils.join(args, " ")));
|
||||
});
|
||||
if (Guilds.get().getConfig().isBoolean("guilds.log-chat-message"))
|
||||
if (Guilds.get().getConfig().getBoolean("guilds.log-chat-message"))
|
||||
{
|
||||
send(Bukkit.getConsoleSender(), messageComponent("guildChatConsoleLog", guild.getName(), guild.getGuildUuid(), player.getName(), StringUtils.join(args, " ")));
|
||||
}
|
||||
@@ -53,7 +54,7 @@ public class ChatSubCommand extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package dev.plex.command.sub;
|
||||
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.guild.Guild;
|
||||
import java.util.Collections;
|
||||
@@ -15,13 +13,17 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "create", aliases = "make", usage = "/guild <command> <name>", description = "Creates a guild with a specified name")
|
||||
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.create")
|
||||
public class CreateSubCommand extends PlexCommand
|
||||
public class CreateSubCommand extends SimplePlexCommand
|
||||
{
|
||||
public CreateSubCommand()
|
||||
{
|
||||
super(false);
|
||||
super(command("create")
|
||||
.description("Creates a guild with a specified name")
|
||||
.usage("/guild <command> <name>")
|
||||
.aliases("make")
|
||||
.permission("plex.guilds.create")
|
||||
.source(RequiredCommandSource.IN_GAME)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,7 +47,7 @@ public class CreateSubCommand extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package dev.plex.command.sub;
|
||||
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -13,13 +11,17 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "home", aliases = "spawn", usage = "/guild <command>", description = "Teleports to the guild home")
|
||||
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.home")
|
||||
public class HomeSubCommand extends PlexCommand
|
||||
public class HomeSubCommand extends SimplePlexCommand
|
||||
{
|
||||
public HomeSubCommand()
|
||||
{
|
||||
super(false);
|
||||
super(command("home")
|
||||
.description("Teleports to the guild home")
|
||||
.usage("/guild <command>")
|
||||
.aliases("spawn")
|
||||
.permission("plex.guilds.home")
|
||||
.source(RequiredCommandSource.IN_GAME)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,7 +41,7 @@ public class HomeSubCommand extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package dev.plex.command.sub;
|
||||
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.api.player.PlexPlayerView;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collections;
|
||||
@@ -17,13 +15,17 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "info", aliases = "information", usage = "/guild <command>", description = "Shows the guild's information")
|
||||
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.info")
|
||||
public class InfoSubCommand extends PlexCommand
|
||||
public class InfoSubCommand extends SimplePlexCommand
|
||||
{
|
||||
public InfoSubCommand()
|
||||
{
|
||||
super(false);
|
||||
super(command("info")
|
||||
.description("Shows the guild's information")
|
||||
.usage("/guild <command>")
|
||||
.aliases("information")
|
||||
.permission("plex.guilds.info")
|
||||
.source(RequiredCommandSource.IN_GAME)
|
||||
.build());
|
||||
}
|
||||
|
||||
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy hh:mm:ss a");
|
||||
@@ -38,26 +40,24 @@ public class InfoSubCommand extends PlexCommand
|
||||
{
|
||||
send(player, mmString("<gradient:yellow:gold>====<aqua>" + guild.getName() + "<gradient:yellow:gold>===="));
|
||||
send(player, mmString(""));
|
||||
try
|
||||
{
|
||||
send(player, mmString("<gold>Owner: <yellow>" + DataUtils.getPlayer(guild.getOwner().getUuid(), false).getName()));
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
send(player, mmString("<gold>Owner: <yellow>Unable to load cache..."));
|
||||
}
|
||||
List<String> members = guild.getMembers().stream().filter(member -> !member.getUuid().equals(guild.getOwner().getUuid())).map(member -> DataUtils.getPlayer(member.getUuid(), false).getName()).toList();
|
||||
send(player, mmString("<gold>Owner: <yellow>" + playerName(guild.getOwner().getUuid())));
|
||||
List<String> members = guild.getMembers().stream().filter(member -> !member.getUuid().equals(guild.getOwner().getUuid())).map(member -> playerName(member.getUuid())).toList();
|
||||
send(player, mmString("<gold>Members (" + members.size() + "): " + StringUtils.join(members, ", ")));
|
||||
send(player, mmString("<gold>Moderators (" + guild.getModerators().size() + "): " + StringUtils.join(guild.getModerators().stream().map(uuid -> DataUtils.getPlayer(uuid, false).getName()).toList(), ", ")));
|
||||
send(player, mmString("<gold>Moderators (" + guild.getModerators().size() + "): " + StringUtils.join(guild.getModerators().stream().map(this::playerName).toList(), ", ")));
|
||||
send(player, mmString("<gold>Prefix: " + (guild.getPrefix() == null ? "N/A" : guild.getPrefix())));
|
||||
send(player, mmString("<gold>Created At: " + formatter.format(guild.getCreatedAt())));
|
||||
}, () -> send(player, messageComponent("guildNotFound")));
|
||||
});
|
||||
}, Guilds.get().api().scheduler().asyncExecutor());
|
||||
return null;
|
||||
}
|
||||
|
||||
private String playerName(java.util.UUID uuid)
|
||||
{
|
||||
return api().players().byUuid(uuid).map(PlexPlayerView::name).orElse("Unable to load cache...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -2,14 +2,11 @@ package dev.plex.command.sub;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.guild.Guild;
|
||||
import dev.plex.guild.GuildHolder;
|
||||
import dev.plex.guild.data.Member;
|
||||
import dev.plex.util.PlexLog;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -25,13 +22,17 @@ import java.util.stream.Collectors;
|
||||
// TODO: 5/9/2022 deny command maybe?
|
||||
// TODO: 5/9/2022 deny members from inviting themselves or existing members in the current guild
|
||||
|
||||
@CommandParameters(name = "invite", aliases = "inv", usage = "/guild <command> <player name>", description = "Invites a player to the guild")
|
||||
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.invite")
|
||||
public class InviteSubCommand extends PlexCommand
|
||||
public class InviteSubCommand extends SimplePlexCommand
|
||||
{
|
||||
public InviteSubCommand()
|
||||
{
|
||||
super(false);
|
||||
super(command("invite")
|
||||
.description("Invites a player to the guild")
|
||||
.usage("/guild <command> <player name>")
|
||||
.aliases("inv")
|
||||
.permission("plex.guilds.invite")
|
||||
.source(RequiredCommandSource.IN_GAME)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,7 +117,7 @@ public class InviteSubCommand extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
protected @NotNull List<String> suggestions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (!(sender instanceof Player player))
|
||||
{
|
||||
@@ -132,7 +133,7 @@ public class InviteSubCommand extends PlexCommand
|
||||
{
|
||||
return ImmutableList.of();
|
||||
}
|
||||
PlexLog.debug("Tab Completing moment");
|
||||
api().logging().debug("Completing pending guild invites");
|
||||
return GuildHolder.PENDING_INVITES.get(player.getUniqueId()).stream().map(Guild::getName).collect(Collectors.toList());
|
||||
}
|
||||
return ImmutableList.of();
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package dev.plex.command.sub;
|
||||
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.api.player.PlexPlayerView;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.guild.data.Member;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -16,13 +13,17 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "owner", aliases = "setowner", usage = "/guild <command> <player name>", description = "Sets the guild owner")
|
||||
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.owner")
|
||||
public class OwnerSubCommand extends PlexCommand
|
||||
public class OwnerSubCommand extends SimplePlexCommand
|
||||
{
|
||||
public OwnerSubCommand()
|
||||
{
|
||||
super(false);
|
||||
super(command("owner")
|
||||
.description("Sets the guild owner")
|
||||
.usage("/guild <command> <player name>")
|
||||
.aliases("setowner")
|
||||
.permission("plex.guilds.owner")
|
||||
.source(RequiredCommandSource.IN_GAME)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,13 +42,13 @@ public class OwnerSubCommand extends PlexCommand
|
||||
return;
|
||||
}
|
||||
Member memberSender = guild.getMember(player.getUniqueId());
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(args[0], false);
|
||||
PlexPlayerView plexPlayer = api().players().byName(args[0]).orElse(null);
|
||||
if (plexPlayer == null)
|
||||
{
|
||||
send(player, messageComponent("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
Member member = guild.getMember(plexPlayer.getUuid());
|
||||
Member member = guild.getMember(plexPlayer.uuid());
|
||||
if (member == null)
|
||||
{
|
||||
send(player, messageComponent("guildMemberNotFound"));
|
||||
@@ -56,13 +57,13 @@ public class OwnerSubCommand extends PlexCommand
|
||||
guild.setOwner(member);
|
||||
guild.getMembers().remove(member);
|
||||
guild.getMembers().add(memberSender);
|
||||
send(player, messageComponent("guildOwnerSet", plexPlayer.getName()));
|
||||
send(player, messageComponent("guildOwnerSet", plexPlayer.name()));
|
||||
}, () -> send(player, messageComponent("guildNotFound")));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package dev.plex.command.sub;
|
||||
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import dev.plex.util.GuildUtil;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -15,13 +13,17 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "prefix", aliases = "tag,settag,setprefix", usage = "/guild <command> <prefix>", description = "Sets the guild's default prefix")
|
||||
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.prefix")
|
||||
public class PrefixSubCommand extends PlexCommand
|
||||
public class PrefixSubCommand extends SimplePlexCommand
|
||||
{
|
||||
public PrefixSubCommand()
|
||||
{
|
||||
super(false);
|
||||
super(command("prefix")
|
||||
.description("Sets the guild's default prefix")
|
||||
.usage("/guild <command> <prefix>")
|
||||
.aliases("tag,settag,setprefix")
|
||||
.permission("plex.guilds.prefix")
|
||||
.source(RequiredCommandSource.IN_GAME)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,13 +48,13 @@ public class PrefixSubCommand extends PlexCommand
|
||||
return;
|
||||
}
|
||||
guild.setPrefix(StringUtils.join(args, " "));
|
||||
send(player, messageComponent("guildPrefixSet", SafeMiniMessage.mmDeserializeWithoutEvents(guild.getPrefix())));
|
||||
send(player, messageComponent("guildPrefixSet", GuildUtil.miniMessageWithoutEvents(guild.getPrefix())));
|
||||
}, () -> send(player, messageComponent("guildNotFound")));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package dev.plex.command.sub;
|
||||
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.util.CustomLocation;
|
||||
import java.util.Collections;
|
||||
@@ -14,13 +12,17 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "sethome", aliases = "setspawn", usage = "/guild <command>", description = "Sets the guild's home")
|
||||
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.sethome")
|
||||
public class SetHomeSubCommand extends PlexCommand
|
||||
public class SetHomeSubCommand extends SimplePlexCommand
|
||||
{
|
||||
public SetHomeSubCommand()
|
||||
{
|
||||
super(false);
|
||||
super(command("sethome")
|
||||
.description("Sets the guild's home")
|
||||
.usage("/guild <command>")
|
||||
.aliases("setspawn")
|
||||
.permission("plex.guilds.sethome")
|
||||
.source(RequiredCommandSource.IN_GAME)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,7 +54,7 @@ public class SetHomeSubCommand extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package dev.plex.command.sub;
|
||||
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.util.CustomLocation;
|
||||
import java.util.Collections;
|
||||
@@ -16,13 +14,17 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "setwarp", aliases = "makewarp,createwarp", usage = "/guild <command> <name>", description = "Creates a new warp at player's location with a specified name")
|
||||
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.setwarp")
|
||||
public class SetWarpSubCommand extends PlexCommand
|
||||
public class SetWarpSubCommand extends SimplePlexCommand
|
||||
{
|
||||
public SetWarpSubCommand()
|
||||
{
|
||||
super(false);
|
||||
super(command("setwarp")
|
||||
.description("Creates a new warp at player's location with a specified name")
|
||||
.usage("/guild <command> <name>")
|
||||
.aliases("makewarp,createwarp")
|
||||
.permission("plex.guilds.setwarp")
|
||||
.source(RequiredCommandSource.IN_GAME)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,7 +65,7 @@ public class SetWarpSubCommand extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@ package dev.plex.command.sub;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.guild.Guild;
|
||||
import java.util.Collections;
|
||||
@@ -16,13 +14,17 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "warps", aliases = "listwarps", usage = "/guild <command>", description = "Displays a clickable list of warps")
|
||||
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.warps")
|
||||
public class WarpListSubCommand extends PlexCommand
|
||||
public class WarpListSubCommand extends SimplePlexCommand
|
||||
{
|
||||
public WarpListSubCommand()
|
||||
{
|
||||
super(false);
|
||||
super(command("warps")
|
||||
.description("Displays a clickable list of warps")
|
||||
.usage("/guild <command>")
|
||||
.aliases("listwarps")
|
||||
.permission("plex.guilds.warps")
|
||||
.source(RequiredCommandSource.IN_GAME)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +57,7 @@ public class WarpListSubCommand extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package dev.plex.command.sub;
|
||||
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.SimplePlexCommand;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -14,13 +12,17 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "warp", aliases = "goto", usage = "/guild <command> <name>", description = "Warps to a specified guild warp")
|
||||
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.warp")
|
||||
public class WarpSubCommand extends PlexCommand
|
||||
public class WarpSubCommand extends SimplePlexCommand
|
||||
{
|
||||
public WarpSubCommand()
|
||||
{
|
||||
super(false);
|
||||
super(command("warp")
|
||||
.description("Warps to a specified guild warp")
|
||||
.usage("/guild <command> <name>")
|
||||
.aliases("goto")
|
||||
.permission("plex.guilds.warp")
|
||||
.source(RequiredCommandSource.IN_GAME)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,7 +47,7 @@ public class WarpSubCommand extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -2,13 +2,12 @@ package dev.plex.data;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import dev.plex.Guilds;
|
||||
import com.google.gson.Gson;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.guild.Guild;
|
||||
import dev.plex.guild.data.Member;
|
||||
import dev.plex.util.CustomLocation;
|
||||
import dev.plex.util.GuildUtil;
|
||||
import dev.plex.util.PlexLog;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@@ -34,11 +33,10 @@ public class SQLGuildManager
|
||||
|
||||
public CompletableFuture<Guild> insertGuild(Guild guild)
|
||||
{
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
return supplyStorageAsync(connection ->
|
||||
{
|
||||
try (Connection connection = Plex.get().getSqlConnection().getCon())
|
||||
try (PreparedStatement statement = connection.prepareStatement(INSERT_GUILD))
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(INSERT_GUILD);
|
||||
statement.setString(1, guild.getGuildUuid().toString());
|
||||
statement.setString(2, guild.getName());
|
||||
statement.setString(3, GSON.toJson(guild.getOwner()));
|
||||
@@ -56,38 +54,28 @@ public class SQLGuildManager
|
||||
statement.execute();
|
||||
return guild;
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
GuildUtil.throwExceptionSync(e);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> deleteGuild(UUID uuid)
|
||||
{
|
||||
return CompletableFuture.runAsync(() ->
|
||||
return supplyStorageAsync(connection ->
|
||||
{
|
||||
try (Connection connection = Plex.get().getSqlConnection().getCon())
|
||||
try (PreparedStatement statement = connection.prepareStatement(DELETE_GUILD))
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(DELETE_GUILD);
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.execute();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
GuildUtil.throwExceptionSync(e);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<Guild> updateGuild(Guild guild)
|
||||
{
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
return supplyStorageAsync(connection ->
|
||||
{
|
||||
try (Connection connection = Plex.get().getSqlConnection().getCon())
|
||||
try (PreparedStatement statement = connection.prepareStatement(UPDATE_GUILD))
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(UPDATE_GUILD);
|
||||
statement.setString(1, guild.getName());
|
||||
statement.setString(2, GSON.toJson(guild.getOwner()));
|
||||
statement.setString(3, GSON.toJson(guild.getMembers()));
|
||||
@@ -104,34 +92,36 @@ public class SQLGuildManager
|
||||
statement.executeUpdate();
|
||||
return guild;
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
GuildUtil.throwExceptionSync(e);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<Guild> getGuildsSync()
|
||||
private List<Guild> getGuildsSync(Connection connection) throws SQLException
|
||||
{
|
||||
List<Guild> guilds = Lists.newArrayList();
|
||||
try (Connection connection = Plex.get().getSqlConnection().getCon())
|
||||
try (PreparedStatement statement = connection.prepareStatement(SELECT_GUILD);
|
||||
ResultSet set = statement.executeQuery())
|
||||
{
|
||||
PreparedStatement statement = connection.prepareStatement(SELECT_GUILD);
|
||||
ResultSet set = statement.executeQuery();
|
||||
while (set.next())
|
||||
{
|
||||
String timezone = Guilds.get().api().configuration().mainConfig().getString("server.timezone", "Etc/UTC");
|
||||
Guild guild = new Guild(UUID.fromString(set.getString("guildUuid")),
|
||||
ZonedDateTime.ofInstant(Instant.ofEpochMilli(set.getLong("createdAt")), ZoneId.of(Plex.get().config.getString("server.timezone")).getRules().getOffset(Instant.now())));
|
||||
ZonedDateTime.ofInstant(Instant.ofEpochMilli(set.getLong("createdAt")), ZoneId.of(timezone).getRules().getOffset(Instant.now())));
|
||||
guild.setName(set.getString("name"));
|
||||
guild.setOwner(GSON.fromJson(set.getString("owner"), Member.class));
|
||||
List<Member> members = new Gson().fromJson(set.getString("members"), new TypeToken<List<Member>>()
|
||||
{
|
||||
}.getType());
|
||||
members.forEach(guild::addMember);
|
||||
guild.getModerators().addAll(new Gson().fromJson(set.getString("moderators"), new TypeToken<List<String>>()
|
||||
if (members != null)
|
||||
{
|
||||
}.getType()));
|
||||
members.forEach(guild::addMember);
|
||||
}
|
||||
List<String> moderators = new Gson().fromJson(set.getString("moderators"), new TypeToken<List<String>>()
|
||||
{
|
||||
}.getType());
|
||||
if (moderators != null)
|
||||
{
|
||||
moderators.stream().map(UUID::fromString).forEach(guild.getModerators()::add);
|
||||
}
|
||||
guild.setPrefix(set.getString("prefix"));
|
||||
guild.setMotd(set.getString("motd"));
|
||||
guild.setHome(GSON.fromJson(set.getString("home"), CustomLocation.class));
|
||||
@@ -139,24 +129,37 @@ public class SQLGuildManager
|
||||
Map<String, CustomLocation> warps = GSON.fromJson(set.getString("warps"), new TypeToken<Map<String, CustomLocation>>()
|
||||
{
|
||||
}.getType());
|
||||
PlexLog.debug("Loaded {0} warps for {1} guild", warps.size(), guild.getName());
|
||||
guild.getWarps().putAll(GSON.fromJson(set.getString("warps"), new TypeToken<Map<String, CustomLocation>>()
|
||||
if (warps != null)
|
||||
{
|
||||
}.getType()));
|
||||
Guilds.get().api().logging().debug("Loaded {0} warps for {1} guild", warps.size(), guild.getName());
|
||||
guild.getWarps().putAll(warps);
|
||||
}
|
||||
guild.setPublic(set.getBoolean("isPublic"));
|
||||
guilds.add(guild);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
GuildUtil.throwExceptionSync(e);
|
||||
}
|
||||
return guilds;
|
||||
}
|
||||
|
||||
public CompletableFuture<List<Guild>> getGuilds()
|
||||
{
|
||||
return CompletableFuture.supplyAsync(this::getGuildsSync);
|
||||
return supplyStorageAsync(this::getGuildsSync);
|
||||
}
|
||||
|
||||
private <T> CompletableFuture<T> supplyStorageAsync(dev.plex.api.storage.StorageApi.SqlFunction<T> function)
|
||||
{
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
return Guilds.get().api().storage().withConnection(function);
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
GuildUtil.throwExceptionSync(e);
|
||||
return null;
|
||||
}
|
||||
}, Guilds.get().api().scheduler().asyncExecutor());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,39 +1,46 @@
|
||||
package dev.plex.data;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.util.GuildUtil;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class SQLManager
|
||||
{
|
||||
public static void makeTables()
|
||||
{
|
||||
try (Connection connection = Plex.get().getSqlConnection().getCon())
|
||||
try
|
||||
{
|
||||
connection.prepareStatement(
|
||||
"CREATE TABLE IF NOT EXISTS `guilds` (" +
|
||||
"`guildUuid` VARCHAR(46) NOT NULL, " +
|
||||
"`name` VARCHAR(2000) NOT NULL, " +
|
||||
"`owner` LONGTEXT NOT NULL, " +
|
||||
"`createdAt` BIGINT NOT NULL, " +
|
||||
"`prefix` VARCHAR(2000), " +
|
||||
"`motd` VARCHAR(3000), " +
|
||||
"`home` VARCHAR(1000)," +
|
||||
"`members` LONGTEXT, " +
|
||||
"`moderators` LONGTEXT, " +
|
||||
"`ranks` LONGTEXT, " +
|
||||
"`defaultRank` LONGTEXT, " +
|
||||
"`warps` LONGTEXT, " +
|
||||
"`tagEnabled` BOOLEAN, " +
|
||||
"`isPublic` BOOLEAN, " +
|
||||
"PRIMARY KEY (`guildUuid`)" +
|
||||
");"
|
||||
).execute();
|
||||
Guilds.get().api().storage().withConnection(connection ->
|
||||
{
|
||||
try (PreparedStatement statement = connection.prepareStatement(
|
||||
"CREATE TABLE IF NOT EXISTS `guilds` (" +
|
||||
"`guildUuid` VARCHAR(46) NOT NULL, " +
|
||||
"`name` VARCHAR(2000) NOT NULL, " +
|
||||
"`owner` LONGTEXT NOT NULL, " +
|
||||
"`createdAt` BIGINT NOT NULL, " +
|
||||
"`prefix` VARCHAR(2000), " +
|
||||
"`motd` VARCHAR(3000), " +
|
||||
"`home` VARCHAR(1000)," +
|
||||
"`members` LONGTEXT, " +
|
||||
"`moderators` LONGTEXT, " +
|
||||
"`ranks` LONGTEXT, " +
|
||||
"`defaultRank` LONGTEXT, " +
|
||||
"`warps` LONGTEXT, " +
|
||||
"`tagEnabled` BOOLEAN, " +
|
||||
"`isPublic` BOOLEAN, " +
|
||||
"PRIMARY KEY (`guildUuid`)" +
|
||||
");"))
|
||||
{
|
||||
statement.execute();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
GuildUtil.throwExceptionSync(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ package dev.plex.guild;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.guild.data.Member;
|
||||
import dev.plex.guild.data.Rank;
|
||||
import dev.plex.util.CustomLocation;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import dev.plex.util.GuildUtil;
|
||||
import lombok.Data;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -38,8 +38,9 @@ public class Guild
|
||||
|
||||
public static Guild create(Player player, String guildName)
|
||||
{
|
||||
Guild guild = new Guild(UUID.randomUUID(), ZonedDateTime.now(ZoneId.of(Plex.get().config.getString("server.timezone"))));
|
||||
guild.setName(PlainTextComponentSerializer.plainText().serialize(SafeMiniMessage.mmDeserialize(guildName)));
|
||||
String timezone = Guilds.get().api().configuration().mainConfig().getString("server.timezone", "Etc/UTC");
|
||||
Guild guild = new Guild(UUID.randomUUID(), ZonedDateTime.now(ZoneId.of(timezone)));
|
||||
guild.setName(PlainTextComponentSerializer.plainText().serialize(GuildUtil.miniMessageWithoutEvents(guildName)));
|
||||
guild.setOwner(new Member(player.getUniqueId()));
|
||||
return guild;
|
||||
}
|
||||
|
||||
@@ -1,96 +1,37 @@
|
||||
package dev.plex.handler;
|
||||
|
||||
import dev.plex.Guilds;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.guild.data.Member;
|
||||
import dev.plex.hook.VaultHook;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import io.papermc.paper.chat.ChatRenderer;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
||||
import java.util.Objects;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class ChatHandlerImpl
|
||||
public class ChatHandlerImpl implements Listener
|
||||
{
|
||||
private final static TextReplacementConfig URL_REPLACEMENT_CONFIG = TextReplacementConfig.builder().match("(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]").replacement((matchResult, builder) -> Component.empty().content(matchResult.group()).clickEvent(ClickEvent.openUrl(matchResult.group()))).build();
|
||||
private final PlexChatRenderer renderer = new PlexChatRenderer();
|
||||
|
||||
@EventHandler
|
||||
public void doChat(AsyncChatEvent event)
|
||||
{
|
||||
event.renderer(renderer);
|
||||
Player player = event.getPlayer();
|
||||
Guilds.get().getGuildHolder().getGuild(player.getUniqueId()).ifPresent(guild ->
|
||||
{
|
||||
Member member = guild.getMember(player.getUniqueId());
|
||||
if (member == null)
|
||||
if (member == null || !member.isChat())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!member.isChat())
|
||||
|
||||
String message = PlainTextComponentSerializer.plainText().serialize(event.message());
|
||||
guild.getMembers().stream().map(Member::getPlayer).filter(Objects::nonNull).forEach(memberPlayer ->
|
||||
memberPlayer.sendMessage(Guilds.get().messageComponent("guildChatMessage", player.getName(), message)));
|
||||
if (Guilds.get().getConfig().getBoolean("guilds.log-chat-message"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
guild.getMembers().stream().map(Member::getPlayer).filter(Objects::nonNull).forEach(player1 ->
|
||||
{
|
||||
player1.sendMessage(PlexUtils.messageComponent("guildChatMessage", player.getName(), PlainTextComponentSerializer.plainText().serialize(event.message())));
|
||||
});
|
||||
if (Guilds.get().getConfig().isBoolean("guilds.log-chat-message"))
|
||||
{
|
||||
Bukkit.getConsoleSender().sendMessage(PlexUtils.messageComponent("guildChatConsoleLog", guild.getName(), guild.getGuildUuid(), player.getName(), PlainTextComponentSerializer.plainText().serialize(event.message())));
|
||||
Bukkit.getConsoleSender().sendMessage(Guilds.get().messageComponent("guildChatConsoleLog", guild.getName(), guild.getGuildUuid(), player.getName(), message));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
});
|
||||
}
|
||||
|
||||
public static class PlexChatRenderer implements ChatRenderer
|
||||
{
|
||||
@Override
|
||||
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer)
|
||||
{
|
||||
String text = PlexUtils.getTextFromComponent(message);
|
||||
|
||||
PlexPlayer plexPlayer = Plex.get().getPlayerCache().getPlexPlayerMap().get(source.getUniqueId());
|
||||
Component prefix = VaultHook.getPrefix(plexPlayer);
|
||||
|
||||
AtomicBoolean guildPrefix = new AtomicBoolean(false);
|
||||
AtomicReference<Component> component = new AtomicReference<>(Component.empty());
|
||||
Guilds.get().getGuildHolder().getGuild(source.getUniqueId()).ifPresent(guild ->
|
||||
{
|
||||
if (guild.getPrefix() != null)
|
||||
{
|
||||
component.set(component.get().append(SafeMiniMessage.mmDeserializeWithoutEvents(guild.getPrefix())));
|
||||
guildPrefix.set(true);
|
||||
}
|
||||
});
|
||||
|
||||
if (prefix != null)
|
||||
{
|
||||
if (guildPrefix.get())
|
||||
{
|
||||
component.set(component.get().append(Component.space()));
|
||||
}
|
||||
component.set(component.get().append(prefix));
|
||||
}
|
||||
|
||||
return component.get().append(Component.space()).append(PlexUtils.mmDeserialize(Plex.get().config.getString("chat.name-color", "<white>") + MiniMessage.builder().tags(TagResolver.resolver(StandardTags.color(), StandardTags.rainbow(), StandardTags.decorations(), StandardTags.gradient(), StandardTags.transition())).build().serialize(sourceDisplayName))).append(Component.space()).append(Component.text("»").color(NamedTextColor.GRAY)).append(Component.space()).append(SafeMiniMessage.mmDeserializeWithoutEvents(text)).replaceText(URL_REPLACEMENT_CONFIG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
package dev.plex.util;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import org.bukkit.Bukkit;
|
||||
import dev.plex.Guilds;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
public class GuildUtil
|
||||
{
|
||||
private static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage();
|
||||
|
||||
public static void throwExceptionSync(Throwable throwable)
|
||||
{
|
||||
Bukkit.getScheduler().runTask(Plex.get(), () -> throwable.printStackTrace());
|
||||
if (Guilds.get() != null && Guilds.get().getLogger() != null)
|
||||
{
|
||||
Guilds.get().getLogger().error("Guild module task failed", throwable);
|
||||
return;
|
||||
}
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
public static Component miniMessageWithoutEvents(String text)
|
||||
{
|
||||
return MINI_MESSAGE.deserialize(text).clickEvent(null).hoverEvent(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
guildsHelpCommand: "<gradient:gold:yellow>======</gradient>Guild Menu<gradient:gold:yellow>======</gradient><newline><newline>{0}"
|
||||
guildsCommandDisplay: "<gold>{0} <yellow>{1}"
|
||||
guildCommandNotFound: "<red>'<gold>{0}</gold>'<red> is not a valid sub command!"
|
||||
guildNotFound: "<red>You're currently not a part of a guild!"
|
||||
guildInThis: "<red>You're currently a part of this guild!"
|
||||
alreadyInGuild: "<red>You're currently in a guild. Please do <gold>/guild leave<red> if you're a member, or if you're an owner with members, <gold>/guild promote <player><red> then <gold>/guild leave<red>, or just an owner, <gold>/guild disband<red>."
|
||||
guildNotOwner: "<red>You're not the owner of this guild!"
|
||||
guildMemberNotFound: "<red>This guild member could not be found!"
|
||||
guildOwnerSet: "<green>You have successfully promoted <dark_green>{0}<green> to be the new guild owner. You have been set to a default guild member."
|
||||
guildPrefixSet: "<green>You have changed the guild prefix to '<gold>{0}</gold><green>'"
|
||||
guildPrefixCleared: "<green>Your guild's prefix has been cleared."
|
||||
guildWarpAlphanumeric: "<red>Warp names may only contain alphabetical and/or numerical characters."
|
||||
guildWarpExists: "<red>'<gold>{0}</gold>'<red> is already an existing warp!"
|
||||
guildWarpNotFound: "<red>'<gold>{0}</gold>'<red> is not a valid warp!"
|
||||
guildWarpCreated: "<green>You have created a warp called '<dark_green>{0}</dark_green><green>'"
|
||||
guildHomeRemoved: "<green>You have removed the guild's home!"
|
||||
guildHomeSet: "<green>You have changed the guild's home!"
|
||||
guildHomeNotFound: "<red>This guild currently has no home set."
|
||||
guildChatMessage: "<blue>[GUILD] <aqua>{0} <yellow>{1}"
|
||||
guildChatToggled: "<green>Your chat has been toggled {0}"
|
||||
guildChatConsoleLog: "<blue>[GUILD - {0}:{1}] <aqua>{2} <yellow>{3}"
|
||||
guildNoInvite: "<red>You don't have any pending invitations!"
|
||||
guildNotValidInvite: "<red>You don't have an invite from this guild!"
|
||||
guildInviteExists: "<red>You've already sent an invite to this person!"
|
||||
guildInviteSent: "<green>You have sent an invite to <dark_green>{0}"
|
||||
guildInviteReceived: "<gold>You have received an invite from <yellow>{0}<gold> for the guild <yellow>{1}<newline><newline><green><bold><click:run_command:/guild invite accept {1}>[ACCEPT]<newline><newline><!bold><gold>You may also run <yellow>/guild invite accept {1}<gold> to accept this invite. It will expire in 5 minutes"
|
||||
guildMemberJoined: "<green>{0} has joined the guild!"
|
||||
guildMemberLeft: "<green>{0} has left the guild!"
|
||||
guildDisbandNeeded: "<red>You need to disband your guild using <gold>/guild disband<red> or promote a new owner using <gold>/guild owner <player>"
|
||||
guildAutoDisbanded: "<green>Auto-disbanding your guild since there were no members"
|
||||
@@ -1,4 +1,5 @@
|
||||
name: Module-Guilds
|
||||
main: dev.plex.Guilds
|
||||
description: The guilds module for Plex
|
||||
version: 1.5
|
||||
version: 2.0-SNAPSHOT
|
||||
apiCompatibility: 1
|
||||
|
||||
Reference in New Issue
Block a user