@ -42,6 +42,11 @@ public abstract class Command implements ICommandExecutor
* /
* /
private DefaultPermission defaultPermission ;
private DefaultPermission defaultPermission ;
/ * *
* Tells where the command should run , ie . PM or guild chat , or both
* /
private CommandScope commandScope ;
/ * *
/ * *
* Basic constructor .
* Basic constructor .
* @param name Name of the command
* @param name Name of the command
@ -50,8 +55,9 @@ public abstract class Command implements ICommandExecutor
* @param isEnabled Is the command enabled ?
* @param isEnabled Is the command enabled ?
* @param usage Command usage help
* @param usage Command usage help
* @param defaultPermission Default permission , ie . when the permissions provider doesn ' t return anything .
* @param defaultPermission Default permission , ie . when the permissions provider doesn ' t return anything .
* @param commandScope Tells where the command should run , ie . PM or guild chat , or both
* /
* /
public Command ( String name , List < String > aliases , String description , boolean isEnabled , String usage , DefaultPermission defaultPermission )
public Command ( String name , List < String > aliases , String description , boolean isEnabled , String usage , DefaultPermission defaultPermission , CommandScope commandScope )
{
{
this . name = name ;
this . name = name ;
this . aliases = aliases ;
this . aliases = aliases ;
@ -59,6 +65,7 @@ public abstract class Command implements ICommandExecutor
this . isEnabled = isEnabled ;
this . isEnabled = isEnabled ;
this . usage = usage ;
this . usage = usage ;
this . defaultPermission = defaultPermission ;
this . defaultPermission = defaultPermission ;
this . commandScope = commandScope ;
}
}
/ * *
/ * *
@ -71,6 +78,7 @@ public abstract class Command implements ICommandExecutor
public static final boolean IS_ENABLED = true ;
public static final boolean IS_ENABLED = true ;
public static final String USAGE = "No command usage provided." ;
public static final String USAGE = "No command usage provided." ;
public static final DefaultPermission DEFAULT_PERMISSION = DefaultPermission . EVERYONE ;
public static final DefaultPermission DEFAULT_PERMISSION = DefaultPermission . EVERYONE ;
public static final CommandScope COMMAND_SCOPE = CommandScope . NOWHERE ; // NOWHERE is enforced as a default value to force devs to specify a real scope.
}
}
/ * *
/ * *
@ -108,6 +116,11 @@ public abstract class Command implements ICommandExecutor
* /
* /
private DefaultPermission defaultPermission = Defaults . DEFAULT_PERMISSION ;
private DefaultPermission defaultPermission = Defaults . DEFAULT_PERMISSION ;
/ * *
* Tells where the command should run , ie . PM or guild chat , or both
* /
private CommandScope commandScope = Defaults . COMMAND_SCOPE ;
public Builder ( String name )
public Builder ( String name )
{
{
this . name = name ;
this . name = name ;
@ -153,6 +166,12 @@ public abstract class Command implements ICommandExecutor
return this ;
return this ;
}
}
public Builder commandScope ( CommandScope commandScope )
{
this . commandScope = commandScope ;
return this ;
}
/ * *
/ * *
* Build a new Command using a supplied executor .
* Build a new Command using a supplied executor .
* @param toExecute The body of the command .
* @param toExecute The body of the command .
@ -160,7 +179,7 @@ public abstract class Command implements ICommandExecutor
* /
* /
public Command build ( ICommandExecutor toExecute )
public Command build ( ICommandExecutor toExecute )
{
{
return new Command ( name , aliases , description , isEnabled , usage , defaultPermission )
return new Command ( name , aliases , description , isEnabled , usage , defaultPermission , commandScope )
{
{
@Override
@Override
public void execute ( MessageReceivedEvent event , List < String > arguments ) throws Throwable
public void execute ( MessageReceivedEvent event , List < String > arguments ) throws Throwable
@ -178,7 +197,7 @@ public abstract class Command implements ICommandExecutor
* /
* /
public Command build ( Method target , Object invokable )
public Command build ( Method target , Object invokable )
{
{
return new Command ( name , aliases , description , isEnabled , usage , defaultPermission )
return new Command ( name , aliases , description , isEnabled , usage , defaultPermission , commandScope )
{
{
@Override
@Override
public void execute ( MessageReceivedEvent event , List < String > arguments ) throws Throwable
public void execute ( MessageReceivedEvent event , List < String > arguments ) throws Throwable
@ -212,6 +231,7 @@ public abstract class Command implements ICommandExecutor
. enabled ( meta . isEnabled ( ) )
. enabled ( meta . isEnabled ( ) )
. usage ( meta . usage ( ) )
. usage ( meta . usage ( ) )
. defaultPermission ( meta . defaultPermission ( ) )
. defaultPermission ( meta . defaultPermission ( ) )
. commandScope ( meta . scope ( ) )
. build ( target , invokable ) ;
. build ( target , invokable ) ;
}
}
@ -245,6 +265,11 @@ public abstract class Command implements ICommandExecutor
return defaultPermission ;
return defaultPermission ;
}
}
public CommandScope getScope ( )
{
return commandScope ;
}
public void setEnabled ( boolean enabled )
public void setEnabled ( boolean enabled )
{
{
isEnabled = enabled ;
isEnabled = enabled ;