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

New McMMOItemSpawnEvent

- Changed all of mcMMO to use one drop method to facilitate new event
- Added a missing bit of copyright notice to last event
This commit is contained in:
NuclearW
2012-01-29 02:51:59 -05:00
parent a61efae527
commit 01bbd9bcac
10 changed files with 213 additions and 100 deletions

View File

@@ -31,6 +31,7 @@ import com.gmail.nossr50.config.*;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.FakeBlockBreakEvent;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.McMMOItemSpawnEvent;
public class m
{
@@ -255,15 +256,21 @@ public class m
}
return true;
}
public static void mcDropItem(Location loc, int id)
public static void mcDropItem(Location location, int id)
{
if(loc != null)
{
Material mat = Material.getMaterial(id);
byte damage = 0;
ItemStack item = new ItemStack(mat, 1, (byte)0, damage);
loc.getWorld().dropItemNaturally(loc, item);
}
if(location == null) return;
Material mat = Material.getMaterial(id);
ItemStack item = new ItemStack(mat, 1, (byte) 0, (byte) 0);
mcDropItem(location, item);
}
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);
Bukkit.getPluginManager().callEvent(event);
if(event.isCancelled()) return;
location.getWorld().dropItemNaturally(location, itemStack);
}
public static boolean isSwords(ItemStack is)