Example #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);
    }
  }
Example #2
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());
          }
      }
    }
  }
Example #3
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();
       */
    }
  }
Example #4
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;
    }*/
  }
Example #5
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();
       */
    }
  }
Example #6
0
 @Override
 public boolean onCommand(CommandSender sender, Command cmd, String cmdl, String[] args) {
   if (sender instanceof Player) {
     if (!Client.getClient((Player) sender).isRanked()) {
       sender.sendMessage(ChatColor.RED + "No permission!");
       return false;
     }
   }
   sender.sendMessage(ChatColor.RED + "Are you sure you wish to turn off the server?");
   sender.sendMessage(ChatColor.RED + "Use /stoptheserver if you would like to.");
   return false;
 }
Example #7
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);
    }
  }
Example #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);
  }
Example #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);
    }
  }