mirror of
https://github.com/Freezy-Studios/BlazeSMP.git
synced 2025-04-22 01:14:03 +02:00
add DiscordCommand
This commit is contained in:
parent
7aebce806a
commit
aa7f495488
2 changed files with 42 additions and 4 deletions
|
@ -1,10 +1,7 @@
|
|||
package me.freezy.plugins.papermc.blazesmp;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.freezy.plugins.papermc.blazesmp.command.ClaimCommand;
|
||||
import me.freezy.plugins.papermc.blazesmp.command.ClanCommand;
|
||||
import me.freezy.plugins.papermc.blazesmp.command.HomeCommand;
|
||||
import me.freezy.plugins.papermc.blazesmp.command.ReportCommand;
|
||||
import me.freezy.plugins.papermc.blazesmp.command.*;
|
||||
import me.freezy.plugins.papermc.blazesmp.listener.*;
|
||||
import me.freezy.plugins.papermc.blazesmp.module.manager.Clans;
|
||||
import me.freezy.plugins.papermc.blazesmp.module.manager.Homes;
|
||||
|
@ -73,6 +70,7 @@ public final class BlazeSMP extends JavaPlugin {
|
|||
new ReportCommand().register();
|
||||
new ClaimCommand().register();
|
||||
new HomeCommand().register();
|
||||
new DiscordCommand().register();
|
||||
this.log.info("Registered Commands!");
|
||||
|
||||
this.log.info("Registering EventListeners...");
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package me.freezy.plugins.papermc.blazesmp.command;
|
||||
|
||||
import me.freezy.plugins.papermc.blazesmp.BlazeSMP;
|
||||
import me.freezy.plugins.papermc.blazesmp.command.util.SimpleCommand;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DiscordCommand extends SimpleCommand {
|
||||
|
||||
private final String discordUrl;
|
||||
|
||||
public DiscordCommand() {
|
||||
super("discord");
|
||||
this.discordUrl = BlazeSMP.getInstance().getConfig().getString("discord-url");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
Component message = MiniMessage.miniMessage().deserialize("<click:open_url:'" + discordUrl + "'><gradient:#00ff00:#0000ff><b>Click here to join our Discord!</b></gradient></click>");
|
||||
player.sendMessage(message);
|
||||
} else {
|
||||
sender.sendMessage("This command can only be used by players.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue