Пример #1
0
  @Override
  public void OnPlayerDeathEvent(RunsafePlayerDeathEvent event) {
    IPlayer killer = event.getEntity().getKiller();

    if (killer != null && killer.isInUniverse("survival") && event.getLevelAmount() >= 30)
      award(killer);
  }
Пример #2
0
  @Override
  public void OnPlayerDamage(IPlayer player, RunsafeEntityDamageEvent event) {
    List<Hook> hooks = HookHandler.getHooks(HookType.PLAYER_DAMAGE);

    if (hooks != null) {
      IWorld damageWorld = player.getWorld();

      LuaString playerName = LuaValue.valueOf(player.getName());
      LuaString damageCause = LuaValue.valueOf(event.getCause().name());
      LuaValue damage = LuaValue.valueOf(event.getDamage());

      for (Hook hook : hooks) {
        IWorld world = hook.getWorld();
        if (world == null || !world.isWorld(damageWorld)) return;

        LuaTable table = new LuaTable();
        table.set("player", playerName);
        table.set("playerHealth", player.getHealth());
        table.set("playerMaxHealth", player.getMaxHealth());
        table.set("damage", damage);
        table.set("cause", damageCause);

        hook.execute(table);
      }
    }
  }
Пример #3
0
  private void handleItemHook(Hook hook, IPlayer player, RunsafeMeta item) {
    IWorld hookWorld = hook.getWorld();
    if (hookWorld.isWorld(player.getWorld())) {
      LuaTable table = new LuaTable();
      table.set("player", player.getName());
      table.set("itemID", item.getItemId());
      table.set("itemName", item.hasDisplayName() ? item.getDisplayName() : item.getNormalName());

      hook.execute(table);
    }
  }
 @Override
 public String OnExecute(ICommandExecutor executor, IArgumentList parameters) {
   IPlayer player = parameters.getValue("player");
   if (player == null) return null;
   this.history.save(player);
   player.getInventory().clear();
   player.updateInventory();
   if (executor instanceof IPlayer && executor.getName().equals(player.getName()))
     return "&2Your inventory has been cleared.";
   return "&2Inventory for " + player.getPrettyName() + " &2cleared.";
 }
Пример #5
0
  @Override
  public boolean OnBlockBreak(IPlayer player, IBlock block) {
    List<Hook> hooks = HookHandler.getHooks(HookType.BLOCK_BREAK);

    if (hooks != null) {
      ILocation blockLocation = block.getLocation();
      String blockWorld = blockLocation.getWorld().getName();
      for (Hook hook : hooks) {
        IWorld world = hook.getWorld();
        if (world != null && !blockWorld.equals(world.getName())) return true;

        LuaTable table = new LuaTable();
        if (player != null) table.set("player", LuaValue.valueOf(player.getName()));

        table.set("world", LuaValue.valueOf(blockWorld));
        table.set("x", LuaValue.valueOf(blockLocation.getBlockX()));
        table.set("y", LuaValue.valueOf(blockLocation.getBlockY()));
        table.set("z", LuaValue.valueOf(blockLocation.getBlockZ()));
        table.set("blockID", LuaValue.valueOf(block.getMaterial().getItemID()));
        table.set("blockData", LuaValue.valueOf(((RunsafeBlock) block).getData()));

        hook.execute(table);
      }
    }
    return true;
  }
Пример #6
0
  private void playerLogEvent(IPlayer player, HookType type) {
    List<Hook> hooks = HookHandler.getHooks(type);

    if (hooks != null)
      for (Hook hook : hooks)
        if (hook.getPlayerName().equalsIgnoreCase(player.getName())) hook.execute();
  }
Пример #7
0
 @Override
 public String OnExecute(IPlayer executor, IArgumentList parameters) {
   if (core.isEnabled())
     return Constants.MSG_COLOR + "Only use this command when headhunters is disabled!";
   equipmentRepository.setEquipment(executor.getInventory());
   equipmentHandler.update();
   return Constants.MSG_COLOR + "Successfully set the standard equipment";
 }
Пример #8
0
  @Override
  public void OnPlayerDeathEvent(RunsafePlayerDeathEvent event) {
    List<Hook> hooks = HookHandler.getHooks(HookType.PLAYER_DEATH);

    if (hooks != null) {
      IPlayer player = event.getEntity();

      for (Hook hook : hooks) {
        IWorld hookWorld = hook.getWorld();
        if (hookWorld.isWorld(player.getWorld())) {
          LuaTable table = new LuaTable();
          table.set("player", LuaValue.valueOf(player.getName()));

          hook.execute(table);
        }
      }
    }
  }
Пример #9
0
  private void concludeEvent(IPlayer winner) {
    if (winner == null) {
      // We have no winner, conclude without a winner.
      server.broadcastMessage(config.getConcludeNoWinnerMessage());
    } else {
      // We have a winner! Woooo!
      server.broadcastMessage(
          config.getConcludeMessage().replaceAll("<player>", winner.getPrettyName()));
      new TournamentWinEvent(winner).Fire(); // Fire win event.
      winner.give(mountHandler.getMountItem()); // Give the winner a squid mount.

      RunsafeMeta loot = Item.Materials.Emerald.getItem();
      loot.setAmount(10);
      winner.give(loot);
    }
    progress.clear(); // Clear all progress.
    stopEvent(); // Stop the event.
  }
Пример #10
0
  @Override
  public void OnPlayerChatEvent(RunsafePlayerChatEvent event) {
    List<Hook> hooks = HookHandler.getHooks(HookType.CHAT_MESSAGE);

    if (hooks != null) {
      IPlayer player = event.getPlayer();
      IWorld playerWorld = player.getWorld();

      if (playerWorld == null) return;

      for (Hook hook : hooks) {
        if (hook.getWorld().isWorld(player.getWorld())) {
          LuaTable table = new LuaTable();
          table.set("player", LuaValue.valueOf(player.getName()));
          table.set("message", LuaValue.valueOf(event.getMessage()));

          hook.execute(table);
        }
      }
    }
  }
Пример #11
0
  @Override
  public boolean isPlayerHidden(IPlayer viewer, IPlayer target) {
    // DEBUG
    boolean hasPermission = viewer.hasPermission("vanish.see");
    boolean isVanished = vanishNoPacket.isVanished((Player) ObjectUnwrapper.convert(target));
    debug.debugInfo(
        hasPermission
            ? "The viewer has override perms"
            : "The viewer does not have override perms");
    debug.debugInfo(isVanished ? "The target is not vanished" : "The target is vanished");
    // DEBUG END

    return isVanished && !hasPermission;
  }
Пример #12
0
 @Override
 public String OnExecute(IPlayer executor, IArgumentList parameters) {
   executor.Launch(ProjectileEntity.PrimedTNT);
   return null;
 }
Пример #13
0
 public void registerCatch(IPlayer player) {
   String playerName = player.getName();
   int newProgress = progress.containsKey(playerName) ? progress.get(playerName) + 1 : 1;
   if (newProgress == config.getFishToWin()) concludeEvent(player);
   else progress.put(playerName, newProgress);
 }