use of au.com.mineauz.minigames.MinigamePlayer in project Minigames by AddstarMC.
the class SetTeamScoreAction method checkScore.
private void checkScore(MinigamePlayer player) {
if (player.getTeam().getScore() >= player.getMinigame().getMaxScore()) {
if (player.getMinigame().isTeamGame()) {
List<MinigamePlayer> w;
List<MinigamePlayer> l;
w = new ArrayList<>(player.getTeam().getPlayers());
l = new ArrayList<>(player.getMinigame().getPlayers().size() - player.getTeam().getPlayers().size());
for (Team t : TeamsModule.getMinigameModule(player.getMinigame()).getTeams()) {
if (t != player.getTeam())
l.addAll(t.getPlayers());
}
Minigames.plugin.pdata.endMinigame(player.getMinigame(), w, l);
}
}
}
use of au.com.mineauz.minigames.MinigamePlayer in project Minigames by AddstarMC.
the class MultiplayerType method joinMinigame.
@Override
public boolean joinMinigame(MinigamePlayer player, Minigame mgm) {
if (!LobbySettingsModule.getMinigameModule(mgm).canInteractPlayerWait())
player.setCanInteract(false);
if (!LobbySettingsModule.getMinigameModule(mgm).canMovePlayerWait())
player.setFrozen(true);
if (!mgm.isWaitingForPlayers() && !mgm.hasStarted()) {
if (mgm.getMpTimer() == null && mgm.getPlayers().size() == mgm.getMinPlayers()) {
mgm.setMpTimer(new MultiplayerTimer(mgm));
mgm.getMpTimer().startTimer();
if (mgm.getPlayers().size() == mgm.getMaxPlayers()) {
mgm.getMpTimer().setPlayerWaitTime(0);
mdata.sendMinigameMessage(mgm, MinigameUtils.getLang("minigame.skipWaitTime"), "info", null);
}
} else if (mgm.getMpTimer() != null && mgm.getPlayers().size() == mgm.getMaxPlayers()) {
mgm.getMpTimer().setPlayerWaitTime(0);
mdata.sendMinigameMessage(mgm, MinigameUtils.getLang("minigame.skipWaitTime"), "info", null);
} else if (mgm.getMpTimer() == null) {
int neededPlayers = mgm.getMinPlayers() - mgm.getPlayers().size();
mdata.sendMinigameMessage(mgm, MinigameUtils.formStr("minigame.waitingForPlayers", neededPlayers), null, null);
}
} else if (mgm.hasStarted()) {
player.setLatejoining(true);
//TODO: Late join delay variable
player.sendMessage(MinigameUtils.formStr("minigame.lateJoin", 5));
final MinigamePlayer fply = player;
final Minigame fmgm = mgm;
if (mgm.isTeamGame()) {
Team smTeam = null;
for (Team team : TeamsModule.getMinigameModule(mgm).getTeams()) {
if (smTeam == null || team.getPlayers().size() < smTeam.getPlayers().size()) {
smTeam = team;
}
}
smTeam.addPlayer(player);
player.sendMessage(String.format(smTeam.getAssignMessage(), smTeam.getChatColor() + smTeam.getDisplayName()), null);
final Team fteam = smTeam;
player.setLateJoinTimer(Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (fply.isInMinigame()) {
List<Location> locs = new ArrayList<Location>();
if (TeamsModule.getMinigameModule(fmgm).hasTeamStartLocations()) {
locs.addAll(fteam.getStartLocations());
} else {
locs.addAll(fmgm.getStartLocations());
}
Collections.shuffle(locs);
fply.teleport(locs.get(0));
fply.getLoadout().equiptLoadout(fply);
fply.setLatejoining(false);
fply.setFrozen(false);
fply.setCanInteract(true);
fply.setLateJoinTimer(-1);
}
}
}, //TODO: Latejoin variable
5 * 20));
} else {
player.setLateJoinTimer(Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (fply.isInMinigame()) {
List<Location> locs = new ArrayList<Location>(fmgm.getStartLocations());
Collections.shuffle(locs);
fply.teleport(locs.get(0));
fply.getLoadout().equiptLoadout(fply);
fply.setLatejoining(false);
fply.setFrozen(false);
fply.setCanInteract(true);
fply.setLateJoinTimer(-1);
}
}
}, //TODO: Latejoin variable
5 * 20));
}
player.getPlayer().setScoreboard(mgm.getScoreboardManager());
mgm.setScore(player, 1);
mgm.setScore(player, 0);
}
return true;
}
use of au.com.mineauz.minigames.MinigamePlayer in project Minigames by AddstarMC.
the class AddScoreAction method checkScore.
private void checkScore(MinigamePlayer player) {
if (player.getMinigame().getMaxScorePerPlayer() >= player.getScore() || player.getTeam().getScore() >= player.getMinigame().getMaxScore()) {
List<MinigamePlayer> w;
List<MinigamePlayer> l;
if (player.getMinigame().isTeamGame()) {
w = new ArrayList<>(player.getTeam().getPlayers());
l = new ArrayList<>(player.getMinigame().getPlayers().size() - player.getTeam().getPlayers().size());
for (Team t : TeamsModule.getMinigameModule(player.getMinigame()).getTeams()) {
if (t != player.getTeam())
l.addAll(t.getPlayers());
}
} else {
w = new ArrayList<>(1);
l = new ArrayList<>(player.getMinigame().getPlayers().size());
w.add(player);
l.addAll(player.getMinigame().getPlayers());
l.remove(player);
}
Minigames.plugin.pdata.endMinigame(player.getMinigame(), w, l);
}
}
use of au.com.mineauz.minigames.MinigamePlayer in project Minigames by AddstarMC.
the class RegionEvents method itemPickupEvent.
@EventHandler(ignoreCancelled = true)
private void itemPickupEvent(PlayerPickupItemEvent event) {
final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame()) {
final Trigger trig = Triggers.getTrigger("ITEM_PICKUP");
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (!ply.isInMinigame()) {
return;
}
for (Node node : getRegionModule(ply.getMinigame()).getNodes()) {
node.execute(trig, ply);
}
for (Region region : getRegionModule(ply.getMinigame()).getRegions()) {
if (region.hasPlayer(ply)) {
region.execute(trig, ply);
}
}
}
});
}
}
use of au.com.mineauz.minigames.MinigamePlayer in project Minigames by AddstarMC.
the class Region method changeTickDelay.
public void changeTickDelay(long delay) {
removeTickTask();
taskDelay = delay;
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Minigames.plugin, new Runnable() {
@Override
public void run() {
List<MinigamePlayer> plys = new ArrayList<MinigamePlayer>(players);
for (MinigamePlayer player : plys) {
execute(Triggers.getTrigger("TICK"), player);
}
}
}, 0, delay);
}
Aggregations