Skip to content

Commit

Permalink
Merge branch 'master' into PM1E
Browse files Browse the repository at this point in the history
  • Loading branch information
lt-name committed Aug 6, 2023
2 parents da6dacf + dbaa09a commit f0ef654
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 15 deletions.
9 changes: 4 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>cn.lanink</groupId>
<artifactId>MurderMystery</artifactId>
<version>1.4.2-PM1E-SNAPSHOT</version>
<version>1.4.2-PM1E<!-- -SNAPSHOT--></version>

<licenses>
<license>
Expand Down Expand Up @@ -81,7 +81,6 @@
<includes>
<include>${project.basedir}/src/main/java/cn/lanink/murdermystery/MurderMystery.java</include>
<include>${project.basedir}/src/main/resources/plugin.yml</include>
<include>${project.basedir}/.circleci/config.yml</include>
</includes>
<replacements>
<replacement>
Expand Down Expand Up @@ -158,7 +157,7 @@
<dependency>
<groupId>com.smallaswater</groupId>
<artifactId>RsNPC</artifactId>
<version>2.3.0</version>
<version>2.3.1</version>
<scope>provided</scope>
</dependency>

Expand All @@ -173,14 +172,14 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>23.1.0</version>
<version>24.0.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<version>1.18.26</version>
<scope>provided</scope>
</dependency>

Expand Down
15 changes: 14 additions & 1 deletion src/main/java/cn/lanink/murdermystery/MurderMystery.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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(
Expand Down Expand Up @@ -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; //游戏结束后自动加入新房间

Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}

}
32 changes: 32 additions & 0 deletions src/main/resources/Resources/Language/ConfigDescription/en_US.yml
Original file line number Diff line number Diff line change
@@ -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"
32 changes: 32 additions & 0 deletions src/main/resources/Resources/Language/ConfigDescription/zh_CN.yml
Original file line number Diff line number Diff line change
@@ -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: "失败执行命令"
22 changes: 14 additions & 8 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ConfigVersion: 1.4.2

#zh_CN | en_US | ko_KR | vi_VN | de_DE
defaultLanguage: zh_CN
languageMappingTable:
Expand All @@ -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:
Expand All @@ -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: []
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit f0ef654

Please sign in to comment.