-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding #360 * provide ExecutionInfo with a record * fixing JavaDocs * fixing some things * adding a CommandArguments class to hold provided arguments * remove method parameters, fix documentation code to match new syntax * fix Kotlin DSL to match new syntax * fixing Converter * fix some more documentation issues * fixing some annotation examples to match new syntax * fix annotation generation to match new syntax * handle String[] for converted commands correctly * parse arguments only once * Make argsToObjectArr return a CommandArguments object. Change name of argsToObjectArr to argsToCommandArgs * fixing generateCommand method * fix Brigadier#parseArguments method * add Javadocs to ExecutionInfo * Remove test command thingy from CommandAPIMain. Add Javadocs to CommandArguments * clean up after merge * fixing a method call in Brigadier#parseArguments * fixing CommandTree DSL * optimizing some imports * fixing some formatting issues * fixing documentation example code * fix commands not being executable * fixing build error
- Loading branch information
1 parent
6c715cb
commit 340902c
Showing
47 changed files
with
1,260 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
commandapi-core/src/main/java/dev/jorel/commandapi/executors/AbstractExecutionInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package dev.jorel.commandapi.executors; | ||
|
||
import dev.jorel.commandapi.commandsenders.AbstractCommandSender; | ||
|
||
/** | ||
* This interface represents an AbstractExecutionInfo for a command. It provides the sender of a command, as well as it's arguments | ||
* | ||
* @param <Sender> The type of the sender of a command this AbstractExecutionInfo belongs to | ||
*/ | ||
public interface AbstractExecutionInfo<Sender, WrapperType extends AbstractCommandSender<? extends Sender>> { | ||
|
||
/** | ||
* @return The sender of this command | ||
*/ | ||
Sender sender(); | ||
|
||
/** | ||
* @return The wrapper type of this command | ||
*/ | ||
WrapperType senderWrapper(); | ||
|
||
/** | ||
* @return The arguments of this command | ||
*/ | ||
CommandArguments args(); | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
commandapi-core/src/main/java/dev/jorel/commandapi/executors/CommandArguments.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package dev.jorel.commandapi.executors; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* This class stores the arguments for this command | ||
*/ | ||
public class CommandArguments { | ||
|
||
private final Object[] args; | ||
private final Map<String, Object> argsMap; | ||
|
||
/** | ||
* Constructs a new CommandArguments instance | ||
* | ||
* @param args The arguments for this command | ||
* @param argsMap The arguments for this command mapped to the node names. This is an ordered map | ||
*/ | ||
public CommandArguments(Object[] args, Map<String, Object> argsMap) { | ||
this.args = args; | ||
this.argsMap = argsMap; | ||
} | ||
|
||
/** | ||
* @return The complete argument array of this command | ||
*/ | ||
public Object[] args() { | ||
return args; | ||
} | ||
|
||
/** | ||
* Returns an argument by its position | ||
* | ||
* @param index The position of this argument | ||
* @return an argument which is placed at the given index | ||
*/ | ||
public Object get(int index) { | ||
return args[index]; | ||
} | ||
|
||
/** | ||
* Returns an argument by its node name | ||
* | ||
* @param nodeName The node name of this argument. This was set when initializing an argument | ||
* @return an argument which has the given node name | ||
*/ | ||
public Object get(String nodeName) { | ||
return argsMap.get(nodeName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.