2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd ;
2011-03-22 15:45:41 +01:00
2011-10-16 16:11:29 +02:00
import com.massivecraft.factions.Conf ;
2018-10-23 01:42:57 +02:00
import com.massivecraft.factions.SavageFactions ;
2011-10-05 12:13:54 +02:00
import com.massivecraft.factions.integration.Econ ;
2011-10-09 14:53:38 +02:00
import com.massivecraft.factions.struct.Permission ;
2014-12-08 00:12:52 +01:00
import com.massivecraft.factions.zcore.util.TL ;
2015-05-13 04:09:52 +02:00
import org.bukkit.configuration.ConfigurationSection ;
2011-03-23 17:39:56 +01:00
2014-04-04 20:55:21 +02:00
import java.util.ArrayList ;
2015-05-13 04:09:52 +02:00
import java.util.List ;
2014-04-04 20:55:21 +02:00
public class CmdHelp extends FCommand {
2018-07-12 18:11:07 +02:00
public ArrayList < ArrayList < String > > helpPages ;
2014-04-04 20:55:21 +02:00
public CmdHelp ( ) {
2014-07-01 22:10:18 +02:00
super ( ) ;
this . aliases . add ( " help " ) ;
this . aliases . add ( " h " ) ;
this . aliases . add ( " ? " ) ;
2014-04-04 20:55:21 +02:00
//this.requiredArgs.add("");
this . optionalArgs . put ( " page " , " 1 " ) ;
2014-07-01 22:10:18 +02:00
this . permission = Permission . HELP . node ;
this . disableOnLock = false ;
2014-04-04 20:55:21 +02:00
2014-07-01 22:10:18 +02:00
senderMustBePlayer = false ;
senderMustBeMember = false ;
senderMustBeModerator = false ;
2018-03-26 23:43:15 +02:00
senderMustBeColeader = false ;
2014-04-04 20:55:21 +02:00
senderMustBeAdmin = false ;
}
2018-07-12 18:11:07 +02:00
//----------------------------------------------//
// Build the help pages
//----------------------------------------------//
2014-04-04 20:55:21 +02:00
@Override
public void perform ( ) {
2018-10-23 01:42:57 +02:00
if ( SavageFactions . plugin . getConfig ( ) . getBoolean ( " use-old-help " , true ) ) {
2015-05-13 04:09:52 +02:00
if ( helpPages = = null ) {
updateHelp ( ) ;
}
2014-04-04 20:55:21 +02:00
2015-05-13 04:09:52 +02:00
int page = this . argAsInt ( 0 , 1 ) ;
sendMessage ( p . txt . titleize ( " Factions Help ( " + page + " / " + helpPages . size ( ) + " ) " ) ) ;
2014-04-04 20:55:21 +02:00
2015-05-13 04:09:52 +02:00
page - = 1 ;
2014-04-04 20:55:21 +02:00
2015-05-13 04:09:52 +02:00
if ( page < 0 | | page > = helpPages . size ( ) ) {
msg ( TL . COMMAND_HELP_404 . format ( String . valueOf ( page ) ) ) ;
return ;
}
sendMessage ( helpPages . get ( page ) ) ;
return ;
}
2018-10-23 01:42:57 +02:00
ConfigurationSection help = SavageFactions . plugin . getConfig ( ) . getConfigurationSection ( " help " ) ;
2015-05-13 04:09:52 +02:00
if ( help = = null ) {
2018-10-23 01:42:57 +02:00
help = SavageFactions . plugin . getConfig ( ) . createSection ( " help " ) ; // create new help section
2017-12-19 11:18:13 +01:00
List < String > error = new ArrayList < > ( ) ;
2015-05-13 04:09:52 +02:00
error . add ( " &cUpdate help messages in config.yml! " ) ;
error . add ( " &cSet use-old-help for legacy help messages " ) ;
help . set ( " '1' " , error ) ; // add default error messages
}
String pageArg = this . argAsString ( 0 , " 1 " ) ;
List < String > page = help . getStringList ( pageArg ) ;
if ( page = = null | | page . isEmpty ( ) ) {
msg ( TL . COMMAND_HELP_404 . format ( pageArg ) ) ;
2014-07-01 22:10:18 +02:00
return ;
}
2015-05-13 04:09:52 +02:00
for ( String helpLine : page ) {
2018-10-23 01:42:57 +02:00
sendMessage ( SavageFactions . plugin . txt . parse ( helpLine ) ) ;
2015-05-13 04:09:52 +02:00
}
2014-04-04 20:55:21 +02:00
}
public void updateHelp ( ) {
2017-12-19 11:18:13 +01:00
helpPages = new ArrayList < > ( ) ;
2014-07-01 22:10:18 +02:00
ArrayList < String > pageLines ;
2014-04-04 20:55:21 +02:00
2017-12-19 11:18:13 +01:00
pageLines = new ArrayList < > ( ) ;
2014-07-01 22:10:18 +02:00
pageLines . add ( p . cmdBase . cmdHelp . getUseageTemplate ( true ) ) ;
2014-04-04 20:55:21 +02:00
pageLines . add ( p . cmdBase . cmdList . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdShow . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdPower . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdJoin . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdLeave . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdChat . getUseageTemplate ( true ) ) ;
2015-03-05 05:55:46 +01:00
pageLines . add ( p . cmdBase . cmdToggleAllianceChat . getUseageTemplate ( true ) ) ;
2014-04-04 20:55:21 +02:00
pageLines . add ( p . cmdBase . cmdHome . getUseageTemplate ( true ) ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_NEXTCREATE . toString ( ) ) ) ;
2014-07-01 22:10:18 +02:00
helpPages . add ( pageLines ) ;
2014-04-04 20:55:21 +02:00
2017-12-19 11:18:13 +01:00
pageLines = new ArrayList < > ( ) ;
2014-07-01 22:10:18 +02:00
pageLines . add ( p . cmdBase . cmdCreate . getUseageTemplate ( true ) ) ;
2014-04-04 20:55:21 +02:00
pageLines . add ( p . cmdBase . cmdDescription . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdTag . getUseageTemplate ( true ) ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_INVITATIONS . toString ( ) ) ) ;
2014-04-04 20:55:21 +02:00
pageLines . add ( p . cmdBase . cmdOpen . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdInvite . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdDeinvite . getUseageTemplate ( true ) ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_HOME . toString ( ) ) ) ;
2014-07-01 22:10:18 +02:00
pageLines . add ( p . cmdBase . cmdSethome . getUseageTemplate ( true ) ) ;
helpPages . add ( pageLines ) ;
2014-04-04 20:55:21 +02:00
if ( Econ . isSetup ( ) & & Conf . econEnabled & & Conf . bankEnabled ) {
2017-12-19 11:18:13 +01:00
pageLines = new ArrayList < > ( ) ;
2014-07-01 22:10:18 +02:00
pageLines . add ( " " ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_BANK_1 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_BANK_2 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_BANK_3 . toString ( ) ) ) ;
2014-07-01 22:10:18 +02:00
pageLines . add ( " " ) ;
pageLines . add ( p . cmdBase . cmdMoney . getUseageTemplate ( true ) ) ;
pageLines . add ( " " ) ;
pageLines . add ( " " ) ;
pageLines . add ( " " ) ;
helpPages . add ( pageLines ) ;
2014-04-04 20:55:21 +02:00
}
2017-12-19 11:18:13 +01:00
pageLines = new ArrayList < > ( ) ;
2014-07-01 22:10:18 +02:00
pageLines . add ( p . cmdBase . cmdClaim . getUseageTemplate ( true ) ) ;
2014-04-04 20:55:21 +02:00
pageLines . add ( p . cmdBase . cmdAutoClaim . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdUnclaim . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdUnclaimall . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdKick . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdMod . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdAdmin . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdTitle . getUseageTemplate ( true ) ) ;
2014-11-05 18:34:46 +01:00
pageLines . add ( p . cmdBase . cmdSB . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdSeeChunk . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdStatus . getUseageTemplate ( true ) ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_PLAYERTITLES . toString ( ) ) ) ;
2014-04-04 20:55:21 +02:00
helpPages . add ( pageLines ) ;
2017-12-19 11:18:13 +01:00
pageLines = new ArrayList < > ( ) ;
2014-07-01 22:10:18 +02:00
pageLines . add ( p . cmdBase . cmdMap . getUseageTemplate ( true ) ) ;
2014-04-04 20:55:21 +02:00
pageLines . add ( p . cmdBase . cmdBoom . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdOwner . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdOwnerList . getUseageTemplate ( true ) ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_OWNERSHIP_1 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_OWNERSHIP_2 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_OWNERSHIP_3 . toString ( ) ) ) ;
2014-07-01 22:10:18 +02:00
helpPages . add ( pageLines ) ;
2014-04-04 20:55:21 +02:00
2017-12-19 11:18:13 +01:00
pageLines = new ArrayList < > ( ) ;
2014-07-01 22:10:18 +02:00
pageLines . add ( p . cmdBase . cmdDisband . getUseageTemplate ( true ) ) ;
pageLines . add ( " " ) ;
pageLines . add ( p . cmdBase . cmdRelationAlly . getUseageTemplate ( true ) ) ;
2014-04-04 20:55:21 +02:00
pageLines . add ( p . cmdBase . cmdRelationNeutral . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdRelationEnemy . getUseageTemplate ( true ) ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_RELATIONS_1 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_RELATIONS_2 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_RELATIONS_3 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_RELATIONS_4 . toString ( ) ) ) ;
2014-04-04 20:55:21 +02:00
helpPages . add ( pageLines ) ;
2017-12-19 11:18:13 +01:00
pageLines = new ArrayList < > ( ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_RELATIONS_5 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_RELATIONS_6 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_RELATIONS_7 . toString ( ) ) ) ;
2014-12-11 17:05:04 +01:00
pageLines . add ( TL . COMMAND_HELP_RELATIONS_8 . toString ( ) ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_RELATIONS_9 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_RELATIONS_10 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_RELATIONS_11 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_RELATIONS_12 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_RELATIONS_13 . toString ( ) ) ) ;
2014-04-04 20:55:21 +02:00
helpPages . add ( pageLines ) ;
2017-12-19 11:18:13 +01:00
pageLines = new ArrayList < > ( ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_PERMISSIONS_1 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_PERMISSIONS_2 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_PERMISSIONS_3 . toString ( ) ) ) ;
2014-12-11 17:05:04 +01:00
pageLines . add ( TL . COMMAND_HELP_PERMISSIONS_4 . toString ( ) ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_PERMISSIONS_5 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_PERMISSIONS_6 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_PERMISSIONS_7 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_PERMISSIONS_8 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_PERMISSIONS_9 . toString ( ) ) ) ;
2014-07-01 22:10:18 +02:00
helpPages . add ( pageLines ) ;
2014-04-04 20:55:21 +02:00
2017-12-19 11:18:13 +01:00
pageLines = new ArrayList < > ( ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( TL . COMMAND_HELP_MOAR_1 . toString ( ) ) ;
2014-04-04 20:55:21 +02:00
pageLines . add ( p . cmdBase . cmdBypass . getUseageTemplate ( true ) ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_ADMIN_1 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_ADMIN_2 . toString ( ) ) ) ;
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_ADMIN_3 . toString ( ) ) ) ;
2014-04-04 20:55:21 +02:00
pageLines . add ( p . cmdBase . cmdSafeunclaimall . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdWarunclaimall . getUseageTemplate ( true ) ) ;
2014-12-08 00:12:52 +01:00
//TODO:TL
2018-10-23 01:42:57 +02:00
pageLines . add ( p . txt . parse ( " <i>Note: " + p . cmdBase . cmdUnclaim . getUseageTemplate ( false ) + SavageFactions . plugin . txt . parse ( " <i> " ) + " works on safe/war zones as well. " ) ) ;
2014-07-01 22:10:18 +02:00
pageLines . add ( p . cmdBase . cmdPeaceful . getUseageTemplate ( true ) ) ;
helpPages . add ( pageLines ) ;
2014-04-04 20:55:21 +02:00
2017-12-19 11:18:13 +01:00
pageLines = new ArrayList < > ( ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_MOAR_2 . toString ( ) ) ) ;
2014-04-04 20:55:21 +02:00
pageLines . add ( p . cmdBase . cmdChatSpy . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdPermanent . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdPermanentPower . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdPowerBoost . getUseageTemplate ( true ) ) ;
2014-07-01 22:10:18 +02:00
pageLines . add ( p . cmdBase . cmdConfig . getUseageTemplate ( true ) ) ;
helpPages . add ( pageLines ) ;
2011-03-22 15:45:41 +01:00
2017-12-19 11:18:13 +01:00
pageLines = new ArrayList < > ( ) ;
2014-12-08 00:12:52 +01:00
pageLines . add ( p . txt . parse ( TL . COMMAND_HELP_MOAR_3 . toString ( ) ) ) ;
2014-04-04 20:55:21 +02:00
pageLines . add ( p . cmdBase . cmdLock . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdReload . getUseageTemplate ( true ) ) ;
pageLines . add ( p . cmdBase . cmdSaveAll . getUseageTemplate ( true ) ) ;
2014-07-01 22:10:18 +02:00
pageLines . add ( p . cmdBase . cmdVersion . getUseageTemplate ( true ) ) ;
helpPages . add ( pageLines ) ;
2014-04-04 20:55:21 +02:00
}
2015-01-22 00:58:33 +01:00
@Override
public TL getUsageTranslation ( ) {
return TL . COMMAND_HELP_DESCRIPTION ;
}
2011-03-22 15:45:41 +01:00
}