Add config toggle to back command; add last tp to back command
This commit is contained in:
parent
a57d06d20a
commit
9fe614fde9
6 changed files with 33 additions and 0 deletions
|
@ -79,6 +79,9 @@ public class AriasEssentials {
|
|||
if(TeleportActioner.isBlacklistedDimension(event.getContainer().Dimension))
|
||||
{
|
||||
event.setCanceled(true);
|
||||
} else {
|
||||
if(AEServerConfig.BACK_ALLOWS_LAST_TP.get())
|
||||
BackPositionCaches.Update(event.getContainer().PlayerInst.getUUID(), event.getContainer().world_pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,9 @@ public class Messages {
|
|||
public static final String RTP_CACHED;
|
||||
public static final String NO_BACK;
|
||||
public static final String TELEPORT_BACK;
|
||||
public static final String TELEPORT_BACK_DISABLED;
|
||||
public static final String TELEPORT_BACK_LAST;
|
||||
public static final String TELEPORT_BACK_NO_LAST;
|
||||
|
||||
|
||||
static{
|
||||
|
@ -155,5 +158,11 @@ public class Messages {
|
|||
NO_BACK = ESSENTIALS_PREFIX + "!Dark_Green!Good news! You have not died recently, there is no saved back position";
|
||||
TELEPORT_BACK = ESSENTIALS_PREFIX + "!Dark_Purple!You are being taken back to your last death location now.";
|
||||
|
||||
TELEPORT_BACK_DISABLED = ESSENTIALS_PREFIX + "!Dark_Red!You are not an op, and the back command is disabled on this server.";
|
||||
|
||||
TELEPORT_BACK_NO_LAST = ESSENTIALS_PREFIX + "!Dark_Red!You have not teleported recently, nor died. There is nothing to go back to.";
|
||||
|
||||
TELEPORT_BACK_LAST = ESSENTIALS_PREFIX + "!Dark_Purple!You are being taken back to your last death or teleport location.";
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package dev.zontreck.essentials.commands.teleport;
|
|||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import dev.zontreck.essentials.Messages;
|
||||
import dev.zontreck.essentials.configs.AEServerConfig;
|
||||
import dev.zontreck.essentials.util.BackPositionCaches;
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
|
@ -18,6 +19,13 @@ public class BackCommand
|
|||
public static int back(CommandSourceStack ctx)
|
||||
{
|
||||
try {
|
||||
|
||||
if(!AEServerConfig.ENABLE_BACK.get() && !ctx.hasPermission(ctx.getServer().getOperatorUserPermissionLevel()))
|
||||
{
|
||||
ChatHelpers.broadcastTo(ctx.getPlayer(), ChatHelpers.macro(Messages.TELEPORT_BACK_DISABLED), ctx.getServer());
|
||||
return 0;
|
||||
}
|
||||
|
||||
WorldPosition wp = BackPositionCaches.Pop(ctx.getPlayer().getUUID());
|
||||
|
||||
ChatHelpers.broadcastTo(ctx.getPlayer(), ChatHelpers.macro(Messages.TELEPORT_BACK), ctx.getServer());
|
||||
|
|
|
@ -24,6 +24,7 @@ public class TeleportContainer implements Comparable{
|
|||
public Vec3 Position;
|
||||
public Vec2 Rotation;
|
||||
public ServerLevel Dimension;
|
||||
public WorldPosition OldPosition; // Populated in a teleport event
|
||||
|
||||
|
||||
public boolean has_expired(){
|
||||
|
|
|
@ -4,6 +4,7 @@ package dev.zontreck.essentials.commands.teleport;
|
|||
import dev.zontreck.ariaslib.terminal.Task;
|
||||
import dev.zontreck.ariaslib.util.DelayedExecutorService;
|
||||
import dev.zontreck.essentials.events.TeleportEvent;
|
||||
import dev.zontreck.libzontreck.vectors.WorldPosition;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class TeleportRunnable extends Task
|
||||
|
@ -17,6 +18,7 @@ public class TeleportRunnable extends Task
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
Action.OldPosition = new WorldPosition(Action.PlayerInst);
|
||||
|
||||
if(MinecraftForge.EVENT_BUS.post(new TeleportEvent(Action)))
|
||||
{
|
||||
|
|
|
@ -28,6 +28,9 @@ public class AEServerConfig {
|
|||
public static final ForgeConfigSpec.ConfigValue<List<String>> DIMENSION_BLACKLIST;
|
||||
public static final ForgeConfigSpec.ConfigValue<String> BLACKLISTED_DIMENSION_ERROR;
|
||||
|
||||
public static final ForgeConfigSpec.ConfigValue<Boolean> BACK_ALLOWS_LAST_TP;
|
||||
public static final ForgeConfigSpec.ConfigValue<Boolean> ENABLE_BACK;
|
||||
|
||||
public static final ForgeConfigSpec.ConfigValue<List<String>> TELEPORT_EFFECTS;
|
||||
|
||||
|
||||
|
@ -61,6 +64,13 @@ public class AEServerConfig {
|
|||
|
||||
));
|
||||
|
||||
BUILDER.push("back");
|
||||
BACK_ALLOWS_LAST_TP = BUILDER.comment("Whether to allow going back to the last teleport location in addition to the last death (If back is enabled for non-op). The history for the back command goes back only to the very last teleport or death").define("allow_last_tp", true);
|
||||
|
||||
ENABLE_BACK = BUILDER.comment("Enable the use of the back command for non-op?").define("enabled", true);
|
||||
|
||||
BUILDER.pop();
|
||||
|
||||
|
||||
|
||||
BUILDER.pop();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue