/**
   * Creates a new mcMMO replacer. This also validates if all variables are available and can be
   * used in the runtime.
   */
  public McmmoVariables() {
    final ImmutableSet.Builder<String> builder = ImmutableSet.builder();
    // goes through all available skill types
    for (SkillType type : SkillType.values()) {
      final String skillName = type.name().toLowerCase(Locale.ENGLISH);
      builder.add('%' + skillName + '%');
    }

    skillTypes = builder.build();
  }
示例#2
0
  public McMMOPlayer(Player player, PlayerProfile profile) {
    String playerName = player.getName();
    UUID uuid = player.getUniqueId();

    this.player = player;
    playerMetadata = new FixedMetadataValue(mcMMO.p, playerName);
    this.profile = profile;

    if (profile.getUniqueId() == null) {
      profile.setUniqueId(uuid);
    }

    /*
     * I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually),
     * but I actually have no idea about the performance impact, if there is any.
     * If in the future someone wants to remove this, don't forget to also remove what is in the SkillType enum. - bm01
     */
    try {
      for (SkillType skillType : SkillType.values()) {
        skillManagers.put(
            skillType,
            skillType.getManagerClass().getConstructor(McMMOPlayer.class).newInstance(this));
      }
    } catch (Exception e) {
      e.printStackTrace();
      mcMMO.p.getPluginLoader().disablePlugin(mcMMO.p);
    }

    for (AbilityType abilityType : AbilityType.values()) {
      abilityMode.put(abilityType, false);
      abilityInformed.put(abilityType, true); // This is intended
    }

    for (ToolType toolType : ToolType.values()) {
      toolMode.put(toolType, false);
    }
  }