SteamWar/BauSystem
Archiviert
13
0

Merge remote-tracking branch 'origin/dt_rework' into dt_rework

Dieser Commit ist enthalten in:
Chaoscaot 2021-03-25 13:48:01 +01:00
Commit 2eba7c3cb5

Datei anzeigen

@ -116,18 +116,18 @@ public class Detonator implements Listener {
VersionedRunnable.call(new VersionedRunnable(() -> execute(player, PLAYER_LOCS.get(player)), 12), new VersionedRunnable(() -> {
try {
ItemStack item = getNextBestDetonator(player);
if(item == null)
if (item == null)
return;
Detonator detonator = getDetonator(player, item);
execute(player, detonator.getLocs());
}catch (SecurityException e) {
} catch (SecurityException e) {
player.sendMessage(BauSystem.PREFIX + "§c" + e.getMessage());
}
}, 15));
}
private static ItemStack getNextBestDetonator(Player player) {
if(player.getInventory().getItemInMainHand().getItemMeta() != null && player.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
if (player.getInventory().getItemInMainHand().getItemMeta() != null && player.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
return player.getInventory().getItemInMainHand();
}
@ -136,10 +136,10 @@ public class Detonator implements Listener {
}
for (ItemStack item : player.getInventory().getContents()) {
if(item == null)
if (item == null)
continue;
if(item.getItemMeta() != null &&
if (item.getItemMeta() != null &&
item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
return item;
}
@ -174,11 +174,11 @@ public class Detonator implements Listener {
private static int getFreeSlot(ItemStack item) {
ItemMeta meta = item.getItemMeta();
if(meta == null) {
if (meta == null) {
throw new SecurityException("Das Item ist kein Detonator");
}
PersistentDataContainer container = meta.getPersistentDataContainer();
if(!container.has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
if (!container.has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
throw new SecurityException("Das Item ist kein Detonator");
}
for (int i = 0; i < getDetoLocs(container) + 1; i++) {
@ -189,17 +189,17 @@ public class Detonator implements Listener {
}
private static int getDetoLocs(PersistentDataContainer container) {
if(!container.has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
if (!container.has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
throw new SecurityException("Das Item ist kein Detonator");
}
return container.get(new NamespacedKey(BauSystem.getPlugin(), "deto-locs"), PersistentDataType.INTEGER);
}
private static void increaseLocsSize(PersistentDataContainer container, int to) {
if(!container.has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
if (!container.has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
throw new SecurityException("Das Item ist kein Detonator");
}
if(container.get(new NamespacedKey(BauSystem.getPlugin(), "deto-locs"), PersistentDataType.INTEGER) < to) {
if (container.get(new NamespacedKey(BauSystem.getPlugin(), "deto-locs"), PersistentDataType.INTEGER) < to) {
container.set(new NamespacedKey(BauSystem.getPlugin(), "deto-locs"), PersistentDataType.INTEGER, to);
}
}