Skip to content

Commit

Permalink
Additional changes for second Playtest
Browse files Browse the repository at this point in the history
  • Loading branch information
Andus committed Aug 31, 2024
1 parent cdc73cc commit 70e69cc
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 160 deletions.
Binary file modified server/SpectrumSurvival.jar
Binary file not shown.
27 changes: 2 additions & 25 deletions src/main/java/dev/celestialfox/spectrumsurvival/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dev.celestialfox.spectrumsurvival.game.commands.*;
import dev.celestialfox.spectrumsurvival.game.managers.GameManager;
import dev.celestialfox.spectrumsurvival.game.managers.QueueManager;
import dev.celestialfox.spectrumsurvival.utils.classes.SignHandler;
import dev.celestialfox.spectrumsurvival.utils.classes.Randomized;
import dev.celestialfox.spectrumsurvival.utils.config.Checks;
import dev.celestialfox.spectrumsurvival.utils.config.Settings;
import dev.celestialfox.spectrumsurvival.utils.events.MiscEvents;
Expand Down Expand Up @@ -44,7 +44,6 @@ public static void main(String[] args) {

Terminal.start();
tablist();
MinecraftServer.getBlockManager().registerHandler("minecraft:spruce_wall_sign", SignHandler::new);

// Server Start
BungeeCordProxy.enable();
Expand All @@ -67,31 +66,9 @@ public static void tablist() {
.append(Component.text("\nᴘʟᴀʏᴇʀѕ ɪɴ-ɢᴀᴍᴇ: " + GameManager.getPlayersInGame() + "\n", NamedTextColor.BLUE)));

Component footer = Component.newline()
.append(Component.text("ᴍᴀᴅᴇ ʙʏ: CelestialFox Studio", randomMadeByColor()));
.append(Component.text("ᴍᴀᴅᴇ ʙʏ: CelestialFox Studio", Randomized.madeByColor()));

Audiences.players().sendPlayerListHeaderAndFooter(header, footer);
}, TaskSchedule.tick(10), TaskSchedule.tick(10));
}

public static NamedTextColor randomMadeByColor() {
Random random = new Random();
int num = random.nextInt(4);
switch (num) {
case 0 -> {
return NamedTextColor.BLUE;
}
case 1 -> {
return NamedTextColor.GRAY;
}
case 2 -> {
return NamedTextColor.GOLD;
}
case 3 -> {
return NamedTextColor.GREEN;
}
default -> {
return NamedTextColor.RED;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ public class GameLobby {
private Task latestTask;
private Task repeatTask;
private Task endTask;
private Task bossBarTask;
private Instance instance;
private String name = "";
private long phaseStartTime;

public void setPlayers(ArrayList<UUID> playerList) {
players.addAll(playerList);
Expand Down Expand Up @@ -116,18 +118,28 @@ public void setTask(Task task) {
public Task getTask() {
return latestTask;
}

public void setRepeatTask(Task task) {
repeatTask = task;
}
public Task getRepeatTask() {
return repeatTask;
}

public void setEndTask(Task task) {
endTask = task;
}
public Task getEndTask() {
return endTask;
}
public void setBossBarTask(Task task) {
bossBarTask = task;
}
public Task getBossBarTask() {
return bossBarTask;
}
public long getPhaseStartTime() {
return phaseStartTime;
}
public void setPhaseStartTime(long phaseStartTime) {
this.phaseStartTime = phaseStartTime;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minestom.server.entity.GameMode;
import net.minestom.server.entity.Player;
import net.minestom.server.entity.ai.goal.MeleeAttackGoal;
import net.minestom.server.entity.ai.goal.RandomStrollGoal;
import net.minestom.server.entity.ai.target.ClosestEntityTarget;
import net.minestom.server.entity.attribute.Attribute;
import net.minestom.server.utils.time.TimeUnit;
Expand All @@ -15,16 +16,15 @@ public class ZombieCreature extends EntityCreature {

public ZombieCreature() {
super(EntityType.ZOMBIE);

getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.15);

getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.2);
addAIGroup(
List.of(
new MeleeAttackGoal(this, 1.6, 20, TimeUnit.SERVER_TICK) // Attack the target
new MeleeAttackGoal(this, 1.6, 20, TimeUnit.SERVER_TICK), // Attack the target
new RandomStrollGoal(this, 20) // Walk around
),
List.of(
new ClosestEntityTarget(this, 50,
entity -> entity instanceof Player && ((Player) entity).getGameMode() != GameMode.SPECTATOR) // Target the nearest player
new ClosestEntityTarget(this, 64, entity -> entity instanceof Player player
&& player.getGameMode() != GameMode.SPECTATOR) // If there is none, target the nearest player
)
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.celestialfox.spectrumsurvival.game.managers;

import dev.celestialfox.spectrumsurvival.game.classes.GameLobby;
import dev.celestialfox.spectrumsurvival.utils.Misc;
import dev.celestialfox.spectrumsurvival.game.classes.GameQueue;
import net.kyori.adventure.key.Key;
Expand All @@ -22,7 +21,7 @@ public class QueueManager {
public static List<GameQueue> queues = new ArrayList<>();
private static final HashMap<GameQueue, Task> countdownTasks = new HashMap<>();
private static int minPlayers = 6;
private static int maxPlayers = 10;
private static int maxPlayers = 12;
public static Instance lobbyInstance;

public static void joinPlayer(Player player) {
Expand All @@ -46,8 +45,8 @@ public static void joinPlayer(Player player) {
createQueue(player);
}

player.sendMessage(Component.text("The queue starts the countdown from §e6 players.", NamedTextColor.GRAY));
player.sendMessage(Component.text("One queue can hold up to §e10 players.", NamedTextColor.GRAY));
player.sendMessage(Component.text("The queue starts the countdown from §e" + minPlayers + " players.", NamedTextColor.GRAY));
player.sendMessage(Component.text("One queue can hold up to §e" + maxPlayers + " players.", NamedTextColor.GRAY));
player.sendMessage(Component.text("§e§lWaiting for too long? §rUse §a/queue force §rto start now.", NamedTextColor.GRAY));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package dev.celestialfox.spectrumsurvival.game.phases;

import dev.celestialfox.spectrumsurvival.game.classes.GameLobby;
import dev.celestialfox.spectrumsurvival.utils.Misc;
import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;

public class PhaseBossBar {
public static void updateBossBar(GameLobby game, BossBar nextPhaseBossBar, int phaseDuration) {
long currentTime = System.currentTimeMillis();
long elapsedMillis = currentTime - game.getPhaseStartTime();
long elapsedSeconds = elapsedMillis / 1000;
float progress = 1.0f - (float) elapsedSeconds / phaseDuration;
nextPhaseBossBar.progress(Math.max(progress, 0.0f));
long remainingSeconds = phaseDuration - elapsedSeconds;
String remainingTime = String.format("%d seconds until next phase", Math.max(remainingSeconds, 0));
nextPhaseBossBar.name(Component.text(remainingTime, NamedTextColor.WHITE));
}

public static void resetBossBarProgress(BossBar nextPhaseBossBar) {
nextPhaseBossBar.progress(1.0f);
}

public static void removeBossBar(GameLobby game, BossBar nextPhaseBossBar) {
game.getPlayers().forEach(uuid -> Misc.getPlayer(uuid).hideBossBar(nextPhaseBossBar));
}
}
Loading

0 comments on commit 70e69cc

Please sign in to comment.