Implemented check to detect attempt to link 2 beacons
This commit is contained in:
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)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPrepareItemCraftEvent(CraftingInventory what, InventoryView view, boolean isRepair){
|
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…
x
Reference in New Issue
Block a user