feat: 修改指令的判断逻辑
This commit is contained in:
1 parent
2967c021e5
commit
ba034dd12f
1 file changed
+3
-12
@@ -110,8 +110,8 @@ public class ServerMain implements ModInitializer, CarpetExtension {
|
|||||||
public void registerCommands(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess commandBuildContext) {
|
public void registerCommands(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess commandBuildContext) {
|
||||||
dispatcher.register(CommandManager.literal("hat")
|
dispatcher.register(CommandManager.literal("hat")
|
||||||
.requires(ServerCommandSource::isExecutedByPlayer)
|
.requires(ServerCommandSource::isExecutedByPlayer)
|
||||||
|
.requires((commandSource) -> SLSCarpetSettings.canUseHatCommand)
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
if(SLSCarpetSettings.canUseHatCommand){
|
|
||||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||||
assert player != null;
|
assert player != null;
|
||||||
ItemStack stack = player.getMainHandStack();
|
ItemStack stack = player.getMainHandStack();
|
||||||
@@ -119,18 +119,14 @@ public class ServerMain implements ModInitializer, CarpetExtension {
|
|||||||
player.equipStack(EquipmentSlot.HEAD, stack);
|
player.equipStack(EquipmentSlot.HEAD, stack);
|
||||||
player.getInventory().setStack(player.getInventory().selectedSlot, head);
|
player.getInventory().setStack(player.getInventory().selectedSlot, head);
|
||||||
player.currentScreenHandler.syncState();
|
player.currentScreenHandler.syncState();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
else {
|
|
||||||
context.getSource().sendMessage(Text.literal("服务器尚未启用本指令!").setStyle(Style.EMPTY.withColor(Formatting.RED)));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
dispatcher.register(CommandManager.literal("sit")
|
dispatcher.register(CommandManager.literal("sit")
|
||||||
.requires(ServerCommandSource::isExecutedByPlayer)
|
.requires(ServerCommandSource::isExecutedByPlayer)
|
||||||
|
.requires((commandSource) -> SLSCarpetSettings.canUseSitCommand)
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
if(SLSCarpetSettings.canUseSitCommand){
|
|
||||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||||
assert player != null;
|
assert player != null;
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
@@ -142,11 +138,6 @@ public class ServerMain implements ModInitializer, CarpetExtension {
|
|||||||
player.startRiding(armorStandEntity);
|
player.startRiding(armorStandEntity);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
else {
|
|
||||||
context.getSource().sendMessage(Text.literal("服务器尚未启用本指令!").setStyle(Style.EMPTY.withColor(Formatting.RED)));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user