Package org.bukkit.event.vehicle

Examples of org.bukkit.event.vehicle.VehicleExitEvent


    @SuppressWarnings("serial")
    @Test
    public void testOnVehicleExit() {

        VehicleExitEvent event = mock(VehicleExitEvent.class);
        Boat boat = mock(Boat.class);

        Server server = mock(Server.class);
        when(server.getName()).thenReturn("Mock");
        when(server.getVersion()).thenReturn("MockVer");
        when(server.getBukkitVersion()).thenReturn("MockVer");
        when(server.getLogger()).thenReturn(Logger.getLogger(Logger.GLOBAL_LOGGER_NAME));
        when(server.getScheduler()).thenReturn(mock(BukkitScheduler.class));

        Bukkit.setServer(server);

        Location location = mock(Location.class);

        World world = mock(World.class);
        when(location.getWorld()).thenReturn(world);

        when(boat.getLocation()).thenReturn(location);
        when(boat.isValid()).thenReturn(true);

        when(event.getVehicle()).thenReturn(boat);

        ExitRemover rem = new ExitRemover();
        rem.onVehicleExit(event);

        verify(server).getScheduler();

        CraftBookPlugin plugin = mock(CraftBookPlugin.class);
        BukkitConfiguration config = mock(BukkitConfiguration.class);

        when(plugin.getConfiguration()).thenReturn(config);
        rem.giveItem = true;

        CraftBookPlugin.setInstance(plugin);

        rem.new BoatRemover(null, boat).run();

        LivingEntity player = mock(LivingEntity.class);

        when(player.getLocation()).thenReturn(location);
        when(event.getExited()).thenReturn(player);

        rem.new BoatRemover(player, boat).run();

        player = mock(Player.class);

        when(player.getLocation()).thenReturn(location);
        when(event.getExited()).thenReturn(player);

        Inventory inv = mock(PlayerInventory.class);

        when(inv.addItem(Mockito.<ItemStack[]>any())).thenReturn(new HashMap<Integer, ItemStack>(){{put(0,null);}});
View Full Code Here


  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  private void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    if (event.getPlayer().getVehicle() == event.getRightClicked() && event.getRightClicked() instanceof Vehicle) {
      // Call a player exit event
      final Vehicle vehicle = (Vehicle) event.getRightClicked();
      event.setCancelled(CommonUtil.callEvent(new VehicleExitEvent(vehicle, event.getPlayer())).isCancelled());
    }
  }
View Full Code Here

TOP

Related Classes of org.bukkit.event.vehicle.VehicleExitEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.