More Missle Info
Dieser Commit ist enthalten in:
Ursprung
41bb28e1c5
Commit
292a1fcf96
@ -22,6 +22,7 @@ package de.steamwar.misslewars.items;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
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.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
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.math.transform.AffineTransform;
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import de.steamwar.misslewars.MissileWars;
|
import de.steamwar.misslewars.MissileWars;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -41,14 +43,22 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class Missile extends SpecialItem {
|
public class Missile extends SpecialItem {
|
||||||
|
|
||||||
private static final World world = new BukkitWorld(Bukkit.getWorlds().get(0));
|
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 Clipboard clipboard;
|
||||||
private final ItemStack item;
|
private final ItemStack item;
|
||||||
|
|
||||||
@ -65,15 +75,14 @@ public class Missile extends SpecialItem {
|
|||||||
if (strings.length > 3) {
|
if (strings.length > 3) {
|
||||||
try {
|
try {
|
||||||
lore.add("§7Speed §8: " + graph(Integer.parseInt(strings[2]), 7));
|
lore.add("§7Speed §8: " + graph(Integer.parseInt(strings[2]), 7));
|
||||||
lore.add("§7Size §8: " + graph(Integer.parseInt(strings[2]), 7));
|
lore.add("§7Size §8: " + graph(Integer.parseInt(strings[3]), 7));
|
||||||
lore.add("§7TNT §8: " + "");
|
lore.add("§7TNT §8: " + count());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClipboardFormat format = ClipboardFormats.findByFile(missileFile);
|
ClipboardFormat format = ClipboardFormats.findByFile(missileFile);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assert format != null;
|
assert format != null;
|
||||||
clipboard = format.getReader(new FileInputStream(missileFile)).read();
|
clipboard = format.getReader(new FileInputStream(missileFile)).read();
|
||||||
@ -85,6 +94,7 @@ public class Missile extends SpecialItem {
|
|||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
assert meta != null;
|
assert meta != null;
|
||||||
meta.setDisplayName("§c" + name);
|
meta.setDisplayName("§c" + name);
|
||||||
|
meta.setLore(lore);
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +118,10 @@ public class Missile extends SpecialItem {
|
|||||||
return st.toString();
|
return st.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int count() {
|
||||||
|
return WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1).countBlocks(clipboard.getRegion(), tnt);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem(){
|
public ItemStack getItem(){
|
||||||
return item;
|
return item;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren