use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class GameOverModule method startEndGameTimer.
public void startEndGameTimer() {
Minigames.getPlugin().getMinigameManager().sendMinigameMessage(getMinigame(), MinigameUtils.formStr("minigame.gameOverQuit", timer.getFlag()));
getMinigame().setState(MinigameState.ENDED);
List<MinigamePlayer> allPlys = new ArrayList<>(winners.size() + losers.size());
allPlys.addAll(losers);
allPlys.addAll(winners);
for (MinigamePlayer p : allPlys) {
if (!isInteractAllowed()) {
p.setCanInteract(false);
}
if (isHumiliationMode() && losers.contains(p)) {
p.getPlayer().getInventory().clear();
p.getPlayer().getInventory().setHelmet(null);
p.getPlayer().getInventory().setChestplate(null);
p.getPlayer().getInventory().setLeggings(null);
p.getPlayer().getInventory().setBoots(null);
for (PotionEffect potion : p.getPlayer().getActivePotionEffects()) {
p.getPlayer().removePotionEffect(potion.getType());
}
}
if (isInvincible()) {
p.setInvincible(true);
}
}
if (timer.getFlag() > 0) {
if (task != -1)
stopEndGameTimer();
task = Bukkit.getScheduler().scheduleSyncDelayedTask(Minigames.getPlugin(), () -> {
for (MinigamePlayer loser : new ArrayList<>(losers)) {
if (loser.isInMinigame())
Minigames.getPlugin().getPlayerManager().quitMinigame(loser, true);
}
for (MinigamePlayer winner : new ArrayList<>(winners)) {
if (winner.isInMinigame())
Minigames.getPlugin().getPlayerManager().quitMinigame(winner, true);
}
clearLosers();
clearWinners();
}, timer.getFlag() * 20);
}
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class PlayMGSound method playLoop.
private static void playLoop(MinigamePlayer player, MGSound sound) {
final MinigamePlayer fplayer = player;
final MGSound fsound = sound;
Bukkit.getScheduler().scheduleSyncDelayedTask(Minigames.getPlugin(), () -> {
fplayer.getPlayer().playSound(fplayer.getLocation(), fsound.getSound(), fsound.getVolume(), fsound.getPitch());
fsound.setTimesPlayed(fsound.getTimesPlayed() + 1);
if (fsound.getTimesPlayed() < fsound.getCount())
playLoop(fplayer, fsound);
}, sound.getDelay());
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class SpawnEntityAction method displayMenu.
@Override
public boolean displayMenu(MinigamePlayer player, Menu previous) {
Menu m = new Menu(3, "Spawn Entity", player);
m.addItem(new MenuItemPage("Back", MenuUtility.getBackMaterial(), previous), m.getSize() - 9);
List<String> options = new ArrayList<>();
for (EntityType type : EntityType.values()) {
if (type != EntityType.ITEM_FRAME && type != EntityType.LEASH_HITCH && type != EntityType.PLAYER && type != EntityType.LIGHTNING && type != EntityType.PAINTING && type != EntityType.UNKNOWN && type != EntityType.DROPPED_ITEM)
options.add(MinigameUtils.capitalize(type.toString().replace("_", " ")));
}
m.addItem(new MenuItemList("Entity Type", Material.SKELETON_SKULL, new Callback<String>() {
@Override
public void setValue(String value) {
type.setFlag(value.toUpperCase().replace(" ", "_"));
settings.clear();
addBaseSettings();
}
@Override
public String getValue() {
return MinigameUtils.capitalize(type.getFlag().replace("_", " "));
}
}, options));
m.addItem(new MenuItemDecimal("X Velocity", Material.ARROW, new Callback<Double>() {
@Override
public void setValue(Double value) {
settings.put("velocityx", value.toString());
}
@Override
public Double getValue() {
return Double.valueOf(settings.get("velocityx"));
}
}, 0.5, 1, null, null));
m.addItem(new MenuItemDecimal("Y Velocity", Material.ARROW, new Callback<Double>() {
@Override
public void setValue(Double value) {
settings.put("velocityy", value.toString());
}
@Override
public Double getValue() {
return Double.valueOf(settings.get("velocityy"));
}
}, 0.5, 1, null, null));
m.addItem(new MenuItemDecimal("Z Velocity", Material.ARROW, new Callback<Double>() {
@Override
public void setValue(Double value) {
settings.put("velocityz", value.toString());
}
@Override
public Double getValue() {
return Double.valueOf(settings.get("velocityz"));
}
}, 0.5, 1, null, null));
m.addItem(new MenuItemNewLine());
final Menu eSet = new Menu(3, "Settings", player);
final MenuItemPage backButton = new MenuItemPage("Back", MenuUtility.getBackMaterial(), m);
final MenuItemCustom cus = new MenuItemCustom("Entity Settings", Material.CHEST);
final MinigamePlayer fply = player;
cus.setClick(object -> {
if (type.getFlag().equals("ZOMBIE")) {
eSet.clearMenu();
eSet.addItem(backButton, eSet.getSize() - 9);
livingEntitySettings(eSet);
eSet.displayMenu(fply);
return null;
}
return cus.getItem();
});
m.addItem(cus);
m.displayMenu(player);
return true;
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class MinigamesTest method onJoinMinigame.
@Test
public void onJoinMinigame() {
assertNotSame(player.getLocation(), game.getLobbyPosition());
plugin.getPlayerManager().addMinigamePlayer(player);
MinigamePlayer mplayer = plugin.getPlayerManager().getMinigamePlayer(player.getUniqueId());
plugin.getPlayerManager().joinMinigame(mplayer, game, false, 0D);
LobbySettingsModule module = (LobbySettingsModule) game.getModule("LobbySettings");
player.assertLocation(lobby, 0);
assertTrue(module.isTeleportOnStart());
assertNotSame(player.getLocation(), game.getStartLocations().indexOf(0));
server.getScheduler().performTicks(200L);
player.assertLocation(start, 0);
server.getScheduler().performTicks(200L);
player.assertLocation(quit, 0);
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class RegionEvents method playerDeath.
@EventHandler
private void playerDeath(PlayerDeathEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getEntity());
boolean pvp = false;
MinigamePlayer killer = null;
if (ply == null)
return;
if (ply.isInMinigame()) {
if (event.getEntity().getKiller() != null) {
killer = pdata.getMinigamePlayer(event.getEntity().getKiller());
if (killer != null && killer.isInMinigame()) {
pvp = true;
}
}
for (Node node : RegionModule.getMinigameModule(ply.getMinigame()).getNodes()) {
node.execute(Triggers.getTrigger("DEATH"), ply);
if (pvp) {
node.execute(Triggers.getTrigger("PLAYER_KILL"), killer);
node.execute(Triggers.getTrigger("PLAYER_KILLED"), ply);
}
}
for (Region region : RegionModule.getMinigameModule(ply.getMinigame()).getRegions()) {
if (region.hasPlayer(ply))
region.execute(Triggers.getTrigger("DEATH"), ply);
if (pvp) {
region.execute(Triggers.getTrigger("PLAYER_KILL"), killer);
region.execute(Triggers.getTrigger("PLAYER_KILLED"), ply);
}
}
}
}
Aggregations