Skip to content

Commit

Permalink
add config to prevent teleporting while falling
Browse files Browse the repository at this point in the history
  • Loading branch information
MelanX committed Apr 12, 2024
1 parent 2a29374 commit 26a1aa9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
Expand Up @@ -52,6 +52,11 @@ private static int home(CommandSourceStack source) throws CommandSyntaxException
return 0;
}

if (!player.hasPermissions(2) && PermissionsConfig.Teleports.preventWhileFalling && player.fallDistance > 1) {
source.sendFailure(Component.translatable("skyblockbuilder.command.error.prevent_while_falling"));
return 0;
}

switch (SkyblockHooks.onHome(player, team)) {
case DENY:
source.sendSuccess(() -> Component.translatable("skyblockbuilder.command.denied.teleport_home").withStyle(ChatFormatting.RED), false);
Expand Down
Expand Up @@ -45,6 +45,11 @@ private static int spawn(CommandSourceStack source) throws CommandSyntaxExceptio
return 0;
}

if (!player.hasPermissions(2) && PermissionsConfig.Teleports.preventWhileFalling && player.fallDistance > 1) {
source.sendFailure(Component.translatable("skyblockbuilder.command.error.prevent_while_falling"));
return 0;
}

data.getOrCreateMetaInfo(player).setLastSpawnTeleport(level.getGameTime());
source.sendSuccess(() -> Component.translatable("skyblockbuilder.command.success.teleport_to_spawn"), false);
WorldUtil.teleportToIsland(player, team);
Expand Down
Expand Up @@ -23,6 +23,9 @@ public static class Teleports {
@Config("Should fall damage be removed when teleporting? [default: false]")
public static boolean noFallDamage = false;

@Config("Should teleporting be prevented while falling? [default: false]")
public static boolean preventWhileFalling = false;

@Config("Should players be able to teleport to spawn? [default: true]")
public static boolean spawn = true;

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/skyblockbuilder/lang/de_de.json
Expand Up @@ -37,6 +37,7 @@
"skyblockbuilder.command.error.user_no_player": "Du bist kein Spieler. Lügner!",
"skyblockbuilder.command.error.teleport_across_dimensions": "Du darfst dich nicht zwischen Dimensionen teleportieren.",
"skyblockbuilder.command.error.teleportation_not_allowed_dimension": "Du darfst dich nicht in dieser Dimension teleportieren.",
"skyblockbuilder.command.error.prevent_while_falling": "Du darfst dich nicht teleportieren während du fällst.",

"skyblockbuilder.command.denied.accept_invitations": "Du kannst diese Einladung nicht annehmen!",
"skyblockbuilder.command.denied.decline_invitations": "Du kannst diese Einladung nicht ablehnen!",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/skyblockbuilder/lang/en_us.json
Expand Up @@ -37,6 +37,7 @@
"skyblockbuilder.command.error.user_no_player": "You are not a player, but a mere liar!",
"skyblockbuilder.command.error.teleport_across_dimensions": "You are not allowed to teleport across dimensions.",
"skyblockbuilder.command.error.teleportation_not_allowed_dimension": "You are not allowed to teleport in this dimension.",
"skyblockbuilder.command.error.prevent_while_falling": "You are not allowed to teleport while falling.",

"skyblockbuilder.command.denied.accept_invitations": "You cannot accept this invitation!",
"skyblockbuilder.command.denied.decline_invitations": "You cannot decline this invitation!",
Expand Down

0 comments on commit 26a1aa9

Please sign in to comment.