use of gg.projecteden.nexus.features.minigames.models.events.matches.minigamers.MinigamerDeathEvent in project Nexus by ProjectEdenGG.
the class SabotageMatchData method endMeeting.
public void endMeeting() {
if (votingScreen instanceof ResultsScreen)
return;
AbstractVoteScreen oldScreen = votingScreen;
votingScreen = new ResultsScreen();
meetingEnded = LocalDateTime.now();
match.getTasks().cancel(meetingTaskID);
match.getTasks().cancel(endMeetingTask);
meetingTaskID = -1;
endMeetingTask = -1;
match.getMinigamers().forEach(minigamer -> {
oldScreen.close(minigamer);
votingScreen.open(minigamer);
minigamer.getPlayer().getInventory().remove(Sabotage.VOTING_ITEM.get());
});
match.getTasks().wait(TimeUtils.TickTime.SECOND.x(Sabotage.POST_MEETING_DELAY), () -> {
match.getMinigamers().forEach(minigamer -> votingScreen.close(minigamer));
Minigamer ejected = null;
int votes = getVotesFor(null).size();
boolean tie = false;
for (Minigamer minigamer : match.getAliveMinigamers()) {
int mVotes = getVotesFor(minigamer).size();
if (mVotes > votes) {
ejected = minigamer;
votes = mVotes;
tie = false;
} else if (mVotes == votes) {
ejected = null;
tie = true;
}
}
String ejectedName;
if (ejected != null) {
ejectedName = ejected.getNickname();
} else
ejectedName = "Nobody";
String display = ejectedName + " was ejected.";
if (ejected == null)
display += " (" + (tie ? "Tied" : "Skipped") + ")";
// TODO: true animation
match.showTitle(Title.title(Component.empty(), new JsonBuilder(display).build(), Title.Times.of(fade, Duration.ofSeconds(7), fade)));
match.playSound(Sound.sound(org.bukkit.Sound.ENTITY_PLAYER_SPLASH_HIGH_SPEED, Sound.Source.PLAYER, 1.0F, 1.0F));
clearVotes();
votingScreen = null;
roundStarted = LocalDateTime.now();
match.getMinigamers().forEach(Minigamer::respawn);
SabotageTeam team = SabotageTeam.of(ejected);
if (team == SabotageTeam.JESTER) {
ejected.scored();
match.end();
} else if (ejected != null)
match.getMechanic().onDeath(new MinigamerDeathEvent(ejected));
});
}
use of gg.projecteden.nexus.features.minigames.models.events.matches.minigamers.MinigamerDeathEvent in project Nexus by ProjectEdenGG.
the class AntiCampingTask method teleport.
private void teleport(@NotNull Minigamer minigamer, int floorId) {
Arena arena = minigamer.getMatch().getArena();
Mechanic mechanic = arena.getMechanic();
ProtectedRegion floorAt;
// Floor ID not provided, get it
if (floorId == -1) {
floorAt = getFloorAt(minigamer);
if (floorAt == null)
throw new InvalidInputException("Could not find floor for player " + minigamer.getNickname());
floorId = Arena.getRegionNumber(floorAt);
} else {
// Floor ID provided (probably recursively trying to find next floor down)
floorAt = arena.getProtectedRegion("floor_" + floorId);
}
if (floorId < 2) {
MinigamerDeathEvent deathEvent = new MinigamerDeathEvent(minigamer);
if (!deathEvent.callEvent())
return;
mechanic.onDeath(deathEvent);
} else {
Location location = minigamer.getPlayer().getLocation();
location.setY(floorAt.getMinimumPoint().getY() - 1);
Region floorTo = arena.getRegion("floor_" + --floorId);
Location to = null;
while (location.getY() >= floorTo.getMinimumPoint().getY()) {
location.add(0, -1, 0);
if (!location.getBlock().getType().isSolid())
continue;
to = location;
break;
}
if (to != null) {
teleport(minigamer, to);
return;
}
// Set up correct origin and search radius for nearest block check
int yDiff = floorTo.getMaximumPoint().getBlockY() - floorTo.getMinimumPoint().getBlockY();
location.setY(floorTo.getMaximumPoint().getBlockY());
if (yDiff > 0) {
yDiff = (yDiff / 2) + 1;
location.add(0, -yDiff, 0);
}
List<Block> blocks = BlockUtils.getBlocksInRadius(location.getBlock(), 4, yDiff, 4).stream().filter(block -> block.getType().isSolid()).sorted((block1, block2) -> {
Double distance1 = block1.getLocation().distance(minigamer.getPlayer().getLocation());
Double distance2 = block2.getLocation().distance(minigamer.getPlayer().getLocation());
return distance1.compareTo(distance2);
}).collect(Collectors.toList());
// No blocks within required radius on below floor, try next one
if (blocks.size() == 0) {
teleport(minigamer, floorId);
return;
}
teleport(minigamer, blocks.get(0).getLocation());
}
}
use of gg.projecteden.nexus.features.minigames.models.events.matches.minigamers.MinigamerDeathEvent in project Nexus by ProjectEdenGG.
the class Mechanic method kill.
public void kill(@NotNull Minigamer victim, @Nullable Minigamer attacker) {
MinigamerDeathEvent event = new MinigamerDeathEvent(victim, attacker);
if (!event.callEvent())
return;
onDeath(event);
}
Aggregations