mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-10-31 23:59:36 +01:00
New command 'nbttools' also integrating ACF
This commit is contained in:
parent
ab0fc06dc2
commit
24ba3b1a01
@ -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 {
|
||||
|
@ -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")
|
||||
|
@ -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;
|
||||
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user