diff --git a/bukkit/pom.xml b/bukkit/pom.xml
index a875e72..13c43ef 100644
--- a/bukkit/pom.xml
+++ b/bukkit/pom.xml
@@ -10,7 +10,7 @@
io.wdsj
AdvancedSensitiveWords
- 1.1
+ 1.2
../pom.xml
@@ -69,6 +69,14 @@
+
+ org.hjug.refactorfirst.plugin
+ refactor-first-maven-plugin
+ 0.5.0
+
+ false
+
+
org.jetbrains.kotlin
kotlin-maven-plugin
@@ -315,7 +323,7 @@
com.github.retrooper
packetevents-spigot
- 2.5.0
+ 2.5.1-SNAPSHOT
provided
@@ -403,7 +411,7 @@
io.wdsj
AdvancedSensitiveWords-common
- 1.1
+ 1.2
compile
diff --git a/bukkit/src/main/java/io/wdsj/asw/bukkit/service/hook/VoiceChatHookService.java b/bukkit/src/main/java/io/wdsj/asw/bukkit/service/hook/VoiceChatHookService.java
index 34574f0..10cfdf9 100644
--- a/bukkit/src/main/java/io/wdsj/asw/bukkit/service/hook/VoiceChatHookService.java
+++ b/bukkit/src/main/java/io/wdsj/asw/bukkit/service/hook/VoiceChatHookService.java
@@ -21,7 +21,7 @@ public void register() {
service.registerPlugin(voiceChatExtension);
LOGGER.info("Successfully hooked into voicechat.");
} catch (Exception e) {
- LOGGER.severe("Failed to register voicechat listener." +
+ LOGGER.warning("Failed to register voicechat listener." +
" This should not happen, please report to the author: " + e.getMessage());
}
} else {
diff --git a/bukkit/src/main/java/io/wdsj/asw/bukkit/update/Updater.java b/bukkit/src/main/java/io/wdsj/asw/bukkit/update/Updater.java
index 68bb0d9..5c5c875 100644
--- a/bukkit/src/main/java/io/wdsj/asw/bukkit/update/Updater.java
+++ b/bukkit/src/main/java/io/wdsj/asw/bukkit/update/Updater.java
@@ -2,18 +2,21 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
+import io.wdsj.asw.common.template.PluginVersionTemplate;
-import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
+import static io.wdsj.asw.bukkit.AdvancedSensitiveWords.LOGGER;
+
public class Updater {
private static String currentVersion;
private static String latestVersion;
private static boolean isUpdateAvailable = false;
private static final String UPDATE_URL = "https://api.github.com/repos/HaHaWTH/AdvancedSensitiveWords/releases/latest";
+ private static final String currentVersionChannel = PluginVersionTemplate.VERSION_CHANNEL;
public Updater(String current) {
currentVersion = current;
@@ -24,7 +27,12 @@ public Updater(String current) {
* Note: This method will perform a network request!
* @return true if there is an update available, false otherwise
*/
+ @SuppressWarnings("all")
public boolean isUpdateAvailable() {
+ boolean isDevChannel = currentVersionChannel.equalsIgnoreCase("dev");
+ if (isDevChannel) {
+ LOGGER.info("You are running an development version of AdvancedSensitiveWords!");
+ }
URI uri = URI.create(UPDATE_URL);
try {
URL url = uri.toURL();
@@ -37,9 +45,13 @@ public boolean isUpdateAvailable() {
latestVersion = latest;
isUpdateAvailable = !currentVersion.equals(latest);
reader.close();
+ if (isDevChannel) {
+ LOGGER.info("Current running: " + currentVersion + "-" + currentVersionChannel + ", latest release: " + latest);
+ return false;
+ }
return isUpdateAvailable;
}
- } catch (IOException e) {
+ } catch (Exception e) {
latestVersion = null;
isUpdateAvailable = false;
return false;
diff --git a/bukkit/src/main/java/io/wdsj/asw/bukkit/util/SchedulingUtils.java b/bukkit/src/main/java/io/wdsj/asw/bukkit/util/SchedulingUtils.java
index 790fd61..b86647d 100644
--- a/bukkit/src/main/java/io/wdsj/asw/bukkit/util/SchedulingUtils.java
+++ b/bukkit/src/main/java/io/wdsj/asw/bukkit/util/SchedulingUtils.java
@@ -3,12 +3,15 @@
import com.github.Anon8281.universalScheduler.UniversalScheduler;
import com.github.Anon8281.universalScheduler.scheduling.tasks.MyScheduledTask;
-import io.wdsj.asw.bukkit.AdvancedSensitiveWords;
+import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
+import org.bukkit.event.Event;
import java.util.concurrent.Callable;
+import static io.wdsj.asw.bukkit.AdvancedSensitiveWords.getScheduler;
+
public class SchedulingUtils {
private SchedulingUtils() {
}
@@ -16,7 +19,7 @@ private SchedulingUtils() {
public static void runSyncIfFolia(Runnable runnable) {
if (isFolia) {
- AdvancedSensitiveWords.getScheduler().runTask(runnable);
+ getScheduler().runTask(runnable);
} else {
runnable.run();
}
@@ -24,7 +27,7 @@ public static void runSyncIfFolia(Runnable runnable) {
public static void runSyncAtEntityIfFolia(Entity entity, Runnable runnable) {
if (isFolia) {
- AdvancedSensitiveWords.getScheduler().runTask(entity, runnable);
+ getScheduler().runTask(entity, runnable);
} else {
runnable.run();
}
@@ -32,12 +35,28 @@ public static void runSyncAtEntityIfFolia(Entity entity, Runnable runnable) {
public static void runSyncAtLocationIfFolia(Location location, Runnable runnable) {
if (isFolia) {
- AdvancedSensitiveWords.getScheduler().runTask(location, runnable);
+ getScheduler().runTask(location, runnable);
+ } else {
+ runnable.run();
+ }
+ }
+
+ public static void runSyncIfEventAsync(Runnable runnable, Event event) {
+ if (event.isAsynchronous()) {
+ getScheduler().runTask(runnable);
} else {
runnable.run();
}
}
+ public static void runSyncIfNotOnMainThread(Runnable runnable) {
+ if (Bukkit.isPrimaryThread()) {
+ runnable.run();
+ } else {
+ getScheduler().runTask(runnable);
+ }
+ }
+
public static void cancelTaskSafely(MyScheduledTask task) {
if (task == null) return;
task.cancel();
@@ -45,7 +64,7 @@ public static void cancelTaskSafely(MyScheduledTask task) {
public static T callSyncMethod(Callable callable) {
try {
- return AdvancedSensitiveWords.getScheduler().callSyncMethod(callable).get();
+ return getScheduler().callSyncMethod(callable).get();
} catch (Exception e) {
throw new RuntimeException(e);
}
diff --git a/bukkit/src/main/kotlin/io/wdsj/asw/bukkit/listener/ChatListener.kt b/bukkit/src/main/kotlin/io/wdsj/asw/bukkit/listener/ChatListener.kt
index a581c2b..48e3cac 100644
--- a/bukkit/src/main/kotlin/io/wdsj/asw/bukkit/listener/ChatListener.kt
+++ b/bukkit/src/main/kotlin/io/wdsj/asw/bukkit/listener/ChatListener.kt
@@ -16,6 +16,7 @@ import io.wdsj.asw.bukkit.setting.PluginMessages
import io.wdsj.asw.bukkit.setting.PluginSettings
import io.wdsj.asw.bukkit.type.ModuleType
import io.wdsj.asw.bukkit.util.LoggingUtils
+import io.wdsj.asw.bukkit.util.SchedulingUtils
import io.wdsj.asw.bukkit.util.TimingUtils
import io.wdsj.asw.bukkit.util.Utils
import io.wdsj.asw.bukkit.util.context.ChatContext
@@ -65,8 +66,10 @@ class ChatListener : Listener {
val endTime = System.currentTimeMillis()
TimingUtils.addProcessStatistic(endTime, startTime)
if (settingsManager.getProperty(PluginSettings.NOTICE_OPERATOR)) Notifier.notice(player, ModuleType.CHAT, originalMessage, censoredWordList)
- getScheduler().runTask {
- if (settingsManager.getProperty(PluginSettings.CHAT_PUNISH)) Punishment.punish(player)
+ if (settingsManager.getProperty(PluginSettings.CHAT_PUNISH)) {
+ SchedulingUtils.runSyncIfEventAsync({
+ Punishment.punish(player)
+ }, event)
}
return
} else {
@@ -96,7 +99,9 @@ class ChatListener : Listener {
Notifier.notice(player, ModuleType.CHAT_AI, originalMessage, unsupportedList)
}
if (settingsManager.getProperty(PluginSettings.CHAT_PUNISH) && settingsManager.getProperty(PluginSettings.OLLAMA_AI_PUNISH)) {
- getScheduler().runTask { Punishment.punish(player) }
+ SchedulingUtils.runSyncIfEventAsync({
+ Punishment.punish(player)
+ }, event)
}
}
} catch (e: NumberFormatException) {
@@ -143,7 +148,9 @@ class ChatListener : Listener {
Notifier.notice(player, ModuleType.CHAT_AI, originalMessage, unsupportedList)
}
if (settingsManager.getProperty(PluginSettings.CHAT_PUNISH) && settingsManager.getProperty(PluginSettings.OPENAI_AI_PUNISH)) {
- getScheduler().runTask { Punishment.punish(player) }
+ SchedulingUtils.runSyncIfEventAsync({
+ Punishment.punish(player)
+ }, event)
}
}
}
@@ -182,9 +189,9 @@ class ChatListener : Listener {
TimingUtils.addProcessStatistic(endTime, startTime)
if (settingsManager.getProperty(PluginSettings.NOTICE_OPERATOR)) Notifier.notice(player, ModuleType.CHAT, originalContext, censoredContextList)
if (settingsManager.getProperty(PluginSettings.CHAT_PUNISH)) {
- getScheduler().runTask {
+ SchedulingUtils.runSyncIfEventAsync({
Punishment.punish(player)
- }
+ }, event)
}
}
}
diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml
index 5ba38bb..ecd431c 100644
--- a/bukkit/src/main/resources/plugin.yml
+++ b/bukkit/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
name: AdvancedSensitiveWords
-version: ${project.version}
+version: ${project.version}-${version.channel}
# noinspection YAMLSchemaValidation
main: ${plugin.mainClass}
api-version: '1.13'
diff --git a/bungee/pom.xml b/bungee/pom.xml
index 760771c..de54b09 100644
--- a/bungee/pom.xml
+++ b/bungee/pom.xml
@@ -10,7 +10,7 @@
io.wdsj
AdvancedSensitiveWords
- 1.1
+ 1.2
../pom.xml
@@ -88,7 +88,7 @@
io.wdsj
AdvancedSensitiveWords-common
- 1.1
+ 1.2
compile
diff --git a/bungee/src/main/resources/bungee.yml b/bungee/src/main/resources/bungee.yml
index 52fd5b7..35fafe6 100644
--- a/bungee/src/main/resources/bungee.yml
+++ b/bungee/src/main/resources/bungee.yml
@@ -1,3 +1,3 @@
name: AdvancedSensitiveWords
-version: '${project.version}'
+version: '${project.version}-${version.channel}'
main: io.wdsj.asw.bungee.AdvancedSensitiveWords
diff --git a/common/pom.xml b/common/pom.xml
index 588fd38..154fa10 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -7,7 +7,7 @@
io.wdsj
AdvancedSensitiveWords
- 1.1
+ 1.2
../pom.xml
diff --git a/common/src/main/java/io/wdsj/asw/common/template/PluginVersionTemplate.java b/common/src/main/java/io/wdsj/asw/common/template/PluginVersionTemplate.java
index 06f9a3b..693a0f9 100644
--- a/common/src/main/java/io/wdsj/asw/common/template/PluginVersionTemplate.java
+++ b/common/src/main/java/io/wdsj/asw/common/template/PluginVersionTemplate.java
@@ -2,4 +2,5 @@
public class PluginVersionTemplate {
public static final String VERSION = "${project.version}";
+ public static final String VERSION_CHANNEL = "${version.channel}";
}
diff --git a/pom.xml b/pom.xml
index 8224c41..ba24efc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
io.wdsj
AdvancedSensitiveWords
- 1.1
+ 1.2
pom
AdvancedSensitiveWords
@@ -14,6 +14,7 @@
1.8
UTF-8
+ dev
diff --git a/velocity/pom.xml b/velocity/pom.xml
index 052eefe..0d91b65 100644
--- a/velocity/pom.xml
+++ b/velocity/pom.xml
@@ -10,7 +10,7 @@
io.wdsj
AdvancedSensitiveWords
- 1.1
+ 1.2
../pom.xml
@@ -122,7 +122,7 @@
io.wdsj
AdvancedSensitiveWords-common
- 1.1
+ 1.2
compile
diff --git a/velocity/src/main/java/io/wdsj/asw/velocity/AdvancedSensitiveWords.java b/velocity/src/main/java/io/wdsj/asw/velocity/AdvancedSensitiveWords.java
index 4e067d8..03d7199 100644
--- a/velocity/src/main/java/io/wdsj/asw/velocity/AdvancedSensitiveWords.java
+++ b/velocity/src/main/java/io/wdsj/asw/velocity/AdvancedSensitiveWords.java
@@ -24,7 +24,7 @@
@Plugin(
id = "advancedsensitivewords",
name = "AdvancedSensitiveWords",
- version = PluginVersionTemplate.VERSION,
+ version = PluginVersionTemplate.VERSION + "-" + PluginVersionTemplate.VERSION_CHANNEL,
authors = {"HaHaWTH"}
)
public class AdvancedSensitiveWords {