1.18.2
This commit is contained in:
parent
ced1f642c2
commit
ac8fac4947
9 changed files with 295 additions and 144 deletions
|
@ -8,7 +8,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Date;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
public enum BackupHandler {
|
||||
INSTANCE;
|
||||
|
@ -61,10 +61,10 @@ public enum BackupHandler {
|
|||
server.getPlayerList().saveAll();
|
||||
}
|
||||
|
||||
for (ServerWorld world : server.getAllLevels()) {
|
||||
if (world != null) {
|
||||
for (ServerLevel level : server.getAllLevels()) {
|
||||
if (level != null) {
|
||||
//world.save(null, true, false);
|
||||
world.noSave = true;
|
||||
level.noSave = true;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
@ -114,9 +114,9 @@ public enum BackupHandler {
|
|||
}
|
||||
|
||||
private void enableSaving(MinecraftServer server) {
|
||||
for (ServerWorld world : server.getAllLevels()) {
|
||||
if (world != null) {
|
||||
world.noSave = false;
|
||||
for (ServerLevel level : server.getAllLevels()) {
|
||||
if (level != null) {
|
||||
level.noSave = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,12 @@ import net.minecraftforge.event.TickEvent;
|
|||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.LogicalSide;
|
||||
import net.minecraftforge.fml.LogicalSidedProvider;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
|
||||
import net.minecraftforge.event.server.ServerStartedEvent;
|
||||
import net.minecraftforge.event.server.ServerStoppingEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
@Mod(ExtBackup.MOD_ID)
|
||||
|
@ -31,8 +29,8 @@ public class ExtBackup {
|
|||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ConfigHandler.COMMON_SPEC);
|
||||
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
modBus.addListener(this::setup);
|
||||
modBus.addListener((ModConfig.Loading e) -> ConfigHandler.onConfigLoad());
|
||||
modBus.addListener((ModConfig.Reloading e) -> ConfigHandler.onConfigLoad());
|
||||
//modBus.addListener((ModConfig.Loading e) -> ConfigHandler.onConfigLoad());
|
||||
//modBus.addListener((ModConfig.Reloading e) -> ConfigHandler.onConfigLoad());
|
||||
|
||||
// Register ourselves for server and other game events we are interested in
|
||||
IEventBus forgeBus = MinecraftForge.EVENT_BUS;
|
||||
|
@ -45,12 +43,12 @@ public class ExtBackup {
|
|||
ConfigHandler.onConfigLoad();
|
||||
}
|
||||
|
||||
public void serverAboutToStart(FMLServerStartedEvent event) {
|
||||
public void serverAboutToStart(ServerStartedEvent event) {
|
||||
BackupHandler.INSTANCE.init();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverStopping(FMLServerStoppingEvent event) {
|
||||
public void serverStopping(ServerStoppingEvent event) {
|
||||
if (ConfigHandler.COMMON.force_on_shutdown.get()) {
|
||||
MinecraftServer server = event.getServer();
|
||||
|
||||
|
@ -61,9 +59,10 @@ public class ExtBackup {
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void serverTick(TickEvent.ServerTickEvent event) {
|
||||
public static void serverTick(TickEvent.WorldTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START) {
|
||||
MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER);
|
||||
//MinecraftServer server = LogicalSidedProvider.INSTANCE.get(LogicalSide.SERVER);
|
||||
MinecraftServer server = event.world.getServer();
|
||||
|
||||
if (server != null) {
|
||||
//logger.debug("Server Tick! " + event.phase);
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
package com.github.jinks.extbackup;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.text.ChatType;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class ExtBackupUtil {
|
||||
|
||||
public static void broadcast(MinecraftServer server, String message) {
|
||||
if (!ConfigHandler.COMMON.silent.get()) {
|
||||
StringTextComponent bcMessage = new StringTextComponent("[§1ExtBackup§r] " + message);
|
||||
Component bcMessage = new TextComponent("[§1ExtBackup§r] " + message);
|
||||
server.getPlayerList().broadcastMessage(bcMessage, ChatType.SYSTEM, Util.NIL_UUID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
modLoader="javafml"
|
||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||
# Forge for 1.16.3 is version 34
|
||||
loaderVersion="[36.1,)"
|
||||
loaderVersion="[40,)"
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
issueTrackerURL="https://github.com/jinks/extbackup/issues"
|
||||
license="GPL"
|
||||
|
@ -22,13 +22,13 @@
|
|||
[[dependencies.extbackup]]
|
||||
modId="forge"
|
||||
mandatory=true
|
||||
versionRange="[36.1,)"
|
||||
versionRange="[40,)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
[[dependencies.extbackup]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.16.5]"
|
||||
versionRange="[1.18.2]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
side="BOTH"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"pack": {
|
||||
"description": "ExtBackup resources",
|
||||
"pack_format": 6,
|
||||
"pack_format": 8,
|
||||
"_comment": "A pack_format of 6 requires json lang files and some texture changes from 1.16.2. Note: we require v6 pack meta for all mods."
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue