All checks were successful
KnarCraft/PlaceholderSigns/pipeline/head This commit looks good
Adds a new copySign command that copies all info about a sign, including current lines, placeholders, waxed state, dye for each side, and glow state for each side. Renames editSign to setSignLine to avoid collision with EssentialsX's editSign Reduces viewSign to a single command Makes viewSign display the looked at sign, instead of creating a session Adds some additional messages Adds missing documentation to the README
55 lines
2.1 KiB
Java
55 lines
2.1 KiB
Java
package net.knarcraft.placeholdersigns.command;
|
|
|
|
import net.knarcraft.knarlib.formatting.StringFormatter;
|
|
import net.knarcraft.placeholdersigns.PlaceholderSigns;
|
|
import net.knarcraft.placeholdersigns.config.PlaceholderSignMessage;
|
|
import net.knarcraft.placeholdersigns.container.SignCopyRequest;
|
|
import org.bukkit.block.Block;
|
|
import org.bukkit.block.Sign;
|
|
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 copying signs, including placeholders
|
|
*/
|
|
public class CopySignCommand implements TabExecutor {
|
|
|
|
@Override
|
|
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
|
|
@NotNull String[] strings) {
|
|
PlaceholderSigns placeholderSigns = PlaceholderSigns.getInstance();
|
|
StringFormatter stringFormatter = placeholderSigns.getStringFormatter();
|
|
if (!(commandSender instanceof Player player)) {
|
|
stringFormatter.displayErrorMessage(commandSender, PlaceholderSignMessage.ERROR_PLAYER_ONLY);
|
|
return false;
|
|
}
|
|
|
|
Block targetBlock = player.getTargetBlockExact(7);
|
|
if (targetBlock == null || !(targetBlock.getState() instanceof Sign sign)) {
|
|
stringFormatter.displayErrorMessage(commandSender, PlaceholderSignMessage.ERROR_NOT_LOOKING_AT_SIGN);
|
|
return false;
|
|
}
|
|
|
|
SignCopyRequest signCopyRequest = new SignCopyRequest(player, sign);
|
|
placeholderSigns.getRequestHandler().addSignCopyRequest(signCopyRequest);
|
|
|
|
stringFormatter.displaySuccessMessage(commandSender, PlaceholderSignMessage.SUCCESS_CLICK_SIGN_TO_PASTE);
|
|
return true;
|
|
}
|
|
|
|
@Nullable
|
|
@Override
|
|
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s,
|
|
@NotNull String[] strings) {
|
|
return new ArrayList<>();
|
|
}
|
|
|
|
}
|