Skip to content

Commit eb3e90a

Browse files
committed
Apply waiting period config to /back command
1 parent ca7d0e5 commit eb3e90a

3 files changed

Lines changed: 24 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [1.4.8] - 2026-04-04
10+
### Changed
11+
- Apply waiting period config to `/back` command
12+
913
## [1.4.7] - 2026-03-04
1014
### Changed
1115
- Updated Essential-Commands importer to support their v0 and v1 schema.

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ minecraft_version=[VERSIONED]
66
curseforge_minecraft_versions=[VERSIONED]
77
modrinth_minecraft_versions=[VERSIONED]
88
java_version=[VERSIONED]
9-
loader_version=0.18.4
9+
loader_version=0.18.6
1010
# Mod Properties
11-
mod_version=1.4.7
11+
mod_version=1.4.8
1212
maven_group=me.drex
1313
archives_base_name=fabric-essentials
1414
# Dependencies

src/main/java/me/drex/essentials/command/impl/teleportation/BackCommand.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
import com.mojang.brigadier.exceptions.CommandSyntaxException;
66
import me.drex.essentials.command.Command;
77
import me.drex.essentials.command.CommandProperties;
8-
import me.drex.essentials.config.Config;
8+
import me.drex.essentials.command.util.CommandUtil;
99
import me.drex.essentials.config.ConfigManager;
1010
import me.drex.essentials.storage.DataStorage;
1111
import me.drex.essentials.storage.PlayerData;
1212
import me.drex.essentials.util.teleportation.Location;
1313
import me.drex.message.api.LocalizedMessage;
1414
import net.minecraft.commands.CommandBuildContext;
1515
import net.minecraft.commands.CommandSourceStack;
16+
import net.minecraft.server.level.ServerLevel;
1617

1718
import static me.drex.message.api.LocalizedMessage.localized;
1819

@@ -36,13 +37,22 @@ private int teleportBack(CommandContext<CommandSourceStack> ctx) throws CommandS
3637
return FAILURE;
3738
}
3839
Location location = playerData.teleportLocations.pop();
39-
source.sendSystemMessage(
40-
LocalizedMessage.builder("fabric-essentials.commands.back")
41-
.addPlaceholders(location.placeholders())
42-
.build()
43-
);
44-
location.teleport(target, ConfigManager.config().teleportation.saveBackCommandLocation);
45-
return SUCCESS;
40+
ServerLevel level = location.getLevel(source.getServer());
41+
42+
if (level != null) {
43+
CommandUtil.asyncTeleport(source, level, location.chunkPos(), config().teleportation.waitingPeriod).whenCompleteAsync((chunkAccess, throwable) -> {
44+
if (chunkAccess == null) return;
45+
source.sendSystemMessage(
46+
LocalizedMessage.builder("fabric-essentials.commands.back")
47+
.addPlaceholders(location.placeholders())
48+
.build()
49+
);
50+
location.teleport(target, ConfigManager.config().teleportation.saveBackCommandLocation);
51+
}, source.getServer());
52+
return SUCCESS;
53+
} else {
54+
throw WORLD_UNKNOWN.create();
55+
}
4656
}
4757

4858
}

0 commit comments

Comments
 (0)