Adds a reload command

This commit is contained in:
Kristian Knarvik 2023-03-26 17:56:49 +02:00
parent 592f53ec9e
commit 9a56f58f2f
3 changed files with 49 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import net.knarcraft.dropper.command.JoinArenaCommand;
import net.knarcraft.dropper.command.JoinArenaTabCompleter;
import net.knarcraft.dropper.command.LeaveArenaCommand;
import net.knarcraft.dropper.command.ListArenaCommand;
import net.knarcraft.dropper.command.ReloadCommand;
import net.knarcraft.dropper.command.RemoveArenaCommand;
import net.knarcraft.dropper.command.RemoveArenaTabCompleter;
import net.knarcraft.dropper.container.SerializableMaterial;
@ -65,6 +66,14 @@ public final class Dropper extends JavaPlugin {
return this.playerRegistry;
}
/**
* Reloads all configurations and data from disk
*/
public void reload() {
// Load all arenas again
this.arenaHandler.loadArenas();
}
@Override
public void onLoad() {
super.onLoad();
@ -97,6 +106,7 @@ public final class Dropper extends JavaPlugin {
pluginManager.registerEvents(new MoveListener(), this);
pluginManager.registerEvents(new PlayerLeaveListener(), this);
registerCommand("dropperreload", new ReloadCommand(), null);
registerCommand("droppercreate", new CreateArenaCommand(), null);
registerCommand("dropperlist", new ListArenaCommand(), null);
registerCommand("dropperjoin", new JoinArenaCommand(), new JoinArenaTabCompleter());

View File

@ -0,0 +1,33 @@
package net.knarcraft.dropper.command;
import net.knarcraft.dropper.Dropper;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
/**
* The command for reloading the plugin
*/
public class ReloadCommand implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
@NotNull String[] arguments) {
Dropper.getInstance().reload();
commandSender.sendMessage("Plugin reloaded!");
return true;
}
@Nullable
@Override
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
@NotNull String[] arguments) {
return new ArrayList<>();
}
}

View File

@ -5,6 +5,12 @@ api-version: 1.19
description: A plugin for dropper mini-games
commands:
dropperreload:
aliases:
- dreload
permission: dropper.admin
usage: /<command>
description: Reloads all data from disk
dropperlist:
aliases:
- dlist