SteamWar/MissileWars
Archiviert
13
0

More Missle Info

Dieser Commit ist enthalten in:
jojo 2020-09-06 18:58:53 +02:00
Ursprung 41bb28e1c5
Commit 292a1fcf96

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.misslewars.items;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
@ -30,6 +31,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
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 org.bukkit.Bukkit;
import org.bukkit.Location;
@ -41,14 +43,22 @@ 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;
import java.util.*;
public class Missile extends SpecialItem {
private static final World world = new BukkitWorld(Bukkit.getWorlds().get(0));
private static Set<BaseBlock> tnt = new HashSet<>();
static {
try {
tnt = WorldEdit.getInstance().getBlockFactory().parseFromListInput("minecraft:tnt", new ParserContext());
} catch (Exception e) {
}
}
private final Clipboard clipboard;
private final ItemStack item;
@ -65,15 +75,14 @@ public class Missile extends SpecialItem {
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: " + "");
lore.add("§7Size §8: " + graph(Integer.parseInt(strings[3]), 7));
lore.add("§7TNT §8: " + count());
} catch (NumberFormatException e) {
}
}
ClipboardFormat format = ClipboardFormats.findByFile(missileFile);
try {
assert format != null;
clipboard = format.getReader(new FileInputStream(missileFile)).read();
@ -85,6 +94,7 @@ public class Missile extends SpecialItem {
ItemMeta meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("§c" + name);
meta.setLore(lore);
item.setItemMeta(meta);
}
@ -108,6 +118,10 @@ public class Missile extends SpecialItem {
return st.toString();
}
private int count() {
return WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1).countBlocks(clipboard.getRegion(), tnt);
}
@Override
public ItemStack getItem(){
return item;