diff --git a/pom.xml b/pom.xml
index b918dda..0983c53 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
cn.lanink
MurderMystery
- 1.4.2-PM1E-SNAPSHOT
+ 1.4.2-PM1E
@@ -81,7 +81,6 @@
${project.basedir}/src/main/java/cn/lanink/murdermystery/MurderMystery.java
${project.basedir}/src/main/resources/plugin.yml
- ${project.basedir}/.circleci/config.yml
@@ -158,7 +157,7 @@
com.smallaswater
RsNPC
- 2.3.0
+ 2.3.1
provided
@@ -173,14 +172,14 @@
org.jetbrains
annotations
- 23.1.0
+ 24.0.1
provided
org.projectlombok
lombok
- 1.18.24
+ 1.18.26
provided
diff --git a/src/main/java/cn/lanink/murdermystery/MurderMystery.java b/src/main/java/cn/lanink/murdermystery/MurderMystery.java
index b391869..c45b828 100644
--- a/src/main/java/cn/lanink/murdermystery/MurderMystery.java
+++ b/src/main/java/cn/lanink/murdermystery/MurderMystery.java
@@ -3,6 +3,7 @@
import cn.lanink.gamecore.GameCore;
import cn.lanink.gamecore.scoreboard.ScoreboardUtil;
import cn.lanink.gamecore.scoreboard.base.IScoreboard;
+import cn.lanink.gamecore.utils.ConfigUtils;
import cn.lanink.gamecore.utils.FileUtils;
import cn.lanink.gamecore.utils.Language;
import cn.lanink.gamecore.utils.VersionUtils;
@@ -26,6 +27,7 @@
import cn.lanink.murdermystery.tasks.admin.SetRoomTask;
import cn.lanink.murdermystery.utils.MetricsLite;
import cn.lanink.murdermystery.utils.RsNpcVariable;
+import cn.lanink.murdermystery.utils.update.ConfigUpdateUtils;
import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.entity.data.Skin;
@@ -51,7 +53,7 @@
*/
public class MurderMystery extends PluginBase {
- public static final String VERSION = "1.4.2-PM1E-SNAPSHOT git-f9f5181";
+ public static final String VERSION = "?";
public static boolean debug = false;
public static final Random RANDOM = new Random();
public static final ThreadPoolExecutor CHECK_ROOM_THREAD_POOL = new ThreadPoolExecutor(
@@ -101,6 +103,9 @@ public class MurderMystery extends PluginBase {
private boolean restoreWorld = false;
private boolean autoCreateTemporaryRoom = false;
+
+ @Getter
+ private boolean automaticJoinGame = false;
@Getter
private boolean automaticNextRound = false; //游戏结束后自动加入新房间
@@ -154,12 +159,20 @@ public void onLoad() {
}
}
+ ConfigUpdateUtils.updateConfig();
+ Config configDescription = new Config();
+ configDescription.load(this.getResource("Resources/Language/ConfigDescription/" + this.config.getString("language", "zh_CN") + ".yml"));
+ ConfigUtils.addDescription(this.config, configDescription);
+
+ this.config = new Config(this.getDataFolder() + "/config.yml", Config.YAML);
+
this.temporaryRoomsConfig = new Config(this.getDataFolder() + "/temporaryRoomList.yml", Config.YAML);
this.temporaryRooms = new CopyOnWriteArrayList<>(this.temporaryRoomsConfig.getStringList("temporaryRooms"));
this.removeAllTemporaryRoom();
this.restoreWorld = this.config.getBoolean("restoreWorld", false);
this.autoCreateTemporaryRoom = this.config.getBoolean("autoCreateTemporaryRoom", false);
+ this.automaticJoinGame = this.config.getBoolean("AutomaticJoinGame", false);
this.automaticNextRound = this.config.getBoolean("AutomaticNextRound", false);
this.cmdUser = this.config.getString("cmdUser", "murdermystery");
diff --git a/src/main/java/cn/lanink/murdermystery/listener/defaults/PlayerJoinAndQuit.java b/src/main/java/cn/lanink/murdermystery/listener/defaults/PlayerJoinAndQuit.java
index 7eeafd7..ce423af 100644
--- a/src/main/java/cn/lanink/murdermystery/listener/defaults/PlayerJoinAndQuit.java
+++ b/src/main/java/cn/lanink/murdermystery/listener/defaults/PlayerJoinAndQuit.java
@@ -11,6 +11,7 @@
import cn.nukkit.event.EventPriority;
import cn.nukkit.event.Listener;
import cn.nukkit.event.player.PlayerJoinEvent;
+import cn.nukkit.event.player.PlayerLocallyInitializedEvent;
import cn.nukkit.event.player.PlayerQuitEvent;
import cn.nukkit.event.player.PlayerTeleportEvent;
@@ -57,6 +58,17 @@ public void onPlayerJoin(PlayerJoinEvent event) {
}
}
+ @EventHandler
+ public void onPlayerLocallyInitialized(PlayerLocallyInitializedEvent event) {
+ Player player = event.getPlayer();
+ if (player == null) {
+ return;
+ }
+ if (this.murderMystery.isAutomaticJoinGame()) {
+ Server.getInstance().dispatchCommand(player, this.murderMystery.getCmdUser() + " join");
+ }
+ }
+
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
diff --git a/src/main/java/cn/lanink/murdermystery/utils/update/ConfigUpdateUtils.java b/src/main/java/cn/lanink/murdermystery/utils/update/ConfigUpdateUtils.java
new file mode 100644
index 0000000..a15292f
--- /dev/null
+++ b/src/main/java/cn/lanink/murdermystery/utils/update/ConfigUpdateUtils.java
@@ -0,0 +1,40 @@
+package cn.lanink.murdermystery.utils.update;
+
+import cn.lanink.gamecore.utils.VersionUtils;
+import cn.lanink.murdermystery.MurderMystery;
+import cn.nukkit.utils.Config;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author LT_Name
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public class ConfigUpdateUtils {
+
+ public static void updateConfig() {
+ update1_X_X_To_1_4_2();
+ }
+
+ @NotNull
+ private static Config getConfig() {
+ return new Config(MurderMystery.getInstance().getDataFolder() + "/config.yml", Config.YAML);
+ }
+
+ private static void update1_X_X_To_1_4_2() {
+ Config config = getConfig();
+ if (VersionUtils.compareVersion(config.getString("ConfigVersion", "1.0.0"), "1.4.2") >= 0) {
+ return;
+ }
+
+ config.set("ConfigVersion", "1.4.2");
+
+ if (!config.exists("AutomaticJoinGame")) {
+ config.set("AutomaticJoinGame", false);
+ }
+
+ config.save();
+ }
+
+}
diff --git a/src/main/resources/Resources/Language/ConfigDescription/en_US.yml b/src/main/resources/Resources/Language/ConfigDescription/en_US.yml
new file mode 100644
index 0000000..a7338e2
--- /dev/null
+++ b/src/main/resources/Resources/Language/ConfigDescription/en_US.yml
@@ -0,0 +1,32 @@
+header: |-
+ MurderMystery Plugin configuration file
+footer: |-
+ You have reached the bottom of the profile
+
+ConfigVersion: |-
+ The version number of the configuration file
+ Warning! Don't try to change this configuration unless you know exactly what you are doing!
+
+defaultLanguage: "Plugin default language settings. Optional: zh_CN | en_US | ko_KR | vi_VN | de_DE"
+languageMappingTable: "languageMappingTable"
+autoUpdateLanguage: "Automatically update language files"
+
+cmdUser: "plugin command"
+cmdUserAliases: "plugin command alias"
+cmdAdmin: "plugin management commands"
+cmdAdminAliases: "plugin management command alias"
+cmdWhitelist: "Commands that can be used in the game room"
+
+restoreWorld: |-
+ Restore the map(world) after the game is over
+ Note: The map(world) is only backed up when loading the room for the first time!
+autoCreateTemporaryRoom: "Automatically create a temporary room to ensure that there is at least one free room"
+
+AutomaticJoinGame: "Players automatically join the game room after entering the server (applicable to group service game sub-service scene)"
+QuitRoom.cmd: "Exit Room Execute Command"
+AutomaticNextRound: "After the game is over, it will automatically join the next round (it is recommended to open the autoCreateTemporaryRoom)"
+
+killerVictoryCmd: "Killer Triumph Execute Command (Killer Execute Only)"
+commonPeopleVictoryCmd: "Civilian and Detective Victory Execute Command (only executed by surviving players)"
+killKillerCmd: "The player who kills the killer executes the command."
+defeatCmd: "Failed to execute command"
\ No newline at end of file
diff --git a/src/main/resources/Resources/Language/ConfigDescription/zh_CN.yml b/src/main/resources/Resources/Language/ConfigDescription/zh_CN.yml
new file mode 100644
index 0000000..1d31f06
--- /dev/null
+++ b/src/main/resources/Resources/Language/ConfigDescription/zh_CN.yml
@@ -0,0 +1,32 @@
+header: |-
+ MurderMystery 插件配置文件
+footer: |-
+ 你已经到达配置文件的底部啦
+
+ConfigVersion: |-
+ 配置文件的版本号
+ 警告! 除非您明确知道您在干什么,否则不要尝试改动此项配置!
+
+defaultLanguage: "插件默认语言设置 可选 zh_CN | en_US | ko_KR | vi_VN | de_DE"
+languageMappingTable: "语言映射表"
+autoUpdateLanguage: "自动更新语言文件"
+
+cmdUser: "插件命令"
+cmdUserAliases: "插件命令别名"
+cmdAdmin: "插件管理命令"
+cmdAdminAliases: "插件管理命令别名"
+cmdWhitelist: "可以在游戏房间中使用的命令"
+
+restoreWorld: |-
+ 结束游戏后还原地图
+ 注意:仅在首次加载房间时备份地图!
+autoCreateTemporaryRoom: "自动创建临时房间 保证至少有一个空闲房间"
+
+AutomaticJoinGame: "玩家进入服务器后自动加入游戏房间(适用于群组服游戏子服场景)"
+QuitRoom.cmd: "退出房间执行命令"
+AutomaticNextRound: "游戏结束后自动加入下一局 (建议开启autoCreateTemporaryRoom)"
+
+killerVictoryCmd: "杀手胜利执行命令(仅杀手执行)"
+commonPeopleVictoryCmd: "平民与侦探胜利执行命令(仅存活的玩家执行)"
+killKillerCmd: "击杀杀手的玩家执行命令"
+defeatCmd: "失败执行命令"
\ No newline at end of file
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 796d768..5460e70 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -1,3 +1,5 @@
+ConfigVersion: 1.4.2
+
#zh_CN | en_US | ko_KR | vi_VN | de_DE
defaultLanguage: zh_CN
languageMappingTable:
@@ -9,14 +11,7 @@ languageMappingTable:
en_GB: "en_US"
de: "de_DE"
autoUpdateLanguage: false
-#结束游戏后还原地图
-#注意:仅在首次加载房间时备份地图!
-#Restore the map(world) after the game is over
-#Note: The map(world) is only backed up when loading the room for the first time!
-restoreWorld: true
-#自动创建临时房间 保证至少有一个空闲房间
-#Automatically create a temporary room to ensure that there is at least one free room
-autoCreateTemporaryRoom: true
+
#插件命令 Plugin commands
cmdUser: murdermystery
cmdUserAliases:
@@ -30,6 +25,17 @@ cmdWhitelist:
- kick
- report
+#结束游戏后还原地图
+#注意:仅在首次加载房间时备份地图!
+#Restore the map(world) after the game is over
+#Note: The map(world) is only backed up when loading the room for the first time!
+restoreWorld: true
+#自动创建临时房间 保证至少有一个空闲房间
+#Automatically create a temporary room to ensure that there is at least one free room
+autoCreateTemporaryRoom: true
+
+#玩家进入服务器后自动加入游戏房间(适用于群组服游戏子服场景)
+AutomaticJoinGame: false
QuitRoom:
#退出房间执行命令
cmd: []
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index ceef49c..771cef2 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
name: MurderMystery
main: cn.lanink.murdermystery.MurderMystery
-version: "1.4.2-PM1E-SNAPSHOT"
+version: "1.4.2-PM1E"
api: ["Nukkit-PM1E"]
load: POSTWORLD
author: "LT_Name"