SteamWar/MissileWars
Archiviert
13
0

Fix Missle Info

Dieser Commit ist enthalten in:
jojo 2020-09-18 18:44:33 +02:00
Ursprung 16a69c0e41
Commit c325244702

Datei anzeigen

@ -33,7 +33,6 @@ import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import de.steamwar.misslewars.MissileWars;
import io.netty.handler.logging.LogLevel;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -55,9 +54,9 @@ public class Missile extends SpecialItem {
static {
try {
tnt = WorldEdit.getInstance().getBlockFactory().parseFromListInput("tnt", new ParserContext());
tnt = WorldEdit.getInstance().getBlockFactory().parseFromListInput("[tnt]", new ParserContext());
} catch (Exception e) {
//Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e.getCause());
Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e.getCause());
}
}
@ -68,20 +67,32 @@ public class Missile extends SpecialItem {
String[] strings = missileFile.getName().split("\\.");
String name = strings[0];
String material = strings[1];
if (!material.endsWith("_SPAWN_EGG")) {
material += "_SPAWN_EGG";
}
if (!material.endsWith("_SPAWN_EGG")) material += "_SPAWN_EGG";
Material itemType = Material.valueOf(material);
List<String> lore = new ArrayList<>();
if (strings.length > 3) {
if (strings.length > 2) {
try {
lore.add(graph(Integer.parseInt(strings[2]), 7) + " §7Speed");
lore.add(graph(Integer.parseInt(strings[3]), 7) + " §7Size");
// lore.add("§7TNT §8: " + count());
} catch (NumberFormatException e) {
lore.add(graph(0, 7) + " §7Speed");
}
} else {
lore.add(graph(0, 7) + " §7Speed");
}
if (strings.length > 3) {
try {
lore.add(graph(Integer.parseInt(strings[3]), 7) + " §7Size");
} catch (NumberFormatException e) {
lore.add(graph(0, 7) + " §7Size");
}
} else {
lore.add(graph(0, 7) + " §7Size");
}
try {
lore.add("§7TNT §8: §e" + count());
} catch (Exception e) {
lore.add("§7TNT §8: §e?");
}
ClipboardFormat format = ClipboardFormats.findByFile(missileFile);
@ -104,7 +115,9 @@ public class Missile extends SpecialItem {
if (index > size) index = size;
StringBuilder st = new StringBuilder();
st.append("§8[§e");
st.append(repeat(index));
if (index > 0) {
st.append(repeat(index));
}
st.append("§7");
st.append(repeat(size - index));
st.append("§8]");
@ -162,14 +175,12 @@ public class Missile extends SpecialItem {
}
public static void init(){
File missileFolder = new File(MissileWars.getPlugin().getDataFolder(), "missiles");
File missileFolder = new File(MissileWars.getPlugin().getDataFolder(), "default-missles");
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;
if(!missileFile.canRead() || !missileFile.isFile()) continue;
new Missile(missileFile);
}
}