Add TNTSpawn naming
Dieser Commit ist enthalten in:
Ursprung
870fc285e7
Commit
bbdf02594b
@ -22,6 +22,7 @@
|
||||
package de.steamwar.bausystem.cannonsimulator;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.inventory.SWAnvilInv;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.inventory.SWListInv;
|
||||
@ -102,7 +103,7 @@ public class TNTSimulator {
|
||||
static void editTNT(Player player, TNTSpawn tntSpawn) {
|
||||
TNTSimulator tntSimulator = get(player);
|
||||
|
||||
SWInventory swInventory = new SWInventory(player, 54, "TNT");
|
||||
SWInventory swInventory = new SWInventory(player, 54, "TNT" + (tntSpawn.getName().isEmpty() ? "§8- §e" + tntSpawn.getName() : ""));
|
||||
swInventory.setItem(49, new SWItem(Material.REDSTONE_BLOCK, "§cZurück", clickType -> {
|
||||
openSimulator(player);
|
||||
}));
|
||||
@ -113,6 +114,16 @@ public class TNTSimulator {
|
||||
openSimulator(player);
|
||||
}));
|
||||
|
||||
// tnt Name
|
||||
swInventory.setItem(45, new SWItem(Material.NAME_TAG, "§eName", clickType -> {
|
||||
SWAnvilInv swAnvilInv = new SWAnvilInv(player, "Name");
|
||||
swAnvilInv.setCallback(s -> {
|
||||
tntSpawn.setName(s);
|
||||
editTNT(player, tntSpawn);
|
||||
});
|
||||
swAnvilInv.open();
|
||||
}));
|
||||
|
||||
// Change Count of spawned TNT
|
||||
swInventory.setItem(10, new SWItem(SWItem.getDye(10), "§a+1", clickType -> {
|
||||
tntSpawn.setCount(tntSpawn.getCount() + 1);
|
||||
@ -293,7 +304,7 @@ public class TNTSimulator {
|
||||
}
|
||||
|
||||
private static double clamp(double d) {
|
||||
return (int)(d * 100) * 0.01;
|
||||
return (int)(d * 10000) * 0.0001;
|
||||
}
|
||||
|
||||
private Set<TNTSpawn> tntSpawns = new HashSet<>();
|
||||
|
@ -49,7 +49,7 @@ public class TNTSimulatorListener implements Listener {
|
||||
if (event.getItem() == null) return;
|
||||
if (!event.getItem().isSimilar(TNTSimulator.WAND)) return;
|
||||
event.setCancelled(true);
|
||||
if (permissionCheck(event.getPlayer())) {
|
||||
if (!permissionCheck(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ public class TNTSpawn implements Comparable<TNTSpawn> {
|
||||
|
||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||
|
||||
private String name = "";
|
||||
private Vector position;
|
||||
private int fuseTicks = 80;
|
||||
private int count = 1;
|
||||
@ -53,6 +54,14 @@ public class TNTSpawn implements Comparable<TNTSpawn> {
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Vector getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.cannonsimulator.TNTSimulator;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import org.bukkit.block.data.type.TNT;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -45,13 +46,20 @@ public class CommandSimulator implements CommandExecutor {
|
||||
if (!(commandSender instanceof Player))
|
||||
return false;
|
||||
Player player = (Player) commandSender;
|
||||
if (permissionCheck(player)) {
|
||||
if (!permissionCheck(player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 1 && args[0].equalsIgnoreCase("wand")) {
|
||||
if (args.length == 1) {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "wand":
|
||||
player.getInventory().setItemInMainHand(TNTSimulator.WAND);
|
||||
player.updateInventory();
|
||||
break;
|
||||
case "start":
|
||||
TNTSimulator.get(player).start();
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
TNTSimulator.openSimulator(player);
|
||||
|
@ -40,6 +40,7 @@ public class CommandSimulatorTabCompleter implements TabCompleter {
|
||||
private List<String> detonaterTabComplete(Player player, String[] args) {
|
||||
List<String> tabComplete = new ArrayList<>();
|
||||
tabComplete.add("wand");
|
||||
tabComplete.add("start");
|
||||
|
||||
if (args.length >= 2) {
|
||||
return new ArrayList<>();
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren