Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/java/me/Navoei/customdiscsplugin/CustomDiscs.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ public void onDisable() {
}
}

/**
* Perform a reload of the plugin
*/
public void reload() {
onDisable();
onEnable();
}

public static CustomDiscs getInstance() {
return instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import me.Navoei.customdiscsplugin.CustomDiscs;
import me.Navoei.customdiscsplugin.command.SubCommands.CreateCommand;
import me.Navoei.customdiscsplugin.command.SubCommands.DownloadCommand;
import me.Navoei.customdiscsplugin.command.SubCommands.ReloadCommand;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.ChatColor;
Expand All @@ -25,6 +26,7 @@ public class CommandManager implements CommandExecutor, TabCompleter {
public CommandManager() {
subCommands.add(new CreateCommand());
subCommands.add(new DownloadCommand());
subCommands.add(new ReloadCommand());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package me.Navoei.customdiscsplugin.command.SubCommands;

import me.Navoei.customdiscsplugin.CustomDiscs;
import me.Navoei.customdiscsplugin.command.SubCommand;
import me.Navoei.customdiscsplugin.language.Lang;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;

public class ReloadCommand extends SubCommand {

CustomDiscs customDiscs = CustomDiscs.getInstance();

@Override
public String getName() {
return "reload";
}

@Override
public String getDescription() {
return ChatColor.GRAY + "Reloads plugin configuration.";
}

@Override
public String getSyntax() {
return "/customdisc reload";
}

@Override
public void perform(Player player, String[] args) {

if (!player.hasPermission("customdiscs.reload")) {
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.NO_PERMISSION.toString());
player.sendMessage(textComponent);
return;
}

customDiscs.reload();
Component textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(Lang.PREFIX + Lang.RELOAD.toString());
player.sendMessage(textComponent);

}
}
3 changes: 2 additions & 1 deletion src/main/java/me/Navoei/customdiscsplugin/language/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public enum Lang {
SUCCESSFUL_DOWNLOAD("successful-download", "&aFile successfully downloaded to &7%file_path%&a."),
CREATE_DISC("create-disc", "&aCreate a disc by doing &7/cd create filename.extension \"Custom Lore\"&a."),
DOWNLOAD_ERROR("download-error", "&rAn error has occurred while downloading."),
NOW_PLAYING("now-playing","&6Now playing: %song_name%");
NOW_PLAYING("now-playing","&6Now playing: %song_name%"),
RELOAD("reload", "&aReloading complete!");

private final String path;
private final String def;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ successful-download: "&aFile successfully downloaded to &7%file_path%&a."
create-disc: "&aCreate a disc by doing &7/cd create %filename% \"Custom Lore\"&a."
download-error: "&cAn error has occurred while downloading."
now-playing: "&6Now playing: %song_name%"
reload: "&aReloading complete!"