diff --git a/api/pom.xml b/api/pom.xml
index a7e3396..be593f3 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -6,7 +6,7 @@
com.artformgames
votepass-parent
- 1.2.5
+ 1.3.0
${project.jdk.version}
diff --git a/core/pom.xml b/core/pom.xml
index 0e4e47c..3463ee0 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -6,7 +6,7 @@
com.artformgames
votepass-parent
- 1.2.5
+ 1.3.0
${project.jdk.version}
diff --git a/core/src/main/java/com/artformgames/plugin/votepass/core/VotePassPlugin.java b/core/src/main/java/com/artformgames/plugin/votepass/core/VotePassPlugin.java
index bc77c28..6e0d6a9 100644
--- a/core/src/main/java/com/artformgames/plugin/votepass/core/VotePassPlugin.java
+++ b/core/src/main/java/com/artformgames/plugin/votepass/core/VotePassPlugin.java
@@ -1,6 +1,6 @@
package com.artformgames.plugin.votepass.core;
-import cc.carm.lib.configuration.core.ConfigurationRoot;
+import cc.carm.lib.configuration.core.Configuration;
import cc.carm.lib.easyplugin.EasyPlugin;
import cc.carm.lib.easyplugin.i18n.EasyPluginMessageProvider;
import cc.carm.lib.mineconfiguration.bukkit.MineConfiguration;
@@ -21,8 +21,8 @@ protected VotePassPlugin() {
public abstract AbstractUserManager> getUserManager();
- public void initializeConfigs(@NotNull Class extends ConfigurationRoot> configRoot,
- @NotNull Class extends ConfigurationRoot> messageRoot) {
+ public void initializeConfigs(@NotNull Class extends Configuration> configRoot,
+ @NotNull Class extends Configuration> messageRoot) {
this.configuration = new MineConfiguration(this, CommonConfig.class, CommonMessages.class);
this.configuration.initializeConfig(configRoot);
this.configuration.initializeMessage(messageRoot);
diff --git a/core/src/main/java/com/artformgames/plugin/votepass/core/database/DataManager.java b/core/src/main/java/com/artformgames/plugin/votepass/core/database/DataManager.java
index 977aef5..374650c 100644
--- a/core/src/main/java/com/artformgames/plugin/votepass/core/database/DataManager.java
+++ b/core/src/main/java/com/artformgames/plugin/votepass/core/database/DataManager.java
@@ -103,7 +103,7 @@ public CompletableFuture updateRequest(@NotNull RequestInformation requ
public @NotNull Map queryRequests(@Nullable Consumer<@NotNull TableQueryBuilder> conditions) throws SQLException {
TableQueryBuilder builder = DataTables.REQUESTS.createQuery();
if (conditions != null) conditions.accept(builder);
- return builder.build().executeFunction(query -> readRequests(query.getResultSet()), new HashMap<>());
+ return builder.build().executeFunction(query -> readRequests(query.getResultSet()), new LinkedHashMap<>());
}
private @NotNull RequestInformation readRequest(ResultSet rs) throws SQLException {
@@ -122,7 +122,7 @@ public CompletableFuture updateRequest(@NotNull RequestInformation requ
}
private @NotNull Map readRequests(ResultSet resultSet) throws SQLException {
- Map requests = new HashMap<>();
+ Map requests = new LinkedHashMap<>();
while (resultSet.next()) {
int requestID = resultSet.getInt("id");
try {
diff --git a/game/api/pom.xml b/game/api/pom.xml
index fe14c52..23badc8 100644
--- a/game/api/pom.xml
+++ b/game/api/pom.xml
@@ -6,7 +6,7 @@
com.artformgames
votepass-parent
- 1.2.5
+ 1.3.0
../../pom.xml
diff --git a/game/plugin/pom.xml b/game/plugin/pom.xml
index e7646aa..001ca26 100644
--- a/game/plugin/pom.xml
+++ b/game/plugin/pom.xml
@@ -6,7 +6,7 @@
com.artformgames
votepass-parent
- 1.2.5
+ 1.3.0
../../pom.xml
diff --git a/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/conf/PluginConfig.java b/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/conf/PluginConfig.java
index f748628..afde34d 100644
--- a/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/conf/PluginConfig.java
+++ b/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/conf/PluginConfig.java
@@ -1,12 +1,13 @@
package com.artformgames.plugin.votepass.game.conf;
-import cc.carm.lib.configuration.core.ConfigurationRoot;
+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.ConfiguredMap;
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
-import cc.carm.lib.mineconfiguration.bukkit.value.item.ConfiguredItem;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessageList;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredSound;
+import cc.carm.lib.mineconfiguration.bukkit.value.item.ConfiguredItem;
import com.artformgames.plugin.votepass.core.utils.TimeStringUtils;
import com.artformgames.plugin.votepass.game.ui.admin.AdminHandleGUI;
import com.artformgames.plugin.votepass.game.ui.admin.AdminManageGUI;
@@ -19,12 +20,12 @@
import java.time.Duration;
-public class PluginConfig extends ConfigurationRoot {
+public interface PluginConfig extends Configuration {
- public static final class SERVER extends ConfigurationRoot {
+ interface SERVER extends Configuration {
@HeaderComment({"The identify of this server", "Used for request and whitelist data"})
- public static final ConfiguredValue ID = ConfiguredValue.of(String.class, "survival");
+ ConfiguredValue ID = ConfiguredValue.of(String.class, "survival");
@HeaderComment({
@@ -32,9 +33,10 @@ public static final class SERVER extends ConfigurationRoot {
"the vote will be automatically passed, below zero means disabled auto pass.",
"You can configure different ratio based on different size votable players.",
})
- public static final ConfiguredMap AUTO_PASS_RATIO = ConfiguredMap.builderOf(Integer.class, Double.class)
+ ConfiguredMap AUTO_PASS_RATIO = ConfigValueMap.builderOf(Integer.class, Double.class)
.asTreeMap().fromString().parseKey(Integer::parseInt).parseValue(Double::parseDouble)
.defaults(m -> {
+ m.put(2, 1.0);
m.put(5, 0.8);
m.put(20, 0.6);
}).build();
@@ -44,7 +46,7 @@ public static final class SERVER extends ConfigurationRoot {
"Only users that have been online within this time will be counted as active users.",
"And only active users will be count when auto pass handling."
})
- public static final ConfiguredValue ACTIVE_ONLINE_TIME = ConfiguredValue
+ ConfiguredValue ACTIVE_ONLINE_TIME = ConfiguredValue
.builderOf(Duration.class).fromString()
.parseValue((v, d) -> TimeStringUtils.parseDuration(v))
.serializeValue(TimeStringUtils::serializeDuration)
@@ -56,7 +58,7 @@ public static final class SERVER extends ConfigurationRoot {
"This value should not be lower than 10 seconds.",
"If periods value ≤0 , the new requests will only be synced by execute 'votepass sync' command"
})
- public static final ConfiguredValue SYNC_PERIOD = ConfiguredValue
+ ConfiguredValue SYNC_PERIOD = ConfiguredValue
.builderOf(Duration.class).fromString()
.parseValue((v, d) -> TimeStringUtils.parseDuration(v))
.serializeValue(TimeStringUtils::serializeDuration)
@@ -64,7 +66,7 @@ public static final class SERVER extends ConfigurationRoot {
.build();
@HeaderComment({"Periods that notify players to handle requests"})
- public static final ConfiguredValue NOTIFY_PERIOD = ConfiguredValue
+ ConfiguredValue NOTIFY_PERIOD = ConfiguredValue
.builderOf(Duration.class).fromString()
.parseValue((v, d) -> TimeStringUtils.parseDuration(v))
.serializeValue(TimeStringUtils::serializeDuration)
@@ -74,29 +76,29 @@ public static final class SERVER extends ConfigurationRoot {
@HeaderComment({
"The kick message when the player is not in the whitelist."
})
- public static final ConfiguredMessageList KICK_MESSAGE = ConfiguredMessageList.asStrings()
+ ConfiguredMessageList KICK_MESSAGE = ConfiguredMessageList.asStrings()
.defaults("You are not in the whitelist, please request to join the whitelist.")
.build();
@HeaderComment("Whether to restrict administrators to managing only requests that require intervention.")
- public static final ConfiguredValue MANAGE_RESTRICT = ConfiguredValue.of(Boolean.class, false);
+ ConfiguredValue MANAGE_RESTRICT = ConfiguredValue.of(Boolean.class, false);
@HeaderComment({
"The commands that will be executed after player submit a vote."
})
- public static final class COMMANDS extends ConfigurationRoot {
+ interface COMMANDS extends Configuration {
- public static final ConfiguredMessageList APPROVE = ConfiguredMessageList.asStrings()
+ ConfiguredMessageList APPROVE = ConfiguredMessageList.asStrings()
.defaults("say &a%player_name% &fjust &aapproved&f the &a%(target)&f's request &6#%(id) &f!")
.params("id", "target")
.build();
- public static final ConfiguredMessageList ABSTAIN = ConfiguredMessageList.asStrings()
+ ConfiguredMessageList ABSTAIN = ConfiguredMessageList.asStrings()
.defaults("say &a%player_name% &fjust &eabstained&f to vote for the &a%(target)&f's request &6#%(id) &f!")
.params("id", "target")
.build();
- public static final ConfiguredMessageList REJECT = ConfiguredMessageList.asStrings()
+ ConfiguredMessageList REJECT = ConfiguredMessageList.asStrings()
.defaults("say &a%player_name% &fjust &cdenied&f the &a%(target)&f's request &6#%(id) &f!")
.params("id", "target")
.build();
@@ -106,48 +108,48 @@ public static final class COMMANDS extends ConfigurationRoot {
}
- public static final class SOUNDS extends ConfigurationRoot {
+ interface SOUNDS extends Configuration {
- public static final ConfiguredSound NOTIFY = ConfiguredSound.of("ENTITY_VILLAGER_CELEBRATE");
+ ConfiguredSound NOTIFY = ConfiguredSound.of("ENTITY_VILLAGER_CELEBRATE");
- public static final ConfiguredSound ABSTAIN = ConfiguredSound.of("ENTITY_VILLAGER_HURT");
+ ConfiguredSound ABSTAIN = ConfiguredSound.of("ENTITY_VILLAGER_HURT");
- public static final ConfiguredSound APPROVED = ConfiguredSound.of("ENTITY_VILLAGER_CELEBRATE");
+ ConfiguredSound APPROVED = ConfiguredSound.of("ENTITY_VILLAGER_CELEBRATE");
- public static final ConfiguredSound REJECT = ConfiguredSound.of("ENTITY_VILLAGER_NO");
+ ConfiguredSound REJECT = ConfiguredSound.of("ENTITY_VILLAGER_NO");
}
- public static final class COMMENT extends ConfigurationRoot {
+ interface COMMENT extends Configuration {
@HeaderComment("Max letters in a single comment")
- public static final ConfiguredValue MAX = ConfiguredValue.of(Integer.class, 120);
+ ConfiguredValue MAX = ConfiguredValue.of(Integer.class, 120);
@HeaderComment("How many letters are displayed in a single line")
- public static final ConfiguredValue LINE = ConfiguredValue.of(Integer.class, 25);
+ ConfiguredValue LINE = ConfiguredValue.of(Integer.class, 25);
}
- public static final class ANSWERS extends ConfigurationRoot {
+ interface ANSWERS extends Configuration {
@HeaderComment("How many letters are displayed in a single line")
- public static final ConfiguredValue LETTERS_PER_LINE = ConfiguredValue.of(Integer.class, 25);
+ ConfiguredValue LETTERS_PER_LINE = ConfiguredValue.of(Integer.class, 25);
@HeaderComment("Max lines that displayed in lore")
- public static final ConfiguredValue MAX_LINES = ConfiguredValue.of(Integer.class, 6);
+ ConfiguredValue MAX_LINES = ConfiguredValue.of(Integer.class, 6);
@HeaderComment("Extra lore if answers are too long, tell voters to click to view details.")
- public static final ConfiguredMessageList EXTRA = ConfiguredMessageList.ofStrings(
+ ConfiguredMessageList EXTRA = ConfiguredMessageList.ofStrings(
"&f&o ... More in details!"
);
}
- public static final class ICON extends ConfigurationRoot {
+ interface ICON extends Configuration {
- public static final ConfiguredItem INFO = ConfiguredItem.create()
+ ConfiguredItem INFO = ConfiguredItem.create()
.defaultType(Material.PLAYER_HEAD)
.defaultName("&7#%(request_id) &e&l%(name)")
.defaultLore(
@@ -178,18 +180,18 @@ public static final class ICON extends ConfigurationRoot {
}
@SuppressWarnings("unused")
- public static final class GUIS extends ConfigurationRoot {
+ interface GUIS extends Configuration {
- public static final Class> ABSTAIN_TOGGLE = AbstainToggleGUI.CONFIG.class;
+ Class> ABSTAIN_TOGGLE = AbstainToggleGUI.CONFIG.class;
- public static final Class> REQUEST_LIST = RequestListGUI.CONFIG.class;
- public static final Class> REQUEST_COMMENTS = RequestCommentsGUI.CONFIG.class;
+ Class> REQUEST_LIST = RequestListGUI.CONFIG.class;
+ Class> REQUEST_COMMENTS = RequestCommentsGUI.CONFIG.class;
- public static final Class> VOTE_HANDLE = VoteHandleGUI.CONFIG.class;
- public static final Class> VOTE_CONFIRM = VoteConfirmGUI.CONFIG.class;
+ Class> VOTE_HANDLE = VoteHandleGUI.CONFIG.class;
+ Class> VOTE_CONFIRM = VoteConfirmGUI.CONFIG.class;
- public static final Class> ADMIN_MANAGE = AdminManageGUI.CONFIG.class;
- public static final Class> ADMIN_HANDLE = AdminHandleGUI.CONFIG.class;
+ Class> ADMIN_MANAGE = AdminManageGUI.CONFIG.class;
+ Class> ADMIN_HANDLE = AdminHandleGUI.CONFIG.class;
}
diff --git a/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/conf/PluginMessages.java b/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/conf/PluginMessages.java
index b0e3014..a9b4b39 100644
--- a/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/conf/PluginMessages.java
+++ b/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/conf/PluginMessages.java
@@ -1,17 +1,18 @@
package com.artformgames.plugin.votepass.game.conf;
-import cc.carm.lib.configuration.core.ConfigurationRoot;
+import cc.carm.lib.configuration.core.Configuration;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessageList;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredSound;
-import com.artformgames.plugin.votepass.core.conf.TextMessages;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.Sound;
-public class PluginMessages extends TextMessages {
+import static com.artformgames.plugin.votepass.core.conf.TextMessages.list;
- public static final class COMMAND extends ConfigurationRoot {
+public interface PluginMessages extends Configuration {
- public static final ConfiguredMessageList USER = list()
+ interface COMMAND extends Configuration {
+
+ ConfiguredMessageList USER = list()
.defaults(
"&e&lVotePass &fCommands &7(/votepass)",
"&8#&f requests",
@@ -22,7 +23,7 @@ public static final class COMMAND extends ConfigurationRoot {
"&8-&7 Enable/Disable the auto abstain function."
).build();
- public static final ConfiguredMessageList ADMIN = list()
+ ConfiguredMessageList ADMIN = list()
.defaults(
"&8#&f manage",
"&8-&7 Open the admin manage GUI.",
@@ -41,7 +42,7 @@ public static final class COMMAND extends ConfigurationRoot {
).build();
}
- public static class USERS extends ConfigurationRoot {
+ interface USERS extends Configuration {
public static final ConfiguredMessageList NEVER_JOINED = list()
.defaults(
"&fUser %(name) is never joined in the server,",
@@ -67,39 +68,39 @@ public static class USERS extends ConfigurationRoot {
"&fUser %(name) is not in the whitelist."
).params("name").build();
- public static final class ADD extends ConfigurationRoot {
+ public interface ADD extends Configuration {
- public static final ConfiguredMessageList START = list()
+ ConfiguredMessageList START = list()
.defaults(
"&fTry to add user %(name) to whitelist...",
"&fThis may take a while, please wait patiently."
).params("name").build();
- public static final ConfiguredMessageList SUCCESS = list()
+ ConfiguredMessageList SUCCESS = list()
.defaults(
"&a&lSuccess! &fUser &e%(name) &fhas been added to whitelist, cost &a%(time)&fms."
).params("name", "time").build();
- public static final ConfiguredMessageList FAILED = list()
+ ConfiguredMessageList FAILED = list()
.defaults(
"&c&lFailed to add! &fThere are some errors, please see console for details."
).params("amount", "time").build();
}
- public static final class REMOVE extends ConfigurationRoot {
+ public interface REMOVE extends Configuration {
- public static final ConfiguredMessageList START = list()
+ ConfiguredMessageList START = list()
.defaults(
"&fTry to remove user %(name) from whitelist...",
"&fThis may take a while, please wait patiently."
).params("name").build();
- public static final ConfiguredMessageList SUCCESS = list()
+ ConfiguredMessageList SUCCESS = list()
.defaults(
"&a&lSuccess! &fUser &e%(name) &fhas been removed from whitelist, cost &a%(time)&fms."
).params("name", "time").build();
- public static final ConfiguredMessageList FAILED = list()
+ ConfiguredMessageList FAILED = list()
.defaults(
"&c&lFailed to remove! &fThere are some errors, please see console for details."
).build();
@@ -108,7 +109,7 @@ public static final class REMOVE extends ConfigurationRoot {
}
- public static class MIGRATE extends ConfigurationRoot {
+ interface MIGRATE extends Configuration {
public static final ConfiguredMessageList START = list()
.defaults(
@@ -128,7 +129,7 @@ public static class MIGRATE extends ConfigurationRoot {
}
- public static class SYNC extends ConfigurationRoot {
+ interface SYNC extends Configuration {
public static final ConfiguredMessageList START = list()
.defaults(
@@ -143,7 +144,7 @@ public static class SYNC extends ConfigurationRoot {
}
- public static class VERIFY extends ConfigurationRoot {
+ interface VERIFY extends Configuration {
public static final ConfiguredMessageList START = list()
.defaults(
@@ -158,7 +159,7 @@ public static class VERIFY extends ConfigurationRoot {
}
- public static class ABSTAIN extends ConfigurationRoot {
+ interface ABSTAIN extends Configuration {
public static final ConfiguredMessageList ABSTAINED = list()
.defaults(
@@ -173,7 +174,7 @@ public static class ABSTAIN extends ConfigurationRoot {
}
- public static class VOTE extends ConfigurationRoot {
+ interface VOTE extends Configuration {
public static final ConfiguredMessageList NOT_VOTED = list()
.defaults(
@@ -214,7 +215,7 @@ public static class VOTE extends ConfigurationRoot {
}
- public static class ADMIN extends ConfigurationRoot {
+ interface ADMIN extends Configuration {
public static final ConfiguredSound SOUND = ConfiguredSound.of(Sound.ENTITY_VILLAGER_CELEBRATE);
@@ -237,7 +238,7 @@ public static class ADMIN extends ConfigurationRoot {
}
- public static class COMMENT extends ConfigurationRoot {
+ interface COMMENT extends Configuration {
public static final ConfiguredMessageList START = list()
.defaults(
diff --git a/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/ui/admin/AdminHandleGUI.java b/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/ui/admin/AdminHandleGUI.java
index 98ae769..8aaf030 100644
--- a/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/ui/admin/AdminHandleGUI.java
+++ b/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/ui/admin/AdminHandleGUI.java
@@ -4,11 +4,12 @@
import cc.carm.lib.easyplugin.gui.GUIItem;
import cc.carm.lib.easyplugin.gui.GUIType;
import cc.carm.lib.easyplugin.gui.paged.AutoPagedGUI;
-import cc.carm.lib.mineconfiguration.bukkit.value.item.ConfiguredItem;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessage;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessageList;
+import cc.carm.lib.mineconfiguration.bukkit.value.item.ConfiguredItem;
import com.artformgames.plugin.votepass.api.data.request.RequestAnswer;
import com.artformgames.plugin.votepass.api.data.request.RequestInformation;
+import com.artformgames.plugin.votepass.core.conf.TextMessages;
import com.artformgames.plugin.votepass.game.Main;
import com.artformgames.plugin.votepass.game.conf.PluginMessages;
import com.artformgames.plugin.votepass.game.ui.GUIUtils;
@@ -143,7 +144,7 @@ public static final class ITEMS extends ConfigurationRoot {
public static final class BOOK extends ConfigurationRoot {
- public static final ConfiguredMessageList RETURN = PluginMessages.list()
+ public static final ConfiguredMessageList RETURN = TextMessages.list()
.defaults(
"&0All answers have been displayed.",
"[&2&l[Click here]](hover=Click to return to the details page and continue processing related answers. run_command=/votepass manage %(id))&0 to return to the request details page."
diff --git a/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/ui/user/AbstainToggleGUI.java b/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/ui/user/AbstainToggleGUI.java
index 325f995..5dc1a7e 100644
--- a/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/ui/user/AbstainToggleGUI.java
+++ b/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/ui/user/AbstainToggleGUI.java
@@ -2,6 +2,7 @@
import cc.carm.lib.configuration.core.ConfigurationRoot;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessageList;
+import com.artformgames.plugin.votepass.core.conf.TextMessages;
import com.artformgames.plugin.votepass.game.Main;
import com.artformgames.plugin.votepass.game.api.whiteist.WhitelistedUserData;
import com.artformgames.plugin.votepass.game.conf.PluginMessages;
@@ -40,7 +41,7 @@ public static void open(Player player) {
public static final class CONFIG extends ConfigurationRoot {
- public static final ConfiguredMessageList ENABLED = PluginMessages.list()
+ public static final ConfiguredMessageList ENABLED = TextMessages.list()
.defaults(
"&8Your current status is",
"&e&labstaining all vote rights&8.",
@@ -50,7 +51,7 @@ public static final class CONFIG extends ConfigurationRoot {
" "
).build();
- public static final ConfiguredMessageList DISABLED = PluginMessages.list()
+ public static final ConfiguredMessageList DISABLED = TextMessages.list()
.defaults(
"&8Your current status is",
"&a&lParticipating in voting&8.",
@@ -59,7 +60,7 @@ public static final class CONFIG extends ConfigurationRoot {
" ",
" "
).build();
- public static final ConfiguredMessageList TOGGLE = PluginMessages.list()
+ public static final ConfiguredMessageList TOGGLE = TextMessages.list()
.defaults(
"You can choose whether to automatically waive all future requests.",
" ",
diff --git a/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/ui/vote/VoteHandleGUI.java b/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/ui/vote/VoteHandleGUI.java
index 0de172a..a6d32ee 100644
--- a/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/ui/vote/VoteHandleGUI.java
+++ b/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/ui/vote/VoteHandleGUI.java
@@ -4,12 +4,13 @@
import cc.carm.lib.easyplugin.gui.GUIItem;
import cc.carm.lib.easyplugin.gui.GUIType;
import cc.carm.lib.easyplugin.gui.paged.AutoPagedGUI;
-import cc.carm.lib.mineconfiguration.bukkit.value.item.ConfiguredItem;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessage;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessageList;
+import cc.carm.lib.mineconfiguration.bukkit.value.item.ConfiguredItem;
import com.artformgames.plugin.votepass.api.data.request.RequestAnswer;
import com.artformgames.plugin.votepass.api.data.request.RequestInformation;
import com.artformgames.plugin.votepass.api.data.vote.VoteDecision;
+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.PluginMessages;
@@ -209,7 +210,7 @@ public static final class ITEMS extends ConfigurationRoot {
public static final class BOOK extends ConfigurationRoot {
- public static final ConfiguredMessageList RETURN = PluginMessages.list()
+ public static final ConfiguredMessageList RETURN = TextMessages.list()
.defaults(
"&0All answers have been displayed.",
"[&2&l[Click here]](hover=Click to return to the details page and continue processing related answers. run_command=/votepass handle %(id))&0 to return to the request details page."
diff --git a/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/vote/VoteManagerImpl.java b/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/vote/VoteManagerImpl.java
index 83ff1bd..4753945 100644
--- a/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/vote/VoteManagerImpl.java
+++ b/game/plugin/src/main/java/com/artformgames/plugin/votepass/game/vote/VoteManagerImpl.java
@@ -57,16 +57,14 @@ public int sync() {
@Override
public double getAutoPassRatio(int total) {
Map ratioMap = PluginConfig.SERVER.AUTO_PASS_RATIO.getNotNull();
- if (ratioMap.isEmpty()) return 0;
+ if (ratioMap.isEmpty()) return 1;
- double ratio = 0;
+ double ratio = 1;
for (Map.Entry entry : ratioMap.entrySet()) {
- if (ratio == 0 || total > entry.getKey()) {
- ratio = entry.getValue();
- } else {
- return ratio;
- }
+ if (total < entry.getKey()) break;
+ ratio = entry.getValue();
}
+
return ratio;
}
diff --git a/lobby/api/pom.xml b/lobby/api/pom.xml
index 78f92b3..37bbfe9 100644
--- a/lobby/api/pom.xml
+++ b/lobby/api/pom.xml
@@ -6,7 +6,7 @@
com.artformgames
votepass-parent
- 1.2.5
+ 1.3.0
../../pom.xml
diff --git a/lobby/api/src/main/java/com/artformgames/plugin/votepass/lobby/api/request/UserRequestManager.java b/lobby/api/src/main/java/com/artformgames/plugin/votepass/lobby/api/request/UserRequestManager.java
index 79d41dd..aa08f7e 100644
--- a/lobby/api/src/main/java/com/artformgames/plugin/votepass/lobby/api/request/UserRequestManager.java
+++ b/lobby/api/src/main/java/com/artformgames/plugin/votepass/lobby/api/request/UserRequestManager.java
@@ -4,6 +4,7 @@
import com.artformgames.plugin.votepass.api.user.UserKey;
import com.artformgames.plugin.votepass.lobby.api.data.user.PendingRequest;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.concurrent.CompletableFuture;
@@ -13,4 +14,6 @@ public interface UserRequestManager {
@NotNull CompletableFuture update(@NotNull RequestInformation content);
+ @NotNull CompletableFuture<@Nullable RequestInformation> lastFailed(@NotNull UserKey key, @NotNull String server);
+
}
diff --git a/lobby/plugin/pom.xml b/lobby/plugin/pom.xml
index 29d9167..3fd5cc8 100644
--- a/lobby/plugin/pom.xml
+++ b/lobby/plugin/pom.xml
@@ -6,7 +6,7 @@
com.artformgames
votepass-parent
- 1.2.5
+ 1.3.0
../../pom.xml
diff --git a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/Main.java b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/Main.java
index 1d0f051..8840719 100644
--- a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/Main.java
+++ b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/Main.java
@@ -4,8 +4,6 @@
import com.artformgames.plugin.votepass.core.VotePassPlugin;
import com.artformgames.plugin.votepass.core.database.DataManager;
import com.artformgames.plugin.votepass.core.listener.UserListener;
-import com.artformgames.plugin.votepass.lobby.api.request.UserRequestManager;
-import com.artformgames.plugin.votepass.lobby.api.server.ServerSettingsManager;
import com.artformgames.plugin.votepass.lobby.command.MainCommand;
import com.artformgames.plugin.votepass.lobby.conf.PluginConfig;
import com.artformgames.plugin.votepass.lobby.conf.PluginMessages;
@@ -14,9 +12,6 @@
import com.artformgames.plugin.votepass.lobby.request.RequestManager;
import com.artformgames.plugin.votepass.lobby.server.SettingsManager;
import com.artformgames.plugin.votepass.lobby.user.UsersManager;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class Main extends VotePassPlugin implements VotePassLobby {
@@ -114,12 +109,12 @@ public static Main getInstance() {
}
@Override
- public @NotNull ServerSettingsManager getServersManager() {
+ public @NotNull SettingsManager getServersManager() {
return this.settingsManager;
}
@Override
- public @NotNull UserRequestManager getRequestManager() {
+ public @NotNull RequestManager getRequestManager() {
return this.requestManager;
}
}
diff --git a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/command/user/RequestCommand.java b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/command/user/RequestCommand.java
index 5d92a4b..89cce75 100644
--- a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/command/user/RequestCommand.java
+++ b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/command/user/RequestCommand.java
@@ -3,6 +3,7 @@
import cc.carm.lib.easyplugin.command.SimpleCompleter;
import cc.carm.lib.easyplugin.command.SubCommand;
import com.artformgames.plugin.votepass.api.data.request.RequestInformation;
+import com.artformgames.plugin.votepass.lobby.Main;
import com.artformgames.plugin.votepass.lobby.VotePassLobbyAPI;
import com.artformgames.plugin.votepass.lobby.api.data.server.ServerSettings;
import com.artformgames.plugin.votepass.lobby.api.data.user.PendingRequest;
@@ -10,6 +11,7 @@
import com.artformgames.plugin.votepass.lobby.command.MainCommand;
import com.artformgames.plugin.votepass.lobby.conf.PluginMessages;
import com.artformgames.plugin.votepass.lobby.ui.RequestingGUI;
+import com.artformgames.plugin.votepass.lobby.ui.ResubmitGUI;
import com.artformgames.plugin.votepass.lobby.ui.RulesBookUI;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -44,17 +46,26 @@ public Void execute(JavaPlugin plugin, CommandSender sender, String[] args) thro
if (settings.rules() != null) {
PluginMessages.RULES.send(player, settings.name());
RulesBookUI.open(player, settings.id(), settings.rules());
- } else {
- PendingRequest pendingRequest = requestData.getPendingRequest();
- if (pendingRequest != null && pendingRequest.getSettings().equals(settings)) {
- RequestingGUI.open(player, requestData, pendingRequest);
- } else {
- PluginMessages.ACCEPTED.send(player, settings.name());
- RequestingGUI.open(player, requestData, requestData.createPendingRequest(settings));
- }
+ return null;
+ }
+ PendingRequest pendingRequest = requestData.getPendingRequest();
+ if (pendingRequest != null && pendingRequest.getSettings().equals(settings)) {
+ RequestingGUI.open(player, requestData, pendingRequest);
+ return null;
}
+ PluginMessages.ACCEPTED.send(player, settings.name());
+ Main.getInstance().getRequestManager()
+ .lastFailed(requestData.getKey(), settings.id())
+ .thenAccept(lastFailed -> Main.getInstance().getScheduler().run(() -> {
+ if (lastFailed == null) {
+ RequestingGUI.open(player, requestData, requestData.createPendingRequest(settings));
+ } else {
+ ResubmitGUI.open(player, requestData, settings, lastFailed);
+ }
+ }));
+
return null;
}
diff --git a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/command/user/RuleAcceptCommand.java b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/command/user/RuleAcceptCommand.java
index 45b3767..b3704f7 100644
--- a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/command/user/RuleAcceptCommand.java
+++ b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/command/user/RuleAcceptCommand.java
@@ -1,6 +1,7 @@
package com.artformgames.plugin.votepass.lobby.command.user;
import cc.carm.lib.easyplugin.command.SubCommand;
+import com.artformgames.plugin.votepass.lobby.Main;
import com.artformgames.plugin.votepass.lobby.VotePassLobbyAPI;
import com.artformgames.plugin.votepass.lobby.api.data.server.ServerSettings;
import com.artformgames.plugin.votepass.lobby.api.data.user.PendingRequest;
@@ -8,6 +9,7 @@
import com.artformgames.plugin.votepass.lobby.command.MainCommand;
import com.artformgames.plugin.votepass.lobby.conf.PluginMessages;
import com.artformgames.plugin.votepass.lobby.ui.RequestingGUI;
+import com.artformgames.plugin.votepass.lobby.ui.ResubmitGUI;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
@@ -41,7 +43,15 @@ public Void execute(JavaPlugin plugin, CommandSender sender, String[] args) {
RequestingGUI.open(player, data, pendingRequest);
} else {
PluginMessages.ACCEPTED.send(player, settings.name());
- RequestingGUI.open(player, data, data.createPendingRequest(settings));
+ Main.getInstance().getRequestManager()
+ .lastFailed(data.getKey(), settings.id())
+ .thenAccept(lastFailed -> Main.getInstance().getScheduler().run(() -> {
+ if (lastFailed == null) {
+ RequestingGUI.open(player, data, data.createPendingRequest(settings));
+ } else {
+ ResubmitGUI.open(player, data, settings, lastFailed);
+ }
+ }));
}
return null;
diff --git a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/conf/PluginConfig.java b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/conf/PluginConfig.java
index 868beaf..225be31 100644
--- a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/conf/PluginConfig.java
+++ b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/conf/PluginConfig.java
@@ -1,6 +1,7 @@
package com.artformgames.plugin.votepass.lobby.conf;
-import cc.carm.lib.configuration.core.ConfigurationRoot;
+import cc.carm.lib.configuration.core.Configuration;
+import cc.carm.lib.configuration.core.annotation.HeaderComment;
import cc.carm.lib.configuration.core.value.type.ConfiguredList;
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessage;
@@ -8,26 +9,26 @@
import cc.carm.lib.mineconfiguration.bukkit.value.item.ConfiguredItem;
import org.bukkit.Material;
-public class PluginConfig extends ConfigurationRoot {
+public interface PluginConfig extends Configuration {
- public static final class SERVERS extends ConfigurationRoot {
+ interface SERVERS extends Configuration {
- public static final ConfiguredValue FOLDER_NAME = ConfiguredValue.of(String.class, "servers");
+ ConfiguredValue FOLDER_NAME = ConfiguredValue.of(String.class, "servers");
- public static final ConfiguredList DISABLED = ConfiguredList.of(String.class);
+ ConfiguredList DISABLED = ConfiguredList.of(String.class);
}
- public static final class RULES extends ConfigurationRoot {
+ interface RULES extends Configuration {
- public static final class BOOK extends ConfigurationRoot {
+ interface BOOK extends Configuration {
- public static final ConfiguredMessageList ACCEPT = ConfiguredMessageList.asStrings()
+ ConfiguredMessageList ACCEPT = ConfiguredMessageList.asStrings()
.defaults("[&a&l[ACCEPT THE RULE]](hover=&fClick to &a&lconfirm and accept the server rules&f. run_command=/votepass accept %(server))")
.params("server")
.build();
- public static final ConfiguredMessageList DENY = ConfiguredMessageList.asStrings()
+ ConfiguredMessageList DENY = ConfiguredMessageList.asStrings()
.defaults("[&c&l[DENY THE RULE]](hover=&fClick to &c&lrefuse the server rules&f. run_command=/votepass deny %(server))")
.params("server")
.build();
@@ -36,31 +37,32 @@ public static final class BOOK extends ConfigurationRoot {
}
- public static final class ANSWERING extends ConfigurationRoot {
+ interface ANSWERING extends Configuration {
- public static final ConfiguredMessage TITLE = ConfiguredMessage.asString()
+ ConfiguredMessage TITLE = ConfiguredMessage.asString()
.defaults("&a&lRequest &8| &f%(server)")
.params("server")
.build();
- public static final class BOOK_ITEM extends ConfigurationRoot {
+ interface BOOK_ITEM extends Configuration {
- public static final ConfiguredValue SLOT = ConfiguredValue.of(Integer.class, 8);
+ @HeaderComment("Which slot should we put the answering book in players inventory? (0~8)")
+ ConfiguredValue SLOT = ConfiguredValue.of(Integer.class, 8);
- public static final ConfiguredMessage NAME = ConfiguredMessage.asString()
+ ConfiguredMessage NAME = ConfiguredMessage.asString()
.defaults("&c&lAnswering book &8(Right click)")
.build();
- public static final ConfiguredMessageList LORE = ConfiguredMessageList.asStrings()
+ ConfiguredMessageList LORE = ConfiguredMessageList.asStrings()
.defaults("&fOpen and answer your questions!")
.build();
}
- public static final class ITEMS extends ConfigurationRoot {
+ interface ITEMS extends Configuration {
- public static final ConfiguredItem REQUIRED = ConfiguredItem.create()
+ ConfiguredItem REQUIRED = ConfiguredItem.create()
.defaultType(Material.WRITABLE_BOOK)
.defaultName("&8Q: &f%(title)")
.defaultLore(
@@ -70,7 +72,7 @@ public static final class ITEMS extends ConfigurationRoot {
"&e&l● &eClick and answer!"
).params("title", "description").build();
- public static final ConfiguredItem FINISHED = ConfiguredItem.create()
+ ConfiguredItem FINISHED = ConfiguredItem.create()
.defaultType(Material.WRITTEN_BOOK)
.defaultName("&8Q: &f%(title)")
.defaultLore(
@@ -82,19 +84,19 @@ public static final class ITEMS extends ConfigurationRoot {
).params("title").build();
- public static final ConfiguredItem CONFIRM = ConfiguredItem.create()
+ ConfiguredItem CONFIRM = ConfiguredItem.create()
.defaultType(Material.EMERALD)
.defaultName("&a&lConfirm and submit the request")
.defaultLore(" ", "&fClick to confirm and submit your request.")
.build();
- public static final ConfiguredItem CANCEL = ConfiguredItem.create()
+ ConfiguredItem CANCEL = ConfiguredItem.create()
.defaultType(Material.REDSTONE)
.defaultName("&c&lCancel the request")
.defaultLore(" ", "&fClick to cancel your request.")
.build();
- public static final ConfiguredItem PENDING = ConfiguredItem.create()
+ ConfiguredItem PENDING = ConfiguredItem.create()
.defaultType(Material.BARRIER)
.defaultName("&e&lPlease answer all the questions")
.defaultLore(
@@ -104,8 +106,56 @@ public static final class ITEMS extends ConfigurationRoot {
).build();
}
+ }
+
+ interface RESUBMIT extends Configuration {
+
+ ConfiguredMessage TITLE = ConfiguredMessage.asString()
+ .defaults("&a&lRequest &8| &f%(server)")
+ .params("server")
+ .build();
+ interface ITEMS extends Configuration {
+ ConfiguredItem INFO = ConfiguredItem.create()
+ .defaultType(Material.NAME_TAG)
+ .defaultName("&ePrevious request &8#&f%(id)")
+ .defaultLore(
+ " ",
+ "&fWe found a previous request with",
+ " &a Approved %(approve)",
+ " &c Rejected %(reject)",
+ " &e Abstained %(abstain)",
+ "&7&oMaybe the request wasn't rejected, ",
+ "&7&obut simply closed automatically because it took too long.",
+ " ",
+ "&e Would you like to modify your previous request",
+ "&e and resubmit it for the next round of voting?",
+ " "
+ ).params("id", "approve", "reject", "abstain").build();
+
+ ConfiguredItem ANSWERS = ConfiguredItem.create()
+ .defaultType(Material.WRITTEN_BOOK)
+ .defaultName("&8Q: &f%(question)")
+ .defaultLore(
+ " ",
+ "#answers#",
+ " "
+ ).params("id", "question", "answers").build();
+
+ ConfiguredItem CONFIRM = ConfiguredItem.create()
+ .defaultType(Material.EMERALD)
+ .defaultName("&a&lYes, I'd like to modify previous request.")
+ .defaultLore(" ", "&fClick to confirm and modify your previous request.")
+ .build();
+
+ ConfiguredItem CANCEL = ConfiguredItem.create()
+ .defaultType(Material.REDSTONE)
+ .defaultName("&c&lNope, create a new request.")
+ .defaultLore(" ", "&fClick to create your new request.")
+ .build();
+
+ }
}
}
diff --git a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/conf/PluginMessages.java b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/conf/PluginMessages.java
index bca87b3..d69b63c 100644
--- a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/conf/PluginMessages.java
+++ b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/conf/PluginMessages.java
@@ -1,23 +1,24 @@
package com.artformgames.plugin.votepass.lobby.conf;
-import cc.carm.lib.configuration.core.ConfigurationRoot;
+import cc.carm.lib.configuration.core.Configuration;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredMessageList;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredSound;
-import com.artformgames.plugin.votepass.core.conf.TextMessages;
import net.md_5.bungee.api.chat.BaseComponent;
-public class PluginMessages extends TextMessages {
+import static com.artformgames.plugin.votepass.core.conf.TextMessages.list;
- public static final class COMMAND extends ConfigurationRoot {
+public interface PluginMessages extends Configuration {
- public static final ConfiguredMessageList USER = list()
+ interface COMMAND extends Configuration {
+
+ ConfiguredMessageList USER = list()
.defaults(
"&e&lVotePass &fCommands &7(/votepass)",
"&8#&f request &e",
"&8-&7 Submit a whitelist request for a specific server."
).build();
- public static final ConfiguredMessageList ADMIN = list()
+ ConfiguredMessageList ADMIN = list()
.defaults(
"&8#&f toggle ",
"&8-&7 Enable/Disable the vote application for the corresponding server.",
@@ -26,93 +27,93 @@ public static final class COMMAND extends ConfigurationRoot {
).build();
}
- public static final ConfiguredMessageList NOT_EXISTS = list()
+ ConfiguredMessageList NOT_EXISTS = list()
.defaults(
"&fThere is no server configuration with ID &e%(server) &f, please check."
).params("server").build();
- public static final ConfiguredMessageList DISABLED = list()
+ ConfiguredMessageList DISABLED = list()
.defaults(
"&lSorry! &fHowever, the whitelist application for &e%(server) &f is not open yet, please refer to the server chat group for details."
).params("server").build();
- public static final ConfiguredMessageList RULES = list()
+ ConfiguredMessageList RULES = list()
.defaults(
"&fYou first need to &a understand and accept &6%(name) &f server rules, please read carefully to make sure you know it."
).params("name").build();
- public static final ConfiguredMessageList ACCEPTED = list()
+ ConfiguredMessageList ACCEPTED = list()
.defaults(
"&fYou HAVE &aknowledged and accepted the server rules of &6%(name) &f, and then you can fill in your application content."
).params("name").build();
- public static final ConfiguredMessageList REJECTED = list()
+ ConfiguredMessageList REJECTED = list()
.defaults(
"&c&lSorry! &fBut you have &c&lrejected server rules for &6%(name) &f, so you cannot join this server."
).params("name").build();
- public static final ConfiguredMessageList WHITELISTED = list()
+ ConfiguredMessageList WHITELISTED = list()
.defaults(
"&fYou already have the whitelist of &e%(name) &f, join the game now~"
).params("name").build();
- public static final ConfiguredMessageList PENDING = list()
+ ConfiguredMessageList PENDING = list()
.defaults(
"&fYou already have a &6%(name) &f whitelist application with tracking number &e%(id) &f being reviewed, please wait patiently for the result~"
).params("id", "name").build();
- public static final ConfiguredMessageList WRITING = list()
+ ConfiguredMessageList WRITING = list()
.defaults(
"&fWe placed a writable book in your NO.&e%(slot) &f slot for answering the question &r%(question) &f,",
"&fPlease right-click to open it and fill in the content you want to tell us, and click \"&a&lFinish&f\" directly after filling in to save."
).params("slot", "question").build();
- public static final ConfiguredMessageList CANCELLED = list()
+ ConfiguredMessageList CANCELLED = list()
.defaults(
"&fYou have canceled your application for &6%(name) &f's white list, you can re-apply later."
).params("name").build();
- public static final ConfiguredMessageList POSTED = list()
+ ConfiguredMessageList POSTED = list()
.defaults(
"&fWe has successfully submitted the &6%(name) &f whitelist application for you. ",
"&fThe application number is &e%(id) &f. Please wait patiently for the result."
).params("id", "name").build();
- public static final ConfiguredMessageList ERROR = list()
+ ConfiguredMessageList ERROR = list()
.defaults(
"&fWe failed to submitted the application, please contact the administrator."
).params("name").build();
- public static class FEEDBACK extends ConfigurationRoot {
+ interface FEEDBACK extends Configuration {
- public static final ConfiguredSound SOUND = ConfiguredSound.of("ENTITY_CHICKEN_EGG");
+ ConfiguredSound SOUND = ConfiguredSound.of("ENTITY_CHICKEN_EGG");
- public static final ConfiguredMessageList APPROVED = list()
+ ConfiguredMessageList APPROVED = list()
.defaults(
"&f Your application for &6%(name) &fserver whitelist &8#&e%(request_id)&f has been approved, welcome to join our family!"
).params("request_id", "name").build();
- public static final ConfiguredMessageList REJECTED = list()
+ ConfiguredMessageList REJECTED = list()
.defaults(
"&fYour application for &6%(name) &fserver whitelist &8#&e%(request_id)&f has been rejected, please check the application content and try again."
).params("request_id", "name").build();
- public static final ConfiguredMessageList EXPIRED = list()
+ ConfiguredMessageList EXPIRED = list()
.defaults(
"&fYour application for &6%(name) &fserver whitelist &8#&e%(request_id)&f has expired because no enough users to vote. please try again and call on more users to vote for you."
).params("request_id", "name").build();
}
- public static class TOGGLE extends ConfigurationRoot {
+ interface TOGGLE extends Configuration {
- public static final ConfiguredMessageList DISABLED = list()
+ ConfiguredMessageList DISABLED = list()
.defaults(
"&fThe application for &6%(name) &fserver whitelist now has successfully &c&ldisabled&f!"
).params("name").build();
- public static final ConfiguredMessageList ENABLED = list()
+ ConfiguredMessageList ENABLED = list()
.defaults(
"&fThe application for &6%(name) &fserver whitelist now has successfully &a&lenabled &f!"
).params("name").build();
diff --git a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/request/RequestManager.java b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/request/RequestManager.java
index d989491..f7d06dd 100644
--- a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/request/RequestManager.java
+++ b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/request/RequestManager.java
@@ -13,6 +13,7 @@
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.HashSet;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
public class RequestManager implements UserRequestManager {
@@ -55,4 +56,27 @@ public class RequestManager implements UserRequestManager {
}
});
}
+
+ @Override
+ public @NotNull CompletableFuture lastFailed(@NotNull UserKey key, @NotNull String server) {
+ return CompletableFuture.supplyAsync(() -> {
+ try {
+ Map requests = Main.getInstance().getDataManager().queryRequests(b -> {
+ b.addCondition("server", server);
+ b.addCondition("user", key.id());
+ b.addCondition("result", RequestResult.REJECTED.getID());
+ b.addNotNullCondition("closed_time");
+ b.orderBy("create_time", false);
+ b.setLimit(1);
+ });
+ if (requests.isEmpty()) return null;
+ else return requests.values().iterator().next();
+ } catch (Exception ex) {
+ Main.severe("Error occurred when loading " + key.name() + "'s request, please check the configuration.");
+ ex.printStackTrace();
+ return null;
+ }
+ });
+ }
+
}
diff --git a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/ui/RequestingGUI.java b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/ui/RequestingGUI.java
index b1751f5..c12abe0 100644
--- a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/ui/RequestingGUI.java
+++ b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/ui/RequestingGUI.java
@@ -6,6 +6,7 @@
import cc.carm.lib.easyplugin.utils.ColorParser;
import cc.carm.lib.easyplugin.utils.ItemStackFactory;
import cc.carm.lib.mineconfiguration.bukkit.value.item.ConfiguredItem;
+import cc.carm.lib.mineconfiguration.bukkit.value.item.PreparedItem;
import com.artformgames.plugin.votepass.api.data.request.RequestAnswer;
import com.artformgames.plugin.votepass.api.data.request.RequestInformation;
import com.artformgames.plugin.votepass.core.conf.CommonConfig;
@@ -16,18 +17,17 @@
import com.artformgames.plugin.votepass.lobby.api.user.LobbyUserData;
import com.artformgames.plugin.votepass.lobby.conf.PluginConfig;
import com.artformgames.plugin.votepass.lobby.conf.PluginMessages;
-import com.google.common.collect.Lists;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.upperlevel.spigot.book.BookUtil;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
public class RequestingGUI extends AutoPagedGUI {
@@ -42,7 +42,11 @@ public static void open(Player player, LobbyUserData data, PendingRequest reques
@NotNull PendingRequest pendingRequest;
public RequestingGUI(@NotNull Player player, @NotNull LobbyUserData data, @NotNull PendingRequest pendingRequest) {
- super(GUIType.SIX_BY_NINE, PluginConfig.ANSWERING.TITLE.parse(player, pendingRequest.getSettings().name()), 10, 34);
+ super(
+ GUIType.SIX_BY_NINE,
+ Objects.requireNonNull(PluginConfig.ANSWERING.TITLE.parse(player, pendingRequest.getSettings().name())),
+ 10, 34
+ );
this.player = player;
this.data = data;
this.pendingRequest = pendingRequest;
@@ -87,11 +91,10 @@ public void initItems() {
protected GUIItem createQuestionItem(int id, ServerQuestion question) {
boolean isAnswered = getPendingRequest().isAnswered(id);
ConfiguredItem configuredItem = isAnswered ? PluginConfig.ANSWERING.ITEMS.FINISHED : PluginConfig.ANSWERING.ITEMS.REQUIRED;
+ PreparedItem item = configuredItem.prepare(question.title());
+ item.insertLore("description", ColorParser.parse(question.description()));
- ItemStack icon = configuredItem.get(player, question.title());
- insertLore(icon, "description", ColorParser.parse(question.description()));
-
- return new GUIItem(icon) {
+ return new GUIItem(item.get(player)) {
@Override
public void onClick(Player clicker, ClickType type) {
player.closeInventory();
@@ -161,23 +164,6 @@ protected GUIItem createPendingItem() {
return new GUIItem(PluginConfig.ANSWERING.ITEMS.PENDING.get(player));
}
-
- public void insertLore(@Nullable ItemStack item, String id, List var2) {
- if (item == null) return;
-
- ItemMeta meta = item.getItemMeta();
- if (meta == null || meta.getLore() == null || meta.getLore().isEmpty()) return;
-
- List lore = meta.getLore();
- int index = lore.indexOf("#" + id + "#");
- if (index >= 0) {
- Lists.reverse(var2).forEach(var2x -> lore.add(index + 1, var2x));
- lore.remove(index);
- }
- meta.setLore(lore);
- item.setItemMeta(meta);
- }
-
public ItemStack generateAnswerBook(@Nullable List existingPages) {
ItemStackFactory factory = new ItemStackFactory(Material.WRITABLE_BOOK);
Optional.ofNullable(PluginConfig.ANSWERING.BOOK_ITEM.NAME.parse(player)).ifPresent(factory::setDisplayName);
diff --git a/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/ui/ResubmitGUI.java b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/ui/ResubmitGUI.java
new file mode 100644
index 0000000..2bb3526
--- /dev/null
+++ b/lobby/plugin/src/main/java/com/artformgames/plugin/votepass/lobby/ui/ResubmitGUI.java
@@ -0,0 +1,106 @@
+package com.artformgames.plugin.votepass.lobby.ui;
+
+import cc.carm.lib.easyplugin.gui.GUIItem;
+import cc.carm.lib.easyplugin.gui.GUIType;
+import cc.carm.lib.easyplugin.gui.paged.AutoPagedGUI;
+import cc.carm.lib.easyplugin.utils.ColorParser;
+import cc.carm.lib.mineconfiguration.bukkit.value.item.PreparedItem;
+import com.artformgames.plugin.votepass.api.data.request.RequestInformation;
+import com.artformgames.plugin.votepass.api.data.vote.VoteDecision;
+import com.artformgames.plugin.votepass.core.conf.CommonConfig;
+import com.artformgames.plugin.votepass.lobby.api.data.server.ServerSettings;
+import com.artformgames.plugin.votepass.lobby.api.data.user.PendingRequest;
+import com.artformgames.plugin.votepass.lobby.api.user.LobbyUserData;
+import com.artformgames.plugin.votepass.lobby.conf.PluginConfig;
+import org.bukkit.entity.Player;
+import org.bukkit.event.inventory.ClickType;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Objects;
+
+public class ResubmitGUI extends AutoPagedGUI {
+
+ public static void open(@NotNull Player player, @NotNull LobbyUserData data,
+ @NotNull ServerSettings server, @NotNull RequestInformation lastFailed) {
+ ResubmitGUI questionsGUI = new ResubmitGUI(player, data, server, lastFailed);
+ questionsGUI.openGUI(player);
+ }
+
+ protected final @NotNull Player player;
+ protected final @NotNull LobbyUserData data;
+ protected final @NotNull ServerSettings server;
+ protected final @NotNull RequestInformation request;
+
+ public ResubmitGUI(@NotNull Player player, @NotNull LobbyUserData data,
+ @NotNull ServerSettings server, @NotNull RequestInformation lastFailed) {
+ super(GUIType.SIX_BY_NINE, Objects.requireNonNull(PluginConfig.RESUBMIT.TITLE.parse(player, lastFailed.getServer())), 10, 34);
+ this.player = player;
+ this.data = data;
+ this.server = server;
+ this.request = lastFailed;
+ initItems();
+
+ setPreviousPageSlot(18);
+ setNextPageSlot(26);
+ setPreviousPageUI(CommonConfig.PAGE_ITEMS.PREVIOUS_PAGE.get(player));
+ setNextPageUI(CommonConfig.PAGE_ITEMS.NEXT_PAGE.get(player));
+ }
+
+
+ public @NotNull Player getPlayer() {
+ return player;
+ }
+
+ public @NotNull LobbyUserData getData() {
+ return data;
+ }
+
+ public @NotNull RequestInformation getRequest() {
+ return request;
+ }
+
+ public void initItems() {
+ setItem(4, new GUIItem(PluginConfig.RESUBMIT.ITEMS.INFO.prepare(
+ getRequest().getID(),
+ getRequest().count(VoteDecision.APPROVE),
+ getRequest().count(VoteDecision.REJECT),
+ getRequest().count(VoteDecision.ABSTAIN)
+ ).get(player)));
+
+ getRequest().getContents().forEach((i, a) -> {
+ PreparedItem item = PluginConfig.RESUBMIT.ITEMS.ANSWERS
+ .prepare(i, a.question())
+ .insertLore("answers", ColorParser.parse(a.answers()));
+ addItem(new GUIItem(item.get(player)));
+ });
+
+ setItem(createCancelItem(), 50, 51, 52);
+ setItem(createConfirmItem(), 46, 47, 48);
+ }
+
+
+ protected GUIItem createConfirmItem() {
+ return new GUIItem(PluginConfig.RESUBMIT.ITEMS.CONFIRM.get(player)) {
+ @Override
+ public void onClick(Player clicker, ClickType type) {
+ player.closeInventory();
+
+ PendingRequest pending = new PendingRequest(server);
+ getRequest().getContents().forEach((i, a) -> pending.applyAnswer(i, a.answers()));
+
+ RequestingGUI.open(player, data, pending);
+ }
+ };
+ }
+
+ protected GUIItem createCancelItem() {
+ return new GUIItem(PluginConfig.RESUBMIT.ITEMS.CANCEL.get(player)) {
+ @Override
+ public void onClick(Player clicker, ClickType type) {
+ getPlayer().closeInventory();
+ RequestingGUI.open(player, data, new PendingRequest(server));
+ }
+ };
+ }
+
+}
diff --git a/pom.xml b/pom.xml
index 32d2c90..004d94f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
com.artformgames
votepass-parent
- 1.2.5
+ 1.3.0
api
lobby/api