Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
- public void onPlayerInteract(PlayerInteractEvent e) {
- if (e.useInteractedBlock() != Result.ALLOW) return;
- Player p = e.getPlayer();
- if (e.getAction().toString().equalsIgnoreCase(plugin.getConfig().getString("Check.Type"))) {
- String required = plugin.getConfig().getString("Check.Item");
- if (required.equals("*") || (MultiVersion.get().getItemInHand(p) != null && MultiVersion.get().getItemInHand(p).getType().toString().equalsIgnoreCase(required))) {
- Block block = e.getClickedBlock();
- Optional<DamagedBlock> optDmgBlock = DamagedBlock.get(block);
- if (optDmgBlock.isPresent()) {
- DamagedBlock dmgBlock = optDmgBlock.get();
- int percent = (int) (((dmgBlock.getHealth() * 100) / ConfigHandler.getDefaultHealth(block.getType())));
- int health = (int) Math.round(dmgBlock.getHealth());
- String str = PlaceholderAPI.setPlaceholders(p,"%bo_health_block% " +String.valueOf(health));
- p.sendMessage(str);
- } else if (ConfigHandler.makeBlowable(block) && plugin.getConfig().getBoolean("Always Send Health")) {
- int health = (int) Math.round(ConfigHandler.getDefaultHealth(block.getType()));
- BlowablePlugin.getInstance().vanished.add(p);
- PlaceholderAPI.setPlaceholders(p,"%bo_health_block% " +String.valueOf(health));
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment