SteamWar/MissileWars
Archiviert
13
0

Add all Missiles back

Dieser Commit ist enthalten in:
jojo 2020-09-26 11:42:41 +02:00
Ursprung 1ea911437b
Commit 8140ad4072
2 geänderte Dateien mit 20 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -52,13 +52,12 @@ public class Missile extends SpecialItem {
private static final BlockType TNT = BlockTypes.TNT;
private static final int GRAPH_SIZE = 7;
private static final Random r = new Random();
public static final List<String> specialMissiles = new ArrayList<>();
private final Clipboard clipboard;
private final ItemStack item;
private final int tntCount;
private Missile(File missileFile, boolean special) {
private Missile(File missileFile) {
String[] strings = missileFile.getName().split("\\.");
String name = strings[0];
String material = strings[1];
@ -85,8 +84,7 @@ public class Missile extends SpecialItem {
tntCount = count;
lore.add("§7TNT §8: §e" + tntCount);
item = createItem(itemType, "§c" + name, 1, lore, special);
if (special) specialMissiles.add(name);
item = createItem(itemType, "§c" + name, 1, lore, false);
}
private void lore(List<String> lore, String[] args, int index, String tag) {
@ -175,7 +173,20 @@ public class Missile extends SpecialItem {
}
for (File missileFile : Objects.requireNonNull(missileFolder.listFiles())) {
if (!missileFile.canRead() || !missileFile.isFile()) continue;
new Missile(missileFile, false);
new Missile(missileFile);
}
otherInit();
}
public static void otherInit() {
File missileFolder = new File(MissileWars.getPlugin().getDataFolder(), "missiles");
if (!missileFolder.exists() || !missileFolder.canRead() || !missileFolder.isDirectory()) {
throw new SecurityException("Missiles could not be loaded");
}
for (File missileFile : Objects.requireNonNull(missileFolder.listFiles())) {
if (!missileFile.canRead() || !missileFile.isFile()) continue;
new Missile(missileFile);
}
}

Datei anzeigen

@ -39,9 +39,9 @@ public abstract class SpecialItem {
SpecialItem() {
if (this.isMissile()) {
missileItems.add(this);
return;
} else {
supportItems.add(this);
}
supportItems.add(this);
}
public abstract ItemStack getItem();
@ -54,7 +54,7 @@ public abstract class SpecialItem {
return createItem(material, name, amount, new ArrayList<>(), false);
}
public ItemStack createItem(Material material, String name, int amount, List<String> lore, boolean special) {
public ItemStack createItem(Material material, String name, int amount, List<String> lore, boolean enchanted) {
ItemStack item = new ItemStack(material, amount);
ItemMeta meta = item.getItemMeta();
assert meta != null;
@ -62,7 +62,7 @@ public abstract class SpecialItem {
meta.setLore(lore);
meta.setDisplayName(name);
item.setItemMeta(meta);
if (special) item.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 1);
if (enchanted) item.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, 1);
return item;
}