Skip to content

Commit

Permalink
fix(close): Fixed the issues that expired requests still can be voted.
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmJos committed Oct 23, 2023
1 parent b617ff2 commit d264837
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import java.time.Duration;

public class CommonConfig extends ConfigurationRoot{
public class CommonConfig extends ConfigurationRoot {

@ConfigPath(root = true)
public static final ConfiguredValue<Boolean> DEBUG = ConfiguredValue.of(Boolean.class, false);
Expand Down Expand Up @@ -40,13 +40,15 @@ public class CommonConfig extends ConfigurationRoot{
@ConfigPath(root = true)
public static final class TIME extends ConfigurationRoot {

@HeaderComment("The time that the request will be automatically closed if it have not been handled yet.")
public static final ConfiguredValue<Duration> AUTO_CLOSE = ConfiguredValue
.builderOf(Duration.class).fromString()
.parseValue((v, d) -> TimeStringUtils.parseDuration(v))
.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.")
public static final ConfiguredValue<Duration> ADMIN_INTERVENTION = ConfiguredValue
.builderOf(Duration.class).fromString()
.parseValue((v, d) -> TimeStringUtils.parseDuration(v))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessage;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessageList;
import com.artformgames.plugin.votepass.api.data.request.RequestInformation;
import com.artformgames.plugin.votepass.core.conf.CommonConfig;
import com.artformgames.plugin.votepass.game.Main;
import com.artformgames.plugin.votepass.game.ui.GUIUtils;
import com.artformgames.plugin.votepass.game.ui.RequestIconInfo;
Expand Down Expand Up @@ -45,6 +46,7 @@ public GameUser getUser() {

public void initItems() {
Main.getInstance().getVoteManager().getRequests().values().stream()
.filter(v -> !v.isTimeout(CommonConfig.TIME.AUTO_CLOSE.getNotNull()))
.filter(value -> !value.isVoted(getUser().getKey()))
.forEachOrdered(value -> addItem(createIcon(value)));
}
Expand Down

0 comments on commit d264837

Please sign in to comment.