diff --git a/common.gradle b/common.gradle index 6d60cab..74e6628 100644 --- a/common.gradle +++ b/common.gradle @@ -14,14 +14,16 @@ repositories { mavenCentral() maven { url 'https://maven.nova-committee.cn/releases' } maven { url 'https://maven.mohistmc.com/' } - + mavenLocal() } dependencies { minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings loom.officialMojangMappings() forge "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}" - implementation forgeRuntimeLibrary(include("cn.evole.config:AtomConfig-Toml:${project.toml_version}")) + implementation forgeRuntimeLibrary(include("cn.evole.config:AtomConfig-Toml:${project.toml_version}")) { + transitive = false + } compileOnly "net.luckperms:api:${lickperms_version}" compileOnly "org.projectlombok:lombok:${lombok_version}" @@ -39,8 +41,15 @@ remapJar { tasks.register('copyJars', Copy) { - from "$projectDir/build/libs" + delete fileTree("$rootDir/build/libs").matching { + include "**/*.jar" + } + delete fileTree("$projectDir/build/libs").matching { + include "**/*.jar" + } into "$rootDir/build/libs" + from("$projectDir/build/libs") + include { details -> details.file.name.contains("${mod_version}") } } buildNeeded.finalizedBy("copyJars") diff --git a/gradle.properties b/gradle.properties index e9aaa13..27f80ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,12 +5,12 @@ org.gradle.daemon=false mod_id=atomsweep mod_name=AtomSweep-forge mod_license=GPL V3 -mod_version=0.2.0 +mod_version=0.2.1 mod_group_id=committee.nova.atom mod_authors=cnlimiter mod_description=Example mod description.\nNewline characters can be used and will be replaced properly. # Dependency Properties minecraft_version=1.20.1 -toml_version=0.1.2 +toml_version=0.1.3 lombok_version=1.18.24 lickperms_version=5.4 \ No newline at end of file diff --git a/src/main/java/nova/committee/atom/sweep/common/cmd/SweepCommand.java b/src/main/java/nova/committee/atom/sweep/common/cmd/SweepCommand.java index fcc5f6f..fffd323 100644 --- a/src/main/java/nova/committee/atom/sweep/common/cmd/SweepCommand.java +++ b/src/main/java/nova/committee/atom/sweep/common/cmd/SweepCommand.java @@ -6,6 +6,9 @@ import lombok.val; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; +import net.minecraft.commands.arguments.ResourceLocationArgument; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.registries.ForgeRegistries; import nova.committee.atom.sweep.Static; import nova.committee.atom.sweep.core.Sweeper; @@ -51,42 +54,98 @@ public static void register(CommandDispatcher dispatcher) { .then( Commands.literal("white") .then( - Commands.literal("add") - .executes(SweepCommand::whiteAdd) - .requires(context -> context.hasPermission(2)) - + Commands.literal("item") + .then( + Commands.literal("add") + .executes(SweepCommand::itemWhiteAdd) + .requires(context -> context.hasPermission(2)) + + ) + .then( + Commands.literal("del") + .executes(SweepCommand::itemWhiteDel) + .requires(context -> context.hasPermission(2)) + ) ) .then( - Commands.literal("del") - .executes(SweepCommand::whiteDel) - .requires(context -> context.hasPermission(2)) + Commands.literal("entity") + .then( + Commands.literal("add") + .then(Commands.argument("entity_name", ResourceLocationArgument.id()) + .executes(SweepCommand::entityWhiteAdd) + ) + .requires(context -> context.hasPermission(2)) + + ) + .then( + Commands.literal("del") + .then(Commands.argument("entity_name", ResourceLocationArgument.id()) + .executes(SweepCommand::entityWhiteDel) + ) + .requires(context -> context.hasPermission(2)) + ) ) + ) ); } - private static int whiteAdd(CommandContext context) throws CommandSyntaxException { + private static int itemWhiteAdd(CommandContext context) throws CommandSyntaxException { val player = context.getSource().getPlayerOrException(); val itemStack = player.getMainHandItem(); if (ForgeRegistries.ITEMS.getKey(itemStack.getItem()) != null) { ModConfig.INSTANCE.getItem().addItemEntitiesWhitelist(ForgeRegistries.ITEMS.getKey(itemStack.getItem()).toString()); ModConfig.INSTANCE.save(); - Static.sendMessage(player, "message.cmd.white.add.success"); + Static.sendMessage(player, "message.cmd.item_white.add.success"); } else { - Static.sendMessage(player, "message.cmd.white.add.fail"); + Static.sendMessage(player, "message.cmd.item_white.add.fail"); } return 1; } - private static int whiteDel(CommandContext context) throws CommandSyntaxException { + private static int itemWhiteDel(CommandContext context) throws CommandSyntaxException { val player = context.getSource().getPlayerOrException(); val itemStack = player.getMainHandItem(); if (ForgeRegistries.ITEMS.getKey(itemStack.getItem()) != null) { ModConfig.INSTANCE.getItem().delItemEntitiesWhitelist(ForgeRegistries.ITEMS.getKey(itemStack.getItem()).toString()); ModConfig.INSTANCE.save(); - Static.sendMessage(player, "message.cmd.white.del.success"); + Static.sendMessage(player, "message.cmd.item_white.del.success"); + } else { + Static.sendMessage(player, "message.cmd.item_white.del.success"); + } + return 1; + } + + private static int entityWhiteAdd(CommandContext context) throws CommandSyntaxException { + val player = context.getSource().getPlayerOrException(); + val entityName = context.getArgument("entity_name", ResourceLocation.class); + //#if MC >= 11900 + if (ForgeRegistries.ENTITY_TYPES.getValue(entityName) != null) { + //#else + //$$ if (ForgeRegistries.ENTITIES.getValue(entityName) != null) { + //#endif + ModConfig.INSTANCE.getMob().addMobEntitiesWhitelist(entityName.toString()); + ModConfig.INSTANCE.save(); + Static.sendMessage(player, "message.cmd.entity_white.add.success"); + } else { + Static.sendMessage(player, "message.cmd.entity_white.add.fail"); + } + return 1; + } + + private static int entityWhiteDel(CommandContext context) throws CommandSyntaxException { + val player = context.getSource().getPlayerOrException(); + val entityName = context.getArgument("entity_name", ResourceLocation.class); + //#if MC >= 11900 + if (ForgeRegistries.ENTITY_TYPES.getValue(entityName) != null) { + //#else + //$$ if (ForgeRegistries.ENTITIES.getValue(entityName) != null) { + //#endif + ModConfig.INSTANCE.getItem().delItemEntitiesWhitelist(entityName.toString()); + ModConfig.INSTANCE.save(); + Static.sendMessage(player, "message.cmd.entity_white.del.success"); } else { - Static.sendMessage(player, "message.cmd.white.del.success"); + Static.sendMessage(player, "message.cmd.entity_white.del.success"); } return 1; } diff --git a/src/main/java/nova/committee/atom/sweep/core/model/ASMob.java b/src/main/java/nova/committee/atom/sweep/core/model/ASMob.java index 6ea7e6e..0a8df77 100644 --- a/src/main/java/nova/committee/atom/sweep/core/model/ASMob.java +++ b/src/main/java/nova/committee/atom/sweep/core/model/ASMob.java @@ -24,7 +24,6 @@ public ASMob(Mob entity) { } public boolean filtrate() { - int index; if (ModConfig.INSTANCE.getMob().isMobWhiteMode()) { // Whitelist for (String s : ModConfig.INSTANCE.getMob().getMobEntitiesWhitelist()) { diff --git a/src/main/java/nova/committee/atom/sweep/init/config/CommonConfig.java b/src/main/java/nova/committee/atom/sweep/init/config/CommonConfig.java index ec04347..1b6ab41 100644 --- a/src/main/java/nova/committee/atom/sweep/init/config/CommonConfig.java +++ b/src/main/java/nova/committee/atom/sweep/init/config/CommonConfig.java @@ -2,7 +2,7 @@ import cn.evole.config.toml.AutoLoadTomlConfig; import cn.evole.config.toml.annotation.TableField; -import cn.evole.libs.tomlj.TomlTable; +import org.tomlj.TomlTable; /** * Name: atomsweep / CommonConfig diff --git a/src/main/java/nova/committee/atom/sweep/init/config/ItemsConfig.java b/src/main/java/nova/committee/atom/sweep/init/config/ItemsConfig.java index e2e11c4..7123c85 100644 --- a/src/main/java/nova/committee/atom/sweep/init/config/ItemsConfig.java +++ b/src/main/java/nova/committee/atom/sweep/init/config/ItemsConfig.java @@ -2,7 +2,7 @@ import cn.evole.config.toml.AutoLoadTomlConfig; import cn.evole.config.toml.annotation.TableField; -import cn.evole.libs.tomlj.TomlTable; +import org.tomlj.TomlTable; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/nova/committee/atom/sweep/init/config/MobsConfig.java b/src/main/java/nova/committee/atom/sweep/init/config/MobsConfig.java index 4575fae..2740f18 100644 --- a/src/main/java/nova/committee/atom/sweep/init/config/MobsConfig.java +++ b/src/main/java/nova/committee/atom/sweep/init/config/MobsConfig.java @@ -2,7 +2,7 @@ import cn.evole.config.toml.AutoLoadTomlConfig; import cn.evole.config.toml.annotation.TableField; -import cn.evole.libs.tomlj.TomlTable; +import org.tomlj.TomlTable; import java.util.Arrays; import java.util.List; diff --git a/src/main/java/nova/committee/atom/sweep/init/config/ModConfig.java b/src/main/java/nova/committee/atom/sweep/init/config/ModConfig.java index 541f03e..b35dedd 100644 --- a/src/main/java/nova/committee/atom/sweep/init/config/ModConfig.java +++ b/src/main/java/nova/committee/atom/sweep/init/config/ModConfig.java @@ -4,7 +4,7 @@ import cn.evole.config.toml.TomlUtil; import cn.evole.config.toml.annotation.Reload; import cn.evole.config.toml.annotation.TableField; -import cn.evole.libs.tomlj.TomlTable; +import org.tomlj.TomlTable; import lombok.Getter; import lombok.Setter; import nova.committee.atom.sweep.Static; diff --git a/src/main/java/nova/committee/atom/sweep/init/config/OthersConfig.java b/src/main/java/nova/committee/atom/sweep/init/config/OthersConfig.java index 01c66ce..ddc1a47 100644 --- a/src/main/java/nova/committee/atom/sweep/init/config/OthersConfig.java +++ b/src/main/java/nova/committee/atom/sweep/init/config/OthersConfig.java @@ -2,7 +2,7 @@ import cn.evole.config.toml.AutoLoadTomlConfig; import cn.evole.config.toml.annotation.TableField; -import cn.evole.libs.tomlj.TomlTable; +import org.tomlj.TomlTable; /** * Name: atomsweep / OthersConfig diff --git a/src/main/resources/assets/atomsweep/lang/en_us.json b/src/main/resources/assets/atomsweep/lang/en_us.json index cde1fb8..ac85005 100644 --- a/src/main/resources/assets/atomsweep/lang/en_us.json +++ b/src/main/resources/assets/atomsweep/lang/en_us.json @@ -7,8 +7,12 @@ "message.atomclean.mobCleanupComplete": "{0} mob entity(entities) removed", "message.atomclean.monsterCleanupComplete": "{0} monster entity(entities) removed", "message.atomclean.animalCleanupComplete": "{0} animal entity(entities) removed", - "message.cmd.white.add.success": "", - "message.cmd.white.add.fail": "", - "message.cmd.white.del.success": "", - "message.cmd.white.del.fail": "" + "message.cmd.item_white.add.success": "", + "message.cmd.item_white.add.fail": "", + "message.cmd.item_white.del.success": "", + "message.cmd.item_white.del.fail": "", + "message.cmd.entity_white.add.success": "", + "message.cmd.entity_white.add.fail": "", + "message.cmd.entity_white.del.success": "", + "message.cmd.entity_white.del.fail": "" } diff --git a/src/main/resources/assets/atomsweep/lang/zh_cn.json b/src/main/resources/assets/atomsweep/lang/zh_cn.json index 741fa17..68efd9a 100644 --- a/src/main/resources/assets/atomsweep/lang/zh_cn.json +++ b/src/main/resources/assets/atomsweep/lang/zh_cn.json @@ -7,8 +7,12 @@ "message.atomclean.mobCleanupComplete": "已清除 {0} 个生物实体。", "message.atomclean.monsterCleanupComplete": "已清除 {0} 个怪物实体。", "message.atomclean.animalCleanupComplete": "已清除 {0} 个动物实体。", - "message.cmd.white.add.success": "已经添加到白名单", - "message.cmd.white.add.fail": "添加到白名单失败", - "message.cmd.white.del.success": "已经从白名单移除", - "message.cmd.white.del.fail": "从白名单移除失败" + "message.cmd.item_white.add.success": "已经添加到白名单", + "message.cmd.item_white.add.fail": "添加到白名单失败", + "message.cmd.item_white.del.success": "已经从白名单移除", + "message.cmd.item_white.del.fail": "从白名单移除失败", + "message.cmd.entity_white.add.success": "已经添加到白名单", + "message.cmd.entity_white.add.fail": "添加到白名单失败", + "message.cmd.entity_white.del.success": "已经从白名单移除", + "message.cmd.entity_white.del.fail": "从白名单移除失败" }