use of gg.projecteden.nexus.features.minigames.models.exceptions.MinigameException in project Nexus by ProjectEdenGG.
the class Mastermind 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();
MastermindMatchData matchData = match.getMatchData();
if (isInRegion(match, block, "button")) {
if (!MaterialTag.BUTTONS.isTagged(block.getType()))
return;
// 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);
if (isInRegion(match, block, "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 (isInRegion(match, block, "repeats_off")) {
if (guess != 1) {
minigamer.tell("You cannot change the difficulty mode in the middle of the game");
return;
}
matchData.setRepeats(false);
matchData.createAnswer();
match.getArena().regenerate();
minigamer.tell("Difficulty mode updated");
return;
}
if (isInRegion(match, block, "repeats_on")) {
if (guess != 1) {
minigamer.tell("You cannot change the difficulty mode in the middle of the game");
return;
}
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);
}
}
use of gg.projecteden.nexus.features.minigames.models.exceptions.MinigameException 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);
}
}
use of gg.projecteden.nexus.features.minigames.models.exceptions.MinigameException in project Nexus by ProjectEdenGG.
the class HoleInTheWall method onInitialize.
@Override
public void onInitialize(@NotNull MatchInitializeEvent event) {
super.onInitialize(event);
HoleInTheWallArena arena = event.getMatch().getArena();
HoleInTheWallMatchData matchData = event.getMatch().getMatchData();
for (Location location : arena.getDesignHangerLocation()) {
Set<ProtectedRegion> trackRegions = arena.getRegionsLikeAt("track", location);
if (trackRegions.size() != 1)
throw new MinigameException("Was expecting 1 track region at " + getLocationString(location) + ", but found " + trackRegions.size());
Track track = matchData.new Track(trackRegions.iterator().next(), location);
track.reset();
matchData.getTracks().add(track);
}
}
Aggregations