mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-30 01:13:38 +01:00
Fixed placeholders looping
This commit is contained in:
parent
a299325b39
commit
632ee8abb1
@ -19,9 +19,17 @@ public class Placeholders {
|
||||
// Remove conditions first
|
||||
str = removeCondition(str);
|
||||
|
||||
/*
|
||||
* For MMOCore not to loop on unparsable placeholders, it keeps
|
||||
* track of the "last placeholder" parsed. The 'explored' string
|
||||
* has NO parsed placeholder.
|
||||
*/
|
||||
String explored = str;
|
||||
|
||||
// Internal placeholders
|
||||
while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) {
|
||||
String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}"));
|
||||
while (explored.contains("{") && explored.substring(explored.indexOf("{")).contains("}")) {
|
||||
final int begin = explored.indexOf("{"), end = explored.indexOf("}");
|
||||
final String holder = explored.substring(begin + 1, end);
|
||||
@Nullable String found = placeholders.get(holder);
|
||||
|
||||
/*
|
||||
@ -32,6 +40,9 @@ public class Placeholders {
|
||||
*/
|
||||
if (found != null)
|
||||
str = str.replace("{" + holder + "}", found);
|
||||
|
||||
// Increase counter
|
||||
explored = explored.substring(end + 1);
|
||||
}
|
||||
|
||||
// External placeholders
|
||||
|
Loading…
Reference in New Issue
Block a user