Server ready conf, doc

This commit is contained in:
Norbi Peti 2019-04-10 13:50:26 +02:00
parent 22bdc3fa62
commit d2aea8559a
4 changed files with 36 additions and 22 deletions

View file

@ -40,6 +40,14 @@
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- <compilerArgs>
<arg>-processor</arg>
<arg>buttondevteam.buttonproc.ButtonProcessor, lombok.core.AnnotationProcessor</arg>
</compilerArgs> -->
<!-- <annotationProcessors>
<annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</annotationProcessor>
<annotationProcessor>buttondevteam.buttonproc.ButtonProcessor</annotationProcessor>
</annotationProcessors> -->
</configuration>
</plugin>
<plugin>
@ -96,6 +104,7 @@
</executions> </plugin> -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<useSystemClassLoader>false
</useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 -->

View file

@ -20,6 +20,9 @@ import java.io.File;
import java.util.List;
public class AnnouncerModule extends Component<DiscordPlugin> {
/**
* Channel to post new posts.
*/
public ConfigData<IChannel> channel() {
return DPUtils.channelData(getConfig(), "channel", 239519012529111040L);
}
@ -29,7 +32,7 @@ public class AnnouncerModule extends Component<DiscordPlugin> {
}
/**
* Set to 0 or >50 to disable
* Automatically unpins all messages except the last few. Set to 0 or >50 to disable
*/
public ConfigData<Short> keepPinned() {
return getConfig().getData("keepPinned", (short) 40);

View file

@ -40,19 +40,23 @@ public class FunModule extends Component<DiscordPlugin> implements Listener {
"When will *you* be open?" // Ali
};
private ConfigData<Boolean> serverReady() {
return getConfig().getData("serverReady", true);
/**
* Questions that the bot will choose a random answer to give to.
*/
private ConfigData<String[]> serverReadyQuestions() {
return getConfig().getData("serverReady", ()->new String[]{"when will the server be open",
"when will the server be ready", "when will the server be done", "when will the server be complete",
"when will the server be finished", "when's the server ready", "when's the server open",
"Vhen vill ze server be open?"});
}
/**
* Answers for a recognized question. Selected randomly.
*/
private ConfigData<ArrayList<String>> serverReadyAnswers() {
return getConfig().getData("serverReadyAnswers", () -> Lists.newArrayList(serverReadyStrings)); //TODO: Test
}
private static final String[] serverReadyQuestions = new String[]{"when will the server be open",
"when will the server be ready", "when will the server be done", "when will the server be complete",
"when will the server be finished", "when's the server ready", "when's the server open",
"Vhen vill ze server be open?"};
private static final Random serverReadyRandom = new Random();
private static final ArrayList<Short> usableServerReadyStrings = new ArrayList<>(0);
@ -93,16 +97,14 @@ public class FunModule extends Component<DiscordPlugin> implements Listener {
return true; //Handled
}
lastlistp = (short) Bukkit.getOnlinePlayers().size(); //Didn't handle
if (fm.serverReady().get()) {
if (!TBMCCoreAPI.IsTestServer()
&& Arrays.stream(serverReadyQuestions).anyMatch(msglowercased::contains)) {
int next;
if (usableServerReadyStrings.size() == 0)
fm.createUsableServerReadyStrings();
next = usableServerReadyStrings.remove(serverReadyRandom.nextInt(usableServerReadyStrings.size()));
DiscordPlugin.sendMessageToChannel(message.getChannel(), serverReadyStrings[next]);
return false; //Still process it as a command/mcchat if needed
}
if (!TBMCCoreAPI.IsTestServer()
&& Arrays.stream(fm.serverReadyQuestions().get()).anyMatch(msglowercased::contains)) {
int next;
if (usableServerReadyStrings.size() == 0)
fm.createUsableServerReadyStrings();
next = usableServerReadyStrings.remove(serverReadyRandom.nextInt(usableServerReadyStrings.size()));
DiscordPlugin.sendMessageToChannel(message.getChannel(), serverReadyStrings[next]);
return false; //Still process it as a command/mcchat if needed
}
return false;
}

View file

@ -25,9 +25,9 @@ import java.util.stream.Collectors;
public class MinecraftChatModule extends Component<DiscordPlugin> {
private @Getter MCChatListener listener;
public MCChatListener getListener() { //It doesn't want to generate
return listener;
}
/*public MCChatListener getListener() { //It doesn't want to generate
return listener; - And now ButtonProcessor didn't look beyond this - return instead of continue...
}*/
/**
* A list of commands that can be used in public chats - Warning: Some plugins will treat players as OPs, always test before allowing a command!
@ -52,7 +52,7 @@ public class MinecraftChatModule extends Component<DiscordPlugin> {
}
/**
* 0 * The plugins to exclude from fake player events used for the 'mcchat' command - some plugins may crash, add them here
* The plugins to exclude from fake player events used for the 'mcchat' command - some plugins may crash, add them here
*/
public ConfigData<String[]> excludedPlugins() {
return getConfig().getData("excludedPlugins", new String[]{"ProtocolLib", "LibsDisguises", "JourneyMapServer"});