Giter Club home page Giter Club logo

mcommands's Introduction

mCommands

CodeFactor mCommands logo

An advanced general purpose command dispatching framework designed using OOP concepts.The library is user-friendly and provides high performance along with a high quality of production code.

This library utilizes Kyori Adventure for messages and text styles

so in the installation you must include the dependencies of Kyori in your project's dependencies control tool file here's an example using build.gradle:

dependencies {
    compileOnly "net.kyori:adventure-api:4.13.1"
    compileOnly "net.kyori:adventure-platform-bukkit:4.3.0"
}

Installation

mCommands has its own repo in maven central so all you have to do is like this:

repositories {
    mavenCentral()
}

dependencies {
    implementation 'io.github.mqzn:mCommands-<platform>:<LATEST_VERSION>'
}

Platforms

Common

The main platform that contain the core of the library

implementation 'io.github.mqzn:mCommands-common:<LATEST_VERSION>'

Spigot

The spigot platform is for minecraft spigot api development

implementation 'io.github.mqzn:mCommands-spigot:<LATEST_VERSION>'

Bungee

This bungeecord platform is for minecraft bungeecord proxy api development, allows you to declare and register bungeecord commands.

implementation 'io.github.mqzn:mCommands-bungee:<LATEST_VERSION>'

Wiki

If you want to learn how to fully utilize the amazing potential of this library. you must read the wiki pages starting from here You will also need the wiki in order to make something cool like the example below:

Code Example

Here's a quick example on how to create a command using mCommands.

public final class SpigotPluginTest extends JavaPlugin {
	
	private SpigotCommandManager commandManager;
	
	@Override
	public void onEnable() {
		var cmd = Command.builder(commandManager, "test")
			.info(new CommandInfo("test.perm", "Test cmd", "testis"))
			.requirement(SpigotCommandRequirement.ONLY_PLAYER_EXECUTABLE)
			.cooldown(new CommandCooldown(5, TimeUnit.MINUTES))
			.executionMeta(
				SpigotCommandSyntaxBuilder.builder(commandManager, "test")
					.argument(Argument.literal("testsub"))
					.execute((sender, context) -> sender.sendMessage("Test sub works !"))
					.build()
			)
			.defaultExecutor((s, context) -> s.sendMessage("OMG NO ARGS !"))
			.build();
		
		commandManager.register(cmd);
	}

}

mcommands's People

Contributors

mqzn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mcommands's Issues

@CommandsGroup

An annotation that helps the parser to parse several nested classes recursively within a class
that class doesn't have to be annotated with @command

SubCommands return an Execution Error with a greedy argument

Creating a greedy argument using a regular command

@Command(name = "test")
public class Testcmd {
    @Default
    @ExecutionMeta(syntax = "<str>")
    public void defaultExecution(@NotNull CommandSender sender, @Arg(id = "str") @Greedy String str) {
        sender.sendMessage("test -> " + str);
    }
}

works as intended.
(using /test hello im a greedy string)

Creating a greedy argument in a sub command

Parent class

@Command(name = "parent")
@SubCommand(ChildCmd.class)
public class ParentCmd {
    @Default
    public void defaultExecution(@NotNull CommandSender sender) {
        sender.sendMessage("hi this is the parent");
    }
}

Sub command class

@ExecutionMeta(syntax = "<str>")
@SubCommandInfo(name = "greedy")
public class ChildCmd {
    @SubCommandExecution
    public void execute(@NotNull CommandSender sender, @Arg(id = "str") @Greedy String str) {
        sender.sendMessage("child -> " + str);
    }
}

The sub command produces an error when executing /parent greedy hello im a greedy string

image

Potentially Useful Info

  • Version: 1.1.2
  • Spigot Module
  • MC 1.20.1

Cheers!
~ Foxikle

Command-SubCommand tree structure

  • A command in one class, and a sub command in another, and a sub, of a sub command in another class.

Reason: 1 class where I have a command, can get really cluttered if I have a command that is really bulked out with a plethora of sub
commands and sub sub commands

on top of being annotated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.