Fixed lore getter

This commit is contained in:
Auxilor 2021-02-19 18:58:07 +00:00
parent 16de0f9630
commit 953091bc6c

View File

@ -17,9 +17,11 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
public class HoldItemListener extends PluginDependent implements Listener { public class HoldItemListener extends PluginDependent implements Listener {
/** /**
@ -69,33 +71,33 @@ public class HoldItemListener extends PluginDependent implements Listener {
EcoEnchant enchant; EcoEnchant enchant;
int level; int level;
String[] lineSplit = line.split(" "); List<String> lineSplit = new ArrayList<>(Arrays.asList(line.split(" ")));
if (lineSplit.length == 0) { if (lineSplit.size() == 0) {
continue; continue;
} }
if (lineSplit.length == 1) { if (lineSplit.size() == 1) {
enchant = EcoEnchants.getByName(lineSplit[0]); enchant = EcoEnchants.getByName(lineSplit.get(0));
level = 1; level = 1;
} else { } else {
String levelString = lineSplit[lineSplit.length - 1]; EcoEnchant attemptFullLine = EcoEnchants.getByName(line);
levelString = levelString.replace(" ", "");
try { if (attemptFullLine != null) {
level = NumberUtils.fromNumeral(levelString); enchant = attemptFullLine;
} catch (IllegalArgumentException e) { level = 1;
continue; } else {
} String levelString = lineSplit.get(lineSplit.size() - 1);
lineSplit.remove(levelString);
levelString = levelString.trim();
StringBuilder nameBuilder = new StringBuilder(); try {
level = NumberUtils.fromNumeral(levelString);
for (int i = 0; i < lineSplit.length - 1; i++) { } catch (IllegalArgumentException e) {
nameBuilder.append(lineSplit[i]); continue;
if (i != lineSplit.length - 2) {
nameBuilder.append(" ");
} }
}
enchant = EcoEnchants.getByName(nameBuilder.toString()); String enchantName = lineSplit.stream().collect(Collectors.joining(" "));
enchant = EcoEnchants.getByName(enchantName);
}
} }
if (enchant != null) { if (enchant != null) {