mirror of
https://github.com/TotalFreedomMC/TF-Marriage.git
synced 2024-12-31 20:42:18 +00:00
Add help command
This commit is contained in:
parent
bfed27fd81
commit
c689e4d0ec
5 changed files with 54 additions and 5 deletions
|
@ -16,6 +16,7 @@ public abstract class Command {
|
|||
private int minArgs = 0;
|
||||
private String permission = null;
|
||||
private boolean allowConsole = false;
|
||||
private boolean hidden = false;
|
||||
|
||||
protected CommandSender sender;
|
||||
protected Player player;
|
||||
|
@ -87,9 +88,7 @@ public abstract class Command {
|
|||
*
|
||||
* @param message Message to send.
|
||||
* @param args Formatting arguments
|
||||
* @deprecated Use the {@link Command#reply(Message, Object...) reply} method
|
||||
*/
|
||||
@Deprecated
|
||||
protected void reply(String message, Object... args) {
|
||||
reply(sender, message, args);
|
||||
}
|
||||
|
@ -98,7 +97,6 @@ public abstract class Command {
|
|||
reply(sender, message.toString(), args);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected void reply(CommandSender sender, String message, Object... args) {
|
||||
message = ChatColor.translateAlternateColorCodes('&', String.format(message, args));
|
||||
sender.sendMessage(message);
|
||||
|
@ -108,7 +106,6 @@ public abstract class Command {
|
|||
broadcast(message.toString(), args);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected void broadcast(String message, Object... args) {
|
||||
message = ChatColor.translateAlternateColorCodes('&', String.format(message, args));
|
||||
sender.sendMessage(message);
|
||||
|
@ -157,4 +154,12 @@ public abstract class Command {
|
|||
protected void setAllowConsole(boolean allowConsole) {
|
||||
this.allowConsole = allowConsole;
|
||||
}
|
||||
|
||||
protected boolean isHidden() {
|
||||
return hidden;
|
||||
}
|
||||
|
||||
protected void setHidden(boolean hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.lenis0012.bukkit.marriage2.commands;
|
||||
|
||||
import com.lenis0012.bukkit.marriage2.Marriage;
|
||||
import com.lenis0012.bukkit.marriage2.internal.MarriageBase;
|
||||
import com.lenis0012.bukkit.marriage2.internal.MarriageCommandExecutor;
|
||||
|
||||
public class CommandHelp extends Command {
|
||||
|
||||
public CommandHelp(Marriage marriage, String[] aliases) {
|
||||
super(marriage, aliases);
|
||||
setMinArgs(-1);
|
||||
setHidden(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
MarriageCommandExecutor commandExecutor = ((MarriageBase) marriage).getCommandExecutor();
|
||||
reply("Author: &alenis0012");
|
||||
reply("Version: &a" + marriage.getPlugin().getDescription().getVersion());
|
||||
reply("&2&m----------------&2< &a&lMarriage Command Help &2>&2&m----------------"); // Play around with the amount of dashes later
|
||||
for(Command command : commandExecutor.getSubCommands()) {
|
||||
if(command.isHidden()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
reply("&a/marry " + command.getAliases()[0] + " " + command.getUsage() + " &f- &7" + command.getDescription());
|
||||
}
|
||||
|
||||
reply("&2&m--------------------------------------------"); // Play around with the amount of dashes later
|
||||
}
|
||||
}
|
|
@ -45,4 +45,8 @@ public abstract class MarriageBase implements Marriage {
|
|||
public MarriagePlugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public MarriageCommandExecutor getCommandExecutor() {
|
||||
return commandExecutor;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.lenis0012.bukkit.marriage2.internal;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
@ -58,4 +59,8 @@ public class MarriageCommandExecutor implements CommandExecutor {
|
|||
core.getLogger().log(Level.SEVERE, "Failed to register sub command", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<Command> getSubCommands() {
|
||||
return commands.values();
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import java.util.UUID;
|
|||
import com.lenis0012.bukkit.marriage2.MPlayer;
|
||||
import com.lenis0012.bukkit.marriage2.commands.CommandDivorce;
|
||||
import com.lenis0012.bukkit.marriage2.commands.CommandGift;
|
||||
import com.lenis0012.bukkit.marriage2.commands.CommandHelp;
|
||||
import com.lenis0012.bukkit.marriage2.commands.CommandHome;
|
||||
import com.lenis0012.bukkit.marriage2.commands.CommandMarry;
|
||||
import com.lenis0012.bukkit.marriage2.commands.CommandSethome;
|
||||
|
@ -49,8 +50,11 @@ public class MarriageCore extends MarriageBase {
|
|||
register(CommandMarry.class);
|
||||
register(CommandHome.class);
|
||||
register(CommandSethome.class);
|
||||
register(CommandDivorce.class);
|
||||
register(CommandGift.class);
|
||||
register(CommandDivorce.class);
|
||||
|
||||
// Hidden/secret commands
|
||||
register(CommandHelp.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue