Skip to content

Commit b9adbc5

Browse files
Merge pull request #11 from AzisabaNetwork/issues-10
リロードしてもコマンドを使えるように変更
2 parents b4b8f60 + 482fccb commit b9adbc5

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

multiserverreward/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.github.aburaagetarou</groupId>
88
<artifactId>MultiServerReward</artifactId>
9-
<version>1.1.0</version>
9+
<version>1.1.1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>MultiServerReward</name>
@@ -17,6 +17,7 @@
1717
</properties>
1818

1919
<build>
20+
<finalName>${project.name}</finalName>
2021
<plugins>
2122
<plugin>
2223
<groupId>org.apache.maven.plugins</groupId>

multiserverreward/src/main/java/com/github/aburaagetarou/MultiServerReward.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.aburaagetarou;
22

3+
import co.aikar.commands.BaseCommand;
34
import org.bukkit.Bukkit;
45
import org.bukkit.plugin.java.JavaPlugin;
56

@@ -15,6 +16,9 @@
1516
import co.aikar.commands.MessageType;
1617
import co.aikar.commands.PaperCommandManager;
1718

19+
import java.util.ArrayList;
20+
import java.util.List;
21+
1822
/**
1923
* MultiServerReward メインクラス
2024
* @author AburaAgeTarou
@@ -27,6 +31,8 @@ public class MultiServerReward extends JavaPlugin
2731
// コマンドAPI
2832
static PaperCommandManager manager;
2933

34+
// コマンドリスト
35+
private static final List<BaseCommand> commands = new ArrayList<>();
3036
/**
3137
* プラグインが有効化されたときの処理
3238
*/
@@ -64,7 +70,7 @@ public void onEnable() {
6470
manager.registerCommand(new MSRCommand().setExceptionHandler((command, registeredCommand, sender, args, t) -> {
6571
sender.sendMessage(MessageType.ERROR, MessageKeys.ERROR_GENERIC_LOGGED);
6672
return true;
67-
}));
73+
}), true);
6874

6975
// 連携先サーバーの場合、報酬データの自動保存を開始
7076
if(!MSRConfig.isOriginal()) {
@@ -95,6 +101,10 @@ public void onDisable() {
95101
});
96102
}
97103

104+
// コマンド登録の解除
105+
commands.forEach(manager::unregisterCommand);
106+
manager.unregisterCommands();
107+
98108
getLogger().info("MultiServerRewardの終了処理が完了しました。");
99109
}
100110

@@ -111,4 +121,11 @@ public static MultiServerReward getInstance() {
111121
public static PaperCommandManager getCommandManager() {
112122
return manager;
113123
}
124+
125+
/**
126+
* コマンドを登録する
127+
*/
128+
public static void addCommand(BaseCommand command) {
129+
commands.add(command);
130+
}
114131
}

multiserverreward/src/main/java/com/github/aburaagetarou/command/MSRCommand.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@
3939
@CommandAlias("msr")
4040
@Description("MultiServerRewardのコマンド")
4141
public class MSRCommand extends BaseCommand {
42-
42+
43+
/**
44+
* コンストラクタ
45+
*/
46+
public MSRCommand() {
47+
MultiServerReward.addCommand(this);
48+
}
49+
4350
@Dependency
4451
private Plugin plugin;
4552

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
main: com.github.aburaagetarou.MultiServerReward
22
name: MultiServerReward
3-
version: "1.1.0"
3+
version: "1.1.1"
44
api: 1.16.5
55
api-version: 1.16
66
depend: ["LeonGunWar"]

0 commit comments

Comments
 (0)