Search in sources :

Example 1 with Match

use of gg.projecteden.nexus.features.minigames.models.Match in project Nexus by ProjectEdenGG.

the class ToyTesting method onMatchStart.

@EventHandler
public void onMatchStart(MatchStartEvent event) {
    Match match = event.getMatch();
    String arenaName = match.getArena().getName();
    if (arenaName.equalsIgnoreCase("AlphaVsOmega")) {
        setPlayedGame(match.getPlayers(), Toy.BATTLESHIP);
    } else if (arenaName.equalsIgnoreCase("MasterMind")) {
        setPlayedGame(match.getPlayers(), Toy.MASTERMIND);
    }
}
Also used : Match(gg.projecteden.nexus.features.minigames.models.Match) EventHandler(org.bukkit.event.EventHandler)

Example 2 with Match

use of gg.projecteden.nexus.features.minigames.models.Match in project Nexus by ProjectEdenGG.

the class MinigamesCommand method autoreset.

@Path("autoreset [boolean]")
@Permission(PERMISSION_USE)
void autoreset(Boolean autoreset) {
    Match match = minigamer.getMatch();
    if (!minigamer.isPlaying())
        error("You must be playing a checkpoint game to use that command");
    if (!(match.getMechanic() instanceof CheckpointMechanic))
        error("You are not in a checkpoint game");
    CheckpointMatchData matchData = match.getMatchData();
    matchData.autoreset(minigamer, autoreset);
    if (matchData.isAutoresetting(minigamer))
        send(PREFIX + "Enabled &eAuto Reset");
    else
        send(PREFIX + "Disabled &eAuto Reset");
}
Also used : CheckpointMechanic(gg.projecteden.nexus.features.minigames.mechanics.common.CheckpointMechanic) CheckpointMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.CheckpointMatchData) Match(gg.projecteden.nexus.features.minigames.models.Match) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 3 with Match

use of gg.projecteden.nexus.features.minigames.models.Match in project Nexus by ProjectEdenGG.

the class MinigamesCommand method list.

@Path("list [filter]")
@Permission(PERMISSION_USE)
void list(String filter) {
    JsonBuilder json = json(PREFIX);
    final List<Arena> arenas = ArenaManager.getAll(filter).stream().sorted(Comparator.comparing(Arena::getName).thenComparing(arena -> MatchManager.find(arena) != null)).toList();
    final Iterator<Arena> iterator = arenas.iterator();
    while (iterator.hasNext()) {
        Arena arena = iterator.next();
        Match match = MatchManager.find(arena);
        if (match == null)
            json.next("&3" + arena.getName());
        else
            json.next("&e" + arena.getName()).hover(match.getMinigamers().stream().map(Minigamer::getNickname).collect(Collectors.joining(", ")));
        if (iterator.hasNext())
            json.group().next("&3, ").group();
    }
    send(json);
}
Also used : JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) Arena(gg.projecteden.nexus.features.minigames.models.Arena) Match(gg.projecteden.nexus.features.minigames.models.Match) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Permission(gg.projecteden.nexus.framework.commands.models.annotations.Permission)

Example 4 with Match

use of gg.projecteden.nexus.features.minigames.models.Match in project Nexus by ProjectEdenGG.

the class AbstractTaskMenu method scheduleInvClose.

// todo: use for more tasks
public void scheduleInvClose(HasPlayer _player) {
    Player player = _player.getPlayer();
    Minigamer minigamer = PlayerManager.get(player);
    // don't schedule if match just ended
    if (!minigamer.isPlaying(Sabotage.class))
        return;
    Match.MatchTasks tasks = minigamer.getMatch().getTasks();
    if (closeInvTasks.containsKey(player.getUniqueId()))
        tasks.cancel(closeInvTasks.remove(player.getUniqueId()));
    closeInvTasks.put(player.getUniqueId(), tasks.wait(20, () -> {
        player.sendMessage(Sabotage.COMPLETED_TASK_TEXT);
        player.closeInventory();
    }));
}
Also used : HasPlayer(me.lexikiq.HasPlayer) Player(org.bukkit.entity.Player) Minigamer(gg.projecteden.nexus.features.minigames.models.Minigamer) Sabotage(gg.projecteden.nexus.features.minigames.mechanics.Sabotage) Match(gg.projecteden.nexus.features.minigames.models.Match)

Example 5 with Match

use of gg.projecteden.nexus.features.minigames.models.Match in project Nexus by ProjectEdenGG.

the class TeamMechanic method getBalanceWrappers.

@NotNull
protected List<BalanceWrapper> getBalanceWrappers(@NotNull Match match) {
    // ALL PERCENTAGES HERE RANGE FROM 0 to 1 !!
    List<Team> teams = match.getArena().getTeams();
    List<BalanceWrapper> wrappers = new ArrayList<>();
    // sum of all balance percentages
    double percentageSum = 0;
    // count of teams w/o balance percentages
    int noPercentage = 0;
    for (Team team : teams) {
        BalanceWrapper wrapper = new BalanceWrapper(team, match);
        wrappers.add(wrapper);
        if (wrapper.getPercentage() != null)
            percentageSum += wrapper.getPercentage();
        else
            noPercentage++;
    }
    if (noPercentage > 0 && percentageSum < 1) {
        // evenly split the balance of teams that don't have a balance percentage (if there is any unassigned %)
        double percentage = (1d / noPercentage) * (1d - percentageSum);
        wrappers.stream().filter(wrapper -> wrapper.getPercentage() == null).forEach(wrapper -> wrapper.setPercentage(percentage));
    }
    // ensure percentages add up to 100
    double totalPercentage = wrappers.stream().mapToDouble(BalanceWrapper::getPercentage).sum();
    wrappers.forEach(wrapper -> wrapper.setPercentage(wrapper.getPercentage() / totalPercentage));
    return wrappers;
}
Also used : MatchTasks(gg.projecteden.nexus.features.minigames.models.Match.MatchTasks) VoiceChannelCategory(gg.projecteden.utils.DiscordId.VoiceChannelCategory) JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) LocalDateTime(java.time.LocalDateTime) OptionalPlayer(me.lexikiq.OptionalPlayer) HashMap(java.util.HashMap) Member(net.dv8tion.jda.api.entities.Member) Player(org.bukkit.entity.Player) MatchData(gg.projecteden.nexus.features.minigames.models.MatchData) Name(gg.projecteden.nexus.utils.Name) Match(gg.projecteden.nexus.features.minigames.models.Match) MinigamerQuitEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MinigamerQuitEvent) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Guild(net.dv8tion.jda.api.entities.Guild) MatchEndEvent(gg.projecteden.nexus.features.minigames.models.events.matches.MatchEndEvent) RandomUtils(gg.projecteden.nexus.utils.RandomUtils) Component(net.kyori.adventure.text.Component) Map(java.util.Map) Team(gg.projecteden.nexus.features.minigames.models.Team) Minigames(gg.projecteden.nexus.features.minigames.Minigames) ChatColor(net.md_5.bungee.api.ChatColor) Nexus(gg.projecteden.nexus.Nexus) DiscordUserService(gg.projecteden.nexus.models.discord.DiscordUserService) Minigamer(gg.projecteden.nexus.features.minigames.models.Minigamer) Set(java.util.Set) EqualsAndHashCode(lombok.EqualsAndHashCode) Collectors(java.util.stream.Collectors) Discord(gg.projecteden.nexus.features.discord.Discord) Arena(gg.projecteden.nexus.features.minigames.models.Arena) MinigamerDeathEvent(gg.projecteden.nexus.features.minigames.models.events.matches.minigamers.MinigamerDeathEvent) DiscordId(gg.projecteden.utils.DiscordId) MatchTaskType(gg.projecteden.nexus.features.minigames.models.Match.MatchTasks.MatchTaskType) TickTime(gg.projecteden.utils.TimeUtils.TickTime) Nullable(org.jetbrains.annotations.Nullable) DiscordUser(gg.projecteden.nexus.models.discord.DiscordUser) List(java.util.List) Data(lombok.Data) Optional(java.util.Optional) NotNull(org.jetbrains.annotations.NotNull) Comparator(java.util.Comparator) Collections(java.util.Collections) MultiplayerMechanic(gg.projecteden.nexus.features.minigames.models.mechanics.multiplayer.MultiplayerMechanic) ArrayList(java.util.ArrayList) Team(gg.projecteden.nexus.features.minigames.models.Team) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Match (gg.projecteden.nexus.features.minigames.models.Match)70 Minigamer (gg.projecteden.nexus.features.minigames.models.Minigamer)33 Player (org.bukkit.entity.Player)18 EventHandler (org.bukkit.event.EventHandler)18 NotNull (org.jetbrains.annotations.NotNull)17 MatchEndEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MatchEndEvent)15 ItemStack (org.bukkit.inventory.ItemStack)15 Location (org.bukkit.Location)14 TickTime (gg.projecteden.utils.TimeUtils.TickTime)13 List (java.util.List)13 Material (org.bukkit.Material)13 Block (org.bukkit.block.Block)13 Team (gg.projecteden.nexus.features.minigames.models.Team)12 ArrayList (java.util.ArrayList)12 Map (java.util.Map)12 Arena (gg.projecteden.nexus.features.minigames.models.Arena)11 MatchStartEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MatchStartEvent)11 MinigamerQuitEvent (gg.projecteden.nexus.features.minigames.models.events.matches.MinigamerQuitEvent)11 Set (java.util.Set)11 Sound (org.bukkit.Sound)11