-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
HeadsMenu.java
60 lines (49 loc) · 1.9 KB
/
HeadsMenu.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package io.github.thatsmusic99.headsplus.inventories.list;
import io.github.thatsmusic99.headsplus.HeadsPlus;
import io.github.thatsmusic99.headsplus.config.ConfigHeadsSelector;
import io.github.thatsmusic99.headsplus.inventories.BaseInventory;
import io.github.thatsmusic99.headsplus.inventories.icons.Content;
import io.github.thatsmusic99.headsplus.inventories.icons.content.CustomHeadSection;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class HeadsMenu extends BaseInventory {
public HeadsMenu(Player player, HashMap<String, String> context) {
super(player, context);
}
public HeadsMenu() {
}
@Override
public String getDefaultTitle() {
return "HeadsPlus Heads: {page}/{pages}";
}
@Override
public String getDefaultItems() {
return "FGGGSGGGK" +
"GCCCCCCCG" +
"GCCCCCCCG" +
"GCCCCCCCG" +
"GCCCCCCCG" +
"<{[BXN]}>";
}
@Override
public String getId() {
return "headmenu";
}
@Override
public List<Content> transformContents(HashMap<String, String> context, Player player) {
List<Content> contents = new ArrayList<>();
ConfigHeadsSelector selector = ConfigHeadsSelector.get();
boolean wildcard = player.isPermissionSet("headsplus.section.*") && player.hasPermission("headsplus.section.*");
for (ConfigHeadsSelector.SectionInfo section : selector.getSections().values()) {
if (!wildcard && !player.hasPermission(section.getPermission())) continue;
try {
contents.add(new CustomHeadSection(section.buildSection(), section.getId(), player));
} catch (IllegalStateException ex) {
HeadsPlus.get().getLogger().warning(ex.getMessage());
}
}
return contents;
}
}