2020
2121import dev .despical .commandframework .annotations .Command ;
2222import dev .despical .commandframework .annotations .Param ;
23- import dev .despical .commandframework .confirmations .ConfirmationManager ;
2423import dev .despical .commandframework .exceptions .CommandException ;
25- import dev .despical .commandframework .cooldown .CooldownManager ;
2624import dev .despical .commandframework .debug .DebugLogger ;
2725import dev .despical .commandframework .options .FrameworkOption ;
2826import dev .despical .commandframework .options .OptionManager ;
2927import org .bukkit .command .CommandMap ;
30- import org .bukkit .command .CommandSender ;
3128import org .bukkit .plugin .Plugin ;
3229import org .jetbrains .annotations .ApiStatus ;
30+ import org .jetbrains .annotations .Contract ;
3331import org .jetbrains .annotations .NotNull ;
3432
35- import java .lang .reflect .Method ;
3633import java .util .ArrayList ;
3734import java .util .List ;
3835import java .util .function .Function ;
@@ -52,22 +49,16 @@ public class CommandFramework extends CommandHandler {
5249 protected static CommandFramework instance ;
5350
5451 private Logger logger ;
55- private CooldownManager cooldownManager ;
56- private ConfirmationManager confirmationManager ;
57-
58- protected final Plugin plugin ;
59- private final OptionManager optionManager ;
60- private final CommandRegistry registry ;
52+ private final Plugin plugin ;
53+ private final OptionManager optionManager ;
6154
6255 public CommandFramework (@ NotNull Plugin plugin ) {
6356 this .checkRelocation ();
6457 this .checkIsAlreadyInitialized ();
6558
6659 this .plugin = plugin ;
67- this .registry = new CommandRegistry ();
68- this .optionManager = new OptionManager ();
60+ this .optionManager = new OptionManager ();
6961 this .initializeLogger ();
70- super .setRegistry (this );
7162 }
7263
7364 private void checkRelocation () {
@@ -114,14 +105,14 @@ public final void registerCommands(@NotNull Object instance) {
114105 * @param commandName name of the command that's going to be removed
115106 */
116107 public final void unregisterCommand (@ NotNull String commandName ) {
117- this .registry .unregisterCommand (commandName );
108+ this .registry .unregisterCommand (commandName );
118109 }
119110
120111 /**
121112 * Unregisters all of registered commands and tab completers using that instance.
122113 */
123114 public final void unregisterCommands () {
124- this .registry .unregisterCommands ();
115+ this .registry .unregisterCommands ();
125116 }
126117
127118 /**
@@ -171,6 +162,7 @@ public final <T> void addCustomParameter(@NotNull Class<T> clazz, @NotNull Funct
171162 * @since 1.4.8
172163 */
173164 @ NotNull
165+ @ Contract (pure = true )
174166 public final Logger getLogger () {
175167 return logger ;
176168 }
@@ -195,31 +187,8 @@ public final OptionManager options() {
195187 return this .optionManager ;
196188 }
197189
198- @ ApiStatus .Internal
199- CooldownManager getCooldownManager () {
200- if (this .cooldownManager == null )
201- this .cooldownManager = new CooldownManager (this );
202- return cooldownManager ;
203- }
204-
205- @ ApiStatus .Internal
206- CommandRegistry getRegistry () {
207- return registry ;
208- }
209-
210- @ ApiStatus .Internal
211- boolean checkConfirmation (CommandSender sender , final Command command , final Method method ) {
212- if (!this .optionManager .isEnabled (FrameworkOption .CONFIRMATIONS )) {
213- return false ;
214- }
215-
216- if (this .confirmationManager == null )
217- this .confirmationManager = new ConfirmationManager ();
218- return confirmationManager .checkConfirmations (sender , command , method );
219- }
220-
221190 protected final void setCommandMap (CommandMap commandMap ) {
222- this .registry .setCommandMap (commandMap );
191+ this .registry .setCommandMap (commandMap );
223192 }
224193
225194 /**
@@ -228,6 +197,7 @@ protected final void setCommandMap(CommandMap commandMap) {
228197 * @return list of the commands.
229198 */
230199 @ NotNull
200+ @ Contract (pure = true )
231201 public final List <Command > getCommands () {
232202 return new ArrayList <>(this .registry .getCommands ());
233203 }
@@ -238,6 +208,7 @@ public final List<Command> getCommands() {
238208 * @return list of the sub-commands.
239209 */
240210 @ NotNull
211+ @ Contract (pure = true )
241212 public final List <Command > getSubCommands () {
242213 return new ArrayList <>(this .registry .getSubCommands ());
243214 }
@@ -248,14 +219,21 @@ public final List<Command> getSubCommands() {
248219 * @return list of the commands and sub-commands.
249220 */
250221 @ NotNull
222+ @ Contract (pure = true )
251223 public final List <Command > getAllCommands () {
252- final List <Command > commands = new ArrayList <>(this . registry .getCommands ());
253- commands .addAll (this . registry .getSubCommands ());
224+ final List <Command > commands = new ArrayList <>(registry .getCommands ());
225+ commands .addAll (registry .getSubCommands ());
254226
255227 return commands ;
256228 }
257229
258- public static CommandFramework getInstance () {
230+ @ NotNull
231+ @ Contract (pure = true )
232+ public final Plugin getPlugin () {
233+ return plugin ;
234+ }
235+
236+ public static CommandFramework getInstance () {
259237 return instance ;
260238 }
261239}
0 commit comments