Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Listener
- public void onPlayerPlaceBlock(ChangeBlockEvent.Place event)
- {
- if(event.getCause().first(Player.class).isPresent())
- {
- Player player = (Player) event.getCause().first(Player.class).get();
- System.out.println(player.getItemInHand().isPresent());
- if(player.getItemInHand().isPresent() && player.getItemInHand().get().get(DisplayNameData.class).isPresent() && player.getItemInHand().get().get(DisplayNameData.class).get().get(Keys.DISPLAY_NAME).get().toString().contains("dark_red") && Texts.toPlain(player.getItemInHand().get().get(DisplayNameData.class).get().get(Keys.DISPLAY_NAME).get()).equals("Crate"))
- {
- player.setItemInHand(null);
- for(Transaction<BlockSnapshot> transaction : event.getTransactions())
- {
- System.out.println(transaction.getFinal().get(Keys.DISPLAY_NAME).isPresent());
- System.out.println(transaction.getFinal().getState().get(Keys.DISPLAY_NAME).isPresent());
- crateBlocks.add(transaction.getFinal().getLocation().get());
- }
- }
- for(Transaction<BlockSnapshot> transaction : event.getTransactions())
- {
- System.out.println(transaction.getFinal().get(Keys.DISPLAY_NAME).isPresent());
- System.out.println(transaction.getFinal().getState().get(Keys.DISPLAY_NAME).isPresent());
- crateBlocks.add(transaction.getFinal().getLocation().get());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment