Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Disabling /cosmetics Command #164

Draft
wants to merge 2 commits into
base: remapped
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import me.lojosho.shaded.configurate.yaml.YamlConfigurationLoader;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.permissions.Permission;
Expand Down Expand Up @@ -89,8 +90,16 @@ public void onStart() {
setup();

// Commands
getServer().getPluginCommand("cosmetic").setExecutor(new CosmeticCommand());
getServer().getPluginCommand("cosmetic").setTabCompleter(new CosmeticCommandTabComplete());
final PluginCommand cosmeticCommand = getServer().getPluginCommand("cosmetic");

if(Settings.isCosmeticCommandEnabled()) {
cosmeticCommand.setExecutor(new CosmeticCommand());
cosmeticCommand.setTabCompleter(new CosmeticCommandTabComplete());
} else {
cosmeticCommand.unregister(getServer().getCommandMap());

MessagesUtil.sendDebugMessages("Running HMCCosmetics without default /cosmetic command enabled, You may re-enable this in the configuration by setting 'command-settings.cosmetic-command' to true.");
}

// Listener
getServer().getPluginManager().registerEvents(new PlayerConnectionListener(), this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public class Settings {
private static final String ENABLED_PATH = "enabled";
private static final String SLOT_OPTIONS_PATH = "slot-options";
private static final String BACKPACK_PREVENT_DARKNESS_PATH = "backpack-prevent-darkness";
private static final String COMMAND_SETTINGS_PATH = "command-settings";
private static final String COSMETIC_COMMAND = "cosmetic-command";

@Getter
private static String defaultMenu;
Expand Down Expand Up @@ -169,6 +171,8 @@ public class Settings {
private static boolean emoteMoveCheck;
@Getter @Setter
private static boolean allPlayersHidden;
@Getter
private static boolean cosmeticCommandEnabled;


public static void load(ConfigurationNode source) {
Expand Down Expand Up @@ -278,6 +282,9 @@ public static void load(ConfigurationNode source) {
MessagesUtil.sendDebugMessages("There is a deprecated way of using WG hook setting. Change player_move_check to player-move-check in your configuration to prevent issues in the future. ", Level.WARNING);
worldGuardMoveCheck = worldGuardSettings.node(HOOK_WG_MOVE_CHECK_PATH_LEGACY).getBoolean(true);
}

ConfigurationNode commandSettings = source.node(COMMAND_SETTINGS_PATH);
cosmeticCommandEnabled = commandSettings.node(COSMETIC_COMMAND).getBoolean(true);
}

public static Vector loadVector(final ConfigurationNode config) {
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ cosmetic-settings:
display-name: true
lore: true

command-settings:
cosmetic-command: true # whether the /cosmetics command is enabled

# This is a list of worlds that cosmetics are hidden in. When a player enters one of these worlds, their cosmetics will be hidden.
disabled-worlds:
- "disabledworld"
Expand Down