-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(commands): refactoring the command system and adding kill fu…
…nctionality - Renamed multiple classes and packages to make the structure clearer - Added implementation and completion of the kill command - Updated the processing logic of baseplugin command - optimized the implementation of configuration, data query and other functions
- Loading branch information
Showing
22 changed files
with
134 additions
and
76 deletions.
There are no files selected for viewing
55 changes: 24 additions & 31 deletions
55
src/main/java/fun/suya/suisuroru/commands/CommandRegister.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,40 @@ | ||
package fun.suya.suisuroru.commands; | ||
|
||
import fun.suya.suisuroru.commands.execute.CommandManager; | ||
import fun.suya.suisuroru.commands.execute.othercommands.ConfigRoot; | ||
import fun.suya.suisuroru.commands.execute.othercommands.DataRoot; | ||
import fun.suya.suisuroru.commands.execute.othercommands.Help; | ||
import fun.suya.suisuroru.commands.execute.othercommands.ReportQuery; | ||
import fun.suya.suisuroru.commands.execute.othercommands.config.Reload; | ||
import fun.suya.suisuroru.commands.execute.vanilla.Ban; | ||
import fun.suya.suisuroru.commands.execute.vanilla.Kill; | ||
import fun.suya.suisuroru.commands.execute.vanilla.Pardon; | ||
import fun.suya.suisuroru.commands.tab.othercommands.BasePluginTab; | ||
import fun.suya.suisuroru.commands.tab.othercommands.ConfigTab; | ||
import fun.suya.suisuroru.commands.tab.othercommands.DataTab; | ||
import fun.suya.suisuroru.commands.tab.othercommands.ReportTab; | ||
import fun.suya.suisuroru.commands.tab.vanilla.BanTab; | ||
import fun.suya.suisuroru.commands.tab.vanilla.KillTab; | ||
import fun.suya.suisuroru.commands.tab.vanilla.PardonTab; | ||
import fun.suya.suisuroru.config.Config; | ||
import fun.suya.suisuroru.commands.execute.othercommands.sub.Config; | ||
import fun.suya.suisuroru.commands.execute.othercommands.sub.Data; | ||
import fun.suya.suisuroru.commands.execute.othercommands.sub.Help; | ||
import fun.suya.suisuroru.commands.execute.othercommands.sub.ReportQuery; | ||
import fun.suya.suisuroru.commands.execute.othercommands.sub.config.Reload; | ||
import fun.suya.suisuroru.commands.tab.othercommands.BasePlugin; | ||
import fun.suya.suisuroru.commands.tab.othercommands.sub.Report; | ||
import fun.suya.suisuroru.commands.tab.vanilla.Ban; | ||
import fun.suya.suisuroru.commands.tab.vanilla.Kill; | ||
import fun.suya.suisuroru.commands.tab.vanilla.Pardon; | ||
import fun.xd.suka.command.ReportCommand; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public class CommandRegister { | ||
public static void registerCommand(JavaPlugin plugin) { | ||
if (Config.VanillaCommandsRewritten) { | ||
if (fun.suya.suisuroru.config.Config.VanillaCommandsRewritten) { | ||
// vanilla functions | ||
plugin.getCommand("ban").setExecutor(new Ban()); | ||
plugin.getCommand("ban").setTabCompleter(new BanTab()); | ||
plugin.getCommand("pardon").setExecutor(new Pardon()); | ||
plugin.getCommand("pardon").setTabCompleter(new PardonTab()); | ||
plugin.getCommand("kill").setExecutor(new Kill()); | ||
plugin.getCommand("kill").setTabCompleter(new KillTab()); | ||
plugin.getCommand("ban").setExecutor(new fun.suya.suisuroru.commands.execute.vanilla.Ban()); | ||
plugin.getCommand("ban").setTabCompleter(new Ban()); | ||
plugin.getCommand("pardon").setExecutor(new fun.suya.suisuroru.commands.execute.vanilla.Pardon()); | ||
plugin.getCommand("pardon").setTabCompleter(new Pardon()); | ||
plugin.getCommand("kill").setExecutor(new fun.suya.suisuroru.commands.execute.vanilla.Kill()); | ||
plugin.getCommand("kill").setTabCompleter(new Kill()); | ||
} | ||
// new functions | ||
plugin.getCommand("basepluginhelp").setExecutor(new Help()); | ||
plugin.getCommand("report").setExecutor(new ReportCommand()); | ||
plugin.getCommand("report").setTabCompleter(new ReportTab()); | ||
plugin.getCommand("bpconfig").setExecutor(new ConfigRoot()); | ||
plugin.getCommand("bpconfig").setTabCompleter(new ConfigTab()); | ||
plugin.getCommand("report").setTabCompleter(new Report()); | ||
plugin.getCommand("bpconfig").setExecutor(new Config()); | ||
plugin.getCommand("bpconfig").setTabCompleter(new fun.suya.suisuroru.commands.tab.othercommands.sub.Config()); | ||
plugin.getCommand("bpreload").setExecutor(new Reload()); | ||
plugin.getCommand("baseplugin").setExecutor(new CommandManager()); | ||
plugin.getCommand("baseplugin").setTabCompleter(new BasePluginTab()); | ||
plugin.getCommand("baseplugin").setExecutor(new fun.suya.suisuroru.commands.execute.othercommands.BasePlugin()); | ||
plugin.getCommand("baseplugin").setTabCompleter(new BasePlugin()); | ||
plugin.getCommand("query-report").setExecutor(new ReportQuery()); | ||
plugin.getCommand("bpdata").setExecutor(new DataRoot()); | ||
plugin.getCommand("bpdata").setTabCompleter(new DataTab()); | ||
plugin.getCommand("bpdata").setExecutor(new Data()); | ||
plugin.getCommand("bpdata").setTabCompleter(new fun.suya.suisuroru.commands.tab.othercommands.sub.Data()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...mands/execute/othercommands/DataRoot.java → ...mands/execute/othercommands/sub/Data.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/fun/suya/suisuroru/commands/execute/othercommands/sub/Kill.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package fun.suya.suisuroru.commands.execute.othercommands.sub; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class Kill implements CommandExecutor { | ||
@Override | ||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { | ||
if (!sender.isOp()) { | ||
sender.sendMessage("你没有权限执行此命令!"); | ||
return true; | ||
} | ||
if (args.length == 0) { | ||
sender.sendMessage("§4请输入玩家名"); | ||
} else { | ||
Player target = sender.getServer().getPlayer(args[0]); | ||
if (target != null && target.isOnline()) { | ||
target.setHealth(0); | ||
Bukkit.broadcastMessage("§4BasePlugin已尝试清除玩家: " + args[0]); | ||
} else { | ||
sender.sendMessage("§4玩家不在线或不存在"); | ||
} | ||
} | ||
return true; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ds/execute/othercommands/ReportQuery.java → ...xecute/othercommands/sub/ReportQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/execute/othercommands/config/Query.java → ...ecute/othercommands/sub/config/Query.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../execute/othercommands/config/Reload.java → ...cute/othercommands/sub/config/Reload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nds/execute/othercommands/config/Set.java → ...execute/othercommands/sub/config/Set.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...nds/execute/othercommands/data/Query.java → ...execute/othercommands/sub/data/Query.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../data/QueryFunctions/DataQueryByName.java → ...mands/sub/data/query/DataQueryByName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ds/data/QueryFunctions/DataQueryByQQ.java → ...ommands/sub/data/query/DataQueryByQQ.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../data/QueryFunctions/DataQueryByUUID.java → ...mands/sub/data/query/DataQueryByUUID.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/fun/suya/suisuroru/commands/tab/othercommands/sub/Kill.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package fun.suya.suisuroru.commands.tab.othercommands.sub; | ||
|
||
import fun.suya.suisuroru.module.impl.OnlinePlayerListGet; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.command.TabCompleter; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Kill implements TabCompleter { | ||
|
||
@Nullable | ||
@Override | ||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { | ||
List<String> completions = new ArrayList<>(); | ||
if (args.length == 1) { | ||
// 返回所有在线玩家的名字 | ||
completions.addAll(OnlinePlayerListGet.GetOnlinePlayerList()); | ||
} | ||
return completions; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.