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();
}
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);
}
}
Aggregations