mirror of
https://github.com/plexusorg/Module-NickMiniMessage.git
synced 2026-06-04 01:06:55 +00:00
Update for Plex 2.0
This commit is contained in:
+7
-7
@@ -20,19 +20,19 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("org.projectlombok:lombok:1.18.42")
|
compileOnly("org.projectlombok:lombok:1.18.46")
|
||||||
annotationProcessor("org.projectlombok:lombok:1.18.42")
|
annotationProcessor("org.projectlombok:lombok:1.18.46")
|
||||||
compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:26.1.2.build.+")
|
||||||
compileOnly("dev.plex:server:1.6")
|
compileOnly("dev.plex:api:2.0-SNAPSHOT")
|
||||||
compileOnly("net.essentialsx:EssentialsX:2.21.2-SNAPSHOT")
|
compileOnly("net.essentialsx:EssentialsX:2.22.0-SNAPSHOT")
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "dev.plex"
|
group = "dev.plex"
|
||||||
version = "1.6"
|
version = "2.0-SNAPSHOT"
|
||||||
description = "Module-NickMiniMessage"
|
description = "Module-NickMiniMessage"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
+3
-1
@@ -1,7 +1,9 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
|
retries=0
|
||||||
|
retryBackOffMs=500
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015-2021 the original authors.
|
# Copyright © 2015 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (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.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@@ -86,8 +86,7 @@ done
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# 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
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -115,7 +114,6 @@ case "$( uname )" in #(
|
|||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# 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
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if "$cygwin" || "$msys" ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
@@ -206,15 +203,14 @@ fi
|
|||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# 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.
|
# 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
|
# * 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.
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
# Stop when "xargs" is not available.
|
||||||
|
|||||||
Vendored
+10
-22
@@ -23,8 +23,8 @@
|
|||||||
@rem
|
@rem
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
setlocal EnableExtensions
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
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 Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
"%COMSPEC%" /c exit 1
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
:findJavaFromJavaHome
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
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 Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
"%COMSPEC%" /c exit 1
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@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
|
:exitWithErrorLevel
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||||
|
|
||||||
: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
|
|
||||||
|
|||||||
@@ -2,18 +2,22 @@ package dev.plex.module.nickmm.command;
|
|||||||
|
|
||||||
import com.earth2me.essentials.I18n;
|
import com.earth2me.essentials.I18n;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.SimplePlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.module.nickmm.NickMiniMessageModule;
|
import dev.plex.module.nickmm.NickMiniMessageModule;
|
||||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.minimessage.Context;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
import net.kyori.adventure.text.minimessage.ParsingException;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -22,12 +26,22 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@CommandParameters(name = "nickmm", description = "Change your nickname using MiniMessage formatting!", usage = "/<command> <nick>", aliases = "nickminimessage")
|
public class NickMMCommand extends SimplePlexCommand
|
||||||
@CommandPermissions(permission = "plex.nickmm", source = RequiredCommandSource.IN_GAME)
|
|
||||||
public class NickMMCommand extends PlexCommand
|
|
||||||
{
|
{
|
||||||
private final PlainTextComponentSerializer plainText = PlainTextComponentSerializer.plainText();
|
private final PlainTextComponentSerializer plainText = PlainTextComponentSerializer.plainText();
|
||||||
private final LegacyComponentSerializer legacyComponent = LegacyComponentSerializer.legacySection();
|
private final LegacyComponentSerializer legacyComponent = LegacyComponentSerializer.legacySection();
|
||||||
|
private final MiniMessage miniMessage = MiniMessage.builder().tags(new NicknameTagResolver()).build();
|
||||||
|
|
||||||
|
public NickMMCommand()
|
||||||
|
{
|
||||||
|
super(command("nickmm")
|
||||||
|
.description("Change your nickname using MiniMessage formatting!")
|
||||||
|
.usage("/<command> <nick>")
|
||||||
|
.aliases("nickminimessage")
|
||||||
|
.permission("plex.nickmm")
|
||||||
|
.source(RequiredCommandSource.IN_GAME)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
|
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] args)
|
||||||
@@ -42,7 +56,7 @@ public class NickMMCommand extends PlexCommand
|
|||||||
return usage();
|
return usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Component nick = SafeMiniMessage.mmDeserializeWithoutEvents(args[0]);
|
final Component nick = miniMessage.deserialize(args[0]).clickEvent(null).hoverEvent(null);
|
||||||
final String plain = plainText.serialize(nick);
|
final String plain = plainText.serialize(nick);
|
||||||
|
|
||||||
if (plain.length() > NickMiniMessageModule.getEssentials().getSettings().getMaxNickLength()
|
if (plain.length() > NickMiniMessageModule.getEssentials().getSettings().getMaxNickLength()
|
||||||
@@ -65,14 +79,45 @@ public class NickMMCommand extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String legacy = legacyComponent.serialize(nick);
|
final String legacy = legacyComponent.serialize(nick);
|
||||||
NickMiniMessageModule.getEssentials().getUser(player).setNickname(legacy);
|
User essentialsUser = NickMiniMessageModule.getEssentials().getUser(player);
|
||||||
|
essentialsUser.setNickname(legacy);
|
||||||
|
essentialsUser.setDisplayNick();
|
||||||
|
|
||||||
return mmString(I18n.tlLiteral("nickSet", legacy));
|
return mmString(I18n.tlLiteral("nickSet", legacy));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
||||||
{
|
{
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class NicknameTagResolver implements TagResolver
|
||||||
|
{
|
||||||
|
private static final TagResolver STANDARD_RESOLVER = TagResolver.standard();
|
||||||
|
private static final List<String> IGNORED_TAGS = Arrays.asList(
|
||||||
|
"click",
|
||||||
|
"hover",
|
||||||
|
"insertion",
|
||||||
|
"insert",
|
||||||
|
"obfuscated",
|
||||||
|
"obf",
|
||||||
|
"br",
|
||||||
|
"newline",
|
||||||
|
"lang",
|
||||||
|
"key",
|
||||||
|
"translate");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable Tag resolve(@NotNull String name, @NotNull ArgumentQueue arguments, @NotNull Context ctx) throws ParsingException
|
||||||
|
{
|
||||||
|
return IGNORED_TAGS.contains(name.toLowerCase()) ? null : STANDARD_RESOLVER.resolve(name, arguments, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean has(@NotNull String name)
|
||||||
|
{
|
||||||
|
return STANDARD_RESOLVER.has(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
name: Module-NickMiniMessage
|
name: Module-NickMiniMessage
|
||||||
main: dev.plex.module.nickmm.NickMiniMessageModule
|
main: dev.plex.module.nickmm.NickMiniMessageModule
|
||||||
description: Module for Plex that adds a command allowing for Essentials nicknames to be created with MiniMessage
|
description: Module for Plex that adds a command allowing for Essentials nicknames to be created with MiniMessage
|
||||||
version: 1.6
|
version: 2.0-SNAPSHOT
|
||||||
|
apiCompatibility: 1
|
||||||
|
|||||||
Reference in New Issue
Block a user