-
Notifications
You must be signed in to change notification settings - Fork 5
/
MainGUI.java
155 lines (133 loc) · 5.79 KB
/
MainGUI.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
* Skulls
* Copyright 2022 Kiran Hart
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package ca.tweetzy.skulls.guis;
import ca.tweetzy.flight.comp.enums.CompMaterial;
import ca.tweetzy.flight.gui.template.BaseGUI;
import ca.tweetzy.flight.settings.TranslationManager;
import ca.tweetzy.flight.utils.ChatUtil;
import ca.tweetzy.flight.utils.Common;
import ca.tweetzy.flight.utils.QuickItem;
import ca.tweetzy.flight.utils.input.TitleInput;
import ca.tweetzy.skulls.Skulls;
import ca.tweetzy.skulls.api.enums.BaseCategory;
import ca.tweetzy.skulls.api.enums.ViewMode;
import ca.tweetzy.skulls.model.SkullItem;
import ca.tweetzy.skulls.settings.Settings;
import ca.tweetzy.skulls.settings.Translations;
import lombok.NonNull;
import org.bukkit.entity.Player;
/**
* Date Created: April 20 2022
* Time Created: 9:47 p.m.
*
* @author Kiran Hart
*/
public final class MainGUI extends BaseGUI {
private final Player player;
public MainGUI(@NonNull final Player player) {
super(null, TranslationManager.string(Translations.GUI_MAIN_TITLE), 6);
this.player = player;
draw();
}
@Override
protected void draw() {
for (BaseCategory baseCategory : BaseCategory.values()) {
if (!baseCategory.isEnabled()) continue;
setButton(baseCategory.getSlot(), QuickItem
.of(Skulls.getSkullManager().getSkullItem(baseCategory.getTexture()))
.name(TranslationManager.string(Translations.GUI_MAIN_ITEMS_CATEGORY_NAME, "category_name", baseCategory.getName()))
.lore(TranslationManager.list(Translations.GUI_MAIN_ITEMS_CATEGORY_LORE, "category_size", Skulls.getSkullManager().getSkullCount(baseCategory.getId())))
.make(), click -> {
if (!Settings.GENERAL_USAGE_REQUIRES_NO_PERM.getBoolean())
if (!click.player.hasPermission("skulls.category." + baseCategory.getId().toLowerCase().replace(" ", "").replace("&", ""))) {
Common.tell(click.player, TranslationManager.string(Translations.CATEGORY_PERMISSION));
return;
}
click.manager.showGUI(click.player, new SkullsViewGUI(this, Skulls.getPlayerManager().findPlayer(click.player), baseCategory.getId(), ViewMode.LIST));
});
}
setButton(4, 4, QuickItem.of(SkullItem.get("skulls:5650"))
.name(TranslationManager.string(Translations.GUI_MAIN_ITEMS_SEARCH_NAME))
.lore(TranslationManager.list(Translations.GUI_MAIN_ITEMS_SEARCH_LORE))
.make(), click -> {
if (!Settings.GENERAL_USAGE_REQUIRES_NO_PERM.getBoolean())
if (!click.player.hasPermission("skulls.search")) {
Common.tell(click.player, TranslationManager.string(Translations.NO_PERMISSION));
return;
}
new TitleInput(Skulls.getInstance(), click.player, TranslationManager.string(Translations.INPUT_SKULL_SEARCH_TITLE), TranslationManager.string(Translations.INPUT_SKULL_SEARCH_SUBTITLE)) {
@Override
public boolean onResult(String string) {
if (string.matches("[\\\\^$.|?*+(){}]")) return false;
Skulls.getGuiManager().showGUI(click.player, new SkullsViewGUI(MainGUI.this, Skulls.getPlayerManager().findPlayer(click.player), string.trim(), ViewMode.SEARCH));
return true;
}
};
});
setButton(4, 2, QuickItem.of(SkullItem.get("skulls:25001"))
.name(TranslationManager.string(Translations.GUI_MAIN_ITEMS_CUSTOM_CATEGORIES_NAME))
.lore(TranslationManager.list(Translations.GUI_MAIN_ITEMS_CUSTOM_CATEGORIES_LORE))
.make(), click -> click.manager.showGUI(click.player, new CustomCategoryListGUI(click.player, this)));
setButton(4, 6, QuickItem.of(SkullItem.get("skulls:39696"))
.name(TranslationManager.string(Translations.GUI_MAIN_ITEMS_FAVOURITES_NAME))
.lore(TranslationManager.list(Translations.GUI_MAIN_ITEMS_FAVOURITES_LORE))
.make(), click -> {
if (!Settings.GENERAL_USAGE_REQUIRES_NO_PERM.getBoolean())
if (!click.player.hasPermission("skulls.favourites")) {
Common.tell(click.player, TranslationManager.string(Translations.NO_PERMISSION));
return;
}
click.manager.showGUI(click.player, new SkullsViewGUI(this, Skulls.getPlayerManager().findPlayer(click.player), "", ViewMode.FAVOURITE));
});
if (this.player.hasPermission("skulls.admin") || this.player.isOp()) {
setButton(5, 0, QuickItem.of(CompMaterial.REPEATER)
.name("&e&lSettings")
.lore(
"&8Skull Settings",
"&7You can view skulls that are new here",
"&7and then download them if you want.",
"",
"&e&lClick &8» &7To view settings"
)
.make(), click -> click.manager.showGUI(click.player, new HistoryViewGUI(this)));
setButton(5, 8, QuickItem.of(CompMaterial.DIAMOND)
.name("&e&lPatreon")
.lore(
"&8Support me on Patreon",
"&7By supporting me on Patreon you will",
"&7be helping me be able to continue updating",
"&7and creating free plugins.",
"",
"&8&oDon't worry, normal players can't see this",
"",
"&e&lClick &8» &7To view Patreon"
)
.glow(true)
.make(), click -> {
click.gui.close();
Common.tellNoPrefix(click.player,
"&8&m-----------------------------------------------------",
"",
ChatUtil.centerMessage("&E&lTweetzy Patreon"),
ChatUtil.centerMessage("&bhttps://patreon.com/kiranhart"),
"&8&m-----------------------------------------------------"
);
});
}
}
}