Implemented placing of LinkedBeaconTeleporterItem

master
Ruakij 4 years ago
parent d9c95a5e53
commit 3df5c9d4ac

@ -76,6 +76,28 @@ public class LinkedBeaconTeleporterManager {
Main.log.info("All done!");
}
public LinkedBeaconTeleporterBlock placeLbtItem(LinkedBeaconTeleporterItem lbtItem, Block block){
// Check if id already exists
List<LinkedBeaconTeleporterBlock> lbtBlocks = linkedBeaconTeleporterById.get(lbtItem.teleporterId());
if(lbtBlocks == null){
// Create empty if not found
lbtBlocks = new ArrayList<>();
}
// Block from item
LinkedBeaconTeleporterBlock lbtBlock = new LinkedBeaconTeleporterBlock(lbtItem.teleporterId(), block);
// Add to list
lbtBlocks.add(lbtBlock);
// Add to location
linkedBeaconTeleporterByLoc.put(
Function.serialiseBlockLocation(block.getLocation()),
lbtBlock
);
return lbtBlock;
}
public LinkedBeaconTeleporterItem breakLbtBlock(LinkedBeaconTeleporterBlock lbtBlock){
// Get list by id
List<LinkedBeaconTeleporterBlock> lbtBlocks = linkedBeaconTeleporterById.get(lbtBlock.teleporterId());

@ -1,11 +1,16 @@
package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.listener;
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterBlock;
import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterItem;
import org.bukkit.block.Block;
import org.bukkit.event.block.BlockPlaceEvent;
public class OnBlockPlace {
public static void onBlockPlaceEvent(BlockPlaceEvent e, LinkedBeaconTeleporterItem lbtItem){
Block block = e.getBlock();
LinkedBeaconTeleporterBlock lbtBlock = Main.lbtManager.placeLbtItem(lbtItem, block);
}
}

Loading…
Cancel
Save