Consume everything after lore as lore in MetaItemStack. Fixes #1722.

This commit is contained in:
Ali Moghnieh 2017-12-22 19:45:44 +00:00
parent 0a0c45238c
commit 5fa2ce7d9e
No known key found for this signature in database
GPG Key ID: F09D3A1BAF2E6D70

View File

@ -7,6 +7,8 @@ import com.earth2me.essentials.utils.FormatUtil;
import com.earth2me.essentials.utils.NumberUtil;
import com.google.common.base.Joiner;
import net.ess3.api.IEssentials;
import org.apache.commons.lang.ArrayUtils;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
@ -117,6 +119,27 @@ public class MetaItemStack {
}
public void parseStringMeta(final CommandSource sender, final boolean allowUnsafe, String[] string, int fromArg, final IEssentials ess) throws Exception {
// Make any entries after lore definition become the lore and not parsed.
{
int loreIndex = -1;
boolean dirty = false;
for (int i = 0; i < string.length; i++) {
String _str = string[i];
if (loreIndex == -1) {
if (_str.matches("^lore" + splitPattern.pattern() + ".*")) {
System.out.println("YES " + _str);
loreIndex = i;
}
} else {
string[loreIndex] += " " + string[i];
string[i] = null;
dirty = true;
}
}
if (dirty) {
string = (String[]) ArrayUtils.subarray(string, 0, loreIndex + 1);
}
}
if (string[fromArg].startsWith("{") && hasMetaPermission(sender, "vanilla", false, true, ess)) {
try {
stack = ess.getServer().getUnsafe().modifyItemStack(stack, Joiner.on(' ').join(Arrays.asList(string).subList(fromArg, string.length)));