use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.
the class RecorderData method cartkMoveItem.
@EventHandler(ignoreCancelled = true)
private void cartkMoveItem(InventoryMoveItemEvent event) {
if (!hasRegenArea() || !minigame.hasPlayers())
return;
Location loc = null;
if (event.getInitiator().getHolder() instanceof HopperMinecart) {
loc = ((HopperMinecart) event.getInitiator().getHolder()).getLocation().clone();
if (blockInRegenArea(loc))
addEntity((Entity) event.getInitiator().getHolder(), null, false);
}
loc = null;
if (event.getDestination().getHolder() instanceof HopperMinecart) {
loc = ((HopperMinecart) event.getDestination().getHolder()).getLocation().clone();
if (blockInRegenArea(loc))
addEntity((Entity) event.getInitiator().getHolder(), null, false);
}
}
use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.
the class BasicRecorder method bucketFill.
@EventHandler(ignoreCancelled = true)
private void bucketFill(PlayerBucketFillEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame()) {
Minigame mgm = ply.getMinigame();
RecorderData d = mgm.getBlockRecorder();
if (((d.getWhitelistMode() && d.getWBBlocks().contains(event.getBlockClicked().getType())) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(event.getBlockClicked().getType()))) && mgm.canBlockBreak()) {
d.addBlock(event.getBlockClicked(), pdata.getMinigamePlayer(event.getPlayer()));
} else {
event.setCancelled(true);
}
}
}
use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.
the class BasicRecorder method takeItem.
@EventHandler(ignoreCancelled = true)
private void takeItem(PlayerInteractEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame() && event.getAction() == Action.RIGHT_CLICK_BLOCK && !ply.getMinigame().isSpectator(ply)) {
Minigame mgm = ply.getMinigame();
RecorderData d = mgm.getBlockRecorder();
if (event.getClickedBlock().getState() instanceof InventoryHolder) {
d.addBlock(event.getClickedBlock().getLocation().getBlock(), ply);
}
}
}
use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.
the class BasicRecorder method bucketEmpty.
@EventHandler(ignoreCancelled = true)
private void bucketEmpty(PlayerBucketEmptyEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame()) {
Minigame mgm = ply.getMinigame();
RecorderData d = mgm.getBlockRecorder();
if (((d.getWhitelistMode() && d.getWBBlocks().contains(event.getBlockClicked().getType())) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(event.getBlockClicked().getType()))) && mgm.canBlockPlace()) {
Location loc = new Location(event.getBlockClicked().getWorld(), event.getBlockFace().getModX() + event.getBlockClicked().getX(), event.getBlockFace().getModY() + event.getBlockClicked().getY(), event.getBlockFace().getModZ() + event.getBlockClicked().getZ());
d.addBlock(loc.getBlock(), pdata.getMinigamePlayer(event.getPlayer()));
} else {
event.setCancelled(true);
}
}
}
use of org.bukkit.event.EventHandler 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.isUsingCustomWeather()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
ply.getPlayer().setPlayerWeather(mod.getCustomWeather());
}
});
}
if (ply.getMinigame().getState() == MinigameState.ENDED) {
plugin.pdata.quitMinigame(ply, true);
}
}
if (ply.isRequiredQuit()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
ply.restorePlayerData();
}
});
event.setRespawnLocation(ply.getQuitPos());
ply.setRequiredQuit(false);
ply.setQuitPos(null);
}
}
Aggregations