Skip to content

Commit

Permalink
no more heal when dropping the items
Browse files Browse the repository at this point in the history
also, added some further logic to checking for left and right clicks respectively
  • Loading branch information
xsmeths committed May 8, 2021
1 parent 532c198 commit c3286f8
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class MedCraftListeners implements Listener {
@EventHandler
public void onPlayerUseMedKit(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (e.getAction() == Action.PHYSICAL) {
return;
}
ItemStack[] toCheck;
Expand All @@ -44,13 +44,12 @@ public void onPlayerUseMedKit(PlayerInteractEvent e) {
toCheck[0] = p.getInventory().getItemInHand();
}
for (ItemStack i : toCheck)
if ((i.getType().equals(ItemLoader.getMedKitItem().getType())) && i.getItemMeta().hasCustomModelData() && e.getClickedBlock() != null && !e.getClickedBlock().getType().toString().contains("BED") && e.getClickedBlock().getType() != Material.CHEST && e.getClickedBlock().getType() != Material.FURNACE && e.getClickedBlock().getType() != Material.BLAST_FURNACE && e.getClickedBlock().getType() != Material.SMOKER && e.getClickedBlock().getType() != Material.TRAPPED_CHEST && e.getClickedBlock().getType() != Material.CHEST_MINECART && e.getClickedBlock().getType() != Material.FURNACE_MINECART && e.getClickedBlock().getType() != Material.HOPPER_MINECART && e.getClickedBlock().getType() != Material.CRAFTING_TABLE && e.getClickedBlock().getType() != Material.HOPPER && e.getClickedBlock().getType() != Material.ENDER_CHEST && e.getClickedBlock().getType() != Material.BREWING_STAND && e.getClickedBlock().getType() != Material.BARREL && e.getClickedBlock().getType() != Material.FLETCHING_TABLE && e.getClickedBlock().getType() != Material.CARTOGRAPHY_TABLE && e.getClickedBlock().getType() != Material.GRINDSTONE && e.getClickedBlock().getType() != Material.STONECUTTER && e.getClickedBlock().getType() != Material.SMITHING_TABLE && e.getClickedBlock().getType() != Material.LOOM && p.getGameMode() != GameMode.CREATIVE && (i.getItemMeta().getCustomModelData() == MedCraft.getPlugin().getConfig().getInt("MedKit.ModelData")) || (i.getType().equals(ItemLoader.getMedKitItem().getType())) && i.getItemMeta().hasCustomModelData() && e.getClickedBlock() == null && p.getGameMode() != GameMode.CREATIVE && (i.getItemMeta().getCustomModelData() == MedCraft.getPlugin().getConfig().getInt("MedKit.ModelData"))) {
if (e.getAction() == Action.LEFT_CLICK_BLOCK && (i.getType().equals(ItemLoader.getMedKitItem().getType())) && i.getItemMeta().hasCustomModelData() && e.getClickedBlock() != null && !e.getClickedBlock().getType().toString().contains("FURNACE") && e.getClickedBlock().getType() != Material.SMOKER && !e.getClickedBlock().getType().toString().contains("TABLE") && !e.getClickedBlock().getType().toString().contains("HOPPER") && e.getClickedBlock().getType() != Material.BREWING_STAND && e.getClickedBlock().getType() != Material.LOOM && p.getGameMode() != GameMode.CREATIVE && (i.getItemMeta().getCustomModelData() == MedCraft.getPlugin().getConfig().getInt("MedKit.ModelData")) || e.getAction() == Action.RIGHT_CLICK_BLOCK && (i.getType().equals(ItemLoader.getMedKitItem().getType())) && i.getItemMeta().hasCustomModelData() && e.getClickedBlock() != null && !e.getClickedBlock().getType().toString().contains("CHEST") && !e.getClickedBlock().getType().toString().contains("BED") && !e.getClickedBlock().getType().toString().contains("FURNACE") && e.getClickedBlock().getType() != Material.SMOKER && !e.getClickedBlock().getType().toString().contains("TABLE") && !e.getClickedBlock().getType().toString().contains("HOPPER") && e.getClickedBlock().getType() != Material.BREWING_STAND && e.getClickedBlock().getType() != Material.LOOM && p.getGameMode() != GameMode.CREATIVE && (i.getItemMeta().getCustomModelData() == MedCraft.getPlugin().getConfig().getInt("MedKit.ModelData")) || (i.getType().equals(ItemLoader.getMedKitItem().getType())) && i.getItemMeta().hasCustomModelData() && e.getClickedBlock() == null && p.getGameMode() != GameMode.CREATIVE && (i.getItemMeta().getCustomModelData() == MedCraft.getPlugin().getConfig().getInt("MedKit.ModelData"))) {
if (p.getInventory().getItemInMainHand().getAmount() == 1 && p.hasPermission("medkit.use")) {
int heldslot = p.getInventory().getHeldItemSlot();
p.getInventory().setItem(heldslot, new ItemStack(Material.AIR));
p.updateInventory();
new MedKitHandler(p);
return;
new MedKitHandler(p); return;
}
if (i.getAmount() >= 2 && p.hasPermission("medkit.use")) {
i.setAmount(i.getAmount() - 1);
Expand All @@ -65,7 +64,7 @@ public void onPlayerUseMedKit(PlayerInteractEvent e) {
}
}
for (ItemStack i : toCheck)
if ((i.getType().equals(ItemLoader.getBandageItem().getType())) && e.getClickedBlock() != null && !e.getClickedBlock().getType().toString().contains("BED") && e.getClickedBlock().getType() != Material.CHEST && e.getClickedBlock().getType() != Material.FURNACE && e.getClickedBlock().getType() != Material.BLAST_FURNACE && e.getClickedBlock().getType() != Material.SMOKER && e.getClickedBlock().getType() != Material.TRAPPED_CHEST && e.getClickedBlock().getType() != Material.CHEST_MINECART && e.getClickedBlock().getType() != Material.FURNACE_MINECART && e.getClickedBlock().getType() != Material.HOPPER_MINECART && e.getClickedBlock().getType() != Material.CRAFTING_TABLE && e.getClickedBlock().getType() != Material.HOPPER && e.getClickedBlock().getType() != Material.ENDER_CHEST && e.getClickedBlock().getType() != Material.BREWING_STAND && e.getClickedBlock().getType() != Material.BARREL && e.getClickedBlock().getType() != Material.FLETCHING_TABLE && e.getClickedBlock().getType() != Material.CARTOGRAPHY_TABLE && e.getClickedBlock().getType() != Material.GRINDSTONE && e.getClickedBlock().getType() != Material.STONECUTTER && e.getClickedBlock().getType() != Material.SMITHING_TABLE && e.getClickedBlock().getType() != Material.LOOM && i.getItemMeta().hasCustomModelData() && p.getGameMode() != GameMode.CREATIVE && (i.getItemMeta().getCustomModelData() == MedCraft.getPlugin().getConfig().getInt("Bandage.ModelData")) || (i.getType().equals(ItemLoader.getBandageItem().getType())) && e.getClickedBlock() == null && i.getItemMeta().hasCustomModelData() && p.getGameMode() != GameMode.CREATIVE && (i.getItemMeta().getCustomModelData() == MedCraft.getPlugin().getConfig().getInt("Bandage.ModelData"))) {
if (e.getAction() == Action.LEFT_CLICK_BLOCK && (i.getType().equals(ItemLoader.getBandageItem().getType())) && e.getClickedBlock() != null && !e.getClickedBlock().getType().toString().contains("FURNACE") && e.getClickedBlock().getType() != Material.SMOKER && !e.getClickedBlock().getType().toString().contains("TABLE") && !e.getClickedBlock().getType().toString().contains("HOPPER") && e.getClickedBlock().getType() != Material.BREWING_STAND && e.getClickedBlock().getType() != Material.LOOM && i.getItemMeta().hasCustomModelData() && p.getGameMode() != GameMode.CREATIVE && (i.getItemMeta().getCustomModelData() == MedCraft.getPlugin().getConfig().getInt("Bandage.ModelData")) || e.getAction() == Action.RIGHT_CLICK_BLOCK && (i.getType().equals(ItemLoader.getBandageItem().getType())) && e.getClickedBlock() != null && !e.getClickedBlock().getType().toString().contains("FURNACE") && !e.getClickedBlock().getType().toString().contains("BED") && e.getClickedBlock().getType() != Material.SMOKER && !e.getClickedBlock().getType().toString().contains("TABLE") && !e.getClickedBlock().getType().toString().contains("HOPPER") && !e.getClickedBlock().getType().toString().contains("CHEST") && e.getClickedBlock().getType() != Material.BREWING_STAND && e.getClickedBlock().getType() != Material.LOOM && i.getItemMeta().hasCustomModelData() && p.getGameMode() != GameMode.CREATIVE && (i.getItemMeta().getCustomModelData() == MedCraft.getPlugin().getConfig().getInt("Bandage.ModelData")) || (i.getType().equals(ItemLoader.getBandageItem().getType())) && e.getClickedBlock() == null && i.getItemMeta().hasCustomModelData() && p.getGameMode() != GameMode.CREATIVE && (i.getItemMeta().getCustomModelData() == MedCraft.getPlugin().getConfig().getInt("Bandage.ModelData"))) {
if (p.getInventory().getItemInMainHand().getAmount() == 1 && p.hasPermission("bandage.use")) {
int heldslot = p.getInventory().getHeldItemSlot();
p.getInventory().setItem(heldslot, new ItemStack(Material.AIR));
Expand Down

0 comments on commit c3286f8

Please sign in to comment.