mirror of
https://github.com/songoda/EpicBosses.git
synced 2025-03-12 14:39:05 +01:00
1.0.6
+ Fixed issue where AutoSpawn sections wouldn't spawn on custom location + Fixed issue where when u do /boss killall it doesn't update the auto spawns so they can no longer spawn + Fixed the auto spawn message not disabling the default boss spawn messages when set to true + Added more debug to explain to people why an AutoSpawn won't work (Remember you can go in the config.yml and set debug: false to disable debug messages) + Added Ticks to the TimeUnit conversion class
This commit is contained in:
parent
8a71c487f7
commit
73c7e89017
@ -4,10 +4,10 @@
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/milkbowl/vault/Vault/1.6.6/Vault-1.6.6.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/milkbowl/vault/Vault/1.6.6/Vault-1.6.6-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/milkbowl/vault/vault/1.6.6/vault-1.6.6-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/milkbowl/vault/Vault/1.6.6/Vault-1.6.6-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/milkbowl/vault/vault/1.6.6/vault-1.6.6-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -12,10 +12,7 @@ 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.*;
|
||||
import com.songoda.epicbosses.utils.panel.base.ClickAction;
|
||||
import com.songoda.epicbosses.utils.panel.base.handlers.VariablePanelHandler;
|
||||
import lombok.Getter;
|
||||
@ -74,7 +71,10 @@ public class IntervalSpawnElement implements IAutoSpawnCustomSettingsHandler {
|
||||
List<String> bosses = autoSpawn.getEntities();
|
||||
Location location = getSpawnLocation();
|
||||
|
||||
if(bosses == null || bosses.isEmpty()) return false;
|
||||
if(bosses == null || bosses.isEmpty()) {
|
||||
ServerUtils.get().logDebug("BOSSES IS EMPTY!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(shuffleList) Collections.shuffle(bosses);
|
||||
|
||||
|
@ -32,4 +32,8 @@ public class ActiveAutoSpawnHolder {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.activeBossHolders.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import com.songoda.epicbosses.utils.Debug;
|
||||
import com.songoda.epicbosses.utils.ObjectUtils;
|
||||
import com.songoda.epicbosses.utils.ServerUtils;
|
||||
import com.songoda.epicbosses.utils.time.TimeUnit;
|
||||
import com.songoda.epicbosses.utils.time.TimeUtil;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -39,8 +40,14 @@ public class ActiveIntervalAutoSpawnHolder extends ActiveAutoSpawnHolder {
|
||||
|
||||
@Override
|
||||
public boolean canSpawn() {
|
||||
if(getAutoSpawn().isEditing()) return false;
|
||||
if(!getAutoSpawn().getType().equalsIgnoreCase("INTERVAL")) return false;
|
||||
if(getAutoSpawn().isEditing()) {
|
||||
ServerUtils.get().logDebug("AutoSpawn failed to spawn due to editing enabled.");
|
||||
return false;
|
||||
}
|
||||
if(!getAutoSpawn().getType().equalsIgnoreCase("INTERVAL")) {
|
||||
ServerUtils.get().logDebug("AutoSpawn failed to spawn due to interval type not set.");
|
||||
return false;
|
||||
}
|
||||
|
||||
int currentActiveAmount = getCurrentActiveBossHolders();
|
||||
int maxAmount = getAutoSpawn().getAutoSpawnSettings().getMaxAliveAtOnce();
|
||||
@ -48,11 +55,26 @@ public class ActiveIntervalAutoSpawnHolder extends ActiveAutoSpawnHolder {
|
||||
Location location = this.intervalSpawnElement.getSpawnLocation();
|
||||
boolean spawnIfChunkNotLoaded = ObjectUtils.getValue(getAutoSpawn().getAutoSpawnSettings().getSpawnWhenChunkIsntLoaded(), false);
|
||||
|
||||
if(location == null) return false;
|
||||
if(!spawnIfChunkNotLoaded && !location.getChunk().isLoaded()) return false;
|
||||
if(isSpawnAfterLastBossIsKilled() && !getActiveBossHolders().isEmpty()) return false;
|
||||
if(location == null) {
|
||||
ServerUtils.get().logDebug("AutoSpawn failed to spawn due to location is null.");
|
||||
return false;
|
||||
}
|
||||
if(!spawnIfChunkNotLoaded && !location.getChunk().isLoaded()) {
|
||||
ServerUtils.get().logDebug("AutoSpawn failed to spawn due to spawnIfChunkNotLoaded was false and chunk wasn't loaded.");
|
||||
return false;
|
||||
}
|
||||
if(isSpawnAfterLastBossIsKilled() && !getActiveBossHolders().isEmpty()) {
|
||||
ServerUtils.get().logDebug("AutoSpawn failed due to spawnAfterLastBossKilled is true and activeBossHolders is not empty.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return currentActiveAmount < maxAmount;
|
||||
boolean returnStatement = currentActiveAmount < maxAmount;
|
||||
|
||||
if(!returnStatement) {
|
||||
ServerUtils.get().logDebug("AutoSpawn failed to spawn due to currentActiveAmount is greater then maxAmount of bosses.");
|
||||
}
|
||||
|
||||
return returnStatement;
|
||||
}
|
||||
|
||||
public boolean isSpawnAfterLastBossIsKilled() {
|
||||
@ -71,24 +93,36 @@ public class ActiveIntervalAutoSpawnHolder extends ActiveAutoSpawnHolder {
|
||||
return;
|
||||
}
|
||||
|
||||
int delaySec = (int) TimeUnit.MINUTES.to(TimeUnit.SECONDS, delay);
|
||||
int seconds = 10;
|
||||
|
||||
this.intervalTask = ServerUtils.get().runTimer(delaySec*20, delaySec*20, () -> {
|
||||
boolean canSpawn = canSpawn();
|
||||
ServerUtils.get().runLater((int) TimeUnit.SECONDS.to(TimeUnit.TICK, seconds), () -> {
|
||||
long delayTick = (long) TimeUnit.MINUTES.to(TimeUnit.TICK, delay);
|
||||
|
||||
if(!canSpawn) return;
|
||||
this.intervalTask = ServerUtils.get().runTimer(delayTick, delayTick, () -> {
|
||||
boolean canSpawn = canSpawn();
|
||||
|
||||
this.intervalSpawnElement.attemptSpawn(this);
|
||||
if(!canSpawn) {
|
||||
ServerUtils.get().logDebug("--- Failed to AutoSpawn. ---");
|
||||
updateNextCompleteTime();
|
||||
return;
|
||||
}
|
||||
|
||||
if(isSpawnAfterLastBossIsKilled()) {
|
||||
cancelCurrentInterval();
|
||||
return;
|
||||
}
|
||||
ServerUtils.get().logDebug("AutoSpawn Spawn Attempt: " + this.intervalSpawnElement.attemptSpawn(this));
|
||||
|
||||
if(isSpawnAfterLastBossIsKilled()) {
|
||||
cancelCurrentInterval();
|
||||
return;
|
||||
}
|
||||
|
||||
updateNextCompleteTime();
|
||||
});
|
||||
|
||||
ServerUtils.get().logDebug("Task delay: " + TimeUtil.getFormattedTime(TimeUnit.MINUTES, delay));
|
||||
|
||||
updateNextCompleteTime();
|
||||
});
|
||||
|
||||
updateNextCompleteTime();
|
||||
ServerUtils.get().logDebug("Static Delay: " + TimeUtil.getFormattedTime(TimeUnit.MILLISECONDS, (int) getRemainingMs()));
|
||||
});
|
||||
}
|
||||
|
||||
public void stopInterval() {
|
||||
|
@ -131,7 +131,7 @@ public class BossSpawnListener implements Listener {
|
||||
if(commands != null) {
|
||||
commands.forEach(serverUtils::sendConsoleCommand);
|
||||
}
|
||||
if(messages != null) {
|
||||
if(messages != null && !activeBossHolder.isCustomSpawnMessage()) {
|
||||
if(activeBossHolder.getName() != null) messages.replaceAll(s -> s.replace("{boss}", activeBossHolder.getName()));
|
||||
messages.replaceAll(s -> s.replace("{location}", StringUtils.get().translateLocation(location)));
|
||||
|
||||
|
@ -47,6 +47,10 @@ public class AutoSpawnManager {
|
||||
autoSpawnHolderMap.forEach((name, autoSpawnHolder) -> removeActiveAutoSpawnHolder(name));
|
||||
}
|
||||
|
||||
public void clearAutoSpawns() {
|
||||
this.activeAutoSpawnHolders.values().forEach(ActiveAutoSpawnHolder::clear);
|
||||
}
|
||||
|
||||
public List<String> getIntervalAutoSpawns() {
|
||||
Map<String, ActiveAutoSpawnHolder> autoSpawnHolderMap = new HashMap<>(this.activeAutoSpawnHolders);
|
||||
List<String> intervalAutoSpawns = new ArrayList<>();
|
||||
|
@ -114,6 +114,8 @@ public class BossEntityManager {
|
||||
}
|
||||
}
|
||||
|
||||
CustomBosses.get().getAutoSpawnManager().clearAutoSpawns();
|
||||
|
||||
return amountOfBosses;
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Charles Cullen
|
||||
@ -56,19 +53,30 @@ public class StringUtils {
|
||||
if(input == null) return null;
|
||||
|
||||
String[] split = input.split(",");
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
if(split.length != 4) return null;
|
||||
|
||||
String worldInput = split[0];
|
||||
String xInput = split[1];
|
||||
String yInput = split[2];
|
||||
String zInput = split[3];
|
||||
World world = Bukkit.getWorld(worldInput);
|
||||
|
||||
if(NumberUtils.get().isInt(xInput) && NumberUtils.get().isInt(yInput) && NumberUtils.get().isInt(zInput)) {
|
||||
return new Location(world, Integer.valueOf(xInput), Integer.valueOf(yInput), Integer.valueOf(zInput));
|
||||
for(String s : split) {
|
||||
stringBuilder.append("|").append(s).append(",");
|
||||
}
|
||||
|
||||
ServerUtils.get().logDebug(stringBuilder.toString());
|
||||
|
||||
try {
|
||||
String worldInput = split[0].trim();
|
||||
String xInput = split[1].trim();
|
||||
String yInput = split[2].trim();
|
||||
String zInput = split[3].trim();
|
||||
World world = Bukkit.getWorld(worldInput);
|
||||
|
||||
if(NumberUtils.get().isInt(xInput) && NumberUtils.get().isInt(yInput) && NumberUtils.get().isInt(zInput)) {
|
||||
return new Location(world, Integer.valueOf(xInput), Integer.valueOf(yInput), Integer.valueOf(zInput));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ServerUtils.get().logDebug("Exception caught in location making, returning null");
|
||||
return null;
|
||||
}
|
||||
|
||||
ServerUtils.get().logDebug("X, Y or Z is not number, returning null");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ public enum TimeUnit {
|
||||
HOURS(3600),
|
||||
MINUTES(60),
|
||||
SECONDS(1),
|
||||
TICK(0.05),
|
||||
MILLISECONDS(0.001);
|
||||
|
||||
private double seconds;
|
||||
|
Loading…
Reference in New Issue
Block a user