From 4227506fa2c1d303c24162e8c73146211347c10b Mon Sep 17 00:00:00 2001 From: LT_Name <572413378@qq.com> Date: Sun, 6 Aug 2023 20:09:06 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0AutomaticJoinGame?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lanink/murdermystery/MurderMystery.java | 13 ++++++ .../listener/defaults/PlayerJoinAndQuit.java | 12 ++++++ .../utils/update/ConfigUpdateUtils.java | 40 +++++++++++++++++++ .../Language/ConfigDescription/zh_CN.yml | 32 +++++++++++++++ src/main/resources/config.yml | 22 ++++++---- 5 files changed, 111 insertions(+), 8 deletions(-) create mode 100644 src/main/java/cn/lanink/murdermystery/utils/update/ConfigUpdateUtils.java create mode 100644 src/main/resources/Resources/Language/ConfigDescription/zh_CN.yml diff --git a/src/main/java/cn/lanink/murdermystery/MurderMystery.java b/src/main/java/cn/lanink/murdermystery/MurderMystery.java index c4ab16a..8859bad 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; @@ -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/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: [] From e8601c1c756a2ba6cd93b2244560e15aedc9aeb3 Mon Sep 17 00:00:00 2001 From: LT_Name <572413378@qq.com> Date: Sun, 6 Aug 2023 20:27:42 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8B=B1=E6=96=87?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Language/ConfigDescription/en_US.yml | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/resources/Resources/Language/ConfigDescription/en_US.yml 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 From dbaa09a760c0bd891507ef069484889d7780178e Mon Sep 17 00:00:00 2001 From: LT_Name <572413378@qq.com> Date: Sun, 6 Aug 2023 20:30:02 +0800 Subject: [PATCH 3/3] 1.4.2 --- pom.xml | 11 +++++------ src/main/resources/plugin.yml | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index f165ec0..9c165cb 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ cn.lanink MurderMystery - 1.4.2-SNAPSHOT + 1.4.2 @@ -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 @@ -151,14 +150,14 @@ cn.lanink MemoriesOfTime-GameCore - 1.6.8 + 1.6.11 provided 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/resources/plugin.yml b/src/main/resources/plugin.yml index 99d5869..05f5907 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-SNAPSHOT" +version: "1.4.2" api: ["1.0.9"] load: POSTWORLD author: "LT_Name"