fixed MortarTuner constructor location parsing
parent
65590642ba
commit
73c72cbe41
|
@ -3,6 +3,7 @@ package xyz.soper.arty.item;
|
|||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -13,18 +14,23 @@ public class MortarTuner {
|
|||
*/
|
||||
private final Location linkedLocation;
|
||||
|
||||
public static final String BASIC_TUNER_NAME = ChatColor.RESET + "Basic Tuner";
|
||||
public static final String NORMAL_TUNER_NAME = ChatColor.RESET + "Mortar Tuner";
|
||||
public static final String BASIC_TUNER_NAME = ChatColor.GRAY + "Basic Mortar Tuner";
|
||||
public static final String NORMAL_TUNER_NAME = ChatColor.GRAY + "Mortar Tuner";
|
||||
|
||||
MortarTuner(ItemStack tuner){
|
||||
public MortarTuner(ItemStack tuner){
|
||||
if(isTuner(tuner)){
|
||||
String[] coords = tuner.getItemMeta().getLore().get(0).substring(20).split(", ");
|
||||
linkedLocation = new Location(
|
||||
null,
|
||||
Double.parseDouble(coords[0]),
|
||||
Double.parseDouble(coords[1]),
|
||||
Double.parseDouble(coords[2])
|
||||
);
|
||||
if(tuner.getItemMeta().getLore().get(0).startsWith(ChatColor.GOLD + "Linked")){
|
||||
String[] coords = tuner.getItemMeta().getLore().get(0).substring(22).split(", ");
|
||||
linkedLocation = new Location(
|
||||
null,
|
||||
Double.parseDouble(coords[0]),
|
||||
Double.parseDouble(coords[1]),
|
||||
Double.parseDouble(coords[2])
|
||||
);
|
||||
}
|
||||
else{
|
||||
linkedLocation = null;
|
||||
}
|
||||
} else throw new IllegalArgumentException("Incompatible ItemStack in MortarTuner constructor");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue