-
Notifications
You must be signed in to change notification settings - Fork 2
/
InstaSoup
29 lines (29 loc) · 1.87 KB
/
InstaSoup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Player player = e.getPlayer();
if(e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
if(player.getItemInHand().getType() == Material.MUSHROOM_SOUP) {
int health = player.getHealth();
int foodlvl = player.getFoodLevel();
if(health == 20 && foodlvl >= 13) {
player.setFoodLevel(20);
player.setItemInHand(new ItemStack(Material.AIR));
player.sendMessage(ChatColor.BLUE + "Heal> " + ChatColor.YELLOW + "You were healed by " + ChatColor.GOLD + "Mushroom Soup" + ChatColor.YELLOW + ".");
} else if(health == 20 && foodlvl < 13) {
player.setFoodLevel(foodlvl + 7);
player.setItemInHand(new ItemStack(Material.AIR));
player.sendMessage(ChatColor.BLUE + "Heal> " + ChatColor.YELLOW + "You were healed by " + ChatColor.GOLD + "Mushroom Soup" + ChatColor.YELLOW + ".");
} else {
if(health < 20 && health >= 13) {
player.setHealth(20);
player.setItemInHand(new ItemStack(Material.AIR));
player.sendMessage(ChatColor.BLUE + "Heal> " + ChatColor.YELLOW + "You were healed by " + ChatColor.GOLD + "Mushroom Soup" + ChatColor.YELLOW + ".");
} else if(health < 20 && health < 13) {
player.setHealth(health + 7);
player.setItemInHand(new ItemStack(Material.AIR));
player.sendMessage(ChatColor.BLUE + "Heal> " + ChatColor.YELLOW + "You were healed by " + ChatColor.GOLD + "Mushroom Soup" + ChatColor.YELLOW + ".");
}
}
}
}
}