Skip to content

Commit

Permalink
Make counters a module
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt committed Jun 1, 2024
1 parent 5386e29 commit d63c12f
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 14 deletions.
8 changes: 8 additions & 0 deletions config/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ rootProject.gradleutils {
setupSigning(project: this.project, signAllPublications: true)
}

sourceSets {
sample {
compileClasspath += main.compileClasspath
}
}

repositories {
mavenCentral()
}
Expand All @@ -33,6 +39,8 @@ dependencies {
api "org.apache.groovy:groovy:${project.groovy_version}"
api "org.apache.groovy:groovy-contracts:${project.groovy_version}"
implementation group: 'org.kohsuke', name: 'github-api', version: project.ghapi_version

sampleCompileOnly(sourceSets.main.output)
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package net.neoforged.camelot.config.module

import groovy.transform.CompileStatic

/**
* The module responsible for counters. <br>
* <p>
* Counters can be used for... counting things in server. <br>
* A counter can be incremented by sending {@code <counter>++} in chat (and {@code <counter>--} for
* decrementing), and queried using {@code <counter>==}.
*/
@CompileStatic
class Counters extends ModuleConfiguration {
}
11 changes: 0 additions & 11 deletions sample-config/build.gradle

This file was deleted.

1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ plugins {
rootProject.name = 'Camelot'

include ':config'
include ':sample-config'
3 changes: 1 addition & 2 deletions src/main/java/net/neoforged/camelot/BotMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import net.neoforged.camelot.db.transactionals.LoggingChannelsDAO;
import net.neoforged.camelot.db.transactionals.PendingUnbansDAO;
import net.neoforged.camelot.db.transactionals.StatsDAO;
import net.neoforged.camelot.listener.CountersListener;
import net.neoforged.camelot.listener.DismissListener;
import net.neoforged.camelot.log.ChannelLogging;
import net.neoforged.camelot.log.JoinsLogging;
Expand Down Expand Up @@ -248,7 +247,7 @@ public static void main(String[] args) {
.setActivity(Activity.customStatus("Listening for your commands"))
.setMemberCachePolicy(MemberCachePolicy.ALL)
.addEventListeners(new ModerationActionRecorder())
.addEventListeners(BUTTON_MANAGER, new CountersListener(), new DismissListener());
.addEventListeners(BUTTON_MANAGER, new DismissListener());

try {
Database.init();
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/net/neoforged/camelot/module/CountersModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.neoforged.camelot.module;

import com.google.auto.service.AutoService;
import net.dv8tion.jda.api.JDABuilder;
import net.neoforged.camelot.config.module.Counters;
import net.neoforged.camelot.listener.CountersListener;

/**
* The module for counters.
*/
@AutoService(Counters.class)
public class CountersModule extends CamelotModule.Base<Counters> {
public CountersModule() {
super(Counters.class);
}

@Override
public String id() {
return "counters";
}

@Override
public void registerListeners(JDABuilder builder) {
builder.addEventListeners(new CountersListener());
}
}

0 comments on commit d63c12f

Please sign in to comment.