SteamWar/MissileWars
Archiviert
13
0
Dieser Commit ist enthalten in:
jojo 2020-09-06 18:49:38 +02:00
Ursprung a7011030fa
Commit 41bb28e1c5

Datei anzeigen

@ -41,6 +41,8 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class Missile extends SpecialItem {
@ -59,6 +61,17 @@ public class Missile extends SpecialItem {
}
Material itemType = Material.valueOf(material);
List<String> lore = new ArrayList<>();
if (strings.length > 3) {
try {
lore.add("§7Speed §8: " + graph(Integer.parseInt(strings[2]), 7));
lore.add("§7Size §8: " + graph(Integer.parseInt(strings[2]), 7));
lore.add("§7TNT §8: " + "");
} catch (NumberFormatException e) {
}
}
ClipboardFormat format = ClipboardFormats.findByFile(missileFile);
try {
@ -75,6 +88,26 @@ public class Missile extends SpecialItem {
item.setItemMeta(meta);
}
private String graph(int index, int size) {
if (index > size) index = size;
StringBuilder st = new StringBuilder();
st.append("§8[§e");
st.append(repeat(index));
st.append("§7");
st.append(repeat(size - index));
st.append("§8]");
return st.toString();
}
private String repeat(int count) {
if (count == 0) return "";
StringBuilder st = new StringBuilder();
for (int i = 0; i < count; i++) {
st.append("=");
}
return st.toString();
}
@Override
public ItemStack getItem(){
return item;