mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2025-02-20 06:11:30 +01:00
Added MythicMobs compatibility to mob trigger
This commit is contained in:
parent
b4599e74f3
commit
cabbb35775
@ -113,7 +113,9 @@ public class DPlayer {
|
|||||||
remove(this);
|
remove(this);
|
||||||
|
|
||||||
// Lives
|
// Lives
|
||||||
|
if (p.lives.containsKey(player)) {
|
||||||
p.lives.remove(player);
|
p.lives.remove(player);
|
||||||
|
}
|
||||||
|
|
||||||
DConfig dConfig = GameWorld.get(world).config;
|
DConfig dConfig = GameWorld.get(world).config;
|
||||||
if (this.isFinished) {
|
if (this.isFinished) {
|
||||||
|
@ -2,6 +2,7 @@ package com.dre.dungeonsxl.game;
|
|||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -15,6 +16,8 @@ public class DMob {
|
|||||||
public LivingEntity entity;
|
public LivingEntity entity;
|
||||||
public DMobType type;
|
public DMobType type;
|
||||||
|
|
||||||
|
public String trigger;
|
||||||
|
|
||||||
public DMob(LivingEntity entity, GameWorld gworld, DMobType type) {
|
public DMob(LivingEntity entity, GameWorld gworld, DMobType type) {
|
||||||
gworld.dmobs.add(this);
|
gworld.dmobs.add(this);
|
||||||
|
|
||||||
@ -29,6 +32,21 @@ public class DMob {
|
|||||||
this.entity.getEquipment().setItemInHandDropChance(0);
|
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
|
// Statics
|
||||||
public static void onDeath(EntityDeathEvent event) {
|
public static void onDeath(EntityDeathEvent event) {
|
||||||
if (event.getEntity() instanceof LivingEntity) {
|
if (event.getEntity() instanceof LivingEntity) {
|
||||||
@ -49,6 +67,8 @@ public class DMob {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
name = dmob.type.getName();
|
name = dmob.type.getName();
|
||||||
|
} else if (dmob.type == null && dmob.trigger != null) {// <=MythicMobs mob
|
||||||
|
name = dmob.trigger;
|
||||||
} else {
|
} else {
|
||||||
name = victim.getType().getName();
|
name = victim.getType().getName();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
package com.dre.dungeonsxl.signs;
|
package com.dre.dungeonsxl.signs;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
import com.dre.dungeonsxl.game.DMob;
|
||||||
import com.dre.dungeonsxl.game.GameWorld;
|
import com.dre.dungeonsxl.game.GameWorld;
|
||||||
|
|
||||||
public class SIGNMythicMobs extends DSign {
|
public class SIGNMythicMobs extends DSign {
|
||||||
@ -22,6 +27,9 @@ public class SIGNMythicMobs extends DSign {
|
|||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
private boolean active;
|
private boolean active;
|
||||||
private int taskId = -1;
|
private int taskId = -1;
|
||||||
|
private Location spawnLoc;
|
||||||
|
private LivingEntity mythicMob;
|
||||||
|
private ArrayList<Entity> mythicMobs = new ArrayList<Entity>();
|
||||||
|
|
||||||
public SIGNMythicMobs(Sign sign, GameWorld gworld) {
|
public SIGNMythicMobs(Sign sign, GameWorld gworld) {
|
||||||
super(sign, gworld);
|
super(sign, gworld);
|
||||||
@ -104,15 +112,19 @@ public class SIGNMythicMobs extends DSign {
|
|||||||
GameWorld gworld = GameWorld.get(world);
|
GameWorld gworld = GameWorld.get(world);
|
||||||
|
|
||||||
if (gworld != null) {
|
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 x = spawnLoc.getX();
|
||||||
double y = spawnLoc.getY();
|
double y = spawnLoc.getY();
|
||||||
double z = spawnLoc.getZ();
|
double z = spawnLoc.getZ();
|
||||||
|
|
||||||
String command = "mm mobs spawn " + mob + " " + amount + " DXL_Game_" + gworld.id + ","+ x + "," + y + "," + z;
|
String command = "mm mobs spawn " + mob + " " + amount + " DXL_Game_" + gworld.id + ","+ x + "," + y + "," + z;
|
||||||
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command);
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command);
|
||||||
|
|
||||||
|
setMythicMobs();
|
||||||
|
if (mythicMob != null) {
|
||||||
|
new DMob(mythicMob, sign.gworld, null, mob);
|
||||||
|
}
|
||||||
|
|
||||||
// Set the amount
|
// Set the amount
|
||||||
if (amount != -1) {
|
if (amount != -1) {
|
||||||
if (amount > 1) {
|
if (amount > 1) {
|
||||||
@ -141,4 +153,20 @@ public class SIGNMythicMobs extends DSign {
|
|||||||
public boolean isOnDungeonInit() {
|
public boolean isOnDungeonInit() {
|
||||||
return onDungeonInit;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user