1.0.0-SNAPSHOT-U51

+ Fixed issues reported by Fruit
+ Adjusted the GUIs to handle correctly
+ Completed some commands
+ Added GiveEgg command
+ Updated configuration files
+ Updated Messages to match color scheme of artwork
This commit is contained in:
AMinecraftDev 2018-11-16 00:11:28 +08:00
parent 3d5022b3e0
commit 4fe07e8bc5
22 changed files with 307 additions and 128 deletions

View File

@ -1,4 +1,7 @@
{
"DefaultBossMenuItem": {
"type": "BARRIER"
},
"SKSpawnItem": {
"type": "SKELETON_SPAWN_EGG",
"name": "&6&lSkeleton King Boss Spawn Egg",

View File

@ -2,6 +2,7 @@ Settings:
debug: false
bossTargetRange: 50.0
defaultNearbyRadius: 250.0
nearbyFormat: '{name} ({distance}m)'
BlockedWorlds:
enabled: false
@ -11,6 +12,8 @@ Settings:
Toggles:
endermanTeleporting: true
potionsAffectingBoss: true
Limits:
maxNearbyRadius: 500.0
Hooks:
ASkyBlock:
enabled: false
@ -30,13 +33,13 @@ Hooks:
- 'blocked_region2'
Display:
Bosses:
name: '&e&l{name}'
name: '&b&l{name}'
lore:
- '&eEnabled: &7{enabled}'
- '&3Editing: &f{enabled}'
- '&7'
- '&eLeft Click »'
- '&7Edit the custom boss.'
- '&7'
- '&eRight Click »'
- '&3Left Click »'
- '&7Get spawn item for custom'
- '&7boss.'
- '&7boss.'
- '&7'
- '&3Right Click »'
- '&7Edit the custom boss.'

View File

@ -13,7 +13,7 @@
# BackButton: 9 # back button slot #
# ExitButton: 9 # exit button slot #
MainMenu:
name: '&6&lCustomBosses'
name: '&b&lEpicBosses'
slots: 18
Settings:
emptySpaceFiller: true
@ -23,61 +23,61 @@ MainMenu:
Items:
'2':
type: ZOMBIE_SPAWN_EGG
name: '&6&lCustomBosses'
name: '&b&lCustom Bosses'
lore:
- '&eLeft Click »'
- '&3Left Click »'
- '&7Edit any of the already created'
- '&7custom bosses.'
- '&7'
- '&eRight Click »'
- '&3Right Click »'
- '&7Create a new custom boss from'
- '&7scratch.'
Button: CustomBosses
'5':
type: DIAMOND
name: '&6&lCustom Items'
name: '&b&lCustom Items'
lore:
- '&eLeft Click »'
- '&3Left Click »'
- '&7Edit any of the already created'
- '&7custom items.'
- '&7'
- '&eRight Click »'
- '&3Right Click »'
- '&7Create a new custom item from'
- '&7an item in your inventory.'
Button: CustomItems
'8':
type: CLOCK
name: '&6&lAutoSpawns'
name: '&b&lAuto Spawns'
lore:
- '&eLeft Click »'
- '&3Left Click »'
- '&7Edit any of the already created'
- '&7auto spawns.'
- '&7'
- '&eRight Click »'
- '&3Right Click »'
- '&7Create a new auto spawn from'
- '&7scratch.'
Button: AutoSpawns
'12':
type: OAK_PRESSURE_PLATE
name: '&6&lDrop Tables'
name: '&b&lDrop Tables'
lore:
- '&eLeft Click »'
- '&3Left Click »'
- '&7Edit any of the already created'
- '&7drop tables.'
- '&7'
- '&eRight Click »'
- '&3Right Click »'
- '&7Create a new drop table from'
- '&7scratch.'
Button: DropTables
'16':
type: BLAZE_POWDER
name: '&6&lCustom Skills'
name: '&b&lCustom Skills'
lore:
- '&eLeft Click »'
- '&3Left Click »'
- '&fEdit any of the already created'
- '&fcustom skills.'
- '&7'
- '&eRight Click »'
- '&3Right Click »'
- '&fCreate a new custom skill from'
- '&fscratch.'
Button: CustomSkills

View File

@ -197,6 +197,7 @@ public class BossAPI {
return null;
}
PLUGIN.getBossesFileManager().saveBossEntity(name, bossEntity);
PLUGIN.getBossesFileManager().save();
return bossEntity;

View File

@ -1,9 +1,21 @@
package com.songoda.epicbosses.commands.boss;
import com.songoda.epicbosses.utils.command.SubCommand;
import org.bukkit.command.CommandSender;
/**
* @author Charles Cullen
* @version 1.0.0
* @since 14-Nov-18
*/
public class BossGiveEggCmd {
public class BossGiveEggCmd extends SubCommand {
public BossGiveEggCmd() {
super("give", "giveegg");
}
@Override
public void execute(CommandSender sender, String[] args) {
}
}

View File

@ -3,15 +3,15 @@ package com.songoda.epicbosses.commands.boss;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.file.ConfigFileHandler;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.NumberUtils;
import com.songoda.epicbosses.utils.Permission;
import com.songoda.epicbosses.utils.*;
import com.songoda.epicbosses.utils.command.SubCommand;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* @author Charles Cullen
@ -43,15 +43,34 @@ public class BossNearbyCmd extends SubCommand {
Player player = (Player) sender;
Location location = player.getLocation();
double radius = this.plugin.getConfig().getDouble("Settings.defaultNearbyRadius", 250.0);
double maxRadius = this.plugin.getConfig().getDouble("Limits.maxNearbyRadius", 500.0);
String nearbyFormat = this.plugin.getConfig().getString("Settings.nearbyFormat", "{name} ({distance}m)");
if(args.length == 2) {
Integer newNumber = NumberUtils.get().getInteger(args[1]);
if(newNumber != null) radius = newNumber;
if(radius > maxRadius) {
Message.Boss_Nearby_MaxRadius.msg(player, maxRadius);
return;
}
}
List<ActiveBossHolder> nearbyBosses = this.plugin.getBossEntityManager().getActiveBossHoldersWithinRadius(radius, location);
Map<ActiveBossHolder, Double> nearbyBosses = this.plugin.getBossEntityManager().getActiveBossHoldersWithinRadius(radius, location);
Map<ActiveBossHolder, Double> sortedMap = MapUtils.get().sortByValue(nearbyBosses);
//TODO Finish
if(sortedMap.isEmpty()) {
Message.Boss_Nearby_NoneNearby.msg(player);
return;
}
List<String> input = new LinkedList<>();
sortedMap.forEach(((activeBossHolder, distance) -> {
input.add(nearbyFormat.replace("{name}", activeBossHolder.getName()).replace("{distance}", NumberUtils.get().formatDouble(distance)));
}));
Message.Boss_Nearby_Near.msg(player, StringUtils.get().appendList(input));
}
}

View File

@ -1,5 +1,7 @@
package com.songoda.epicbosses.commands.boss;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.managers.BossEntityManager;
import com.songoda.epicbosses.utils.IReloadable;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.Permission;
@ -13,12 +15,14 @@ import org.bukkit.command.CommandSender;
*/
public class BossReloadCmd extends SubCommand {
private BossEntityManager bossEntityManager;
private IReloadable masterReloadable;
public BossReloadCmd(IReloadable reloadable) {
public BossReloadCmd(IReloadable reloadable, BossEntityManager bossEntityManager) {
super("reload");
this.masterReloadable = reloadable;
this.bossEntityManager = bossEntityManager;
}
@Override
@ -31,6 +35,7 @@ public class BossReloadCmd extends SubCommand {
long currentMs = System.currentTimeMillis();
this.masterReloadable.reload();
this.bossEntityManager.killAllHolders(null);
Message.Boss_Reload_Successful.msg(sender, (System.currentTimeMillis() - currentMs));
}
}

View File

@ -33,6 +33,7 @@ public class BossCommandManager implements ILoadable {
this.commandService.registerSubCommand(new BossDebugCmd(this.customBosses.getDebugManager()));
this.commandService.registerSubCommand(new BossDropTableCmd(this.customBosses.getBossPanelManager()));
this.commandService.registerSubCommand(new BossEditCmd(this.customBosses.getBossPanelManager()));
this.commandService.registerSubCommand(new BossGiveEggCmd());
this.commandService.registerSubCommand(new BossHelpCmd());
this.commandService.registerSubCommand(new BossInfoCmd(this.customBosses.getBossesFileManager(), this.customBosses.getBossEntityManager()));
this.commandService.registerSubCommand(new BossItemsCmd(this.customBosses.getBossPanelManager()));
@ -40,7 +41,7 @@ public class BossCommandManager implements ILoadable {
this.commandService.registerSubCommand(new BossListCmd(this.customBosses.getBossPanelManager()));
this.commandService.registerSubCommand(new BossMenuCmd(this.customBosses.getBossPanelManager()));
this.commandService.registerSubCommand(new BossNearbyCmd(this.customBosses));
this.commandService.registerSubCommand(new BossReloadCmd(this.customBosses));
this.commandService.registerSubCommand(new BossReloadCmd(this.customBosses, this.customBosses.getBossEntityManager()));
this.commandService.registerSubCommand(new BossShopCmd());
this.commandService.registerSubCommand(new BossSkillsCmd(this.customBosses.getBossPanelManager()));
this.commandService.registerSubCommand(new BossSpawnCmd());

View File

@ -38,6 +38,7 @@ import java.util.stream.Collectors;
public class BossEntityManager {
private static final List<ActiveBossHolder> ACTIVE_BOSS_HOLDERS = new ArrayList<>();
private static final String DEFAULT_BOSS_MENU_ITEM = "DefaultBossMenuItem";
private MinionMechanicManager minionMechanicManager;
private DropTableFileManager dropTableFileManager;
@ -69,18 +70,18 @@ public class BossEntityManager {
return centerLocation.distance(location);
}
public List<ActiveBossHolder> getActiveBossHoldersWithinRadius(double radius, Location centerLocation) {
List<ActiveBossHolder> activeBossHolders = new ArrayList<>();
public Map<ActiveBossHolder, Double> getActiveBossHoldersWithinRadius(double radius, Location centerLocation) {
Map<ActiveBossHolder, Double> distanceMap = new HashMap<>();
getActiveBossHolders().forEach(activeBossHolder -> {
double distance = getRadius(activeBossHolder, centerLocation);
if(distance > radius) return;
activeBossHolders.add(activeBossHolder);
distanceMap.put(activeBossHolder, distance);
});
return activeBossHolders;
return distanceMap;
}
public int getCurrentlyActive(BossEntity bossEntity) {
@ -111,22 +112,43 @@ public class BossEntityManager {
return amountOfBosses;
}
//TODO: Add default item if spawnItem is not set.
public ItemStack getSpawnItem(BossEntity bossEntity) {
public ItemStack getDisplaySpawnItem(BossEntity bossEntity) {
if(bossEntity == null) return null;
if(bossEntity.getSpawnItem() == null) return null;
ItemStackHolder itemStackHolder = BossAPI.getStoredItemStack(bossEntity.getSpawnItem());
String spawnItemName = bossEntity.getSpawnItem() == null? DEFAULT_BOSS_MENU_ITEM : bossEntity.getSpawnItem();
ItemStackHolder itemStackHolder = BossAPI.getStoredItemStack(spawnItemName);
if(itemStackHolder == null) {
Debug.FAILED_TO_LOAD_CUSTOM_ITEM.debug(bossEntity.getSpawnItem());
Debug.FAILED_TO_LOAD_CUSTOM_ITEM.debug(spawnItemName);
return null;
}
ItemStack itemStack = this.bossItemFileManager.getItemStackConverter().from(itemStackHolder);
if(itemStack == null) {
Debug.FAILED_TO_LOAD_CUSTOM_ITEM.debug(bossEntity.getSpawnItem());
Debug.FAILED_TO_LOAD_CUSTOM_ITEM.debug(spawnItemName);
return null;
}
return itemStack;
}
public ItemStack getSpawnItem(BossEntity bossEntity) {
if(bossEntity == null) return null;
if(bossEntity.getSpawnItem() == null) return null;
String spawnItemName = bossEntity.getSpawnItem();
ItemStackHolder itemStackHolder = BossAPI.getStoredItemStack(spawnItemName);
if(itemStackHolder == null) {
Debug.FAILED_TO_LOAD_CUSTOM_ITEM.debug(spawnItemName);
return null;
}
ItemStack itemStack = this.bossItemFileManager.getItemStackConverter().from(itemStackHolder);
if(itemStack == null) {
Debug.FAILED_TO_LOAD_CUSTOM_ITEM.debug(spawnItemName);
return null;
}

View File

@ -45,6 +45,12 @@ public class BossesFileManager implements ILoadable, ISavable, IReloadable {
this.bossesFileHandler.saveFile(this.bossEntityContainer.getData());
}
public void saveBossEntity(String name, BossEntity bossEntity) {
if(this.bossEntityContainer.exists(name)) return;
this.bossEntityContainer.saveData(name, bossEntity);
}
public BossEntity getBossEntity(String name) {
return this.bossEntityContainer.getData().getOrDefault(name, null);
}

View File

@ -1,8 +1,10 @@
package com.songoda.epicbosses.panel;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.utils.panel.Panel;
import com.songoda.epicbosses.utils.panel.base.PanelHandler;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
@ -16,11 +18,26 @@ public class AutoSpawnsPanel extends PanelHandler {
public AutoSpawnsPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
super(bossPanelManager, panelBuilder);
fillPanel();
// fillPanel();
}
// @Override
// public void fillPanel() {
// this.panel.setParentPanel(this.bossPanelManager.getMainMenu().getPanel());
// }
@Override
public void initializePanel(PanelBuilder panelBuilder) {
}
@Override
public void fillPanel() {
this.panel.setParentPanel(this.bossPanelManager.getMainMenu().getPanel());
public void fillPanel(Panel panel) {
}
@Override
public void openFor(Player player) {
}
}

View File

@ -6,10 +6,13 @@ import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.managers.BossEntityManager;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.managers.files.BossesFileManager;
import com.songoda.epicbosses.utils.Debug;
import com.songoda.epicbosses.utils.itemstack.ItemStackUtils;
import com.songoda.epicbosses.utils.panel.Panel;
import com.songoda.epicbosses.utils.panel.base.PanelHandler;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
@ -35,41 +38,56 @@ public class CustomBossesPanel extends PanelHandler {
this.customBosses = customBosses;
this.bossEntityManager = customBosses.getBossEntityManager();
this.bossesFileManager = customBosses.getBossesFileManager();
this.panel.setParentPanel(this.bossPanelManager.getMainMenu().getPanel());
fillPanel();
}
@Override
public void fillPanel() {
public void initializePanel(PanelBuilder panelBuilder) {
}
@Override
public void fillPanel(Panel panel) {
Map<String, BossEntity> currentEntities = new HashMap<>(this.bossesFileManager.getBossEntities());
List<String> entryList = new ArrayList<>(currentEntities.keySet());
int maxPage = this.panel.getMaxPage(entryList);
int maxPage = panel.getMaxPage(entryList);
this.panel.setOnPageChange(((player, currentPage, requestedPage) -> {
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
if(requestedPage < 0 || requestedPage > maxPage) return false;
loadPage(requestedPage, currentEntities, entryList);
loadPage(panel, requestedPage, currentEntities, entryList);
return true;
}));
loadPage(0, currentEntities, entryList);
loadPage(panel, 0, currentEntities, entryList);
}
private void loadPage(int page, Map<String, BossEntity> bossEntityMap, List<String> entryList) {
int fillTo = getPanel().getPanelBuilderSettings().getFillTo();
@Override
public void openFor(Player player) {
Panel panel = getPanelBuilder().getPanel()
.setDestroyWhenDone(true)
.setCancelClick(true)
.setCancelLowerClick(true)
.setParentPanel(this.bossPanelManager.getMainMenu().getPanel());
fillPanel(panel);
panel.openFor(player);
}
private void loadPage(Panel panel, int page, Map<String, BossEntity> bossEntityMap, List<String> entryList) {
int fillTo = panel.getPanelBuilderSettings().getFillTo();
int startIndex = page * fillTo;
for(int i = startIndex; i < startIndex + fillTo; i++) {
if(i >= bossEntityMap.size()) {
getPanel().setItem(i-startIndex, new ItemStack(Material.AIR), e -> {});
panel.setItem(i-startIndex, new ItemStack(Material.AIR), e -> {});
} else {
String name = entryList.get(i);
BossEntity entity = bossEntityMap.get(name);
ItemStack itemStack = this.bossEntityManager.getSpawnItem(entity);
ItemStack itemStack = this.bossEntityManager.getDisplaySpawnItem(entity);
if(itemStack == null) {
getPanel().setItem(i-startIndex, new ItemStack(Material.AIR), e -> {});
panel.setItem(i-startIndex, new ItemStack(Material.AIR), e -> {});
continue;
}
@ -77,16 +95,23 @@ public class CustomBossesPanel extends PanelHandler {
ItemStack clone = itemStack.clone();
replaceMap.put("{name}", name);
replaceMap.put("{enabled}", ""+!entity.isEditing());
replaceMap.put("{enabled}", ""+entity.isEditing());
ItemStackUtils.applyDisplayName(clone, this.customBosses.getConfig().getString("Display.Bosses.name"), replaceMap);
ItemStackUtils.applyDisplayLore(clone, this.customBosses.getConfig().getStringList("Display.Bosses.lore"), replaceMap);
getPanel().setItem(i-startIndex, clone, e -> {
if(e.getClick() == ClickType.LEFT || e.getClick() == ClickType.SHIFT_LEFT) {
panel.setItem(i-startIndex, clone, e -> {
if(e.getClick() == ClickType.RIGHT || e.getClick() == ClickType.SHIFT_RIGHT) {
//TODO
} else if(e.getClick() == ClickType.RIGHT || e.getClick() == ClickType.SHIFT_RIGHT) {
e.getWhoClicked().getInventory().addItem(itemStack.clone());
} else if(e.getClick() == ClickType.LEFT || e.getClick() == ClickType.SHIFT_LEFT) {
ItemStack spawnItem = this.bossEntityManager.getSpawnItem(entity);
if(spawnItem == null) {
Debug.FAILED_TO_GIVE_SPAWN_EGG.debug(e.getWhoClicked().getName(), name);
return;
}
e.getWhoClicked().getInventory().addItem(spawnItem);
}
});
}

View File

@ -1,8 +1,10 @@
package com.songoda.epicbosses.panel;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.utils.panel.Panel;
import com.songoda.epicbosses.utils.panel.base.PanelHandler;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
@ -15,12 +17,20 @@ public class CustomItemsPanel extends PanelHandler {
public CustomItemsPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
super(bossPanelManager, panelBuilder);
fillPanel();
}
@Override
public void fillPanel() {
this.panel.setParentPanel(this.bossPanelManager.getMainMenu().getPanel());
public void initializePanel(PanelBuilder panelBuilder) {
}
@Override
public void fillPanel(Panel panel) {
}
@Override
public void openFor(Player player) {
}
}

View File

@ -1,8 +1,10 @@
package com.songoda.epicbosses.panel;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.utils.panel.Panel;
import com.songoda.epicbosses.utils.panel.base.PanelHandler;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
@ -15,12 +17,20 @@ public class CustomSkillsPanel extends PanelHandler {
public CustomSkillsPanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
super(bossPanelManager, panelBuilder);
fillPanel();
}
@Override
public void fillPanel() {
this.panel.setParentPanel(this.bossPanelManager.getMainMenu().getPanel());
public void initializePanel(PanelBuilder panelBuilder) {
}
@Override
public void fillPanel(Panel panel) {
}
@Override
public void openFor(Player player) {
}
}

View File

@ -1,8 +1,10 @@
package com.songoda.epicbosses.panel;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.utils.panel.Panel;
import com.songoda.epicbosses.utils.panel.base.PanelHandler;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
import org.bukkit.entity.Player;
/**
* @author Charles Cullen
@ -15,12 +17,20 @@ public class DropTablePanel extends PanelHandler {
public DropTablePanel(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
super(bossPanelManager, panelBuilder);
fillPanel();
}
@Override
public void fillPanel() {
this.panel.setParentPanel(this.bossPanelManager.getMainMenu().getPanel());
public void initializePanel(PanelBuilder panelBuilder) {
}
@Override
public void fillPanel(Panel panel) {
}
@Override
public void openFor(Player player) {
}
}

View File

@ -2,6 +2,7 @@ package com.songoda.epicbosses.panel;
import com.songoda.epicbosses.managers.BossPanelManager;
import com.songoda.epicbosses.utils.Message;
import com.songoda.epicbosses.utils.panel.Panel;
import com.songoda.epicbosses.utils.panel.base.ClickAction;
import com.songoda.epicbosses.utils.panel.base.PanelHandler;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
@ -37,6 +38,16 @@ public class MainMenuPanel extends PanelHandler {
.setCancelLowerClick(true);
}
@Override
public void fillPanel(Panel panel) {
}
@Override
public void openFor(Player player) {
this.panel.openFor(player);
}
private ClickAction getBossesAction() {
return event -> {
Player player = (Player) event.getWhoClicked();

View File

@ -37,6 +37,7 @@ public enum Debug {
FAILED_TO_LOAD_MESSAGES("The messages name that is provided ({0}) doesn't exist or wasn't found."),
FAILED_TO_LOAD_COMMANDS("The commands name that is provided ({0}) doesn't exist or wasn't found."),
FAILED_TO_CREATE_ACTIVE_BOSS_HOLDER("Something went wrong while trying to create an active boss holder for someone who is trying to spawn a boss."),
FAILED_TO_GIVE_SPAWN_EGG("{0} tried to obtain a spawn egg for the boss {1} but it has not been set yet."),
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."),

View File

@ -26,10 +26,10 @@ public enum Message {
Boss_Create_NoEntitySpecified("&c&l(!) &cNo entity type was specified. Make sure to add an entity type! Possible entity types are: \n&7{0}"),
Boss_Create_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_Create_SomethingWentWrong("&c&l(!) &cSomething went wrong in the API class while finalising the boss creation."),
Boss_Create_SuccessfullyCreated("&e&lEpicBosses &8» &7A boss has successfully been created with the name &f{0}&7 and the entity type &f{1}&7."),
Boss_Create_SuccessfullyCreated("&b&lEpicBosses &8» &7A boss has successfully been created with the name &f{0}&7 and the entity type &f{1}&7."),
Boss_Debug_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_Debug_Toggled("&e&lEpicBosses &8» &7You have toggled debug mode for &fEpicBosses &7to {0}."),
Boss_Debug_Toggled("&b&lEpicBosses &8» &7You have toggled debug mode for &fEpicBosses &7to {0}."),
Boss_DropTable_NoPermission("&c&l(!) &cYou do not have access to this command."),
@ -38,35 +38,34 @@ public enum Message {
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_Help_Page1(
"&8&m----*--------&6&l[ &e&lBoss Help &7(Page 1) &6&l]&8&m--------*----\n" +
"&e/boss help (page) &8» &7Displays boss commands.\n" +
"&e/boss create [name] [entity] &8» &7Start the creation of a boss.\n" +
"&e/boss edit (name) &8» &7Edit the specified boss.\n" +
"&e/boss info [name] &8» &7Shows information on the specified boss.\n" +
"&e/boss nearby (radius) &8» &7Shows the nearby bosses.\n" +
"&e/boss reload &8» &7Reloads the boss plugin.\n" +
"&e/boss killall (world) &8» &7Kills all bosses/minions." +
"&8&m----*--------&3&l[ &b&lBoss Help &7(Page 1/3) &3&l]&8&m--------*----\n" +
"&b/boss help (page) &8» &7Displays boss commands.\n" +
"&b/boss create [name] [entity] &8» &7Start the creation of a boss.\n" +
"&b/boss edit (name) &8» &7Edit the specified boss.\n" +
"&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." +
"&7\n" +
"&7Use /boss help 2 to view the next page.\n" +
"&8&m----*-----------------------------------*----"),
Boss_Help_Page2(
"&8&m----*--------&6&l[ &e&lBoss Help &7(Page 2) &6&l]&8&m--------*----\n" +
"&e/boss spawn [name] (location) &8» &7Spawns a boss at your location or the specified location.\n" +
"&8&m----*--------&3&l[ &b&lBoss Help &7(Page 2/3) &3&l]&8&m--------*----\n" +
"&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" +
"&e/boss time (section) &8» &7Shows the time left till next auto spawn.\n" +
"&e/boss droptable &8» &7Shows all current drop tables.\n" +
"&e/boss items &8» &7Shows all current custom items.\n" +
"&e/boss skills &8» &7Shows all current set skills.\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" +
"&7\n" +
"&8&m----*-----------------------------------*----"),
Boss_Help_Page3(
"&8&m----*--------&6&l[ &e&lBoss Help &7(Page 3) &6&l]&8&m--------*----\n" +
"&e/boss debug &8» &7Used to toggle the debug aspect of the plugin.\n" +
"&e/boss giveegg [name] [name] &8» &7Used to be given a spawn item of the boss.\n" +
"&e/boss list &8» &7Shows all the list of current boss entities.\n" +
"&e/boss nearby (radius) &8» &7Shows all nearby bosses.\n" +
"&e\n" +
"&e\n" +
"&8&m----*--------&3&l[ &b&lBoss Help &7(Page 3/3) &3&l]&8&m--------*----\n" +
"&b/boss debug &8» &7Used to toggle the debug aspect of the plugin.\n" +
"&b/boss giveegg [name] [player] &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" +
"&b\n" +
"&b\n" +
"&7\n" +
"&8&m----*-----------------------------------*----"),
@ -74,16 +73,16 @@ public enum Message {
Boss_Info_InvalidArgs("&c&l(!) &cYou must use &n/boss info [name]&c to view info on a boss."),
Boss_Info_CouldntFindBoss("&c&l(!) &cThe specified boss was not able to be retrieved, please try again."),
Boss_Info_Display(
"&8&m----*--------&6&l[ &e&l{0} Info &6&l]&8&m--------*----\n" +
"&6&lEditing: &f{1}\n" +
"&6&lCurrently Active: &f{2}\n" +
"&6&lComplete enough to spawn: &f{3}"),
"&8&m----*--------&3&l[ &b&l{0} Info &3&l]&8&m--------*----\n" +
"&bEditing: &f{1}\n" +
"&bCurrently Active: &f{2}\n" +
"&bComplete enough to spawn: &f{3}"),
Boss_Items_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_KillAll_WorldNotFound("&c&l(!) &cThe specified world was not found. If you'd like to kill every boss/minion just use &f/boss killall&c without any arguments."),
Boss_KillAll_KilledAll("&e&lEpicBosses &8» &7You have killed {0} boss(es) and minions that were currently active on the server."),
Boss_KillAll_KilledWorld("&e&lEpicBosses &8» &7You have killed {0} boss(es) and minions that were in the world {1}."),
Boss_KillAll_KilledAll("&b&lEpicBosses &8» &7You have killed {0} boss(es) and minions that were currently active on the server."),
Boss_KillAll_KilledWorld("&b&lEpicBosses &8» &7You have killed {0} boss(es) and minions that were in the world {1}."),
Boss_KillAll_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_List_NoPermission("&c&l(!) &cYou do not have access to this command."),
@ -91,9 +90,12 @@ public enum Message {
Boss_Menu_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_Nearby_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_Nearby_MaxRadius("&c&l(!) &cYou cannot check for bosses any further then &f{0}&c away from your position."),
Boss_Nearby_NoneNearby("&b&lEpicBosses &8» &7There is currently no nearby bosses."),
Boss_Nearby_Near("&b&lEpicBosses &8» &7Nearby bosses: &f{0}."),
Boss_Reload_NoPermission("&c&l(!) &cYou do not have access to this command."),
Boss_Reload_Successful("&e&lEpicBosses &8» &7All boss data has been reloaded. The process took &f{0}ms&7."),
Boss_Reload_Successful("&b&lEpicBosses &8» &7All boss data has been reloaded. The process took &f{0}ms&7."),
Boss_Skills_NoPermission("&c&l(!) &cYou do not have access to this command.");

View File

@ -1,5 +1,6 @@
package com.songoda.epicbosses.utils.panel;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
import lombok.Getter;
import com.songoda.epicbosses.utils.ICloneable;
import com.songoda.epicbosses.utils.StringUtils;
@ -49,6 +50,7 @@ public class Panel implements Listener, ICloneable<Panel> {
//--------------------------------------------------
private final Map<Integer, ClickAction> targettedSlotActions = new HashMap<>();
private final List<Inventory> connectedInventories = new ArrayList<>();
private final List<ClickAction> allSlotActions = new ArrayList<>();
private final Map<UUID, Integer> currentPageContainer = new HashMap<>();
@ -84,6 +86,7 @@ public class Panel implements Listener, ICloneable<Panel> {
}
this.inventory = size % 9 == 0 ? Bukkit.createInventory(null, size, StringUtils.get().translateColor(title)) : Bukkit.createInventory(null, InventoryType.HOPPER, StringUtils.get().translateColor(title));
this.connectedInventories.add(this.inventory);
PANELS.add(this);
}
@ -111,6 +114,7 @@ public class Panel implements Listener, ICloneable<Panel> {
fillEmptySpace();
this.connectedInventories.add(this.inventory);
PANELS.add(this);
}
@ -126,7 +130,6 @@ public class Panel implements Listener, ICloneable<Panel> {
if(!getInventory().equals(event.getInventory())) return;
Player player = (Player) event.getWhoClicked();
Inventory inventory = event.getInventory();
if((!isCancelClick()) && (event.getRawSlot() > inventory.getSize())) {
event.setCancelled(true);
@ -361,6 +364,22 @@ public class Panel implements Listener, ICloneable<Panel> {
return this;
}
public Panel setParentPanel(PanelBuilder panelBuilder, boolean cancelClick, boolean destroyWhenDone, boolean cancelLowerClick) {
if(!this.panelBuilderSettings.isBackButton()) return this;
int slot = this.panelBuilderSettings.getBackButtonSlot() - 1;
setOnClick(slot, event -> {
Panel panel = panelBuilder.getPanel()
.setCancelClick(cancelClick)
.setDestroyWhenDone(destroyWhenDone)
.setCancelLowerClick(cancelLowerClick);
panel.openFor((Player) event.getWhoClicked());
});
return this;
}
public Panel setExitButton() {
if(!this.panelBuilderSettings.isExitButton()) return this;
@ -427,6 +446,23 @@ public class Panel implements Listener, ICloneable<Panel> {
}
}
public Inventory cloneInventory() {
Inventory thisInventory = getInventory();
Inventory newInventory = Bukkit.createInventory(thisInventory.getHolder(), thisInventory.getSize(), thisInventory.getTitle());
for(int i = 0; i < thisInventory.getSize(); i++) {
ItemStack itemStack = thisInventory.getItem(i);
if(itemStack == null) continue;
newInventory.setItem(i, itemStack);
}
this.connectedInventories.add(newInventory);
return newInventory;
}
@Override
public Panel clone() {
Panel panel = new Panel(this.inventory.getTitle(), this.inventory.getSize());

View File

@ -11,11 +11,13 @@ import org.bukkit.entity.Player;
*/
public interface IPanelHandler {
PanelBuilder getPanelBuilder();
Panel getPanel();
void initializePanel(PanelBuilder panelBuilder);
void fillPanel();
void fillPanel(Panel panel);
void openFor(Player player);

View File

@ -11,34 +11,17 @@ import org.bukkit.entity.Player;
* @version 1.0.0
* @since 10-Oct-18
*/
public class PanelHandler implements IPanelHandler {
public abstract class PanelHandler implements IPanelHandler {
protected final BossPanelManager bossPanelManager;
@Getter protected Panel panel;
@Getter private PanelBuilder panelBuilder;
@Getter protected Panel panel = null;
public PanelHandler(BossPanelManager bossPanelManager, PanelBuilder panelBuilder) {
this.bossPanelManager = bossPanelManager;
this.panelBuilder = panelBuilder;
initializePanel(panelBuilder);
}
@Override
public void initializePanel(PanelBuilder panelBuilder) {
this.panel = panelBuilder.getPanel()
.setDestroyWhenDone(false)
.setCancelClick(true)
.setCancelLowerClick(true);
}
@Override
public void fillPanel() {
}
@Override
public void openFor(Player player) {
System.out.println(this.panel);
this.panel.openFor(player);
}
}

View File

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