Skip to content

Commit 4e99c79

Browse files
committed
4.1.81
1 parent d7591d4 commit 4e99c79

5 files changed

Lines changed: 77 additions & 26 deletions

File tree

pom.xml

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

77
<groupId>me.kodysimpson</groupId>
88
<artifactId>SimpAPI</artifactId>
9-
<version>4.1.8</version>
9+
<version>4.1.81</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SimpAPI</name>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package me.kodysimpson.simpapi.command;
22

3-
import org.bukkit.entity.Player;
3+
import org.bukkit.command.CommandSender;
44

55
import java.util.List;
66

@@ -11,9 +11,9 @@
1111
public interface CommandList {
1212

1313
/**
14-
* @param player The player to list the commands to
14+
* @param sender The thing that ran the command
1515
* @param subCommandList A list of all the subcommands you can display
1616
*/
17-
void displayCommandList(Player player, List<SubCommand> subCommandList);
17+
void displayCommandList(CommandSender sender, List<SubCommand> subCommandList);
1818

1919
}

src/main/java/me/kodysimpson/simpapi/command/CoreCommand.java

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,22 @@ public ArrayList<SubCommand> getSubCommands(){
3131
@Override
3232
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, String[] args) {
3333

34-
if (sender instanceof Player){
35-
Player p = (Player) sender;
36-
37-
if (args.length > 0){
38-
for (int i = 0; i < getSubCommands().size(); i++){
39-
if (args[0].equalsIgnoreCase(getSubCommands().get(i).getName()) || (getSubCommands().get(i).getAliases() != null && getSubCommands().get(i).getAliases().contains(args[0]))){
40-
getSubCommands().get(i).perform(p, args);
41-
}
34+
if (args.length > 0){
35+
for (int i = 0; i < getSubCommands().size(); i++){
36+
if (args[0].equalsIgnoreCase(getSubCommands().get(i).getName()) || (getSubCommands().get(i).getAliases() != null && getSubCommands().get(i).getAliases().contains(args[0]))){
37+
getSubCommands().get(i).perform(sender, args);
4238
}
43-
}else {
44-
if (commandList == null){
45-
p.sendMessage("--------------------------------");
46-
for (SubCommand subcommand : subcommands) {
47-
p.sendMessage(subcommand.getSyntax() + " - " + subcommand.getDescription());
48-
}
49-
p.sendMessage("--------------------------------");
50-
}else{
51-
commandList.displayCommandList(p, subcommands);
39+
}
40+
}else {
41+
if (commandList == null){
42+
sender.sendMessage("--------------------------------");
43+
for (SubCommand subcommand : subcommands) {
44+
sender.sendMessage(subcommand.getSyntax() + " - " + subcommand.getDescription());
5245
}
46+
sender.sendMessage("--------------------------------");
47+
}else{
48+
commandList.displayCommandList(sender, subcommands);
5349
}
54-
55-
}else{
56-
System.out.println("You must be a player to execute this command");
5750
}
5851

5952
return true;

src/main/java/me/kodysimpson/simpapi/command/SubCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.kodysimpson.simpapi.command;
22

3+
import org.bukkit.command.CommandSender;
34
import org.bukkit.entity.Player;
45

56
import java.util.List;
@@ -31,10 +32,10 @@ public abstract class SubCommand {
3132
public abstract String getSyntax();
3233

3334
/**
34-
* @param player The player who ran the command
35+
* @param sender The thing that ran the command
3536
* @param args The args passed into the command when run
3637
*/
37-
public abstract void perform(Player player, String[] args);
38+
public abstract void perform(CommandSender sender, String[] args);
3839

3940
/**
4041
* @param player The player who ran the command
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package me.kodysimpson.simpapi.menu;
2+
3+
import org.bukkit.ChatColor;
4+
import org.bukkit.Material;
5+
6+
import java.util.List;
7+
8+
public abstract class PaginatedMenu extends Menu {
9+
10+
protected List<Object> data;
11+
12+
//Keep track of what page the menu is on
13+
protected int page = 0;
14+
//28 is max items because with the border set below,
15+
//28 empty slots are remaining.
16+
protected int maxItemsPerPage = 28;
17+
//the index represents the index of the slot
18+
//that the loop is on
19+
protected int index = 0;
20+
21+
public PaginatedMenu(PlayerMenuUtility playerMenuUtility) {
22+
super(playerMenuUtility);
23+
}
24+
25+
//Set the border and menu buttons for the menu
26+
public void addMenuBorder(){
27+
inventory.setItem(48, makeItem(Material.DARK_OAK_BUTTON, ChatColor.GREEN + "Left"));
28+
29+
inventory.setItem(49, makeItem(Material.BARRIER, ChatColor.DARK_RED + "Close"));
30+
31+
inventory.setItem(50, makeItem(Material.DARK_OAK_BUTTON, ChatColor.GREEN + "Right"));
32+
33+
for (int i = 0; i < 10; i++) {
34+
if (inventory.getItem(i) == null) {
35+
inventory.setItem(i, super.FILLER_GLASS);
36+
}
37+
}
38+
39+
inventory.setItem(17, super.FILLER_GLASS);
40+
inventory.setItem(18, super.FILLER_GLASS);
41+
inventory.setItem(26, super.FILLER_GLASS);
42+
inventory.setItem(27, super.FILLER_GLASS);
43+
inventory.setItem(35, super.FILLER_GLASS);
44+
inventory.setItem(36, super.FILLER_GLASS);
45+
46+
for (int i = 44; i < 54; i++) {
47+
if (inventory.getItem(i) == null) {
48+
inventory.setItem(i, super.FILLER_GLASS);
49+
}
50+
}
51+
}
52+
53+
public int getMaxItemsPerPage() {
54+
return maxItemsPerPage;
55+
}
56+
}
57+

0 commit comments

Comments
 (0)