Esempio n. 1
0
  public ChatManager(Main plugin) {
    this.plugin = plugin;
    this.secondsBetweenSameLine = 10;
    _player_mutex = new ReentrantLock(true);
    playerLastChatLine = new TreeMap<>();
    playerWarnings = new TreeMap<>();
    lastTalkPlayer = "";
    lastChatLineTime = 0;

    File enBadWords = new File(plugin.getDataFolder(), "badwords.txt");
    File spBadWords = new File(plugin.getDataFolder(), "malaspalabras.txt");

    if (!enBadWords.exists()) {
      plugin.saveResource(enBadWords.getName(), true);
    }

    if (!spBadWords.exists()) {
      plugin.saveResource(spBadWords.getName(), true);
    }

    String badWordsList;
    badWordsList = loadBadWords(enBadWords);
    badWordsList = badWordsList.concat("|" + loadBadWords(spBadWords));
    badWordsPattern = Pattern.compile("\\b(" + badWordsList + ")\\b");
    if (plugin.getConfig().getBoolean("debug")) {
      plugin.getLogger().log(Level.INFO, "Debug: bad world list: {0}", badWordsList);
    }
  }
Esempio n. 2
0
 public void saveStorageConfig() {
   if (storageConfig == null || storageConfigFile == null) {
     return;
   }
   try {
     getStorageConfig().save(storageConfigFile);
   } catch (IOException ex) {
     plugin.getLogger().log(Level.SEVERE, "Could not save config to " + storageConfigFile, ex);
   }
 }
Esempio n. 3
0
 private String loadBadWords(File file) {
   String badWordsList = "";
   FileInputStream fstream;
   try {
     fstream = new FileInputStream(file);
     try (DataInputStream in = new DataInputStream(fstream)) {
       BufferedReader br = new BufferedReader(new InputStreamReader(in));
       String strLine;
       // Read File Line By Line
       while ((strLine = br.readLine()) != null) {
         badWordsList = badWordsList.concat(strLine + "|");
       }
       badWordsList = badWordsList.substring(0, badWordsList.length() - 1);
     }
   } catch (IOException ex) {
     plugin.getLogger().severe(ex.toString());
   }
   return badWordsList.replaceAll(" ", "");
 }