Skip to content

Commit 696cb2c

Browse files
Improve config and queue type loading
1 parent 5c8d990 commit 696cb2c

3 files changed

Lines changed: 30 additions & 19 deletions

File tree

src/main/java/net/pistonmaster/pistonqueue/shared/PistonQueuePlugin.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ default void loadConfig(Path file) throws IOException {
315315
val queueTypes = config.node("QUEUE_TYPES").childrenMap();
316316
val array = new QueueType[queueTypes.size()];
317317
int i = 0;
318-
for (Map.Entry<Object, ? extends ConfigurationNode> entry : queueTypes.entrySet()) {
318+
for (val entry : queueTypes.entrySet()) {
319319
Object key = entry.getKey();
320320
ConfigurationNode typeData = entry.getValue();
321321
QueueType queueType = new QueueType(
@@ -331,6 +331,16 @@ default void loadConfig(Path file) throws IOException {
331331
}
332332
Arrays.sort(array, Comparator.comparingInt(QueueType::getOrder));
333333
it.set(Config.class, array);
334+
} else { // Modify existing
335+
QueueType[] queueType = (QueueType[]) it.get(Config.class);
336+
for (QueueType type : queueType) {
337+
ConfigurationNode typeData = config.node("QUEUE_TYPES").node(type.getName());
338+
type.setOrder(typeData.node("ORDER").getInt());
339+
type.setPermission(typeData.node("PERMISSION").getString());
340+
type.setReservedSlots(typeData.node("SLOTS").getInt());
341+
type.setHeader(typeData.node("HEADER").getList(String.class));
342+
type.setFooter(typeData.node("FOOTER").getList(String.class));
343+
}
334344
}
335345
} else {
336346
it.set(Config.class, config.node(fieldName).get(it.getType()));

src/main/java/net/pistonmaster/pistonqueue/shared/SharedChatUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static String formatDuration(String str, Duration duration, int position)
3535
}
3636

3737
public static String parseText(String text) {
38-
text = text.replace("%server%", Config.SERVER_NAME);
38+
text = text.replace("%server_name%", Config.SERVER_NAME);
3939
for (QueueType type : Config.QUEUE_TYPES) {
4040
text = text.replace("%" + type.getName().toLowerCase() + "%", String.valueOf(type.getQueueMap().size()));
4141
}

src/main/resources/proxy_config.yml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
# If both PistonQueue and PistonMOTD are installed on your proxy, the following placeholders will be available in the PistonMOTD config:
99
# %pistonqueue_regular%, %pistonqueue_priority%, %pistonqueue_veteran%
1010

11-
SERVERNAME: "SERVERNAME"
11+
# Placeholder for %server_name%
12+
SERVER_NAME: "&cexample.org"
1213

1314
# Username regex
1415
ENABLE_USERNAME_REGEX: true
@@ -19,7 +20,7 @@ USERNAME_REGEX_MESSAGE: "&6[PQ] Invalid username please use: %regex%"
1920
REGISTER_TAB: true
2021

2122
# Server is full message
22-
SERVER_IS_FULL_MESSAGE: "%server% &6is full"
23+
SERVER_IS_FULL_MESSAGE: "%server_name% &6is full"
2324

2425
# It is not recommended decreasing this number (milliseconds)
2526
SERVER_ONLINE_CHECK_DELAY: 500
@@ -43,7 +44,7 @@ START_TIME: 30
4344

4445
# When the main server is down should you kick the player from the queue?
4546
KICK_WHEN_DOWN: false
46-
SERVER_DOWN_KICK_MESSAGE: "%server% &6is down please try again later :("
47+
SERVER_DOWN_KICK_MESSAGE: "%server_name% &6is down please try again later :("
4748

4849
# If a player gets kicked from the main server (it goes down/crashes), he gets sent into queue and waits.
4950
IF_MAIN_DOWN_SEND_TO_QUEUE: true
@@ -116,7 +117,7 @@ SEND_XP_SOUND: true
116117
# KICK: You will be kicked from the queue server on joining it.
117118
SHADOW_BAN_TYPE: "LOOP"
118119

119-
# Custom percentage for the shadow-ban type. Only used when SHADOWBANTYPE is set to CUSTOM_PERCENT.
120+
# Custom percentage for the shadow-ban type. Only used when SHADOW_BAN_TYPE is set to CUSTOM_PERCENT.
120121
CUSTOM_PERCENT_PERCENTAGE: 20
121122

122123
# LOOP: When you're shadow-banned you will be put in queue, but before joining it "fails" and you start all over again.
@@ -140,20 +141,20 @@ QUEUE_TYPES:
140141
# this only shows when your in the queue waiting to join use a separate plugin for your main server
141142
HEADER:
142143
- ""
143-
- " %server% "
144+
- " %server_name% "
144145
- ""
145-
- " %server% &bis full "
146+
- " %server_name% &bis full "
146147
- " Position in queue: &l%position% "
147148
- " &6Estimated time: &l%wait% "
148149
- ""
149150
FOOTER:
150151
- ""
151-
- " &6You can now donate to receive priority queue status, please visit donate.SERVERNAME.org "
152+
- " &6You can now donate to receive priority queue status, please visit donate.example.com "
152153
- ""
153-
- " &7contact: someone@example.com "
154+
- " &7contact: contact@example.com "
154155
- " discussion: https://discord.example.com "
155156
- " website: https://www.example.com "
156-
- " These are the only official SERVERNAME websites and contacts "
157+
- " These are the only official %server_name% websites and contacts "
157158
- ""
158159
PRIORITY:
159160
ORDER: 2
@@ -162,20 +163,20 @@ QUEUE_TYPES:
162163
# Configs for priority queue tab list
163164
HEADER:
164165
- ""
165-
- " %server%"
166+
- " %server_name%"
166167
- ""
167-
- " %server% &bis full "
168+
- " %server_name% &bis full "
168169
- " Position in queue: &l%position% "
169170
- " &6Estimated time: &l%wait% "
170171
- ""
171172
FOOTER:
172173
- ""
173174
- " &6You have priority queue status please wait for an available slot on the server "
174175
- ""
175-
- " &7contact: someone@example.com "
176+
- " &7contact: contact@example.com "
176177
- " discussion: https://discord.example.com "
177178
- " website: https://www.example.com "
178-
- " These are the only official SERVERNAME websites and contacts "
179+
- " These are the only official %server_name% websites and contacts "
179180
- ""
180181
VETERAN:
181182
ORDER: 1
@@ -184,18 +185,18 @@ QUEUE_TYPES:
184185
# Configs for veteran queue tab list
185186
HEADER:
186187
- ""
187-
- " %server% "
188+
- " %server_name% "
188189
- ""
189-
- " %server% &bis full "
190+
- " %server_name% &bis full "
190191
- " Position in queue: &l%position% "
191192
- " &6Estimated time: &l%wait% "
192193
- ""
193194
FOOTER:
194195
- ""
195196
- " &6You have veteran queue status please wait for an available slot on the server "
196197
- ""
197-
- " &7contact: someone@example.com "
198+
- " &7contact: contact@example.com "
198199
- " discussion: https://discord.example.com "
199200
- " website: https://www.example.com "
200-
- " These are the only official SERVERNAME websites and contacts "
201+
- " These are the only official %server_name% websites and contacts "
201202
- ""

0 commit comments

Comments
 (0)