Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 0c131ed

Browse files
committed
Added abstract plugin impl. Reworked plugin presets.
1 parent a32bbea commit 0c131ed

File tree

5 files changed

+44
-36
lines changed

5 files changed

+44
-36
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import org.codeoverflow.chatoverflow.api.io.input.chat.TwitchChatInput;
2+
import org.codeoverflow.chatoverflow.api.plugin.PluginImpl;
3+
import org.codeoverflow.chatoverflow.api.plugin.configuration.Requirement;
4+
5+
public class AJavaPluginImpl extends PluginImpl {
6+
7+
Requirement<TwitchChatInput> twitchChat = require.input.twitchChat("twitchChat", "Twitch Chat", true);
8+
9+
@Override
10+
public void setup() {
11+
loopInterval = 100;
12+
System.out.println("I'm a java plugin!");
13+
}
14+
15+
@Override
16+
public void loop() {
17+
System.out.println("Loop!");
18+
}
19+
20+
@Override
21+
public void shutdown() {
22+
23+
}
24+
}

ajavaplugin/src/main/java/PluggableImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ public int getMinorAPIVersion() {
3030

3131
@Override
3232
public Plugin createNewPluginInstance(PluginManager manager) {
33-
return new PluginImpl();
33+
return new AJavaPluginImpl();
3434
}
3535
}

ajavaplugin/src/main/java/PluginImpl.java

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import org.codeoverflow.chatoverflow.api.plugin.configuration.Requirements
2-
import org.codeoverflow.chatoverflow.api.plugin.{Pluggable, Plugin, PluginManager}
1+
import org.codeoverflow.chatoverflow.api.plugin.{Pluggable, Plugin, PluginImpl, PluginManager}
32

43
class anothertestMainClass extends Pluggable {
54

@@ -13,12 +12,11 @@ class anothertestMainClass extends Pluggable {
1312

1413
override def getMinorAPIVersion: Int = 0
1514

16-
override def createNewPluginInstance(manager: PluginManager): Plugin = new Plugin {
15+
override def createNewPluginInstance(manager: PluginManager): Plugin = new PluginImpl {
16+
override def setup(): Unit = println("Setup!")
1717

18-
override def start(): Unit = {
19-
println("Started another test!")
20-
}
18+
override def loop(): Unit = println("Loop!")
2119

22-
override def getRequirements: Requirements = ???
20+
override def shutdown(): Unit = println("Shutdown!")
2321
}
2422
}
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
import org.codeoverflow.chatoverflow.api.plugin.configuration.Requirements
2-
import org.codeoverflow.chatoverflow.api.plugin.{Plugin, PluginManager}
1+
import org.codeoverflow.chatoverflow.api.plugin.{PluginImpl, PluginManager}
32

4-
class simpletestPlugin(manager: PluginManager) extends Plugin {
3+
class simpletestPlugin(manager: PluginManager) extends PluginImpl {
54

6-
private val require = new Requirements
7-
private val twitchChatInput = require.input.twitchChat("reqTwitch", "A twitch channel", false)
8-
private val nameToSayHelloTo = require.parameter.string("reqHello", "Your name", false)
5+
private val twitchChatInputReq = require.input.twitchChat("reqTwitch", "A twitch channel", false)
6+
private val nameToSayHelloToReq = require.parameter.string("reqHello", "Your name", false)
7+
loopInterval = 1000
98

10-
override def start(): Unit = {
9+
override def setup(): Unit = {
1110
println("Started successfully!")
1211
println(s"Dummy message is:${manager.getDummyMessage}")
1312

14-
twitchChatInput.getValue.registerMessageHandler(msg => println(msg))
13+
twitchChatInputReq.get.registerMessageHandler(msg => println(msg))
1514

16-
println(s"Hello ${nameToSayHelloTo.getValue}!")
15+
println(s"Hello ${nameToSayHelloToReq.get}!")
16+
}
1717

18-
while (true) {
19-
Thread.sleep(10)
20-
}
18+
override def loop(): Unit = {
19+
println("Loop!")
2120
}
2221

23-
override def getRequirements: Requirements = require
22+
override def shutdown(): Unit = {
23+
24+
}
2425
}

0 commit comments

Comments
 (0)