mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 22:26:46 +01:00
More work on ACF integration
This commit is contained in:
parent
2d342f8a3d
commit
f45c70b694
@ -63,7 +63,7 @@ dependencies {
|
||||
api("org.spongepowered:configurate-yaml:3.7-SNAPSHOT")
|
||||
api("org.spongepowered:configurate-hocon:3.7-SNAPSHOT")
|
||||
api("co.aikar:acf-core:0.5.0-SNAPSHOT") //Don't change without updating the artifacts for its dependencies (see the other comments)
|
||||
api("co.aikar:acf-bukkit:0.5.0-SNAPSHOT") //Don't change without updating the artifacts for its dependencies (see the other comments)
|
||||
api("co.aikar:acf-paper:0.5.0-SNAPSHOT") //Don't change without updating the artifacts for its dependencies (see the other comments)
|
||||
// api("co.aikar:locales:1.0-SNAPSHOT") //ACF 0.5.0-SNAPSHOT is dependent on this version of locales
|
||||
// api("co.aikar:table:1.0.0-SNAPSHOT") //ACF 0.5.0-SNAPSHOT is dependent on this version of table
|
||||
// api("net.jodah:expiring-map:0.5.8") //ACF 0.5.0-SNAPSHOT is dependent on this version of expiring map
|
||||
|
@ -1,15 +1,22 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.Default;
|
||||
import co.aikar.commands.annotation.Dependency;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandAlias("nbttools")
|
||||
@Description("Read or Modify values of NBT on an item in-hand")
|
||||
public class NBTToolsCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private mcMMO pluginRef;
|
||||
|
||||
|
||||
@Default
|
||||
public void onCommand(Player player) {
|
||||
player.sendMessage("hi");
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.commands.admin;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.Default;
|
||||
import co.aikar.commands.annotation.Dependency;
|
||||
import co.aikar.commands.annotation.Description;
|
||||
@ -10,18 +11,19 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@CommandAlias("mmodebug")
|
||||
@Description("Puts the player into debug mode, which helps problem solve bugs in mcMMO.")
|
||||
public class PlayerDebugCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private mcMMO pluginRef;
|
||||
private mcMMO plugin;
|
||||
|
||||
@Default
|
||||
public void onCommand(CommandSender sender) {
|
||||
if(sender instanceof Player) {
|
||||
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer((Player) sender);
|
||||
McMMOPlayer mcMMOPlayer = plugin.getUserManager().getPlayer((Player) sender);
|
||||
mcMMOPlayer.toggleDebugMode(); //Toggle debug mode
|
||||
pluginRef.getNotificationManager().sendPlayerInformationChatOnlyPrefixed(mcMMOPlayer.getPlayer(), "Commands.Mmodebug.Toggle", String.valueOf(mcMMOPlayer.isDebugMode()));
|
||||
plugin.getNotificationManager().sendPlayerInformationChatOnlyPrefixed(mcMMOPlayer.getPlayer(), "Commands.Mmodebug.Toggle", String.valueOf(mcMMOPlayer.isDebugMode()));
|
||||
} else {
|
||||
//TODO: Localize
|
||||
sender.sendMessage("Players only");
|
||||
|
@ -218,6 +218,7 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
scheduleTasks();
|
||||
commandRegistrationManager = new CommandRegistrationManager(this);
|
||||
commandRegistrationManager.registerACFCommands();
|
||||
commandRegistrationManager.registerCommands();
|
||||
|
||||
nbtManager = new NBTManager();
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.gmail.nossr50.util.commands;
|
||||
|
||||
import co.aikar.commands.BukkitCommandManager;
|
||||
import co.aikar.commands.PaperCommandManager;
|
||||
import com.gmail.nossr50.commands.*;
|
||||
import com.gmail.nossr50.commands.admin.NBTToolsCommand;
|
||||
import com.gmail.nossr50.commands.admin.PlayerDebugCommand;
|
||||
@ -29,15 +29,70 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
//TODO: Properly rewrite ACF integration later
|
||||
public final class CommandRegistrationManager {
|
||||
private final mcMMO pluginRef;
|
||||
private String permissionsMessage;
|
||||
private BukkitCommandManager bukkitCommandManager;
|
||||
//NOTE: Does not actually require paper, will work for bukkit
|
||||
private PaperCommandManager commandManager;
|
||||
|
||||
public CommandRegistrationManager(mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
permissionsMessage = pluginRef.getLocaleManager().getString("mcMMO.NoPermission");
|
||||
bukkitCommandManager = new BukkitCommandManager(pluginRef);
|
||||
commandManager = new PaperCommandManager(pluginRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register ACF Commands
|
||||
*/
|
||||
//TODO: Properly rewrite ACF integration later
|
||||
public void registerACFCommands() {
|
||||
//Register ACF Commands
|
||||
registerNBTToolsCommand();
|
||||
registerMmoDebugCommand();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register exception handlers for the ACF commands
|
||||
*/
|
||||
//TODO: Properly rewrite ACF integration later
|
||||
private void registerExceptionHandlers() {
|
||||
registerDefaultExceptionHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register default exception handler
|
||||
*/
|
||||
//TODO: Properly rewrite ACF integration later
|
||||
private void registerDefaultExceptionHandler() {
|
||||
commandManager.setDefaultExceptionHandler((command, registeredCommand, sender, args, t) -> {
|
||||
pluginRef.getLogger().warning("Error occurred while executing command " + command.getName());
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register contexts for ACF
|
||||
*/
|
||||
//TODO: Properly rewrite ACF integration later
|
||||
private void registerContexts() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the NBT Tools command
|
||||
*/
|
||||
//TODO: Properly rewrite ACF integration later
|
||||
private void registerNBTToolsCommand() {
|
||||
commandManager.registerCommand(new NBTToolsCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the MMO Debug command
|
||||
*/
|
||||
//TODO: Properly rewrite ACF integration later
|
||||
private void registerMmoDebugCommand() {
|
||||
commandManager.registerCommand(new PlayerDebugCommand());
|
||||
}
|
||||
|
||||
private void registerSkillCommands() {
|
||||
@ -121,40 +176,6 @@ 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"));
|
||||
@ -455,7 +476,6 @@ public final class CommandRegistrationManager {
|
||||
public void registerCommands() {
|
||||
// Generic Commands
|
||||
registerMmoInfoCommand();
|
||||
registerMmoDebugCommand();
|
||||
registerMcabilityCommand();
|
||||
registerMcgodCommand();
|
||||
registerMcChatSpyCommand();
|
||||
@ -504,8 +524,5 @@ public final class CommandRegistrationManager {
|
||||
registerMcmmoReloadCommand();
|
||||
// Admin commands
|
||||
registerReloadLocaleCommand();
|
||||
|
||||
//ACF Commands
|
||||
initACF();
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,6 @@ 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
|
||||
mmoinfo:
|
||||
aliases: [mcinfo]
|
||||
description: Info pages for mcMMO
|
||||
|
Loading…
Reference in New Issue
Block a user