Skip to content

Commit

Permalink
feat: Support hidden questions for internal usage. #50
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmJos committed Feb 19, 2024
1 parent d62ece2 commit e0cf3d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cc.carm.lib.configuration.core.Configuration;
import cc.carm.lib.configuration.core.annotation.HeaderComment;
import cc.carm.lib.configuration.core.value.impl.ConfigValueMap;
import cc.carm.lib.configuration.core.value.type.ConfiguredList;
import cc.carm.lib.configuration.core.value.type.ConfiguredMap;
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessageList;
Expand Down Expand Up @@ -31,7 +32,7 @@ interface TIME extends Configuration {
.serializeValue(TimeStringUtils::serializeDuration)
.defaults(Duration.ofDays(15))
.build();

@HeaderComment("The time that the request will be sent to admin to handle if request still have no result.")
ConfiguredValue<Duration> ADMIN_INTERVENTION = ConfiguredValue
.builderOf(Duration.class).fromString()
Expand Down Expand Up @@ -152,6 +153,9 @@ interface COMMENT extends Configuration {

interface ANSWERS extends Configuration {

@HeaderComment("Hidden questions' id list, will not be displayed to voters.")
ConfiguredList<Integer> HIDDEN = ConfiguredList.of(Integer.class, 999);

@HeaderComment("How many letters are displayed in a single line")
ConfiguredValue<Integer> LETTERS_PER_LINE = ConfiguredValue.of(Integer.class, 25);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.artformgames.plugin.votepass.core.conf.TextMessages;
import com.artformgames.plugin.votepass.game.Main;
import com.artformgames.plugin.votepass.game.api.vote.PendingVote;
import com.artformgames.plugin.votepass.game.conf.PluginConfig;
import com.artformgames.plugin.votepass.game.conf.PluginMessages;
import com.artformgames.plugin.votepass.game.listener.CommentListener;
import com.artformgames.plugin.votepass.game.ui.GUIUtils;
Expand All @@ -28,6 +29,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Map;
import java.util.Optional;

public class VoteHandleGUI extends AutoPagedGUI {
Expand Down Expand Up @@ -118,7 +120,9 @@ public void onClick(Player clicker, ClickType type) {
}

public void loadAnswers() {
for (RequestAnswer answer : request.getContents().values()) {
for (Map.Entry<Integer, RequestAnswer> entry : request.getContents().entrySet()) {
if (PluginConfig.ANSWERS.HIDDEN.contains(entry.getKey())) continue; // Hidden values
RequestAnswer answer = entry.getValue();
addItem(new GUIItem(GUIUtils.loadAnswersIcon(player, answer, CONFIG.ITEMS.ANSWER)) {
@Override
public void onClick(Player clicker, ClickType type) {
Expand Down

0 comments on commit e0cf3d5

Please sign in to comment.