/**
* This fires after the damage event does, so this, somehow, works.
*/
@EventHandler
public void eggCollide(PlayerEggThrowEvent event) {
if (eggTracker.getEntry(event.getEgg()) != null) {
eggTracker.getEntry(event.getEgg()).setPlayer(event.getPlayer());
event.setHatching(false);
} else {
return;
}
// The player is undefined before we set it above. So to make sure the
// local var is in fact a true copy, we will define it post assignment.
EggTrackerEntry entry = eggTracker.getEntry(event.getEgg());
if (entry.getPlayer().hasPermission("SimpleEgg." + entry.getEntity().getType().toString().replaceAll("_", "").toLowerCase())) {
if (!captureManager.ownerConfliction(entry)) {
if (expenseHandler.hasMaterials(entry.getPlayer())) {
captureManager.makeSpawnEgg(entry);
} else {
entry.getPlayer().sendMessage(Text.tag + "You need " + Text.a + expenseHandler.requiredMaterials() + Text.b + " to capture a mob.");
refundEgg(entry.getPlayer());
}
} else {
entry.getPlayer().sendMessage(Text.tag + "You do not own this mob.");
refundEgg(entry.getPlayer());
}
} else {
entry.getPlayer().sendMessage(Text.tag + "You do not have permission to capture this mob type.");
refundEgg(entry.getPlayer());
}
eggTracker.removeEntry(entry);
}
ListenerEggEvents.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:SimpleEgg
作者:
评论列表
文章目录