org.bukkit.entity.minecart.ExplosiveMinecart Java Examples
The following examples show how to use
org.bukkit.entity.minecart.ExplosiveMinecart.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DestroyableMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
/** * This handler only checks to see if the event should be cancelled. It does not change the * state of any Destroyables. */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void testBlockChange(BlockTransformEvent event) { if(this.match.getWorld() != event.getWorld() || !this.anyDestroyableAffected(event)) { return; } // This is a temp fix until there is a tracker for placed minecarts (only dispensed are tracked right now) if((event.getCause() instanceof EntityExplodeEvent && ((EntityExplodeEvent) event.getCause()).getEntity() instanceof ExplosiveMinecart) || event.getCause() instanceof BlockPistonExtendEvent || event.getCause() instanceof BlockPistonRetractEvent) { event.setCancelled(true); return; } for(Destroyable destroyable : this.destroyables) { String reasonKey = destroyable.testBlockChange(event.getOldState(), event.getNewState(), ParticipantBlockTransformEvent.getPlayerState(event)); if(reasonKey != null) { event.setCancelled(true, new TranslatableComponent(reasonKey)); return; } } }
Example #2
Source File: DestroyableMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
/** * This handler only checks to see if the event should be cancelled. It does not change the state * of any Destroyables. */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void testBlockChange(BlockTransformEvent event) { if (this.match.getWorld() != event.getWorld() || !this.anyDestroyableAffected(event)) { return; } // This is a temp fix until there is a tracker for placed minecarts (only dispensed are tracked // right now) if ((event.getCause() instanceof EntityExplodeEvent && ((EntityExplodeEvent) event.getCause()).getEntity() instanceof ExplosiveMinecart) || event.getCause() instanceof BlockPistonExtendEvent || event.getCause() instanceof BlockPistonRetractEvent) { event.setCancelled(true); return; } for (Destroyable destroyable : this.destroyables) { String reasonKey = destroyable.testBlockChange( event.getOldState(), event.getNewState(), ParticipantBlockTransformEvent.getPlayerState(event)); if (reasonKey != null) { event.setCancelled(true, TranslatableComponent.of(reasonKey)); return; } } }
Example #3
Source File: CoreMatchModule.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void breakCheck(final BlockTransformEvent event) { if (event.getWorld() != this.match.getWorld()) return; ParticipantState player = ParticipantBlockTransformEvent.getPlayerState(event); Vector blockVector = BlockVectors.center(event.getNewState()).toVector(); for (Core core : this.cores) { if (!core.hasLeaked() && core.getCasingRegion().contains(blockVector)) { if (event.getNewState().getType() == Material.AIR) { if (player != null) { Competitor team = player.getParty(); if (team == core.getOwner()) { event.setCancelled(true, TranslatableComponent.of("core.damageOwn")); } else if (event.getOldState().getData().equals(core.getMaterial())) { this.match.callEvent(new CoreBlockBreakEvent(core, player, event.getOldState())); core.touch(player); // Note: team may not have touched a broken core if a different team broke it if (!core.isCompleted(team) && !core.hasTouched(team)) { this.match.callEvent(new GoalStatusChangeEvent(this.match, core)); } } } else if (event.getCause() instanceof EntityExplodeEvent) { // this is a temp fix until there is a tracker for placed minecarts (only dispensed are // tracked right now) if (((EntityExplodeEvent) event.getCause()).getEntity() instanceof ExplosiveMinecart) { event.setCancelled(true); } } else if (event.getCause() instanceof BlockPistonRetractEvent) { event.setCancelled(true); } } else if (event.getCause() instanceof BlockPistonExtendEvent) { event.setCancelled(true); } else if (event.getCause() instanceof BlockDispenseEvent) { event.setCancelled(true); } break; } } }
Example #4
Source File: CoreMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void breakCheck(final BlockTransformEvent event) { if(event.getWorld() != this.match.getWorld()) return; ParticipantState player = ParticipantBlockTransformEvent.getPlayerState(event); Vector blockVector = BlockUtils.center(event.getNewState()).toVector(); for(Core core : this.cores) { if(!core.hasLeaked() && core.getCasingRegion().contains(blockVector)) { if(event.getNewState().getType() == Material.AIR) { if(player != null) { Competitor team = player.getParty(); if(team == core.getOwner()) { event.setCancelled(true, new TranslatableComponent("match.core.damageOwn")); } else if (event.getOldState().getData().equals(core.getMaterial())) { this.match.getPluginManager().callEvent(new CoreBlockBreakEvent(core, player, event.getOldState())); core.touch(player); // Note: team may not have touched a broken core if a different team broke it if(!core.isCompleted(team) && !core.hasTouched(team)) { this.match.getPluginManager().callEvent(new GoalStatusChangeEvent(core)); } } } else if(event.getCause() instanceof EntityExplodeEvent) { // this is a temp fix until there is a tracker for placed minecarts (only dispensed are tracked right now) if(((EntityExplodeEvent) event.getCause()).getEntity() instanceof ExplosiveMinecart) { event.setCancelled(true); } } else if(event.getCause() instanceof BlockPistonRetractEvent) { event.setCancelled(true); } } else if(event.getCause() instanceof BlockPistonExtendEvent) { event.setCancelled(true); } else if(event.getCause() instanceof BlockDispenseEvent) { event.setCancelled(true); } break; } } }