Ejemplo n.º 1
0
  @EventHandler(priority = EventPriority.LOW)
  public void onBlockPlace(BlockPlaceEvent event) {
    Player player = event.getPlayer();
    Client client = Client.getClient(player);

    if (client.isObserver() || !Rixor.getRotation().getSlot().getMatch().isCurrentlyRunning()) {
      event.setCancelled(true);
      return;
    }

    if (event.getBlockPlaced().getType() == Material.TNT
        && Rixor.getRotation().getSlot().getMap().getTntsettings().isInstantIgnite()) {
      event.getBlockPlaced().setType(Material.AIR);
      TNTPrimed tnt =
          event
              .getBlockPlaced()
              .getWorld()
              .spawn(event.getBlockPlaced().getLocation(), TNTPrimed.class);
    }

    if (!client.isObserver()) {
      Map map = Rixor.getRotation().getSlot().getMap();
      BlockChangeEvent change =
          new BlockChangeEvent(
              event, map, client, event.getBlockReplacedState(), event.getBlockPlaced().getState());
      Rixor.callEvent(change);
    }
  }
Ejemplo n.º 2
0
 @EventHandler(priority = EventPriority.LOW)
 public void onBlockSpread(BlockSpreadEvent event) {
   Map map = Rixor.getRotation().getSlot().getMap();
   BlockChangeEvent change =
       new BlockChangeEvent(event, map, null, event.getBlock().getState(), event.getNewState());
   Rixor.callEvent(change);
 }
Ejemplo n.º 3
0
  @SuppressWarnings("deprecation")
  @EventHandler(priority = EventPriority.LOW)
  public void onBlockFade(BlockFadeEvent event) {
    Map map = Rixor.getRotation().getSlot().getMap();
    BlockState newState = event.getBlock().getState();
    newState.setData(new MaterialData(Material.AIR, (byte) 0));

    BlockChangeEvent change =
        new BlockChangeEvent(event, map, null, event.getBlock().getState(), newState);
    Rixor.callEvent(change);
  }
Ejemplo n.º 4
0
 @SuppressWarnings("deprecation")
 @EventHandler(priority = EventPriority.LOW)
 public void onBlockPistonRetract(BlockPistonRetractEvent event) {
   Map map = Rixor.getRotation().getSlot().getMap();
   if (event.isSticky()) {
     BlockState state =
         event.getBlock().getWorld().getBlockAt(event.getRetractLocation()).getState();
     BlockState newState = state;
     newState.setData(new MaterialData(Material.AIR, (byte) 0));
     BlockChangeEvent change = new BlockChangeEvent(event, map, null, state, newState);
     Rixor.callEvent(change);
   }
 }
Ejemplo n.º 5
0
 @SuppressWarnings("deprecation")
 @EventHandler(priority = EventPriority.LOW)
 public void onBlockPistonExtend(BlockPistonExtendEvent event) {
   Map map = Rixor.getRotation().getSlot().getMap();
   for (Block block : event.getBlocks()) {
     BlockState newState = block.getRelative(event.getDirection()).getState();
     newState.setData(new MaterialData(block.getType(), block.getData()));
     BlockChangeEvent change =
         new BlockChangeEvent(
             event, map, null, block.getRelative(event.getDirection()).getState(), newState);
     Rixor.callEvent(change);
   }
 }
Ejemplo n.º 6
0
 @EventHandler(priority = EventPriority.LOW)
 public void onBlockFromTo(BlockFromToEvent event) {
   Map map = Rixor.getRotation().getSlot().getMap();
   if (event.getToBlock().getType() == Material.WATER) {
     return;
   }
   if (event.getToBlock().getType() != event.getBlock().getType()) {
     BlockChangeEvent change =
         new BlockChangeEvent(
             event, map, null, event.getBlock().getState(), event.getToBlock().getState());
     Rixor.callEvent(change);
   }
 }
Ejemplo n.º 7
0
  @SuppressWarnings("deprecation")
  @EventHandler(priority = EventPriority.LOW)
  public void onBucketEmpty(PlayerBucketEmptyEvent event) {
    Player player = event.getPlayer();
    Client client = Client.getClient(player);
    Block block = event.getBlockClicked().getRelative(event.getBlockFace());
    Map map = Rixor.getRotation().getSlot().getMap();

    BlockState newState = block.getState();
    Material update = Material.LAVA;
    if (event.getBucket() == Material.WATER_BUCKET) update = Material.WATER;
    newState.setData(new MaterialData(update, (byte) 0));

    BlockState oldState = block.getState();
    BlockChangeEvent change = new BlockChangeEvent(event, map, client, oldState, newState);
    Rixor.callEvent(change);
  }
Ejemplo n.º 8
0
  @SuppressWarnings("deprecation")
  @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
  public void onEntityExplodeNormal(EntityExplodeEvent event) {
    Map map = Rixor.getRotation().getSlot().getMap();

    Client client = null;
    if (event.getEntity() instanceof TNTPrimed) {
      TNTPrimed tnt = (TNTPrimed) event.getEntity();
      if (tnt.getSource() instanceof Player) client = Client.getClient((Player) tnt.getSource());
    }

    for (Block block : event.blockList()) {
      BlockState newState = block.getState();
      newState.setData(new MaterialData(Material.AIR, (byte) 0));
      BlockChangeEvent change =
          new BlockChangeEvent(event, map, client, block.getState(), newState);
      Rixor.callEvent(change);
    }
  }
Ejemplo n.º 9
0
  @SuppressWarnings("deprecation")
  @EventHandler(priority = EventPriority.LOW)
  public void onBlockBreak(BlockBreakEvent event) {
    Player player = event.getPlayer();
    Client client = Client.getClient(player);

    if (client.isObserver() || !Rixor.getRotation().getSlot().getMatch().isCurrentlyRunning()) {
      event.setCancelled(true);
      return;
    }

    if (!client.isObserver()) {
      Map map = Rixor.getRotation().getSlot().getMap();

      BlockState newState = event.getBlock().getState();
      newState.setData(new MaterialData(Material.AIR, (byte) 0));

      BlockChangeEvent change =
          new BlockChangeEvent(event, map, client, event.getBlock().getState(), newState);
      Rixor.callEvent(change);
    }
  }