Implemented check to detect attempt to link 2 beacons

master
Ruakij 4 years ago
parent da05087876
commit 376695b466

@ -0,0 +1,11 @@
package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.listener;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.InventoryView;
public class OnPrepareItemCraftEvent {
public static void onPrepareItemCraftEvent(CraftingInventory what, InventoryView view, boolean isRepair){
}
}

@ -14,5 +14,17 @@ public class OnPrepareItemCraftEvent implements Listener {
@EventHandler(priority = EventPriority.LOW)
public void onPrepareItemCraftEvent(CraftingInventory what, InventoryView view, boolean isRepair){
ItemStack[] matrix = what.getMatrix();
// Check if 2 beacons are in the crafting-slots
int beaconCount = 0;
for (ItemStack item : matrix) {
if(item.getType() == Material.BEACON)
beaconCount++;
}
if(beaconCount == 2){
// Exactly 2 beacons found
eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.listener.OnPrepareItemCraftEvent.onPrepareItemCraftEvent(what, view, isRepair);
}
}
}

Loading…
Cancel
Save