Search in sources :

Example 1 with MultimindMatchData

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

the class Multimind method onStart.

@Override
public void onStart(@NotNull MatchStartEvent event) {
    super.onStart(event);
    Match match = event.getMatch();
    MultimindMatchData matchData = match.getMatchData();
    match.getAliveMinigamers().forEach(matchData::giveLoadout);
    matchData.resetResultsSign();
}
Also used : MultimindMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.MultimindMatchData) Match(gg.projecteden.nexus.features.minigames.models.Match)

Example 2 with MultimindMatchData

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

the class Multimind method onInteract.

@EventHandler
public void onInteract(PlayerInteractEvent event) {
    Block block = event.getClickedBlock();
    if (EquipmentSlot.HAND != event.getHand() || block == null)
        return;
    Minigamer minigamer = PlayerManager.get(event.getPlayer());
    if (!minigamer.isPlaying(this))
        return;
    if (Action.LEFT_CLICK_BLOCK.equals(event.getAction())) {
        event.setCancelled(true);
        removeBlock(minigamer, block);
        return;
    }
    if (Action.RIGHT_CLICK_BLOCK.equals(event.getAction())) {
        Match match = minigamer.getMatch();
        MultimindMatchData matchData = match.getMatchData();
        if (MaterialTag.BUTTONS.isTagged(block.getType())) {
            // TODO Cleanup
            try {
                matchData.guess(minigamer);
            } catch (MinigameException ex) {
                minigamer.tell("&cError: " + ex.getMessage());
            } catch (Exception ex) {
                minigamer.tell("&cUnknown error occurred");
                ex.printStackTrace();
            }
            return;
        }
        if (MaterialTag.SIGNS.isTagged(block.getType())) {
            int guess = matchData.getGuess(minigamer);
            Sign sign = (Sign) block.getState();
            String line1 = stripColor(sign.getLine(0));
            if (line1.equals("< Colorblind >")) {
                if (guess != 1) {
                    minigamer.tell("You cannot change colorblind mode in the middle of the game");
                    return;
                }
                matchData.toggleColorblind(minigamer);
                matchData.giveLoadout(minigamer);
                matchData.createAnswer();
                match.getArena().regenerate();
                return;
            }
            if (line1.equals("< Difficulty >")) {
                if (guess != 1) {
                    minigamer.tell("You cannot change the difficulty mode in the middle of the game");
                    return;
                }
                String line2 = stripColor(sign.getLine(1));
                if (line2.equals("Easy"))
                    matchData.setRepeats(false);
                else if (line2.equals("Hard"))
                    matchData.setRepeats(true);
                matchData.createAnswer();
                match.getArena().regenerate();
                minigamer.tell("Difficulty mode updated");
                return;
            }
        }
        Block placed = event.getClickedBlock().getRelative(event.getBlockFace());
        if (!isNullOrAir(event.getItem()) && !canBuild(minigamer, placed))
            event.setCancelled(true);
    }
}
Also used : MultimindMatchData(gg.projecteden.nexus.features.minigames.models.matchdata.MultimindMatchData) MinigameException(gg.projecteden.nexus.features.minigames.models.exceptions.MinigameException) Block(org.bukkit.block.Block) Sign(org.bukkit.block.Sign) Minigamer(gg.projecteden.nexus.features.minigames.models.Minigamer) MinigameException(gg.projecteden.nexus.features.minigames.models.exceptions.MinigameException) Match(gg.projecteden.nexus.features.minigames.models.Match) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Match (gg.projecteden.nexus.features.minigames.models.Match)2 MultimindMatchData (gg.projecteden.nexus.features.minigames.models.matchdata.MultimindMatchData)2 Minigamer (gg.projecteden.nexus.features.minigames.models.Minigamer)1 MinigameException (gg.projecteden.nexus.features.minigames.models.exceptions.MinigameException)1 Block (org.bukkit.block.Block)1 Sign (org.bukkit.block.Sign)1 EventHandler (org.bukkit.event.EventHandler)1