1.0.0-SNAPSHOT-U166

+ Added HolographicDisplays support
+ Set up Holograms for the boss/minion names above them
This commit is contained in:
Charles 2019-01-02 21:07:37 +08:00
parent ec073be198
commit e4fceb2fb7
8 changed files with 97 additions and 12 deletions

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.3.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/gmail/filoghost/holographicdisplays/holographicdisplays-api/2.3.0/holographicdisplays-api-2.3.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/gmail/filoghost/holographicdisplays/holographicdisplays-api/2.3.0/holographicdisplays-api-2.3.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/gmail/filoghost/holographicdisplays/holographicdisplays-api/2.3.0/holographicdisplays-api-2.3.0-sources.jar!/" />
</SOURCES>
</library>
</component>

3
TODO
View File

@ -9,8 +9,7 @@
01:00 -> Wilderness - Button to change max coords, boss that autospawn applies to, maxActiveBosses, spawnChance
01:00 -> Spawner - Button to change max coords, boss that autospawn applies to, maxActiveBosses, spawnChance
00:30 -> Connect the /boss time [section] to the AutoSpawns timer (can only be applied to Interval AutoSpawns)
00:30 -> Add support for HolographicDisplays placeholder as the entityName for bosses and minions
01:00 -> Add a new branch for the plugin and add support for Legacy version
-----------
15:45 hrs
15:15 hrs

View File

@ -22,6 +22,8 @@ Hooks:
Factions:
enabled: false
useWarzoneSpawnRegion: false
HolographicDisplays:
enabled: false
StackMob:
enabled: false
WorldGuard:

View File

@ -1,6 +1,7 @@
package com.songoda.epicbosses;
import com.songoda.epicbosses.container.MinionEntityContainer;
import com.songoda.epicbosses.utils.dependencies.HolographicDisplayHelper;
import com.songoda.epicbosses.utils.dependencies.VaultHelper;
import lombok.Getter;
import com.songoda.epicbosses.api.BossAPI;
@ -61,6 +62,7 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
@Getter private YmlFileHandler langFileHandler, editorFileHandler, configFileHandler;
@Getter private FileConfiguration lang, editor, config;
@Getter private HolographicDisplayHelper holographicDisplayHelper;
@Getter private VaultHelper vaultHelper;
@Getter private boolean debug = false;
@ -75,7 +77,9 @@ public class CustomBosses extends JavaPlugin implements IReloadable {
Debug.setPlugin(this);
instance = this;
vaultHelper = new VaultHelper();
this.vaultHelper = new VaultHelper();
this.holographicDisplayHelper = new HolographicDisplayHelper();
long beginMs = System.currentTimeMillis();

View File

@ -1,5 +1,6 @@
package com.songoda.epicbosses.mechanics.boss;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.entity.elements.MainStatsElement;
@ -12,11 +13,11 @@ import org.bukkit.entity.LivingEntity;
* @author Charles Cullen
* @version 1.0.0
* @since 27-Jun-18
*
* TODO: Make a hologram above name instead of using default CustomName
*/
public class NameMechanic implements IBossMechanic {
private CustomBosses plugin = CustomBosses.get();
@Override
public boolean applyMechanic(BossEntity bossEntity, ActiveBossHolder activeBossHolder) {
if(activeBossHolder.getLivingEntityMap().getOrDefault(1, null) == null) return false;
@ -29,8 +30,15 @@ public class NameMechanic implements IBossMechanic {
if(livingEntity == null) return false;
if(customName != null) {
livingEntity.setCustomName(StringUtils.get().translateColor(customName));
livingEntity.setCustomNameVisible(true);
String formattedName = StringUtils.get().translateColor(customName);
if(CustomBosses.get().getConfig().getBoolean("Hooks.HolographicDisplays.enabled", false) && this.plugin.getHolographicDisplayHelper().isConnected()) {
this.plugin.getHolographicDisplayHelper().createHologram(livingEntity, formattedName);
livingEntity.setCustomNameVisible(false);
} else {
livingEntity.setCustomName(formattedName);
livingEntity.setCustomNameVisible(true);
}
}
}

View File

@ -1,5 +1,6 @@
package com.songoda.epicbosses.mechanics.minions;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.entity.MinionEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.entity.elements.MainStatsElement;
@ -12,11 +13,11 @@ import org.bukkit.entity.LivingEntity;
* @author Charles Cullen
* @version 1.0.0
* @since 27-Jun-18
*
* TODO: Make a hologram above name instead of using default CustomName
*/
public class NameMechanic implements IMinionMechanic {
private CustomBosses plugin = CustomBosses.get();
@Override
public boolean applyMechanic(MinionEntity minionEntity, ActiveMinionHolder activeMinionHolder) {
if(activeMinionHolder.getLivingEntityMap() == null || activeMinionHolder.getLivingEntityMap().isEmpty()) return false;
@ -29,8 +30,15 @@ public class NameMechanic implements IMinionMechanic {
if(livingEntity == null) return false;
if(customName != null) {
livingEntity.setCustomName(StringUtils.get().translateColor(customName));
livingEntity.setCustomNameVisible(true);
String formattedName = StringUtils.get().translateColor(customName);
if(CustomBosses.get().getConfig().getBoolean("Hooks.HolographicDisplays.enabled", false) && this.plugin.getHolographicDisplayHelper().isConnected()) {
this.plugin.getHolographicDisplayHelper().createHologram(livingEntity, formattedName);
livingEntity.setCustomNameVisible(false);
} else {
livingEntity.setCustomName(formattedName);
livingEntity.setCustomNameVisible(true);
}
}
}

View File

@ -0,0 +1,41 @@
package com.songoda.epicbosses.utils.dependencies;
import com.gmail.filoghost.holographicdisplays.api.Hologram;
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.utils.IHelper;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.scheduler.BukkitRunnable;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 02-Jan-19
*/
public class HolographicDisplayHelper implements IHelper {
@Override
public boolean isConnected() {
return Bukkit.getPluginManager().getPlugin("HolographicDisplays") != null;
}
public void createHologram(LivingEntity livingEntity, String line) {
CustomBosses plugin = CustomBosses.get();
Hologram hologram = HologramsAPI.createHologram(plugin, livingEntity.getEyeLocation());
hologram.insertTextLine(1, line);
new BukkitRunnable() {
@Override
public void run() {
if(!livingEntity.isDead()) {
hologram.teleport(livingEntity.getEyeLocation());
} else {
hologram.delete();
cancel();
}
}
}.runTaskTimer(plugin, 1L, 1L);
}
}

12
pom.xml
View File

@ -20,7 +20,7 @@
<properties>
<!--<plugin.version>maven-version-number-SNAPSHOT-U90</plugin.version>-->
<plugin.version>1.0.0-U165</plugin.version>
<plugin.version>1.0.0-U166</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>
@ -69,9 +69,19 @@
<version>1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
<artifactId>holographicdisplays-api</artifactId>
<version>2.3.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>filoghost-repo</id>
<url>https://ci.filoghost.me/plugin/repository/everything/</url>
</repository>
<repository>
<id>private</id>
<url>http://repo.songoda.com/repository/private/</url>