コード例 #1
0
ファイル: ResidenceGain.java プロジェクト: mung3r/ecoCreature
 @Override
 public double getGain(Player player) {
   ClaimedResidence residence = Residence.getResidenceManager().getByLoc(player.getLocation());
   double multiplier = residence != null ? getMultiplier(residence.getName()) : NO_GAIN;
   LoggerUtil.getInstance().debug("Gain: " + multiplier);
   return multiplier;
 }
コード例 #2
0
ファイル: SuicideRule.java プロジェクト: OhBlihv/ecoCreature
  @Override
  protected boolean isBroken(PlayerKilledEvent event) {
    boolean ruleBroken = !suicideRewards && event.isSuicide();
    LoggerUtil.getInstance()
        .debugTrue(
            "No reward for " + event.getKiller().getName() + " taking their life.", ruleBroken);

    return ruleBroken;
  }
コード例 #3
0
  @Override
  public boolean isBroken(EntityKilledEvent event) {
    boolean ruleBroken = !wolverineMode && event.isTamedCreatureKill();

    if (ruleBroken) {
      LoggerUtil.getInstance()
          .debug("No reward for " + event.getKiller().getName() + " using tamed creatures.");
    }

    return ruleBroken;
  }
コード例 #4
0
  private AbstractRewardSource getRewardSource(Entity entity) {
    AbstractRewardSource source = null;

    if (hasRewardSource(entity.getType())) {
      source = getRewardSource(entity.getType());
    } else {
      LoggerUtil.getInstance().warning("No reward found for entity: " + entity.getType().getName());
    }

    return source;
  }
コード例 #5
0
  @Override
  protected boolean isBroken(EntityKilledEvent event) {
    SpawnerMobTracking tracking = event.getSpawnerMobTracking();
    boolean ruleBroken =
        !canCampSpawner && campByEntity && tracking.isSpawnerMob(event.getEntity());
    LoggerUtil.getInstance()
        .debugTrue(
            "No reward for " + event.getKiller().getName() + " spawner camping.", ruleBroken);

    return ruleBroken;
  }
コード例 #6
0
  private AbstractRewardSource getRewardSource(EntityType entityType) {
    AbstractRewardSource source = null;

    if (hasRewardSource(entityType)) {
      source = getSources().get(entityType).get(nextInt(getSources().get(entityType).size()));
    } else {
      LoggerUtil.getInstance()
          .debug(this.getClass(), "No reward defined for entity type: " + entityType.getName());
    }

    return source;
  }
コード例 #7
0
  @Override
  public double getMultiplier(Player player) {
    double multiplier = NO_GAIN;

    if (DependencyUtils.hasPermission(player, "gain.environment")
        && getMultipliers().containsKey(player.getWorld().getEnvironment())) {
      multiplier = getMultipliers().get(player.getWorld().getEnvironment());
      LoggerUtil.getInstance().debug(this.getClass(), "Environment multiplier: " + multiplier);
    }

    return multiplier;
  }
コード例 #8
0
  private boolean hasRewardSource(EntityKilledEvent event) {
    Player killer = event.getKiller();
    LivingEntity entity = event.getEntity();

    if (DependencyUtils.hasPermission(killer, "reward." + entity.getType().getName())) {
      if (hasRewardSource(entity.getType()) && !isRuleBroken(event)) {
        return true;
      }
    } else {
      LoggerUtil.getInstance()
          .debug(
              this.getClass(),
              "No reward for "
                  + killer.getName()
                  + " due to lack of permission for "
                  + entity.getType().getName());
    }

    return false;
  }
コード例 #9
0
  public static Set<PlayerGain> parseConfig(ConfigurationSection config) {
    Set<PlayerGain> gain = Collections.emptySet();

    if (config != null) {
      Map<Environment, Double> multipliers = new HashMap<World.Environment, Double>();
      for (String environment : config.getKeys(false)) {
        try {
          multipliers.put(
              Environment.valueOf(environment.toUpperCase()),
              Double.valueOf(
                  config.getConfigurationSection(environment).getDouble("Amount", NO_GAIN)));
        } catch (Exception e) {
          LoggerUtil.getInstance().warning("Skipping unknown environment name: " + environment);
        }
      }
      gain = new HashSet<PlayerGain>();
      gain.add(new EnvironmentGain(multipliers));
    }

    return gain;
  }