Guest User

Untitled

a guest
Feb 14th, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  2. public void onPlayerInteract(PlayerInteractEvent e) {
  3. if (e.useInteractedBlock() != Result.ALLOW) return;
  4. Player p = e.getPlayer();
  5. if (e.getAction().toString().equalsIgnoreCase(plugin.getConfig().getString("Check.Type"))) {
  6. String required = plugin.getConfig().getString("Check.Item");
  7. if (required.equals("*") || (MultiVersion.get().getItemInHand(p) != null && MultiVersion.get().getItemInHand(p).getType().toString().equalsIgnoreCase(required))) {
  8. Block block = e.getClickedBlock();
  9. Optional<DamagedBlock> optDmgBlock = DamagedBlock.get(block);
  10. if (optDmgBlock.isPresent()) {
  11. DamagedBlock dmgBlock = optDmgBlock.get();
  12. int percent = (int) (((dmgBlock.getHealth() * 100) / ConfigHandler.getDefaultHealth(block.getType())));
  13. int health = (int) Math.round(dmgBlock.getHealth());
  14. String str = PlaceholderAPI.setPlaceholders(p,"%bo_health_block% " +String.valueOf(health));
  15. p.sendMessage(str);
  16.  
  17. } else if (ConfigHandler.makeBlowable(block) && plugin.getConfig().getBoolean("Always Send Health")) {
  18. int health = (int) Math.round(ConfigHandler.getDefaultHealth(block.getType()));
  19. BlowablePlugin.getInstance().vanished.add(p);
  20. PlaceholderAPI.setPlaceholders(p,"%bo_health_block% " +String.valueOf(health));
  21.  
  22.  
  23. }
  24. }
  25. }
  26.  
  27. }
Add Comment
Please, Sign In to add comment