1.0.0-SNAPSHOT-U193

+ Fixed issue of AutoSpawnsPanel not listing the AutoSpawns
+ Fixed issue of AutoSpawnSpecialSettings not displaying FIREWORK_CHARGE
+ Fixed issue of AutoSpawnType not display MOB_SPAWNER
+ Fixed issue with inverted editing mode
+ Fixed issue with the AutoSpawn list displaying an inverted editing mode
+ Fixed entities not display auto spawn name
+ Fixed issue with IntervalSpawnElement not working on canSpawn
+ Fixed issue with IntervalSpawnElement#getCustomSettingActions not connecting to IntervalSpawnHandler properly
+ Fixed issue with IntervalSpawnElement SpawnRate not updating in the GUI
This commit is contained in:
Charles 2019-01-09 01:53:14 +08:00
parent e316816c33
commit 0dc48bf1ea
9 changed files with 81 additions and 68 deletions

View File

@ -2571,7 +2571,7 @@ MainAutoSpawnEditMenu:
- '&7This will disable the auto spawn until'
- '&7it is enabled again.'
- '&7'
- '&bCurrently Running: &f{editing}'
- '&bCurrently Disabled for Editing: &f{editing}'
Button: Editing
'7':
type: PAPER
@ -2720,7 +2720,7 @@ AutoSpawnSpecialSettingsEditMenu:
- '&bRight Click &8» &f-1'
Button: MaxAliveEntities
'3':
type: FIREWORK_CHARGE
type: FIREWORK_STAR
name: '&e&lAmount of Bosses Per Spawn'
lore:
- '&bCurrently: &f{amountPerSpawn}'
@ -2816,7 +2816,7 @@ AutoSpawnTypeEditMenu:
- '&c&lComing soon...'
Button: BiomeSystem
'5':
type: MOB_SPAWNER
type: SPAWNER
name: '&e&lMob Spawner Spawn System'
lore:
- '&7Select this spawn system if you want to make'

View File

@ -29,53 +29,6 @@ import java.util.*;
*/
public class IntervalSpawnHandler {
public boolean attemptSpawn(ActiveIntervalAutoSpawnHolder activeAutoSpawnHolder, IntervalSpawnElement intervalSpawnElement) {
IBossDeathHandler bossDeathHandler = activeAutoSpawnHolder.getPostDeathHandler();
AutoSpawn autoSpawn = activeAutoSpawnHolder.getAutoSpawn();
AutoSpawnSettings autoSpawnSettings = autoSpawn.getAutoSpawnSettings();
boolean customSpawnMessage = ObjectUtils.getValue(autoSpawnSettings.getOverrideDefaultSpawnMessage(), false);
String spawnMessage = autoSpawnSettings.getSpawnMessage();
int amountToSpawn = ObjectUtils.getValue(autoSpawnSettings.getAmountPerSpawn(), 1);
boolean shuffleList = ObjectUtils.getValue(autoSpawnSettings.getShuffleEntitiesList(), false);
List<String> bosses = autoSpawn.getEntities();
Location location = intervalSpawnElement.getSpawnLocation();
if(bosses == null || bosses.isEmpty()) return false;
if(shuffleList) Collections.shuffle(bosses);
Queue<String> queue = new LinkedList<>(bosses);
for(int i = 1; i <= amountToSpawn; i++) {
if(queue.isEmpty()) queue = new LinkedList<>(bosses);
BossEntity bossEntity = BossAPI.getBossEntity(queue.poll());
ActiveBossHolder activeBossHolder = BossAPI.spawnNewBoss(bossEntity, location, null, null, customSpawnMessage);
if(activeBossHolder == null) continue;
activeBossHolder.getPostBossDeathHandlers().add(bossDeathHandler);
activeAutoSpawnHolder.getActiveBossHolders().add(activeBossHolder);
}
if(customSpawnMessage && spawnMessage != null) {
String x = NumberUtils.get().formatDouble(location.getBlockX());
String y = NumberUtils.get().formatDouble(location.getBlockY());
String z = NumberUtils.get().formatDouble(location.getBlockZ());
String world = StringUtils.get().formatString(location.getWorld().getName());
List<String> spawnMessages = BossAPI.getStoredMessages(spawnMessage);
if(spawnMessages != null) {
spawnMessages.replaceAll(s -> s.replace("{x}", x).replace("{y}", y).replace("{z}", z).replace("{world}", world));
MessageUtils.get().sendMessage(location, -1, spawnMessages);
}
}
return true;
}
public ClickAction getSpawnAfterLastBossIsKilledAction(IntervalSpawnElement intervalSpawnElement, AutoSpawn autoSpawn, VariablePanelHandler<AutoSpawn> panelHandler) {
return event -> {
Player player = (Player) event.getWhoClicked();
@ -122,7 +75,7 @@ public class IntervalSpawnHandler {
return Arrays.asList("&7Click here to modify the placeholder", "&7that is used to display the timer for this", "&7auto spawn section in a hologram or", "&7through PlaceholderAPI.");
}
public ClickAction getSpawnRateAction(IntervalSpawnElement intervalSpawnElement, AutoSpawn autoSpawn) {
public ClickAction getSpawnRateAction(IntervalSpawnElement intervalSpawnElement, AutoSpawn autoSpawn, VariablePanelHandler<AutoSpawn> panelHandler) {
return event -> {
ClickType clickType = event.getClick();
int amountToModifyBy;
@ -160,6 +113,7 @@ public class IntervalSpawnHandler {
autoSpawn.setCustomData(jsonObject);
CustomBosses.get().getAutoSpawnFileManager().save();
Message.Boss_AutoSpawn_SpawnRate.msg(event.getWhoClicked(), modifyValue, NumberUtils.get().formatDouble(newAmount));
panelHandler.openFor((Player) event.getWhoClicked(), autoSpawn);
};
}

View File

@ -1,12 +1,20 @@
package com.songoda.epicbosses.autospawns.types;
import com.google.gson.annotations.Expose;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.autospawns.AutoSpawn;
import com.songoda.epicbosses.autospawns.IAutoSpawnCustomSettingsHandler;
import com.songoda.epicbosses.autospawns.handlers.IntervalSpawnHandler;
import com.songoda.epicbosses.autospawns.settings.AutoSpawnSettings;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.holder.ActiveBossHolder;
import com.songoda.epicbosses.holder.autospawn.ActiveIntervalAutoSpawnHolder;
import com.songoda.epicbosses.listeners.IBossDeathHandler;
import com.songoda.epicbosses.managers.AutoSpawnManager;
import com.songoda.epicbosses.skills.interfaces.ICustomSettingAction;
import com.songoda.epicbosses.utils.MessageUtils;
import com.songoda.epicbosses.utils.NumberUtils;
import com.songoda.epicbosses.utils.ObjectUtils;
import com.songoda.epicbosses.utils.StringUtils;
import com.songoda.epicbosses.utils.panel.base.ClickAction;
import com.songoda.epicbosses.utils.panel.base.handlers.VariablePanelHandler;
@ -25,8 +33,6 @@ import java.util.*;
*/
public class IntervalSpawnElement implements IAutoSpawnCustomSettingsHandler {
private final IntervalSpawnHandler intervalSpawnHandler = new IntervalSpawnHandler();
@Expose @Getter @Setter private Boolean spawnAfterLastBossIsKilled;
@Expose @Getter @Setter private String location, placeholder;
@Expose @Getter @Setter private Integer spawnRate;
@ -42,21 +48,66 @@ public class IntervalSpawnElement implements IAutoSpawnCustomSettingsHandler {
public List<ICustomSettingAction> getCustomSettingActions(AutoSpawn autoSpawn, VariablePanelHandler<AutoSpawn> variablePanelHandler) {
List<ICustomSettingAction> clickActions = new ArrayList<>();
ItemStack clickStack = new ItemStack(Material.IRON_BLOCK);
ClickAction lastBossKilledAction = this.intervalSpawnHandler.getSpawnAfterLastBossIsKilledAction(this, autoSpawn, variablePanelHandler);
ClickAction locationAction = this.intervalSpawnHandler.getLocationAction(this, autoSpawn, variablePanelHandler);
ClickAction placeholderAction = this.intervalSpawnHandler.getPlaceholderAction(this, autoSpawn, variablePanelHandler);
ClickAction spawnRateAction = this.intervalSpawnHandler.getSpawnRateAction(this, autoSpawn);
IntervalSpawnHandler intervalSpawnHandler = new IntervalSpawnHandler();
clickActions.add(AutoSpawnManager.createAutoSpawnAction("Spawn After Last Boss Is Killed", getSpawnAfterLastBossIsKilled()+"", this.intervalSpawnHandler.getSpawnAfterLastBossIsKilledExtraInformation(), clickStack.clone(), lastBossKilledAction));
clickActions.add(AutoSpawnManager.createAutoSpawnAction("Location", getLocation(), this.intervalSpawnHandler.getLocationExtraInformation(), clickStack.clone(), locationAction));
clickActions.add(AutoSpawnManager.createAutoSpawnAction("Placeholder", getPlaceholder(), this.intervalSpawnHandler.getPlaceholderExtraInformation(), clickStack.clone(), placeholderAction));
clickActions.add(AutoSpawnManager.createAutoSpawnAction("Spawn Rate", getSpawnRate()+"", this.intervalSpawnHandler.getSpawnRateExtraInformation(), clickStack.clone(), spawnRateAction));
ClickAction lastBossKilledAction = intervalSpawnHandler.getSpawnAfterLastBossIsKilledAction(this, autoSpawn, variablePanelHandler);
ClickAction locationAction = intervalSpawnHandler.getLocationAction(this, autoSpawn, variablePanelHandler);
ClickAction placeholderAction = intervalSpawnHandler.getPlaceholderAction(this, autoSpawn, variablePanelHandler);
ClickAction spawnRateAction = intervalSpawnHandler.getSpawnRateAction(this, autoSpawn, variablePanelHandler);
clickActions.add(AutoSpawnManager.createAutoSpawnAction("Spawn After Last Boss Is Killed", getSpawnAfterLastBossIsKilled()+"", intervalSpawnHandler.getSpawnAfterLastBossIsKilledExtraInformation(), clickStack.clone(), lastBossKilledAction));
clickActions.add(AutoSpawnManager.createAutoSpawnAction("Location", getLocation(), intervalSpawnHandler.getLocationExtraInformation(), clickStack.clone(), locationAction));
clickActions.add(AutoSpawnManager.createAutoSpawnAction("Placeholder", getPlaceholder(), intervalSpawnHandler.getPlaceholderExtraInformation(), clickStack.clone(), placeholderAction));
clickActions.add(AutoSpawnManager.createAutoSpawnAction("Spawn Rate", getSpawnRate()+"", intervalSpawnHandler.getSpawnRateExtraInformation(), clickStack.clone(), spawnRateAction));
return clickActions;
}
public boolean attemptSpawn(ActiveIntervalAutoSpawnHolder activeAutoSpawnHolder) {
return this.intervalSpawnHandler.attemptSpawn(activeAutoSpawnHolder, this);
IBossDeathHandler bossDeathHandler = activeAutoSpawnHolder.getPostDeathHandler();
AutoSpawn autoSpawn = activeAutoSpawnHolder.getAutoSpawn();
AutoSpawnSettings autoSpawnSettings = autoSpawn.getAutoSpawnSettings();
boolean customSpawnMessage = ObjectUtils.getValue(autoSpawnSettings.getOverrideDefaultSpawnMessage(), false);
String spawnMessage = autoSpawnSettings.getSpawnMessage();
int amountToSpawn = ObjectUtils.getValue(autoSpawnSettings.getAmountPerSpawn(), 1);
boolean shuffleList = ObjectUtils.getValue(autoSpawnSettings.getShuffleEntitiesList(), false);
List<String> bosses = autoSpawn.getEntities();
Location location = getSpawnLocation();
if(bosses == null || bosses.isEmpty()) return false;
if(shuffleList) Collections.shuffle(bosses);
Queue<String> queue = new LinkedList<>(bosses);
for(int i = 1; i <= amountToSpawn; i++) {
if(queue.isEmpty()) queue = new LinkedList<>(bosses);
BossEntity bossEntity = BossAPI.getBossEntity(queue.poll());
ActiveBossHolder activeBossHolder = BossAPI.spawnNewBoss(bossEntity, location, null, null, customSpawnMessage);
if(activeBossHolder == null) continue;
activeBossHolder.getPostBossDeathHandlers().add(bossDeathHandler);
activeAutoSpawnHolder.getActiveBossHolders().add(activeBossHolder);
}
if(customSpawnMessage && spawnMessage != null) {
String x = NumberUtils.get().formatDouble(location.getBlockX());
String y = NumberUtils.get().formatDouble(location.getBlockY());
String z = NumberUtils.get().formatDouble(location.getBlockZ());
String world = StringUtils.get().formatString(location.getWorld().getName());
List<String> spawnMessages = BossAPI.getStoredMessages(spawnMessage);
if(spawnMessages != null) {
spawnMessages.replaceAll(s -> s.replace("{x}", x).replace("{y}", y).replace("{z}", z).replace("{world}", world));
MessageUtils.get().sendMessage(location, -1, spawnMessages);
}
}
return true;
}
public Location getSpawnLocation() {

View File

@ -76,6 +76,7 @@ import com.songoda.epicbosses.utils.IReloadable;
import com.songoda.epicbosses.utils.StringUtils;
import com.songoda.epicbosses.utils.panel.base.IPanelHandler;
import com.songoda.epicbosses.utils.panel.builder.PanelBuilder;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.Collection;

View File

@ -40,7 +40,7 @@ public class AutoSpawnsPanel extends MainListPanelHandler {
@Override
public void fillPanel(Panel panel) {
Map<String, AutoSpawn> autoSpawnMap = this.autoSpawnFileManager.getAutoSpawnMap();
List<String> entryList = new ArrayList<>();
List<String> entryList = new ArrayList<>(autoSpawnMap.keySet());
int maxPage = panel.getMaxPage(entryList);
panel.setOnPageChange(((player, currentPage, requestedPage) -> {
@ -79,7 +79,7 @@ public class AutoSpawnsPanel extends MainListPanelHandler {
replaceMap.put("{name}", name);
replaceMap.put("{type}", StringUtils.get().formatString(autoSpawn.getType()));
replaceMap.put("{enabled}", (!autoSpawn.isLocked())+"");
replaceMap.put("{enabled}", (autoSpawn.isEditing())+"");
replaceMap.put("{entities}", entitiesSize);
replaceMap.put("{maxAlive}", maxAlive);
replaceMap.put("{amountPerSpawn}", amountToSpawn);

View File

@ -89,7 +89,7 @@ public class AutoSpawnCustomSettingsEditorPanel extends VariablePanelHandler<Aut
Map<String, String> replaceMap = new HashMap<>();
replaceMap.put("{setting}", name);
replaceMap.put("{name}", name);
replaceMap.put("{currently}", currently);
if(displayStack == null || displayStack.getType() == Material.AIR) return;

View File

@ -1,6 +1,7 @@
package com.songoda.epicbosses.panel.autospawns;
import com.songoda.epicbosses.CustomBosses;
import com.songoda.epicbosses.api.BossAPI;
import com.songoda.epicbosses.autospawns.AutoSpawn;
import com.songoda.epicbosses.entity.BossEntity;
import com.songoda.epicbosses.managers.BossPanelManager;
@ -62,7 +63,13 @@ public class AutoSpawnEntitiesEditorPanel extends VariablePanelHandler<AutoSpawn
@Override
public void openFor(Player player, AutoSpawn autoSpawn) {
Panel panel = getPanelBuilder().getPanel()
Map<String, String> replaceMap = new HashMap<>();
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();
replaceMap.put("{name}", BossAPI.getAutoSpawnName(autoSpawn));
panelBuilder.addReplaceData(replaceMap);
Panel panel = panelBuilder.getPanel()
.setParentPanelHandler(this.bossPanelManager.getMainAutoSpawnEditPanel(), autoSpawn);
fillPanel(panel, autoSpawn);

View File

@ -48,7 +48,7 @@ public class MainAutoSpawnEditorPanel extends VariablePanelHandler<AutoSpawn> {
public void openFor(Player player, AutoSpawn autoSpawn) {
Map<String, String> replaceMap = new HashMap<>();
String type = ObjectUtils.getValue(autoSpawn.getType(), "INTERVAL");
String editing = ""+ObjectUtils.getValue(!autoSpawn.isLocked(), false);
String editing = ""+ObjectUtils.getValue(autoSpawn.isEditing(), false);
String entities = StringUtils.get().appendList(autoSpawn.getEntities());
PanelBuilder panelBuilder = getPanelBuilder().cloneBuilder();

View File

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