Skip to content

Commit

Permalink
Support left clicking on GUI to show all votesites even without perms
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCodez committed Jun 16, 2024
1 parent e34f5f0 commit f436b03
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;

import com.bencodez.advancedcore.api.bookgui.BookWrapper;
import com.bencodez.advancedcore.api.bookgui.Layout;
Expand Down Expand Up @@ -51,6 +52,10 @@ public VoteURL(VotingPluginMain plugin, CommandSender player, VotingPluginUser u

@Override
public ArrayList<String> getChat(CommandSender sender) {
return getChat(sender, false);
}

public ArrayList<String> getChat(CommandSender sender, boolean bypassPermissionCheck) {
ArrayList<String> sites = new ArrayList<String>();

List<String> title = plugin.getConfigFile().getFormatCommandsVoteText();
Expand All @@ -61,7 +66,7 @@ public ArrayList<String> getChat(CommandSender sender) {
int counter = 0;
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
if (!voteSite.isHidden()) {
if (voteSite.getPermissionToView().isEmpty()
if (voteSite.getPermissionToView().isEmpty() || bypassPermissionCheck
|| sender.hasPermission(voteSite.getPermissionToView())) {
if (!plugin.getConfigFile().isFormatCommandsVoteOnlyShowSitesToVote()
|| user.canVoteSite(voteSite)) {
Expand Down Expand Up @@ -192,7 +197,11 @@ public void onChest(Player player) {
public void onClick(ClickEvent event) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(event.getPlayer());
json = true;
user.sendMessage(getChat(player));
if (event.getClick().equals(ClickType.LEFT)) {
user.sendMessage(getChat(player, true));
} else {
user.sendMessage(getChat(player, false));
}
}

@Override
Expand Down

0 comments on commit f436b03

Please sign in to comment.