MassiveCraft / Factions

https://www.massivecraft.com/factions
245 stars 590 forks source link

Development - Third Party Commands #1351

Open SteveCookTU opened 5 years ago

SteveCookTU commented 5 years ago

Affected Plugin

Describe your Environment

I am currently developing a third party plugin that links with factions. I was hoping to be able to add the command into the factions command system but it seems that system has been reworked since the last time I was able to do so. (Not sure the version but the line was something like P.p.cmdBase). If there is any helpful hints on how commands are registered now within the plugin, I would greatly appreciate them. If the ability to do this is no longer supported I'd also love to know that.

Thank you.

markhughes commented 5 years ago

P.p was a really bad approach because it was terrible with memory cleanup.

Create a command by extending FactionsCommand, here is an example: https://github.com/magnusulf/Factions/blob/master/src/com/massivecraft/factions/cmd/CmdFactionsLeave.java

Then use FactionsCommand and add it as a child

YourCommand yourCommand = YourCommand.get();

// com.massivecraft.factions.cmd.FactionsCommand 
FactionsCommand.get().addChild(yourCommand);