Skip to content

Commit

Permalink
feat: added allowing disabling of super votes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lagggpixel committed Jun 21, 2024
1 parent 3c8716b commit 06e5e13
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import plugily.projects.minigamesbox.classic.handlers.reward.RewardType;
import plugily.projects.minigamesbox.classic.handlers.reward.RewardsFactory;
import plugily.projects.minigamesbox.classic.preferences.ConfigOption;
import plugily.projects.minigamesbox.classic.preferences.ConfigPreferences;

/**
* @author Tigerpanzer_02
Expand Down Expand Up @@ -61,6 +60,7 @@ private void registerConfigOptions() {
configPreferences.registerOption("REPORT_COMMANDS", new ConfigOption("Report.Commands", false));
configPreferences.registerOption("PLOT_HIDE_OWNER", new ConfigOption("Plot.Hide-Owner", false));
configPreferences.registerOption("PLOT_MOVE_OUTSIDE", new ConfigOption("Plot.Move-Outside", false));
configPreferences.registerOption("SUPER_VOTES", new ConfigOption("Super-Votes", true));
}

private void registerStatistics() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,13 @@
import plugily.projects.minigamesbox.api.arena.IArenaState;
import plugily.projects.minigamesbox.api.user.IUser;
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
import plugily.projects.minigamesbox.classic.user.User;
import plugily.projects.minigamesbox.classic.utils.helper.ItemBuilder;
import plugily.projects.minigamesbox.classic.utils.version.xseries.XMaterial;
import plugily.projects.minigamesbox.inventory.common.item.ClickableItem;
import plugily.projects.minigamesbox.inventory.common.item.SimpleClickableItem;
import plugily.projects.minigamesbox.inventory.normal.NormalFastInv;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.Consumer;

/**
Expand Down Expand Up @@ -131,25 +125,30 @@ private NormalFastInv getGUI(Player guiPlayer) {

setGlassPanes(gui, multiplied, percent);

gui.setItem(multiplied + 8, new SimpleClickableItem(new ItemBuilder(new ItemStack(Material.PAPER))
.name(new MessageBuilder("MENU_THEME_VOTE_SUPER_ITEM_NAME").asKey().arena(arena).value(theme).build())
.lore(new MessageBuilder("MENU_THEME_VOTE_SUPER_ITEM_LORE").asKey().player(guiPlayer).arena(arena).value(theme).build().split(";"))
.build(), event -> {
HumanEntity humanEntity = event.getWhoClicked();
if (plugin.getConfigPreferences().getOption("SUPER_VOTES")) {
gui.setItem(multiplied + 8, new SimpleClickableItem(new ItemBuilder(new ItemStack(Material.PAPER))
.name(new MessageBuilder("MENU_THEME_VOTE_SUPER_ITEM_NAME").asKey().arena(arena).value(theme).build())
.lore(new MessageBuilder("MENU_THEME_VOTE_SUPER_ITEM_LORE").asKey().player(guiPlayer).arena(arena).value(theme).build().split(";"))
.build(), event -> {
HumanEntity humanEntity = event.getWhoClicked();

if(!(humanEntity instanceof Player))
return;
if(!(humanEntity instanceof Player))
return;

Player player = (Player) humanEntity;
IUser user = plugin.getUserManager().getUser(player);
Player player = (Player) humanEntity;
IUser user = plugin.getUserManager().getUser(player);

if(user.getStatistic("SUPER_VOTES") > 0) {
user.adjustStatistic("SUPER_VOTES", -1);
new MessageBuilder("MENU_THEME_VOTE_SUPER_USED").asKey().arena(arena).player(player).value(theme).sendArena();
arena.setTheme(theme);
arena.setTimer(0, true);
}
}));
if(user.getStatistic("SUPER_VOTES") > 0) {
user.adjustStatistic("SUPER_VOTES", -1);
new MessageBuilder("MENU_THEME_VOTE_SUPER_USED").asKey().arena(arena).player(player).value(theme).sendArena();
arena.setTheme(theme);
arena.setTimer(0, true);
}
}));
}
else {
gui.setItem(multiplied + 8, ClickableItem.of(new ItemBuilder(XMaterial.IRON_BARS.parseItem()).name("&7<-").colorizeItem().build()));
}

i++;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ Database: false
Rewards: false


# Enable the super votes in the theme vote menu
Super-Votes: true


Chat:
# Enable in game (eg. '[KIT][LEVEL] Tigerpanzer_02: hey') special formatting?
# Formatting is configurable in language.yml
Expand Down

0 comments on commit 06e5e13

Please sign in to comment.