Skip to content

Commit

Permalink
add missing perms
Browse files Browse the repository at this point in the history
Took 27 minutes
  • Loading branch information
kiranhart committed Jun 18, 2022
1 parent fbf8eea commit d4e0c5f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
Expand Up @@ -99,6 +99,11 @@ public boolean onResult(String string) {

@Override
protected void onClick(Category category, GuiClickEvent clickEvent) {
if (!clickEvent.player.hasPermission("skulls.customcategory." + category.getId().toLowerCase())) {
Common.tell(clickEvent.player, Translation.NO_PERMISSIONS.getKey());
return;
}

clickEvent.manager.showGUI(clickEvent.player, new SkullsViewGUI(this, Skulls.getPlayerManager().findPlayer(clickEvent.player), category.getId(), ViewMode.LIST));
}
}
33 changes: 25 additions & 8 deletions src/main/java/ca/tweetzy/skulls/guis/MainGUI.java
Expand Up @@ -59,7 +59,7 @@ protected void draw() {
.lore(Translation.GUI_MAIN_ITEMS_CATEGORY_LORE.getList("category_size", Skulls.getSkullManager().getSkullCount(baseCategory.getId())))
.make(), click -> {

if (!click.player.hasPermission("skulls.category." + baseCategory.getId().toLowerCase())) {
if (!click.player.hasPermission("skulls.category." + baseCategory.getId().toLowerCase().replace(" ", "").replace("&",""))) {
Common.tell(click.player, Translation.CATEGORY_PERMISSION.getKey());
return;
}
Expand All @@ -71,14 +71,23 @@ protected void draw() {
setButton(4, 4, QuickItem.of(SkullItem.get("skulls:5650"))
.name(Translation.GUI_MAIN_ITEMS_SEARCH_NAME.getString())
.lore(Translation.GUI_MAIN_ITEMS_SEARCH_LORE.getList())
.make(), click -> new TitleInput(click.player, Translation.INPUT_SKULL_SEARCH_TITLE.getString(), Translation.INPUT_SKULL_SEARCH_SUBTITLE.getString()) {
.make(), click -> {

@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;
if (!click.player.hasPermission("skulls.search")) {
Common.tell(click.player, Translation.NO_PERMISSIONS.getKey());
return;
}

new TitleInput(click.player, Translation.INPUT_SKULL_SEARCH_TITLE.getString(), Translation.INPUT_SKULL_SEARCH_SUBTITLE.getString()) {

@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"))
Expand All @@ -89,7 +98,15 @@ public boolean onResult(String string) {
setButton(4, 6, QuickItem.of(SkullItem.get("skulls:39696"))
.name(Translation.GUI_MAIN_ITEMS_FAVOURITES_NAME.getString())
.lore(Translation.GUI_MAIN_ITEMS_FAVOURITES_LORE.getList())
.make(), click -> click.manager.showGUI(click.player, new SkullsViewGUI(this, Skulls.getPlayerManager().findPlayer(click.player), "", ViewMode.FAVOURITE)));
.make(), click -> {

if (!click.player.hasPermission("skulls.favourites")) {
Common.tell(click.player, Translation.NO_PERMISSIONS.getKey());
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()) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/ca/tweetzy/skulls/settings/Translation.java
Expand Up @@ -46,6 +46,7 @@ public enum Translation {
NOT_ENOUGH_MONEY("misc.not enough money", "&cYou do not have enough money!"),
NOT_A_NUMBER("misc.not a number", "&cThat is not a valid number"),
CATEGORY_PERMISSION("misc.category permission", "&cYou do not have permission to access that category!"),
NO_PERMISSIONS("misc.no permission", "&cYou do not have permission to use that!"),
PLAYER_OFFLINE("misc.player not found", "&cThe player &4%player% &cis not online!"),
ID_TAKEN("misc.player not found", "&cThat category id is already in use!"),
SKULL_NOT_FOUND("misc.skull not found", "&cNo skull by that id could be found"),
Expand Down

0 comments on commit d4e0c5f

Please sign in to comment.