mirror of
https://github.com/songoda/EpicBosses.git
synced 2024-09-28 21:37:33 +02:00
3.0.0-SNAPSHOT-U29
+ Fully implemented BossCommands + Fully implemented BossMessages + Set up BossDamageListener + Small tweaks
This commit is contained in:
parent
f90716bcc6
commit
5397f90843
@ -46,10 +46,17 @@
|
|||||||
"dropTable": "SKTable"
|
"dropTable": "SKTable"
|
||||||
},
|
},
|
||||||
"messages": {
|
"messages": {
|
||||||
"onSpawn": "SKOnSpawn",
|
"onSpawn": {
|
||||||
"onDeath": "SKOnDeath",
|
"message": "SKOnSpawn",
|
||||||
|
"radius": -1
|
||||||
|
},
|
||||||
|
"onDeath": {
|
||||||
|
"message": "SKOnDeath",
|
||||||
|
"radius": -1
|
||||||
|
},
|
||||||
"taunts": {
|
"taunts": {
|
||||||
"delay": 60,
|
"delay": 60,
|
||||||
|
"radius": 100,
|
||||||
"taunts": [
|
"taunts": [
|
||||||
"SKTaunt1",
|
"SKTaunt1",
|
||||||
"SKTaunt2"
|
"SKTaunt2"
|
||||||
|
@ -4,7 +4,9 @@ import net.aminecraftdev.custombosses.CustomBosses;
|
|||||||
import net.aminecraftdev.custombosses.entity.BossEntity;
|
import net.aminecraftdev.custombosses.entity.BossEntity;
|
||||||
import net.aminecraftdev.custombosses.entity.elements.*;
|
import net.aminecraftdev.custombosses.entity.elements.*;
|
||||||
import net.aminecraftdev.custombosses.holder.ActiveBossHolder;
|
import net.aminecraftdev.custombosses.holder.ActiveBossHolder;
|
||||||
|
import net.aminecraftdev.custombosses.managers.files.BossCommandFileManager;
|
||||||
import net.aminecraftdev.custombosses.managers.files.BossItemFileManager;
|
import net.aminecraftdev.custombosses.managers.files.BossItemFileManager;
|
||||||
|
import net.aminecraftdev.custombosses.managers.files.BossMessagesFileManager;
|
||||||
import net.aminecraftdev.custombosses.utils.Debug;
|
import net.aminecraftdev.custombosses.utils.Debug;
|
||||||
import net.aminecraftdev.custombosses.utils.EntityFinder;
|
import net.aminecraftdev.custombosses.utils.EntityFinder;
|
||||||
import net.aminecraftdev.custombosses.utils.itemstack.holder.ItemStackHolder;
|
import net.aminecraftdev.custombosses.utils.itemstack.holder.ItemStackHolder;
|
||||||
@ -145,7 +147,9 @@ public class BossAPI {
|
|||||||
// return null;
|
// return null;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
return PLUGIN.getBossEntityManager().createActiveBossHolder(bossEntity, location);
|
String name = PLUGIN.getBossEntityContainer().getName(bossEntity);
|
||||||
|
|
||||||
|
return PLUGIN.getBossEntityManager().createActiveBossHolder(bossEntity, location, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,4 +166,30 @@ public class BossAPI {
|
|||||||
return bossItemFileManager.getItemStackHolder(name);
|
return bossItemFileManager.getItemStackHolder(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to obtain the list of strings that
|
||||||
|
* a message is built in to.
|
||||||
|
*
|
||||||
|
* @param id - the id from the messages.json
|
||||||
|
* @return null if not found, instance if found
|
||||||
|
*/
|
||||||
|
public static List<String> getStoredMessages(String id) {
|
||||||
|
BossMessagesFileManager bossMessagesFileManager = PLUGIN.getBossMessagesFileManager();
|
||||||
|
|
||||||
|
return bossMessagesFileManager.getMessages(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to obtain the list of strings that
|
||||||
|
* a command is built of.
|
||||||
|
*
|
||||||
|
* @param id - the id from the commands.json
|
||||||
|
* @return null if not found, instance if found
|
||||||
|
*/
|
||||||
|
public static List<String> getStoredCommands(String id) {
|
||||||
|
BossCommandFileManager bossCommandFileManager = PLUGIN.getBossCommandFileManager();
|
||||||
|
|
||||||
|
return bossCommandFileManager.getCommands(id);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,14 @@ public class BossEntityContainer implements IContainer<Map<String, BossEntity>,
|
|||||||
return new HashMap<>(this.container);
|
return new HashMap<>(this.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName(BossEntity bossEntity) {
|
||||||
|
for(Map.Entry<String, BossEntity> entry : getData().entrySet()) {
|
||||||
|
if(entry.getValue().equals(bossEntity)) return entry.getKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean saveData(Map<String, BossEntity> stringBossEntityMap) {
|
public boolean saveData(Map<String, BossEntity> stringBossEntityMap) {
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
@ -11,7 +11,7 @@ import lombok.Setter;
|
|||||||
*/
|
*/
|
||||||
public class MessagesElement {
|
public class MessagesElement {
|
||||||
|
|
||||||
@Expose @Getter @Setter private String onSpawn, onDeath;
|
@Expose @Getter @Setter private SubMessageElement onSpawn, onDeath;
|
||||||
@Expose @Getter @Setter private TauntElement taunts;
|
@Expose @Getter @Setter private TauntElement taunts;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package net.aminecraftdev.custombosses.entity.elements;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.Expose;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Charles Cullen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 20-Oct-18
|
||||||
|
*/
|
||||||
|
public class SubMessageElement {
|
||||||
|
|
||||||
|
@Expose @Getter @Setter private String message;
|
||||||
|
@Expose @Getter @Setter private Integer radius;
|
||||||
|
}
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class TauntElement {
|
public class TauntElement {
|
||||||
|
|
||||||
@Expose @Getter @Setter private Integer delay;
|
@Expose @Getter @Setter private Integer delay, radius;
|
||||||
@Expose @Getter @Setter private List<String> taunts;
|
@Expose @Getter @Setter private List<String> taunts;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
package net.aminecraftdev.custombosses.events;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.aminecraftdev.custombosses.holder.ActiveBossHolder;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Charles Cullen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 20-Oct-18
|
||||||
|
*/
|
||||||
|
public class BossDamageEvent extends Event {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
@Getter private ActiveBossHolder activeBossHolder;
|
||||||
|
@Getter private LivingEntity livingEntity;
|
||||||
|
@Getter private Location damageLocation;
|
||||||
|
@Getter private double damage;
|
||||||
|
|
||||||
|
public BossDamageEvent(ActiveBossHolder activeBossHolder, LivingEntity livingEntity, Location damageLocation, double damageAmount) {
|
||||||
|
this.activeBossHolder = activeBossHolder;
|
||||||
|
this.damageLocation = damageLocation;
|
||||||
|
this.livingEntity = livingEntity;
|
||||||
|
this.damage = damageAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Charles Cullen
|
* @author Charles Cullen
|
||||||
@ -18,12 +19,15 @@ public class ActiveBossHolder {
|
|||||||
|
|
||||||
@Getter private final BossEntity bossEntity;
|
@Getter private final BossEntity bossEntity;
|
||||||
@Getter private final Location location;
|
@Getter private final Location location;
|
||||||
|
@Getter private final String name;
|
||||||
|
|
||||||
@Getter private Map<Integer, LivingEntity> livingEntityMap = new HashMap<>();
|
@Getter private Map<Integer, LivingEntity> livingEntityMap = new HashMap<>();
|
||||||
|
@Getter private Map<UUID, Double> mapOfDamagingUsers = new HashMap<>();
|
||||||
|
|
||||||
public ActiveBossHolder(BossEntity bossEntity, Location spawnLocation) {
|
public ActiveBossHolder(BossEntity bossEntity, Location spawnLocation, String name) {
|
||||||
this.location = spawnLocation;
|
this.location = spawnLocation;
|
||||||
this.bossEntity = bossEntity;
|
this.bossEntity = bossEntity;
|
||||||
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLivingEntity(int position, LivingEntity livingEntity) {
|
public void setLivingEntity(int position, LivingEntity livingEntity) {
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
package net.aminecraftdev.custombosses.listeners.during;
|
||||||
|
|
||||||
|
import net.aminecraftdev.custombosses.CustomBosses;
|
||||||
|
import net.aminecraftdev.custombosses.events.BossDamageEvent;
|
||||||
|
import net.aminecraftdev.custombosses.holder.ActiveBossHolder;
|
||||||
|
import net.aminecraftdev.custombosses.managers.BossEntityManager;
|
||||||
|
import net.aminecraftdev.custombosses.utils.ServerUtils;
|
||||||
|
import org.bukkit.entity.*;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Charles Cullen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 20-Oct-18
|
||||||
|
*/
|
||||||
|
public class BossDamageListener implements Listener {
|
||||||
|
|
||||||
|
private BossEntityManager bossEntityManager;
|
||||||
|
|
||||||
|
public BossDamageListener(CustomBosses plugin) {
|
||||||
|
this.bossEntityManager = plugin.getBossEntityManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onBossDamage(EntityDamageByEntityEvent event) {
|
||||||
|
Entity entityBeingDamaged = event.getEntity();
|
||||||
|
Entity entityDamaging = event.getDamager();
|
||||||
|
|
||||||
|
if(!(entityBeingDamaged instanceof LivingEntity)) return;
|
||||||
|
|
||||||
|
LivingEntity livingEntity = (LivingEntity) entityBeingDamaged;
|
||||||
|
ActiveBossHolder activeBossHolder = this.bossEntityManager.getActiveBossHolder(livingEntity);
|
||||||
|
double damage = event.getDamage();
|
||||||
|
Player player = null;
|
||||||
|
|
||||||
|
if(activeBossHolder == null) return;
|
||||||
|
|
||||||
|
if(entityDamaging instanceof Player) {
|
||||||
|
player = (Player) entityDamaging;
|
||||||
|
} else if(entityDamaging instanceof Projectile) {
|
||||||
|
Projectile projectile = (Projectile) entityDamaging;
|
||||||
|
LivingEntity shooter = (LivingEntity) projectile.getShooter();
|
||||||
|
|
||||||
|
if(projectile instanceof ThrownPotion) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!(shooter instanceof Player)) return;
|
||||||
|
|
||||||
|
player = (Player) shooter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(player == null) return;
|
||||||
|
|
||||||
|
double currentDamage = activeBossHolder.getMapOfDamagingUsers().getOrDefault(player.getUniqueId(), 0.0);
|
||||||
|
BossDamageEvent bossDamageEvent = new BossDamageEvent(activeBossHolder, livingEntity, livingEntity.getEyeLocation(), damage);
|
||||||
|
|
||||||
|
ServerUtils.get().callEvent(bossDamageEvent);
|
||||||
|
activeBossHolder.getMapOfDamagingUsers().put(player.getUniqueId(), currentDamage+damage);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,16 +2,20 @@ package net.aminecraftdev.custombosses.listeners.pre;
|
|||||||
|
|
||||||
import net.aminecraftdev.custombosses.CustomBosses;
|
import net.aminecraftdev.custombosses.CustomBosses;
|
||||||
import net.aminecraftdev.custombosses.api.BossAPI;
|
import net.aminecraftdev.custombosses.api.BossAPI;
|
||||||
|
import net.aminecraftdev.custombosses.container.BossEntityContainer;
|
||||||
import net.aminecraftdev.custombosses.entity.BossEntity;
|
import net.aminecraftdev.custombosses.entity.BossEntity;
|
||||||
import net.aminecraftdev.custombosses.events.BossSpawnEvent;
|
import net.aminecraftdev.custombosses.events.BossSpawnEvent;
|
||||||
import net.aminecraftdev.custombosses.events.PreBossSpawnEvent;
|
import net.aminecraftdev.custombosses.events.PreBossSpawnEvent;
|
||||||
import net.aminecraftdev.custombosses.holder.ActiveBossHolder;
|
import net.aminecraftdev.custombosses.holder.ActiveBossHolder;
|
||||||
import net.aminecraftdev.custombosses.managers.BossEntityManager;
|
import net.aminecraftdev.custombosses.managers.BossEntityManager;
|
||||||
import net.aminecraftdev.custombosses.managers.BossLocationManager;
|
import net.aminecraftdev.custombosses.managers.BossLocationManager;
|
||||||
|
import net.aminecraftdev.custombosses.utils.Debug;
|
||||||
import net.aminecraftdev.custombosses.utils.Message;
|
import net.aminecraftdev.custombosses.utils.Message;
|
||||||
import net.aminecraftdev.custombosses.utils.ServerUtils;
|
import net.aminecraftdev.custombosses.utils.ServerUtils;
|
||||||
|
import net.aminecraftdev.custombosses.utils.StringUtils;
|
||||||
import net.aminecraftdev.custombosses.utils.itemstack.ItemStackUtils;
|
import net.aminecraftdev.custombosses.utils.itemstack.ItemStackUtils;
|
||||||
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
|
import net.aminecraftdev.custombosses.utils.version.VersionHandler;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -23,6 +27,7 @@ import org.bukkit.event.block.Action;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,7 +94,7 @@ public class BossSpawnListener implements Listener {
|
|||||||
ActiveBossHolder activeBossHolder = BossAPI.spawnNewBoss(bossEntity, location);
|
ActiveBossHolder activeBossHolder = BossAPI.spawnNewBoss(bossEntity, location);
|
||||||
|
|
||||||
if(activeBossHolder == null) {
|
if(activeBossHolder == null) {
|
||||||
//TODO: Make log file to store when a boss was spawned, where, what boss, and who spawned it, and the debug reason to why it couldn't spawn.
|
Debug.FAILED_TO_CREATE_ACTIVE_BOSS_HOLDER.debug();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -104,6 +109,8 @@ public class BossSpawnListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPreBossSpawnEvent(PreBossSpawnEvent event) {
|
public void onPreBossSpawnEvent(PreBossSpawnEvent event) {
|
||||||
ActiveBossHolder activeBossHolder = event.getActiveBossHolder();
|
ActiveBossHolder activeBossHolder = event.getActiveBossHolder();
|
||||||
|
BossEntity bossEntity = activeBossHolder.getBossEntity();
|
||||||
|
Location location = activeBossHolder.getLocation();
|
||||||
ItemStack itemStack = event.getItemStackUsed().clone();
|
ItemStack itemStack = event.getItemStackUsed().clone();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
@ -111,13 +118,36 @@ public class BossSpawnListener implements Listener {
|
|||||||
player.getInventory().removeItem(itemStack);
|
player.getInventory().removeItem(itemStack);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
|
||||||
|
List<String> commands = this.bossEntityManager.getOnSpawnCommands(bossEntity);
|
||||||
|
List<String> messages = this.bossEntityManager.getOnSpawnMessage(bossEntity);
|
||||||
|
int messagesRadius = this.bossEntityManager.getOnSpawnMessageRadius(bossEntity);
|
||||||
|
|
||||||
|
if(commands != null) {
|
||||||
|
commands.forEach(command -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command));
|
||||||
|
}
|
||||||
|
if(messages != null) {
|
||||||
|
if(activeBossHolder.getName() != null) messages.replaceAll(s -> s.replace("{boss}", activeBossHolder.getName()));
|
||||||
|
messages.replaceAll(s -> s.replace("{location}", StringUtils.get().translateLocation(location)));
|
||||||
|
messages.replaceAll(s -> s.replace('&', '§'));
|
||||||
|
|
||||||
|
if(messagesRadius == -1) {
|
||||||
|
messages.forEach(Bukkit::broadcastMessage);
|
||||||
|
} else {
|
||||||
|
Bukkit.getOnlinePlayers().forEach(onlinePlayer -> {
|
||||||
|
if(onlinePlayer.getWorld().getName().equals(location.getWorld().getName())) {
|
||||||
|
if(onlinePlayer.getLocation().distanceSquared(location) <= messagesRadius) {
|
||||||
|
messages.forEach(player::sendMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: Create AutoTarget for TargetHandler
|
//TODO: Create AutoTarget for TargetHandler
|
||||||
//TODO: Handle onSpawn commands, and messages
|
|
||||||
|
|
||||||
BossSpawnEvent bossSpawnEvent = new BossSpawnEvent(activeBossHolder);
|
BossSpawnEvent bossSpawnEvent = new BossSpawnEvent(activeBossHolder);
|
||||||
|
|
||||||
ServerUtils.get().callEvent(bossSpawnEvent);
|
ServerUtils.get().callEvent(bossSpawnEvent);
|
||||||
System.out.println("SPAWN EVENT CALLED");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,14 @@ import net.aminecraftdev.custombosses.CustomBosses;
|
|||||||
import net.aminecraftdev.custombosses.api.BossAPI;
|
import net.aminecraftdev.custombosses.api.BossAPI;
|
||||||
import net.aminecraftdev.custombosses.entity.BossEntity;
|
import net.aminecraftdev.custombosses.entity.BossEntity;
|
||||||
import net.aminecraftdev.custombosses.holder.ActiveBossHolder;
|
import net.aminecraftdev.custombosses.holder.ActiveBossHolder;
|
||||||
|
import net.aminecraftdev.custombosses.managers.files.BossCommandFileManager;
|
||||||
import net.aminecraftdev.custombosses.managers.files.BossItemFileManager;
|
import net.aminecraftdev.custombosses.managers.files.BossItemFileManager;
|
||||||
|
import net.aminecraftdev.custombosses.managers.files.BossMessagesFileManager;
|
||||||
import net.aminecraftdev.custombosses.managers.files.BossesFileManager;
|
import net.aminecraftdev.custombosses.managers.files.BossesFileManager;
|
||||||
import net.aminecraftdev.custombosses.utils.Debug;
|
import net.aminecraftdev.custombosses.utils.Debug;
|
||||||
import net.aminecraftdev.custombosses.utils.itemstack.holder.ItemStackHolder;
|
import net.aminecraftdev.custombosses.utils.itemstack.holder.ItemStackHolder;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -25,11 +28,15 @@ public class BossEntityManager {
|
|||||||
|
|
||||||
private static final List<ActiveBossHolder> ACTIVE_BOSS_HOLDERS = new ArrayList<>();
|
private static final List<ActiveBossHolder> ACTIVE_BOSS_HOLDERS = new ArrayList<>();
|
||||||
|
|
||||||
|
private BossMessagesFileManager bossMessagesFileManager;
|
||||||
|
private BossCommandFileManager bossCommandFileManager;
|
||||||
private BossItemFileManager bossItemFileManager;
|
private BossItemFileManager bossItemFileManager;
|
||||||
private BossMechanicManager bossMechanicManager;
|
private BossMechanicManager bossMechanicManager;
|
||||||
private BossesFileManager bossesFileManager;
|
private BossesFileManager bossesFileManager;
|
||||||
|
|
||||||
public BossEntityManager(CustomBosses customBosses) {
|
public BossEntityManager(CustomBosses customBosses) {
|
||||||
|
this.bossMessagesFileManager = customBosses.getBossMessagesFileManager();
|
||||||
|
this.bossCommandFileManager = customBosses.getBossCommandFileManager();
|
||||||
this.bossMechanicManager = customBosses.getBossMechanicManager();
|
this.bossMechanicManager = customBosses.getBossMechanicManager();
|
||||||
this.bossItemFileManager = customBosses.getItemStackManager();
|
this.bossItemFileManager = customBosses.getItemStackManager();
|
||||||
this.bossesFileManager = customBosses.getBossesFileManager();
|
this.bossesFileManager = customBosses.getBossesFileManager();
|
||||||
@ -53,6 +60,38 @@ public class BossEntityManager {
|
|||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getOnSpawnMessage(BossEntity bossEntity) {
|
||||||
|
String id = bossEntity.getMessages().getOnSpawn().getMessage();
|
||||||
|
List<String> messages = BossAPI.getStoredMessages(id);
|
||||||
|
|
||||||
|
if(messages == null) {
|
||||||
|
Debug.FAILED_TO_LOAD_MESSAGES.debug(id);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOnSpawnMessageRadius(BossEntity bossEntity) {
|
||||||
|
Integer radius = bossEntity.getMessages().getOnSpawn().getRadius();
|
||||||
|
|
||||||
|
if(radius == null) radius = -1;
|
||||||
|
|
||||||
|
return radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getOnSpawnCommands(BossEntity bossEntity) {
|
||||||
|
String id = bossEntity.getCommands().getOnSpawn();
|
||||||
|
List<String> commands = BossAPI.getStoredCommands(id);
|
||||||
|
|
||||||
|
if(commands == null) {
|
||||||
|
Debug.FAILED_TO_LOAD_COMMANDS.debug(id);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return commands;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<BossEntity, ItemStack> getMapOfEntitiesAndSpawnItems() {
|
public Map<BossEntity, ItemStack> getMapOfEntitiesAndSpawnItems() {
|
||||||
Map<String, BossEntity> currentEntities = new HashMap<>(this.bossesFileManager.getBossEntities());
|
Map<String, BossEntity> currentEntities = new HashMap<>(this.bossesFileManager.getBossEntities());
|
||||||
Map<BossEntity, ItemStack> newMap = new HashMap<>();
|
Map<BossEntity, ItemStack> newMap = new HashMap<>();
|
||||||
@ -62,8 +101,8 @@ public class BossEntityManager {
|
|||||||
return newMap;
|
return newMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActiveBossHolder createActiveBossHolder(BossEntity bossEntity, Location spawnLocation) {
|
public ActiveBossHolder createActiveBossHolder(BossEntity bossEntity, Location spawnLocation, String name) {
|
||||||
ActiveBossHolder activeBossHolder = new ActiveBossHolder(bossEntity, spawnLocation);
|
ActiveBossHolder activeBossHolder = new ActiveBossHolder(bossEntity, spawnLocation, name);
|
||||||
|
|
||||||
if(!this.bossMechanicManager.handleMechanicApplication(bossEntity, activeBossHolder)) {
|
if(!this.bossMechanicManager.handleMechanicApplication(bossEntity, activeBossHolder)) {
|
||||||
Debug.FAILED_TO_CREATE_ACTIVE_BOSS_HOLDER.debug();
|
Debug.FAILED_TO_CREATE_ACTIVE_BOSS_HOLDER.debug();
|
||||||
@ -74,4 +113,16 @@ public class BossEntityManager {
|
|||||||
return activeBossHolder;
|
return activeBossHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActiveBossHolder getActiveBossHolder(LivingEntity livingEntity) {
|
||||||
|
List<ActiveBossHolder> currentList = new ArrayList<>(ACTIVE_BOSS_HOLDERS);
|
||||||
|
|
||||||
|
for(ActiveBossHolder activeBossHolder : currentList) {
|
||||||
|
for(Map.Entry<Integer, LivingEntity> entry : activeBossHolder.getLivingEntityMap().entrySet()) {
|
||||||
|
if(entry.getValue().getUniqueId().equals(livingEntity.getUniqueId())) return activeBossHolder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.aminecraftdev.custombosses.managers;
|
package net.aminecraftdev.custombosses.managers;
|
||||||
|
|
||||||
import net.aminecraftdev.custombosses.CustomBosses;
|
import net.aminecraftdev.custombosses.CustomBosses;
|
||||||
|
import net.aminecraftdev.custombosses.listeners.during.BossDamageListener;
|
||||||
import net.aminecraftdev.custombosses.listeners.pre.BossSpawnListener;
|
import net.aminecraftdev.custombosses.listeners.pre.BossSpawnListener;
|
||||||
import net.aminecraftdev.custombosses.utils.Debug;
|
import net.aminecraftdev.custombosses.utils.Debug;
|
||||||
import net.aminecraftdev.custombosses.utils.ILoadable;
|
import net.aminecraftdev.custombosses.utils.ILoadable;
|
||||||
@ -30,6 +31,7 @@ public class BossListenerManager implements ILoadable {
|
|||||||
ServerUtils serverUtils = ServerUtils.get();
|
ServerUtils serverUtils = ServerUtils.get();
|
||||||
|
|
||||||
serverUtils.registerListener(new BossSpawnListener(this.plugin));
|
serverUtils.registerListener(new BossSpawnListener(this.plugin));
|
||||||
|
serverUtils.registerListener(new BossDamageListener(this.plugin));
|
||||||
|
|
||||||
|
|
||||||
this.hasBeenLoaded = true;
|
this.hasBeenLoaded = true;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.aminecraftdev.custombosses.managers.files;
|
package net.aminecraftdev.custombosses.managers.files;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.aminecraftdev.custombosses.CustomBosses;
|
import net.aminecraftdev.custombosses.CustomBosses;
|
||||||
import net.aminecraftdev.custombosses.file.CommandsFileHandler;
|
import net.aminecraftdev.custombosses.file.CommandsFileHandler;
|
||||||
import net.aminecraftdev.custombosses.utils.ILoadable;
|
import net.aminecraftdev.custombosses.utils.ILoadable;
|
||||||
|
@ -26,6 +26,8 @@ public enum Debug {
|
|||||||
FAILED_TO_LOAD_BOSSCOMMANDMANAGER("The boss command manager tried to load again, but it has already loaded previously."),
|
FAILED_TO_LOAD_BOSSCOMMANDMANAGER("The boss command manager tried to load again, but it has already loaded previously."),
|
||||||
FAILED_TO_LOAD_BOSSLISTENERMANAGER("The boss listener manager tried to load again, but it has already loaded previously."),
|
FAILED_TO_LOAD_BOSSLISTENERMANAGER("The boss listener manager tried to load again, but it has already loaded previously."),
|
||||||
FAILED_TO_LOAD_CUSTOM_ITEM("The itemstack name that is provided ({0}) for the spawn item doesn't exist or wasn't found."),
|
FAILED_TO_LOAD_CUSTOM_ITEM("The itemstack name that is provided ({0}) for the spawn item doesn't exist or wasn't found."),
|
||||||
|
FAILED_TO_LOAD_MESSAGES("The messages name that is provided ({0}) doesn't exist or wasn't found."),
|
||||||
|
FAILED_TO_LOAD_COMMANDS("The commands name that is provided ({0}) doesn't exist or wasn't found."),
|
||||||
FAILED_TO_CREATE_ACTIVE_BOSS_HOLDER("Something went wrong while trying to create an active boss holder for someone who is trying to spawn a boss."),
|
FAILED_TO_CREATE_ACTIVE_BOSS_HOLDER("Something went wrong while trying to create an active boss holder for someone who is trying to spawn a boss."),
|
||||||
|
|
||||||
MECHANIC_TYPE_NOT_STORED("This mechanic type is not stored, therefore will not be applied. Valid mechanic types are IOptionalMechanic and IPrimaryMechanic.");
|
MECHANIC_TYPE_NOT_STORED("This mechanic type is not stored, therefore will not be applied. Valid mechanic types are IOptionalMechanic and IPrimaryMechanic.");
|
||||||
|
@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
*/
|
*/
|
||||||
public enum Message {
|
public enum Message {
|
||||||
|
|
||||||
|
General_LocationFormat("{world}, {x}, {y}, {z}"),
|
||||||
General_MustBePlayer("&c&l(!) &cYou must be a player to use this command."),
|
General_MustBePlayer("&c&l(!) &cYou must be a player to use this command."),
|
||||||
General_CannotSpawn("&c&l(!) &cYou cannot spawn a boss at this location! &c&l(!)"),
|
General_CannotSpawn("&c&l(!) &cYou cannot spawn a boss at this location! &c&l(!)"),
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.aminecraftdev.custombosses.utils;
|
package net.aminecraftdev.custombosses.utils;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -23,6 +24,19 @@ public class StringUtils {
|
|||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
return ChatColor.translateAlternateColorCodes('&', string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String translateLocation(Location location) {
|
||||||
|
String world = location.getWorld().getName();
|
||||||
|
int x = location.getBlockX();
|
||||||
|
int y = location.getBlockY();
|
||||||
|
int z = location.getBlockZ();
|
||||||
|
|
||||||
|
return Message.General_LocationFormat.toString()
|
||||||
|
.replace("{world}", world)
|
||||||
|
.replace("{x}", ""+x)
|
||||||
|
.replace("{y}", ""+y)
|
||||||
|
.replace("{z}", ""+z);
|
||||||
|
}
|
||||||
|
|
||||||
public <T> String appendList(List<T> list) {
|
public <T> String appendList(List<T> list) {
|
||||||
Queue<T> queue = new LinkedList<>(list);
|
Queue<T> queue = new LinkedList<>(list);
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
2
pom.xml
2
pom.xml
@ -19,7 +19,7 @@
|
|||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<plugin.version>3.0.0-SNAPSHOT-U28</plugin.version>
|
<plugin.version>3.0.0-SNAPSHOT-U29</plugin.version>
|
||||||
<plugin.name>CustomBosses</plugin.name>
|
<plugin.name>CustomBosses</plugin.name>
|
||||||
<plugin.main>net.aminecraftdev.custombosses.CustomBosses</plugin.main>
|
<plugin.main>net.aminecraftdev.custombosses.CustomBosses</plugin.main>
|
||||||
<plugin.author>AMinecraftDev</plugin.author>
|
<plugin.author>AMinecraftDev</plugin.author>
|
||||||
|
Loading…
Reference in New Issue
Block a user