Makes output text configurable Adds improved formatting and colors when displaying sign contents Adds information about applied dye and glow status for signs Properly cancels the default event when using the viewSign and viewSignRaw commands
54 lines
1.6 KiB
Java
54 lines
1.6 KiB
Java
package net.knarcraft.placeholdersigns.command;
|
|
|
|
import net.knarcraft.placeholdersigns.PlaceholderSigns;
|
|
import net.knarcraft.placeholdersigns.config.PlaceholderSignMessage;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.command.TabExecutor;
|
|
import org.bukkit.entity.Player;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* A command for viewing lines on a sign
|
|
*/
|
|
public class ViewSignCommand implements TabExecutor {
|
|
|
|
boolean raw;
|
|
|
|
/**
|
|
* Instantiates a new view sign command
|
|
*
|
|
* @param raw <p>Whether this sign displays the raw text or not</p>
|
|
*/
|
|
public ViewSignCommand(boolean raw) {
|
|
this.raw = raw;
|
|
}
|
|
|
|
@Override
|
|
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String label,
|
|
@NotNull String[] args) {
|
|
if (!(commandSender instanceof Player player)) {
|
|
return false;
|
|
}
|
|
|
|
// Register the sign view request
|
|
PlaceholderSigns.getInstance().getRequestHandler().addSignViewRequest(player, this.raw);
|
|
|
|
PlaceholderSigns.getInstance().getStringFormatter().displaySuccessMessage(commandSender,
|
|
PlaceholderSignMessage.SUCCESS_CLICK_SIGN_TO_VIEW);
|
|
return true;
|
|
}
|
|
|
|
@Nullable
|
|
@Override
|
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label,
|
|
@NotNull String[] args) {
|
|
return new ArrayList<>();
|
|
}
|
|
|
|
}
|