Server ready conf, doc
This commit is contained in:
parent
22bdc3fa62
commit
d2aea8559a
4 changed files with 36 additions and 22 deletions
9
pom.xml
9
pom.xml
|
@ -40,6 +40,14 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<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>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -96,6 +104,7 @@
|
||||||
</executions> </plugin> -->
|
</executions> </plugin> -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.4.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<useSystemClassLoader>false
|
<useSystemClassLoader>false
|
||||||
</useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 -->
|
</useSystemClassLoader> <!-- https://stackoverflow.com/a/53012553/2703239 -->
|
||||||
|
|
|
@ -20,6 +20,9 @@ import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AnnouncerModule extends Component<DiscordPlugin> {
|
public class AnnouncerModule extends Component<DiscordPlugin> {
|
||||||
|
/**
|
||||||
|
* Channel to post new posts.
|
||||||
|
*/
|
||||||
public ConfigData<IChannel> channel() {
|
public ConfigData<IChannel> channel() {
|
||||||
return DPUtils.channelData(getConfig(), "channel", 239519012529111040L);
|
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() {
|
public ConfigData<Short> keepPinned() {
|
||||||
return getConfig().getData("keepPinned", (short) 40);
|
return getConfig().getData("keepPinned", (short) 40);
|
||||||
|
|
|
@ -40,19 +40,23 @@ public class FunModule extends Component<DiscordPlugin> implements Listener {
|
||||||
"When will *you* be open?" // Ali
|
"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() {
|
private ConfigData<ArrayList<String>> serverReadyAnswers() {
|
||||||
return getConfig().getData("serverReadyAnswers", () -> Lists.newArrayList(serverReadyStrings)); //TODO: Test
|
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 Random serverReadyRandom = new Random();
|
||||||
private static final ArrayList<Short> usableServerReadyStrings = new ArrayList<>(0);
|
private static final ArrayList<Short> usableServerReadyStrings = new ArrayList<>(0);
|
||||||
|
|
||||||
|
@ -93,16 +97,14 @@ public class FunModule extends Component<DiscordPlugin> implements Listener {
|
||||||
return true; //Handled
|
return true; //Handled
|
||||||
}
|
}
|
||||||
lastlistp = (short) Bukkit.getOnlinePlayers().size(); //Didn't handle
|
lastlistp = (short) Bukkit.getOnlinePlayers().size(); //Didn't handle
|
||||||
if (fm.serverReady().get()) {
|
if (!TBMCCoreAPI.IsTestServer()
|
||||||
if (!TBMCCoreAPI.IsTestServer()
|
&& Arrays.stream(fm.serverReadyQuestions().get()).anyMatch(msglowercased::contains)) {
|
||||||
&& Arrays.stream(serverReadyQuestions).anyMatch(msglowercased::contains)) {
|
int next;
|
||||||
int next;
|
if (usableServerReadyStrings.size() == 0)
|
||||||
if (usableServerReadyStrings.size() == 0)
|
fm.createUsableServerReadyStrings();
|
||||||
fm.createUsableServerReadyStrings();
|
next = usableServerReadyStrings.remove(serverReadyRandom.nextInt(usableServerReadyStrings.size()));
|
||||||
next = usableServerReadyStrings.remove(serverReadyRandom.nextInt(usableServerReadyStrings.size()));
|
DiscordPlugin.sendMessageToChannel(message.getChannel(), serverReadyStrings[next]);
|
||||||
DiscordPlugin.sendMessageToChannel(message.getChannel(), serverReadyStrings[next]);
|
return false; //Still process it as a command/mcchat if needed
|
||||||
return false; //Still process it as a command/mcchat if needed
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@ import java.util.stream.Collectors;
|
||||||
public class MinecraftChatModule extends Component<DiscordPlugin> {
|
public class MinecraftChatModule extends Component<DiscordPlugin> {
|
||||||
private @Getter MCChatListener listener;
|
private @Getter MCChatListener listener;
|
||||||
|
|
||||||
public MCChatListener getListener() { //It doesn't want to generate
|
/*public MCChatListener getListener() { //It doesn't want to generate
|
||||||
return listener;
|
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!
|
* 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() {
|
public ConfigData<String[]> excludedPlugins() {
|
||||||
return getConfig().getData("excludedPlugins", new String[]{"ProtocolLib", "LibsDisguises", "JourneyMapServer"});
|
return getConfig().getData("excludedPlugins", new String[]{"ProtocolLib", "LibsDisguises", "JourneyMapServer"});
|
||||||
|
|
Loading…
Reference in a new issue