Exemple #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);
    }
  }
Exemple #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);
 }
Exemple #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);
  }
Exemple #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);
   }
 }
Exemple #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);
   }
 }
Exemple #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);
   }
 }
Exemple #7
0
  @EventHandler(priority = EventPriority.LOW)
  public void onBlockChange(BlockChangeEvent event) {
    Map map = event.getMap();
    if (!Rixor.getRotation().getSlot().getMatch().isCurrentlyRunning()) {
      event.setCancelled(true);
      return;
    }

    if (event.getClient() != null) {
      Client client = event.getClient();

      if (event.getNewState().getLocation().getBlockY() > map.getMaxbuildheight()) {
        event.setCancelled(true);
        client.getPlayer().sendMessage(ChatColor.RED + "You have reached the maximum build height");
        return;
      }
    }

    List<Filter> filters = map.getFilters(event.getOldState().getLocation());
    for (Filter filter : filters) {
      if (event.getClient() != null) {
        if (filter.getParents().contains(FilterType.DENY_PLAYERS))
          if (filter.getAllowTeams().size() > 0) {
            event.setCancelled(true);
            if (filter.hasMessage())
              event.getClient().getPlayer().sendMessage(ChatColor.RED + filter.getMessage());
          }
      }
    }
  }
Exemple #8
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);
  }
Exemple #9
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);
    }
  }
Exemple #10
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);
    }
  }
Exemple #11
0
  @EventHandler(priority = EventPriority.LOW)
  public void onPlayerDropItems(PlayerDropItemEvent 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();
       */
    }
  }
Exemple #12
0
  @EventHandler(priority = EventPriority.LOW)
  public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    Client client = Client.getClient(player);

    if (client.isObserver() || !Rixor.getRotation().getSlot().getMatch().isCurrentlyRunning()) {
      event.setCancelled(true);
      if (event.getClickedBlock() != null
          && event.getClickedBlock().getType() == Material.CHEST
          && event.getAction() == Action.RIGHT_CLICK_BLOCK)
        player.openInventory(((Chest) event.getClickedBlock().getState()).getBlockInventory());
      return;
    }
    /*	if(client.isObserver() || !Rixor.getRotation().getSlot().getMatch().isCurrentlyRunning()) {
    	event.setCancelled(true);
    	if(event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.CHEST && event.getAction() == Action.RIGHT_CLICK_BLOCK)
    		player.openInventory(((Chest) event.getClickedBlock().getState()).getBlockInventory());
    	return;
    }*/
  }
Exemple #13
0
  @EventHandler(priority = EventPriority.LOW)
  public void onInventoryClick(InventoryClickEvent event) {
    if (event.getWhoClicked() instanceof Player == false) {
      event.setCancelled(true);
      return;
    }

    Player player = (Player) event.getWhoClicked();
    Client client = Client.getClient(player);

    if ((client.isObserver() || !Rixor.getRotation().getSlot().getMatch().isCurrentlyRunning())
        && event.getInventory().getType() != InventoryType.PLAYER) {
      event.setCancelled(true);
      return;
    }

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