mirror of
https://github.com/plexusorg/ItemizerX.git
synced 2024-11-24 13:15:01 +00:00
Rewrite this in a way that actually makes sense
This commit is contained in:
parent
dc1b460c6a
commit
cdf06b5a5d
@ -4,10 +4,12 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "dev.plex"
|
group = "dev.plex"
|
||||||
version = "2.0"
|
version = "2.1"
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
|
apply(plugin = "java")
|
||||||
apply(plugin = "com.github.johnrengelman.shadow")
|
apply(plugin = "com.github.johnrengelman.shadow")
|
||||||
|
java.sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -24,6 +26,14 @@ subprojects {
|
|||||||
url = uri("https://maven.playpro.com/")
|
url = uri("https://maven.playpro.com/")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
if (project.name != "shared") {
|
||||||
|
implementation(project(":shared"))
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOnly("net.coreprotect:coreprotect:21.3")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
@ -1,10 +1,3 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
}
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":shared"))
|
implementation(project(":shared"))
|
||||||
implementation(project(":v1_20_R1"))
|
implementation(project(":v1_20_R1"))
|
||||||
@ -14,6 +7,5 @@ dependencies {
|
|||||||
implementation(project(":v1_18_R2"))
|
implementation(project(":v1_18_R2"))
|
||||||
implementation(project(":v1_18_R1"))
|
implementation(project(":v1_18_R1"))
|
||||||
implementation(project(":v1_17_R1"))
|
implementation(project(":v1_17_R1"))
|
||||||
compileOnly("io.papermc.paper:paper-api:1.20-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
|
||||||
compileOnly("net.coreprotect:coreprotect:21.3")
|
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ public class ItemizerX extends JavaPlugin {
|
|||||||
|
|
||||||
public static ItemizerX plugin;
|
public static ItemizerX plugin;
|
||||||
CoreProtectBridge cpb = new CoreProtectBridge();
|
CoreProtectBridge cpb = new CoreProtectBridge();
|
||||||
|
IAttributeManager attr;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
@ -16,45 +17,40 @@ public class ItemizerX extends JavaPlugin {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
cpb.getCoreProtect();
|
cpb.getCoreProtect();
|
||||||
|
getCommand("itemizer").setExecutor(new ItemizerXCommand());
|
||||||
|
getCommand("itemizer").setTabCompleter(new ItemizerXTab());
|
||||||
switch (getNMSVersion()) {
|
switch (getNMSVersion()) {
|
||||||
case "v1_20_R1": {
|
case "v1_20_R1": {
|
||||||
getCommand("itemizer").setExecutor(new dev.plex.itemizerx.v1_20_R1.ItemizerXCommand());
|
attr = new dev.plex.itemizerx.v1_20_R1.AttributeManager();
|
||||||
getCommand("itemizer").setTabCompleter(new dev.plex.itemizerx.v1_20_R1.ItemizerXTab());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case "v1_19_R3": {
|
case "v1_19_R3": {
|
||||||
getCommand("itemizer").setExecutor(new dev.plex.itemizerx.v1_19_R3.ItemizerXCommand());
|
attr = new dev.plex.itemizerx.v1_19_R3.AttributeManager();
|
||||||
getCommand("itemizer").setTabCompleter(new dev.plex.itemizerx.v1_19_R3.ItemizerXTab());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case "v1_19_R2": {
|
case "v1_19_R2": {
|
||||||
getCommand("itemizer").setExecutor(new dev.plex.itemizerx.v1_19_R2.ItemizerXCommand());
|
attr = new dev.plex.itemizerx.v1_19_R2.AttributeManager();
|
||||||
getCommand("itemizer").setTabCompleter(new dev.plex.itemizerx.v1_19_R2.ItemizerXTab());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case "v1_19_R1": {
|
case "v1_19_R1": {
|
||||||
getCommand("itemizer").setExecutor(new dev.plex.itemizerx.v1_19_R1.ItemizerXCommand());
|
attr = new dev.plex.itemizerx.v1_19_R1.AttributeManager();
|
||||||
getCommand("itemizer").setTabCompleter(new dev.plex.itemizerx.v1_19_R1.ItemizerXTab());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case "v1_18_R2": {
|
case "v1_18_R2": {
|
||||||
getCommand("itemizer").setExecutor(new dev.plex.itemizerx.v1_18_R2.ItemizerXCommand());
|
attr = new dev.plex.itemizerx.v1_18_R2.AttributeManager();
|
||||||
getCommand("itemizer").setTabCompleter(new dev.plex.itemizerx.v1_18_R2.ItemizerXTab());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case "v1_18_R1": {
|
case "v1_18_R1": {
|
||||||
getCommand("itemizer").setExecutor(new dev.plex.itemizerx.v1_18_R1.ItemizerXCommand());
|
attr = new dev.plex.itemizerx.v1_18_R1.AttributeManager();
|
||||||
getCommand("itemizer").setTabCompleter(new dev.plex.itemizerx.v1_18_R1.ItemizerXTab());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case "v1_17_R1": {
|
case "v1_17_R1": {
|
||||||
getCommand("itemizer").setExecutor(new dev.plex.itemizerx.v1_17_R1.ItemizerXCommand());
|
attr = new dev.plex.itemizerx.v1_17_R1.AttributeManager();
|
||||||
getCommand("itemizer").setTabCompleter(new dev.plex.itemizerx.v1_17_R1.ItemizerXTab());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
getLogger().severe("You are trying to run ItemizerX on an incompatible server version.");
|
getLogger().severe("You are trying to run ItemizerX on an incompatible server version.");
|
||||||
getLogger().severe("ItemizerX only supports versions 1.17 to 1.20, disabling plugin.");
|
getLogger().severe("ItemizerX only supports versions 1.17 to 1.20.1, disabling plugin.");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
core/src/main/java/dev/plex/itemizerx/ItemizerXBase.java
Normal file
5
core/src/main/java/dev/plex/itemizerx/ItemizerXBase.java
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package dev.plex.itemizerx;
|
||||||
|
|
||||||
|
public interface ItemizerXBase {
|
||||||
|
ItemizerX plugin = ItemizerX.plugin;
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package dev.plex.itemizerx.v1_17_R1;
|
package dev.plex.itemizerx;
|
||||||
|
|
||||||
import dev.plex.itemizerx.CoreProtectBridge;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -27,7 +26,7 @@ import java.util.Objects;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class ItemizerXCommand implements CommandExecutor {
|
public class ItemizerXCommand implements CommandExecutor, ItemizerXBase {
|
||||||
|
|
||||||
final List<Material> POTIONS = Arrays.asList(Material.POTION, Material.LINGERING_POTION, Material.SPLASH_POTION);
|
final List<Material> POTIONS = Arrays.asList(Material.POTION, Material.LINGERING_POTION, Material.SPLASH_POTION);
|
||||||
CoreProtectBridge cpb = new CoreProtectBridge();
|
CoreProtectBridge cpb = new CoreProtectBridge();
|
||||||
@ -419,7 +418,7 @@ public class ItemizerXCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
AttributeManager.addAttr(player, args);
|
plugin.attr.addAttr(player, args);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "remove" -> {
|
case "remove" -> {
|
||||||
@ -427,7 +426,7 @@ public class ItemizerXCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
AttributeManager.removeAttr(player, args[2]);
|
plugin.attr.removeAttr(player, args[2]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "list" -> {
|
case "list" -> {
|
||||||
@ -435,7 +434,7 @@ public class ItemizerXCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
AttributeManager.listAttr(player);
|
plugin.attr.listAttr(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "listall" -> {
|
case "listall" -> {
|
||||||
@ -444,7 +443,7 @@ public class ItemizerXCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
sender.sendMessage(colorize("&2Supported attributes: "
|
sender.sendMessage(colorize("&2Supported attributes: "
|
||||||
+ "&e" + AttributeManager.Attributes.getAttributes()));
|
+ "&e" + Attributes.getAttributes()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
@ -1,4 +1,4 @@
|
|||||||
package dev.plex.itemizerx.v1_18_R2;
|
package dev.plex.itemizerx;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -66,7 +66,7 @@ public class ItemizerXTab implements TabCompleter {
|
|||||||
switch (args[1]) {
|
switch (args[1]) {
|
||||||
case "add":
|
case "add":
|
||||||
case "remove": {
|
case "remove": {
|
||||||
return AttributeManager.Attributes.getAttributeList();
|
return Attributes.getAttributeList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Thu Jun 15 15:30:03 CDT 2023
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
18
gradlew
vendored
18
gradlew
vendored
@ -55,7 +55,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/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/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/.
|
||||||
@ -80,10 +80,10 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
@ -143,12 +143,16 @@ fi
|
|||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@ -205,6 +209,12 @@ set -- \
|
|||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@ -25,7 +25,8 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
@ -1,11 +1,4 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
}
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
|
||||||
compileOnly("net.coreprotect:coreprotect:21.3")
|
compileOnly("org.spigotmc:spigot:1.20.1-R0.1-SNAPSHOT")
|
||||||
}
|
}
|
51
shared/src/main/java/dev/plex/itemizerx/Attributes.java
Normal file
51
shared/src/main/java/dev/plex/itemizerx/Attributes.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package dev.plex.itemizerx;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public enum Attributes {
|
||||||
|
|
||||||
|
MAX_HEALTH("generic.max_health", 0),
|
||||||
|
FOLLOW_RANGE("generic.follow_range", 1),
|
||||||
|
KNOCKBACK_RESISTANCE("generic.knockback_resistance", 1),
|
||||||
|
MOVEMENT_SPEED("generic.movement_speed", 1),
|
||||||
|
DAMAGE("generic.attack_damage", 0),
|
||||||
|
ARMOR("generic.armor", 0),
|
||||||
|
ARMOR_TOUGHNESS("generic.armor_toughness", 0),
|
||||||
|
FLYING_SPEED("generic.flying_speed", 1),
|
||||||
|
ATTACK_SPEED("generic.attack_speed", 1),
|
||||||
|
LUCK("generic.luck", 0),
|
||||||
|
HORSE_JUMP("horse.jump_strength", 1),
|
||||||
|
ZOMBIE_REINFORCEMENTS("zombie.spawn_reinforcements", 1);
|
||||||
|
|
||||||
|
public final String mcName;
|
||||||
|
public final int op;
|
||||||
|
|
||||||
|
Attributes(String mcName, int op) {
|
||||||
|
this.mcName = mcName;
|
||||||
|
this.op = op;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Attributes get(String name) {
|
||||||
|
for (Attributes attr : values()) {
|
||||||
|
if (attr.name().equalsIgnoreCase(name) || attr.mcName.equalsIgnoreCase(name)) {
|
||||||
|
return attr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getAttributes() {
|
||||||
|
return StringUtils.join(values(), ", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getAttributeList() {
|
||||||
|
List<String> attributes = new ArrayList<>();
|
||||||
|
for (Attributes attr : values()) {
|
||||||
|
attributes.add(attr.name());
|
||||||
|
}
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package dev.plex.itemizerx;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface IAttributeManager {
|
||||||
|
NBTTagList getAttrList(final ItemStack item);
|
||||||
|
|
||||||
|
void addAttr(final Player player, final String[] args);
|
||||||
|
|
||||||
|
void removeAttr(final Player player, final String string);
|
||||||
|
|
||||||
|
void listAttr(final Player player);
|
||||||
|
|
||||||
|
String colorize(String string);
|
||||||
|
}
|
@ -1,12 +1,3 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
}
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":shared"))
|
|
||||||
compileOnly("org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT")
|
||||||
compileOnly("net.coreprotect:coreprotect:21.3")
|
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package dev.plex.itemizerx.v1_17_R1;
|
package dev.plex.itemizerx.v1_17_R1;
|
||||||
|
|
||||||
|
import dev.plex.itemizerx.Attributes;
|
||||||
|
import dev.plex.itemizerx.IAttributeManager;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@ -12,9 +14,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class AttributeManager {
|
public class AttributeManager implements IAttributeManager {
|
||||||
|
|
||||||
public static NBTTagList getAttrList(final ItemStack item) {
|
@Override
|
||||||
|
public NBTTagList getAttrList(final ItemStack item) {
|
||||||
NBTTagList attrmod = item.getOrCreateTag().getList("AttributeModifiers", 10);
|
NBTTagList attrmod = item.getOrCreateTag().getList("AttributeModifiers", 10);
|
||||||
if (attrmod == null) {
|
if (attrmod == null) {
|
||||||
item.getTag().set("AttributeModifiers", new NBTTagList());
|
item.getTag().set("AttributeModifiers", new NBTTagList());
|
||||||
@ -22,7 +25,8 @@ public class AttributeManager {
|
|||||||
return item.getTag().getList("AttributeModifiers", 10);
|
return item.getTag().getList("AttributeModifiers", 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addAttr(final Player player, final String[] args) {
|
@Override
|
||||||
|
public void addAttr(final Player player, final String[] args) {
|
||||||
int op;
|
int op;
|
||||||
if (args.length < 4) {
|
if (args.length < 4) {
|
||||||
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
||||||
@ -90,7 +94,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute added!"));
|
player.sendMessage(colorize("&2Attribute added!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeAttr(final Player player, final String string) {
|
@Override
|
||||||
|
public void removeAttr(final Player player, final String string) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
final NBTTagList newList = new NBTTagList();
|
final NBTTagList newList = new NBTTagList();
|
||||||
@ -113,7 +118,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute removed!"));
|
player.sendMessage(colorize("&2Attribute removed!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void listAttr(final Player player) {
|
@Override
|
||||||
|
public void listAttr(final Player player) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
if (attrmod.size() == 0) {
|
if (attrmod.size() == 0) {
|
||||||
@ -128,52 +134,8 @@ public class AttributeManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String colorize(String string) {
|
@Override
|
||||||
|
public String colorize(String string) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
return ChatColor.translateAlternateColorCodes('&', string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Attributes {
|
|
||||||
|
|
||||||
MAX_HEALTH("generic.max_health", 0),
|
|
||||||
FOLLOW_RANGE("generic.follow_range", 1),
|
|
||||||
KNOCKBACK_RESISTANCE("generic.knockback_resistance", 1),
|
|
||||||
MOVEMENT_SPEED("generic.movement_speed", 1),
|
|
||||||
DAMAGE("generic.attack_damage", 0),
|
|
||||||
ARMOR("generic.armor", 0),
|
|
||||||
ARMOR_TOUGHNESS("generic.armor_toughness", 0),
|
|
||||||
FLYING_SPEED("generic.flying_speed", 1),
|
|
||||||
ATTACK_SPEED("generic.attack_speed", 1),
|
|
||||||
LUCK("generic.luck", 0),
|
|
||||||
HORSE_JUMP("horse.jump_strength", 1),
|
|
||||||
ZOMBIE_REINFORCEMENTS("zombie.spawn_reinforcements", 1);
|
|
||||||
|
|
||||||
private final String mcName;
|
|
||||||
private final int op;
|
|
||||||
|
|
||||||
Attributes(String mcName, int op) {
|
|
||||||
this.mcName = mcName;
|
|
||||||
this.op = op;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Attributes get(String name) {
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
if (attr.name().equalsIgnoreCase(name) || attr.mcName.equalsIgnoreCase(name)) {
|
|
||||||
return attr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getAttributes() {
|
|
||||||
return StringUtils.join(values(), ", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getAttributeList() {
|
|
||||||
List<String> attributes = new ArrayList<>();
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
attributes.add(attr.name());
|
|
||||||
}
|
|
||||||
return attributes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,105 +0,0 @@
|
|||||||
package dev.plex.itemizerx.v1_17_R1;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemizerXTab implements TabCompleter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String string, String[] args) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
return Arrays.asList("help", "id", "lore", "potion", "attr", "flag", "enchant", "title", "author",
|
|
||||||
"head", "sign", "clearall");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 2) {
|
|
||||||
switch (args[0]) {
|
|
||||||
case "id": {
|
|
||||||
List<String> materials = new ArrayList<>();
|
|
||||||
for (Material material : Material.values()) {
|
|
||||||
materials.add(material.name());
|
|
||||||
}
|
|
||||||
return materials;
|
|
||||||
}
|
|
||||||
case "lore": {
|
|
||||||
return Arrays.asList("add", "remove", "change", "clear");
|
|
||||||
}
|
|
||||||
case "potion": {
|
|
||||||
return Arrays.asList("add", "remove", "change", "color", "list");
|
|
||||||
}
|
|
||||||
case "attr":
|
|
||||||
case "flag":
|
|
||||||
case "enchant": {
|
|
||||||
return Arrays.asList("add", "remove", "list", "listall");
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 3) {
|
|
||||||
switch (args[0]) {
|
|
||||||
case "potion": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> potions = new ArrayList<>();
|
|
||||||
for (PotionEffectType effect : PotionEffectType.values()) {
|
|
||||||
potions.add(effect.getName());
|
|
||||||
}
|
|
||||||
return potions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "attr": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
return AttributeManager.Attributes.getAttributeList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "flag": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> flags = new ArrayList<>();
|
|
||||||
for (ItemFlag flag : ItemFlag.values()) {
|
|
||||||
flags.add(flag.name());
|
|
||||||
}
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "enchant": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> enchantments = new ArrayList<>();
|
|
||||||
for (Enchantment enchantment : Enchantment.values()) {
|
|
||||||
enchantments.add(enchantment.getKey().getKey());
|
|
||||||
}
|
|
||||||
return enchantments;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,3 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
}
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":shared"))
|
|
||||||
compileOnly("org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT")
|
||||||
compileOnly("net.coreprotect:coreprotect:21.3")
|
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package dev.plex.itemizerx.v1_18_R1;
|
package dev.plex.itemizerx.v1_18_R1;
|
||||||
|
|
||||||
|
import dev.plex.itemizerx.Attributes;
|
||||||
|
import dev.plex.itemizerx.IAttributeManager;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@ -12,9 +14,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class AttributeManager {
|
public class AttributeManager implements IAttributeManager {
|
||||||
|
|
||||||
public static NBTTagList getAttrList(final ItemStack item) {
|
@Override
|
||||||
|
public NBTTagList getAttrList(final ItemStack item) {
|
||||||
NBTTagList attrmod = item.t().c("AttributeModifiers", 10);
|
NBTTagList attrmod = item.t().c("AttributeModifiers", 10);
|
||||||
if (attrmod == null) {
|
if (attrmod == null) {
|
||||||
item.t().a("AttributeModifiers", new NBTTagList());
|
item.t().a("AttributeModifiers", new NBTTagList());
|
||||||
@ -22,7 +25,8 @@ public class AttributeManager {
|
|||||||
return item.t().c("AttributeModifiers", 10);
|
return item.t().c("AttributeModifiers", 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addAttr(final Player player, final String[] args) {
|
@Override
|
||||||
|
public void addAttr(final Player player, final String[] args) {
|
||||||
int op;
|
int op;
|
||||||
if (args.length < 4) {
|
if (args.length < 4) {
|
||||||
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
||||||
@ -90,7 +94,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute added!"));
|
player.sendMessage(colorize("&2Attribute added!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeAttr(final Player player, final String string) {
|
@Override
|
||||||
|
public void removeAttr(final Player player, final String string) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
final NBTTagList newList = new NBTTagList();
|
final NBTTagList newList = new NBTTagList();
|
||||||
@ -113,7 +118,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute removed!"));
|
player.sendMessage(colorize("&2Attribute removed!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void listAttr(final Player player) {
|
@Override
|
||||||
|
public void listAttr(final Player player) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
if (attrmod.size() == 0) {
|
if (attrmod.size() == 0) {
|
||||||
@ -128,52 +134,8 @@ public class AttributeManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String colorize(String string) {
|
@Override
|
||||||
|
public String colorize(String string) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
return ChatColor.translateAlternateColorCodes('&', string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Attributes {
|
|
||||||
|
|
||||||
MAX_HEALTH("generic.max_health", 0),
|
|
||||||
FOLLOW_RANGE("generic.follow_range", 1),
|
|
||||||
KNOCKBACK_RESISTANCE("generic.knockback_resistance", 1),
|
|
||||||
MOVEMENT_SPEED("generic.movement_speed", 1),
|
|
||||||
DAMAGE("generic.attack_damage", 0),
|
|
||||||
ARMOR("generic.armor", 0),
|
|
||||||
ARMOR_TOUGHNESS("generic.armor_toughness", 0),
|
|
||||||
FLYING_SPEED("generic.flying_speed", 1),
|
|
||||||
ATTACK_SPEED("generic.attack_speed", 1),
|
|
||||||
LUCK("generic.luck", 0),
|
|
||||||
HORSE_JUMP("horse.jump_strength", 1),
|
|
||||||
ZOMBIE_REINFORCEMENTS("zombie.spawn_reinforcements", 1);
|
|
||||||
|
|
||||||
private final String mcName;
|
|
||||||
private final int op;
|
|
||||||
|
|
||||||
Attributes(String mcName, int op) {
|
|
||||||
this.mcName = mcName;
|
|
||||||
this.op = op;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Attributes get(String name) {
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
if (attr.name().equalsIgnoreCase(name) || attr.mcName.equalsIgnoreCase(name)) {
|
|
||||||
return attr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getAttributes() {
|
|
||||||
return StringUtils.join(values(), ", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getAttributeList() {
|
|
||||||
List<String> attributes = new ArrayList<>();
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
attributes.add(attr.name());
|
|
||||||
}
|
|
||||||
return attributes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,810 +0,0 @@
|
|||||||
package dev.plex.itemizerx.v1_18_R1;
|
|
||||||
|
|
||||||
import dev.plex.itemizerx.CoreProtectBridge;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.*;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.enchantments.EnchantmentWrapper;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.BookMeta;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class ItemizerXCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
final List<Material> POTIONS = Arrays.asList(Material.POTION, Material.LINGERING_POTION, Material.SPLASH_POTION);
|
|
||||||
CoreProtectBridge cpb = new CoreProtectBridge();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String string, String[] args) {
|
|
||||||
if (!sender.hasPermission("itemizer.use")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
sender.sendMessage(ChatColor.AQUA + "ItemizerX " + ChatColor.GOLD + "v"
|
|
||||||
+ Bukkit.getPluginManager().getPlugin("ItemizerX").getDescription().getVersion()
|
|
||||||
+ ChatColor.AQUA + " by " + ChatColor.GOLD
|
|
||||||
+ StringUtils.join(Bukkit.getPluginManager().getPlugin("ItemizerX").getDescription().getAuthors(), ", "));
|
|
||||||
sender.sendMessage(ChatColor.AQUA + "Type " + ChatColor.GOLD + "/itemizer help "
|
|
||||||
+ ChatColor.AQUA + "for help");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sender instanceof final Player player)) {
|
|
||||||
sender.sendMessage(colorize("&4You must be a player to execute this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ItemStack item = player.getInventory().getItemInMainHand();
|
|
||||||
final boolean hasItem = item.getType() != Material.AIR;
|
|
||||||
final boolean hasPotion = POTIONS.contains(item.getType());
|
|
||||||
final boolean hasBook = item.getType() == Material.WRITTEN_BOOK;
|
|
||||||
final ItemMeta meta = item.getItemMeta();
|
|
||||||
|
|
||||||
switch (args[0]) {
|
|
||||||
case "help" -> {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3=============&f[&dItemizerX Commands&f]&3=============
|
|
||||||
&b/itemizer name <&fname&b> &c- &6Name your item
|
|
||||||
&b/itemizer id <&fid&b> &c- &6Change the item's material
|
|
||||||
&b/itemizer lore &c- &6Lore editing command
|
|
||||||
&b/itemizer potion &c- &6Potion editing command
|
|
||||||
&b/itemizer attr &c- &6Attribute editing command
|
|
||||||
&b/itemizer flag &c- &6Flag editing command
|
|
||||||
&b/itemizer enchant &c- &6Enchant editing command
|
|
||||||
&b/itemizer title <&fname&b> &c- &6Set the book's title
|
|
||||||
&b/itemizer author <&fname&b> &c- &6Set the book's author
|
|
||||||
&b/itemizer head <&fname&b> &c- &6Set the player of the head
|
|
||||||
&b/itemizer sign <&fline&b> <&ftext&b> &c- &6Change the line on the sign
|
|
||||||
&b/itemizer clearall &c- &6Clears all metadata from your item"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "name" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.name")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dName Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer name <&fname&b> &c - &6Name your item"));
|
|
||||||
} else {
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(StringUtils.join(args, " ", 1, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
meta.setDisplayName(name);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The name of the item in your hand has been set to &f'" + name + "&f'"));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "id" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.id")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dID Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer id <&fid&b> &c- &6Change the item's material"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Material material = Material.matchMaterial(args[1].toUpperCase());
|
|
||||||
if (material == null) {
|
|
||||||
sender.sendMessage(colorize("&4The material &f\"" + args[1] + "&f\"&4 does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setType(material);
|
|
||||||
sender.sendMessage(colorize("&2The material of the item has changed to &f'" + material.name() + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "lore" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dLore Commands&f]&3===============
|
|
||||||
&b/itemizer lore add <&ftext&b> &c- &6Add a line of text to your item's lore
|
|
||||||
&b/itemizer lore remove <&findex&b> &c- &6Remove a line of text from your item's lore
|
|
||||||
&b/itemizer lore change <&findex&b> <&ftext&b> &c- &6Change a line of text in your item's lore
|
|
||||||
&b/itemizer lore clear &c- &6Clear the item's lore"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore add <&ftext&b> &c- &6Add a line of text to your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String lore = colorize(StringUtils.join(args, " ", 2, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores = new ArrayList<>();
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
}
|
|
||||||
lores.add(lore);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + lore + "&f'&2 added to the item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore remove <&findex&b> &c- &6Remove a line of text from your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer index = parseInt(sender, args[2]);
|
|
||||||
if (index == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores;
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(colorize("&eThis item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (index > lores.size()) {
|
|
||||||
sender.sendMessage(colorize("&4The item's lore doesn't have line &f'" + index + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
lores.remove(index - 1);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + index + "&f'&2 removed from the item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "change" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.change")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 4) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore change <&findex&b> <&ftext&b> &c- &6Change a line of text in your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer index = parseInt(sender, args[2]);
|
|
||||||
if (index == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String lore = colorize(StringUtils.join(args, " ", 3, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores;
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(colorize("&eThis item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (index > lores.size()) {
|
|
||||||
sender.sendMessage(colorize("&4The item's lore doesn't have line &f'" + index + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
lores.set(index - 1, lore);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + index + "'&2 has changed to &f'" + lore + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "clear" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.clear")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (meta.getLore() == null || meta.getLore().isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4The item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.setLore(null);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The item's lore has been cleared!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer lore &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "potion" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dPotion Commands&f]&3===============
|
|
||||||
&b/itemizer potion add <&feffect&b> <&flevel&b> <&ftime[tick]&b> &c- &6Add a potion effect
|
|
||||||
&b/itemizer potion remove <&feffect&b> &c- &6Remove a potion effect
|
|
||||||
&b/itemizer potion change <&fname&b> &c- &6Change the potion type
|
|
||||||
&b/itemizer potion color <&fhexcolor&b> &c- &6Set the potion color
|
|
||||||
&b/itemizer potion list &c- &6List all potion effects"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasPotion) {
|
|
||||||
sender.sendMessage("Get a POTION in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 5) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion add <&feffect&b> <&flevel&b> <&ftime[tick]&b> &c- &6Add a potion effect"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PotionEffectType potType = PotionEffectType.getByName(args[2].toUpperCase());
|
|
||||||
if (potType == null) {
|
|
||||||
sender.sendMessage(colorize("&4The potion &f\"" + args[2] + "&f\"&4 does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer level = parseInt(sender, args[3]);
|
|
||||||
Integer tick = parseInt(sender, args[4]);
|
|
||||||
if (level == null || tick == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionEffect pot = new PotionEffect(potType, tick, level);
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
if (potionMeta.hasCustomEffect(pot.getType())) {
|
|
||||||
sender.sendMessage(colorize("&4This potion already has &f" + pot.getType().getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
potionMeta.addCustomEffect(pot, false);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(pot.getType().getName() + " &2has been added to the potion"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion remove <&feffect&b> &c- &6Remove a potion effect"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PotionEffectType potType = PotionEffectType.getByName(args[2].toUpperCase());
|
|
||||||
if (potType == null) {
|
|
||||||
sender.sendMessage("&4The potion effect &f\"" + args[2] + "&f\"&4 does not exist!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
if (!potionMeta.hasCustomEffect(potType)) {
|
|
||||||
sender.sendMessage(colorize("This potion does not have &f" + potType.getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
potionMeta.removeCustomEffect(potType);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(potType.getName() + " &2has been removed from the potion"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "change" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.change")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion change <&fname&b> &c- &6Change the potion type"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Material material = Material.matchMaterial(args[2]);
|
|
||||||
if (material == null || !POTIONS.contains(material)) {
|
|
||||||
sender.sendMessage(colorize(material != null ?
|
|
||||||
"&f'" + material.name() + "' &4is not a potion type!"
|
|
||||||
:
|
|
||||||
"&4That material doesn't exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setType(material);
|
|
||||||
sender.sendMessage(colorize("&2The potion in hand has changed to &f'" + material.name() + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "color" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.color")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 3) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion color <&fhexcolor&b> &c- &6Set a potion color"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
try {
|
|
||||||
java.awt.Color awtColor = java.awt.Color.decode(args[2]);
|
|
||||||
Color color = Color.fromRGB(awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue());
|
|
||||||
potionMeta.setColor(color);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(args[2] + " &2has been set as potion color"));
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
sender.sendMessage(colorize("&4The hex &f\"" + args[2] + "&f\"&4 is invalid!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
PotionEffectType[] effects;
|
|
||||||
for (int i = 0; i < (effects = PotionEffectType.values()).length; i++) {
|
|
||||||
sb.append(", ").append(effects[i].getName());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available potion effects: &e"
|
|
||||||
+ sb.toString().replaceFirst(", ", "")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer potion &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "attr" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dAttribute Commands&f]&3===============
|
|
||||||
&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c - &6Add an attribute
|
|
||||||
&b/itemizer attr remove <&fname&b> &c- &6Remove an attribute
|
|
||||||
&b/itemizer attr list &c- &6List all item's attributes
|
|
||||||
&b/itemizer attr listall &c- &6List all supported attributes"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.addAttr(player, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.removeAttr(player, args[2]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.listAttr(player);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Supported attributes: "
|
|
||||||
+ "&e" + AttributeManager.Attributes.getAttributes()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer attr &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "flag" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dFlag Commands&f]&3===============
|
|
||||||
&b/itemizer flag add <&fname&b> &c- &6Add a flag
|
|
||||||
&b/itemizer flag remove <&fname&b> &c- &6Remove a flag
|
|
||||||
&b/itemizer flag list &c- &6List all item's flag
|
|
||||||
&b/itemizer flag listall &c- &6List all available flags"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dFlag Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer flag add <&fname&b> &c- &6Add a flag"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ItemFlag flag = null;
|
|
||||||
try {
|
|
||||||
flag = ItemFlag.valueOf(args[2].toUpperCase());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
if (flag == null) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f\"" + args[2] + "&f\" does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (meta.getItemFlags().contains(flag)) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f'" + args[2].toUpperCase() + "' &4already added to the item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.addItemFlags(flag);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The flag &f'" + args[2].toUpperCase() + "' &2has been added to your item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dFlag Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer flag remove <&fname&b> &c- &6remove a flag"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ItemFlag flag = null;
|
|
||||||
try {
|
|
||||||
flag = ItemFlag.valueOf(args[2].toUpperCase());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
if (flag == null) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f\"" + args[2] + "&f\" does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (!meta.getItemFlags().contains(flag)) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f'" + args[2].toUpperCase() + "' &4has not been added the item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.removeItemFlags(flag);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The flag &f'" + args[2].toUpperCase() + "' &2has been removed from your item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getItemFlags()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4The item in your hand does not have any flags"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Item flags: &e"
|
|
||||||
+ StringUtils.join(meta.getItemFlags(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available item flags: &e"
|
|
||||||
+ StringUtils.join(ItemFlag.values(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer flag &bfor help"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "enchant" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dEnchant Commands&f]&3===============
|
|
||||||
&b/itemizer enchant add <&fname&b> <&flevel&b> &c- &6Add an enchant
|
|
||||||
&b/itemizer enchant remove <&fname&b> &c- &6Remove an enchant
|
|
||||||
&b/itemizer enchant list &c- &6List all item's enchants
|
|
||||||
&b/itemizer enchant listall &c- &6List all available enchants"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 4) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dEnchant Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer enchant add <&fname&b> <&flevel&b> &c- &6Add an enchant"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Enchantment ench = EnchantmentWrapper.getByKey(NamespacedKey.minecraft(args[2].toLowerCase()));
|
|
||||||
if (ench == null) {
|
|
||||||
sender.sendMessage(colorize("&4The enchantment &f'" + args[2] + "&f' &4does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer level = parseInt(sender, args[3]);
|
|
||||||
if (level == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.addUnsafeEnchantment(ench, level);
|
|
||||||
sender.sendMessage(colorize("&2The enchant &f'" + ench.getKey().getKey() + "' &2has been added to your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.remove")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dEnchant Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer enchant remove <&fname&b> &c- &6Remove an enchant"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Enchantment ench = EnchantmentWrapper.getByKey(NamespacedKey.minecraft(args[2].toLowerCase()));
|
|
||||||
if (ench == null) {
|
|
||||||
sender.sendMessage(colorize("&4The enchantment &f'" + args[2] + "&f' &4does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getEnchants()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't hold any enchants"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!meta.getEnchants().containsKey(ench)) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't have &f'" + ench.getKey().getKey() + "' &4enchant!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.removeEnchantment(ench);
|
|
||||||
sender.sendMessage(colorize("&2The enchant &f'" + ench.getKey().getKey() + "' &2has been removed from your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getEnchants()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't hold any enchants"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Item enchants: &e"
|
|
||||||
+ StringUtils.join(meta.getEnchants().keySet(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
Enchantment[] enchantments;
|
|
||||||
for (int i = 0; i < (enchantments = Enchantment.values()).length; i++) {
|
|
||||||
sb.append(", ").append(enchantments[i].getKey().getKey());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available item enchants: &e"
|
|
||||||
+ sb.toString().replaceFirst(", ", "")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer enchant &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "title" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.title")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dTitle Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer title <&fname&b> &c- &6Set the book's title"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasBook) {
|
|
||||||
sender.sendMessage("Get a WRITTEN_BOOK in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(StringUtils.join(args, " ", 1, args.length));
|
|
||||||
final BookMeta bookMeta = (BookMeta) meta;
|
|
||||||
assert bookMeta != null;
|
|
||||||
bookMeta.setTitle(name);
|
|
||||||
item.setItemMeta(bookMeta);
|
|
||||||
sender.sendMessage(colorize("&2The title of the book has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "author" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.author")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dAuthor Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer author <&fname&b> &c- &6Set the book's title"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasBook) {
|
|
||||||
sender.sendMessage("Get a WRITTEN_BOOK in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(args[1]);
|
|
||||||
final BookMeta bookMeta = (BookMeta) meta;
|
|
||||||
assert bookMeta != null;
|
|
||||||
bookMeta.setAuthor(name);
|
|
||||||
item.setItemMeta(bookMeta);
|
|
||||||
sender.sendMessage(colorize("&2The author of the book has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "head" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.head")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dHead Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer head <&fname&b> &c- &6Set the player of the head"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (item.getType() != Material.PLAYER_HEAD) {
|
|
||||||
sender.sendMessage("Get a SKULL in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = args[1];
|
|
||||||
if (name.length() > 16) {
|
|
||||||
name = name.substring(0, 16);
|
|
||||||
}
|
|
||||||
final SkullMeta skullMeta = (SkullMeta) meta;
|
|
||||||
assert skullMeta != null;
|
|
||||||
skullMeta.setOwner(name);
|
|
||||||
item.setItemMeta(skullMeta);
|
|
||||||
sender.sendMessage(colorize("&2The player of the head has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "sign" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.sign")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 3) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dSign Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer sign <&fline&b> <&ftext&b> &c- &6Change the line on the sign"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Block block = player.getTargetBlockExact(20);
|
|
||||||
if (block == null || block.getType() == Material.AIR
|
|
||||||
|| !block.getType().toString().contains("SIGN")) {
|
|
||||||
sender.sendMessage(colorize("&4Please look at a sign!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer line = parseInt(sender, args[1]);
|
|
||||||
if (line == null) {
|
|
||||||
return true;
|
|
||||||
} else if (line > 4) {
|
|
||||||
sender.sendMessage(colorize("&4There's maximum of 4 lines on a sign"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String text = colorize(StringUtils.join(args, " ", 2, args.length));
|
|
||||||
if (cpb.getAPI() != null) {
|
|
||||||
cpb.getAPI().logRemoval(player.getName(), block.getLocation(), block.getType(), block.getBlockData());
|
|
||||||
}
|
|
||||||
Sign sign = (Sign) block.getState();
|
|
||||||
sign.setLine(line - 1, text);
|
|
||||||
sign.update();
|
|
||||||
if (cpb.getAPI() != null) {
|
|
||||||
cpb.getAPI().logPlacement(player.getName(), sign.getLocation(), sign.getType(), sign.getBlockData());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + line + "'&2 has successfully changed to &f'" + text + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "clearall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.clearall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setItemMeta(null);
|
|
||||||
sender.sendMessage(colorize("&2All data cleared from your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer help &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String colorize(String string) {
|
|
||||||
Matcher matcher = Pattern.compile("&#[a-fA-F0-9]{6}").matcher(string);
|
|
||||||
while (matcher.find()) {
|
|
||||||
String code = matcher.group().replace("&", "");
|
|
||||||
string = string.replace("&" + code, net.md_5.bungee.api.ChatColor.of(code) + "");
|
|
||||||
}
|
|
||||||
string = ChatColor.translateAlternateColorCodes('&', string);
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer parseInt(CommandSender sender, String string) {
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(string);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
sender.sendMessage(colorize("&f\"" + string + "&f\"&4 is not a valid number!"));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,105 +0,0 @@
|
|||||||
package dev.plex.itemizerx.v1_18_R1;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemizerXTab implements TabCompleter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String string, String[] args) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
return Arrays.asList("help", "id", "lore", "potion", "attr", "flag", "enchant", "title", "author",
|
|
||||||
"head", "sign", "clearall");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 2) {
|
|
||||||
switch (args[0]) {
|
|
||||||
case "id": {
|
|
||||||
List<String> materials = new ArrayList<>();
|
|
||||||
for (Material material : Material.values()) {
|
|
||||||
materials.add(material.name());
|
|
||||||
}
|
|
||||||
return materials;
|
|
||||||
}
|
|
||||||
case "lore": {
|
|
||||||
return Arrays.asList("add", "remove", "change", "clear");
|
|
||||||
}
|
|
||||||
case "potion": {
|
|
||||||
return Arrays.asList("add", "remove", "change", "color", "list");
|
|
||||||
}
|
|
||||||
case "attr":
|
|
||||||
case "flag":
|
|
||||||
case "enchant": {
|
|
||||||
return Arrays.asList("add", "remove", "list", "listall");
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 3) {
|
|
||||||
switch (args[0]) {
|
|
||||||
case "potion": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> potions = new ArrayList<>();
|
|
||||||
for (PotionEffectType effect : PotionEffectType.values()) {
|
|
||||||
potions.add(effect.getName());
|
|
||||||
}
|
|
||||||
return potions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "attr": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
return AttributeManager.Attributes.getAttributeList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "flag": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> flags = new ArrayList<>();
|
|
||||||
for (ItemFlag flag : ItemFlag.values()) {
|
|
||||||
flags.add(flag.name());
|
|
||||||
}
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "enchant": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> enchantments = new ArrayList<>();
|
|
||||||
for (Enchantment enchantment : Enchantment.values()) {
|
|
||||||
enchantments.add(enchantment.getKey().getKey());
|
|
||||||
}
|
|
||||||
return enchantments;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,3 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
}
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":shared"))
|
|
||||||
compileOnly("org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT")
|
||||||
compileOnly("net.coreprotect:coreprotect:21.3")
|
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package dev.plex.itemizerx.v1_18_R2;
|
package dev.plex.itemizerx.v1_18_R2;
|
||||||
|
|
||||||
|
import dev.plex.itemizerx.Attributes;
|
||||||
|
import dev.plex.itemizerx.IAttributeManager;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@ -12,9 +14,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class AttributeManager {
|
public class AttributeManager implements IAttributeManager {
|
||||||
|
|
||||||
public static NBTTagList getAttrList(final ItemStack item) {
|
@Override
|
||||||
|
public NBTTagList getAttrList(final ItemStack item) {
|
||||||
NBTTagList attrmod = item.u().c("AttributeModifiers", 10);
|
NBTTagList attrmod = item.u().c("AttributeModifiers", 10);
|
||||||
if (attrmod == null) {
|
if (attrmod == null) {
|
||||||
item.u().a("AttributeModifiers", new NBTTagList());
|
item.u().a("AttributeModifiers", new NBTTagList());
|
||||||
@ -22,7 +25,8 @@ public class AttributeManager {
|
|||||||
return item.u().c("AttributeModifiers", 10);
|
return item.u().c("AttributeModifiers", 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addAttr(final Player player, final String[] args) {
|
@Override
|
||||||
|
public void addAttr(final Player player, final String[] args) {
|
||||||
int op;
|
int op;
|
||||||
if (args.length < 4) {
|
if (args.length < 4) {
|
||||||
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
||||||
@ -90,7 +94,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute added!"));
|
player.sendMessage(colorize("&2Attribute added!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeAttr(final Player player, final String string) {
|
@Override
|
||||||
|
public void removeAttr(final Player player, final String string) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
final NBTTagList newList = new NBTTagList();
|
final NBTTagList newList = new NBTTagList();
|
||||||
@ -113,7 +118,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute removed!"));
|
player.sendMessage(colorize("&2Attribute removed!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void listAttr(final Player player) {
|
@Override
|
||||||
|
public void listAttr(final Player player) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
if (attrmod.size() == 0) {
|
if (attrmod.size() == 0) {
|
||||||
@ -128,52 +134,8 @@ public class AttributeManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String colorize(String string) {
|
@Override
|
||||||
|
public String colorize(String string) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
return ChatColor.translateAlternateColorCodes('&', string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Attributes {
|
|
||||||
|
|
||||||
MAX_HEALTH("generic.max_health", 0),
|
|
||||||
FOLLOW_RANGE("generic.follow_range", 1),
|
|
||||||
KNOCKBACK_RESISTANCE("generic.knockback_resistance", 1),
|
|
||||||
MOVEMENT_SPEED("generic.movement_speed", 1),
|
|
||||||
DAMAGE("generic.attack_damage", 0),
|
|
||||||
ARMOR("generic.armor", 0),
|
|
||||||
ARMOR_TOUGHNESS("generic.armor_toughness", 0),
|
|
||||||
FLYING_SPEED("generic.flying_speed", 1),
|
|
||||||
ATTACK_SPEED("generic.attack_speed", 1),
|
|
||||||
LUCK("generic.luck", 0),
|
|
||||||
HORSE_JUMP("horse.jump_strength", 1),
|
|
||||||
ZOMBIE_REINFORCEMENTS("zombie.spawn_reinforcements", 1);
|
|
||||||
|
|
||||||
private final String mcName;
|
|
||||||
private final int op;
|
|
||||||
|
|
||||||
Attributes(String mcName, int op) {
|
|
||||||
this.mcName = mcName;
|
|
||||||
this.op = op;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Attributes get(String name) {
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
if (attr.name().equalsIgnoreCase(name) || attr.mcName.equalsIgnoreCase(name)) {
|
|
||||||
return attr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getAttributes() {
|
|
||||||
return StringUtils.join(values(), ", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getAttributeList() {
|
|
||||||
List<String> attributes = new ArrayList<>();
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
attributes.add(attr.name());
|
|
||||||
}
|
|
||||||
return attributes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,810 +0,0 @@
|
|||||||
package dev.plex.itemizerx.v1_18_R2;
|
|
||||||
|
|
||||||
import dev.plex.itemizerx.CoreProtectBridge;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.*;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.enchantments.EnchantmentWrapper;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.BookMeta;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class ItemizerXCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
final List<Material> POTIONS = Arrays.asList(Material.POTION, Material.LINGERING_POTION, Material.SPLASH_POTION);
|
|
||||||
CoreProtectBridge cpb = new CoreProtectBridge();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String string, String[] args) {
|
|
||||||
if (!sender.hasPermission("itemizer.use")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
sender.sendMessage(ChatColor.AQUA + "ItemizerX " + ChatColor.GOLD + "v"
|
|
||||||
+ Bukkit.getPluginManager().getPlugin("ItemizerX").getDescription().getVersion()
|
|
||||||
+ ChatColor.AQUA + " by " + ChatColor.GOLD
|
|
||||||
+ StringUtils.join(Bukkit.getPluginManager().getPlugin("ItemizerX").getDescription().getAuthors(), ", "));
|
|
||||||
sender.sendMessage(ChatColor.AQUA + "Type " + ChatColor.GOLD + "/itemizer help "
|
|
||||||
+ ChatColor.AQUA + "for help");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sender instanceof final Player player)) {
|
|
||||||
sender.sendMessage(colorize("&4You must be a player to execute this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ItemStack item = player.getInventory().getItemInMainHand();
|
|
||||||
final boolean hasItem = item.getType() != Material.AIR;
|
|
||||||
final boolean hasPotion = POTIONS.contains(item.getType());
|
|
||||||
final boolean hasBook = item.getType() == Material.WRITTEN_BOOK;
|
|
||||||
final ItemMeta meta = item.getItemMeta();
|
|
||||||
|
|
||||||
switch (args[0]) {
|
|
||||||
case "help" -> {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3=============&f[&dItemizerX Commands&f]&3=============
|
|
||||||
&b/itemizer name <&fname&b> &c- &6Name your item
|
|
||||||
&b/itemizer id <&fid&b> &c- &6Change the item's material
|
|
||||||
&b/itemizer lore &c- &6Lore editing command
|
|
||||||
&b/itemizer potion &c- &6Potion editing command
|
|
||||||
&b/itemizer attr &c- &6Attribute editing command
|
|
||||||
&b/itemizer flag &c- &6Flag editing command
|
|
||||||
&b/itemizer enchant &c- &6Enchant editing command
|
|
||||||
&b/itemizer title <&fname&b> &c- &6Set the book's title
|
|
||||||
&b/itemizer author <&fname&b> &c- &6Set the book's author
|
|
||||||
&b/itemizer head <&fname&b> &c- &6Set the player of the head
|
|
||||||
&b/itemizer sign <&fline&b> <&ftext&b> &c- &6Change the line on the sign
|
|
||||||
&b/itemizer clearall &c- &6Clears all metadata from your item"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "name" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.name")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dName Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer name <&fname&b> &c - &6Name your item"));
|
|
||||||
} else {
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(StringUtils.join(args, " ", 1, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
meta.setDisplayName(name);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The name of the item in your hand has been set to &f'" + name + "&f'"));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "id" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.id")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dID Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer id <&fid&b> &c- &6Change the item's material"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Material material = Material.matchMaterial(args[1].toUpperCase());
|
|
||||||
if (material == null) {
|
|
||||||
sender.sendMessage(colorize("&4The material &f\"" + args[1] + "&f\"&4 does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setType(material);
|
|
||||||
sender.sendMessage(colorize("&2The material of the item has changed to &f'" + material.name() + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "lore" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dLore Commands&f]&3===============
|
|
||||||
&b/itemizer lore add <&ftext&b> &c- &6Add a line of text to your item's lore
|
|
||||||
&b/itemizer lore remove <&findex&b> &c- &6Remove a line of text from your item's lore
|
|
||||||
&b/itemizer lore change <&findex&b> <&ftext&b> &c- &6Change a line of text in your item's lore
|
|
||||||
&b/itemizer lore clear &c- &6Clear the item's lore"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore add <&ftext&b> &c- &6Add a line of text to your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String lore = colorize(StringUtils.join(args, " ", 2, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores = new ArrayList<>();
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
}
|
|
||||||
lores.add(lore);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + lore + "&f'&2 added to the item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore remove <&findex&b> &c- &6Remove a line of text from your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer index = parseInt(sender, args[2]);
|
|
||||||
if (index == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores;
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(colorize("&eThis item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (index > lores.size()) {
|
|
||||||
sender.sendMessage(colorize("&4The item's lore doesn't have line &f'" + index + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
lores.remove(index - 1);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + index + "&f'&2 removed from the item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "change" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.change")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 4) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore change <&findex&b> <&ftext&b> &c- &6Change a line of text in your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer index = parseInt(sender, args[2]);
|
|
||||||
if (index == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String lore = colorize(StringUtils.join(args, " ", 3, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores;
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(colorize("&eThis item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (index > lores.size()) {
|
|
||||||
sender.sendMessage(colorize("&4The item's lore doesn't have line &f'" + index + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
lores.set(index - 1, lore);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + index + "'&2 has changed to &f'" + lore + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "clear" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.clear")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (meta.getLore() == null || meta.getLore().isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4The item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.setLore(null);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The item's lore has been cleared!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer lore &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "potion" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dPotion Commands&f]&3===============
|
|
||||||
&b/itemizer potion add <&feffect&b> <&flevel&b> <&ftime[tick]&b> &c- &6Add a potion effect
|
|
||||||
&b/itemizer potion remove <&feffect&b> &c- &6Remove a potion effect
|
|
||||||
&b/itemizer potion change <&fname&b> &c- &6Change the potion type
|
|
||||||
&b/itemizer potion color <&fhexcolor&b> &c- &6Set the potion color
|
|
||||||
&b/itemizer potion list &c- &6List all potion effects"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasPotion) {
|
|
||||||
sender.sendMessage("Get a POTION in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 5) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion add <&feffect&b> <&flevel&b> <&ftime[tick]&b> &c- &6Add a potion effect"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PotionEffectType potType = PotionEffectType.getByName(args[2].toUpperCase());
|
|
||||||
if (potType == null) {
|
|
||||||
sender.sendMessage(colorize("&4The potion &f\"" + args[2] + "&f\"&4 does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer level = parseInt(sender, args[3]);
|
|
||||||
Integer tick = parseInt(sender, args[4]);
|
|
||||||
if (level == null || tick == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionEffect pot = new PotionEffect(potType, tick, level);
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
if (potionMeta.hasCustomEffect(pot.getType())) {
|
|
||||||
sender.sendMessage(colorize("&4This potion already has &f" + pot.getType().getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
potionMeta.addCustomEffect(pot, false);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(pot.getType().getName() + " &2has been added to the potion"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion remove <&feffect&b> &c- &6Remove a potion effect"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PotionEffectType potType = PotionEffectType.getByName(args[2].toUpperCase());
|
|
||||||
if (potType == null) {
|
|
||||||
sender.sendMessage("&4The potion effect &f\"" + args[2] + "&f\"&4 does not exist!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
if (!potionMeta.hasCustomEffect(potType)) {
|
|
||||||
sender.sendMessage(colorize("This potion does not have &f" + potType.getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
potionMeta.removeCustomEffect(potType);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(potType.getName() + " &2has been removed from the potion"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "change" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.change")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion change <&fname&b> &c- &6Change the potion type"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Material material = Material.matchMaterial(args[2]);
|
|
||||||
if (material == null || !POTIONS.contains(material)) {
|
|
||||||
sender.sendMessage(colorize(material != null ?
|
|
||||||
"&f'" + material.name() + "' &4is not a potion type!"
|
|
||||||
:
|
|
||||||
"&4That material doesn't exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setType(material);
|
|
||||||
sender.sendMessage(colorize("&2The potion in hand has changed to &f'" + material.name() + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "color" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.color")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 3) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion color <&fhexcolor&b> &c- &6Set a potion color"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
try {
|
|
||||||
java.awt.Color awtColor = java.awt.Color.decode(args[2]);
|
|
||||||
Color color = Color.fromRGB(awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue());
|
|
||||||
potionMeta.setColor(color);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(args[2] + " &2has been set as potion color"));
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
sender.sendMessage(colorize("&4The hex &f\"" + args[2] + "&f\"&4 is invalid!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
PotionEffectType[] effects;
|
|
||||||
for (int i = 0; i < (effects = PotionEffectType.values()).length; i++) {
|
|
||||||
sb.append(", ").append(effects[i].getName());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available potion effects: &e"
|
|
||||||
+ sb.toString().replaceFirst(", ", "")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer potion &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "attr" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dAttribute Commands&f]&3===============
|
|
||||||
&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c - &6Add an attribute
|
|
||||||
&b/itemizer attr remove <&fname&b> &c- &6Remove an attribute
|
|
||||||
&b/itemizer attr list &c- &6List all item's attributes
|
|
||||||
&b/itemizer attr listall &c- &6List all supported attributes"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.addAttr(player, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.removeAttr(player, args[2]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.listAttr(player);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Supported attributes: "
|
|
||||||
+ "&e" + AttributeManager.Attributes.getAttributes()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer attr &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "flag" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dFlag Commands&f]&3===============
|
|
||||||
&b/itemizer flag add <&fname&b> &c- &6Add a flag
|
|
||||||
&b/itemizer flag remove <&fname&b> &c- &6Remove a flag
|
|
||||||
&b/itemizer flag list &c- &6List all item's flag
|
|
||||||
&b/itemizer flag listall &c- &6List all available flags"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dFlag Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer flag add <&fname&b> &c- &6Add a flag"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ItemFlag flag = null;
|
|
||||||
try {
|
|
||||||
flag = ItemFlag.valueOf(args[2].toUpperCase());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
if (flag == null) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f\"" + args[2] + "&f\" does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (meta.getItemFlags().contains(flag)) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f'" + args[2].toUpperCase() + "' &4already added to the item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.addItemFlags(flag);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The flag &f'" + args[2].toUpperCase() + "' &2has been added to your item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dFlag Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer flag remove <&fname&b> &c- &6remove a flag"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ItemFlag flag = null;
|
|
||||||
try {
|
|
||||||
flag = ItemFlag.valueOf(args[2].toUpperCase());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
if (flag == null) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f\"" + args[2] + "&f\" does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (!meta.getItemFlags().contains(flag)) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f'" + args[2].toUpperCase() + "' &4has not been added the item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.removeItemFlags(flag);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The flag &f'" + args[2].toUpperCase() + "' &2has been removed from your item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getItemFlags()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4The item in your hand does not have any flags"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Item flags: &e"
|
|
||||||
+ StringUtils.join(meta.getItemFlags(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available item flags: &e"
|
|
||||||
+ StringUtils.join(ItemFlag.values(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer flag &bfor help"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "enchant" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dEnchant Commands&f]&3===============
|
|
||||||
&b/itemizer enchant add <&fname&b> <&flevel&b> &c- &6Add an enchant
|
|
||||||
&b/itemizer enchant remove <&fname&b> &c- &6Remove an enchant
|
|
||||||
&b/itemizer enchant list &c- &6List all item's enchants
|
|
||||||
&b/itemizer enchant listall &c- &6List all available enchants"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 4) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dEnchant Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer enchant add <&fname&b> <&flevel&b> &c- &6Add an enchant"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Enchantment ench = EnchantmentWrapper.getByKey(NamespacedKey.minecraft(args[2].toLowerCase()));
|
|
||||||
if (ench == null) {
|
|
||||||
sender.sendMessage(colorize("&4The enchantment &f'" + args[2] + "&f' &4does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer level = parseInt(sender, args[3]);
|
|
||||||
if (level == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.addUnsafeEnchantment(ench, level);
|
|
||||||
sender.sendMessage(colorize("&2The enchant &f'" + ench.getKey().getKey() + "' &2has been added to your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.remove")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dEnchant Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer enchant remove <&fname&b> &c- &6Remove an enchant"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Enchantment ench = EnchantmentWrapper.getByKey(NamespacedKey.minecraft(args[2].toLowerCase()));
|
|
||||||
if (ench == null) {
|
|
||||||
sender.sendMessage(colorize("&4The enchantment &f'" + args[2] + "&f' &4does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getEnchants()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't hold any enchants"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!meta.getEnchants().containsKey(ench)) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't have &f'" + ench.getKey().getKey() + "' &4enchant!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.removeEnchantment(ench);
|
|
||||||
sender.sendMessage(colorize("&2The enchant &f'" + ench.getKey().getKey() + "' &2has been removed from your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getEnchants()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't hold any enchants"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Item enchants: &e"
|
|
||||||
+ StringUtils.join(meta.getEnchants().keySet(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
Enchantment[] enchantments;
|
|
||||||
for (int i = 0; i < (enchantments = Enchantment.values()).length; i++) {
|
|
||||||
sb.append(", ").append(enchantments[i].getKey().getKey());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available item enchants: &e"
|
|
||||||
+ sb.toString().replaceFirst(", ", "")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer enchant &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "title" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.title")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dTitle Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer title <&fname&b> &c- &6Set the book's title"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasBook) {
|
|
||||||
sender.sendMessage("Get a WRITTEN_BOOK in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(StringUtils.join(args, " ", 1, args.length));
|
|
||||||
final BookMeta bookMeta = (BookMeta) meta;
|
|
||||||
assert bookMeta != null;
|
|
||||||
bookMeta.setTitle(name);
|
|
||||||
item.setItemMeta(bookMeta);
|
|
||||||
sender.sendMessage(colorize("&2The title of the book has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "author" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.author")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dAuthor Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer author <&fname&b> &c- &6Set the book's title"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasBook) {
|
|
||||||
sender.sendMessage("Get a WRITTEN_BOOK in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(args[1]);
|
|
||||||
final BookMeta bookMeta = (BookMeta) meta;
|
|
||||||
assert bookMeta != null;
|
|
||||||
bookMeta.setAuthor(name);
|
|
||||||
item.setItemMeta(bookMeta);
|
|
||||||
sender.sendMessage(colorize("&2The author of the book has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "head" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.head")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dHead Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer head <&fname&b> &c- &6Set the player of the head"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (item.getType() != Material.PLAYER_HEAD) {
|
|
||||||
sender.sendMessage("Get a SKULL in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = args[1];
|
|
||||||
if (name.length() > 16) {
|
|
||||||
name = name.substring(0, 16);
|
|
||||||
}
|
|
||||||
final SkullMeta skullMeta = (SkullMeta) meta;
|
|
||||||
assert skullMeta != null;
|
|
||||||
skullMeta.setOwner(name);
|
|
||||||
item.setItemMeta(skullMeta);
|
|
||||||
sender.sendMessage(colorize("&2The player of the head has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "sign" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.sign")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 3) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dSign Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer sign <&fline&b> <&ftext&b> &c- &6Change the line on the sign"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Block block = player.getTargetBlockExact(20);
|
|
||||||
if (block == null || block.getType() == Material.AIR
|
|
||||||
|| !block.getType().toString().contains("SIGN")) {
|
|
||||||
sender.sendMessage(colorize("&4Please look at a sign!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer line = parseInt(sender, args[1]);
|
|
||||||
if (line == null) {
|
|
||||||
return true;
|
|
||||||
} else if (line > 4) {
|
|
||||||
sender.sendMessage(colorize("&4There's maximum of 4 lines on a sign"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String text = colorize(StringUtils.join(args, " ", 2, args.length));
|
|
||||||
if (cpb.getAPI() != null) {
|
|
||||||
cpb.getAPI().logRemoval(player.getName(), block.getLocation(), block.getType(), block.getBlockData());
|
|
||||||
}
|
|
||||||
Sign sign = (Sign) block.getState();
|
|
||||||
sign.setLine(line - 1, text);
|
|
||||||
sign.update();
|
|
||||||
if (cpb.getAPI() != null) {
|
|
||||||
cpb.getAPI().logPlacement(player.getName(), sign.getLocation(), sign.getType(), sign.getBlockData());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + line + "'&2 has successfully changed to &f'" + text + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "clearall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.clearall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setItemMeta(null);
|
|
||||||
sender.sendMessage(colorize("&2All data cleared from your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer help &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String colorize(String string) {
|
|
||||||
Matcher matcher = Pattern.compile("&#[a-fA-F0-9]{6}").matcher(string);
|
|
||||||
while (matcher.find()) {
|
|
||||||
String code = matcher.group().replace("&", "");
|
|
||||||
string = string.replace("&" + code, net.md_5.bungee.api.ChatColor.of(code) + "");
|
|
||||||
}
|
|
||||||
string = ChatColor.translateAlternateColorCodes('&', string);
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer parseInt(CommandSender sender, String string) {
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(string);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
sender.sendMessage(colorize("&f\"" + string + "&f\"&4 is not a valid number!"));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,3 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
}
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":shared"))
|
|
||||||
compileOnly("org.spigotmc:spigot:1.19.2-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot:1.19.2-R0.1-SNAPSHOT")
|
||||||
compileOnly("net.coreprotect:coreprotect:21.3")
|
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package dev.plex.itemizerx.v1_19_R1;
|
package dev.plex.itemizerx.v1_19_R1;
|
||||||
|
|
||||||
|
import dev.plex.itemizerx.Attributes;
|
||||||
|
import dev.plex.itemizerx.IAttributeManager;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@ -12,9 +14,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class AttributeManager {
|
public class AttributeManager implements IAttributeManager {
|
||||||
|
|
||||||
public static NBTTagList getAttrList(final ItemStack item) {
|
@Override
|
||||||
|
public NBTTagList getAttrList(final ItemStack item) {
|
||||||
NBTTagList attrmod = item.v().c("AttributeModifiers", 10);
|
NBTTagList attrmod = item.v().c("AttributeModifiers", 10);
|
||||||
if (attrmod == null) {
|
if (attrmod == null) {
|
||||||
item.u().a("AttributeModifiers", new NBTTagList());
|
item.u().a("AttributeModifiers", new NBTTagList());
|
||||||
@ -22,7 +25,8 @@ public class AttributeManager {
|
|||||||
return item.u().c("AttributeModifiers", 10);
|
return item.u().c("AttributeModifiers", 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addAttr(final Player player, final String[] args) {
|
@Override
|
||||||
|
public void addAttr(final Player player, final String[] args) {
|
||||||
int op;
|
int op;
|
||||||
if (args.length < 4) {
|
if (args.length < 4) {
|
||||||
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
||||||
@ -90,7 +94,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute added!"));
|
player.sendMessage(colorize("&2Attribute added!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeAttr(final Player player, final String string) {
|
@Override
|
||||||
|
public void removeAttr(final Player player, final String string) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
final NBTTagList newList = new NBTTagList();
|
final NBTTagList newList = new NBTTagList();
|
||||||
@ -113,7 +118,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute removed!"));
|
player.sendMessage(colorize("&2Attribute removed!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void listAttr(final Player player) {
|
@Override
|
||||||
|
public void listAttr(final Player player) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
if (attrmod.size() == 0) {
|
if (attrmod.size() == 0) {
|
||||||
@ -128,52 +134,8 @@ public class AttributeManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String colorize(String string) {
|
@Override
|
||||||
|
public String colorize(String string) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
return ChatColor.translateAlternateColorCodes('&', string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Attributes {
|
|
||||||
|
|
||||||
MAX_HEALTH("generic.max_health", 0),
|
|
||||||
FOLLOW_RANGE("generic.follow_range", 1),
|
|
||||||
KNOCKBACK_RESISTANCE("generic.knockback_resistance", 1),
|
|
||||||
MOVEMENT_SPEED("generic.movement_speed", 1),
|
|
||||||
DAMAGE("generic.attack_damage", 0),
|
|
||||||
ARMOR("generic.armor", 0),
|
|
||||||
ARMOR_TOUGHNESS("generic.armor_toughness", 0),
|
|
||||||
FLYING_SPEED("generic.flying_speed", 1),
|
|
||||||
ATTACK_SPEED("generic.attack_speed", 1),
|
|
||||||
LUCK("generic.luck", 0),
|
|
||||||
HORSE_JUMP("horse.jump_strength", 1),
|
|
||||||
ZOMBIE_REINFORCEMENTS("zombie.spawn_reinforcements", 1);
|
|
||||||
|
|
||||||
private final String mcName;
|
|
||||||
private final int op;
|
|
||||||
|
|
||||||
Attributes(String mcName, int op) {
|
|
||||||
this.mcName = mcName;
|
|
||||||
this.op = op;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Attributes get(String name) {
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
if (attr.name().equalsIgnoreCase(name) || attr.mcName.equalsIgnoreCase(name)) {
|
|
||||||
return attr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getAttributes() {
|
|
||||||
return StringUtils.join(values(), ", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getAttributeList() {
|
|
||||||
List<String> attributes = new ArrayList<>();
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
attributes.add(attr.name());
|
|
||||||
}
|
|
||||||
return attributes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,810 +0,0 @@
|
|||||||
package dev.plex.itemizerx.v1_19_R1;
|
|
||||||
|
|
||||||
import dev.plex.itemizerx.CoreProtectBridge;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.*;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.enchantments.EnchantmentWrapper;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.BookMeta;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class ItemizerXCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
final List<Material> POTIONS = Arrays.asList(Material.POTION, Material.LINGERING_POTION, Material.SPLASH_POTION);
|
|
||||||
CoreProtectBridge cpb = new CoreProtectBridge();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String string, String[] args) {
|
|
||||||
if (!sender.hasPermission("itemizer.use")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
sender.sendMessage(ChatColor.AQUA + "ItemizerX " + ChatColor.GOLD + "v"
|
|
||||||
+ Bukkit.getPluginManager().getPlugin("ItemizerX").getDescription().getVersion()
|
|
||||||
+ ChatColor.AQUA + " by " + ChatColor.GOLD
|
|
||||||
+ StringUtils.join(Bukkit.getPluginManager().getPlugin("ItemizerX").getDescription().getAuthors(), ", "));
|
|
||||||
sender.sendMessage(ChatColor.AQUA + "Type " + ChatColor.GOLD + "/itemizer help "
|
|
||||||
+ ChatColor.AQUA + "for help");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sender instanceof final Player player)) {
|
|
||||||
sender.sendMessage(colorize("&4You must be a player to execute this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ItemStack item = player.getInventory().getItemInMainHand();
|
|
||||||
final boolean hasItem = item.getType() != Material.AIR;
|
|
||||||
final boolean hasPotion = POTIONS.contains(item.getType());
|
|
||||||
final boolean hasBook = item.getType() == Material.WRITTEN_BOOK;
|
|
||||||
final ItemMeta meta = item.getItemMeta();
|
|
||||||
|
|
||||||
switch (args[0]) {
|
|
||||||
case "help" -> {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3=============&f[&dItemizerX Commands&f]&3=============
|
|
||||||
&b/itemizer name <&fname&b> &c- &6Name your item
|
|
||||||
&b/itemizer id <&fid&b> &c- &6Change the item's material
|
|
||||||
&b/itemizer lore &c- &6Lore editing command
|
|
||||||
&b/itemizer potion &c- &6Potion editing command
|
|
||||||
&b/itemizer attr &c- &6Attribute editing command
|
|
||||||
&b/itemizer flag &c- &6Flag editing command
|
|
||||||
&b/itemizer enchant &c- &6Enchant editing command
|
|
||||||
&b/itemizer title <&fname&b> &c- &6Set the book's title
|
|
||||||
&b/itemizer author <&fname&b> &c- &6Set the book's author
|
|
||||||
&b/itemizer head <&fname&b> &c- &6Set the player of the head
|
|
||||||
&b/itemizer sign <&fline&b> <&ftext&b> &c- &6Change the line on the sign
|
|
||||||
&b/itemizer clearall &c- &6Clears all metadata from your item"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "name" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.name")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dName Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer name <&fname&b> &c - &6Name your item"));
|
|
||||||
} else {
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(StringUtils.join(args, " ", 1, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
meta.setDisplayName(name);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The name of the item in your hand has been set to &f'" + name + "&f'"));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "id" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.id")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dID Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer id <&fid&b> &c- &6Change the item's material"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Material material = Material.matchMaterial(args[1].toUpperCase());
|
|
||||||
if (material == null) {
|
|
||||||
sender.sendMessage(colorize("&4The material &f\"" + args[1] + "&f\"&4 does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setType(material);
|
|
||||||
sender.sendMessage(colorize("&2The material of the item has changed to &f'" + material.name() + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "lore" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dLore Commands&f]&3===============
|
|
||||||
&b/itemizer lore add <&ftext&b> &c- &6Add a line of text to your item's lore
|
|
||||||
&b/itemizer lore remove <&findex&b> &c- &6Remove a line of text from your item's lore
|
|
||||||
&b/itemizer lore change <&findex&b> <&ftext&b> &c- &6Change a line of text in your item's lore
|
|
||||||
&b/itemizer lore clear &c- &6Clear the item's lore"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore add <&ftext&b> &c- &6Add a line of text to your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String lore = colorize(StringUtils.join(args, " ", 2, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores = new ArrayList<>();
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
}
|
|
||||||
lores.add(lore);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + lore + "&f'&2 added to the item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore remove <&findex&b> &c- &6Remove a line of text from your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer index = parseInt(sender, args[2]);
|
|
||||||
if (index == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores;
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(colorize("&eThis item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (index > lores.size()) {
|
|
||||||
sender.sendMessage(colorize("&4The item's lore doesn't have line &f'" + index + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
lores.remove(index - 1);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + index + "&f'&2 removed from the item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "change" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.change")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 4) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore change <&findex&b> <&ftext&b> &c- &6Change a line of text in your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer index = parseInt(sender, args[2]);
|
|
||||||
if (index == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String lore = colorize(StringUtils.join(args, " ", 3, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores;
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(colorize("&eThis item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (index > lores.size()) {
|
|
||||||
sender.sendMessage(colorize("&4The item's lore doesn't have line &f'" + index + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
lores.set(index - 1, lore);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + index + "'&2 has changed to &f'" + lore + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "clear" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.clear")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (meta.getLore() == null || meta.getLore().isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4The item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.setLore(null);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The item's lore has been cleared!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer lore &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "potion" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dPotion Commands&f]&3===============
|
|
||||||
&b/itemizer potion add <&feffect&b> <&flevel&b> <&ftime[tick]&b> &c- &6Add a potion effect
|
|
||||||
&b/itemizer potion remove <&feffect&b> &c- &6Remove a potion effect
|
|
||||||
&b/itemizer potion change <&fname&b> &c- &6Change the potion type
|
|
||||||
&b/itemizer potion color <&fhexcolor&b> &c- &6Set the potion color
|
|
||||||
&b/itemizer potion list &c- &6List all potion effects"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasPotion) {
|
|
||||||
sender.sendMessage("Get a POTION in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 5) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion add <&feffect&b> <&flevel&b> <&ftime[tick]&b> &c- &6Add a potion effect"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PotionEffectType potType = PotionEffectType.getByName(args[2].toUpperCase());
|
|
||||||
if (potType == null) {
|
|
||||||
sender.sendMessage(colorize("&4The potion &f\"" + args[2] + "&f\"&4 does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer level = parseInt(sender, args[3]);
|
|
||||||
Integer tick = parseInt(sender, args[4]);
|
|
||||||
if (level == null || tick == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionEffect pot = new PotionEffect(potType, tick, level);
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
if (potionMeta.hasCustomEffect(pot.getType())) {
|
|
||||||
sender.sendMessage(colorize("&4This potion already has &f" + pot.getType().getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
potionMeta.addCustomEffect(pot, false);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(pot.getType().getName() + " &2has been added to the potion"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion remove <&feffect&b> &c- &6Remove a potion effect"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PotionEffectType potType = PotionEffectType.getByName(args[2].toUpperCase());
|
|
||||||
if (potType == null) {
|
|
||||||
sender.sendMessage("&4The potion effect &f\"" + args[2] + "&f\"&4 does not exist!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
if (!potionMeta.hasCustomEffect(potType)) {
|
|
||||||
sender.sendMessage(colorize("This potion does not have &f" + potType.getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
potionMeta.removeCustomEffect(potType);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(potType.getName() + " &2has been removed from the potion"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "change" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.change")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion change <&fname&b> &c- &6Change the potion type"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Material material = Material.matchMaterial(args[2]);
|
|
||||||
if (material == null || !POTIONS.contains(material)) {
|
|
||||||
sender.sendMessage(colorize(material != null ?
|
|
||||||
"&f'" + material.name() + "' &4is not a potion type!"
|
|
||||||
:
|
|
||||||
"&4That material doesn't exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setType(material);
|
|
||||||
sender.sendMessage(colorize("&2The potion in hand has changed to &f'" + material.name() + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "color" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.color")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 3) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion color <&fhexcolor&b> &c- &6Set a potion color"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
try {
|
|
||||||
java.awt.Color awtColor = java.awt.Color.decode(args[2]);
|
|
||||||
Color color = Color.fromRGB(awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue());
|
|
||||||
potionMeta.setColor(color);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(args[2] + " &2has been set as potion color"));
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
sender.sendMessage(colorize("&4The hex &f\"" + args[2] + "&f\"&4 is invalid!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
PotionEffectType[] effects;
|
|
||||||
for (int i = 0; i < (effects = PotionEffectType.values()).length; i++) {
|
|
||||||
sb.append(", ").append(effects[i].getName());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available potion effects: &e"
|
|
||||||
+ sb.toString().replaceFirst(", ", "")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer potion &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "attr" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dAttribute Commands&f]&3===============
|
|
||||||
&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c - &6Add an attribute
|
|
||||||
&b/itemizer attr remove <&fname&b> &c- &6Remove an attribute
|
|
||||||
&b/itemizer attr list &c- &6List all item's attributes
|
|
||||||
&b/itemizer attr listall &c- &6List all supported attributes"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.addAttr(player, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.removeAttr(player, args[2]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.listAttr(player);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Supported attributes: "
|
|
||||||
+ "&e" + AttributeManager.Attributes.getAttributes()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer attr &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "flag" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dFlag Commands&f]&3===============
|
|
||||||
&b/itemizer flag add <&fname&b> &c- &6Add a flag
|
|
||||||
&b/itemizer flag remove <&fname&b> &c- &6Remove a flag
|
|
||||||
&b/itemizer flag list &c- &6List all item's flag
|
|
||||||
&b/itemizer flag listall &c- &6List all available flags"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dFlag Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer flag add <&fname&b> &c- &6Add a flag"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ItemFlag flag = null;
|
|
||||||
try {
|
|
||||||
flag = ItemFlag.valueOf(args[2].toUpperCase());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
if (flag == null) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f\"" + args[2] + "&f\" does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (meta.getItemFlags().contains(flag)) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f'" + args[2].toUpperCase() + "' &4already added to the item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.addItemFlags(flag);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The flag &f'" + args[2].toUpperCase() + "' &2has been added to your item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dFlag Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer flag remove <&fname&b> &c- &6remove a flag"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ItemFlag flag = null;
|
|
||||||
try {
|
|
||||||
flag = ItemFlag.valueOf(args[2].toUpperCase());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
if (flag == null) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f\"" + args[2] + "&f\" does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (!meta.getItemFlags().contains(flag)) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f'" + args[2].toUpperCase() + "' &4has not been added the item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.removeItemFlags(flag);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The flag &f'" + args[2].toUpperCase() + "' &2has been removed from your item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getItemFlags()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4The item in your hand does not have any flags"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Item flags: &e"
|
|
||||||
+ StringUtils.join(meta.getItemFlags(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available item flags: &e"
|
|
||||||
+ StringUtils.join(ItemFlag.values(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer flag &bfor help"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "enchant" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dEnchant Commands&f]&3===============
|
|
||||||
&b/itemizer enchant add <&fname&b> <&flevel&b> &c- &6Add an enchant
|
|
||||||
&b/itemizer enchant remove <&fname&b> &c- &6Remove an enchant
|
|
||||||
&b/itemizer enchant list &c- &6List all item's enchants
|
|
||||||
&b/itemizer enchant listall &c- &6List all available enchants"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 4) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dEnchant Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer enchant add <&fname&b> <&flevel&b> &c- &6Add an enchant"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Enchantment ench = EnchantmentWrapper.getByKey(NamespacedKey.minecraft(args[2].toLowerCase()));
|
|
||||||
if (ench == null) {
|
|
||||||
sender.sendMessage(colorize("&4The enchantment &f'" + args[2] + "&f' &4does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer level = parseInt(sender, args[3]);
|
|
||||||
if (level == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.addUnsafeEnchantment(ench, level);
|
|
||||||
sender.sendMessage(colorize("&2The enchant &f'" + ench.getKey().getKey() + "' &2has been added to your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.remove")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dEnchant Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer enchant remove <&fname&b> &c- &6Remove an enchant"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Enchantment ench = EnchantmentWrapper.getByKey(NamespacedKey.minecraft(args[2].toLowerCase()));
|
|
||||||
if (ench == null) {
|
|
||||||
sender.sendMessage(colorize("&4The enchantment &f'" + args[2] + "&f' &4does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getEnchants()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't hold any enchants"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!meta.getEnchants().containsKey(ench)) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't have &f'" + ench.getKey().getKey() + "' &4enchant!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.removeEnchantment(ench);
|
|
||||||
sender.sendMessage(colorize("&2The enchant &f'" + ench.getKey().getKey() + "' &2has been removed from your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getEnchants()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't hold any enchants"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Item enchants: &e"
|
|
||||||
+ StringUtils.join(meta.getEnchants().keySet(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
Enchantment[] enchantments;
|
|
||||||
for (int i = 0; i < (enchantments = Enchantment.values()).length; i++) {
|
|
||||||
sb.append(", ").append(enchantments[i].getKey().getKey());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available item enchants: &e"
|
|
||||||
+ sb.toString().replaceFirst(", ", "")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer enchant &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "title" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.title")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dTitle Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer title <&fname&b> &c- &6Set the book's title"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasBook) {
|
|
||||||
sender.sendMessage("Get a WRITTEN_BOOK in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(StringUtils.join(args, " ", 1, args.length));
|
|
||||||
final BookMeta bookMeta = (BookMeta) meta;
|
|
||||||
assert bookMeta != null;
|
|
||||||
bookMeta.setTitle(name);
|
|
||||||
item.setItemMeta(bookMeta);
|
|
||||||
sender.sendMessage(colorize("&2The title of the book has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "author" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.author")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dAuthor Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer author <&fname&b> &c- &6Set the book's title"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasBook) {
|
|
||||||
sender.sendMessage("Get a WRITTEN_BOOK in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(args[1]);
|
|
||||||
final BookMeta bookMeta = (BookMeta) meta;
|
|
||||||
assert bookMeta != null;
|
|
||||||
bookMeta.setAuthor(name);
|
|
||||||
item.setItemMeta(bookMeta);
|
|
||||||
sender.sendMessage(colorize("&2The author of the book has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "head" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.head")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dHead Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer head <&fname&b> &c- &6Set the player of the head"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (item.getType() != Material.PLAYER_HEAD) {
|
|
||||||
sender.sendMessage("Get a SKULL in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = args[1];
|
|
||||||
if (name.length() > 16) {
|
|
||||||
name = name.substring(0, 16);
|
|
||||||
}
|
|
||||||
final SkullMeta skullMeta = (SkullMeta) meta;
|
|
||||||
assert skullMeta != null;
|
|
||||||
skullMeta.setOwner(name);
|
|
||||||
item.setItemMeta(skullMeta);
|
|
||||||
sender.sendMessage(colorize("&2The player of the head has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "sign" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.sign")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 3) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dSign Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer sign <&fline&b> <&ftext&b> &c- &6Change the line on the sign"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Block block = player.getTargetBlockExact(20);
|
|
||||||
if (block == null || block.getType() == Material.AIR
|
|
||||||
|| !block.getType().toString().contains("SIGN")) {
|
|
||||||
sender.sendMessage(colorize("&4Please look at a sign!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer line = parseInt(sender, args[1]);
|
|
||||||
if (line == null) {
|
|
||||||
return true;
|
|
||||||
} else if (line > 4) {
|
|
||||||
sender.sendMessage(colorize("&4There's maximum of 4 lines on a sign"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String text = colorize(StringUtils.join(args, " ", 2, args.length));
|
|
||||||
if (cpb.getAPI() != null) {
|
|
||||||
cpb.getAPI().logRemoval(player.getName(), block.getLocation(), block.getType(), block.getBlockData());
|
|
||||||
}
|
|
||||||
Sign sign = (Sign) block.getState();
|
|
||||||
sign.setLine(line - 1, text);
|
|
||||||
sign.update();
|
|
||||||
if (cpb.getAPI() != null) {
|
|
||||||
cpb.getAPI().logPlacement(player.getName(), sign.getLocation(), sign.getType(), sign.getBlockData());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + line + "'&2 has successfully changed to &f'" + text + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "clearall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.clearall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setItemMeta(null);
|
|
||||||
sender.sendMessage(colorize("&2All data cleared from your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer help &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String colorize(String string) {
|
|
||||||
Matcher matcher = Pattern.compile("&#[a-fA-F0-9]{6}").matcher(string);
|
|
||||||
while (matcher.find()) {
|
|
||||||
String code = matcher.group().replace("&", "");
|
|
||||||
string = string.replace("&" + code, net.md_5.bungee.api.ChatColor.of(code) + "");
|
|
||||||
}
|
|
||||||
string = ChatColor.translateAlternateColorCodes('&', string);
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer parseInt(CommandSender sender, String string) {
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(string);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
sender.sendMessage(colorize("&f\"" + string + "&f\"&4 is not a valid number!"));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,105 +0,0 @@
|
|||||||
package dev.plex.itemizerx.v1_19_R1;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemizerXTab implements TabCompleter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String string, String[] args) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
return Arrays.asList("help", "id", "lore", "potion", "attr", "flag", "enchant", "title", "author",
|
|
||||||
"head", "sign", "clearall");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 2) {
|
|
||||||
switch (args[0]) {
|
|
||||||
case "id": {
|
|
||||||
List<String> materials = new ArrayList<>();
|
|
||||||
for (Material material : Material.values()) {
|
|
||||||
materials.add(material.name());
|
|
||||||
}
|
|
||||||
return materials;
|
|
||||||
}
|
|
||||||
case "lore": {
|
|
||||||
return Arrays.asList("add", "remove", "change", "clear");
|
|
||||||
}
|
|
||||||
case "potion": {
|
|
||||||
return Arrays.asList("add", "remove", "change", "color", "list");
|
|
||||||
}
|
|
||||||
case "attr":
|
|
||||||
case "flag":
|
|
||||||
case "enchant": {
|
|
||||||
return Arrays.asList("add", "remove", "list", "listall");
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 3) {
|
|
||||||
switch (args[0]) {
|
|
||||||
case "potion": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> potions = new ArrayList<>();
|
|
||||||
for (PotionEffectType effect : PotionEffectType.values()) {
|
|
||||||
potions.add(effect.getName());
|
|
||||||
}
|
|
||||||
return potions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "attr": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
return AttributeManager.Attributes.getAttributeList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "flag": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> flags = new ArrayList<>();
|
|
||||||
for (ItemFlag flag : ItemFlag.values()) {
|
|
||||||
flags.add(flag.name());
|
|
||||||
}
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "enchant": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> enchantments = new ArrayList<>();
|
|
||||||
for (Enchantment enchantment : Enchantment.values()) {
|
|
||||||
enchantments.add(enchantment.getKey().getKey());
|
|
||||||
}
|
|
||||||
return enchantments;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,3 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
}
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":shared"))
|
|
||||||
compileOnly("org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT")
|
||||||
compileOnly("net.coreprotect:coreprotect:21.3")
|
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package dev.plex.itemizerx.v1_19_R2;
|
package dev.plex.itemizerx.v1_19_R2;
|
||||||
|
|
||||||
|
import dev.plex.itemizerx.Attributes;
|
||||||
|
import dev.plex.itemizerx.IAttributeManager;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@ -12,9 +14,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class AttributeManager {
|
public class AttributeManager implements IAttributeManager {
|
||||||
|
|
||||||
public static NBTTagList getAttrList(final ItemStack item) {
|
@Override
|
||||||
|
public NBTTagList getAttrList(final ItemStack item) {
|
||||||
NBTTagList attrmod = item.v().c("AttributeModifiers", 10);
|
NBTTagList attrmod = item.v().c("AttributeModifiers", 10);
|
||||||
if (attrmod == null) {
|
if (attrmod == null) {
|
||||||
item.u().a("AttributeModifiers", new NBTTagList());
|
item.u().a("AttributeModifiers", new NBTTagList());
|
||||||
@ -22,7 +25,8 @@ public class AttributeManager {
|
|||||||
return item.u().c("AttributeModifiers", 10);
|
return item.u().c("AttributeModifiers", 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addAttr(final Player player, final String[] args) {
|
@Override
|
||||||
|
public void addAttr(final Player player, final String[] args) {
|
||||||
int op;
|
int op;
|
||||||
if (args.length < 4) {
|
if (args.length < 4) {
|
||||||
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
||||||
@ -90,7 +94,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute added!"));
|
player.sendMessage(colorize("&2Attribute added!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeAttr(final Player player, final String string) {
|
@Override
|
||||||
|
public void removeAttr(final Player player, final String string) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
final NBTTagList newList = new NBTTagList();
|
final NBTTagList newList = new NBTTagList();
|
||||||
@ -113,7 +118,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute removed!"));
|
player.sendMessage(colorize("&2Attribute removed!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void listAttr(final Player player) {
|
@Override
|
||||||
|
public void listAttr(final Player player) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
if (attrmod.size() == 0) {
|
if (attrmod.size() == 0) {
|
||||||
@ -128,52 +134,8 @@ public class AttributeManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String colorize(String string) {
|
@Override
|
||||||
|
public String colorize(String string) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
return ChatColor.translateAlternateColorCodes('&', string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Attributes {
|
|
||||||
|
|
||||||
MAX_HEALTH("generic.max_health", 0),
|
|
||||||
FOLLOW_RANGE("generic.follow_range", 1),
|
|
||||||
KNOCKBACK_RESISTANCE("generic.knockback_resistance", 1),
|
|
||||||
MOVEMENT_SPEED("generic.movement_speed", 1),
|
|
||||||
DAMAGE("generic.attack_damage", 0),
|
|
||||||
ARMOR("generic.armor", 0),
|
|
||||||
ARMOR_TOUGHNESS("generic.armor_toughness", 0),
|
|
||||||
FLYING_SPEED("generic.flying_speed", 1),
|
|
||||||
ATTACK_SPEED("generic.attack_speed", 1),
|
|
||||||
LUCK("generic.luck", 0),
|
|
||||||
HORSE_JUMP("horse.jump_strength", 1),
|
|
||||||
ZOMBIE_REINFORCEMENTS("zombie.spawn_reinforcements", 1);
|
|
||||||
|
|
||||||
private final String mcName;
|
|
||||||
private final int op;
|
|
||||||
|
|
||||||
Attributes(String mcName, int op) {
|
|
||||||
this.mcName = mcName;
|
|
||||||
this.op = op;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Attributes get(String name) {
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
if (attr.name().equalsIgnoreCase(name) || attr.mcName.equalsIgnoreCase(name)) {
|
|
||||||
return attr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getAttributes() {
|
|
||||||
return StringUtils.join(values(), ", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getAttributeList() {
|
|
||||||
List<String> attributes = new ArrayList<>();
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
attributes.add(attr.name());
|
|
||||||
}
|
|
||||||
return attributes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,810 +0,0 @@
|
|||||||
package dev.plex.itemizerx.v1_19_R2;
|
|
||||||
|
|
||||||
import dev.plex.itemizerx.CoreProtectBridge;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.*;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.enchantments.EnchantmentWrapper;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.BookMeta;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class ItemizerXCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
final List<Material> POTIONS = Arrays.asList(Material.POTION, Material.LINGERING_POTION, Material.SPLASH_POTION);
|
|
||||||
CoreProtectBridge cpb = new CoreProtectBridge();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String string, String[] args) {
|
|
||||||
if (!sender.hasPermission("itemizer.use")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
sender.sendMessage(ChatColor.AQUA + "ItemizerX " + ChatColor.GOLD + "v"
|
|
||||||
+ Bukkit.getPluginManager().getPlugin("ItemizerX").getDescription().getVersion()
|
|
||||||
+ ChatColor.AQUA + " by " + ChatColor.GOLD
|
|
||||||
+ StringUtils.join(Bukkit.getPluginManager().getPlugin("ItemizerX").getDescription().getAuthors(), ", "));
|
|
||||||
sender.sendMessage(ChatColor.AQUA + "Type " + ChatColor.GOLD + "/itemizer help "
|
|
||||||
+ ChatColor.AQUA + "for help");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sender instanceof final Player player)) {
|
|
||||||
sender.sendMessage(colorize("&4You must be a player to execute this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ItemStack item = player.getInventory().getItemInMainHand();
|
|
||||||
final boolean hasItem = item.getType() != Material.AIR;
|
|
||||||
final boolean hasPotion = POTIONS.contains(item.getType());
|
|
||||||
final boolean hasBook = item.getType() == Material.WRITTEN_BOOK;
|
|
||||||
final ItemMeta meta = item.getItemMeta();
|
|
||||||
|
|
||||||
switch (args[0]) {
|
|
||||||
case "help" -> {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3=============&f[&dItemizerX Commands&f]&3=============
|
|
||||||
&b/itemizer name <&fname&b> &c- &6Name your item
|
|
||||||
&b/itemizer id <&fid&b> &c- &6Change the item's material
|
|
||||||
&b/itemizer lore &c- &6Lore editing command
|
|
||||||
&b/itemizer potion &c- &6Potion editing command
|
|
||||||
&b/itemizer attr &c- &6Attribute editing command
|
|
||||||
&b/itemizer flag &c- &6Flag editing command
|
|
||||||
&b/itemizer enchant &c- &6Enchant editing command
|
|
||||||
&b/itemizer title <&fname&b> &c- &6Set the book's title
|
|
||||||
&b/itemizer author <&fname&b> &c- &6Set the book's author
|
|
||||||
&b/itemizer head <&fname&b> &c- &6Set the player of the head
|
|
||||||
&b/itemizer sign <&fline&b> <&ftext&b> &c- &6Change the line on the sign
|
|
||||||
&b/itemizer clearall &c- &6Clears all metadata from your item"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "name" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.name")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dName Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer name <&fname&b> &c - &6Name your item"));
|
|
||||||
} else {
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(StringUtils.join(args, " ", 1, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
meta.setDisplayName(name);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The name of the item in your hand has been set to &f'" + name + "&f'"));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "id" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.id")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dID Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer id <&fid&b> &c- &6Change the item's material"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Material material = Material.matchMaterial(args[1].toUpperCase());
|
|
||||||
if (material == null) {
|
|
||||||
sender.sendMessage(colorize("&4The material &f\"" + args[1] + "&f\"&4 does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setType(material);
|
|
||||||
sender.sendMessage(colorize("&2The material of the item has changed to &f'" + material.name() + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "lore" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dLore Commands&f]&3===============
|
|
||||||
&b/itemizer lore add <&ftext&b> &c- &6Add a line of text to your item's lore
|
|
||||||
&b/itemizer lore remove <&findex&b> &c- &6Remove a line of text from your item's lore
|
|
||||||
&b/itemizer lore change <&findex&b> <&ftext&b> &c- &6Change a line of text in your item's lore
|
|
||||||
&b/itemizer lore clear &c- &6Clear the item's lore"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore add <&ftext&b> &c- &6Add a line of text to your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String lore = colorize(StringUtils.join(args, " ", 2, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores = new ArrayList<>();
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
}
|
|
||||||
lores.add(lore);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + lore + "&f'&2 added to the item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore remove <&findex&b> &c- &6Remove a line of text from your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer index = parseInt(sender, args[2]);
|
|
||||||
if (index == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores;
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(colorize("&eThis item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (index > lores.size()) {
|
|
||||||
sender.sendMessage(colorize("&4The item's lore doesn't have line &f'" + index + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
lores.remove(index - 1);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + index + "&f'&2 removed from the item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "change" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.change")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 4) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore change <&findex&b> <&ftext&b> &c- &6Change a line of text in your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer index = parseInt(sender, args[2]);
|
|
||||||
if (index == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String lore = colorize(StringUtils.join(args, " ", 3, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores;
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(colorize("&eThis item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (index > lores.size()) {
|
|
||||||
sender.sendMessage(colorize("&4The item's lore doesn't have line &f'" + index + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
lores.set(index - 1, lore);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + index + "'&2 has changed to &f'" + lore + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "clear" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.clear")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (meta.getLore() == null || meta.getLore().isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4The item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.setLore(null);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The item's lore has been cleared!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer lore &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "potion" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dPotion Commands&f]&3===============
|
|
||||||
&b/itemizer potion add <&feffect&b> <&flevel&b> <&ftime[tick]&b> &c- &6Add a potion effect
|
|
||||||
&b/itemizer potion remove <&feffect&b> &c- &6Remove a potion effect
|
|
||||||
&b/itemizer potion change <&fname&b> &c- &6Change the potion type
|
|
||||||
&b/itemizer potion color <&fhexcolor&b> &c- &6Set the potion color
|
|
||||||
&b/itemizer potion list &c- &6List all potion effects"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasPotion) {
|
|
||||||
sender.sendMessage("Get a POTION in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 5) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion add <&feffect&b> <&flevel&b> <&ftime[tick]&b> &c- &6Add a potion effect"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PotionEffectType potType = PotionEffectType.getByName(args[2].toUpperCase());
|
|
||||||
if (potType == null) {
|
|
||||||
sender.sendMessage(colorize("&4The potion &f\"" + args[2] + "&f\"&4 does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer level = parseInt(sender, args[3]);
|
|
||||||
Integer tick = parseInt(sender, args[4]);
|
|
||||||
if (level == null || tick == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionEffect pot = new PotionEffect(potType, tick, level);
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
if (potionMeta.hasCustomEffect(pot.getType())) {
|
|
||||||
sender.sendMessage(colorize("&4This potion already has &f" + pot.getType().getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
potionMeta.addCustomEffect(pot, false);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(pot.getType().getName() + " &2has been added to the potion"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion remove <&feffect&b> &c- &6Remove a potion effect"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PotionEffectType potType = PotionEffectType.getByName(args[2].toUpperCase());
|
|
||||||
if (potType == null) {
|
|
||||||
sender.sendMessage("&4The potion effect &f\"" + args[2] + "&f\"&4 does not exist!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
if (!potionMeta.hasCustomEffect(potType)) {
|
|
||||||
sender.sendMessage(colorize("This potion does not have &f" + potType.getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
potionMeta.removeCustomEffect(potType);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(potType.getName() + " &2has been removed from the potion"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "change" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.change")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion change <&fname&b> &c- &6Change the potion type"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Material material = Material.matchMaterial(args[2]);
|
|
||||||
if (material == null || !POTIONS.contains(material)) {
|
|
||||||
sender.sendMessage(colorize(material != null ?
|
|
||||||
"&f'" + material.name() + "' &4is not a potion type!"
|
|
||||||
:
|
|
||||||
"&4That material doesn't exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setType(material);
|
|
||||||
sender.sendMessage(colorize("&2The potion in hand has changed to &f'" + material.name() + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "color" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.color")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 3) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion color <&fhexcolor&b> &c- &6Set a potion color"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
try {
|
|
||||||
java.awt.Color awtColor = java.awt.Color.decode(args[2]);
|
|
||||||
Color color = Color.fromRGB(awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue());
|
|
||||||
potionMeta.setColor(color);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(args[2] + " &2has been set as potion color"));
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
sender.sendMessage(colorize("&4The hex &f\"" + args[2] + "&f\"&4 is invalid!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
PotionEffectType[] effects;
|
|
||||||
for (int i = 0; i < (effects = PotionEffectType.values()).length; i++) {
|
|
||||||
sb.append(", ").append(effects[i].getName());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available potion effects: &e"
|
|
||||||
+ sb.toString().replaceFirst(", ", "")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer potion &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "attr" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dAttribute Commands&f]&3===============
|
|
||||||
&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c - &6Add an attribute
|
|
||||||
&b/itemizer attr remove <&fname&b> &c- &6Remove an attribute
|
|
||||||
&b/itemizer attr list &c- &6List all item's attributes
|
|
||||||
&b/itemizer attr listall &c- &6List all supported attributes"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.addAttr(player, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.removeAttr(player, args[2]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.listAttr(player);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Supported attributes: "
|
|
||||||
+ "&e" + AttributeManager.Attributes.getAttributes()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer attr &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "flag" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dFlag Commands&f]&3===============
|
|
||||||
&b/itemizer flag add <&fname&b> &c- &6Add a flag
|
|
||||||
&b/itemizer flag remove <&fname&b> &c- &6Remove a flag
|
|
||||||
&b/itemizer flag list &c- &6List all item's flag
|
|
||||||
&b/itemizer flag listall &c- &6List all available flags"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dFlag Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer flag add <&fname&b> &c- &6Add a flag"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ItemFlag flag = null;
|
|
||||||
try {
|
|
||||||
flag = ItemFlag.valueOf(args[2].toUpperCase());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
if (flag == null) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f\"" + args[2] + "&f\" does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (meta.getItemFlags().contains(flag)) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f'" + args[2].toUpperCase() + "' &4already added to the item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.addItemFlags(flag);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The flag &f'" + args[2].toUpperCase() + "' &2has been added to your item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dFlag Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer flag remove <&fname&b> &c- &6remove a flag"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ItemFlag flag = null;
|
|
||||||
try {
|
|
||||||
flag = ItemFlag.valueOf(args[2].toUpperCase());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
if (flag == null) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f\"" + args[2] + "&f\" does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (!meta.getItemFlags().contains(flag)) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f'" + args[2].toUpperCase() + "' &4has not been added the item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.removeItemFlags(flag);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The flag &f'" + args[2].toUpperCase() + "' &2has been removed from your item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getItemFlags()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4The item in your hand does not have any flags"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Item flags: &e"
|
|
||||||
+ StringUtils.join(meta.getItemFlags(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available item flags: &e"
|
|
||||||
+ StringUtils.join(ItemFlag.values(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer flag &bfor help"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "enchant" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dEnchant Commands&f]&3===============
|
|
||||||
&b/itemizer enchant add <&fname&b> <&flevel&b> &c- &6Add an enchant
|
|
||||||
&b/itemizer enchant remove <&fname&b> &c- &6Remove an enchant
|
|
||||||
&b/itemizer enchant list &c- &6List all item's enchants
|
|
||||||
&b/itemizer enchant listall &c- &6List all available enchants"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 4) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dEnchant Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer enchant add <&fname&b> <&flevel&b> &c- &6Add an enchant"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Enchantment ench = EnchantmentWrapper.getByKey(NamespacedKey.minecraft(args[2].toLowerCase()));
|
|
||||||
if (ench == null) {
|
|
||||||
sender.sendMessage(colorize("&4The enchantment &f'" + args[2] + "&f' &4does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer level = parseInt(sender, args[3]);
|
|
||||||
if (level == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.addUnsafeEnchantment(ench, level);
|
|
||||||
sender.sendMessage(colorize("&2The enchant &f'" + ench.getKey().getKey() + "' &2has been added to your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.remove")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dEnchant Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer enchant remove <&fname&b> &c- &6Remove an enchant"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Enchantment ench = EnchantmentWrapper.getByKey(NamespacedKey.minecraft(args[2].toLowerCase()));
|
|
||||||
if (ench == null) {
|
|
||||||
sender.sendMessage(colorize("&4The enchantment &f'" + args[2] + "&f' &4does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getEnchants()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't hold any enchants"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!meta.getEnchants().containsKey(ench)) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't have &f'" + ench.getKey().getKey() + "' &4enchant!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.removeEnchantment(ench);
|
|
||||||
sender.sendMessage(colorize("&2The enchant &f'" + ench.getKey().getKey() + "' &2has been removed from your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getEnchants()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't hold any enchants"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Item enchants: &e"
|
|
||||||
+ StringUtils.join(meta.getEnchants().keySet(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
Enchantment[] enchantments;
|
|
||||||
for (int i = 0; i < (enchantments = Enchantment.values()).length; i++) {
|
|
||||||
sb.append(", ").append(enchantments[i].getKey().getKey());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available item enchants: &e"
|
|
||||||
+ sb.toString().replaceFirst(", ", "")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer enchant &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "title" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.title")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dTitle Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer title <&fname&b> &c- &6Set the book's title"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasBook) {
|
|
||||||
sender.sendMessage("Get a WRITTEN_BOOK in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(StringUtils.join(args, " ", 1, args.length));
|
|
||||||
final BookMeta bookMeta = (BookMeta) meta;
|
|
||||||
assert bookMeta != null;
|
|
||||||
bookMeta.setTitle(name);
|
|
||||||
item.setItemMeta(bookMeta);
|
|
||||||
sender.sendMessage(colorize("&2The title of the book has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "author" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.author")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dAuthor Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer author <&fname&b> &c- &6Set the book's title"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasBook) {
|
|
||||||
sender.sendMessage("Get a WRITTEN_BOOK in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(args[1]);
|
|
||||||
final BookMeta bookMeta = (BookMeta) meta;
|
|
||||||
assert bookMeta != null;
|
|
||||||
bookMeta.setAuthor(name);
|
|
||||||
item.setItemMeta(bookMeta);
|
|
||||||
sender.sendMessage(colorize("&2The author of the book has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "head" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.head")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dHead Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer head <&fname&b> &c- &6Set the player of the head"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (item.getType() != Material.PLAYER_HEAD) {
|
|
||||||
sender.sendMessage("Get a SKULL in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = args[1];
|
|
||||||
if (name.length() > 16) {
|
|
||||||
name = name.substring(0, 16);
|
|
||||||
}
|
|
||||||
final SkullMeta skullMeta = (SkullMeta) meta;
|
|
||||||
assert skullMeta != null;
|
|
||||||
skullMeta.setOwner(name);
|
|
||||||
item.setItemMeta(skullMeta);
|
|
||||||
sender.sendMessage(colorize("&2The player of the head has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "sign" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.sign")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 3) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dSign Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer sign <&fline&b> <&ftext&b> &c- &6Change the line on the sign"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Block block = player.getTargetBlockExact(20);
|
|
||||||
if (block == null || block.getType() == Material.AIR
|
|
||||||
|| !block.getType().toString().contains("SIGN")) {
|
|
||||||
sender.sendMessage(colorize("&4Please look at a sign!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer line = parseInt(sender, args[1]);
|
|
||||||
if (line == null) {
|
|
||||||
return true;
|
|
||||||
} else if (line > 4) {
|
|
||||||
sender.sendMessage(colorize("&4There's maximum of 4 lines on a sign"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String text = colorize(StringUtils.join(args, " ", 2, args.length));
|
|
||||||
if (cpb.getAPI() != null) {
|
|
||||||
cpb.getAPI().logRemoval(player.getName(), block.getLocation(), block.getType(), block.getBlockData());
|
|
||||||
}
|
|
||||||
Sign sign = (Sign) block.getState();
|
|
||||||
sign.setLine(line - 1, text);
|
|
||||||
sign.update();
|
|
||||||
if (cpb.getAPI() != null) {
|
|
||||||
cpb.getAPI().logPlacement(player.getName(), sign.getLocation(), sign.getType(), sign.getBlockData());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + line + "'&2 has successfully changed to &f'" + text + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "clearall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.clearall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setItemMeta(null);
|
|
||||||
sender.sendMessage(colorize("&2All data cleared from your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer help &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String colorize(String string) {
|
|
||||||
Matcher matcher = Pattern.compile("&#[a-fA-F0-9]{6}").matcher(string);
|
|
||||||
while (matcher.find()) {
|
|
||||||
String code = matcher.group().replace("&", "");
|
|
||||||
string = string.replace("&" + code, net.md_5.bungee.api.ChatColor.of(code) + "");
|
|
||||||
}
|
|
||||||
string = ChatColor.translateAlternateColorCodes('&', string);
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer parseInt(CommandSender sender, String string) {
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(string);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
sender.sendMessage(colorize("&f\"" + string + "&f\"&4 is not a valid number!"));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,105 +0,0 @@
|
|||||||
package dev.plex.itemizerx.v1_19_R2;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemizerXTab implements TabCompleter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String string, String[] args) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
return Arrays.asList("help", "id", "lore", "potion", "attr", "flag", "enchant", "title", "author",
|
|
||||||
"head", "sign", "clearall");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 2) {
|
|
||||||
switch (args[0]) {
|
|
||||||
case "id": {
|
|
||||||
List<String> materials = new ArrayList<>();
|
|
||||||
for (Material material : Material.values()) {
|
|
||||||
materials.add(material.name());
|
|
||||||
}
|
|
||||||
return materials;
|
|
||||||
}
|
|
||||||
case "lore": {
|
|
||||||
return Arrays.asList("add", "remove", "change", "clear");
|
|
||||||
}
|
|
||||||
case "potion": {
|
|
||||||
return Arrays.asList("add", "remove", "change", "color", "list");
|
|
||||||
}
|
|
||||||
case "attr":
|
|
||||||
case "flag":
|
|
||||||
case "enchant": {
|
|
||||||
return Arrays.asList("add", "remove", "list", "listall");
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 3) {
|
|
||||||
switch (args[0]) {
|
|
||||||
case "potion": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> potions = new ArrayList<>();
|
|
||||||
for (PotionEffectType effect : PotionEffectType.values()) {
|
|
||||||
potions.add(effect.getName());
|
|
||||||
}
|
|
||||||
return potions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "attr": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
return AttributeManager.Attributes.getAttributeList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "flag": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> flags = new ArrayList<>();
|
|
||||||
for (ItemFlag flag : ItemFlag.values()) {
|
|
||||||
flags.add(flag.name());
|
|
||||||
}
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "enchant": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> enchantments = new ArrayList<>();
|
|
||||||
for (Enchantment enchantment : Enchantment.values()) {
|
|
||||||
enchantments.add(enchantment.getKey().getKey());
|
|
||||||
}
|
|
||||||
return enchantments;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,3 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
}
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":shared"))
|
|
||||||
compileOnly("org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT")
|
||||||
compileOnly("net.coreprotect:coreprotect:21.3")
|
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package dev.plex.itemizerx.v1_19_R3;
|
package dev.plex.itemizerx.v1_19_R3;
|
||||||
|
|
||||||
|
import dev.plex.itemizerx.Attributes;
|
||||||
|
import dev.plex.itemizerx.IAttributeManager;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@ -12,9 +14,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class AttributeManager {
|
public class AttributeManager implements IAttributeManager {
|
||||||
|
|
||||||
public static NBTTagList getAttrList(final ItemStack item) {
|
@Override
|
||||||
|
public NBTTagList getAttrList(final ItemStack item) {
|
||||||
NBTTagList attrmod = item.v().c("AttributeModifiers", 10);
|
NBTTagList attrmod = item.v().c("AttributeModifiers", 10);
|
||||||
if (attrmod == null) {
|
if (attrmod == null) {
|
||||||
item.u().a("AttributeModifiers", new NBTTagList());
|
item.u().a("AttributeModifiers", new NBTTagList());
|
||||||
@ -22,7 +25,8 @@ public class AttributeManager {
|
|||||||
return item.u().c("AttributeModifiers", 10);
|
return item.u().c("AttributeModifiers", 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addAttr(final Player player, final String[] args) {
|
@Override
|
||||||
|
public void addAttr(final Player player, final String[] args) {
|
||||||
int op;
|
int op;
|
||||||
if (args.length < 4) {
|
if (args.length < 4) {
|
||||||
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
||||||
@ -90,7 +94,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute added!"));
|
player.sendMessage(colorize("&2Attribute added!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeAttr(final Player player, final String string) {
|
@Override
|
||||||
|
public void removeAttr(final Player player, final String string) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
final NBTTagList newList = new NBTTagList();
|
final NBTTagList newList = new NBTTagList();
|
||||||
@ -113,7 +118,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute removed!"));
|
player.sendMessage(colorize("&2Attribute removed!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void listAttr(final Player player) {
|
@Override
|
||||||
|
public void listAttr(final Player player) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
if (attrmod.size() == 0) {
|
if (attrmod.size() == 0) {
|
||||||
@ -128,52 +134,8 @@ public class AttributeManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String colorize(String string) {
|
@Override
|
||||||
|
public String colorize(String string) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
return ChatColor.translateAlternateColorCodes('&', string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Attributes {
|
|
||||||
|
|
||||||
MAX_HEALTH("generic.max_health", 0),
|
|
||||||
FOLLOW_RANGE("generic.follow_range", 1),
|
|
||||||
KNOCKBACK_RESISTANCE("generic.knockback_resistance", 1),
|
|
||||||
MOVEMENT_SPEED("generic.movement_speed", 1),
|
|
||||||
DAMAGE("generic.attack_damage", 0),
|
|
||||||
ARMOR("generic.armor", 0),
|
|
||||||
ARMOR_TOUGHNESS("generic.armor_toughness", 0),
|
|
||||||
FLYING_SPEED("generic.flying_speed", 1),
|
|
||||||
ATTACK_SPEED("generic.attack_speed", 1),
|
|
||||||
LUCK("generic.luck", 0),
|
|
||||||
HORSE_JUMP("horse.jump_strength", 1),
|
|
||||||
ZOMBIE_REINFORCEMENTS("zombie.spawn_reinforcements", 1);
|
|
||||||
|
|
||||||
private final String mcName;
|
|
||||||
private final int op;
|
|
||||||
|
|
||||||
Attributes(String mcName, int op) {
|
|
||||||
this.mcName = mcName;
|
|
||||||
this.op = op;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Attributes get(String name) {
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
if (attr.name().equalsIgnoreCase(name) || attr.mcName.equalsIgnoreCase(name)) {
|
|
||||||
return attr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getAttributes() {
|
|
||||||
return StringUtils.join(values(), ", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getAttributeList() {
|
|
||||||
List<String> attributes = new ArrayList<>();
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
attributes.add(attr.name());
|
|
||||||
}
|
|
||||||
return attributes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,810 +0,0 @@
|
|||||||
package dev.plex.itemizerx.v1_19_R3;
|
|
||||||
|
|
||||||
import dev.plex.itemizerx.CoreProtectBridge;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.*;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.enchantments.EnchantmentWrapper;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.BookMeta;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class ItemizerXCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
final List<Material> POTIONS = Arrays.asList(Material.POTION, Material.LINGERING_POTION, Material.SPLASH_POTION);
|
|
||||||
CoreProtectBridge cpb = new CoreProtectBridge();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String string, String[] args) {
|
|
||||||
if (!sender.hasPermission("itemizer.use")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
sender.sendMessage(ChatColor.AQUA + "ItemizerX " + ChatColor.GOLD + "v"
|
|
||||||
+ Bukkit.getPluginManager().getPlugin("ItemizerX").getDescription().getVersion()
|
|
||||||
+ ChatColor.AQUA + " by " + ChatColor.GOLD
|
|
||||||
+ StringUtils.join(Bukkit.getPluginManager().getPlugin("ItemizerX").getDescription().getAuthors(), ", "));
|
|
||||||
sender.sendMessage(ChatColor.AQUA + "Type " + ChatColor.GOLD + "/itemizer help "
|
|
||||||
+ ChatColor.AQUA + "for help");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sender instanceof final Player player)) {
|
|
||||||
sender.sendMessage(colorize("&4You must be a player to execute this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ItemStack item = player.getInventory().getItemInMainHand();
|
|
||||||
final boolean hasItem = item.getType() != Material.AIR;
|
|
||||||
final boolean hasPotion = POTIONS.contains(item.getType());
|
|
||||||
final boolean hasBook = item.getType() == Material.WRITTEN_BOOK;
|
|
||||||
final ItemMeta meta = item.getItemMeta();
|
|
||||||
|
|
||||||
switch (args[0]) {
|
|
||||||
case "help" -> {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3=============&f[&dItemizerX Commands&f]&3=============
|
|
||||||
&b/itemizer name <&fname&b> &c- &6Name your item
|
|
||||||
&b/itemizer id <&fid&b> &c- &6Change the item's material
|
|
||||||
&b/itemizer lore &c- &6Lore editing command
|
|
||||||
&b/itemizer potion &c- &6Potion editing command
|
|
||||||
&b/itemizer attr &c- &6Attribute editing command
|
|
||||||
&b/itemizer flag &c- &6Flag editing command
|
|
||||||
&b/itemizer enchant &c- &6Enchant editing command
|
|
||||||
&b/itemizer title <&fname&b> &c- &6Set the book's title
|
|
||||||
&b/itemizer author <&fname&b> &c- &6Set the book's author
|
|
||||||
&b/itemizer head <&fname&b> &c- &6Set the player of the head
|
|
||||||
&b/itemizer sign <&fline&b> <&ftext&b> &c- &6Change the line on the sign
|
|
||||||
&b/itemizer clearall &c- &6Clears all metadata from your item"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "name" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.name")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dName Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer name <&fname&b> &c - &6Name your item"));
|
|
||||||
} else {
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(StringUtils.join(args, " ", 1, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
meta.setDisplayName(name);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The name of the item in your hand has been set to &f'" + name + "&f'"));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "id" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.id")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dID Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer id <&fid&b> &c- &6Change the item's material"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Material material = Material.matchMaterial(args[1].toUpperCase());
|
|
||||||
if (material == null) {
|
|
||||||
sender.sendMessage(colorize("&4The material &f\"" + args[1] + "&f\"&4 does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setType(material);
|
|
||||||
sender.sendMessage(colorize("&2The material of the item has changed to &f'" + material.name() + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "lore" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dLore Commands&f]&3===============
|
|
||||||
&b/itemizer lore add <&ftext&b> &c- &6Add a line of text to your item's lore
|
|
||||||
&b/itemizer lore remove <&findex&b> &c- &6Remove a line of text from your item's lore
|
|
||||||
&b/itemizer lore change <&findex&b> <&ftext&b> &c- &6Change a line of text in your item's lore
|
|
||||||
&b/itemizer lore clear &c- &6Clear the item's lore"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore add <&ftext&b> &c- &6Add a line of text to your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String lore = colorize(StringUtils.join(args, " ", 2, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores = new ArrayList<>();
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
}
|
|
||||||
lores.add(lore);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + lore + "&f'&2 added to the item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore remove <&findex&b> &c- &6Remove a line of text from your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer index = parseInt(sender, args[2]);
|
|
||||||
if (index == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores;
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(colorize("&eThis item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (index > lores.size()) {
|
|
||||||
sender.sendMessage(colorize("&4The item's lore doesn't have line &f'" + index + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
lores.remove(index - 1);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + index + "&f'&2 removed from the item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "change" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.change")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 4) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore change <&findex&b> <&ftext&b> &c- &6Change a line of text in your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer index = parseInt(sender, args[2]);
|
|
||||||
if (index == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String lore = colorize(StringUtils.join(args, " ", 3, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores;
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(colorize("&eThis item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (index > lores.size()) {
|
|
||||||
sender.sendMessage(colorize("&4The item's lore doesn't have line &f'" + index + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
lores.set(index - 1, lore);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + index + "'&2 has changed to &f'" + lore + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "clear" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.clear")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (meta.getLore() == null || meta.getLore().isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4The item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.setLore(null);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The item's lore has been cleared!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer lore &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "potion" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dPotion Commands&f]&3===============
|
|
||||||
&b/itemizer potion add <&feffect&b> <&flevel&b> <&ftime[tick]&b> &c- &6Add a potion effect
|
|
||||||
&b/itemizer potion remove <&feffect&b> &c- &6Remove a potion effect
|
|
||||||
&b/itemizer potion change <&fname&b> &c- &6Change the potion type
|
|
||||||
&b/itemizer potion color <&fhexcolor&b> &c- &6Set the potion color
|
|
||||||
&b/itemizer potion list &c- &6List all potion effects"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasPotion) {
|
|
||||||
sender.sendMessage("Get a POTION in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 5) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion add <&feffect&b> <&flevel&b> <&ftime[tick]&b> &c- &6Add a potion effect"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PotionEffectType potType = PotionEffectType.getByName(args[2].toUpperCase());
|
|
||||||
if (potType == null) {
|
|
||||||
sender.sendMessage(colorize("&4The potion &f\"" + args[2] + "&f\"&4 does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer level = parseInt(sender, args[3]);
|
|
||||||
Integer tick = parseInt(sender, args[4]);
|
|
||||||
if (level == null || tick == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionEffect pot = new PotionEffect(potType, tick, level);
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
if (potionMeta.hasCustomEffect(pot.getType())) {
|
|
||||||
sender.sendMessage(colorize("&4This potion already has &f" + pot.getType().getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
potionMeta.addCustomEffect(pot, false);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(pot.getType().getName() + " &2has been added to the potion"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion remove <&feffect&b> &c- &6Remove a potion effect"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PotionEffectType potType = PotionEffectType.getByName(args[2].toUpperCase());
|
|
||||||
if (potType == null) {
|
|
||||||
sender.sendMessage("&4The potion effect &f\"" + args[2] + "&f\"&4 does not exist!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
if (!potionMeta.hasCustomEffect(potType)) {
|
|
||||||
sender.sendMessage(colorize("This potion does not have &f" + potType.getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
potionMeta.removeCustomEffect(potType);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(potType.getName() + " &2has been removed from the potion"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "change" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.change")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion change <&fname&b> &c- &6Change the potion type"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Material material = Material.matchMaterial(args[2]);
|
|
||||||
if (material == null || !POTIONS.contains(material)) {
|
|
||||||
sender.sendMessage(colorize(material != null ?
|
|
||||||
"&f'" + material.name() + "' &4is not a potion type!"
|
|
||||||
:
|
|
||||||
"&4That material doesn't exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setType(material);
|
|
||||||
sender.sendMessage(colorize("&2The potion in hand has changed to &f'" + material.name() + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "color" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.color")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 3) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion color <&fhexcolor&b> &c- &6Set a potion color"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
try {
|
|
||||||
java.awt.Color awtColor = java.awt.Color.decode(args[2]);
|
|
||||||
Color color = Color.fromRGB(awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue());
|
|
||||||
potionMeta.setColor(color);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(args[2] + " &2has been set as potion color"));
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
sender.sendMessage(colorize("&4The hex &f\"" + args[2] + "&f\"&4 is invalid!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
PotionEffectType[] effects;
|
|
||||||
for (int i = 0; i < (effects = PotionEffectType.values()).length; i++) {
|
|
||||||
sb.append(", ").append(effects[i].getName());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available potion effects: &e"
|
|
||||||
+ sb.toString().replaceFirst(", ", "")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer potion &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "attr" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dAttribute Commands&f]&3===============
|
|
||||||
&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c - &6Add an attribute
|
|
||||||
&b/itemizer attr remove <&fname&b> &c- &6Remove an attribute
|
|
||||||
&b/itemizer attr list &c- &6List all item's attributes
|
|
||||||
&b/itemizer attr listall &c- &6List all supported attributes"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.addAttr(player, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.removeAttr(player, args[2]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.listAttr(player);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Supported attributes: "
|
|
||||||
+ "&e" + AttributeManager.Attributes.getAttributes()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer attr &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "flag" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dFlag Commands&f]&3===============
|
|
||||||
&b/itemizer flag add <&fname&b> &c- &6Add a flag
|
|
||||||
&b/itemizer flag remove <&fname&b> &c- &6Remove a flag
|
|
||||||
&b/itemizer flag list &c- &6List all item's flag
|
|
||||||
&b/itemizer flag listall &c- &6List all available flags"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dFlag Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer flag add <&fname&b> &c- &6Add a flag"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ItemFlag flag = null;
|
|
||||||
try {
|
|
||||||
flag = ItemFlag.valueOf(args[2].toUpperCase());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
if (flag == null) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f\"" + args[2] + "&f\" does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (meta.getItemFlags().contains(flag)) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f'" + args[2].toUpperCase() + "' &4already added to the item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.addItemFlags(flag);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The flag &f'" + args[2].toUpperCase() + "' &2has been added to your item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dFlag Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer flag remove <&fname&b> &c- &6remove a flag"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ItemFlag flag = null;
|
|
||||||
try {
|
|
||||||
flag = ItemFlag.valueOf(args[2].toUpperCase());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
if (flag == null) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f\"" + args[2] + "&f\" does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (!meta.getItemFlags().contains(flag)) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f'" + args[2].toUpperCase() + "' &4has not been added the item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.removeItemFlags(flag);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The flag &f'" + args[2].toUpperCase() + "' &2has been removed from your item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getItemFlags()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4The item in your hand does not have any flags"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Item flags: &e"
|
|
||||||
+ StringUtils.join(meta.getItemFlags(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available item flags: &e"
|
|
||||||
+ StringUtils.join(ItemFlag.values(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer flag &bfor help"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "enchant" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dEnchant Commands&f]&3===============
|
|
||||||
&b/itemizer enchant add <&fname&b> <&flevel&b> &c- &6Add an enchant
|
|
||||||
&b/itemizer enchant remove <&fname&b> &c- &6Remove an enchant
|
|
||||||
&b/itemizer enchant list &c- &6List all item's enchants
|
|
||||||
&b/itemizer enchant listall &c- &6List all available enchants"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 4) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dEnchant Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer enchant add <&fname&b> <&flevel&b> &c- &6Add an enchant"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Enchantment ench = EnchantmentWrapper.getByKey(NamespacedKey.minecraft(args[2].toLowerCase()));
|
|
||||||
if (ench == null) {
|
|
||||||
sender.sendMessage(colorize("&4The enchantment &f'" + args[2] + "&f' &4does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer level = parseInt(sender, args[3]);
|
|
||||||
if (level == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.addUnsafeEnchantment(ench, level);
|
|
||||||
sender.sendMessage(colorize("&2The enchant &f'" + ench.getKey().getKey() + "' &2has been added to your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.remove")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dEnchant Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer enchant remove <&fname&b> &c- &6Remove an enchant"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Enchantment ench = EnchantmentWrapper.getByKey(NamespacedKey.minecraft(args[2].toLowerCase()));
|
|
||||||
if (ench == null) {
|
|
||||||
sender.sendMessage(colorize("&4The enchantment &f'" + args[2] + "&f' &4does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getEnchants()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't hold any enchants"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!meta.getEnchants().containsKey(ench)) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't have &f'" + ench.getKey().getKey() + "' &4enchant!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.removeEnchantment(ench);
|
|
||||||
sender.sendMessage(colorize("&2The enchant &f'" + ench.getKey().getKey() + "' &2has been removed from your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getEnchants()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't hold any enchants"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Item enchants: &e"
|
|
||||||
+ StringUtils.join(meta.getEnchants().keySet(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
Enchantment[] enchantments;
|
|
||||||
for (int i = 0; i < (enchantments = Enchantment.values()).length; i++) {
|
|
||||||
sb.append(", ").append(enchantments[i].getKey().getKey());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available item enchants: &e"
|
|
||||||
+ sb.toString().replaceFirst(", ", "")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer enchant &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "title" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.title")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dTitle Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer title <&fname&b> &c- &6Set the book's title"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasBook) {
|
|
||||||
sender.sendMessage("Get a WRITTEN_BOOK in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(StringUtils.join(args, " ", 1, args.length));
|
|
||||||
final BookMeta bookMeta = (BookMeta) meta;
|
|
||||||
assert bookMeta != null;
|
|
||||||
bookMeta.setTitle(name);
|
|
||||||
item.setItemMeta(bookMeta);
|
|
||||||
sender.sendMessage(colorize("&2The title of the book has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "author" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.author")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dAuthor Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer author <&fname&b> &c- &6Set the book's title"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasBook) {
|
|
||||||
sender.sendMessage("Get a WRITTEN_BOOK in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(args[1]);
|
|
||||||
final BookMeta bookMeta = (BookMeta) meta;
|
|
||||||
assert bookMeta != null;
|
|
||||||
bookMeta.setAuthor(name);
|
|
||||||
item.setItemMeta(bookMeta);
|
|
||||||
sender.sendMessage(colorize("&2The author of the book has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "head" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.head")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dHead Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer head <&fname&b> &c- &6Set the player of the head"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (item.getType() != Material.PLAYER_HEAD) {
|
|
||||||
sender.sendMessage("Get a SKULL in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = args[1];
|
|
||||||
if (name.length() > 16) {
|
|
||||||
name = name.substring(0, 16);
|
|
||||||
}
|
|
||||||
final SkullMeta skullMeta = (SkullMeta) meta;
|
|
||||||
assert skullMeta != null;
|
|
||||||
skullMeta.setOwner(name);
|
|
||||||
item.setItemMeta(skullMeta);
|
|
||||||
sender.sendMessage(colorize("&2The player of the head has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "sign" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.sign")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 3) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dSign Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer sign <&fline&b> <&ftext&b> &c- &6Change the line on the sign"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Block block = player.getTargetBlockExact(20);
|
|
||||||
if (block == null || block.getType() == Material.AIR
|
|
||||||
|| !block.getType().toString().contains("SIGN")) {
|
|
||||||
sender.sendMessage(colorize("&4Please look at a sign!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer line = parseInt(sender, args[1]);
|
|
||||||
if (line == null) {
|
|
||||||
return true;
|
|
||||||
} else if (line > 4) {
|
|
||||||
sender.sendMessage(colorize("&4There's maximum of 4 lines on a sign"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String text = colorize(StringUtils.join(args, " ", 2, args.length));
|
|
||||||
if (cpb.getAPI() != null) {
|
|
||||||
cpb.getAPI().logRemoval(player.getName(), block.getLocation(), block.getType(), block.getBlockData());
|
|
||||||
}
|
|
||||||
Sign sign = (Sign) block.getState();
|
|
||||||
sign.setLine(line - 1, text);
|
|
||||||
sign.update();
|
|
||||||
if (cpb.getAPI() != null) {
|
|
||||||
cpb.getAPI().logPlacement(player.getName(), sign.getLocation(), sign.getType(), sign.getBlockData());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + line + "'&2 has successfully changed to &f'" + text + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "clearall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.clearall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setItemMeta(null);
|
|
||||||
sender.sendMessage(colorize("&2All data cleared from your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer help &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String colorize(String string) {
|
|
||||||
Matcher matcher = Pattern.compile("&#[a-fA-F0-9]{6}").matcher(string);
|
|
||||||
while (matcher.find()) {
|
|
||||||
String code = matcher.group().replace("&", "");
|
|
||||||
string = string.replace("&" + code, net.md_5.bungee.api.ChatColor.of(code) + "");
|
|
||||||
}
|
|
||||||
string = ChatColor.translateAlternateColorCodes('&', string);
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer parseInt(CommandSender sender, String string) {
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(string);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
sender.sendMessage(colorize("&f\"" + string + "&f\"&4 is not a valid number!"));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,105 +0,0 @@
|
|||||||
package dev.plex.itemizerx.v1_19_R3;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemizerXTab implements TabCompleter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String string, String[] args) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
return Arrays.asList("help", "id", "lore", "potion", "attr", "flag", "enchant", "title", "author",
|
|
||||||
"head", "sign", "clearall");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 2) {
|
|
||||||
switch (args[0]) {
|
|
||||||
case "id": {
|
|
||||||
List<String> materials = new ArrayList<>();
|
|
||||||
for (Material material : Material.values()) {
|
|
||||||
materials.add(material.name());
|
|
||||||
}
|
|
||||||
return materials;
|
|
||||||
}
|
|
||||||
case "lore": {
|
|
||||||
return Arrays.asList("add", "remove", "change", "clear");
|
|
||||||
}
|
|
||||||
case "potion": {
|
|
||||||
return Arrays.asList("add", "remove", "change", "color", "list");
|
|
||||||
}
|
|
||||||
case "attr":
|
|
||||||
case "flag":
|
|
||||||
case "enchant": {
|
|
||||||
return Arrays.asList("add", "remove", "list", "listall");
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 3) {
|
|
||||||
switch (args[0]) {
|
|
||||||
case "potion": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> potions = new ArrayList<>();
|
|
||||||
for (PotionEffectType effect : PotionEffectType.values()) {
|
|
||||||
potions.add(effect.getName());
|
|
||||||
}
|
|
||||||
return potions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "attr": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
return AttributeManager.Attributes.getAttributeList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "flag": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> flags = new ArrayList<>();
|
|
||||||
for (ItemFlag flag : ItemFlag.values()) {
|
|
||||||
flags.add(flag.name());
|
|
||||||
}
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "enchant": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> enchantments = new ArrayList<>();
|
|
||||||
for (Enchantment enchantment : Enchantment.values()) {
|
|
||||||
enchantments.add(enchantment.getKey().getKey());
|
|
||||||
}
|
|
||||||
return enchantments;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,3 @@
|
|||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
}
|
|
||||||
|
|
||||||
group = rootProject.group
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":shared"))
|
|
||||||
compileOnly("org.spigotmc:spigot:1.20.1-R0.1-SNAPSHOT")
|
compileOnly("org.spigotmc:spigot:1.20.1-R0.1-SNAPSHOT")
|
||||||
compileOnly("net.coreprotect:coreprotect:21.3")
|
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package dev.plex.itemizerx.v1_20_R1;
|
package dev.plex.itemizerx.v1_20_R1;
|
||||||
|
|
||||||
|
import dev.plex.itemizerx.Attributes;
|
||||||
|
import dev.plex.itemizerx.IAttributeManager;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
@ -12,9 +14,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class AttributeManager {
|
public class AttributeManager implements IAttributeManager {
|
||||||
|
|
||||||
public static NBTTagList getAttrList(final ItemStack item) {
|
@Override
|
||||||
|
public NBTTagList getAttrList(final ItemStack item) {
|
||||||
NBTTagList attrmod = item.w().c("AttributeModifiers", 10);
|
NBTTagList attrmod = item.w().c("AttributeModifiers", 10);
|
||||||
if (attrmod == null) {
|
if (attrmod == null) {
|
||||||
item.v().a("AttributeModifiers", new NBTTagList());
|
item.v().a("AttributeModifiers", new NBTTagList());
|
||||||
@ -22,7 +25,8 @@ public class AttributeManager {
|
|||||||
return item.v().c("AttributeModifiers", 10);
|
return item.v().c("AttributeModifiers", 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addAttr(final Player player, final String[] args) {
|
@Override
|
||||||
|
public void addAttr(final Player player, final String[] args) {
|
||||||
int op;
|
int op;
|
||||||
if (args.length < 4) {
|
if (args.length < 4) {
|
||||||
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
player.sendMessage(colorize("&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c- "
|
||||||
@ -90,7 +94,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute added!"));
|
player.sendMessage(colorize("&2Attribute added!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeAttr(final Player player, final String string) {
|
@Override
|
||||||
|
public void removeAttr(final Player player, final String string) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
final NBTTagList newList = new NBTTagList();
|
final NBTTagList newList = new NBTTagList();
|
||||||
@ -113,7 +118,8 @@ public class AttributeManager {
|
|||||||
player.sendMessage(colorize("&2Attribute removed!"));
|
player.sendMessage(colorize("&2Attribute removed!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void listAttr(final Player player) {
|
@Override
|
||||||
|
public void listAttr(final Player player) {
|
||||||
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
final ItemStack nms = CraftItemStack.asNMSCopy(player.getInventory().getItemInMainHand());
|
||||||
final NBTTagList attrmod = getAttrList(nms);
|
final NBTTagList attrmod = getAttrList(nms);
|
||||||
if (attrmod.size() == 0) {
|
if (attrmod.size() == 0) {
|
||||||
@ -128,52 +134,8 @@ public class AttributeManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String colorize(String string) {
|
@Override
|
||||||
|
public String colorize(String string) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
return ChatColor.translateAlternateColorCodes('&', string);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Attributes {
|
|
||||||
|
|
||||||
MAX_HEALTH("generic.max_health", 0),
|
|
||||||
FOLLOW_RANGE("generic.follow_range", 1),
|
|
||||||
KNOCKBACK_RESISTANCE("generic.knockback_resistance", 1),
|
|
||||||
MOVEMENT_SPEED("generic.movement_speed", 1),
|
|
||||||
DAMAGE("generic.attack_damage", 0),
|
|
||||||
ARMOR("generic.armor", 0),
|
|
||||||
ARMOR_TOUGHNESS("generic.armor_toughness", 0),
|
|
||||||
FLYING_SPEED("generic.flying_speed", 1),
|
|
||||||
ATTACK_SPEED("generic.attack_speed", 1),
|
|
||||||
LUCK("generic.luck", 0),
|
|
||||||
HORSE_JUMP("horse.jump_strength", 1),
|
|
||||||
ZOMBIE_REINFORCEMENTS("zombie.spawn_reinforcements", 1);
|
|
||||||
|
|
||||||
private final String mcName;
|
|
||||||
private final int op;
|
|
||||||
|
|
||||||
Attributes(String mcName, int op) {
|
|
||||||
this.mcName = mcName;
|
|
||||||
this.op = op;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Attributes get(String name) {
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
if (attr.name().equalsIgnoreCase(name) || attr.mcName.equalsIgnoreCase(name)) {
|
|
||||||
return attr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getAttributes() {
|
|
||||||
return StringUtils.join(values(), ", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getAttributeList() {
|
|
||||||
List<String> attributes = new ArrayList<>();
|
|
||||||
for (Attributes attr : values()) {
|
|
||||||
attributes.add(attr.name());
|
|
||||||
}
|
|
||||||
return attributes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,810 +0,0 @@
|
|||||||
package dev.plex.itemizerx.v1_20_R1;
|
|
||||||
|
|
||||||
import dev.plex.itemizerx.CoreProtectBridge;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.*;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.enchantments.EnchantmentWrapper;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.BookMeta;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.inventory.meta.PotionMeta;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class ItemizerXCommand implements CommandExecutor {
|
|
||||||
|
|
||||||
final List<Material> POTIONS = Arrays.asList(Material.POTION, Material.LINGERING_POTION, Material.SPLASH_POTION);
|
|
||||||
CoreProtectBridge cpb = new CoreProtectBridge();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String string, String[] args) {
|
|
||||||
if (!sender.hasPermission("itemizer.use")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
sender.sendMessage(ChatColor.AQUA + "ItemizerX " + ChatColor.GOLD + "v"
|
|
||||||
+ Bukkit.getPluginManager().getPlugin("ItemizerX").getDescription().getVersion()
|
|
||||||
+ ChatColor.AQUA + " by " + ChatColor.GOLD
|
|
||||||
+ StringUtils.join(Bukkit.getPluginManager().getPlugin("ItemizerX").getDescription().getAuthors(), ", "));
|
|
||||||
sender.sendMessage(ChatColor.AQUA + "Type " + ChatColor.GOLD + "/itemizer help "
|
|
||||||
+ ChatColor.AQUA + "for help");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(sender instanceof final Player player)) {
|
|
||||||
sender.sendMessage(colorize("&4You must be a player to execute this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ItemStack item = player.getInventory().getItemInMainHand();
|
|
||||||
final boolean hasItem = item.getType() != Material.AIR;
|
|
||||||
final boolean hasPotion = POTIONS.contains(item.getType());
|
|
||||||
final boolean hasBook = item.getType() == Material.WRITTEN_BOOK;
|
|
||||||
final ItemMeta meta = item.getItemMeta();
|
|
||||||
|
|
||||||
switch (args[0]) {
|
|
||||||
case "help" -> {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3=============&f[&dItemizerX Commands&f]&3=============
|
|
||||||
&b/itemizer name <&fname&b> &c- &6Name your item
|
|
||||||
&b/itemizer id <&fid&b> &c- &6Change the item's material
|
|
||||||
&b/itemizer lore &c- &6Lore editing command
|
|
||||||
&b/itemizer potion &c- &6Potion editing command
|
|
||||||
&b/itemizer attr &c- &6Attribute editing command
|
|
||||||
&b/itemizer flag &c- &6Flag editing command
|
|
||||||
&b/itemizer enchant &c- &6Enchant editing command
|
|
||||||
&b/itemizer title <&fname&b> &c- &6Set the book's title
|
|
||||||
&b/itemizer author <&fname&b> &c- &6Set the book's author
|
|
||||||
&b/itemizer head <&fname&b> &c- &6Set the player of the head
|
|
||||||
&b/itemizer sign <&fline&b> <&ftext&b> &c- &6Change the line on the sign
|
|
||||||
&b/itemizer clearall &c- &6Clears all metadata from your item"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "name" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.name")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dName Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer name <&fname&b> &c - &6Name your item"));
|
|
||||||
} else {
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(StringUtils.join(args, " ", 1, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
meta.setDisplayName(name);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The name of the item in your hand has been set to &f'" + name + "&f'"));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "id" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.id")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dID Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer id <&fid&b> &c- &6Change the item's material"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Material material = Material.matchMaterial(args[1].toUpperCase());
|
|
||||||
if (material == null) {
|
|
||||||
sender.sendMessage(colorize("&4The material &f\"" + args[1] + "&f\"&4 does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setType(material);
|
|
||||||
sender.sendMessage(colorize("&2The material of the item has changed to &f'" + material.name() + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "lore" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dLore Commands&f]&3===============
|
|
||||||
&b/itemizer lore add <&ftext&b> &c- &6Add a line of text to your item's lore
|
|
||||||
&b/itemizer lore remove <&findex&b> &c- &6Remove a line of text from your item's lore
|
|
||||||
&b/itemizer lore change <&findex&b> <&ftext&b> &c- &6Change a line of text in your item's lore
|
|
||||||
&b/itemizer lore clear &c- &6Clear the item's lore"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore add <&ftext&b> &c- &6Add a line of text to your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String lore = colorize(StringUtils.join(args, " ", 2, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores = new ArrayList<>();
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
}
|
|
||||||
lores.add(lore);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + lore + "&f'&2 added to the item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore remove <&findex&b> &c- &6Remove a line of text from your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer index = parseInt(sender, args[2]);
|
|
||||||
if (index == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores;
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(colorize("&eThis item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (index > lores.size()) {
|
|
||||||
sender.sendMessage(colorize("&4The item's lore doesn't have line &f'" + index + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
lores.remove(index - 1);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + index + "&f'&2 removed from the item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "change" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.change")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 4) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dLore Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer lore change <&findex&b> <&ftext&b> &c- &6Change a line of text in your item's lore"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer index = parseInt(sender, args[2]);
|
|
||||||
if (index == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String lore = colorize(StringUtils.join(args, " ", 3, args.length));
|
|
||||||
assert meta != null;
|
|
||||||
List<String> lores;
|
|
||||||
if (meta.getLore() != null) {
|
|
||||||
lores = meta.getLore();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(colorize("&eThis item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (index > lores.size()) {
|
|
||||||
sender.sendMessage(colorize("&4The item's lore doesn't have line &f'" + index + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
lores.set(index - 1, lore);
|
|
||||||
meta.setLore(lores);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + index + "'&2 has changed to &f'" + lore + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "clear" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.lore.clear")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (meta.getLore() == null || meta.getLore().isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4The item has no lores."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.setLore(null);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The item's lore has been cleared!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer lore &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "potion" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dPotion Commands&f]&3===============
|
|
||||||
&b/itemizer potion add <&feffect&b> <&flevel&b> <&ftime[tick]&b> &c- &6Add a potion effect
|
|
||||||
&b/itemizer potion remove <&feffect&b> &c- &6Remove a potion effect
|
|
||||||
&b/itemizer potion change <&fname&b> &c- &6Change the potion type
|
|
||||||
&b/itemizer potion color <&fhexcolor&b> &c- &6Set the potion color
|
|
||||||
&b/itemizer potion list &c- &6List all potion effects"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasPotion) {
|
|
||||||
sender.sendMessage("Get a POTION in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 5) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion add <&feffect&b> <&flevel&b> <&ftime[tick]&b> &c- &6Add a potion effect"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PotionEffectType potType = PotionEffectType.getByName(args[2].toUpperCase());
|
|
||||||
if (potType == null) {
|
|
||||||
sender.sendMessage(colorize("&4The potion &f\"" + args[2] + "&f\"&4 does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer level = parseInt(sender, args[3]);
|
|
||||||
Integer tick = parseInt(sender, args[4]);
|
|
||||||
if (level == null || tick == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionEffect pot = new PotionEffect(potType, tick, level);
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
if (potionMeta.hasCustomEffect(pot.getType())) {
|
|
||||||
sender.sendMessage(colorize("&4This potion already has &f" + pot.getType().getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
potionMeta.addCustomEffect(pot, false);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(pot.getType().getName() + " &2has been added to the potion"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion remove <&feffect&b> &c- &6Remove a potion effect"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
PotionEffectType potType = PotionEffectType.getByName(args[2].toUpperCase());
|
|
||||||
if (potType == null) {
|
|
||||||
sender.sendMessage("&4The potion effect &f\"" + args[2] + "&f\"&4 does not exist!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
if (!potionMeta.hasCustomEffect(potType)) {
|
|
||||||
sender.sendMessage(colorize("This potion does not have &f" + potType.getName()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
potionMeta.removeCustomEffect(potType);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(potType.getName() + " &2has been removed from the potion"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "change" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.change")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion change <&fname&b> &c- &6Change the potion type"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Material material = Material.matchMaterial(args[2]);
|
|
||||||
if (material == null || !POTIONS.contains(material)) {
|
|
||||||
sender.sendMessage(colorize(material != null ?
|
|
||||||
"&f'" + material.name() + "' &4is not a potion type!"
|
|
||||||
:
|
|
||||||
"&4That material doesn't exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setType(material);
|
|
||||||
sender.sendMessage(colorize("&2The potion in hand has changed to &f'" + material.name() + "'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "color" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.color")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 3) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dPotion Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer potion color <&fhexcolor&b> &c- &6Set a potion color"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final PotionMeta potionMeta = (PotionMeta) meta;
|
|
||||||
assert potionMeta != null;
|
|
||||||
try {
|
|
||||||
java.awt.Color awtColor = java.awt.Color.decode(args[2]);
|
|
||||||
Color color = Color.fromRGB(awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue());
|
|
||||||
potionMeta.setColor(color);
|
|
||||||
item.setItemMeta(potionMeta);
|
|
||||||
sender.sendMessage(colorize(args[2] + " &2has been set as potion color"));
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
sender.sendMessage(colorize("&4The hex &f\"" + args[2] + "&f\"&4 is invalid!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.potion.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
PotionEffectType[] effects;
|
|
||||||
for (int i = 0; i < (effects = PotionEffectType.values()).length; i++) {
|
|
||||||
sb.append(", ").append(effects[i].getName());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available potion effects: &e"
|
|
||||||
+ sb.toString().replaceFirst(", ", "")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer potion &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "attr" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dAttribute Commands&f]&3===============
|
|
||||||
&b/itemizer attr add <&fname&b> <&fstrength&b> [&fslot&b] &c - &6Add an attribute
|
|
||||||
&b/itemizer attr remove <&fname&b> &c- &6Remove an attribute
|
|
||||||
&b/itemizer attr list &c- &6List all item's attributes
|
|
||||||
&b/itemizer attr listall &c- &6List all supported attributes"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.addAttr(player, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.removeAttr(player, args[2]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
AttributeManager.listAttr(player);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.attr.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Supported attributes: "
|
|
||||||
+ "&e" + AttributeManager.Attributes.getAttributes()));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer attr &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "flag" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dFlag Commands&f]&3===============
|
|
||||||
&b/itemizer flag add <&fname&b> &c- &6Add a flag
|
|
||||||
&b/itemizer flag remove <&fname&b> &c- &6Remove a flag
|
|
||||||
&b/itemizer flag list &c- &6List all item's flag
|
|
||||||
&b/itemizer flag listall &c- &6List all available flags"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dFlag Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer flag add <&fname&b> &c- &6Add a flag"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ItemFlag flag = null;
|
|
||||||
try {
|
|
||||||
flag = ItemFlag.valueOf(args[2].toUpperCase());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
if (flag == null) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f\"" + args[2] + "&f\" does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (meta.getItemFlags().contains(flag)) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f'" + args[2].toUpperCase() + "' &4already added to the item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.addItemFlags(flag);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The flag &f'" + args[2].toUpperCase() + "' &2has been added to your item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.remove")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dFlag Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer flag remove <&fname&b> &c- &6remove a flag"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ItemFlag flag = null;
|
|
||||||
try {
|
|
||||||
flag = ItemFlag.valueOf(args[2].toUpperCase());
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
if (flag == null) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f\"" + args[2] + "&f\" does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (!meta.getItemFlags().contains(flag)) {
|
|
||||||
sender.sendMessage(colorize("&4The flag &f'" + args[2].toUpperCase() + "' &4has not been added the item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
meta.removeItemFlags(flag);
|
|
||||||
item.setItemMeta(meta);
|
|
||||||
sender.sendMessage(colorize("&2The flag &f'" + args[2].toUpperCase() + "' &2has been removed from your item!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getItemFlags()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4The item in your hand does not have any flags"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Item flags: &e"
|
|
||||||
+ StringUtils.join(meta.getItemFlags(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.flag.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available item flags: &e"
|
|
||||||
+ StringUtils.join(ItemFlag.values(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer flag &bfor help"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "enchant" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("""
|
|
||||||
&3===============&f[&dEnchant Commands&f]&3===============
|
|
||||||
&b/itemizer enchant add <&fname&b> <&flevel&b> &c- &6Add an enchant
|
|
||||||
&b/itemizer enchant remove <&fname&b> &c- &6Remove an enchant
|
|
||||||
&b/itemizer enchant list &c- &6List all item's enchants
|
|
||||||
&b/itemizer enchant listall &c- &6List all available enchants"""));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.add")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 4) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dEnchant Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer enchant add <&fname&b> <&flevel&b> &c- &6Add an enchant"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Enchantment ench = EnchantmentWrapper.getByKey(NamespacedKey.minecraft(args[2].toLowerCase()));
|
|
||||||
if (ench == null) {
|
|
||||||
sender.sendMessage(colorize("&4The enchantment &f'" + args[2] + "&f' &4does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer level = parseInt(sender, args[3]);
|
|
||||||
if (level == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.addUnsafeEnchantment(ench, level);
|
|
||||||
sender.sendMessage(colorize("&2The enchant &f'" + ench.getKey().getKey() + "' &2has been added to your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "remove" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.remove")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dEnchant Commands&f]&3===============\n"
|
|
||||||
+ "&b/itemizer enchant remove <&fname&b> &c- &6Remove an enchant"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Enchantment ench = EnchantmentWrapper.getByKey(NamespacedKey.minecraft(args[2].toLowerCase()));
|
|
||||||
if (ench == null) {
|
|
||||||
sender.sendMessage(colorize("&4The enchantment &f'" + args[2] + "&f' &4does not exist!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getEnchants()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't hold any enchants"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!meta.getEnchants().containsKey(ench)) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't have &f'" + ench.getKey().getKey() + "' &4enchant!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.removeEnchantment(ench);
|
|
||||||
sender.sendMessage(colorize("&2The enchant &f'" + ench.getKey().getKey() + "' &2has been removed from your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "list" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.list")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
assert meta != null;
|
|
||||||
if (Objects.requireNonNull(meta.getEnchants()).isEmpty()) {
|
|
||||||
sender.sendMessage(colorize("&4This item doesn't hold any enchants"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Item enchants: &e"
|
|
||||||
+ StringUtils.join(meta.getEnchants().keySet(), ", ")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "listall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.enchant.listall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
Enchantment[] enchantments;
|
|
||||||
for (int i = 0; i < (enchantments = Enchantment.values()).length; i++) {
|
|
||||||
sb.append(", ").append(enchantments[i].getKey().getKey());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Available item enchants: &e"
|
|
||||||
+ sb.toString().replaceFirst(", ", "")));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer enchant &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "title" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.title")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dTitle Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer title <&fname&b> &c- &6Set the book's title"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasBook) {
|
|
||||||
sender.sendMessage("Get a WRITTEN_BOOK in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(StringUtils.join(args, " ", 1, args.length));
|
|
||||||
final BookMeta bookMeta = (BookMeta) meta;
|
|
||||||
assert bookMeta != null;
|
|
||||||
bookMeta.setTitle(name);
|
|
||||||
item.setItemMeta(bookMeta);
|
|
||||||
sender.sendMessage(colorize("&2The title of the book has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "author" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.author")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dAuthor Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer author <&fname&b> &c- &6Set the book's title"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasBook) {
|
|
||||||
sender.sendMessage("Get a WRITTEN_BOOK in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = colorize(args[1]);
|
|
||||||
final BookMeta bookMeta = (BookMeta) meta;
|
|
||||||
assert bookMeta != null;
|
|
||||||
bookMeta.setAuthor(name);
|
|
||||||
item.setItemMeta(bookMeta);
|
|
||||||
sender.sendMessage(colorize("&2The author of the book has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "head" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.head")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length == 1) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dHead Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer head <&fname&b> &c- &6Set the player of the head"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (item.getType() != Material.PLAYER_HEAD) {
|
|
||||||
sender.sendMessage("Get a SKULL in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String name = args[1];
|
|
||||||
if (name.length() > 16) {
|
|
||||||
name = name.substring(0, 16);
|
|
||||||
}
|
|
||||||
final SkullMeta skullMeta = (SkullMeta) meta;
|
|
||||||
assert skullMeta != null;
|
|
||||||
skullMeta.setOwner(name);
|
|
||||||
item.setItemMeta(skullMeta);
|
|
||||||
sender.sendMessage(colorize("&2The player of the head has been set to &f'" + name + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "sign" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.sign")) {
|
|
||||||
sender.sendMessage("&4You don't have permission to use this command!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 3) {
|
|
||||||
sender.sendMessage(colorize("&3===============&f[&dSign Command&f]&3===============\n"
|
|
||||||
+ "&b/itemizer sign <&fline&b> <&ftext&b> &c- &6Change the line on the sign"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
final Block block = player.getTargetBlockExact(20);
|
|
||||||
if (block == null || block.getType() == Material.AIR
|
|
||||||
|| !block.getType().toString().contains("SIGN")) {
|
|
||||||
sender.sendMessage(colorize("&4Please look at a sign!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Integer line = parseInt(sender, args[1]);
|
|
||||||
if (line == null) {
|
|
||||||
return true;
|
|
||||||
} else if (line > 4) {
|
|
||||||
sender.sendMessage(colorize("&4There's maximum of 4 lines on a sign"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String text = colorize(StringUtils.join(args, " ", 2, args.length));
|
|
||||||
if (cpb.getAPI() != null) {
|
|
||||||
cpb.getAPI().logRemoval(player.getName(), block.getLocation(), block.getType(), block.getBlockData());
|
|
||||||
}
|
|
||||||
Sign sign = (Sign) block.getState();
|
|
||||||
sign.setLine(line - 1, text);
|
|
||||||
sign.update();
|
|
||||||
if (cpb.getAPI() != null) {
|
|
||||||
cpb.getAPI().logPlacement(player.getName(), sign.getLocation(), sign.getType(), sign.getBlockData());
|
|
||||||
}
|
|
||||||
sender.sendMessage(colorize("&2Line &f'" + line + "'&2 has successfully changed to &f'" + text + "&f'"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "clearall" -> {
|
|
||||||
if (!sender.hasPermission("itemizer.clearall")) {
|
|
||||||
sender.sendMessage(colorize("&4You don't have permission to use this command!"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!hasItem) {
|
|
||||||
sender.sendMessage("Get an ITEM in hand!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
item.setItemMeta(null);
|
|
||||||
sender.sendMessage(colorize("&2All data cleared from your item"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default -> {
|
|
||||||
sender.sendMessage(colorize("&bUnknown sub-command. Type &6/itemizer help &bfor help."));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String colorize(String string) {
|
|
||||||
Matcher matcher = Pattern.compile("&#[a-fA-F0-9]{6}").matcher(string);
|
|
||||||
while (matcher.find()) {
|
|
||||||
String code = matcher.group().replace("&", "");
|
|
||||||
string = string.replace("&" + code, net.md_5.bungee.api.ChatColor.of(code) + "");
|
|
||||||
}
|
|
||||||
string = ChatColor.translateAlternateColorCodes('&', string);
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer parseInt(CommandSender sender, String string) {
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(string);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
sender.sendMessage(colorize("&f\"" + string + "&f\"&4 is not a valid number!"));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,105 +0,0 @@
|
|||||||
package dev.plex.itemizerx.v1_20_R1;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemizerXTab implements TabCompleter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String string, String[] args) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
return Arrays.asList("help", "id", "lore", "potion", "attr", "flag", "enchant", "title", "author",
|
|
||||||
"head", "sign", "clearall");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 2) {
|
|
||||||
switch (args[0]) {
|
|
||||||
case "id": {
|
|
||||||
List<String> materials = new ArrayList<>();
|
|
||||||
for (Material material : Material.values()) {
|
|
||||||
materials.add(material.name());
|
|
||||||
}
|
|
||||||
return materials;
|
|
||||||
}
|
|
||||||
case "lore": {
|
|
||||||
return Arrays.asList("add", "remove", "change", "clear");
|
|
||||||
}
|
|
||||||
case "potion": {
|
|
||||||
return Arrays.asList("add", "remove", "change", "color", "list");
|
|
||||||
}
|
|
||||||
case "attr":
|
|
||||||
case "flag":
|
|
||||||
case "enchant": {
|
|
||||||
return Arrays.asList("add", "remove", "list", "listall");
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 3) {
|
|
||||||
switch (args[0]) {
|
|
||||||
case "potion": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> potions = new ArrayList<>();
|
|
||||||
for (PotionEffectType effect : PotionEffectType.values()) {
|
|
||||||
potions.add(effect.getName());
|
|
||||||
}
|
|
||||||
return potions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "attr": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
return AttributeManager.Attributes.getAttributeList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "flag": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> flags = new ArrayList<>();
|
|
||||||
for (ItemFlag flag : ItemFlag.values()) {
|
|
||||||
flags.add(flag.name());
|
|
||||||
}
|
|
||||||
return flags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "enchant": {
|
|
||||||
switch (args[1]) {
|
|
||||||
case "add":
|
|
||||||
case "remove": {
|
|
||||||
List<String> enchantments = new ArrayList<>();
|
|
||||||
for (Enchantment enchantment : Enchantment.values()) {
|
|
||||||
enchantments.add(enchantment.getKey().getKey());
|
|
||||||
}
|
|
||||||
return enchantments;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user