Skip to content

Commit

Permalink
chore: Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
phinner committed Dec 23, 2023
1 parent a1ec305 commit f34781b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 60 deletions.
55 changes: 3 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Then, go to the created directory `config/mods/nohorny` and create a file named
Now you can set up the analyzer of your choice:

- **[ModerateContent](https://moderatecontent.com/)**: Incredibly generous free tier with 10000 free requests per month.
Much thanks for the recommandation @osp54.

```yaml
analyzer:
Expand Down Expand Up @@ -57,9 +56,7 @@ Now you can set up the analyzer of your choice:
analyzer: Debug
```

> For more detailed debugging, enable debug logging with the command `config debug true`
and distributor trace logging with `config trace true`.
There is also the in-game command `nohorny-tracker-debug` that allows you to check
> There is also the in-game command `nohorny-tracker-debug` that allows you to check
if displays and canvases are properly tracked.

Once you chose your analyzer, load your changes using the command `nohorny-reload` in the console, and enjoy,
Expand All @@ -84,50 +81,8 @@ dependencies {
```

Then you will be able to intercept `ImageAnalyzerEvent`, which
is posted every time a cluster of `NoHornyImage` is processed:

```java
import arc.Events;
import arc.util.Log;
import com.xpdustry.nohorny.analyzer.ImageAnalyzerEvent;
import com.xpdustry.nohorny.NoHornyImage;
import mindustry.Vars;
import mindustry.gen.Groups;
import mindustry.mod.Plugin;
public final class MyPlugin extends Plugin {
@Override
public void init() {
Events.on(ImageAnalyzerEvent.class, event -> {
switch (event.getResult().getRating()) {
case WARNING -> {
Log.info("The @ cluster is kinda sus",
event.getCluster().getIdentifier());
}
case UNSAFE -> {
Log.info("That's it, to the horny jail",
event.getCluster().getIdentifier());
final NoHornyImage.Author author = event.getAuthor();
if (author == null) {
return;
}
Groups.player.forEach(player -> {
if (player.uuid().equals(author.getUuid()) ||
player.ip().equals(author.getAddress().getHostAddress())) {
Vars.netServer.admins.banPlayer(player.uuid());
player.kick("[scarlet]You have been banned for building a NSFW building.");
}
});
}
}
});
}
}
```
is posted every time a cluster of `NoHornyImage` is processed,
see [NoHornyAutoBan](src/main/kotlin/com/xpdustry/nohorny/NoHornyAutoBan.kt) for an example.

> If you handle the ban of the player yourself (like in the above example),
> you should disable the auto ban of nohorny by adding the following in the config.
Expand All @@ -151,16 +106,12 @@ This plugin requires :

- `./gradlew shadowJar` to compile the plugin into a usable jar (will be located at `builds/libs/nohorny.jar`).

- `./gradlew jar` for a plain jar that contains only the plugin code.

- `./gradlew runMindustryServer` to run the plugin in a local Mindustry server.

- `./gradlew runMindustryClient` to start a local Mindustry client that will let you test the plugin.

- `./gradlew spotlessApply` to apply the code formatting and the licence header.

- `./gradlew dependencyUpdates` to check for dependency updates.

## Support

Need a helping hand ? You can talk to the maintainers in the [Chaotic Neutral discord](https://discord.xpdustry.com) in
Expand Down
5 changes: 0 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode

plugins {
kotlin("jvm") version "1.9.10"
id("org.jetbrains.dokka") version "1.9.10"
id("com.diffplug.spotless") version "6.23.3"
id("net.kyori.indra") version "3.1.3"
id("net.kyori.indra.publishing") version "3.1.3"
Expand Down Expand Up @@ -213,7 +212,3 @@ val downloadKotlinRuntime =
tasks.runMindustryServer {
mods.setFrom(tasks.shadowJar, downloadDistributorCore, downloadKotlinRuntime)
}

tasks.javadocJar {
from(tasks.dokkaHtml)
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ internal class ModerateContentAnalyzer(
ImageAnalyzer.Result(
ImageAnalyzer.Rating.SAFE,
mapOf(
ImageAnalyzer.Kind.NUDITY to
prediction[EVERYONE_LABEL]!! / 100F))
ImageAnalyzer.Kind.NUDITY to prediction[ADULT_LABEL]!! / 100F))
TEEN_LABEL ->
ImageAnalyzer.Result(
ImageAnalyzer.Rating.WARNING,
mapOf(ImageAnalyzer.Kind.NUDITY to prediction[TEEN_LABEL]!! / 100F))
mapOf(
ImageAnalyzer.Kind.NUDITY to prediction[ADULT_LABEL]!! / 100F))
ADULT_LABEL ->
ImageAnalyzer.Result(
ImageAnalyzer.Rating.UNSAFE,
Expand Down

0 comments on commit f34781b

Please sign in to comment.