Skip to content

Commit

Permalink
Merge pull request #12 from spacechunks/dev
Browse files Browse the repository at this point in the history
Fix last bugs
  • Loading branch information
NicoND1 authored Aug 2, 2024
2 parents ae1de25 + 35dca97 commit 8766fa0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ public interface Flight {

@Nullable
Boolean isBoarding();

boolean isValid();
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,9 @@ public double progress() {
public Boolean isBoarding() {
return null;
}

@Override
public boolean isValid() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void forceCreate(@NotNull Destination destination) {
}

protected void tickFlightDeletor(int currentTick) {
this.flights.removeIf(flight -> flight.targetFinishTick() == currentTick);
this.flights.removeIf(flight -> !flight.isValid() || flight.targetFinishTick() == currentTick);
}

protected void tickFlightCreator(int currentTick) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,10 @@ public double progress() {
}
return null;
}

@Override
public boolean isValid() {
return this.passengers.stream().filter(Passenger::isValid).count() > 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import space.chunks.gamecup.dgr.map.object.upgradable.UpgradeHolderRegistry;
import space.chunks.gamecup.dgr.minestom.inventory.Item;
import space.chunks.gamecup.dgr.minestom.inventory.SinglePageGui;
import space.chunks.gamecup.dgr.team.Team;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -68,11 +69,19 @@ private void drawItem(int slot, @NotNull Material iconType, @NotNull String key,
.withLore(lore)
.withoutExtraTooltip())
.addAllClickListener(event -> {
boolean upgrade = holder.upgrade();
if (upgrade) {
event.getPlayer().playSound(Sound.sound(Key.key("entity.player.levelup"), Source.AMBIENT, 1F, 1F), this.config.spawnPosition());
Team team = this.map.owner();
if (team.money() >= getCost(currentLevel+1)) {
boolean upgrade = holder.upgrade();

if (upgrade) {
team.forceRemoveMoney(getCost(currentLevel+1));
event.getPlayer().playSound(Sound.sound(Key.key("entity.player.levelup"), Source.AMBIENT, 1F, 1F), this.config.spawnPosition());
}

redraw();
} else {
event.getPlayer().sendMessage(Component.text("Not enough money!").color(NamedTextColor.RED));
}
redraw();
}));
}

Expand Down

0 comments on commit 8766fa0

Please sign in to comment.