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,16 +71,23 @@ 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(" ", "");
|
|
||||||
|
if (attemptFullLine != null) {
|
||||||
|
enchant = attemptFullLine;
|
||||||
|
level = 1;
|
||||||
|
} else {
|
||||||
|
String levelString = lineSplit.get(lineSplit.size() - 1);
|
||||||
|
lineSplit.remove(levelString);
|
||||||
|
levelString = levelString.trim();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
level = NumberUtils.fromNumeral(levelString);
|
level = NumberUtils.fromNumeral(levelString);
|
||||||
@ -86,18 +95,11 @@ public class HoldItemListener extends PluginDependent implements Listener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder nameBuilder = new StringBuilder();
|
String enchantName = lineSplit.stream().collect(Collectors.joining(" "));
|
||||||
|
enchant = EcoEnchants.getByName(enchantName);
|
||||||
for (int i = 0; i < lineSplit.length - 1; i++) {
|
|
||||||
nameBuilder.append(lineSplit[i]);
|
|
||||||
if (i != lineSplit.length - 2) {
|
|
||||||
nameBuilder.append(" ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enchant = EcoEnchants.getByName(nameBuilder.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enchant != null) {
|
if (enchant != null) {
|
||||||
lore.remove(rawLine);
|
lore.remove(rawLine);
|
||||||
toAdd.put(enchant, level);
|
toAdd.put(enchant, level);
|
||||||
|
Loading…
Reference in New Issue
Block a user