Skip to content

Commit

Permalink
[Add] Config reload command
Browse files Browse the repository at this point in the history
  • Loading branch information
sysnote8main committed Oct 27, 2024
1 parent 75d32c9 commit 727f43b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package jp.azisaba.lgw.rankingdisplayer;

import jp.azisaba.lgw.rankingdisplayer.command.RankingDisplayerCommand;
import jp.azisaba.lgw.rankingdisplayer.command.RankingHoloCommand;
import jp.azisaba.lgw.rankingdisplayer.config.PluginConfig;
import jp.azisaba.lgw.rankingdisplayer.holo.DHListener;
Expand Down Expand Up @@ -58,6 +59,9 @@ public void onEnable() {
Bukkit.getPluginCommand("rankingholo").setExecutor(new RankingHoloCommand());
Bukkit.getPluginCommand("rankingholo").setPermissionMessage(ChatColor.RED + "権限がありません!");

Bukkit.getPluginCommand("rankingdisplayer").setExecutor(new RankingDisplayerCommand(this));
Bukkit.getPluginCommand("rankingdisplayer").setPermissionMessage(ChatColor.RED + "権限がありません!");

if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
new KDSPlaceholderExpansion().register();
}
Expand All @@ -72,11 +76,12 @@ public void onDisable() {
}

public void reloadPluginConfig() {

getLogger().info("Reloading plugin config...");
reloadConfig();

RankingDisplayer.config = new PluginConfig(this);
RankingDisplayer.config.loadConfig();
getLogger().info("Successfully to reload plugin config!");
}

public static PluginConfig getPluginConfig() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package jp.azisaba.lgw.rankingdisplayer.command;

import jp.azisaba.lgw.rankingdisplayer.RankingDisplayer;
import lombok.RequiredArgsConstructor;
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;

@RequiredArgsConstructor
public class RankingDisplayerCommand implements CommandExecutor {
private final RankingDisplayer plugin;

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if(args.length < 1) {
return false;
}
if(sender instanceof Player) {
Player player = (Player) sender;
switch (args[0]) {
case "reload":
if(args.length != 2) {
sender.sendMessage("/" + command.getName() + " reload <type>");
return true;
}
switch (args[1]) {
case "config":
sender.sendMessage("Reloading config...");
plugin.reloadPluginConfig();
sender.sendMessage("Completed to reload config!");
return true;
}
sender.sendMessage("No type matched: " + args[1]);
return true;
}
}
return false;
}
}
3 changes: 3 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ commands:
rankingholo:
usage: /rankingholo <place|remove|remove-all|list>
permission: rankingdisplayer.command.rankingholo
rankingdisplayer:
usage: /rankingdisplayer <reload>
permission: rankingdisplayer.command.rankingdisplayer
permissions:
rankingdisplayer.command.ranking:
default: true

0 comments on commit 727f43b

Please sign in to comment.