Exemplo n.º 1
0
 @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;
 }
Exemplo n.º 2
0
  @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;
  }
Exemplo n.º 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;
  }
  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;
  }
Exemplo n.º 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;
  }
  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;
  }
Exemplo n.º 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;
  }
  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;
  }
Exemplo n.º 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;
  }