Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
CptbeffHeart committed Aug 25, 2024
2 parents 3b4916f + 8395dde commit 8734c91
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.expectale.customserverlinks;

import com.expectale.customserverlinks.command.ServerLinksReloadCommand;
import com.expectale.customserverlinks.serverlinks.ServerLinkManager;
import com.expectale.customserverlinks.listener.ServerLinkListener;
import org.bukkit.plugin.java.JavaPlugin;
Expand All @@ -18,6 +19,7 @@ public void onEnable() {

saveDefaultConfig();
getServer().getPluginManager().registerEvents(new ServerLinkListener(), this);
getCommand("customserverlinks").setExecutor(new ServerLinksReloadCommand());
ServerLinkManager.reloadLinks();

LOGGER.info("CustomServerLinks enabled");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.expectale.customserverlinks.command;

import com.expectale.customserverlinks.CustomServerLinks;
import com.expectale.customserverlinks.serverlinks.ServerLinkManager;
import net.kyori.adventure.text.Component;
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.List;

public class ServerLinksReloadCommand implements TabExecutor {

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (args.length == 0 || !args[0].equalsIgnoreCase("reload")) return false;
CustomServerLinks.INSTANCE.reloadConfig();
ServerLinkManager.reloadLinks();
sender.sendMessage(Component.text("§a[!] CustomServerLinks config have been reloaded"));
return true;
}

@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
return List.of("reload");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static List<AbstractServerLink> getLinks() {
}

public static void reloadLinks() {
LINKS.clear();
FileConfiguration config = CustomServerLinks.INSTANCE.getConfig();
for (String key : config.getKeys(false)) {

Expand Down
9 changes: 8 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@ name: CustomServerLinks
version: '${version}'
main: com.expectale.customserverlinks.CustomServerLinks
api-version: '1.21'
author: CptBeffHeart
author: CptBeffHeart

commands:
customserverlinks:
description: CustomServerLinks command
aliases: [ "cslink", "cslinks" ]
usage: /cslink reload
permission: "cslink.command"

0 comments on commit 8734c91

Please sign in to comment.