use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class MultiplayerType method endMinigame.
@Override
public void endMinigame(List<MinigamePlayer> winners, List<MinigamePlayer> losers, Minigame mgm) {
if (mgm.isTeamGame()) {
for (MinigamePlayer player : winners) {
player.removeTeam();
}
for (MinigamePlayer player : losers) {
player.removeTeam();
}
for (Team t : TeamsModule.getMinigameModule(mgm).getTeams()) {
t.resetScore();
}
}
if (mgm.getMpTimer() == null)
return;
mgm.getMpTimer().setStartWaitTime(0);
mgm.setMpTimer(null);
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class MultiplayerType method playerRespawn.
/*----------------*/
/*-----EVENTS-----*/
/*----------------*/
@EventHandler(priority = EventPriority.HIGHEST)
public void playerRespawn(PlayerRespawnEvent event) {
final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply.isInMinigame() && ply.getMinigame().getType() == MinigameType.MULTIPLAYER) {
Minigame mg = ply.getMinigame();
Location respawnPos;
if (ply.getMinigame().isTeamGame()) {
Team team = ply.getTeam();
if (mg.hasStarted() && !ply.isLatejoining()) {
if (mg.isAllowedMPCheckpoints() && ply.hasCheckpoint()) {
respawnPos = ply.getCheckpoint();
} else {
List<Location> starts = new ArrayList<>();
if (TeamsModule.getMinigameModule(mg).hasTeamStartLocations()) {
starts.addAll(team.getStartLocations());
ply.getLoadout().equiptLoadout(ply);
} else {
starts.addAll(mg.getStartLocations());
}
Collections.shuffle(starts);
respawnPos = starts.get(0);
}
ply.getLoadout().equiptLoadout(ply);
} else {
respawnPos = mg.getLobbyPosition();
}
} else {
if (mg.hasStarted() && !ply.isLatejoining()) {
if (mg.isAllowedMPCheckpoints() && ply.hasCheckpoint()) {
respawnPos = ply.getCheckpoint();
} else {
List<Location> starts = new ArrayList<>(mg.getStartLocations());
Collections.shuffle(starts);
respawnPos = starts.get(0);
}
ply.getLoadout().equiptLoadout(ply);
} else {
respawnPos = mg.getLobbyPosition();
}
}
event.setRespawnLocation(respawnPos);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> ply.getPlayer().setNoDamageTicks(60));
}
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class MinigameManager method stopGlobalMinigame.
public void stopGlobalMinigame(final Minigame minigame, final MinigamePlayer caller) {
if (minigame.getType() == MinigameType.GLOBAL) {
final StopGlobalMinigameEvent ev = new StopGlobalMinigameEvent(minigame, caller);
Bukkit.getPluginManager().callEvent(ev);
minigame.getMechanic().stopMinigame(minigame, caller);
minigame.setEnabled(false);
final ResourcePackModule module = (ResourcePackModule) minigame.getModule("ResourcePack");
if (module != null) {
if (module.isEnabled()) {
final ResourcePack pack = PLUGIN.getResourceManager().getResourcePack("empty");
if (pack.isValid()) {
for (final MinigamePlayer player : minigame.getPlayers()) {
player.applyResourcePack(pack);
}
}
}
}
minigame.saveMinigame();
}
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class MenuItemToolMode method onClick.
public ItemStack onClick() {
MinigamePlayer ply = getContainer().getViewer();
if (MinigameUtils.hasMinigameTool(ply)) {
MinigameTool tool = MinigameUtils.getMinigameTool(ply);
if (tool.getMode() != null)
tool.getMode().onUnsetMode(ply, tool);
tool.setMode(mode);
tool.getMode().onSetMode(ply, tool);
}
return getItem();
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class MenuItemInteger method onDoubleClick.
@Override
public ItemStack onDoubleClick() {
MinigamePlayer ply = getContainer().getViewer();
ply.setNoClose(true);
ply.getPlayer().closeInventory();
ply.sendMessage("Enter number value into chat for " + getName() + ", the menu will automatically reopen in 10s if nothing is entered.", MinigameMessageType.INFO);
String min = "N/A";
String max = "N/A";
if (this.min != null) {
min = this.min.toString();
}
if (this.max != null) {
max = this.max.toString();
}
ply.setManualEntry(this);
ply.sendInfoMessage("Min: " + min + ", Max: " + max);
getContainer().startReopenTimer(10);
return null;
}
Aggregations