com.github.sanctum.myessentials.commands.BroadcastCommand 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.formatting.completion.SimpleTabCompletion;
import com.github.sanctum.labyrinth.formatting.completion.TabCompletionIndex;
import com.github.sanctum.myessentials.model.CommandBuilder;
import com.github.sanctum.myessentials.model.InternalCommandData;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public final class BroadcastCommand extends CommandBuilder {
public BroadcastCommand() {
super(InternalCommandData.BROADCAST_COMMAND);
}
private final SimpleTabCompletion builder = SimpleTabCompletion.empty();
@Override
public List tabComplete(@NotNull Player player, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException {
return builder
.fillArgs(args)
.then(TabCompletionIndex.ONE, "message")
.then(TabCompletionIndex.TWO, "message", TabCompletionIndex.ONE, "goes")
.then(TabCompletionIndex.THREE, "goes", TabCompletionIndex.TWO, "here")
.get();
}
@Override
public boolean playerView(@NotNull Player player, @NotNull String commandLabel, @NotNull String[] args) {
if (!testPermission(player)) {
return false;
}
api.getMessenger().broadcastMessage(player, String.join(" ", args));
return true;
}
@Override
public boolean consoleView(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
api.getMessenger().broadcastMessage(String.join(" ", args));
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy