SuperLeadRope/src/main/java/top/r3944realms/superleadrope/content/command/Command.java
3944Realms 3a519afad2 更新版本 v1.0.0 -> v1.1.0
添加了拴绳实体
新增新的附魔
调整拴绳数据cap实现
修改配置
删除无用代码
更新代码版权声明
优化import
2026-02-03 11:46:28 +08:00

142 lines
4.4 KiB
Java

/*
* Super Lead rope mod
* Copyright (C) 2026 R3944Realms
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package top.r3944realms.superleadrope.content.command;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;
import org.jetbrains.annotations.Nullable;
import top.r3944realms.superleadrope.CommonEventHandler;
import top.r3944realms.superleadrope.SuperLeadRope;
import top.r3944realms.superleadrope.content.entity.SuperLeashKnotEntity;
import java.util.List;
/**
* The type Command.
*/
public class Command {
/**
* The constant PREFIX.
*/
public static final String PREFIX = CommonEventHandler.leashConfigManager.getCommandPrefix();
/**
* The constant SHOULD_USE_PREFIX.
*/
public static boolean SHOULD_USE_PREFIX = CommonEventHandler.leashConfigManager.isCommandPrefixEnabled();
/**
* The constant BASE_.
*/
public static final String BASE_ = SuperLeadRope.MOD_ID + ".command.";
/**
* The constant ABBREVIATION.
*/
public static final String ABBREVIATION = BASE_ + "abbreviation";
/**
* The constant BLOCK_POS.
*/
public static final String BLOCK_POS = BASE_ + "block_pos";
/**
* The constant SUC.
*/
public static final String SUC = "suc";
/**
* The constant FAIL.
*/
public static final String FAIL = "fail";
/**
* The constant SUC_FAIL.
*/
public static final String SUC_FAIL = "suc_fail";
/**
* The constant COLON.
*/
public static final String COLON = BASE_ + "colon";
/**
* The constant MAX_SHOW_NUMBER.
*/
public static final int MAX_SHOW_NUMBER = 4;
/**
* The constant END.
*/
public static final String END = BASE_ + "end";
/**
* The constant NONE.
*/
public static final String NONE = BASE_ + "none";
/**
* The constant STATE.
*/
public static final String STATE = BASE_ + "state";
/**
* The constant SLP_LEASH_MESSAGE_.
*/
public static final String SLP_LEASH_MESSAGE_ = Command.BASE_ + "leash.message.";
/**
* The constant ALL_KNOTS.
*/
public static final String ALL_KNOTS = SLP_LEASH_MESSAGE_ + "all_knots";
/**
* The constant ALL_HOLDERS.
*/
public static final String ALL_HOLDERS = SLP_LEASH_MESSAGE_ + "all_holders";
/**
* Gets slp name.
*
* @param entity the entity
* @return the slp name
*/
public static Component getSLPName(Entity entity) {
if (entity instanceof SuperLeashKnotEntity superLeashKnot) {
BlockPos pos = superLeashKnot.getPos();
return Component.translatable(BLOCK_POS, pos.getX(), pos.getY(), pos.getZ());
}
return entity.getDisplayName();
}
/**
* Gets slp name.
*
* @param pos the pos
* @return the slp name
*/
public static Component getSLPName(BlockPos pos) {
return Component.translatable(BLOCK_POS, pos.getX(), pos.getY(), pos.getZ());
}
/**
* Gets liter argument builder of css.
*
* @param name the name
* @param shouldAddToList the should add to list
* @param list the list
* @return the liter argument builder of css
*/
static LiteralArgumentBuilder<CommandSourceStack> getLiterArgumentBuilderOfCSS(String name, boolean shouldAddToList, @Nullable List<LiteralArgumentBuilder<CommandSourceStack>> list) {
LiteralArgumentBuilder<CommandSourceStack> literal = Commands.literal(name);
if (shouldAddToList) {
assert list != null;
list.add(literal);
}
return literal;
}
}