mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Fixed lore getter
This commit is contained in:
parent
16de0f9630
commit
953091bc6c
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user