diff --git a/build.gradle.kts b/build.gradle.kts index 325e37558..f84c06abb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,6 +11,8 @@ subprojects { maven("https://repo.codemc.org/repository/maven-public") maven("https://maven.sk89q.com/repo") maven("https://mvnrepository.com/artifact/org.jetbrains/annotations") + maven("https://repo.aikar.co/content/groups/aikar/") + maven("https://hub.spigotmc.org/nexus/content/groups/public/") } tasks { diff --git a/mcmmo-core/build.gradle.kts b/mcmmo-core/build.gradle.kts index c98b656cf..d7743b180 100644 --- a/mcmmo-core/build.gradle.kts +++ b/mcmmo-core/build.gradle.kts @@ -20,12 +20,14 @@ tasks { include(dependency("org.apache.tomcat:tomcat-jdbc")) include(dependency("org.apache.tomcat:tomcat-juli")) include(dependency("com.typesafe:config")) + include(dependency("co.aikar:acf-bukkit")) exclude(dependency("org.spigotmc:spigot")) } relocate("org.apache.commons.logging", "com.gmail.nossr50.commons.logging") relocate("org.apache.juli", "com.gmail.nossr50.database.tomcat.juli") relocate("org.apache.tomcat", "com.gmail.nossr50.database.tomcat") relocate("org.bstats", "com.gmail.nossr50.metrics.bstat") + relocate("co.aikar.commands", "com.gmail.nossr50.acf") } processResources { @@ -43,6 +45,7 @@ dependencies { api("org.spongepowered:configurate-core:3.7-SNAPSHOT") api("org.spongepowered:configurate-yaml:3.7-SNAPSHOT") api("org.spongepowered:configurate-hocon:3.7-SNAPSHOT") + api("co.aikar:acf-bukkit:0.5.0-SNAPSHOT") implementation("org.jetbrains:annotations:17.0.0") implementation("org.apache.maven.scm:maven-scm-provider-gitexe:1.8.1") implementation("org.bstats:bstats-bukkit:1.4") diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/admin/NBTToolsCommand.java b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/admin/NBTToolsCommand.java new file mode 100644 index 000000000..82a63daab --- /dev/null +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/admin/NBTToolsCommand.java @@ -0,0 +1,15 @@ +package com.gmail.nossr50.commands.admin; + +import co.aikar.commands.BaseCommand; +import co.aikar.commands.annotation.Dependency; +import co.aikar.commands.annotation.Description; +import com.gmail.nossr50.mcMMO; + +@Description("Read or Modify values of NBT on an item in-hand") +public class NBTToolsCommand extends BaseCommand { + + @Dependency + private mcMMO pluginRef; + + +} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebug.java b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebug.java deleted file mode 100644 index 7e6849d71..000000000 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebug.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.gmail.nossr50.commands.admin; - -import com.gmail.nossr50.mcMMO; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -public class PlayerDebug implements CommandExecutor { - - private final mcMMO pluginRef; - - public PlayerDebug(mcMMO pluginRef) { - this.pluginRef = pluginRef; - } - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - return false; - } -} diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebugCommand.java b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebugCommand.java index b48e76939..a0f885c37 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebugCommand.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/commands/admin/PlayerDebugCommand.java @@ -1,29 +1,28 @@ package com.gmail.nossr50.commands.admin; +import co.aikar.commands.BaseCommand; +import co.aikar.commands.annotation.Dependency; +import co.aikar.commands.annotation.Description; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.mcMMO; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -public class PlayerDebugCommand implements CommandExecutor { - private final mcMMO pluginRef; +@Description("Puts the player into debug mode, which helps problem solve bugs in mcMMO.") +public class PlayerDebugCommand extends BaseCommand { - public PlayerDebugCommand(mcMMO pluginRef) { - this.pluginRef = pluginRef; - } + @Dependency + private mcMMO pluginRef; - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + public void onCommand(CommandSender sender) { if(sender instanceof Player) { McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer((Player) sender); mcMMOPlayer.toggleDebugMode(); //Toggle debug mode pluginRef.getNotificationManager().sendPlayerInformationChatOnlyPrefixed(mcMMOPlayer.getPlayer(), "Commands.Mmodebug.Toggle", String.valueOf(mcMMOPlayer.isDebugMode())); - return true; } else { - return false; + //TODO: Localize + sender.sendMessage("Players only"); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/config/skills/ranks/SkillRankProperty.java b/mcmmo-core/src/main/java/com/gmail/nossr50/config/skills/ranks/SkillRankProperty.java index 96220ee83..1b7ac8398 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/config/skills/ranks/SkillRankProperty.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/config/skills/ranks/SkillRankProperty.java @@ -3,7 +3,6 @@ package com.gmail.nossr50.config.skills.ranks; import com.gmail.nossr50.api.exceptions.MissingSkillPropertyDefinition; import com.gmail.nossr50.datatypes.skills.properties.SkillProperty; import com.gmail.nossr50.mcMMO; -import org.apache.logging.log4j.Level; import java.util.HashMap; diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/core/adapters/NMS_114/BukkitNBTAdapter.java b/mcmmo-core/src/main/java/com/gmail/nossr50/core/adapters/NMS_114/BukkitNBTAdapter.java index 8930c66ed..431c5a9ea 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/core/adapters/NMS_114/BukkitNBTAdapter.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/core/adapters/NMS_114/BukkitNBTAdapter.java @@ -32,7 +32,7 @@ public class BukkitNBTAdapter implements NBTAdapter { case LIST: return asNativeNBTList((NBTList) nbtBase); case COMPOUND: - return ; + return asNativeNBTCompound((NBTCompound) nbtBase); case INT_ARRAY: return asNativeNBTIntArray((NBTIntArray) nbtBase); case LONG_ARRAY: @@ -130,9 +130,12 @@ public class BukkitNBTAdapter implements NBTAdapter { * @param nbtCompound target NBTCompound * @return NBTTagCompound copy of our NBTCompound representation */ + //TODO: Finish private NBTTagCompound asNativeNBTCompound(NBTCompound nbtCompound) { + System.out.println("FINISH asNativeNBTCompound()"); NBTTagCompound nbtTagCompound = new NBTTagCompound(); - nbtCompound + + return nbtTagCompound; } /** diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTByteArray.java b/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTByteArray.java index 31a733a73..bd6fdaa27 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTByteArray.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTByteArray.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.core.nbt; -import org.checkerframework.checker.nullness.qual.NonNull; - import java.util.Arrays; public class NBTByteArray implements NBTBase { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTIntArray.java b/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTIntArray.java index d49d74412..05e0bf518 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTIntArray.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/core/nbt/NBTIntArray.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.core.nbt; -import org.checkerframework.checker.nullness.qual.NonNull; - import java.util.Arrays; public class NBTIntArray implements NBTBase { diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java index 8fc2f31a7..75068f146 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/commands/CommandRegistrationManager.java @@ -1,6 +1,8 @@ package com.gmail.nossr50.util.commands; +import co.aikar.commands.BukkitCommandManager; import com.gmail.nossr50.commands.*; +import com.gmail.nossr50.commands.admin.NBTToolsCommand; import com.gmail.nossr50.commands.admin.PlayerDebugCommand; import com.gmail.nossr50.commands.admin.ReloadLocaleCommand; import com.gmail.nossr50.commands.chat.AdminChatCommand; @@ -30,10 +32,12 @@ import java.util.Locale; public final class CommandRegistrationManager { private final mcMMO pluginRef; private String permissionsMessage; + private BukkitCommandManager bukkitCommandManager; public CommandRegistrationManager(mcMMO pluginRef) { this.pluginRef = pluginRef; permissionsMessage = pluginRef.getLocaleManager().getString("mcMMO.NoPermission"); + bukkitCommandManager = new BukkitCommandManager(pluginRef); } private void registerSkillCommands() { @@ -117,6 +121,40 @@ public final class CommandRegistrationManager { } } + /** + * Initialize ACF commands + */ + private void initACF() { + //TODO: See if needed + bukkitCommandManager.enableUnstableAPI("help"); + + + registerACFCommands(); + } + + /** + * Register ACF Commands + */ + private void registerACFCommands() { + //Register ACF Commands + registerNBTToolsCommand(); + registerMmoDebugCommand(); + } + + /** + * Register the NBT Tools command + */ + private void registerNBTToolsCommand() { + bukkitCommandManager.registerCommand(new NBTToolsCommand()); + } + + /** + * Register the MMO Debug command + */ + private void registerMmoDebugCommand() { + bukkitCommandManager.registerCommand(new PlayerDebugCommand()); + } + private void registerAddlevelsCommand() { PluginCommand command = pluginRef.getCommand("addlevels"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.addlevels")); @@ -153,16 +191,6 @@ public final class CommandRegistrationManager { command.setExecutor(new MmoInfoCommand(pluginRef)); } - - private void registerMmoDebugCommand() { - PluginCommand command = pluginRef.getCommand("mmodebug"); - command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mmodebug")); - command.setPermission(null); //No perm required to save support headaches - command.setPermissionMessage(permissionsMessage); - command.setUsage(pluginRef.getLocaleManager().getString("Commands.Usage.0", "mmodebug")); - command.setExecutor(new PlayerDebugCommand(pluginRef)); - } - private void registerMcChatSpyCommand() { PluginCommand command = pluginRef.getCommand("mcchatspy"); command.setDescription(pluginRef.getLocaleManager().getString("Commands.Description.mcchatspy")); @@ -476,5 +504,8 @@ public final class CommandRegistrationManager { registerMcmmoReloadCommand(); // Admin commands registerReloadLocaleCommand(); + + //ACF Commands + initACF(); } } diff --git a/mcmmo-core/src/main/java/com/gmail/nossr50/util/nbt/NBTFactory.java b/mcmmo-core/src/main/java/com/gmail/nossr50/util/nbt/NBTFactory.java index 35529853f..022e5288b 100644 --- a/mcmmo-core/src/main/java/com/gmail/nossr50/util/nbt/NBTFactory.java +++ b/mcmmo-core/src/main/java/com/gmail/nossr50/util/nbt/NBTFactory.java @@ -5,28 +5,30 @@ import com.gmail.nossr50.core.nbt.NBTCompound; import net.minecraft.server.v1_14_R1.NBTTagByte; public class NBTFactory { + //TODO: Finish /** * Converts NMS NBT types into our own NBT type representation * @param nmsNBT target NMS Compound * @return NMS Representation of our NBT */ - public NBTCompound asNBT(net.minecraft.server.v1_14_R1.NBTTagCompound nmsNBT) { - NBTCompound nbtCompound = new NBTCompound(""); +// public NBTCompound asNBT(net.minecraft.server.v1_14_R1.NBTTagCompound nmsNBT) { +// NBTCompound nbtCompound = new NBTCompound(""); +// +// //Traverse the NMS Map +// for(String key : nmsNBT.getKeys()) { +// +// } +// } - //Traverse the NMS Map - for(String key : nmsNBT.getKeys()) { - - } - } - - /** - * Convert our NBT type into the NMS NBT Type equivalent - * @param nbtCompound target nbt compound - * @return NMS NBT copy of our NBT type - */ - public net.minecraft.server.v1_14_R1.NBTTagCompound asNMSCopy(NBTCompound nbtCompound) { - - } + //TODO: Finish +// /** +// * Convert our NBT type into the NMS NBT Type equivalent +// * @param nbtCompound target nbt compound +// * @return NMS NBT copy of our NBT type +// */ +// public net.minecraft.server.v1_14_R1.NBTTagCompound asNMSCopy(NBTCompound nbtCompound) { +// +// } /** * Create a new NMS NBT tag compound with only 1 tag compound named "tag" @@ -40,12 +42,13 @@ public class NBTFactory { return nbtTagCompound; } - private NBTCompound deepCopy(NBTCompound target, String key, net.minecraft.server.v1_14_R1.NBTBase nbtBase) { - switch (nbtBase.getTypeId()) { - case 0: - return new NBTCompound(); - } - } + //TODO: Finish +// private NBTCompound deepCopy(NBTCompound target, String key, net.minecraft.server.v1_14_R1.NBTBase nbtBase) { +// switch (nbtBase.getTypeId()) { +// case 0: +// return new NBTCompound(); +// } +// } /** * Create a NBTByte representation of NBTTagByte (NMS Type) diff --git a/mcmmo-core/src/main/resources/plugin.yml b/mcmmo-core/src/main/resources/plugin.yml index f24b8540f..2e371b8ca 100644 --- a/mcmmo-core/src/main/resources/plugin.yml +++ b/mcmmo-core/src/main/resources/plugin.yml @@ -19,6 +19,9 @@ load: POSTWORLD api-version: 1.13 commands: + nbttools: + description: Modify or Read NBT from an item in hand + permission: mcmmo.commands.nbttools mmodebug: aliases: [mcmmodebugmode] description: Toggles a debug mode which will print useful information to chat @@ -628,6 +631,10 @@ permissions: children: mcmmo.commands.mcconvert.all: true mcmmo.commands.xprate.all: true + mcmmo.commands.nbttools: true + mcmmo.commands.nbttools: + default: false + description: Modify or Read NBT of an item in-hand mcmmo.bypass.*: default: false description: Implies all bypass permissions.