Make the builder command functional

This commit is contained in:
Zontreck 2024-02-18 07:22:06 -07:00
parent 5755389cd0
commit 845a3b920b
3 changed files with 22 additions and 7 deletions

View file

@ -4,6 +4,7 @@ import com.mojang.brigadier.CommandDispatcher;
import dev.zontreck.libzontreck.util.ChatHelpers;
import dev.zontreck.libzontreck.vectors.Vector3;
import dev.zontreck.libzontreck.vectors.WorldPosition;
import dev.zontreck.otemod.configs.OTEServerConfig;
import dev.zontreck.otemod.implementation.Messages;
import dev.zontreck.otemod.registry.ModDimensions;
import net.minecraft.commands.CommandSourceStack;
@ -20,15 +21,24 @@ public class BuildCommand
{
if(stack.isPlayer())
{
return 1;
boolean playerIsOp = stack.getPlayer().hasPermissions(stack.getServer().getOperatorUserPermissionLevel());
if(playerIsOp || OTEServerConfig.ALLOW_BUILDER_DIM.get())
{
WorldPosition pos = new WorldPosition(new Vector3(0, -55, 0), ModDimensions.BUILDER_DIM());
stack.getPlayer().teleportTo(pos.getActualDimension(), pos.Position.x, pos.Position.y, pos.Position.z, 0, 0);
return 0;
}else {
ChatHelpers.broadcastTo(stack.getPlayer(), ChatHelpers.macro(Messages.BUILDER_DIMENSION_DISALLOWED), stack.getServer());
return 0;
}
}else {
stack.sendFailure(ChatHelpers.macro(Messages.CONSOLE_ERROR));
WorldPosition pos = new WorldPosition(new Vector3(0, -55, 0), ModDimensions.BUILDER_DIM());
stack.getPlayer().teleportTo(pos.getActualDimension(), pos.Position.x, pos.Position.y, pos.Position.z, 0, 0);
return 0;
return -1;
}
}
}

View file

@ -14,6 +14,7 @@ public class OTEServerConfig {
public static final ForgeConfigSpec.ConfigValue<Double> SPAWN_EGG_CHANCE;
public static final ForgeConfigSpec.ConfigValue<Integer> ITEM_DESPAWN_TIMER;
public static final ForgeConfigSpec.BooleanValue ALLOW_BUILDER_DIM;
public static final ForgeConfigSpec.ConfigValue<Integer> RTP_COOLDOWN;
@ -52,6 +53,8 @@ public class OTEServerConfig {
BUILDER.pop();
ALLOW_BUILDER_DIM = BUILDER.comment("Allow the builder dimension for non-opped players. This could be dangerous as the builder dimension swaps players into creative").define("allow_non_op_builder", false);
MAX_VAULTS = BUILDER.comment("What is the maximum number of vaults a player may have available? (0 is unlimited)").define("max_vaults", 0);
ITEM_DESPAWN_TIMER = BUILDER.comment("How many times should the item's expire be cancelled. The vanilla expire time is 5 minutes, so this would be ticked down once every 5 minutes.").define("item_extra_lives", 2);

View file

@ -13,6 +13,7 @@ public class Messages {
public static final String FLIGHT_GIVEN;
public static final String FLIGHT_REMOVED;
public static final String BUILDER_DIMENSION_DISALLOWED;
static{
@ -28,5 +29,6 @@ public class Messages {
STARTER_KIT_GIVEN = OTE_PREFIX + "!Dark_Purple!You have been given a starter kit. Welcome to the server.";
FLIGHT_GIVEN = OTE_PREFIX + "!Dark_Green!You start to feel lighter than a feather";
FLIGHT_REMOVED = OTE_PREFIX + "!Dark_Red!You have a sinking feeling you are no longer lighter than a feather.";
BUILDER_DIMENSION_DISALLOWED = OTE_PREFIX+"!Dark_Red!The builder dimension is disallowed for regular users. You must be a server operator.";
}
}