Add help to destroy command.

This commit is contained in:
Jesse Prescott 2018-06-04 14:18:58 +01:00
parent 1f5d15cdf4
commit 95adac5ef2
2 changed files with 51 additions and 3 deletions

View File

@ -159,6 +159,7 @@ public final class CreateCommand implements Command {
// Show specific help.
chatLogger.message(player, "command.create.help");
// Return.
return true;
}
}

View File

@ -17,6 +17,7 @@ package com.gmail.bleedobsidian.itemcase.commands;
import com.gmail.bleedobsidian.itemcase.ChatLogger;
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
import com.gmail.bleedobsidian.itemcase.Itemcase;
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
import com.gmail.bleedobsidian.itemcase.managers.ItemcaseManager;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
@ -45,12 +46,19 @@ public final class DestroyCommand implements Command {
return;
}
// Get chat logger.
ChatLogger chatLogger = ItemCaseCore.instance.getChatLogger();
// Cast sender to player.
Player player = (Player) sender;
// Check if player is asking for help.
if(this.isAskingForHelp(player, label, args)) {
// Exit.
return;
}
// Get chat logger.
ChatLogger chatLogger = ItemCaseCore.instance.getChatLogger();
// Check if player has permission (Uses create permission).
if(!player.hasPermission("itemcase.create")) {
@ -106,4 +114,43 @@ public final class DestroyCommand implements Command {
// Show message.
chatLogger.message(player, "command.destroy.success");
}
/**
* @return If the command sender is asking for help about this command.
*/
public boolean isAskingForHelp(Player player, String label, String[] args) {
// If args length equals 2.
if(args.length != 2) {
// False.
return false;
}
// Get argument.
String argument = args[1];
// If not equal to help.
if(!argument.equalsIgnoreCase("help")) {
return false;
}
// Get chat logger.
ChatLogger chatLogger = ItemCaseCore.instance.getChatLogger();
// Get translator.
LanguageTranslator translator = ItemCaseCore.instance.getTranslator();
// Set placeholder.
translator.setPlaceholder("%COMMAND%", "/" + label + " destroy");
// Show command help.
chatLogger.message(player, "command.itemcase-help");
// Show specific help.
chatLogger.message(player, "command.destroy.help");
return true;
}
}