All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.sanctum.myessentials.commands.ReloadCommand Maven / Gradle / Ivy

The newest version!
/*
 *  Copyright 2021 Sanctum 
 *
 *  This file is part of myEssentials, a derivative work inspired by the
 *  Essentials  and EssentialsX 
 *  projects, both licensed under the GPLv3.
 *
 *  This software is currently in development and its licensing has not
 *  yet been chosen.
 */
package com.github.sanctum.myessentials.commands;

import com.github.sanctum.labyrinth.data.FileManager;
import com.github.sanctum.myessentials.Essentials;
import com.github.sanctum.myessentials.api.MyEssentialsAPI;
import com.github.sanctum.myessentials.model.CommandBuilder;
import com.github.sanctum.myessentials.model.InternalCommandData;
import java.util.Arrays;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public final class ReloadCommand extends CommandBuilder {
	public ReloadCommand() {
		super(InternalCommandData.RELOAD_COMMAND);
	}

	@Override
	public @Nullable
	List tabComplete(@NotNull Player player, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException {
		return null;
	}

	@Override
	public boolean playerView(@NotNull Player player, @NotNull String commandLabel, @NotNull String[] args) {

		if (testPermission(player)) {
			for (String con : Arrays.asList("commands", "messages", "config")) {
				FileManager manager = MyEssentialsAPI.getInstance().getFileList().get(con, "Configuration");
				manager.getRoot().reload();
			}
			sendMessage(player, "&aAll configuration reloaded for &2" + Essentials.getInstance());
			return true;
		}

		return false;
	}

	@Override
	public boolean consoleView(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
		return false;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy