1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2026-02-19 18:33:00 +01:00

More optimizing.

This commit is contained in:
GJ
2012-02-23 22:26:20 -05:00
parent 10fa9e5465
commit 19ab8b89f5
6 changed files with 38 additions and 94 deletions

View File

@@ -23,7 +23,6 @@ import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.inventory.ItemStack;
@@ -180,15 +179,21 @@ public class m
return true;
}
public static void mcDropItem(Location location, int id)
public static void mcDropItems(Location location, ItemStack is, int quantity)
{
if(location == null) return;
Material mat = Material.getMaterial(id);
ItemStack item = new ItemStack(mat, 1, (byte) 0, (byte) 0);
mcDropItem(location, item);
for(int i = 0; i < quantity; i++)
mcDropItem(location, is);
}
public static void mcRandomDropItem(Location location, ItemStack is, int chance)
{
if(Math.random() * 100 < chance)
mcDropItem(location, is);
}
public static void mcRandomDropItems(Location location, ItemStack is, int chance, int quantity)
{
for(int i = 0; i < quantity; i++)
mcRandomDropItem(location, is, chance);
}
public static void mcDropItem(Location location, ItemStack itemStack) {
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
McMMOItemSpawnEvent event = new McMMOItemSpawnEvent(location, itemStack);