Merge remote-tracking branch 'origin/dt_rework' into dt_rework
Dieser Commit ist enthalten in:
Commit
2eba7c3cb5
@ -116,18 +116,18 @@ public class Detonator implements Listener {
|
|||||||
VersionedRunnable.call(new VersionedRunnable(() -> execute(player, PLAYER_LOCS.get(player)), 12), new VersionedRunnable(() -> {
|
VersionedRunnable.call(new VersionedRunnable(() -> execute(player, PLAYER_LOCS.get(player)), 12), new VersionedRunnable(() -> {
|
||||||
try {
|
try {
|
||||||
ItemStack item = getNextBestDetonator(player);
|
ItemStack item = getNextBestDetonator(player);
|
||||||
if(item == null)
|
if (item == null)
|
||||||
return;
|
return;
|
||||||
Detonator detonator = getDetonator(player, item);
|
Detonator detonator = getDetonator(player, item);
|
||||||
execute(player, detonator.getLocs());
|
execute(player, detonator.getLocs());
|
||||||
}catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
player.sendMessage(BauSystem.PREFIX + "§c" + e.getMessage());
|
player.sendMessage(BauSystem.PREFIX + "§c" + e.getMessage());
|
||||||
}
|
}
|
||||||
}, 15));
|
}, 15));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ItemStack getNextBestDetonator(Player player) {
|
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();
|
return player.getInventory().getItemInMainHand();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,10 +136,10 @@ public class Detonator implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack item : player.getInventory().getContents()) {
|
for (ItemStack item : player.getInventory().getContents()) {
|
||||||
if(item == null)
|
if (item == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(item.getItemMeta() != null &&
|
if (item.getItemMeta() != null &&
|
||||||
item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
|
item.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(BauSystem.getPlugin(), "deto"), PersistentDataType.BYTE)) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@ -174,11 +174,11 @@ public class Detonator implements Listener {
|
|||||||
|
|
||||||
private static int getFreeSlot(ItemStack item) {
|
private static int getFreeSlot(ItemStack item) {
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
if(meta == null) {
|
if (meta == null) {
|
||||||
throw new SecurityException("Das Item ist kein Detonator");
|
throw new SecurityException("Das Item ist kein Detonator");
|
||||||
}
|
}
|
||||||
PersistentDataContainer container = meta.getPersistentDataContainer();
|
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");
|
throw new SecurityException("Das Item ist kein Detonator");
|
||||||
}
|
}
|
||||||
for (int i = 0; i < getDetoLocs(container) + 1; i++) {
|
for (int i = 0; i < getDetoLocs(container) + 1; i++) {
|
||||||
@ -189,17 +189,17 @@ public class Detonator implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int getDetoLocs(PersistentDataContainer container) {
|
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");
|
throw new SecurityException("Das Item ist kein Detonator");
|
||||||
}
|
}
|
||||||
return container.get(new NamespacedKey(BauSystem.getPlugin(), "deto-locs"), PersistentDataType.INTEGER);
|
return container.get(new NamespacedKey(BauSystem.getPlugin(), "deto-locs"), PersistentDataType.INTEGER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void increaseLocsSize(PersistentDataContainer container, int to) {
|
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");
|
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);
|
container.set(new NamespacedKey(BauSystem.getPlugin(), "deto-locs"), PersistentDataType.INTEGER, to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren