...
 
Commits (3)
......@@ -67,7 +67,6 @@ when I debug my subpar code.
### Some to-do
* Separate exceptions for orangetext and greentext
* Toggle orangetext separately from greentext
* Support for reply reference (`>>31337`) and board reference (`>>>/out/`)
......
......@@ -21,6 +21,7 @@
<license>
<name>MIT</name>
<url>https://choosealicense.com/licenses/mit/</url>
<distribution>repo</distribution>
</license>
</licenses>
......@@ -58,7 +59,7 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.14.3-R0.1-SNAPSHOT</version>
<version>1.14.4-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
......
......@@ -26,6 +26,7 @@ package net.ssterling.BukkitGreentext;
import java.util.HashMap;
import java.util.UUID;
import java.util.List;
import java.io.File;
import java.io.BufferedReader;
import java.io.InputStreamReader;
......@@ -152,6 +153,23 @@ public class BukkitGreentext extends JavaPlugin
}
}
/* Finally, separate orangetext and greentext exceptions if not yet done */
if (config.isSet("exceptions") &&
!(config.isSet("greentext-exceptions") || config.isSet("orangetext-exceptions"))) {
getLogger().config("Updating configuration file to have separate `greentext-exception' and `orangetext-exception' lists (cloning contents of `exceptions)");
/* Clone the values of `exceptions' to the specific lists and remove `exceptions' */
List<String> exceptions_tmp = config.getStringList("exceptions");
config.set("greentext-exceptions", exceptions_tmp);
config.set("orangetext-exceptions", exceptions_tmp);
config.set("exceptions", null);
try {
this.saveConfig();
} catch (Throwable ex) {
getLogger().warning("Failed to update configuration file.");
ex.printStackTrace();
}
}
getLogger().finest("Initialising player hashmap...");
enabled_for_player = new HashMap<UUID, Boolean>();
......@@ -331,7 +349,7 @@ public class BukkitGreentext extends JavaPlugin
* For example, if `:' is listed as an exception,
* any message starting with `>:' isn't greenified,
* such as in emoticons, e.g. `>:('. */
for (String exception : config.getStringList("exceptions")) {
for (String exception : config.getStringList("greentext-exceptions")) {
if (message.startsWith(">" + exception)) {
getLogger().fine("Aforementioned message begins with exception `>" + exception + "'; ignoring");
return false;
......@@ -363,7 +381,7 @@ public class BukkitGreentext extends JavaPlugin
}
/* Same concept as in isValidGreentext() */
for (String exception : config.getStringList("exceptions")) {
for (String exception : config.getStringList("orangetext-exceptions")) {
if (message.endsWith(exception + "<")) {
getLogger().fine("Aforementioned message ends with exception `" + exception + "<'; ignoring");
return false;
......
check-for-permission: false
allow-orangetext: true
enabled-by-default: true
exceptions:
greentext-exceptions:
- ':'
- '_'
- '.'
orangetext-exceptions:
- ':'
- '_'
- '.'
......