@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onSpawn(PlayerInteractEvent e){
Player p = e.getPlayer();
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if(e.getHand() != EquipmentSlot.HAND) return;
if (e.getItem() == null || !e.getItem().hasItemMeta() || !e.getItem().getItemMeta().hasDisplayName() || e.getItem().getType() != Material.MONSTER_EGG) return;
if (!ChatColor.stripColor(e.getItem().getItemMeta().getDisplayName()).contains("Spawn")) return;
int id = Integer.parseInt(e.getItem().getItemMeta().getLore().get(0));
String s = e.getItem().getItemMeta().getLore().get(1);
boolean canCatch = true;
ApplicableRegionSet region = plugin.getWg().getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation());
for (ProtectedRegion r : region.getRegions()) if (!r.getOwners().contains(p.getName())) canCatch = false;
if (!canCatch) {
p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No puedes spawnear un mob en parcelas ajenas");
return;
}
SNMob mob = new SNMob(p);
if (!mob.isOwner(id)) {
p.sendMessage(SafariNet.getInstance().getPrefix() + ChatColor.RED + "No eres el dueño de este huevo");
return;
}
mob.spawnMob(id, s);
p.getInventory().getItemInMainHand().setAmount(-1);
}
}
SpawnMob.java 文件源码
java
阅读 17
收藏 0
点赞 0
评论 0
项目:PA
作者:
评论列表
文章目录