예제 #1
0
파일: BuySign.java 프로젝트: Nekocraft/Saga
  @Override
  public boolean complete(Building building) throws SignException {

    super.complete(building);

    if (stored == null) {
      SagaLogger.nullField(this, "stored");
      stored = 0.0;
    }

    if (maxStored == null) {
      SagaLogger.nullField(this, "maxStored");
      maxStored = 0.0;
    }

    initialiseFields();

    return true;
  }
예제 #2
0
  /**
   * Loads configuration.
   *
   * @return configuration
   */
  public static ExperienceConfiguration load() {

    // Create config:
    if (!WriterReader.checkExists(Directory.EXPERIENCE_CONFIG)) {

      try {
        WriterReader.unpackConfig(Directory.EXPERIENCE_CONFIG);
      } catch (IOException e) {
        SagaLogger.severe(
            ExperienceConfiguration.class,
            "failed to create default configuration: " + e.getClass().getSimpleName());
      }
    }

    // Read config:
    ExperienceConfiguration config;
    try {

      config = WriterReader.readConfig(Directory.EXPERIENCE_CONFIG, ExperienceConfiguration.class);

    } catch (IOException e) {

      SagaLogger.severe(
          ExperienceConfiguration.class,
          "failed to read configuration: " + e.getClass().getSimpleName());
      config = new ExperienceConfiguration();

    } catch (JsonParseException e) {

      SagaLogger.severe(
          ExperienceConfiguration.class,
          "failed to parse configuration: " + e.getClass().getSimpleName());
      SagaLogger.info("message: " + e.getMessage());
      config = new ExperienceConfiguration();
    }

    // Set instance:
    instance = config;

    config.complete();

    return config;
  }
예제 #3
0
  private static void chatMessage(String message) {

    // Send the message to all players who have the correct permission:
    Collection<SagaPlayer> allPlayers = Saga.plugin().getLoadedPlayers();

    for (SagaPlayer loadedPlayer : allPlayers) {

      if (PermissionsDependency.hasPermission(
          loadedPlayer, PermissionsDependency.SPECIAL_CHAT_PERMISSION)) {
        loadedPlayer.message(message);
      }
    }

    // Log:
    SagaLogger.message(message);
  }
예제 #4
0
  /**
   * Completes.
   *
   * @return integrity check
   */
  public boolean complete() {

    boolean integrity = true;

    // Set instance:
    instance = this;

    // Attributes and abilities:
    if (attributePointCost == null) {
      SagaLogger.nullField(getClass(), "attributePointCost");
      attributePointCost = 500.0;
    }

    if (abilityPointCost == null) {
      SagaLogger.nullField(getClass(), "abilityPointCost");
      abilityPointCost = 500.0;
    }

    // Experience gain:
    if (maxExp == null) {
      maxExp = 10000000000.0;
      SagaLogger.nullField(getClass(), "maxExp");
      integrity = false;
    }

    if (expGainMultiplier == null) {
      expGainMultiplier = new TwoPointFunction(1.0);
      SagaLogger.nullField(getClass(), "expGainMultiplier");
      integrity = false;
    }

    if (blockExp == null) {
      blockExp = new Hashtable<Material, Hashtable<Byte, Double>>();
      SagaLogger.nullField(getClass(), "blockExp");
      integrity = false;
    }

    if (playerExp == null) {
      playerExp = new TwoPointFunction(0.0);
      SagaLogger.nullField(getClass(), "playerExp");
      integrity = false;
    }

    if (creatureExp == null) {
      creatureExp = new Hashtable<String, Double>();
      SagaLogger.nullField(getClass(), "creatureExp");
      integrity = false;
    }

    if (abilityExp == null) {
      abilityExp = new Hashtable<String, TwoPointFunction>();
      SagaLogger.nullField(getClass(), "abilityExp");
      integrity = false;
    }
    Collection<TwoPointFunction> abExpVals = abilityExp.values();
    for (TwoPointFunction abExpVal : abExpVals) {
      abExpVal.complete();
    }

    if (spawnerEncPointMult == null) {
      spawnerEncPointMult = 1.0;
      SagaLogger.nullField(this, "spawnerEncPointMult");
      integrity = false;
    }

    if (spawnerExpMult == null) {
      spawnerExpMult = 1.0;
      SagaLogger.nullField(this, "spawnerExpMult");
      integrity = false;
    }

    return integrity;
  }