+ 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:
Charles 2019-02-01 21:04:23 +08:00
parent 8a71c487f7
commit 73c7e89017
10 changed files with 93 additions and 40 deletions

View File

@ -4,10 +4,10 @@
<root url="jar://$MAVEN_REPOSITORY$/net/milkbowl/vault/Vault/1.6.6/Vault-1.6.6.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/net/milkbowl/vault/Vault/1.6.6/Vault-1.6.6.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC> <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> </JAVADOC>
<SOURCES> <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> </SOURCES>
</library> </library>
</component> </component>

View File

@ -12,10 +12,7 @@ import com.songoda.epicbosses.holder.autospawn.ActiveIntervalAutoSpawnHolder;
import com.songoda.epicbosses.listeners.IBossDeathHandler; import com.songoda.epicbosses.listeners.IBossDeathHandler;
import com.songoda.epicbosses.managers.AutoSpawnManager; import com.songoda.epicbosses.managers.AutoSpawnManager;
import com.songoda.epicbosses.skills.interfaces.ICustomSettingAction; import com.songoda.epicbosses.skills.interfaces.ICustomSettingAction;
import com.songoda.epicbosses.utils.MessageUtils; import com.songoda.epicbosses.utils.*;
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.ClickAction;
import com.songoda.epicbosses.utils.panel.base.handlers.VariablePanelHandler; import com.songoda.epicbosses.utils.panel.base.handlers.VariablePanelHandler;
import lombok.Getter; import lombok.Getter;
@ -74,7 +71,10 @@ public class IntervalSpawnElement implements IAutoSpawnCustomSettingsHandler {
List<String> bosses = autoSpawn.getEntities(); List<String> bosses = autoSpawn.getEntities();
Location location = getSpawnLocation(); 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); if(shuffleList) Collections.shuffle(bosses);

View File

@ -32,4 +32,8 @@ public class ActiveAutoSpawnHolder {
return true; return true;
} }
public void clear() {
this.activeBossHolders.clear();
}
} }

View File

@ -13,6 +13,7 @@ import com.songoda.epicbosses.utils.Debug;
import com.songoda.epicbosses.utils.ObjectUtils; import com.songoda.epicbosses.utils.ObjectUtils;
import com.songoda.epicbosses.utils.ServerUtils; import com.songoda.epicbosses.utils.ServerUtils;
import com.songoda.epicbosses.utils.time.TimeUnit; import com.songoda.epicbosses.utils.time.TimeUnit;
import com.songoda.epicbosses.utils.time.TimeUtil;
import lombok.Getter; import lombok.Getter;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -39,8 +40,14 @@ public class ActiveIntervalAutoSpawnHolder extends ActiveAutoSpawnHolder {
@Override @Override
public boolean canSpawn() { public boolean canSpawn() {
if(getAutoSpawn().isEditing()) return false; if(getAutoSpawn().isEditing()) {
if(!getAutoSpawn().getType().equalsIgnoreCase("INTERVAL")) return false; 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 currentActiveAmount = getCurrentActiveBossHolders();
int maxAmount = getAutoSpawn().getAutoSpawnSettings().getMaxAliveAtOnce(); int maxAmount = getAutoSpawn().getAutoSpawnSettings().getMaxAliveAtOnce();
@ -48,11 +55,26 @@ public class ActiveIntervalAutoSpawnHolder extends ActiveAutoSpawnHolder {
Location location = this.intervalSpawnElement.getSpawnLocation(); Location location = this.intervalSpawnElement.getSpawnLocation();
boolean spawnIfChunkNotLoaded = ObjectUtils.getValue(getAutoSpawn().getAutoSpawnSettings().getSpawnWhenChunkIsntLoaded(), false); boolean spawnIfChunkNotLoaded = ObjectUtils.getValue(getAutoSpawn().getAutoSpawnSettings().getSpawnWhenChunkIsntLoaded(), false);
if(location == null) return false; if(location == null) {
if(!spawnIfChunkNotLoaded && !location.getChunk().isLoaded()) return false; ServerUtils.get().logDebug("AutoSpawn failed to spawn due to location is null.");
if(isSpawnAfterLastBossIsKilled() && !getActiveBossHolders().isEmpty()) return false; 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() { public boolean isSpawnAfterLastBossIsKilled() {
@ -71,14 +93,21 @@ public class ActiveIntervalAutoSpawnHolder extends ActiveAutoSpawnHolder {
return; return;
} }
int delaySec = (int) TimeUnit.MINUTES.to(TimeUnit.SECONDS, delay); int seconds = 10;
this.intervalTask = ServerUtils.get().runTimer(delaySec*20, delaySec*20, () -> { ServerUtils.get().runLater((int) TimeUnit.SECONDS.to(TimeUnit.TICK, seconds), () -> {
long delayTick = (long) TimeUnit.MINUTES.to(TimeUnit.TICK, delay);
this.intervalTask = ServerUtils.get().runTimer(delayTick, delayTick, () -> {
boolean canSpawn = canSpawn(); boolean canSpawn = canSpawn();
if(!canSpawn) return; if(!canSpawn) {
ServerUtils.get().logDebug("--- Failed to AutoSpawn. ---");
updateNextCompleteTime();
return;
}
this.intervalSpawnElement.attemptSpawn(this); ServerUtils.get().logDebug("AutoSpawn Spawn Attempt: " + this.intervalSpawnElement.attemptSpawn(this));
if(isSpawnAfterLastBossIsKilled()) { if(isSpawnAfterLastBossIsKilled()) {
cancelCurrentInterval(); cancelCurrentInterval();
@ -88,7 +117,12 @@ public class ActiveIntervalAutoSpawnHolder extends ActiveAutoSpawnHolder {
updateNextCompleteTime(); 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() { public void stopInterval() {

View File

@ -131,7 +131,7 @@ public class BossSpawnListener implements Listener {
if(commands != null) { if(commands != null) {
commands.forEach(serverUtils::sendConsoleCommand); commands.forEach(serverUtils::sendConsoleCommand);
} }
if(messages != null) { if(messages != null && !activeBossHolder.isCustomSpawnMessage()) {
if(activeBossHolder.getName() != null) messages.replaceAll(s -> s.replace("{boss}", activeBossHolder.getName())); if(activeBossHolder.getName() != null) messages.replaceAll(s -> s.replace("{boss}", activeBossHolder.getName()));
messages.replaceAll(s -> s.replace("{location}", StringUtils.get().translateLocation(location))); messages.replaceAll(s -> s.replace("{location}", StringUtils.get().translateLocation(location)));

View File

@ -47,6 +47,10 @@ public class AutoSpawnManager {
autoSpawnHolderMap.forEach((name, autoSpawnHolder) -> removeActiveAutoSpawnHolder(name)); autoSpawnHolderMap.forEach((name, autoSpawnHolder) -> removeActiveAutoSpawnHolder(name));
} }
public void clearAutoSpawns() {
this.activeAutoSpawnHolders.values().forEach(ActiveAutoSpawnHolder::clear);
}
public List<String> getIntervalAutoSpawns() { public List<String> getIntervalAutoSpawns() {
Map<String, ActiveAutoSpawnHolder> autoSpawnHolderMap = new HashMap<>(this.activeAutoSpawnHolders); Map<String, ActiveAutoSpawnHolder> autoSpawnHolderMap = new HashMap<>(this.activeAutoSpawnHolders);
List<String> intervalAutoSpawns = new ArrayList<>(); List<String> intervalAutoSpawns = new ArrayList<>();

View File

@ -114,6 +114,8 @@ public class BossEntityManager {
} }
} }
CustomBosses.get().getAutoSpawnManager().clearAutoSpawns();
return amountOfBosses; return amountOfBosses;
} }

View File

@ -5,10 +5,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import java.util.ArrayList; import java.util.*;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
/** /**
* @author Charles Cullen * @author Charles Cullen
@ -56,19 +53,30 @@ public class StringUtils {
if(input == null) return null; if(input == null) return null;
String[] split = input.split(","); String[] split = input.split(",");
StringBuilder stringBuilder = new StringBuilder();
if(split.length != 4) return null; for(String s : split) {
stringBuilder.append("|").append(s).append(",");
}
String worldInput = split[0]; ServerUtils.get().logDebug(stringBuilder.toString());
String xInput = split[1];
String yInput = split[2]; try {
String zInput = split[3]; 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); World world = Bukkit.getWorld(worldInput);
if(NumberUtils.get().isInt(xInput) && NumberUtils.get().isInt(yInput) && NumberUtils.get().isInt(zInput)) { 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)); 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; return null;
} }

View File

@ -17,6 +17,7 @@ public enum TimeUnit {
HOURS(3600), HOURS(3600),
MINUTES(60), MINUTES(60),
SECONDS(1), SECONDS(1),
TICK(0.05),
MILLISECONDS(0.001); MILLISECONDS(0.001);
private double seconds; private double seconds;

View File

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