diff --git a/src/com/dre/dungeonsxl/DPlayer.java b/src/com/dre/dungeonsxl/DPlayer.java index 4df29995..cbb8f68e 100644 --- a/src/com/dre/dungeonsxl/DPlayer.java +++ b/src/com/dre/dungeonsxl/DPlayer.java @@ -113,7 +113,9 @@ public class DPlayer { remove(this); // Lives - p.lives.remove(player); + if (p.lives.containsKey(player)) { + p.lives.remove(player); + } DConfig dConfig = GameWorld.get(world).config; if (this.isFinished) { diff --git a/src/com/dre/dungeonsxl/game/DMob.java b/src/com/dre/dungeonsxl/game/DMob.java index 40eef78b..d07ea539 100644 --- a/src/com/dre/dungeonsxl/game/DMob.java +++ b/src/com/dre/dungeonsxl/game/DMob.java @@ -2,6 +2,7 @@ package com.dre.dungeonsxl.game; import java.util.Random; +import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; @@ -15,6 +16,8 @@ public class DMob { public LivingEntity entity; public DMobType type; + public String trigger; + public DMob(LivingEntity entity, GameWorld gworld, DMobType type) { gworld.dmobs.add(this); @@ -29,6 +32,21 @@ public class DMob { this.entity.getEquipment().setItemInHandDropChance(0); } + public DMob(LivingEntity entity, GameWorld gworld, DMobType type, String trigger) { + gworld.dmobs.add(this); + + this.entity = entity; + this.type = type; + this.trigger = trigger; + + /* Remove DropChance of equipment */ + this.entity.getEquipment().setHelmetDropChance(0); + this.entity.getEquipment().setChestplateDropChance(0); + this.entity.getEquipment().setLeggingsDropChance(0); + this.entity.getEquipment().setBootsDropChance(0); + this.entity.getEquipment().setItemInHandDropChance(0); + } + // Statics public static void onDeath(EntityDeathEvent event) { if (event.getEntity() instanceof LivingEntity) { @@ -49,6 +67,8 @@ public class DMob { } } name = dmob.type.getName(); + } else if (dmob.type == null && dmob.trigger != null) {// <=MythicMobs mob + name = dmob.trigger; } else { name = victim.getType().getName(); } diff --git a/src/com/dre/dungeonsxl/signs/SIGNMythicMobs.java b/src/com/dre/dungeonsxl/signs/SIGNMythicMobs.java index 6cbba69b..9881e654 100644 --- a/src/com/dre/dungeonsxl/signs/SIGNMythicMobs.java +++ b/src/com/dre/dungeonsxl/signs/SIGNMythicMobs.java @@ -1,11 +1,16 @@ package com.dre.dungeonsxl.signs; +import java.util.ArrayList; + +import org.bukkit.entity.Entity; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Sign; +import org.bukkit.entity.LivingEntity; import org.bukkit.Location; +import com.dre.dungeonsxl.game.DMob; import com.dre.dungeonsxl.game.GameWorld; public class SIGNMythicMobs extends DSign { @@ -22,6 +27,9 @@ public class SIGNMythicMobs extends DSign { private boolean initialized; private boolean active; private int taskId = -1; + private Location spawnLoc; + private LivingEntity mythicMob; + private ArrayList mythicMobs = new ArrayList(); public SIGNMythicMobs(Sign sign, GameWorld gworld) { super(sign, gworld); @@ -104,15 +112,19 @@ public class SIGNMythicMobs extends DSign { GameWorld gworld = GameWorld.get(world); if (gworld != null) { - Location spawnLoc = sign.sign.getLocation().add(0.5, 0, 0.5); + spawnLoc = sign.sign.getLocation().add(0.5, 0, 0.5); double x = spawnLoc.getX(); double y = spawnLoc.getY(); double z = spawnLoc.getZ(); String command = "mm mobs spawn " + mob + " " + amount + " DXL_Game_" + gworld.id + ","+ x + "," + y + "," + z; - Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command); + setMythicMobs(); + if (mythicMob != null) { + new DMob(mythicMob, sign.gworld, null, mob); + } + // Set the amount if (amount != -1) { if (amount > 1) { @@ -141,4 +153,20 @@ public class SIGNMythicMobs extends DSign { public boolean isOnDungeonInit() { return onDungeonInit; } + + private void setMythicMobs() { + for (Entity entity : spawnLoc.getChunk().getEntities()) { + if (entity.getLocation().getX() >= spawnLoc.getX()-1 + && entity.getLocation().getX() <= spawnLoc.getX()+1 + && entity.getLocation().getY() >= spawnLoc.getY()-1 + && entity.getLocation().getY() <= spawnLoc.getY()+1 + && entity.getLocation().getZ() >= spawnLoc.getZ()-1 + && entity.getLocation().getZ() <= spawnLoc.getZ()+1 + && !mythicMobs.contains(entity)) { + mythicMob = (LivingEntity) entity; + mythicMobs.add(entity); + return; + } + } + } }