Skip to content

Commit 75e653b

Browse files
Merge pull request #169 from dmccoystephenson/help-command
Added the Help Command
2 parents fe210cc + 3a6e510 commit 75e653b

File tree

7 files changed

+41
-9
lines changed

7 files changed

+41
-9
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>KingdomProgrammers</groupId>
88
<artifactId>More-Recipes</artifactId>
9-
<version>v1.5-alpha-1</version>
9+
<version>v1.5</version>
1010
<packaging>jar</packaging>
1111

1212
<name>More Recipes</name>

src/main/java/dansplugins/recipesystem/CommandInterpreter.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dansplugins.recipesystem;
22

3+
import dansplugins.recipesystem.commands.HelpCommand;
34
import org.bukkit.ChatColor;
45
import org.bukkit.command.CommandSender;
56
import dansplugins.recipesystem.commands.GetCommand;
@@ -16,20 +17,27 @@ public boolean interpretCommand(CommandSender sender, String label, String[] arg
1617
return true;
1718
}
1819

19-
if (args[0].equalsIgnoreCase("get")) {
20-
GetCommand command = new GetCommand();
21-
command.getItem(sender, args);
20+
if (args[0].equalsIgnoreCase("help")) {
21+
HelpCommand command = new HelpCommand();
22+
command.execute(sender);
2223
return true;
2324
}
2425

2526
if (args[0].equalsIgnoreCase("listitems")) {
2627
ListItemsCommand command = new ListItemsCommand();
27-
command.showListToPlayer(sender);
28+
command.execute(sender);
29+
return true;
30+
}
31+
32+
if (args[0].equalsIgnoreCase("get")) {
33+
GetCommand command = new GetCommand();
34+
command.execute(sender, args);
2835
return true;
2936
}
3037

3138
}
3239

40+
sender.sendMessage(ChatColor.RED + "More Recipes doesn't recognize that command.");
3341
return false;
3442
}
3543

src/main/java/dansplugins/recipesystem/MoreRecipes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public final class MoreRecipes extends JavaPlugin {
1111
private static MoreRecipes instance;
1212

1313
// version
14-
public String version = "v1.5-alpha-1";
14+
public final String version = "v1.5";
1515

1616
public static MoreRecipes getInstance() {
1717
return instance;

src/main/java/dansplugins/recipesystem/commands/GetCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
public class GetCommand {
1111

12-
public void getItem(CommandSender sender, String[] args) {
12+
public void execute(CommandSender sender, String[] args) {
1313

1414
if (sender instanceof Player) {
1515

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package dansplugins.recipesystem.commands;
2+
3+
import org.bukkit.ChatColor;
4+
import org.bukkit.command.CommandSender;
5+
import org.bukkit.entity.Player;
6+
7+
public class HelpCommand {
8+
9+
public void execute(CommandSender sender) {
10+
if (sender instanceof Player) {
11+
Player player = (Player) sender;
12+
if (!player.hasPermission("morerecipes.help")) {
13+
sender.sendMessage(ChatColor.RED + "You don't have permission to use this command.");
14+
return;
15+
}
16+
}
17+
sender.sendMessage(ChatColor.AQUA + "/mr help - View a list of helpful commands.");
18+
sender.sendMessage(ChatColor.AQUA + "/mr listitems - List the items that can be crafted.");
19+
sender.sendMessage(ChatColor.AQUA + "/mr get (name) (amount) - Get an certain amount of a specified item.");
20+
}
21+
22+
}

src/main/java/dansplugins/recipesystem/commands/ListItemsCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
public class ListItemsCommand {
1212

13-
public void showListToPlayer(CommandSender sender) {
13+
public void execute(CommandSender sender) {
1414

1515
if (sender instanceof Player) {
1616

src/main/resources/plugin.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: More-Recipes
2-
version: "1.5-alpha-1"
2+
version: "1.5"
33
author: DanTheTechMan
44
main: dansplugins.recipesystem.MoreRecipes
55
api-version: "1.13"
@@ -9,6 +9,8 @@ commands:
99
mr:
1010

1111
permissions:
12+
morerecipes.help:
13+
default: true
1214
morerecipes.listitems:
1315
default: true
1416
morerecipes.get:

0 commit comments

Comments
 (0)