-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.wdsj.asw.method; | ||
|
||
import com.github.houbb.sensitive.word.api.IWordAllow; | ||
import io.wdsj.asw.AdvancedSensitiveWords; | ||
import io.wdsj.asw.impl.list.AdvancedList; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public class ExternalWordAllow implements IWordAllow { | ||
private final File dataFolder = new File(AdvancedSensitiveWords.getInstance().getDataFolder(), "/external/allow"); | ||
|
||
@Override | ||
public List<String> allow() { | ||
List<String> totalList = new AdvancedList<>(); | ||
|
||
if (Files.notExists(dataFolder.toPath())) { | ||
try { | ||
Files.createDirectories(dataFolder.toPath()); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
try (Stream<Path> paths = Files.walk(dataFolder.toPath())) { | ||
List<File> files = paths | ||
.filter(Files::isRegularFile) | ||
.map(Path::toFile) | ||
.collect(Collectors.toList()); | ||
|
||
for (File file : files) { | ||
List<String> lines = Files.readAllLines(file.toPath()); | ||
totalList.addAll(lines); | ||
} | ||
if (files.size() > 0) AdvancedSensitiveWords.getInstance().getLogger().info("Loaded " + files.size() + " external allow files."); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
return Collections.emptyList(); | ||
} | ||
return totalList; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.wdsj.asw.method; | ||
|
||
import com.github.houbb.sensitive.word.api.IWordDeny; | ||
import io.wdsj.asw.AdvancedSensitiveWords; | ||
import io.wdsj.asw.impl.list.AdvancedList; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public class ExternalWordDeny implements IWordDeny { | ||
private final File dataFolder = new File(AdvancedSensitiveWords.getInstance().getDataFolder(), "/external/deny"); | ||
|
||
@Override | ||
public List<String> deny() { | ||
List<String> totalList = new AdvancedList<>(); | ||
|
||
if (Files.notExists(dataFolder.toPath())) { | ||
try { | ||
Files.createDirectories(dataFolder.toPath()); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
try (Stream<Path> paths = Files.walk(dataFolder.toPath())) { | ||
List<File> files = paths | ||
.filter(Files::isRegularFile) | ||
.map(Path::toFile) | ||
.collect(Collectors.toList()); | ||
|
||
for (File file : files) { | ||
List<String> lines = Files.readAllLines(file.toPath()); | ||
totalList.addAll(lines); | ||
} | ||
if (files.size() > 0) AdvancedSensitiveWords.getInstance().getLogger().info("Loaded " + files.size() + " external deny files."); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
return Collections.emptyList(); | ||
} | ||
return totalList; | ||
} | ||
} |