Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions src/com/untamedears/bottleO/EventListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void onPlayerInteractEvent(PlayerInteractEvent e) {
}
}
}
} else if (e.getMaterial() == Material.EMERALD || e.getMaterial() == Material.EMERALD_BLOCK) {
} else if (e.getMaterial() == Material.EMERALD || e.getMaterial() == Material.EMERALD_BLOCK || e.getMaterial() == Material.EXP_BOTTLE) {
Player p = e.getPlayer();
//check player has waited for the required amount of time
if (!playerWaitHash.containsKey(p.getName())) {
Expand All @@ -211,17 +211,29 @@ public void onPlayerInteractEvent(PlayerInteractEvent e) {
ItemStack i = p.getItemInHand();
Material m = e.getMaterial();
int amount = i.getAmount();
int xp = amount*BOTTLES_PER_EMERALD*XP_PER_BOTTLE;
if (m == Material.EMERALD_BLOCK) {
xp *= EMERALDS_PER_BLOCK;
int xp = 0;
switch (m) {
case EMERALD_BLOCK:
xp = amount * EMERALDS_PER_BLOCK * BOTTLES_PER_EMERALD * XP_PER_BOTTLE;
break;
case EMERALD:
xp = amount * BOTTLES_PER_EMERALD * XP_PER_BOTTLE;
break;
case EXP_BOTTLE:
xp = amount * XP_PER_BOTTLE;
break;
}
PlayerExpChangeEvent event = new PlayerExpChangeEvent(p, xp);
Bukkit.getPluginManager().callEvent(event);

//destroy items
p.setItemInHand(new ItemStack(Material.AIR));

p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 40, 3));
if (m == Material.EXP_BOTTLE) {
//return empty bottles
p.setItemInHand(new ItemStack(Material.GLASS_BOTTLE, amount));
} else {
//destroy items
p.setItemInHand(new ItemStack(Material.AIR));
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 40, 3));
}

//restart cool-down timer
playerWaitHash.put(p.getName(), System.currentTimeMillis());
Expand Down