1.0.0-SNAPSHOT-U197

+ Added /epicbosses and /eb aliases to BossCmd
+ Fixed issue of SpawnItemManager not updating
+ Improved the message which is displayed when a boss is not complete enough to be enabled.
+ Fixed bug with BossTextManager buttons not working
+ Added /boss menu to the /boss help lists
This commit is contained in:
Charles 2019-01-11 02:48:55 +08:00
parent 449d7e7003
commit 42893e10b2
8 changed files with 94 additions and 67 deletions

View File

@ -13,7 +13,7 @@ import org.bukkit.command.CommandSender;
* @since 18-Jul-18
*/
@Name("boss")
@Alias({"bosses", "b", "bs"})
@Alias({"bosses", "b", "bs", "eb", "epicbosses"})
@Description("Used to handle all CustomBosses related commands.")
public class BossCmd extends SubCommandService<CommandSender> {

View File

@ -7,6 +7,7 @@ import lombok.Setter;
import com.songoda.epicbosses.entity.elements.*;
import com.songoda.epicbosses.utils.potion.holder.PotionEffectHolder;
import java.util.ArrayList;
import java.util.List;
/**
@ -50,6 +51,34 @@ public class BossEntity {
}
}
public List<String> getIncompleteSectionsToEnable() {
List<String> incompleteList = new ArrayList<>();
if(this.entityStats == null) incompleteList.add("EntityStats");
else {
EntityStatsElement entityStatsElement = this.entityStats.get(0);
if(entityStatsElement == null) incompleteList.add("EntityStatsElement");
else {
MainStatsElement mainStatsElement = entityStatsElement.getMainStats();
if(mainStatsElement == null) incompleteList.add("MainStatsElement");
else {
Integer position = mainStatsElement.getPosition();
String entityType = mainStatsElement.getEntityType();
Double health = mainStatsElement.getHealth();
if(position == null) incompleteList.add("Entity Position");
if(health == null) incompleteList.add("Entity Health");
if(entityType == null || entityType.isEmpty()) incompleteList.add("Entity Type");
if(getSpawnItem() == null || getSpawnItem().isEmpty()) incompleteList.add("Spawn Item");
}
}
}
return incompleteList;
}
public boolean isCompleteEnoughToSpawn() {
if(this.entityStats == null) return false;

View File

@ -9,6 +9,7 @@ import com.songoda.epicbosses.managers.files.BossesFileManager;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.ObjectUtils;
import com.songoda.epicbosses.utils.ServerUtils;
import com.songoda.epicbosses.utils.StringUtils;
import com.songoda.epicbosses.utils.panel.Panel;
import com.songoda.epicbosses.utils.panel.base.ClickAction;
import com.songoda.epicbosses.utils.panel.base.handlers.VariablePanelHandler;
@ -18,6 +19,7 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -95,7 +97,9 @@ public class MainBossEditPanel extends VariablePanelHandler<BossEntity> {
this.bossEntityManager.killAllHolders(bossEntity);
}
} else {
Message.Boss_Edit_NotCompleteEnough.msg(player);
List<String> incompleteThings = bossEntity.getIncompleteSectionsToEnable();
Message.Boss_Edit_NotCompleteEnough.msg(player, StringUtils.get().appendList(incompleteThings));
}
};
}

View File

@ -3,7 +3,6 @@ package com.songoda.epicbosses.panel.bosses;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.entity.elements.EntityStatsElement;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.managers.files.BossesFileManager;
import com.songoda.epicbosses.managers.files.ItemsFileManager;

View File

@ -41,35 +41,33 @@ public class SpawnTextEditorPanel extends VariablePanelHandler<BossEntity> {
@Override
public void openFor(Player player, BossEntity bossEntity) {
Map<String, String> replaceMap = new HashMap<>();
Integer radius = bossEntity.getMessages().getOnSpawn().getRadius();
String message = bossEntity.getMessages().getOnDeath().getMessage();
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
if(radius == null) radius = 0;
if(message == null) message = "N/A";
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
replaceMap.put("{radius}", NumberUtils.get().formatDouble(radius));
replaceMap.put("{selected}", message);
panelBuilder.addReplaceData(replaceMap);
Panel panel = panelBuilder.getPanel()
.setDestroyWhenDone(true)
.setCancelClick(true)
.setCancelLowerClick(true)
.setParentPanelHandler(this.bossPanelManager.getMainTextEditMenu(), bossEntity);
PanelBuilderCounter counter = panel.getPanelBuilderCounter();
ServerUtils.get().runTaskAsync(() -> {
Map<String, String> replaceMap = new HashMap<>();
Integer radius = bossEntity.getMessages().getOnSpawn().getRadius();
String message = bossEntity.getMessages().getOnDeath().getMessage();
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
counter.getSlotsWith("Select").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getOnSpawnTextEditMenu().openFor((Player) event.getWhoClicked(), bossEntity)));
counter.getSlotsWith("Radius").forEach(slot -> panel.setOnClick(slot, getRadiusAction(bossEntity)));
if(radius == null) radius = 0;
if(message == null) message = "N/A";
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
replaceMap.put("{radius}", NumberUtils.get().formatDouble(radius));
replaceMap.put("{selected}", message);
panelBuilder.addReplaceData(replaceMap);
Panel panel = panelBuilder.getPanel()
.setDestroyWhenDone(true)
.setCancelClick(true)
.setCancelLowerClick(true)
.setParentPanelHandler(this.bossPanelManager.getMainTextEditMenu(), bossEntity);
PanelBuilderCounter counter = panel.getPanelBuilderCounter();
ServerUtils.get().runTaskAsync(() -> {
counter.getSlotsWith("Select").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getOnSpawnTextEditMenu().openFor((Player) event.getWhoClicked(), bossEntity)));
counter.getSlotsWith("Radius").forEach(slot -> panel.setOnClick(slot, getRadiusAction(bossEntity)));
});
panel.openFor(player);
});
panel.openFor(player);
}
@Override

View File

@ -45,39 +45,37 @@ public class TauntTextEditorPanel extends VariablePanelHandler<BossEntity> {
@Override
public void openFor(Player player, BossEntity bossEntity) {
Map<String, String> replaceMap = new HashMap<>();
TauntElement tauntElement = bossEntity.getMessages().getTaunts();
Integer radius = tauntElement.getRadius();
Integer delay = tauntElement.getDelay();
List<String> taunts = tauntElement.getTaunts();
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
if(radius == null) radius = 100;
if(delay == null) delay = 60;
if(taunts == null || taunts.isEmpty()) taunts = Arrays.asList("N/A");
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
replaceMap.put("{radius}", NumberUtils.get().formatDouble(radius));
replaceMap.put("{delay}", NumberUtils.get().formatDouble(delay));
replaceMap.put("{taunts}", StringUtils.get().appendList(taunts));
panelBuilder.addReplaceData(replaceMap);
Panel panel = panelBuilder.getPanel()
.setDestroyWhenDone(true)
.setCancelClick(true)
.setCancelLowerClick(true)
.setParentPanelHandler(this.bossPanelManager.getMainTextEditMenu(), bossEntity);
PanelBuilderCounter counter = panel.getPanelBuilderCounter();
ServerUtils.get().runTaskAsync(() -> {
Map<String, String> replaceMap = new HashMap<>();
TauntElement tauntElement = bossEntity.getMessages().getTaunts();
Integer radius = tauntElement.getRadius();
Integer delay = tauntElement.getDelay();
List<String> taunts = tauntElement.getTaunts();
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
if(radius == null) radius = 100;
if(delay == null) delay = 60;
if(taunts == null || taunts.isEmpty()) taunts = Arrays.asList("N/A");
replaceMap.put("{name}", BossAPI.getBossEntityName(bossEntity));
replaceMap.put("{radius}", NumberUtils.get().formatDouble(radius));
replaceMap.put("{delay}", NumberUtils.get().formatDouble(delay));
replaceMap.put("{taunts}", StringUtils.get().appendList(taunts));
panelBuilder.addReplaceData(replaceMap);
Panel panel = panelBuilder.getPanel()
.setDestroyWhenDone(true)
.setCancelClick(true)
.setCancelLowerClick(true)
.setParentPanelHandler(this.bossPanelManager.getMainTextEditMenu(), bossEntity);
PanelBuilderCounter counter = panel.getPanelBuilderCounter();
ServerUtils.get().runTaskAsync(() -> {
counter.getSlotsWith("Radius").forEach(slot -> panel.setOnClick(slot, getRadiusAction(bossEntity)));
counter.getSlotsWith("Delay").forEach(slot -> panel.setOnClick(slot, getDelayAction(bossEntity)));
counter.getSlotsWith("Taunts").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getOnTauntTextEditMenu().openFor((Player) event.getWhoClicked(), bossEntity)));
});
panel.openFor(player);
counter.getSlotsWith("Radius").forEach(slot -> panel.setOnClick(slot, getRadiusAction(bossEntity)));
counter.getSlotsWith("Delay").forEach(slot -> panel.setOnClick(slot, getDelayAction(bossEntity)));
counter.getSlotsWith("Taunts").forEach(slot -> panel.setOnClick(slot, event -> this.bossPanelManager.getOnTauntTextEditMenu().openFor((Player) event.getWhoClicked(), bossEntity)));
});
panel.openFor(player);
}
@Override

View File

@ -63,7 +63,7 @@ public enum Message {
Boss_Edit_ItemStackHolderNull("&c&l(!) &cThe itemstack name that is provided for the spawn item doesn't exist or wasn't found."),
Boss_Edit_CannotSpawn("&c&l(!) &cYou cannot spawn this boss while editing is enabled. If you think this is a mistake please contact an administrator to disable the editing of the boss."),
Boss_Edit_Toggled("&b&lEpicBosses &8» &7You have toggled the editing mode for &f{0}&7 to &f{1}&7."),
Boss_Edit_NotCompleteEnough("&c&l(!) &cThe boss is not set up enough to be enabled. Please make sure it has: &fA Spawn Item, Entity Type, Health and Position&c before you try and enable the boss."),
Boss_Edit_NotCompleteEnough("&c&l(!) &cThe boss is not set up enough to be enabled. Please make sure it has the following things: &f{0}&c Once these things are set try toggling again."),
Boss_Edit_DoesntExist("&c&l(!) &cThe specified boss does not exist. Please try again with the proper name. If you cannot figure it out please check the bosses.json file to find the one you're looking for."),
Boss_GiveEgg_NoPermission("&c&l(!) &cYou do not have access to this command."),
@ -82,7 +82,6 @@ public enum Message {
"&b/boss info [name] &8» &7Shows information on the specified boss.\n" +
"&b/boss nearby (radius) &8» &7Shows the nearby bosses.\n" +
"&b/boss reload &8» &7Reloads the boss plugin.\n" +
"&b/boss killall (world) &8» &7Kills all bosses/minions.\n" +
"&7\n" +
"&7Use /boss help 2 to view the next page.\n" +
"&8&m----*-----------------------------------*----"),
@ -91,16 +90,16 @@ public enum Message {
"&b/boss spawn [name] (location) &8» &7Spawns a boss at your" +
" location or the specified location.\n" +
"&7&o(Separate location with commas, an example is: world,0,100,0)\n" +
"&b/boss time [section] &8» &7Shows the time left till next auto spawn.\n" +
"&b/boss droptable &8» &7Shows all current drop tables.\n" +
"&b/boss items &8» &7Shows all current custom items.\n" +
"&b/boss skills &8» &7Shows all current set skills.\n" +
"&b/boss skills &8» &7Shows all current set skills.\n" +
"&b/boss killall (world) &8» &7Kills all bosses/minions.\n" +
"&7\n" +
"&7Use /boss help 3 to view the next page.\n" +
"&8&m----*-----------------------------------*----"),
Boss_Help_Page3(
"&8&m----*--------&3&l[ &b&lBoss Help &7(Page 3/4) &3&l]&8&m--------*----\n" +
"&b/boss debug &8» &7Used to toggle the debug aspect of the plugin.\n" +
"&b/boss time [section] &8» &7Shows the time left till next auto spawn.\n" +
"&b/boss giveegg [name] [player] (amount) &8» &7Used to be given a " +
"spawn item of the boss.\n" +
"&b/boss list &8» &7Shows all the list of current boss entities.\n" +
@ -116,7 +115,7 @@ public enum Message {
"&b/boss new message [name] [messages] &8» &7Used to create a new message section.\n" +
"&7&o(To add a new line use &7||&7&o in-between the messages.)\n" +
"&7/boss new autospawn [name] &8» &7Used to create a new auto spawn section.\n" +
"&7\n" +
"&b/boss debug &8» &7Used to toggle the debug aspect of the plugin.\n" +
"&7\n" +
"&7\n" +
"&7Use /boss help [page] to view the next page.\n" +

View File

@ -19,7 +19,7 @@
</modules>
<properties>
<plugin.version>1.0.0-U196</plugin.version>
<plugin.version>1.0.0-U197</plugin.version>
<plugin.name>EpicBosses</plugin.name>
<plugin.main>com.songoda.epicbosses.CustomBosses</plugin.main>
<plugin.author>AMinecraftDev</plugin.author>