use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class Events method playerRightClickEntity.
@EventHandler(ignoreCancelled = true)
private void playerRightClickEntity(PlayerInteractEntityEvent event) {
Player player = event.getPlayer();
MinigamePlayer ply = pdata.getMinigamePlayer(player);
ItemStack item = player.getEquipment().getItemInMainHand();
if (MinigameUtils.isMinigameTool(item) && player.hasPermission("minigame.tool")) {
if (ply.isInMinigame()) {
ply.sendInfoMessage("Quit the game to use the tool at this time");
return;
}
MinigameTool tool = new MinigameTool(item);
if (player.isSneaking()) {
tool.openMenu(ply);
event.setCancelled(true);
} else {
checkTool(tool, ply);
if (tool.getMinigame() != null && tool.getMode() != null) {
Minigame mg = tool.getMinigame();
tool.getMode().onEntityRightClick(ply, mg, TeamsModule.getMinigameModule(mg).getTeam(tool.getTeam()), event);
}
}
}
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class Events method manualItemEntry.
@EventHandler
private void manualItemEntry(AsyncPlayerChatEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply.isInMenu() && ply.getNoClose() && ply.getManualEntry() != null) {
event.setCancelled(true);
ply.setNoClose(false);
ply.getManualEntry().checkValidEntry(event.getMessage());
ply.setManualEntry(null);
}
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class Events method playerSpawn.
@EventHandler(priority = EventPriority.HIGHEST)
private void playerSpawn(PlayerRespawnEvent event) {
final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame()) {
final WeatherTimeModule mod = WeatherTimeModule.getMinigameModule(ply.getMinigame());
if (mod != null && mod.isUsingCustomWeather()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> ply.getPlayer().setPlayerWeather(mod.getCustomWeather()));
}
if (ply.getMinigame().getState() == MinigameState.ENDED) {
plugin.getPlayerManager().quitMinigame(ply, true);
}
}
if (ply.isRequiredQuit()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, ply::restorePlayerData);
event.setRespawnLocation(ply.getQuitPos());
ply.setRequiredQuit(false);
ply.setQuitPos(null);
}
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class Events method onFlyToggle.
@EventHandler(ignoreCancelled = true)
public void onFlyToggle(PlayerToggleFlightEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame() && (!ply.getMinigame().isSpectator(ply) || !ply.getMinigame().canSpectateFly()) && !ply.canFly()) {
event.setCancelled(true);
pdata.quitMinigame(ply, true);
event.getPlayer().sendMessage(ChatColor.RED + "[Minigames] " + ChatColor.WHITE + MinigameUtils.getLang("minigame.error.noFly"));
}
}
use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.
the class Events method playerShoot.
@EventHandler(ignoreCancelled = true)
private void playerShoot(ProjectileLaunchEvent event) {
if (event.getEntityType() == EntityType.SNOWBALL) {
Snowball snowball = (Snowball) event.getEntity();
if (snowball.getShooter() != null && snowball.getShooter() instanceof Player) {
MinigamePlayer ply = pdata.getMinigamePlayer((Player) snowball.getShooter());
if (ply == null)
return;
if (ply.isInMinigame() && ply.getMinigame().hasUnlimitedAmmo()) {
ItemStack mainhand = ply.getPlayer().getInventory().getItemInMainHand();
if (mainhand.getType() == Material.SNOW_BLOCK) {
mainhand.setAmount(16);
// todo
ply.getPlayer().updateInventory();
} else {
ply.getPlayer().getInventory().addItem(new ItemStack(Material.SNOWBALL, 1));
}
}
}
} else if (event.getEntityType() == EntityType.EGG) {
Egg egg = (Egg) event.getEntity();
if (egg.getShooter() != null && egg.getShooter() instanceof Player) {
MinigamePlayer ply = pdata.getMinigamePlayer((Player) egg.getShooter());
if (ply == null)
return;
if (ply.isInMinigame() && ply.getMinigame().hasUnlimitedAmmo()) {
ply.getPlayer().getInventory().addItem(new ItemStack(Material.EGG));
}
}
}
}
Aggregations