Skip to content

Commit

Permalink
perf(forge): 版本精简
Browse files Browse the repository at this point in the history
采用java8编译以适配1.16.5
  • Loading branch information
cnlimiter committed Feb 3, 2024
1 parent db9a550 commit 4af85be
Show file tree
Hide file tree
Showing 27 changed files with 95 additions and 249 deletions.
6 changes: 1 addition & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ preprocess {
def mc1165 = createNode("1.16.5", 1_16_05, "srg")
def mc1182 = createNode("1.18.2", 1_18_02, "srg")
def mc1192 = createNode("1.19.2", 1_19_02, "srg")
def mc1193 = createNode("1.19.3", 1_19_03, "srg")
def mc1194 = createNode("1.19.4", 1_19_04, "srg")
def mc1201 = createNode("1.20.1", 1_20_01, "srg")

mc1165.link(mc1182, null)
mc1182.link(mc1192, null)
mc1192.link(mc1193, null)
mc1193.link(mc1194, null)
mc1194.link(mc1201, null)
mc1192.link(mc1201, null)
}


6 changes: 3 additions & 3 deletions common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ tasks.register('copyJars', Copy) {

buildNeeded.finalizedBy("copyJars")

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

version = mod_version
group = mod_group_id
archivesBaseName = mod_name + "-" + minecraft_dependency
Expand All @@ -80,9 +83,6 @@ processResources {

tasks.withType(JavaCompile).configureEach {
options.setEncoding("UTF-8")
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of("${jdk_version}")
}
}

jar {
Expand Down
2 changes: 0 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ def versions = Arrays.asList(
"1.16.5",
"1.18.2",
"1.19.2",
"1.19.3",
"1.19.4",
"1.20.1"
)
for (String version : versions) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
package nova.committee.atom.sweep;
package committee.nova.atom.sweep;

import committee.nova.atom.sweep.core.Sweeper;
import committee.nova.atom.sweep.util.FileUtils;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.loading.FMLPaths;
import nova.committee.atom.sweep.core.Sweeper;
import nova.committee.atom.sweep.init.handler.SweepHandler;
import nova.committee.atom.sweep.util.FileUtils;

import static nova.committee.atom.sweep.Static.ATOM_FOLDER;
import static nova.committee.atom.sweep.Static.SWEEP_FOLDER;
import committee.nova.atom.sweep.init.handler.SweepHandler;

public class ISweep {
public ISweep() {
ATOM_FOLDER = FMLPaths.GAMEDIR.get().resolve("atom");
FileUtils.checkFolder(ATOM_FOLDER);
SWEEP_FOLDER = ATOM_FOLDER.resolve("sweep");
FileUtils.checkFolder(SWEEP_FOLDER);
Static.CONFIG_FILE = SWEEP_FOLDER.resolve("config.toml");
Static.ATOM_FOLDER = FMLPaths.GAMEDIR.get().resolve("atom");
FileUtils.checkFolder(Static.ATOM_FOLDER);
Static.SWEEP_FOLDER = Static.ATOM_FOLDER.resolve("sweep");
FileUtils.checkFolder(Static.SWEEP_FOLDER);
Static.CONFIG_FILE = Static.SWEEP_FOLDER.resolve("config.toml");
Static.isLuckPerms = ModList.get().isLoaded("luckperms");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nova.committee.atom.sweep;
package committee.nova.atom.sweep;

import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.luckperms.api.LuckPermsProvider;
Expand All @@ -17,16 +17,16 @@
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
//#if MC < 11900
//$$ import net.minecraft.network.chat.TextComponent;
//$$ import net.minecraft.network.chat.ChatType;
//$$ import net.minecraft.Util;
//$$ import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.ChatType;
import net.minecraft.Util;
import net.minecraft.network.chat.TranslatableComponent;
//#endif

//#if MC < 11700
//$$ import net.minecraftforge.fml.server.ServerLifecycleHooks;
//#if MC >= 11700
//$$ import net.minecraftforge.server.ServerLifecycleHooks;
//#else
import net.minecraftforge.server.ServerLifecycleHooks;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
//#endif
/**
* Description:
Expand All @@ -44,10 +44,10 @@ public class Static {
public static boolean isLuckPerms = false;

public static void sendMessage(Player player, String message) {
//#if MC >= 11900
player.sendSystemMessage(Component.translatable(message));
//#if MC < 11900
player.sendMessage(new TranslatableComponent(message), Util.NIL_UUID);
//#else
//$$ player.sendMessage(new TranslatableComponent(message), Util.NIL_UUID);
//$$ player.sendSystemMessage(Component.translatable(message));
//#endif
}

Expand All @@ -60,27 +60,27 @@ public static void sendMessageToAllPlayers(Component message, boolean actionBar)

public static void sendMessageToAllPlayers(MinecraftServer server1, String message, Object... args) {

//#if MC >= 11900
//#if MC < 11900
new Thread(() -> Optional.ofNullable(server1).ifPresent(server -> server.getPlayerList()
.broadcastSystemMessage(Component.literal(MessageFormat.format(message, args)), true)))
.broadcastMessage(new TextComponent(MessageFormat.format(message, args)), ChatType.SYSTEM, Util.NIL_UUID)))
.start();
//#else
//$$ new Thread(() -> Optional.ofNullable(server1).ifPresent(server -> server.getPlayerList()
//$$ .broadcastMessage(new TextComponent(MessageFormat.format(message, args)), ChatType.SYSTEM, Util.NIL_UUID)))
//$$ .broadcastSystemMessage(Component.literal(MessageFormat.format(message, args)), true)))
//$$ .start();
//#endif


}

public static void sendMessageToAllPlayers(String message, Object... args) {
//#if MC >= 11900
//#if MC < 11900
new Thread(() -> Optional.ofNullable(SERVER).ifPresent(server -> server.getPlayerList()
.broadcastSystemMessage(Component.literal(MessageFormat.format(message, args)), true)))
.broadcastMessage(new TextComponent(MessageFormat.format(message, args)), ChatType.SYSTEM, Util.NIL_UUID)))
.start();
//#else
//$$ new Thread(() -> Optional.ofNullable(SERVER).ifPresent(server -> server.getPlayerList()
//$$ .broadcastMessage(new TextComponent(MessageFormat.format(message, args)), ChatType.SYSTEM, Util.NIL_UUID)))
//$$ .broadcastSystemMessage(Component.literal(MessageFormat.format(message, args)), true)))
//$$ .start();
//#endif
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package nova.committee.atom.sweep;
package committee.nova.atom.sweep;

import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import committee.nova.atom.sweep.common.cmd.SweepCommand;
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
import nova.committee.atom.sweep.common.cmd.SweepCommand;
import org.jetbrains.annotations.NotNull;

@Mod(Static.MOD_ID)
Expand Down Expand Up @@ -43,7 +42,7 @@ public void onServerTick(TickEvent.ServerTickEvent event) {
}

@SubscribeEvent
public void onServerStopping(@NotNull FMLServerStoppingEvent event) {
public void onServerStopping(@NotNull FMLServerStoppedEvent event) {
this.sweep.onServerStopping(event.getServer());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package nova.committee.atom.sweep.common.cmd;
package committee.nova.atom.sweep.common.cmd;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import committee.nova.atom.sweep.Static;
import committee.nova.atom.sweep.core.Sweeper;
import committee.nova.atom.sweep.init.config.ModConfig;
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;
import nova.committee.atom.sweep.init.config.ModConfig;


/**
Expand Down Expand Up @@ -119,10 +118,10 @@ private static int itemWhiteDel(CommandContext<CommandSourceStack> context) thro
private static int entityWhiteAdd(CommandContext<CommandSourceStack> 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) {
//#if MC < 11900
if (ForgeRegistries.ENTITIES.getValue(entityName) != null) {
//#else
//$$ if (ForgeRegistries.ENTITIES.getValue(entityName) != null) {
//$$ if (ForgeRegistries.ENTITY_TYPES.getValue(entityName) != null) {
//#endif
ModConfig.INSTANCE.getMob().addMobEntitiesWhitelist(entityName.toString());
ModConfig.INSTANCE.save();
Expand All @@ -136,10 +135,10 @@ private static int entityWhiteAdd(CommandContext<CommandSourceStack> context) th
private static int entityWhiteDel(CommandContext<CommandSourceStack> 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) {
//#if MC < 11900
if (ForgeRegistries.ENTITIES.getValue(entityName) != null) {
//#else
//$$ if (ForgeRegistries.ENTITIES.getValue(entityName) != null) {
//$$ if (ForgeRegistries.ENTITY_TYPES.getValue(entityName) != null) {
//#endif
ModConfig.INSTANCE.getItem().delItemEntitiesWhitelist(entityName.toString());
ModConfig.INSTANCE.save();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package nova.committee.atom.sweep.core;
package committee.nova.atom.sweep.core;


import committee.nova.atom.sweep.core.model.ASItem;
import committee.nova.atom.sweep.core.model.ASMob;
import lombok.val;
import net.minecraft.network.chat.Component;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
Expand All @@ -16,12 +17,9 @@
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.entity.projectile.*;
import net.minecraft.world.entity.vehicle.Boat;
import net.minecraft.world.item.Item;
import nova.committee.atom.sweep.Static;
import nova.committee.atom.sweep.core.model.ASItem;
import nova.committee.atom.sweep.core.model.ASMob;
import nova.committee.atom.sweep.init.config.ModConfig;
import nova.committee.atom.sweep.init.handler.SweepHandler;
import committee.nova.atom.sweep.Static;
import committee.nova.atom.sweep.init.config.ModConfig;
import committee.nova.atom.sweep.init.handler.SweepHandler;

import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -155,10 +153,10 @@ private int cleanupEntity(ServerLevel world, Predicate<Entity> type, Predicate<E
if (ModConfig.INSTANCE.getMob().isExpOn()) {
entity.kill();
} else {
//#if MC >= 11800
entity.discard();
//#if MC < 11800
entity.kill();
//#else
//$$ entity.kill();
//$$ entity.discard();
//#endif
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package nova.committee.atom.sweep.core.model;
package committee.nova.atom.sweep.core.model;


import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraftforge.registries.ForgeRegistries;
import nova.committee.atom.sweep.Static;
import nova.committee.atom.sweep.init.config.ModConfig;
import committee.nova.atom.sweep.init.config.ModConfig;

/**
* Description:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package nova.committee.atom.sweep.core.model;
package committee.nova.atom.sweep.core.model;


import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import nova.committee.atom.sweep.Static;
import nova.committee.atom.sweep.init.config.ModConfig;
import committee.nova.atom.sweep.init.config.ModConfig;


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nova.committee.atom.sweep.init.config;
package committee.nova.atom.sweep.init.config;

import cn.evole.config.toml.AutoLoadTomlConfig;
import cn.evole.config.toml.annotation.TableField;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nova.committee.atom.sweep.init.config;
package committee.nova.atom.sweep.init.config;

import cn.evole.config.toml.AutoLoadTomlConfig;
import cn.evole.config.toml.annotation.TableField;
Expand All @@ -22,9 +22,9 @@ public class ItemsConfig extends AutoLoadTomlConfig {
private boolean itemWhiteMode = true;
@TableField(rightComment = "黑名单模式")
private boolean itemBlackMode = true;
@TableField(rightComment = "白名单(优先级高于黑名单)")
@TableField(rightComment = "白名单(优先级高于黑名单),使用<modid:*>实现通配符功能")
private List<String> itemEntitiesWhitelist = Arrays.asList("minecraft:diamond", "minecraft:emerald");
@TableField(rightComment = "黑名单")
@TableField(rightComment = "黑名单,使用<modid:*>实现通配符功能")
private List<String> itemEntitiesBlacklist = Collections.emptyList();

public ItemsConfig() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nova.committee.atom.sweep.init.config;
package committee.nova.atom.sweep.init.config;

import cn.evole.config.toml.AutoLoadTomlConfig;
import cn.evole.config.toml.annotation.TableField;
Expand All @@ -16,24 +16,24 @@
*/

public class MobsConfig extends AutoLoadTomlConfig {
@TableField(rightComment = "生物实体清理功能最高优先级")
@TableField(rightComment = "生物实体清理功能(最高优先级)")
private boolean isMobEntityCleanupEnable = true;
@TableField(rightComment = "生物清理是否掉落经验")
private boolean isExpOn = false;
@TableField(rightComment = "动物实体清理功能(次级)")
@TableField(rightComment = "动物实体清理功能(次级)")
private boolean isAnimalEntitiesCleanupEnable = true;
@TableField(rightComment = "怪物实体清理功能(次级)")
@TableField(rightComment = "怪物实体清理功能(次级)")
private boolean isMonsterEntitiesCleanupEnable = true;
@TableField(rightComment = "白名单模式")
private boolean mobWhiteMode = true;
@TableField(rightComment = "黑名单模式")
private boolean mobBlackMode = true;
@TableField(rightComment = "生物白名单")
@TableField(rightComment = "生物白名单(优先级高于黑名单),使用<modid:*>实现通配符功能")
private List<String> mobEntitiesWhitelist = Arrays.asList(
"minecraft:chicken", "minecraft:cat", "minecraft:mule", "minecraft:wolf", "minecraft:horse", "minecraft:donkey",
"minecraft:wither", "minecraft:guardian", "minecraft:villager", "minecraft:iron_golem", "minecraft:snow_golem",
"minecraft:vindicator", "minecraft:ender_dragon", "minecraft:elder_guardian");
@TableField(rightComment = "生物黑名单")
@TableField(rightComment = "生物黑名单,使用<modid:*>实现通配符功能")
private List<String> mobEntitiesBlacklist = Collections.emptyList();

public boolean isAnimalEntitiesCleanupEnable() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package nova.committee.atom.sweep.init.config;
package committee.nova.atom.sweep.init.config;

import cn.evole.config.toml.AutoReloadToml;
import cn.evole.config.toml.TomlUtil;
import cn.evole.config.toml.annotation.Reload;
import cn.evole.config.toml.annotation.TableField;
import committee.nova.atom.sweep.Static;
import org.tomlj.TomlTable;
import lombok.Getter;
import lombok.Setter;
import nova.committee.atom.sweep.Static;

/**
* Name: atomsweep / SweepConfig
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nova.committee.atom.sweep.init.config;
package committee.nova.atom.sweep.init.config;

import cn.evole.config.toml.AutoLoadTomlConfig;
import cn.evole.config.toml.annotation.TableField;
Expand Down
Loading

0 comments on commit 4af85be

Please sign in to comment.