Esempio n. 1
0
  @Override
  public void executeCommand(Player admin, String[] params) {
    if (admin.getAccessLevel() < AdminConfig.COMMAND_APPLY_PRESET) {
      PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
      return;
    }

    if (params.length == 0 || params.length > 1) {
      PacketSendUtility.sendMessage(admin, "syntax //preset <name>");
      return;
    }

    VisibleObject target = admin.getTarget();
    Player player = null;

    if (target == null) player = admin;
    else if (!(target instanceof Player)) {
      PacketSendUtility.sendMessage(admin, "Presets can be applied only on players!");
      return;
    } else {
      player = (Player) target;
    }

    String presetName = params[0];

    PresetTemplate template = DataManager.CUSTOM_PRESET_DATA.getPresetTemplate(presetName);
    if (template == null) {
      PacketSendUtility.sendMessage(admin, "No such preset!");
      return;
    }
    if (template.getGender().ordinal() != player.getCommonData().getGender().ordinal()
        || template.getRace().ordinal() != player.getCommonData().getRace().ordinal()) {
      PacketSendUtility.sendMessage(admin, "Preset can not be applied on current gender or race!");
      return;
    }

    PlayerAppearance.loadDetails(player.getPlayerAppearance(), template.getDetail());
    if (template.getFaceType() > 0) player.getPlayerAppearance().setFace(template.getFaceType());
    if (template.getHairType() > 0) player.getPlayerAppearance().setHair(template.getHairType());
    if (template.getHairRGB() != null)
      player.getPlayerAppearance().setHairRGB(getDyeColor(template.getHairRGB()));
    if (template.getLipsRGB() != null)
      player.getPlayerAppearance().setLipRGB(getDyeColor(template.getLipsRGB()));
    if (template.getSkinRGB() != null)
      player.getPlayerAppearance().setSkinRGB(getDyeColor(template.getSkinRGB()));
    if (template.getHeight() > 0) player.getPlayerAppearance().setHeight(template.getHeight());

    DAOManager.getDAO(PlayerAppearanceDAO.class).store(player);

    player.clearKnownlist();
    PacketSendUtility.sendPacket(player, new SM_PLAYER_INFO(player, false));
    player.updateKnownlist();
  }
Esempio n. 2
0
  @Override
  public void executeCommand(Player admin, String[] params) {
    if (admin.getAccessLevel() < AdminConfig.COMMAND_ADDCUBE) {
      PacketSendUtility.sendMessage(
          admin, LanguageHandler.translate(CustomMessageId.COMMAND_NOT_ENOUGH_RIGHTS));
      return;
    }

    if (params.length != 1) {
      PacketSendUtility.sendMessage(
          admin, LanguageHandler.translate(CustomMessageId.COMMAND_ADDCUBE_SYNTAX));
      return;
    }

    Player receiver = null;

    receiver = World.getInstance().findPlayer(Util.convertName(params[0]));

    if (receiver == null) {
      PacketSendUtility.sendMessage(
          admin,
          LanguageHandler.translate(
              CustomMessageId.PLAYER_NOT_ONLINE, Util.convertName(params[0])));
      return;
    }

    if (receiver != null) {
      if (receiver.getCubeSize() < 9) {
        CubeExpandService.expand(receiver);
        PacketSendUtility.sendMessage(
            admin,
            LanguageHandler.translate(
                CustomMessageId.COMMAND_ADDCUBE_ADMIN_SUCCESS, receiver.getName()));
        PacketSendUtility.sendMessage(
            receiver,
            LanguageHandler.translate(
                CustomMessageId.COMMAND_ADDCUBE_PLAYER_SUCCESS, admin.getName()));
      } else {
        PacketSendUtility.sendMessage(
            admin,
            LanguageHandler.translate(CustomMessageId.COMMAND_ADDCUBE_FAILURE, receiver.getName()));
        return;
      }
    }
  }