mirror of
https://github.com/songoda/EpicBosses.git
synced 2025-01-20 13:52:19 +01:00
1.0.0-SNAPSHOT-U58
+ Finished working on how skills are handled + Updated skills.json to allow for easier usage of skills
This commit is contained in:
parent
a5287a6cf0
commit
11baa56327
@ -41,8 +41,7 @@
|
||||
"overallChance": 35.5,
|
||||
"masterMessage": "SKMainSkillMessage",
|
||||
"skills": [
|
||||
"KNOCKBACK1",
|
||||
"CAGE1"
|
||||
"Lightning1"
|
||||
]
|
||||
},
|
||||
"drops": {
|
||||
|
@ -2,16 +2,18 @@
|
||||
"Blind1": {
|
||||
"mode": "ALL",
|
||||
"type": "POTION",
|
||||
"radius": 10,
|
||||
"displayName": "Blind",
|
||||
"customMessage": "BlindMessage",
|
||||
"potions": [
|
||||
{
|
||||
"type": "blind",
|
||||
"level": 2,
|
||||
"duration": 10
|
||||
}
|
||||
]
|
||||
"radius": 10,
|
||||
"customData": {
|
||||
"potions": [
|
||||
{
|
||||
"type": "blind",
|
||||
"level": 2,
|
||||
"duration": 10
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"Guts1": {
|
||||
"mode": "ALL",
|
||||
@ -19,35 +21,39 @@
|
||||
"radius": 10,
|
||||
"displayName": "Guts",
|
||||
"customMessage": "GutsMessage",
|
||||
"commands": [
|
||||
{
|
||||
"chance": 25,
|
||||
"commands": [
|
||||
"Guts1",
|
||||
"Guts2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"chance": 10,
|
||||
"commands": [
|
||||
"Guts3"
|
||||
]
|
||||
}
|
||||
]
|
||||
"customData": {
|
||||
"commands": [
|
||||
{
|
||||
"chance": 25,
|
||||
"commands": [
|
||||
"Guts1",
|
||||
"Guts2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"chance": 10,
|
||||
"commands": [
|
||||
"Guts3"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"Cage1": {
|
||||
"mode": "ALL",
|
||||
"type": "CUSTOM",
|
||||
"radius": 10,
|
||||
"displayName": "Cage",
|
||||
"custom": {
|
||||
"type": "CAGE",
|
||||
"multiplier": 0.0
|
||||
},
|
||||
"cage": {
|
||||
"flatType": "IRON_BLOCK",
|
||||
"wallType": "IRON_BARS",
|
||||
"insideType": "WATER"
|
||||
"customData": {
|
||||
"custom": {
|
||||
"type": "CAGE",
|
||||
"multiplier": 0.0,
|
||||
"otherSkillData": {
|
||||
"flatType": "IRON_BLOCK",
|
||||
"wallType": "IRON_BARS",
|
||||
"insideType": "WATER"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Disarm1": {
|
||||
@ -56,9 +62,11 @@
|
||||
"radius": 10,
|
||||
"displayName": "Disarm",
|
||||
"customMessage": null,
|
||||
"custom": {
|
||||
"type": "DISARM",
|
||||
"multiplier": null
|
||||
"customData": {
|
||||
"custom": {
|
||||
"type": "DISARM",
|
||||
"multiplier": null
|
||||
}
|
||||
}
|
||||
},
|
||||
"Fireball1": {
|
||||
@ -67,9 +75,11 @@
|
||||
"radius": 10,
|
||||
"displayName": "Fireball",
|
||||
"customMessage": null,
|
||||
"custom": {
|
||||
"type": "FIREBALL",
|
||||
"multiplier": 3.0
|
||||
"customData": {
|
||||
"custom": {
|
||||
"type": "FIREBALL",
|
||||
"multiplier": 3.0
|
||||
}
|
||||
}
|
||||
},
|
||||
"Grapple1": {
|
||||
@ -78,9 +88,11 @@
|
||||
"radius": 10,
|
||||
"displayName": "Grapple",
|
||||
"customMessage": null,
|
||||
"custom": {
|
||||
"type": "GRAPPLE",
|
||||
"multiplier": 3.0
|
||||
"customData": {
|
||||
"custom": {
|
||||
"type": "GRAPPLE",
|
||||
"multiplier": 3.0
|
||||
}
|
||||
}
|
||||
},
|
||||
"Insidious1": {
|
||||
@ -89,9 +101,11 @@
|
||||
"radius": 10,
|
||||
"displayName": "Insidious",
|
||||
"customMessage": null,
|
||||
"custom": {
|
||||
"type": "INSIDIOUS",
|
||||
"multiplier": 2.5
|
||||
"customData": {
|
||||
"custom": {
|
||||
"type": "INSIDIOUS",
|
||||
"multiplier": 2.5
|
||||
}
|
||||
}
|
||||
},
|
||||
"Knockback1": {
|
||||
@ -100,9 +114,11 @@
|
||||
"radius": 10,
|
||||
"displayName": "Knockback",
|
||||
"customMessage": null,
|
||||
"custom": {
|
||||
"type": "KNOCKBACK",
|
||||
"multiplier": 2.5
|
||||
"customData": {
|
||||
"custom": {
|
||||
"type": "KNOCKBACK",
|
||||
"multiplier": 2.5
|
||||
}
|
||||
}
|
||||
},
|
||||
"Launch1": {
|
||||
@ -111,9 +127,11 @@
|
||||
"radius": 10,
|
||||
"displayName": "Launch",
|
||||
"customMessage": null,
|
||||
"custom": {
|
||||
"type": "LAUNCH",
|
||||
"multiplier": 3.0
|
||||
"customData": {
|
||||
"custom": {
|
||||
"type": "LAUNCH",
|
||||
"multiplier": 3.0
|
||||
}
|
||||
}
|
||||
},
|
||||
"Lightning1": {
|
||||
@ -122,9 +140,11 @@
|
||||
"radius": 10,
|
||||
"displayName": "Lightning",
|
||||
"customMessage": null,
|
||||
"custom": {
|
||||
"type": "LIGHTNING",
|
||||
"multiplier": null
|
||||
"customData": {
|
||||
"custom": {
|
||||
"type": "LIGHTNING",
|
||||
"multiplier": null
|
||||
}
|
||||
}
|
||||
},
|
||||
"Minions1": {
|
||||
@ -133,15 +153,17 @@
|
||||
"radius": 10,
|
||||
"displayName": "Minions",
|
||||
"customMessage": null,
|
||||
"custom": {
|
||||
"type": "MINIONS",
|
||||
"multiplier": null
|
||||
},
|
||||
"minions": {
|
||||
"amount": 5,
|
||||
"minionsToSpawn": [
|
||||
"Minion1"
|
||||
]
|
||||
"customData": {
|
||||
"custom": {
|
||||
"type": "MINIONS",
|
||||
"multiplier": null,
|
||||
"otherSkillData": {
|
||||
"amount": 5,
|
||||
"minionsToSpawn": [
|
||||
"Minion1"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Warp1": {
|
||||
@ -150,9 +172,11 @@
|
||||
"radius": 10,
|
||||
"displayName": "Warp",
|
||||
"customMessage": null,
|
||||
"custom": {
|
||||
"type": "WARP",
|
||||
"multiplier": null
|
||||
"customData": {
|
||||
"custom": {
|
||||
"type": "WARP",
|
||||
"multiplier": null
|
||||
}
|
||||
}
|
||||
},
|
||||
"Shazaam1": {
|
||||
@ -161,9 +185,11 @@
|
||||
"radius": 10,
|
||||
"displayName": "Shazaam",
|
||||
"customMessage": "ShazaamMessage",
|
||||
"groupedSkills": [
|
||||
"Blind1",
|
||||
"Knockback1"
|
||||
]
|
||||
"customData": {
|
||||
"groupedSkills": [
|
||||
"Blind1",
|
||||
"Knockback1"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
Settings:
|
||||
debug: false
|
||||
debug: true
|
||||
bossTargetRange: 50.0
|
||||
defaultNearbyRadius: 250.0
|
||||
nearbyFormat: '{name} ({distance}m)'
|
||||
@ -36,7 +36,7 @@ Display:
|
||||
AutoSpawns:
|
||||
menuName: '&b&lEpicBosses &3&lAutoSpawns'
|
||||
Bosses:
|
||||
menuName: '&b&lEpicBosses &3&lItems'
|
||||
menuName: '&b&lEpicBosses &3&lBosses'
|
||||
name: '&b&l{name}'
|
||||
lore:
|
||||
- '&3Editing: &f{enabled}'
|
||||
|
@ -54,8 +54,8 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
|
||||
@Getter private MinionMechanicManager minionMechanicManager;
|
||||
@Getter private MinionEntityContainer minionEntityContainer;
|
||||
|
||||
@Getter private VersionHandler versionHandler;
|
||||
@Getter private DebugManager debugManager;
|
||||
@Getter private VersionHandler versionHandler = new VersionHandler();
|
||||
@Getter private DebugManager debugManager = new DebugManager();
|
||||
|
||||
@Getter private YmlFileHandler langFileHandler, editorFileHandler, configFileHandler;
|
||||
@Getter private FileConfiguration lang, editor, config;
|
||||
@ -64,6 +64,11 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
|
||||
|
||||
@Getter private boolean debug = false;
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.bossEntityManager.killAllHolders(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Debug.setPlugin(this);
|
||||
@ -82,8 +87,6 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
|
||||
new Metrics(this);
|
||||
new ServerUtils(this);
|
||||
|
||||
this.debugManager = new DebugManager();
|
||||
this.versionHandler = new VersionHandler();
|
||||
this.bossSkillManager = new BossSkillManager();
|
||||
this.bossHookManager = new BossHookManager(this);
|
||||
this.bossTauntManager = new BossTauntManager(this);
|
||||
@ -118,6 +121,7 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
|
||||
this.bossPanelManager.load();
|
||||
|
||||
//RELOAD/LOAD ALL MANAGERS
|
||||
this.bossSkillManager.load();
|
||||
this.bossHookManager.reload();
|
||||
this.bossLocationManager.reload();
|
||||
this.bossMechanicManager.load();
|
||||
|
@ -10,8 +10,11 @@ import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.managers.files.CommandsFileManager;
|
||||
import com.songoda.epicbosses.managers.files.ItemsFileManager;
|
||||
import com.songoda.epicbosses.managers.files.MessagesFileManager;
|
||||
import com.songoda.epicbosses.skills.CustomSkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.custom.Minions;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkill;
|
||||
import com.songoda.epicbosses.skills.elements.CustomMinionSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.EntityFinder;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
@ -101,8 +104,8 @@ public class BossAPI {
|
||||
* @param customSkill - The custom skill you are registering
|
||||
* @return boolean if the registration succeeded or failed
|
||||
*/
|
||||
public static boolean registerCustomSkill(CustomSkill customSkill) {
|
||||
return PLUGIN.getBossSkillManager().registerSkill(customSkill);
|
||||
public static boolean registerCustomSkill(CustomSkillHandler customSkill) {
|
||||
return PLUGIN.getBossSkillManager().registerCustomSkill(customSkill);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -115,8 +118,8 @@ public class BossAPI {
|
||||
*
|
||||
* @param customSkill - The custom skill you are trying to remove
|
||||
*/
|
||||
public static void removeCustomSkill(CustomSkill customSkill) {
|
||||
PLUGIN.getBossSkillManager().removeSkill(customSkill);
|
||||
public static void removeCustomSkill(CustomSkillHandler customSkill) {
|
||||
PLUGIN.getBossSkillManager().removeCustomSkill(customSkill);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -290,6 +293,8 @@ public class BossAPI {
|
||||
preBossSpawnEvent = new PreBossSpawnEvent(activeBossHolder);
|
||||
}
|
||||
|
||||
System.out.println("SPAWNING EVENT " + preBossSpawnEvent);
|
||||
|
||||
PLUGIN.getBossTargetManager().initializeTargetHandler(activeBossHolder);
|
||||
ServerUtils.get().callEvent(preBossSpawnEvent);
|
||||
|
||||
@ -301,16 +306,27 @@ public class BossAPI {
|
||||
* bossEntity, under the activebossholder.
|
||||
*
|
||||
* @param activeBossHolder - targeted active boss
|
||||
* @param minions - Minion skill class
|
||||
* @param skill - the skill from the skills.json
|
||||
* @return boolean if the spawning of the minions succeeded or failed
|
||||
*/
|
||||
public static boolean spawnNewMinion(ActiveBossHolder activeBossHolder, Minions minions) {
|
||||
public static boolean spawnNewMinion(ActiveBossHolder activeBossHolder, Skill skill) {
|
||||
// if(minionEntity.isEditing()) {
|
||||
// Debug.ATTEMPTED_TO_SPAWN_WHILE_DISABLED.debug();
|
||||
// return null;
|
||||
// }
|
||||
|
||||
return PLUGIN.getBossEntityManager().spawnMinionsOnBossHolder(activeBossHolder, minions);
|
||||
if(skill.getType().equalsIgnoreCase("CUSTOM")) {
|
||||
CustomSkillElement customSkillElement = PLUGIN.getBossSkillManager().getCustomSkillElement(skill);
|
||||
|
||||
if(customSkillElement.getCustom().getType().equalsIgnoreCase("MINION")) {
|
||||
CustomMinionSkillElement customMinionSkillElement = customSkillElement.getCustom().getCustomMinionSkillData();
|
||||
|
||||
PLUGIN.getBossEntityManager().spawnMinionsOnBossHolder(activeBossHolder, skill, customMinionSkillElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,17 +3,16 @@ package com.songoda.epicbosses.listeners.during;
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.entity.BossEntity;
|
||||
import com.songoda.epicbosses.events.BossSkillEvent;
|
||||
import com.songoda.epicbosses.events.PreBossSkillEvent;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.managers.BossEntityManager;
|
||||
import com.songoda.epicbosses.managers.BossSkillManager;
|
||||
import com.songoda.epicbosses.managers.files.SkillsFileManager;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.types.CommandSkill;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkill;
|
||||
import com.songoda.epicbosses.skills.types.PotionSkill;
|
||||
import com.songoda.epicbosses.skills.types.CommandSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.GroupSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.PotionSkillElement;
|
||||
import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.RandomUtils;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
@ -26,7 +25,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.potion.Potion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -42,8 +40,10 @@ public class BossSkillListener implements Listener {
|
||||
|
||||
private BossEntityManager bossEntityManager;
|
||||
private SkillsFileManager skillsFileManager;
|
||||
private BossSkillManager bossSkillManager;
|
||||
|
||||
public BossSkillListener(CustomBosses plugin) {
|
||||
this.bossSkillManager = plugin.getBossSkillManager();
|
||||
this.bossEntityManager = plugin.getBossEntityManager();
|
||||
this.skillsFileManager = plugin.getSkillsFileManager();
|
||||
}
|
||||
@ -65,11 +65,11 @@ public class BossSkillListener implements Listener {
|
||||
|
||||
if(bossEntity.getSkills() == null || bossEntity.getSkills().getOverallChance() == null) return;
|
||||
|
||||
if(RandomUtils.get().canPreformAction(bossEntity.getSkills().getOverallChance())) {
|
||||
// if(RandomUtils.get().canPreformAction(bossEntity.getSkills().getOverallChance())) {
|
||||
PreBossSkillEvent preBossSkillEvent = new PreBossSkillEvent(activeBossHolder, livingEntity, (LivingEntity) entityDamaging);
|
||||
|
||||
ServerUtils.get().callEvent(preBossSkillEvent);
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -98,17 +98,25 @@ public class BossSkillListener implements Listener {
|
||||
List<LivingEntity> targettedEntities = getTargetedEntities(activeBossHolder, skill, activeBossHolder.getLivingEntity().getLocation(), damagingEntity);
|
||||
|
||||
if(skill.getType().equalsIgnoreCase("POTION")) {
|
||||
PotionSkill potionSkill = (PotionSkill) skill;
|
||||
PotionSkillElement potionSkillElement = this.bossSkillManager.getPotionSkillElement(skill);
|
||||
|
||||
potionSkill.castSkill(activeBossHolder, targettedEntities);
|
||||
potionSkillElement.castSkill(skill, potionSkillElement, activeBossHolder, targettedEntities);
|
||||
System.out.println("#1");
|
||||
} else if(skill.getType().equalsIgnoreCase("COMMAND")) {
|
||||
CommandSkill commandSkill = (CommandSkill) skill;
|
||||
CommandSkillElement commandSkillElement = this.bossSkillManager.getCommandSkillElement(skill);
|
||||
|
||||
commandSkill.castSkill(activeBossHolder, targettedEntities);
|
||||
commandSkillElement.castSkill(skill, commandSkillElement, activeBossHolder, targettedEntities);
|
||||
System.out.println("#2");
|
||||
} else if(skill.getType().equalsIgnoreCase("GROUP")) {
|
||||
GroupSkillElement groupSkillElement = this.bossSkillManager.getGroupSkillElement(skill);
|
||||
|
||||
groupSkillElement.castSkill(skill, groupSkillElement, activeBossHolder, targettedEntities);
|
||||
System.out.println("#3");
|
||||
} else if(skill.getType().equalsIgnoreCase("CUSTOM")) {
|
||||
CustomSkill customSkill = (CustomSkill) skill;
|
||||
|
||||
CustomSkillElement customSkillElement = this.bossSkillManager.getCustomSkillElement(skill);
|
||||
|
||||
this.bossSkillManager.handleCustomSkillCasting(skill, customSkillElement, activeBossHolder, targettedEntities);
|
||||
System.out.println("#4");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,8 +102,17 @@ public class BossSpawnListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPreBossSpawnItem(PreBossSpawnItemEvent event) {
|
||||
handleEvent(event);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPreBossSpawnEvent(PreBossSpawnEvent event) {
|
||||
handleEvent(event);
|
||||
}
|
||||
|
||||
private void handleEvent(PreBossSpawnEvent event) {
|
||||
ActiveBossHolder activeBossHolder = event.getActiveBossHolder();
|
||||
BossEntity bossEntity = activeBossHolder.getBossEntity();
|
||||
Location location = activeBossHolder.getLocation();
|
||||
@ -130,6 +139,8 @@ public class BossSpawnListener implements Listener {
|
||||
if(activeBossHolder.getName() != null) messages.replaceAll(s -> s.replace("{boss}", activeBossHolder.getName()));
|
||||
messages.replaceAll(s -> s.replace("{location}", StringUtils.get().translateLocation(location)));
|
||||
|
||||
System.out.println("MESSAGE SYSTEM");
|
||||
|
||||
MessageUtils.get().sendMessage(location, NumberUtils.get().getSquared(messageRadius), messages);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,9 @@ import com.songoda.epicbosses.managers.files.BossesFileManager;
|
||||
import com.songoda.epicbosses.managers.files.DropTableFileManager;
|
||||
import com.songoda.epicbosses.managers.files.ItemsFileManager;
|
||||
import com.songoda.epicbosses.managers.files.MinionsFileManager;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.custom.Minions;
|
||||
import com.songoda.epicbosses.skills.elements.CustomMinionSkillElement;
|
||||
import com.songoda.epicbosses.utils.BossesGson;
|
||||
import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.RandomUtils;
|
||||
@ -260,12 +262,12 @@ public class BossEntityManager {
|
||||
return activeBossHolder;
|
||||
}
|
||||
|
||||
public boolean spawnMinionsOnBossHolder(ActiveBossHolder activeBossHolder, Minions minions) {
|
||||
List<String> minionsToSpawn = minions.getMinions().getMinionsToSpawn();
|
||||
Integer amount = minions.getMinions().getAmount();
|
||||
public boolean spawnMinionsOnBossHolder(ActiveBossHolder activeBossHolder, Skill skill, CustomMinionSkillElement minionSkillElement) {
|
||||
List<String> minionsToSpawn = minionSkillElement.getMinionsToSpawn();
|
||||
Integer amount = minionSkillElement.getAmount();
|
||||
|
||||
if(minionsToSpawn == null || minionsToSpawn.isEmpty()) {
|
||||
Debug.FAILED_TO_SPAWN_MINIONS_FROM_SKILL.debug(minions.getDisplayName());
|
||||
Debug.FAILED_TO_SPAWN_MINIONS_FROM_SKILL.debug(skill.getDisplayName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -277,13 +279,13 @@ public class BossEntityManager {
|
||||
MinionEntity minionEntity = this.minionsFileManager.getMinionEntity(string);
|
||||
|
||||
if(minionEntity == null) {
|
||||
Debug.FAILED_TO_FIND_MINION.debug(minions.getDisplayName(), string);
|
||||
Debug.FAILED_TO_FIND_MINION.debug(skill.getDisplayName(), string);
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 1; i <= finalAmount; i++) {
|
||||
if(!this.minionMechanicManager.handleMechanicApplication(minionEntity, activeBossHolder)) {
|
||||
Debug.FAILED_TO_SPAWN_MINION.debug(minions.getDisplayName(), string);
|
||||
Debug.FAILED_TO_SPAWN_MINION.debug(skill.getDisplayName(), string);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.songoda.epicbosses.managers;
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.listeners.after.BossDeathListener;
|
||||
import com.songoda.epicbosses.listeners.during.BossDamageListener;
|
||||
import com.songoda.epicbosses.listeners.during.BossSkillListener;
|
||||
import com.songoda.epicbosses.listeners.pre.BossSpawnListener;
|
||||
import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.ILoadable;
|
||||
@ -33,6 +34,7 @@ public class BossListenerManager implements ILoadable {
|
||||
|
||||
serverUtils.registerListener(new BossSpawnListener(this.plugin));
|
||||
serverUtils.registerListener(new BossDamageListener(this.plugin));
|
||||
serverUtils.registerListener(new BossSkillListener(this.plugin));
|
||||
serverUtils.registerListener(new BossDeathListener(this.plugin));
|
||||
|
||||
this.hasBeenLoaded = true;
|
||||
|
@ -1,8 +1,20 @@
|
||||
package com.songoda.epicbosses.managers;
|
||||
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.CustomSkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.custom.*;
|
||||
import com.songoda.epicbosses.skills.types.CommandSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.GroupSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.PotionSkillElement;
|
||||
import com.songoda.epicbosses.utils.BossesGson;
|
||||
import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.ILoadable;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -10,21 +22,88 @@ import java.util.Set;
|
||||
* @version 1.0.0
|
||||
* @since 05-Nov-18
|
||||
*/
|
||||
public class BossSkillManager {
|
||||
public class BossSkillManager implements ILoadable {
|
||||
|
||||
private static final Set<Skill> SKILLS = new HashSet<>();
|
||||
private static final Set<CustomSkillHandler> SKILLS = new HashSet<>();
|
||||
|
||||
public boolean registerSkill(Skill skill) {
|
||||
if(SKILLS.contains(skill)) return false;
|
||||
@Override
|
||||
public void load() {
|
||||
registerCustomSkill(new Cage());
|
||||
registerCustomSkill(new Disarm());
|
||||
registerCustomSkill(new Fireball());
|
||||
registerCustomSkill(new Grapple());
|
||||
registerCustomSkill(new Insidious());
|
||||
registerCustomSkill(new Knockback());
|
||||
registerCustomSkill(new Launch());
|
||||
registerCustomSkill(new Lightning());
|
||||
registerCustomSkill(new Minions());
|
||||
registerCustomSkill(new Warp());
|
||||
}
|
||||
|
||||
SKILLS.add(skill);
|
||||
public void handleCustomSkillCasting(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
String type = customSkillElement.getCustom().getType();
|
||||
CustomSkillHandler customSkillHandler = getCustomSkillHandler(type);
|
||||
|
||||
if(customSkillHandler == null) {
|
||||
Debug.FAILED_TO_OBTAIN_THE_SKILL_HANDLER.debug(type);
|
||||
return;
|
||||
}
|
||||
|
||||
customSkillHandler.castSkill(skill, customSkillElement, activeBossHolder, nearbyEntities);
|
||||
}
|
||||
|
||||
public PotionSkillElement getPotionSkillElement(Skill skill) {
|
||||
if(skill.getType().equalsIgnoreCase("POTION")) {
|
||||
return BossesGson.get().fromJson(skill.getCustomData(), PotionSkillElement.class);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CommandSkillElement getCommandSkillElement(Skill skill) {
|
||||
if(skill.getType().equalsIgnoreCase("COMMAND")) {
|
||||
return BossesGson.get().fromJson(skill.getCustomData(), CommandSkillElement.class);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public GroupSkillElement getGroupSkillElement(Skill skill) {
|
||||
if(skill.getType().equalsIgnoreCase("GROUP")) {
|
||||
return BossesGson.get().fromJson(skill.getCustomData(), GroupSkillElement.class);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CustomSkillElement getCustomSkillElement(Skill skill) {
|
||||
if(skill.getType().equalsIgnoreCase("CUSTOM")) {
|
||||
return BossesGson.get().fromJson(skill.getCustomData(), CustomSkillElement.class);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean registerCustomSkill(CustomSkillHandler customSkillHandler) {
|
||||
if(SKILLS.contains(customSkillHandler)) return false;
|
||||
|
||||
SKILLS.add(customSkillHandler);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void removeSkill(Skill skill) {
|
||||
if(!SKILLS.contains(skill)) return;
|
||||
public void removeCustomSkill(CustomSkillHandler customSkillHandler) {
|
||||
if(!SKILLS.contains(customSkillHandler)) return;
|
||||
|
||||
SKILLS.remove(skill);
|
||||
SKILLS.remove(customSkillHandler);
|
||||
}
|
||||
|
||||
public CustomSkillHandler getCustomSkillHandler(String name) {
|
||||
for(CustomSkillHandler customSkillHandler : new HashSet<>(SKILLS)) {
|
||||
String skillName = customSkillHandler.getClass().getSimpleName();
|
||||
|
||||
if(skillName.equalsIgnoreCase(name)) return customSkillHandler;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -42,10 +42,6 @@ public class PotionMechanic implements IOptionalMechanic<BossEntity> {
|
||||
potionElements.forEach(potionElement -> {
|
||||
PotionEffect potionEffect = this.potionEffectConverter.from(potionElement);
|
||||
|
||||
System.out.println(potionEffect);
|
||||
System.out.println(potionEffect.getAmplifier());
|
||||
System.out.println(potionEffect.getDuration());
|
||||
System.out.println(livingEntity);
|
||||
livingEntity.addPotionEffect(potionEffect);
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.songoda.epicbosses.skills;
|
||||
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 18-Nov-18
|
||||
*/
|
||||
public abstract class CustomSkillHandler implements ISkillHandler<CustomSkillElement> {
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.songoda.epicbosses.skills;
|
||||
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.List;
|
||||
@ -10,8 +11,8 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 05-Nov-18
|
||||
*/
|
||||
public interface ISkillHandler {
|
||||
public interface ISkillHandler<T> {
|
||||
|
||||
void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities);
|
||||
void castSkill(Skill skill, T t, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities);
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.epicbosses.skills;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@ -13,6 +14,7 @@ public class Skill {
|
||||
|
||||
@Expose @Getter @Setter private String mode, type, displayName, customMessage;
|
||||
@Expose @Getter @Setter private Double radius;
|
||||
@Expose @Getter @Setter private JsonObject customData;
|
||||
|
||||
public Skill(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
this.mode = mode;
|
||||
|
@ -1,18 +1,16 @@
|
||||
package com.songoda.epicbosses.skills.custom;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.CustomSkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.custom.cage.CageLocationData;
|
||||
import com.songoda.epicbosses.skills.custom.cage.CagePlayerData;
|
||||
import com.songoda.epicbosses.skills.elements.CustomCageSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkill;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
import com.songoda.epicbosses.utils.itemstack.converters.MaterialConverter;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -25,21 +23,15 @@ import java.util.*;
|
||||
* @version 1.0.0
|
||||
* @since 06-Nov-18
|
||||
*/
|
||||
public class Cage extends CustomSkill implements ISkillHandler {
|
||||
public class Cage extends CustomSkillHandler {
|
||||
|
||||
private static final MaterialConverter MATERIAL_CONVERTER = new MaterialConverter();
|
||||
|
||||
@Getter private static final Map<Location, CageLocationData> cageLocationDataMap = new HashMap<>();
|
||||
@Getter private static final List<UUID> playersInCage = new ArrayList<>();
|
||||
|
||||
@Expose @Getter @Setter private CustomCageSkillElement cage;
|
||||
|
||||
public Cage(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
nearbyEntities.forEach(livingEntity -> {
|
||||
UUID uuid = livingEntity.getUniqueId();
|
||||
|
||||
@ -53,7 +45,7 @@ public class Cage extends CustomSkill implements ISkillHandler {
|
||||
cagePlayerData.setBlockStateMaps(teleportLocation);
|
||||
livingEntity.teleport(teleportLocation);
|
||||
|
||||
ServerUtils.get().runLater(1L, () -> setCageBlocks(cagePlayerData));
|
||||
ServerUtils.get().runLater(1L, () -> setCageBlocks(cagePlayerData, customSkillElement.getCustom().getCustomCageSkillData(), skill));
|
||||
ServerUtils.get().runLater(100L, () -> {
|
||||
restoreCageBlocks(cagePlayerData);
|
||||
getPlayersInCage().remove(uuid);
|
||||
@ -93,19 +85,19 @@ public class Cage extends CustomSkill implements ISkillHandler {
|
||||
});
|
||||
}
|
||||
|
||||
private void setCageBlocks(CagePlayerData cagePlayerData) {
|
||||
private void setCageBlocks(CagePlayerData cagePlayerData, CustomCageSkillElement cage, Skill skill) {
|
||||
Map<String, Queue<BlockState>> queueMap = cagePlayerData.getMapOfCages();
|
||||
|
||||
setBlocks(queueMap.get("W"), getCage().getWallType());
|
||||
setBlocks(queueMap.get("F"), getCage().getFlatType());
|
||||
setBlocks(queueMap.get("I"), getCage().getInsideType());
|
||||
setBlocks(queueMap.get("W"), cage.getWallType(), skill);
|
||||
setBlocks(queueMap.get("F"), cage.getFlatType(), skill);
|
||||
setBlocks(queueMap.get("I"), cage.getInsideType(), skill);
|
||||
}
|
||||
|
||||
private void setBlocks(Queue<BlockState> queue, String materialType) {
|
||||
private void setBlocks(Queue<BlockState> queue, String materialType, Skill skill) {
|
||||
Material material = MATERIAL_CONVERTER.from(materialType);
|
||||
|
||||
if(material == null) {
|
||||
Debug.SKILL_CAGE_INVALID_MATERIAL.debug(materialType, getDisplayName());
|
||||
Debug.SKILL_CAGE_INVALID_MATERIAL.debug(materialType, skill.getDisplayName());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.songoda.epicbosses.skills.custom;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkill;
|
||||
import com.songoda.epicbosses.skills.CustomSkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import com.songoda.epicbosses.utils.Message;
|
||||
import com.songoda.epicbosses.utils.RandomUtils;
|
||||
import org.bukkit.Material;
|
||||
@ -18,14 +20,10 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 11-Nov-18
|
||||
*/
|
||||
public class Disarm extends CustomSkill implements ISkillHandler {
|
||||
|
||||
public Disarm(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
}
|
||||
public class Disarm extends CustomSkillHandler {
|
||||
|
||||
@Override
|
||||
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
nearbyEntities.forEach(livingEntity -> {
|
||||
EntityEquipment entityEquipment = livingEntity.getEquipment();
|
||||
int itemSlot = RandomUtils.get().getRandomNumber(5);
|
||||
@ -37,8 +35,8 @@ public class Disarm extends CustomSkill implements ISkillHandler {
|
||||
if(livingEntity instanceof HumanEntity) {
|
||||
HumanEntity humanEntity = (HumanEntity) livingEntity;
|
||||
|
||||
itemStack = PLUGIN.getVersionHandler().getItemInHand(humanEntity);
|
||||
PLUGIN.getVersionHandler().setItemInHand(humanEntity, replacementItemStack);
|
||||
itemStack = CustomBosses.get().getVersionHandler().getItemInHand(humanEntity);
|
||||
CustomBosses.get().getVersionHandler().setItemInHand(humanEntity, replacementItemStack);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.songoda.epicbosses.skills.custom;
|
||||
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkill;
|
||||
import com.songoda.epicbosses.skills.CustomSkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -13,19 +14,15 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 11-Nov-18
|
||||
*/
|
||||
public class Fireball extends CustomSkill implements ISkillHandler {
|
||||
|
||||
public Fireball(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
}
|
||||
public class Fireball extends CustomSkillHandler {
|
||||
|
||||
@Override
|
||||
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
LivingEntity boss = activeBossHolder.getLivingEntity();
|
||||
|
||||
if(boss == null) return;
|
||||
|
||||
Double multiplier = getCustom().getMultiplier();
|
||||
Double multiplier = customSkillElement.getCustom().getMultiplier();
|
||||
|
||||
if(multiplier == null) multiplier = 1.0;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.epicbosses.skills.custom;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkill;
|
||||
import com.songoda.epicbosses.skills.CustomSkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -15,16 +15,12 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 11-Nov-18
|
||||
*/
|
||||
public class Grapple extends CustomSkill implements ISkillHandler {
|
||||
|
||||
public Grapple(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
}
|
||||
public class Grapple extends CustomSkillHandler {
|
||||
|
||||
@Override
|
||||
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
Location bossLocation = activeBossHolder.getLocation();
|
||||
Double multiplier = getCustom().getMultiplier();
|
||||
Double multiplier = customSkillElement.getCustom().getMultiplier();
|
||||
|
||||
if(multiplier == null) multiplier = 1.0;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.epicbosses.skills.custom;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkill;
|
||||
import com.songoda.epicbosses.skills.CustomSkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.List;
|
||||
@ -13,15 +13,11 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 11-Nov-18
|
||||
*/
|
||||
public class Insidious extends CustomSkill implements ISkillHandler {
|
||||
|
||||
public Insidious(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
}
|
||||
public class Insidious extends CustomSkillHandler {
|
||||
|
||||
@Override
|
||||
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
Double multiplier = getCustom().getMultiplier();
|
||||
public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
Double multiplier = customSkillElement.getCustom().getMultiplier();
|
||||
|
||||
if(multiplier == null) multiplier = 2.5;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.epicbosses.skills.custom;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkill;
|
||||
import com.songoda.epicbosses.skills.CustomSkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -15,15 +15,11 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 11-Nov-18
|
||||
*/
|
||||
public class Knockback extends CustomSkill implements ISkillHandler {
|
||||
|
||||
public Knockback(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
}
|
||||
public class Knockback extends CustomSkillHandler {
|
||||
|
||||
@Override
|
||||
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
Double multiplier = getCustom().getMultiplier();
|
||||
public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
Double multiplier = customSkillElement.getCustom().getMultiplier();
|
||||
|
||||
if(multiplier == null) multiplier = 2.5;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.epicbosses.skills.custom;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkill;
|
||||
import com.songoda.epicbosses.skills.CustomSkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
@ -14,14 +14,10 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 11-Nov-18
|
||||
*/
|
||||
public class Launch extends CustomSkill implements ISkillHandler {
|
||||
|
||||
public Launch(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
}
|
||||
public class Launch extends CustomSkillHandler {
|
||||
|
||||
@Override
|
||||
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
Location bossLocation = activeBossHolder.getLocation();
|
||||
|
||||
nearbyEntities.forEach(livingEntity -> livingEntity.teleport(bossLocation.clone().add(0, 35, 0)));
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.epicbosses.skills.custom;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkill;
|
||||
import com.songoda.epicbosses.skills.CustomSkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.List;
|
||||
@ -13,14 +13,10 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 11-Nov-18
|
||||
*/
|
||||
public class Lightning extends CustomSkill implements ISkillHandler {
|
||||
|
||||
public Lightning(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
}
|
||||
public class Lightning extends CustomSkillHandler {
|
||||
|
||||
@Override
|
||||
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
nearbyEntities.forEach(livingEntity -> livingEntity.getWorld().strikeLightningEffect(livingEntity.getEyeLocation()));
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,10 @@
|
||||
package com.songoda.epicbosses.skills.custom;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.api.BossAPI;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.elements.CustomMinionSkillElement;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkill;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import com.songoda.epicbosses.skills.CustomSkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.List;
|
||||
@ -18,16 +14,10 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 11-Nov-18
|
||||
*/
|
||||
public class Minions extends CustomSkill implements ISkillHandler {
|
||||
|
||||
@Expose @Getter @Setter private CustomMinionSkillElement minions;
|
||||
|
||||
public Minions(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
}
|
||||
public class Minions extends CustomSkillHandler {
|
||||
|
||||
@Override
|
||||
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
BossAPI.spawnNewMinion(activeBossHolder, this);
|
||||
public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
BossAPI.spawnNewMinion(activeBossHolder, skill);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.epicbosses.skills.custom;
|
||||
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkill;
|
||||
import com.songoda.epicbosses.skills.CustomSkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.types.CustomSkillElement;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.List;
|
||||
@ -13,14 +13,10 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 11-Nov-18
|
||||
*/
|
||||
public class Warp extends CustomSkill implements ISkillHandler {
|
||||
|
||||
public Warp(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
}
|
||||
public class Warp extends CustomSkillHandler {
|
||||
|
||||
@Override
|
||||
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
public void castSkill(Skill skill, CustomSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
LivingEntity target = nearbyEntities.get(0);
|
||||
|
||||
activeBossHolder.getLivingEntity().teleport(target);
|
||||
|
@ -1,17 +0,0 @@
|
||||
package com.songoda.epicbosses.skills.elements;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 05-Nov-18
|
||||
*/
|
||||
public class CustomSkillElement {
|
||||
|
||||
@Expose @Getter @Setter private String type;
|
||||
@Expose @Getter @Setter private Double multiplier;
|
||||
|
||||
}
|
@ -11,7 +11,7 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 05-Nov-18
|
||||
*/
|
||||
public class CommandSkillElement {
|
||||
public class SubCommandSkillElement {
|
||||
|
||||
@Expose @Getter @Setter private Double chance;
|
||||
@Expose @Getter @Setter private List<String> commands;
|
@ -0,0 +1,42 @@
|
||||
package com.songoda.epicbosses.skills.elements;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.songoda.epicbosses.utils.BossesGson;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 05-Nov-18
|
||||
*/
|
||||
public class SubCustomSkillElement {
|
||||
|
||||
@Expose @Getter @Setter private String type;
|
||||
@Expose @Getter @Setter private Double multiplier;
|
||||
@Expose @Setter private JsonObject otherSkillData;
|
||||
|
||||
public SubCustomSkillElement(String type, Double multiplier, JsonObject otherSkillData) {
|
||||
this.type = type;
|
||||
this.multiplier = multiplier;
|
||||
this.otherSkillData = otherSkillData;
|
||||
}
|
||||
|
||||
public CustomCageSkillElement getCustomCageSkillData() {
|
||||
if(getType().equalsIgnoreCase("CAGE")) {
|
||||
return BossesGson.get().fromJson(this.otherSkillData, CustomCageSkillElement.class);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public CustomMinionSkillElement getCustomMinionSkillData() {
|
||||
if(getType().equalsIgnoreCase("MINION")) {
|
||||
return BossesGson.get().fromJson(this.otherSkillData, CustomMinionSkillElement.class);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package com.songoda.epicbosses.skills.types;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.elements.CommandSkillElement;
|
||||
import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.RandomUtils;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 05-Nov-18
|
||||
*/
|
||||
public class CommandSkill extends Skill implements ISkillHandler {
|
||||
|
||||
@Expose @Getter @Setter private List<CommandSkillElement> commands;
|
||||
|
||||
public CommandSkill(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
List<CommandSkillElement> commandSkillElements = getCommands();
|
||||
ServerUtils serverUtils = ServerUtils.get();
|
||||
|
||||
if(commandSkillElements.isEmpty()) {
|
||||
Debug.SKILL_COMMANDS_ARE_EMPTY.debug(getDisplayName());
|
||||
return;
|
||||
}
|
||||
|
||||
nearbyEntities.forEach(livingEntity ->
|
||||
commandSkillElements.forEach(commandSkillElement -> {
|
||||
Double chance = commandSkillElement.getChance();
|
||||
List<String> commands = commandSkillElement.getCommands();
|
||||
|
||||
if(commands == null || commands.isEmpty()) return;
|
||||
if(chance == null) chance = 100.0;
|
||||
if(!RandomUtils.get().canPreformAction(chance)) return;
|
||||
|
||||
commands.replaceAll(s -> s.replace("%player%", livingEntity.getName()));
|
||||
commands.forEach(serverUtils::sendConsoleCommand);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.songoda.epicbosses.skills.types;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.elements.SubCommandSkillElement;
|
||||
import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.RandomUtils;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 05-Nov-18
|
||||
*/
|
||||
public class CommandSkillElement implements ISkillHandler<CommandSkillElement> {
|
||||
|
||||
@Expose @Getter @Setter private List<SubCommandSkillElement> commands;
|
||||
|
||||
public CommandSkillElement(List<SubCommandSkillElement> commandSkillElements) {
|
||||
this.commands = commandSkillElements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void castSkill(Skill skill, CommandSkillElement commandSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
List<SubCommandSkillElement> commandSkillElements = getCommands();
|
||||
ServerUtils serverUtils = ServerUtils.get();
|
||||
|
||||
if(commandSkillElements.isEmpty()) {
|
||||
Debug.SKILL_COMMANDS_ARE_EMPTY.debug();
|
||||
return;
|
||||
}
|
||||
|
||||
nearbyEntities.forEach(livingEntity ->
|
||||
commandSkillElements.forEach(commandSkillEle -> {
|
||||
Double chance = commandSkillEle.getChance();
|
||||
List<String> commands = commandSkillEle.getCommands();
|
||||
|
||||
if(commands == null || commands.isEmpty()) return;
|
||||
if(chance == null) chance = 100.0;
|
||||
if(!RandomUtils.get().canPreformAction(chance)) return;
|
||||
|
||||
commands.replaceAll(s -> s.replace("%player%", livingEntity.getName()));
|
||||
commands.forEach(serverUtils::sendConsoleCommand);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.songoda.epicbosses.skills.types;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.Skill;
|
||||
import com.songoda.epicbosses.skills.elements.CustomSkillElement;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 05-Nov-18
|
||||
*/
|
||||
public class CustomSkill extends Skill {
|
||||
|
||||
protected static final CustomBosses PLUGIN = CustomBosses.get();
|
||||
|
||||
@Expose @Getter @Setter private CustomSkillElement custom;
|
||||
|
||||
public CustomSkill(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.songoda.epicbosses.skills.types;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.songoda.epicbosses.CustomBosses;
|
||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||
import com.songoda.epicbosses.skills.ISkillHandler;
|
||||
import com.songoda.epicbosses.skills.elements.SubCustomSkillElement;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
* @version 1.0.0
|
||||
* @since 05-Nov-18
|
||||
*/
|
||||
public class CustomSkillElement {
|
||||
|
||||
@Expose @Getter @Setter private SubCustomSkillElement custom;
|
||||
|
||||
public CustomSkillElement(SubCustomSkillElement subCustomSkillElement) {
|
||||
this.custom = subCustomSkillElement;
|
||||
}
|
||||
}
|
@ -15,16 +15,16 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 05-Nov-18
|
||||
*/
|
||||
public class GroupSkill extends Skill implements ISkillHandler {
|
||||
public class GroupSkillElement implements ISkillHandler<GroupSkillElement> {
|
||||
|
||||
@Expose @Getter @Setter private List<String> groupedSkills;
|
||||
|
||||
public GroupSkill(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
public GroupSkillElement(List<String> groupedSkills) {
|
||||
this.groupedSkills = groupedSkills;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
public void castSkill(Skill skill, GroupSkillElement groupSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
//TODO
|
||||
}
|
||||
}
|
@ -18,25 +18,24 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @since 05-Nov-18
|
||||
*/
|
||||
public class PotionSkill extends Skill implements ISkillHandler {
|
||||
public class PotionSkillElement implements ISkillHandler<PotionSkillElement> {
|
||||
|
||||
@Expose @Getter @Setter private List<PotionEffectHolder> potions;
|
||||
|
||||
private final PotionEffectConverter potionEffectConverter;
|
||||
|
||||
public PotionSkill(String mode, String type, Double radius, String displayName, String customMessage) {
|
||||
super(mode, type, radius, displayName, customMessage);
|
||||
|
||||
public PotionSkillElement(List<PotionEffectHolder> potions) {
|
||||
this.potions = potions;
|
||||
this.potionEffectConverter = new PotionEffectConverter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void castSkill(ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
public void castSkill(Skill skill, PotionSkillElement customSkillElement, ActiveBossHolder activeBossHolder, List<LivingEntity> nearbyEntities) {
|
||||
List<PotionEffectHolder> potionElements = getPotions();
|
||||
|
||||
if(potionElements == null) return;
|
||||
if(potionElements.isEmpty()) {
|
||||
Debug.SKILL_POTIONS_ARE_EMPTY.debug(getDisplayName());
|
||||
Debug.SKILL_POTIONS_ARE_EMPTY.debug();
|
||||
return;
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ public enum Debug {
|
||||
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_GIVE_SPAWN_EGG("{0} tried to obtain a spawn egg for the boss {1} but it has not been set yet."),
|
||||
FAILED_TO_CONNECT_TO_VAULT("Something went wrong while trying to connect to Vault. Please make sure you have an Economy and Permission plugin connected to your Vault plugin such as Essentials and GroupManager."),
|
||||
FAILED_TO_OBTAIN_THE_SKILL_HANDLER("Something went wrong when trying to detect the skill handler for {0}."),
|
||||
|
||||
DROP_TABLE_FAILED_INVALID_NUMBER("The specified position ({0}) on the drop table is not a valid number."),
|
||||
DROP_TABLE_FAILED_TO_GET_ITEM("The drop table failed to get the specific item for the list."),
|
||||
|
@ -28,6 +28,8 @@ public class NumberUtils {
|
||||
}
|
||||
|
||||
public int getSquared(int original) {
|
||||
if(original == -1) return -1;
|
||||
|
||||
return original * original;
|
||||
}
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -19,7 +19,7 @@
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<plugin.version>1.0.0-SNAPSHOT-U55</plugin.version>
|
||||
<plugin.version>1.0.0-SNAPSHOT-U58</plugin.version>
|
||||
<plugin.name>EpicBosses</plugin.name>
|
||||
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
|
||||
<plugin.author>AMinecraftDev</plugin.author>
|
||||
|
Loading…
Reference in New Issue
Block a user