use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.
the class BasicRecorder method vehicleDestroy.
@EventHandler(ignoreCancelled = true)
private void vehicleDestroy(VehicleDestroyEvent event) {
if (event.getAttacker() != null) {
if (event.getAttacker() instanceof Player) {
Player ply = (Player) event.getAttacker();
Minigame mg = pdata.getMinigamePlayer(ply).getMinigame();
if (pdata.getMinigamePlayer(ply).isInMinigame()) {
if (!mg.getBlockRecorder().hasEntity(event.getVehicle())) {
mg.getBlockRecorder().addEntity(event.getVehicle(), pdata.getMinigamePlayer(ply), false);
}
}
}
}
}
use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.
the class BasicRecorder method blockPlace.
@EventHandler(priority = EventPriority.HIGH)
private void blockPlace(BlockPlaceEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame() && !event.isCancelled()) {
if (!ply.getMinigame().hasStarted() || ply.isLatejoining()) {
event.setCancelled(true);
return;
}
Minigame mgm = ply.getMinigame();
RecorderData d = mgm.getBlockRecorder();
if (((d.getWhitelistMode() && d.getWBBlocks().contains(event.getBlock().getType())) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(event.getBlock().getType()))) && mgm.canBlockPlace()) {
d.addBlock(event.getBlockReplacedState(), ply);
} else {
event.setCancelled(true);
}
}
}
use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.
the class BasicRecorder method igniteblock.
@EventHandler(ignoreCancelled = true)
public void igniteblock(BlockIgniteEvent event) {
MinigamePlayer ply = null;
if (event.getPlayer() != null)
ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame() && (event.getCause() == IgniteCause.FIREBALL || event.getCause() == IgniteCause.FLINT_AND_STEEL)) {
Minigame mgm = ply.getMinigame();
RecorderData d = mgm.getBlockRecorder();
if (((d.getWhitelistMode() && d.getWBBlocks().contains(Material.FIRE)) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(Material.FIRE))) && mgm.canBlockPlace()) {
d.addBlock(event.getBlock(), pdata.getMinigamePlayer(event.getPlayer()));
} else {
event.setCancelled(true);
}
}
}
use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.
the class BasicRecorder method blockBreak.
@EventHandler(priority = EventPriority.HIGH)
private void blockBreak(BlockBreakEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame()) {
if (!ply.getMinigame().hasStarted() || ply.isLatejoining()) {
event.setCancelled(true);
return;
}
Minigame mgm = ply.getMinigame();
RecorderData d = mgm.getBlockRecorder();
if (((d.getWhitelistMode() && d.getWBBlocks().contains(event.getBlock().getType())) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(event.getBlock().getType()))) && mgm.canBlockBreak()) {
if (event.getBlock().getState() instanceof Sign) {
Sign sign = (Sign) event.getBlock().getState();
if (sign.getLine(0).equalsIgnoreCase(ChatColor.DARK_BLUE + "[Minigame]")) {
event.setCancelled(true);
} else {
d.addBlock(event.getBlock(), ply);
if (!mgm.canBlocksdrop()) {
event.setCancelled(true);
event.getBlock().setType(Material.AIR);
}
}
} else {
Location above = event.getBlock().getLocation().clone();
above.setY(above.getY() + 1);
d.addBlock(event.getBlock(), ply);
if (!mgm.canBlocksdrop()) {
event.setCancelled(true);
event.getBlock().setType(Material.AIR);
}
}
} else {
event.setCancelled(true);
}
}
}
use of au.com.mineauz.minigames.minigame.Minigame in project Minigames by AddstarMC.
the class BasicRecorder method paintingPlace.
@EventHandler(ignoreCancelled = true)
private void paintingPlace(HangingPlaceEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply.isInMinigame()) {
Minigame mgm = ply.getMinigame();
RecorderData d = mgm.getBlockRecorder();
if (((d.getWhitelistMode() && d.getWBBlocks().contains(Material.PAINTING)) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(Material.PAINTING))) || ((d.getWhitelistMode() && d.getWBBlocks().contains(Material.ITEM_FRAME)) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(Material.ITEM_FRAME)))) {
d.addEntity(event.getEntity(), ply, true);
} else {
event.setCancelled(true);
}
}
}
Aggregations