Skip to content

Commit

Permalink
Add teams
Browse files Browse the repository at this point in the history
  • Loading branch information
haykam821 committed Jun 24, 2024
1 parent 1ad87fe commit 36f7ce9
Show file tree
Hide file tree
Showing 33 changed files with 1,338 additions and 122 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.github.haykam821.beaconbreakers.game;

import java.util.Optional;

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;

Expand All @@ -8,12 +10,14 @@
import net.minecraft.util.math.intprovider.ConstantIntProvider;
import net.minecraft.util.math.intprovider.IntProvider;
import xyz.nucleoid.plasmid.game.common.config.PlayerConfig;
import xyz.nucleoid.plasmid.game.common.team.GameTeamList;

public class BeaconBreakersConfig {
public static final Codec<BeaconBreakersConfig> CODEC = RecordCodecBuilder.create(instance -> {
return instance.group(
PlayerConfig.CODEC.fieldOf("players").forGetter(BeaconBreakersConfig::getPlayerConfig),
BeaconBreakersMapConfig.CODEC.fieldOf("map").forGetter(BeaconBreakersConfig::getMapConfig),
GameTeamList.CODEC.optionalFieldOf("teams").forGetter(BeaconBreakersConfig::getTeams),
IntProvider.NON_NEGATIVE_CODEC.optionalFieldOf("ticks_until_close", ConstantIntProvider.create(SharedConstants.TICKS_PER_SECOND * 10)).forGetter(BeaconBreakersConfig::getTicksUntilClose),
Codec.INT.optionalFieldOf("invulnerability", 2 * 60 * 20).forGetter(BeaconBreakersConfig::getInvulnerability),
Codec.BOOL.optionalFieldOf("keep_inventory", false).forGetter(BeaconBreakersConfig::shouldKeepInventory),
Expand All @@ -23,14 +27,16 @@ public class BeaconBreakersConfig {

private final PlayerConfig playerConfig;
private final BeaconBreakersMapConfig mapConfig;
private final Optional<GameTeamList> teams;
private final IntProvider ticksUntilClose;
private final int invulnerability;
private final boolean keepInventory;
private final boolean allowSelfBreaking;

public BeaconBreakersConfig(PlayerConfig playerConfig, BeaconBreakersMapConfig mapConfig, IntProvider ticksUntilClose, int invulnerability, boolean keepInventory, boolean allowSelfBreaking) {
public BeaconBreakersConfig(PlayerConfig playerConfig, BeaconBreakersMapConfig mapConfig, Optional<GameTeamList> teams, IntProvider ticksUntilClose, int invulnerability, boolean keepInventory, boolean allowSelfBreaking) {
this.playerConfig = playerConfig;
this.mapConfig = mapConfig;
this.teams = teams;
this.ticksUntilClose = ticksUntilClose;
this.invulnerability = invulnerability;
this.keepInventory = keepInventory;
Expand All @@ -45,6 +51,10 @@ public BeaconBreakersMapConfig getMapConfig() {
return this.mapConfig;
}

public Optional<GameTeamList> getTeams() {
return this.teams;
}

public IntProvider getTicksUntilClose() {
return this.ticksUntilClose;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.haykam821.beaconbreakers.game;

import io.github.haykam821.beaconbreakers.game.phase.BeaconBreakersActivePhase;
import io.github.haykam821.beaconbreakers.game.player.PlayerEntry;
import io.github.haykam821.beaconbreakers.game.player.team.TeamEntry;
import net.minecraft.text.Text;
import xyz.nucleoid.plasmid.game.common.GlobalWidgets;
import xyz.nucleoid.plasmid.game.common.widget.SidebarWidget;
Expand All @@ -21,8 +21,8 @@ public BeaconBreakersSidebar(GlobalWidgets widgets, BeaconBreakersActivePhase ph

public void update() {
this.widget.set(content -> {
for (PlayerEntry player : this.phase.getPlayers()) {
content.add(player.getSidebarEntryText());
for (TeamEntry team : this.phase.getTeams()) {
content.add(team.getSidebarEntryText());
}
});
}
Expand Down
Loading

0 comments on commit 36f7ce9

Please sign in to comment.