Updated CustomID. All errors are gone now!

This commit is contained in:
David Berdik 2019-09-02 19:44:55 -04:00
parent 96eaae3953
commit 8d212b3551

View File

@ -1,63 +1,18 @@
package org.jakub1221.herobrineai.misc; package org.jakub1221.herobrineai.misc;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class CustomID { public class CustomID {
private int ID; private String NAME;
private int DATA;
public CustomID(String _data) { public CustomID(String _data) {
if (_data != null) { NAME = _data;
if (!_data.equals("0")) {
if (_data != null && _data.length() > 0) {
String[] both = _data.split(":");
ID = Integer.parseInt(both[0]);
if (both.length > 1) {
DATA = Integer.parseInt(both[1]);
} else {
DATA = 0;
}
} else {
ID = 0;
DATA = 0;
}
} else {
ID = 0;
DATA = 0;
}
} else {
ID = 0;
DATA = 0;
}
}
public int getID() {
return ID;
}
public int getDATA() {
return DATA;
}
public boolean isData() {
if (DATA > 0) {
return true;
}
return false;
} }
public ItemStack getItemStack() { public ItemStack getItemStack() {
ItemStack item = null; return new ItemStack(Material.matchMaterial(NAME));
if (ID != 0) {
if (DATA > 0) {
item = new ItemStack(ID, 1, (byte) DATA);
} else {
item = new ItemStack(ID);
}
}
return item;
} }
} }