예제 #1
0
  public ChannelManager() {
    registerChannel(new DebugChannel());

    if (!configFile.exists()) {
      try {
        configFile.getParentFile().mkdirs();
        configFile.createNewFile();
        ISMain.log(
            "No channel config found... Created new config & internally writing default channels");
      } catch (IOException ex) {
        ISMain.log("Could not create channel config file: " + ex.getMessage(), 2);
      }

      writeDefaults();
    } else {
      YamlConfiguration channelConfig = ISMain.getChannelConfig();

      try {
        channelConfig.load(configFile);
      } catch (Throwable t) {
        ISMain.log("Could not load channels: " + t.getMessage(), 2);
        writeDefaults();
      }

      List<String> _channelList = channelConfig.getStringList("channels");

      for (String _channel : _channelList) {
        ChatChannel cc = new ChatChannel(_channel);
        registerChannel(cc);
      }

      for (Map.Entry<Channel, Boolean> entry : channels.entrySet()) {
        if (((ChatChannel) entry.getKey()).isDefault()) {
          this.def = entry.getKey();
          break;
        }
      }

      for (Map.Entry<Channel, Boolean> entry : channels.entrySet()) {
        if (((ChatChannel) entry.getKey()).isHelpOp()) {
          this.helpop = entry.getKey();
          break;
        }
      }
    }

    Bukkit.getScheduler()
        .scheduleAsyncRepeatingTask(ISMain.getInstance(), new MPMThread(), 0L, 1200L);
  }