예제 #1
0
 @Override
 public void onDisable() {
   saveSettings();
   saveConfigPlayerRadioSettings();
   amcRadMan.saveRadioSettings();
   logMessage("Disabled.");
 }
예제 #2
0
  @SuppressWarnings("unchecked")
  public void loadPlayerRadioSettings(Player player) {
    boolean playerHasSettings;
    Map<String, Object> playerSetting = new HashMap<String, Object>();
    if (playerRadioConfig.isConfigurationSection(player.getDisplayName())) {
      playerSetting =
          playerRadioConfig.getConfigurationSection(player.getDisplayName()).getValues(true);
      playerHasSettings = true;
    } else {
      logMessage("No Saved settings for player, loading defaults");
      playerHasSettings = false;
    }

    // if some developer reads this drop me a hint at a better way to do .yml settings
    // TODO: Figure out where to put Validation for channel, codes and cutoff settings.

    if (playerHasSettings && playerSetting.containsKey("radio")) {
      if (!isRadioOn(player) && ((Boolean) playerSetting.get("radio"))) {
        togglePlayerRadio(player);
      }
    } else if (!isRadioOn(player) && varRadioAutoOn) {
      togglePlayerRadio(player);
    }

    if (playerHasSettings && playerSetting.containsKey("freq")) {
      tunePlayerRadioChannel(player, (Integer) playerSetting.get("freq"));
    } else {
      tunePlayerRadioChannel(player, varRadioDefFreq);
    }

    if (playerHasSettings && playerSetting.containsKey("code")) {
      setPlayerRadioCode(player, (Integer) playerSetting.get("code"));
    } else {
      setPlayerRadioCode(player, 0);
    }

    if (playerHasSettings && playerSetting.containsKey("mic")) {
      setPlayerMic(player, (Boolean) playerSetting.get("mic"));
    } else {
      setPlayerMic(player, true);
    }

    if (playerHasSettings && playerSetting.containsKey("filter")) {
      setPlayerFilter(player, (Boolean) playerSetting.get("filter"));
    } else {
      setPlayerFilter(player, false);
    }

    if (playerHasSettings && playerSetting.containsKey("cutoff")) {
      setPlayerRadioCutoff(player, (Integer) playerSetting.get("cutoff"));
    } else {
      setPlayerRadioCutoff(player, varRadioMaxCuttoff);
    }
    // String last link we had on logout.
    if (playerHasSettings
        && playerSetting.containsKey("link")
        && amcRadMan.isLinkValid((String) playerSetting.get("link"))) {
      amcRadMan.linkPlayerToRadio(player, (String) playerSetting.get("link"));
    } else {
      setPlayerLinkID(player, "none");
    }
    // ArrayList<String> Players favorite radios
    if (playerHasSettings && playerSetting.containsKey("favorites")) {
      Object objAdmin = playerSetting.get("favorites");
      if (objAdmin instanceof ArrayList<?>) {
        this.setFavRadios(player, (ArrayList<String>) objAdmin);
      }
    }

    if (!playerHasSettings) {
      savePlayerRadioSettings(player);
    }
  }