Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Spawns on the same height (AutoSetup) #101

Open
wants to merge 9 commits into
base: dev-v4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public enum ConfigMessages implements DefaultLanguage {
DEATH_KILL_LIFE_ADD("death.killLifeAdd", "Dein Team hat aufgrund eines Kills ein Teamleben erhalten!"),
DEATH_KILL_TIME_ADD("death.killTimeAdd", "Aufgrund deines Kills hast du zusätzlich %colorcode%%timeAdded% &7Sekunden Zeit erhalten!"),

GAME_FINALE_COUNTDOWN("game.finale.finaleCountdown", "&7Das Finale startet in %colorcode%%countdown% &7Sekunde(n)!"),
GAME_START_COUNTDOWN("game.start.startCountdown", "%projectname% &7startet in %colorcode%%countdown% &7Sekunde(n)!"),
GAME_VARO_START("game.start.varoStart", "%projectname% &7wurde gestartet! &5Viel Erfolg!"),
GAME_VARO_START_TITLE("game.start.startTitle", "%colorcode%%countdown%"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public enum LanguageEN implements LoadableMessage {
DEATH_KILL_LIFE_ADD("death.killLifeAdd", "&7Your team got a team life because of a kill!"),
DEATH_KILL_TIME_ADD("death.killTimeAdd", "You've recieved %colorcode%%timeAdded% &7seconds of additional time!"),

GAME_FINALE_COUNTDOWN("game.finale.finaleCountdown", "&7The finale starts in %colorcode%%countdown% &7second(s)!"),
GAME_START_COUNTDOWN("game.start.startCountdown", "%projectname% &7starts in %colorcode%%countdown% &7second(s)!"),
GAME_VARO_START("game.start.varoStart", "%projectname% &7has started! &5Good luck!"),
GAME_VARO_START_TITLE("game.start.startTitle", "%colorcode%%countdown%"),
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/cuuky/varo/game/VaroGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public void run() {
}

if (VaroGame.this.finaleCountdown != 0) {
Bukkit.broadcastMessage(Main.getPrefix() + "Das Finale startet in " + VaroGame.this.finaleCountdown + " Sekunden!");
Main.getLanguageManager().broadcastMessage(ConfigMessages.GAME_FINALE_COUNTDOWN).replace("%countdown%", finaleCountdown == 1 ? "einer" : String.valueOf(finaleCountdown));
} else {
VaroGame.this.startFinale();
VaroGame.this.finaleStartScheduler.cancel();
Expand Down Expand Up @@ -526,4 +526,4 @@ public void onDeserializeEnd() {
@Override
public void onSerializeStart() {
}
}
}
33 changes: 29 additions & 4 deletions src/main/java/de/cuuky/varo/game/world/AutoSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,40 @@ private void setupBorder(Location middle) {
private void setupSpawns(Location middle) {
System.out.println(Main.getConsolePrefix() + "AutoSetup: Setting the spawns...");

int y = this.getGroundHeight(middle.getWorld(), this.x, this.z);
if (ConfigSetting.AUTOSETUP_PORTAL_ENABLED.getValueAsBoolean())
y += ConfigSetting.AUTOSETUP_PORTAL_HEIGHT.getValueAsInt();
middle.getWorld().setSpawnLocation(this.x, y, this.z);
int flatHeight = getFlatSurfaceHeight(middle.getWorld(), this.x, this.z);

middle.getWorld().setSpawnLocation(this.x, flatHeight, this.z);

new SpawnGenerator(middle, getSpawnRadius(ConfigSetting.AUTOSETUP_SPAWNS_AMOUNT.getValueAsInt()),ConfigSetting.AUTOSETUP_SPAWNS_AMOUNT.getValueAsInt(),
(XMaterial) ConfigSetting.AUTOSETUP_SPAWNS_BLOCKID.getValueAsEnum(), (XMaterial) ConfigSetting.AUTOSETUP_SPAWNS_SIDEBLOCKID.getValueAsEnum());
}

private int getFlatSurfaceHeight(World world, int x, int z) {
int flatHeight = getGroundHeight(world, x, z);

int radius = getSpawnRadius(ConfigSetting.AUTOSETUP_SPAWNS_AMOUNT.getValueAsInt());

for (int i = -radius; i <= radius; i++) {
for (int j = -radius; j <= radius; j++) {
if (i * i + j * j <= radius * radius) {
int tempHeight = getGroundHeight(world, x + i, z + j);
flatHeight = Math.min(flatHeight, tempHeight);
}
}
}

for (int i = -radius; i <= radius; i++) {
for (int j = -radius; j <= radius; j++) {
if (i * i + j * j <= radius * radius) {
Location loc = new Location(world, x + i, flatHeight, z + j);
loc.getBlock().setType(XMaterial.GRASS_BLOCK.parseMaterial());
}
}
}

return flatHeight;
}

private void setupAutoStart() {
if (ConfigSetting.AUTOSETUP_TIME_HOUR.isIntActivated() && ConfigSetting.AUTOSETUP_TIME_MINUTE.isIntActivated()) {
System.out.println(Main.getConsolePrefix() + "AutoSetup: " + "Setting up AutoStart...");
Expand Down
Loading