Implemented breaking of LinkedBeaconTeleporterBlock and dropping LinkedBeaconTeleporterItem
This commit is contained in:
		
							parent
							
								
									3f73d15a5a
								
							
						
					
					
						commit
						d9c95a5e53
					
				| @ -24,6 +24,11 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter { | |||||||
| 
 | 
 | ||||||
|         this.item = item; |         this.item = item; | ||||||
|     } |     } | ||||||
|  |     public LinkedBeaconTeleporterItem(String teleporterId){ | ||||||
|  |         this(teleporterId, | ||||||
|  |                 new ItemStack(Material.BEACON) | ||||||
|  |         ); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     public ItemStack item(){ |     public ItemStack item(){ | ||||||
|         return item; |         return item; | ||||||
|  | |||||||
| @ -76,6 +76,23 @@ public class LinkedBeaconTeleporterManager { | |||||||
|         Main.log.info("All done!"); |         Main.log.info("All done!"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public LinkedBeaconTeleporterItem breakLbtBlock(LinkedBeaconTeleporterBlock lbtBlock){ | ||||||
|  |         // Get list by id | ||||||
|  |         List<LinkedBeaconTeleporterBlock> lbtBlocks = linkedBeaconTeleporterById.get(lbtBlock.teleporterId()); | ||||||
|  | 
 | ||||||
|  |         // Remove from list | ||||||
|  |         lbtBlocks.remove(lbtBlock); | ||||||
|  |         // Remove from location | ||||||
|  |         linkedBeaconTeleporterByLoc.remove( | ||||||
|  |                 Function.serialiseBlockLocation(lbtBlock.block().getLocation()) | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         // Item from block | ||||||
|  |         LinkedBeaconTeleporterItem lbtItem = new LinkedBeaconTeleporterItem(lbtBlock.teleporterId()); | ||||||
|  | 
 | ||||||
|  |         return lbtItem; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     // Conversion-methods |     // Conversion-methods | ||||||
|     public ItemStack getItemStackFromLbtItem(LinkedBeaconTeleporterItem lbtItem){ |     public ItemStack getItemStackFromLbtItem(LinkedBeaconTeleporterItem lbtItem){ | ||||||
|         ItemStack item = new ItemStack(Material.BEACON); |         ItemStack item = new ItemStack(Material.BEACON); | ||||||
|  | |||||||
| @ -1,11 +1,24 @@ | |||||||
| package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.listener; | 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.LinkedBeaconTeleporterBlock; | ||||||
|  | import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterItem; | ||||||
|  | import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterManager; | ||||||
| import org.bukkit.event.block.BlockBreakEvent; | import org.bukkit.event.block.BlockBreakEvent; | ||||||
| 
 | 
 | ||||||
| public class OnBlockBreak { | public class OnBlockBreak { | ||||||
| 
 | 
 | ||||||
|     public static void onBlockBreakEvent(BlockBreakEvent e, LinkedBeaconTeleporterBlock lbtBlock){ |     public static void onBlockBreakEvent(BlockBreakEvent e, LinkedBeaconTeleporterBlock lbtBlock){ | ||||||
|  |         LinkedBeaconTeleporterItem lbtItem = Main.lbtManager.breakLbtBlock(lbtBlock); | ||||||
| 
 | 
 | ||||||
|  |         // Dont drop anything | ||||||
|  |         e.setDropItems(false); | ||||||
|  |         e.setExpToDrop(0); | ||||||
|  | 
 | ||||||
|  |         // Drop custom-item | ||||||
|  |         lbtBlock.block().getLocation().getWorld().dropItemNaturally( | ||||||
|  |                 lbtBlock.block().getLocation(), | ||||||
|  |                 lbtItem.item() | ||||||
|  |         ); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user