Skip to content

Commit

Permalink
✅ 新增规则
Browse files Browse the repository at this point in the history
  • Loading branch information
1024-byteeeee committed May 12, 2024
1 parent 0c32b30 commit c9828f9
Show file tree
Hide file tree
Showing 10 changed files with 239 additions and 155 deletions.
158 changes: 14 additions & 144 deletions src/main/java/club/mcams/carpet/AmsServerSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ public class AmsServerSettings {
public static String commandGoto = "false";

@Rule(
options = {"false", "all", "realPlayerOnly", "fakePlayerOnly"},
categories = {AMS, SURVIVAL}
options = {"false", "all", "realPlayerOnly", "fakePlayerOnly"},
categories = {AMS, SURVIVAL}
)
public static String sendPlayerDeathLocation = "false";

Expand All @@ -425,6 +425,18 @@ public class AmsServerSettings {
)
public static String commandCustomCommandPermissionLevel = "false";

@Rule(categories = {AMS, FEATURE, SURVIVAL})
public static boolean shulkerGolem = false;

@Rule(categories = {AMS, FEATURE, SURVIVAL})
public static boolean headHunter = false;

@Rule(
options = {"0", "1", "2", "3", "4", "ops", "true", "false"},
categories = {AMS, SURVIVAL, COMMAND}
)
public static String commandGetPlayerSkull = "false";

/*
* 区块加载规则
*/
Expand Down Expand Up @@ -515,148 +527,6 @@ public class AmsServerSettings {
public static boolean betterCraftablePolishedBlackStoneButton = false;
//#endif

//#if MC>=12003
//$$ @GameVersion(version = "Minecraft 1.20.3 - 1.20.6")
//$$ @SuppressWarnings("unused")
//$$ @CraftingRule(
//$$ recipes = {
//$$ //#if MC>=12005
//$$ "flow_armor_trim_smithing_template_smithing_trim.json",
//$$ "wind_charge.json",
//$$ "flow_armor_trim_smithing_template.json",
//$$ "bolt_armor_trim_smithing_template_smithing_trim.json",
//$$ "mace.json",
//$$ "bolt_armor_trim_smithing_template.json",
//$$ //#endif
//$$ "chiseled_copper.json",
//$$ "chiseled_copper_from_copper_block_stonecutting.json",
//$$ "chiseled_copper_from_cut_copper_stonecutting.json",
//$$ "chiseled_tuff.json",
//$$ "chiseled_tuff_bricks.json",
//$$ "chiseled_tuff_bricks_from_polished_tuff_stonecutting.json",
//$$ "chiseled_tuff_bricks_from_tuff_bricks_stonecutting.json",
//$$ "chiseled_tuff_bricks_from_tuff_stonecutting.json",
//$$ "chiseled_tuff_from_tuff_stonecutting.json",
//$$ "copper_bulb.json",
//$$ "copper_door.json",
//$$ "copper_grate.json",
//$$ "copper_grate_from_copper_block_stonecutting.json",
//$$ "copper_trapdoor.json",
//$$ "crafter.json",
//$$ "exposed_chiseled_copper.json",
//$$ "exposed_chiseled_copper_from_exposed_copper_stonecutting.json",
//$$ "exposed_chiseled_copper_from_exposed_cut_copper_stonecutting.json",
//$$ "exposed_copper_bulb.json",
//$$ "exposed_copper_door.json",
//$$ "exposed_copper_grate.json",
//$$ "exposed_copper_grate_from_exposed_copper_stonecutting.json",
//$$ "exposed_copper_trapdoor.json",
//$$ "oxidized_chiseled_copper.json",
//$$ "oxidized_chiseled_copper_from_oxidized_copper_stonecutting.json",
//$$ "oxidized_chiseled_copper_from_oxidized_cut_copper_stonecutting.json",
//$$ "oxidized_copper_bulb.json",
//$$ "oxidized_copper_door.json",
//$$ "oxidized_copper_grate.json",
//$$ "oxidized_copper_grate_from_oxidized_copper_stonecutting.json",
//$$ "oxidized_copper_trapdoor.json",
//$$ "polished_tuff.json",
//$$ "polished_tuff_from_tuff_stonecutting.json",
//$$ "polished_tuff_slab.json",
//$$ "polished_tuff_slab_from_polished_tuff_stonecutting.json",
//$$ "polished_tuff_slab_from_tuff_stonecutting.json",
//$$ "polished_tuff_stairs.json",
//$$ "polished_tuff_stairs_from_polished_tuff_stonecutting.json",
//$$ "polished_tuff_stairs_from_tuff_stonecutting.json",
//$$ "polished_tuff_wall.json",
//$$ "polished_tuff_wall_from_polished_tuff_stonecutting.json",
//$$ "polished_tuff_wall_from_tuff_stonecutting.json",
//$$ "tuff_bricks.json",
//$$ "tuff_bricks_from_polished_tuff_stonecutting.json",
//$$ "tuff_bricks_from_tuff_stonecutting.json",
//$$ "tuff_brick_slab.json",
//$$ "tuff_brick_slab_from_polished_tuff_stonecutting.json",
//$$ "tuff_brick_slab_from_tuff_bricks_stonecutting.json",
//$$ "tuff_brick_slab_from_tuff_stonecutting.json",
//$$ "tuff_brick_stairs.json",
//$$ "tuff_brick_stairs_from_polished_tuff_stonecutting.json",
//$$ "tuff_brick_stairs_from_tuff_bricks_stonecutting.json",
//$$ "tuff_brick_stairs_from_tuff_stonecutting.json",
//$$ "tuff_brick_wall.json",
//$$ "tuff_brick_wall_from_polished_tuff_stonecutting.json",
//$$ "tuff_brick_wall_from_tuff_bricks_stonecutting.json",
//$$ "tuff_brick_wall_from_tuff_stonecutting.json",
//$$ "tuff_slab.json",
//$$ "tuff_slab_from_tuff_stonecutting.json",
//$$ "tuff_stairs.json",
//$$ "tuff_stairs_from_tuff_stonecutting.json",
//$$ "tuff_wall.json",
//$$ "tuff_wall_from_tuff_stonecutting.json",
//$$ "waxed_chiseled_copper.json",
//$$ "waxed_chiseled_copper_from_honeycomb.json",
//$$ "waxed_chiseled_copper_from_waxed_copper_block_stonecutting.json",
//$$ "waxed_chiseled_copper_from_waxed_cut_copper_stonecutting.json",
//$$ "waxed_copper_bulb.json",
//$$ "waxed_copper_bulb_from_honeycomb.json",
//$$ "waxed_copper_door.json",
//$$ "waxed_copper_door_from_honeycomb.json",
//$$ "waxed_copper_grate.json",
//$$ "waxed_copper_grate_from_honeycomb.json",
//$$ "waxed_copper_grate_from_waxed_copper_block_stonecutting.json",
//$$ "waxed_copper_trapdoor.json",
//$$ "waxed_copper_trapdoor_from_honeycomb.json",
//$$ "waxed_exposed_chiseled_copper.json",
//$$ "waxed_exposed_chiseled_copper_from_honeycomb.json",
//$$ "waxed_exposed_chiseled_copper_from_waxed_exposed_copper_stonecutting.json",
//$$ "waxed_exposed_chiseled_copper_from_waxed_exposed_cut_copper_stonecutting.json",
//$$ "waxed_exposed_copper_bulb.json",
//$$ "waxed_exposed_copper_bulb_from_honeycomb.json",
//$$ "waxed_exposed_copper_door.json",
//$$ "waxed_exposed_copper_door_from_honeycomb.json",
//$$ "waxed_exposed_copper_grate.json",
//$$ "waxed_exposed_copper_grate_from_honeycomb.json",
//$$ "waxed_exposed_copper_grate_from_waxed_exposed_copper_stonecutting.json",
//$$ "waxed_exposed_copper_trapdoor.json",
//$$ "waxed_exposed_copper_trapdoor_from_honeycomb.json",
//$$ "waxed_oxidized_chiseled_copper.json",
//$$ "waxed_oxidized_chiseled_copper_from_honeycomb.json",
//$$ "waxed_oxidized_chiseled_copper_from_waxed_oxidized_copper_stonecutting.json",
//$$ "waxed_oxidized_chiseled_copper_from_waxed_oxidized_cut_copper_stonecutting.json",
//$$ "waxed_oxidized_copper_bulb.json",
//$$ "waxed_oxidized_copper_bulb_from_honeycomb.json",
//$$ "waxed_oxidized_copper_door.json",
//$$ "waxed_oxidized_copper_door_from_honeycomb.json",
//$$ "waxed_oxidized_copper_grate.json",
//$$ "waxed_oxidized_copper_grate_from_honeycomb.json",
//$$ "waxed_oxidized_copper_grate_from_waxed_oxidized_copper_stonecutting.json",
//$$ "waxed_oxidized_copper_trapdoor.json",
//$$ "waxed_oxidized_copper_trapdoor_from_honeycomb.json",
//$$ "waxed_weathered_chiseled_copper.json",
//$$ "waxed_weathered_chiseled_copper_from_honeycomb.json",
//$$ "waxed_weathered_chiseled_copper_from_waxed_weathered_copper_stonecutting.json",
//$$ "waxed_weathered_chiseled_copper_from_waxed_weathered_cut_copper_stonecutting.json",
//$$ "waxed_weathered_copper_bulb.json",
//$$ "waxed_weathered_copper_bulb_from_honeycomb.json",
//$$ "waxed_weathered_copper_door.json",
//$$ "waxed_weathered_copper_door_from_honeycomb.json",
//$$ "waxed_weathered_copper_grate.json",
//$$ "waxed_weathered_copper_grate_from_honeycomb.json",
//$$ "waxed_weathered_copper_grate_from_waxed_weathered_copper_stonecutting.json",
//$$ "waxed_weathered_copper_trapdoor.json",
//$$ "waxed_weathered_copper_trapdoor_from_honeycomb.json",
//$$ "weathered_chiseled_copper.json",
//$$ "weathered_chiseled_copper_from_weathered_copper_stonecutting.json",
//$$ "weathered_chiseled_copper_from_weathered_cut_copper_stonecutting.json",
//$$ "weathered_copper_bulb.json",
//$$ "weathered_copper_door.json",
//$$ "weathered_copper_grate.json",
//$$ "weathered_copper_grate_from_weathered_copper_stonecutting.json",
//$$ "weathered_copper_trapdoor.json"
//$$ }
//$$ )
//$$ @Rule(categories = {AMS, CRAFTING, SURVIVAL})
//$$ public static boolean enableMinecraft1_21ExperimentalRecipes = false;
//#endif

public enum blueSkullProbability {
VANILLA,
SURELY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package club.mcams.carpet.commands;

import club.mcams.carpet.commands.rule.commandCustomCommandPermissionLevel.CustomCommandPermissionLevelRegistry;
import club.mcams.carpet.commands.rule.commandGetPlayerSkull.GetPlayerSkullCommandRegistry;
import club.mcams.carpet.commands.rule.commandGetSaveSize.GetSaveSizeCommandRegistry;
import club.mcams.carpet.commands.rule.commandGetSystemInfo.GetSystemInfoCommandRegistry;
import club.mcams.carpet.commands.rule.commandHere.HereCommandRegistry;
Expand Down Expand Up @@ -75,5 +76,7 @@ public static void registerCommands(
GotoCommandRegistry.register(dispatcher);

CustomCommandPermissionLevelRegistry.register(dispatcher);

GetPlayerSkullCommandRegistry.register(dispatcher);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* This file is part of the Carpet AMS Addition project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 A Minecraft Server and contributors
*
* Carpet AMS Addition is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Carpet AMS Addition 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Carpet AMS Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package club.mcams.carpet.commands.rule.commandGetPlayerSkull;

import club.mcams.carpet.AmsServerSettings;
import club.mcams.carpet.utils.CommandHelper;
import club.mcams.carpet.helpers.rule.headHunter_commandGetPlayerSkull.SkullSkinHelper;

import com.mojang.brigadier.CommandDispatcher;

import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;

public class GetPlayerSkullCommandRegistry {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(
CommandManager.literal("getPlayerSkull")
.requires(source -> CommandHelper.canUseCommand(source, AmsServerSettings.commandGetPlayerSkull))
.then(CommandManager.argument("player", EntityArgumentType.players())
.executes(context -> execute(
context.getSource().getPlayer(), EntityArgumentType.getPlayer(context, "player"))
))
);
}

private static int execute(PlayerEntity player, PlayerEntity targetPlayer) {
ItemStack headStack = new ItemStack(Items.PLAYER_HEAD);
SkullSkinHelper.writeNbtToPlayerSkull(targetPlayer, headStack);
player.giveItemStack(headStack);
return 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* along with Carpet AMS Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package club.mcams.carpet.helpers.rule.BlockChunkLoader;
package club.mcams.carpet.helpers.rule.blockChunkLoader;

import club.mcams.carpet.AmsServerSettings;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This file is part of the Carpet AMS Addition project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 A Minecraft Server and contributors
*
* Carpet AMS Addition is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Carpet AMS Addition 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Carpet AMS Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package club.mcams.carpet.helpers.rule.headHunter_commandGetPlayerSkull;

import net.minecraft.entity.player.PlayerEntity;
//#if MC>=12005
//$$ import net.minecraft.component.DataComponentTypes;
//$$ import net.minecraft.component.type.ProfileComponent;
//#endif
import net.minecraft.item.ItemStack;

public class SkullSkinHelper {
public static void writeNbtToPlayerSkull(PlayerEntity player, ItemStack headStack) {
//#if MC>=12005
//$$ ProfileComponent profileComponent = new ProfileComponent(player.getGameProfile());
//$$ headStack.set(DataComponentTypes.PROFILE, profileComponent);
//#else
headStack.getOrCreateNbt().putString("SkullOwner", player.getGameProfile().getName());
//#endif
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* This file is part of the Carpet AMS Addition project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 A Minecraft Server and contributors
*
* Carpet AMS Addition is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Carpet AMS Addition 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Carpet AMS Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package club.mcams.carpet.mixin.rule.headHunter;

import club.mcams.carpet.AmsServerSettings;
import club.mcams.carpet.helpers.rule.headHunter_commandGetPlayerSkull.SkullSkinHelper;

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(PlayerEntity.class)
public abstract class PlayerEntityMixin {
@Inject(
method = "dropInventory",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/player/PlayerInventory;dropAll()V"
)
)
private void dropPlayerSkull(CallbackInfo ci) {
if (AmsServerSettings.headHunter) {
PlayerEntity player = (PlayerEntity) (Object) this;
ItemStack headStack = new ItemStack(Items.PLAYER_HEAD);
SkullSkinHelper.writeNbtToPlayerSkull(player, headStack);
player.dropStack(headStack);
}
}
}
Loading

0 comments on commit c9828f9

Please sign in to comment.