mirror of
https://github.com/songoda/EpicBosses.git
synced 2025-01-10 01:07:34 +01:00
1.0.0-SNAPSHOT-U39
+ Started and completed the Taunt system for bosses which runs on intervals. + Updated NumberUtils to contain a squared int method + Added MessageUtils to make sendMessage easier for radius messages, and just simple messages
This commit is contained in:
parent
a8662dc2f3
commit
6a77346abb
@ -1,6 +1,5 @@
|
|||||||
package com.songoda.epicbosses;
|
package com.songoda.epicbosses;
|
||||||
|
|
||||||
import com.songoda.epicbosses.targetting.TargetHandler;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import com.songoda.epicbosses.api.BossAPI;
|
import com.songoda.epicbosses.api.BossAPI;
|
||||||
import com.songoda.epicbosses.commands.BossCmd;
|
import com.songoda.epicbosses.commands.BossCmd;
|
||||||
@ -44,6 +43,7 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
|
|||||||
@Getter private BossEntityManager bossEntityManager;
|
@Getter private BossEntityManager bossEntityManager;
|
||||||
@Getter private BossTargetManager bossTargetManager;
|
@Getter private BossTargetManager bossTargetManager;
|
||||||
@Getter private BossPanelManager bossPanelManager;
|
@Getter private BossPanelManager bossPanelManager;
|
||||||
|
@Getter private BossTauntManager bossTauntManager;
|
||||||
@Getter private BossHookManager bossHookManager;
|
@Getter private BossHookManager bossHookManager;
|
||||||
@Getter private VersionHandler versionHandler;
|
@Getter private VersionHandler versionHandler;
|
||||||
@Getter private DebugManager debugManager;
|
@Getter private DebugManager debugManager;
|
||||||
@ -64,6 +64,7 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
|
|||||||
|
|
||||||
this.debugManager = new DebugManager();
|
this.debugManager = new DebugManager();
|
||||||
this.versionHandler = new VersionHandler();
|
this.versionHandler = new VersionHandler();
|
||||||
|
this.bossTauntManager = new BossTauntManager(this);
|
||||||
this.bossTargetManager = new BossTargetManager(this);
|
this.bossTargetManager = new BossTargetManager(this);
|
||||||
this.bossEntityContainer = new BossEntityContainer();
|
this.bossEntityContainer = new BossEntityContainer();
|
||||||
this.bossMechanicManager = new BossMechanicManager(this);
|
this.bossMechanicManager = new BossMechanicManager(this);
|
||||||
|
@ -2,7 +2,7 @@ package com.songoda.epicbosses.holder;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import com.songoda.epicbosses.targetting.TargetHandler;
|
import com.songoda.epicbosses.targeting.TargetHandler;
|
||||||
import com.songoda.epicbosses.entity.BossEntity;
|
import com.songoda.epicbosses.entity.BossEntity;
|
||||||
import com.songoda.epicbosses.exception.AlreadySetException;
|
import com.songoda.epicbosses.exception.AlreadySetException;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -9,6 +9,7 @@ import com.songoda.epicbosses.holder.ActiveBossHolder;
|
|||||||
import com.songoda.epicbosses.holder.DeadBossHolder;
|
import com.songoda.epicbosses.holder.DeadBossHolder;
|
||||||
import com.songoda.epicbosses.managers.BossEntityManager;
|
import com.songoda.epicbosses.managers.BossEntityManager;
|
||||||
import com.songoda.epicbosses.utils.Debug;
|
import com.songoda.epicbosses.utils.Debug;
|
||||||
|
import com.songoda.epicbosses.utils.MessageUtils;
|
||||||
import com.songoda.epicbosses.utils.NumberUtils;
|
import com.songoda.epicbosses.utils.NumberUtils;
|
||||||
import com.songoda.epicbosses.utils.ServerUtils;
|
import com.songoda.epicbosses.utils.ServerUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -124,17 +125,7 @@ public class BossDeathListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(messageRadius == -1) {
|
MessageUtils.get().sendMessage(location, NumberUtils.get().getSquared(messageRadius), finalMessage);
|
||||||
finalMessage.forEach(Bukkit::broadcastMessage);
|
|
||||||
} else {
|
|
||||||
Bukkit.getOnlinePlayers().forEach(onlinePlayer -> {
|
|
||||||
if(onlinePlayer.getWorld().getName().equals(location.getWorld().getName())) {
|
|
||||||
if(onlinePlayer.getLocation().distanceSquared(location) <= messageRadius) {
|
|
||||||
finalMessage.forEach(onlinePlayer::sendMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -10,10 +10,8 @@ import com.songoda.epicbosses.holder.ActiveBossHolder;
|
|||||||
import com.songoda.epicbosses.managers.BossEntityManager;
|
import com.songoda.epicbosses.managers.BossEntityManager;
|
||||||
import com.songoda.epicbosses.managers.BossLocationManager;
|
import com.songoda.epicbosses.managers.BossLocationManager;
|
||||||
import com.songoda.epicbosses.managers.BossTargetManager;
|
import com.songoda.epicbosses.managers.BossTargetManager;
|
||||||
import com.songoda.epicbosses.utils.Debug;
|
import com.songoda.epicbosses.managers.BossTauntManager;
|
||||||
import com.songoda.epicbosses.utils.Message;
|
import com.songoda.epicbosses.utils.*;
|
||||||
import com.songoda.epicbosses.utils.ServerUtils;
|
|
||||||
import com.songoda.epicbosses.utils.StringUtils;
|
|
||||||
import com.songoda.epicbosses.utils.itemstack.ItemStackUtils;
|
import com.songoda.epicbosses.utils.itemstack.ItemStackUtils;
|
||||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -41,10 +39,12 @@ public class BossSpawnListener implements Listener {
|
|||||||
private BossLocationManager bossLocationManager;
|
private BossLocationManager bossLocationManager;
|
||||||
private BossTargetManager bossTargetManager;
|
private BossTargetManager bossTargetManager;
|
||||||
private BossEntityManager bossEntityManager;
|
private BossEntityManager bossEntityManager;
|
||||||
|
private BossTauntManager bossTauntManager;
|
||||||
private VersionHandler versionHandler;
|
private VersionHandler versionHandler;
|
||||||
|
|
||||||
public BossSpawnListener(CustomBosses customBosses) {
|
public BossSpawnListener(CustomBosses customBosses) {
|
||||||
this.versionHandler = customBosses.getVersionHandler();
|
this.versionHandler = customBosses.getVersionHandler();
|
||||||
|
this.bossTauntManager = customBosses.getBossTauntManager();
|
||||||
this.bossEntityManager = customBosses.getBossEntityManager();
|
this.bossEntityManager = customBosses.getBossEntityManager();
|
||||||
this.bossTargetManager = customBosses.getBossTargetManager();
|
this.bossTargetManager = customBosses.getBossTargetManager();
|
||||||
this.bossLocationManager = customBosses.getBossLocationManager();
|
this.bossLocationManager = customBosses.getBossLocationManager();
|
||||||
@ -122,7 +122,7 @@ public class BossSpawnListener implements Listener {
|
|||||||
|
|
||||||
List<String> commands = this.bossEntityManager.getOnSpawnCommands(bossEntity);
|
List<String> commands = this.bossEntityManager.getOnSpawnCommands(bossEntity);
|
||||||
List<String> messages = this.bossEntityManager.getOnSpawnMessage(bossEntity);
|
List<String> messages = this.bossEntityManager.getOnSpawnMessage(bossEntity);
|
||||||
int messagesRadius = this.bossEntityManager.getOnSpawnMessageRadius(bossEntity);
|
int messageRadius = this.bossEntityManager.getOnSpawnMessageRadius(bossEntity);
|
||||||
|
|
||||||
if(commands != null) {
|
if(commands != null) {
|
||||||
commands.forEach(command -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command));
|
commands.forEach(command -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command));
|
||||||
@ -130,23 +130,12 @@ public class BossSpawnListener implements Listener {
|
|||||||
if(messages != null) {
|
if(messages != null) {
|
||||||
if(activeBossHolder.getName() != null) messages.replaceAll(s -> s.replace("{boss}", activeBossHolder.getName()));
|
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("{location}", StringUtils.get().translateLocation(location)));
|
||||||
messages.replaceAll(s -> s.replace('&', '§'));
|
|
||||||
|
|
||||||
if(messagesRadius == -1) {
|
MessageUtils.get().sendMessage(location, NumberUtils.get().getSquared(messageRadius), messages);
|
||||||
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(onlinePlayer::sendMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
activeBossHolder.getTargetHandler().runTargetCycle();
|
activeBossHolder.getTargetHandler().runTargetCycle();
|
||||||
//TODO: Handle Taunts
|
this.bossTauntManager.handleTauntSystem(activeBossHolder);
|
||||||
|
|
||||||
BossSpawnEvent bossSpawnEvent = new BossSpawnEvent(activeBossHolder);
|
BossSpawnEvent bossSpawnEvent = new BossSpawnEvent(activeBossHolder);
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@ package com.songoda.epicbosses.managers;
|
|||||||
import com.songoda.epicbosses.CustomBosses;
|
import com.songoda.epicbosses.CustomBosses;
|
||||||
import com.songoda.epicbosses.entity.BossEntity;
|
import com.songoda.epicbosses.entity.BossEntity;
|
||||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||||
import com.songoda.epicbosses.targetting.TargetHandler;
|
import com.songoda.epicbosses.targeting.TargetHandler;
|
||||||
import com.songoda.epicbosses.targetting.types.ClosestTargetHandler;
|
import com.songoda.epicbosses.targeting.types.ClosestTargetHandler;
|
||||||
import com.songoda.epicbosses.targetting.types.NotDamagedNearbyTargetHandler;
|
import com.songoda.epicbosses.targeting.types.NotDamagedNearbyTargetHandler;
|
||||||
import com.songoda.epicbosses.targetting.types.RandomNearbyTargetHandler;
|
import com.songoda.epicbosses.targeting.types.RandomNearbyTargetHandler;
|
||||||
import com.songoda.epicbosses.targetting.types.TopDamagerTargetHandler;
|
import com.songoda.epicbosses.targeting.types.TopDamagerTargetHandler;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,69 @@
|
|||||||
|
package com.songoda.epicbosses.managers;
|
||||||
|
|
||||||
|
import com.songoda.epicbosses.CustomBosses;
|
||||||
|
import com.songoda.epicbosses.api.BossAPI;
|
||||||
|
import com.songoda.epicbosses.entity.BossEntity;
|
||||||
|
import com.songoda.epicbosses.entity.elements.TauntElement;
|
||||||
|
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||||
|
import com.songoda.epicbosses.utils.MessageUtils;
|
||||||
|
import com.songoda.epicbosses.utils.NumberUtils;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Queue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Charles Cullen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 04-Nov-18
|
||||||
|
*/
|
||||||
|
public class BossTauntManager {
|
||||||
|
|
||||||
|
private CustomBosses plugin;
|
||||||
|
|
||||||
|
public BossTauntManager(CustomBosses plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleTauntSystem(ActiveBossHolder activeBossHolder) {
|
||||||
|
BossEntity bossEntity = activeBossHolder.getBossEntity();
|
||||||
|
|
||||||
|
if(bossEntity.getMessages() == null) return;
|
||||||
|
if(bossEntity.getMessages().getTaunts() == null) return;
|
||||||
|
|
||||||
|
TauntElement tauntElement = bossEntity.getMessages().getTaunts();
|
||||||
|
Integer delay = tauntElement.getDelay();
|
||||||
|
Integer radius = tauntElement.getRadius();
|
||||||
|
List<String> taunts = tauntElement.getTaunts();
|
||||||
|
|
||||||
|
if(delay == null) delay = 60;
|
||||||
|
if(radius == null) radius = 100;
|
||||||
|
|
||||||
|
if(taunts != null) {
|
||||||
|
if(taunts.isEmpty()) return;
|
||||||
|
|
||||||
|
createRunnable(taunts, activeBossHolder, NumberUtils.get().getSquared(radius), delay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createRunnable(List<String> taunts, ActiveBossHolder activeBossHolder, int radius, int delay) {
|
||||||
|
new BukkitRunnable() {
|
||||||
|
Queue<String> queue = new LinkedList<>(taunts);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(activeBossHolder.isDead()) {
|
||||||
|
cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.queue.isEmpty()) this.queue = new LinkedList<>(taunts);
|
||||||
|
|
||||||
|
List<String> messages = BossAPI.getStoredMessages(this.queue.poll());
|
||||||
|
|
||||||
|
MessageUtils.get().sendMessage(activeBossHolder.getLocation(), radius, messages);
|
||||||
|
}
|
||||||
|
}.runTaskTimer(this.plugin, delay*20, delay*20);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.songoda.epicbosses.targetting;
|
package com.songoda.epicbosses.targeting;
|
||||||
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
@ -1,6 +1,5 @@
|
|||||||
package com.songoda.epicbosses.targetting;
|
package com.songoda.epicbosses.targeting;
|
||||||
|
|
||||||
import com.songoda.epicbosses.CustomBosses;
|
|
||||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||||
import com.songoda.epicbosses.managers.BossTargetManager;
|
import com.songoda.epicbosses.managers.BossTargetManager;
|
||||||
import com.songoda.epicbosses.utils.ServerUtils;
|
import com.songoda.epicbosses.utils.ServerUtils;
|
@ -1,8 +1,8 @@
|
|||||||
package com.songoda.epicbosses.targetting.types;
|
package com.songoda.epicbosses.targeting.types;
|
||||||
|
|
||||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||||
import com.songoda.epicbosses.managers.BossTargetManager;
|
import com.songoda.epicbosses.managers.BossTargetManager;
|
||||||
import com.songoda.epicbosses.targetting.TargetHandler;
|
import com.songoda.epicbosses.targeting.TargetHandler;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,8 +1,8 @@
|
|||||||
package com.songoda.epicbosses.targetting.types;
|
package com.songoda.epicbosses.targeting.types;
|
||||||
|
|
||||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||||
import com.songoda.epicbosses.managers.BossTargetManager;
|
import com.songoda.epicbosses.managers.BossTargetManager;
|
||||||
import com.songoda.epicbosses.targetting.TargetHandler;
|
import com.songoda.epicbosses.targeting.TargetHandler;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,8 +1,8 @@
|
|||||||
package com.songoda.epicbosses.targetting.types;
|
package com.songoda.epicbosses.targeting.types;
|
||||||
|
|
||||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||||
import com.songoda.epicbosses.managers.BossTargetManager;
|
import com.songoda.epicbosses.managers.BossTargetManager;
|
||||||
import com.songoda.epicbosses.targetting.TargetHandler;
|
import com.songoda.epicbosses.targeting.TargetHandler;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
@ -1,8 +1,8 @@
|
|||||||
package com.songoda.epicbosses.targetting.types;
|
package com.songoda.epicbosses.targeting.types;
|
||||||
|
|
||||||
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
import com.songoda.epicbosses.holder.ActiveBossHolder;
|
||||||
import com.songoda.epicbosses.managers.BossTargetManager;
|
import com.songoda.epicbosses.managers.BossTargetManager;
|
||||||
import com.songoda.epicbosses.targetting.TargetHandler;
|
import com.songoda.epicbosses.targeting.TargetHandler;
|
||||||
import com.songoda.epicbosses.utils.MapUtils;
|
import com.songoda.epicbosses.utils.MapUtils;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
|
@ -0,0 +1,51 @@
|
|||||||
|
package com.songoda.epicbosses.utils;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Charles Cullen
|
||||||
|
* @version 1.0.0
|
||||||
|
* @since 04-Nov-18
|
||||||
|
*/
|
||||||
|
public class MessageUtils {
|
||||||
|
|
||||||
|
private static MessageUtils INSTANCE = new MessageUtils();
|
||||||
|
|
||||||
|
public void sendMessage(Player player, String... messages) {
|
||||||
|
sendMessage(player, Arrays.asList(messages));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMessage(Player player, List<String> messages) {
|
||||||
|
for(String s : messages) {
|
||||||
|
player.sendMessage(StringUtils.get().translateColor(s));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMessage(Location center, int radius, String... messages) {
|
||||||
|
sendMessage(center, radius, Arrays.asList(messages));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMessage(Location center, int radius, List<String> messages) {
|
||||||
|
messages.replaceAll(s -> s.replace('&', '§'));
|
||||||
|
|
||||||
|
if(radius == -1) {
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> messages.forEach(player::sendMessage));
|
||||||
|
} else {
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
|
if((player.getWorld().equals(center.getWorld())) && (player.getLocation().distanceSquared(center) <= radius)) {
|
||||||
|
messages.forEach(player::sendMessage);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageUtils get() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -27,6 +27,10 @@ public class NumberUtils {
|
|||||||
return Integer.valueOf(input);
|
return Integer.valueOf(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSquared(int original) {
|
||||||
|
return original * original;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isDouble(String string) {
|
public boolean isDouble(String string) {
|
||||||
try {
|
try {
|
||||||
Double.valueOf(string);
|
Double.valueOf(string);
|
||||||
|
2
pom.xml
2
pom.xml
@ -19,7 +19,7 @@
|
|||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<plugin.version>1.0.0-SNAPSHOT-U38</plugin.version>
|
<plugin.version>1.0.0-SNAPSHOT-U39</plugin.version>
|
||||||
<plugin.name>EpicBosses</plugin.name>
|
<plugin.name>EpicBosses</plugin.name>
|
||||||
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
|
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
|
||||||
<plugin.author>AMinecraftDev</plugin.author>
|
<plugin.author>AMinecraftDev</plugin.author>
|
||||||
|
Loading…
Reference in New Issue
Block a user