From 5e3a9793e6824686831240f7dc7d567bb41a17f6 Mon Sep 17 00:00:00 2001 From: Ryan Fox Date: Tue, 1 Dec 2020 03:27:23 +0000 Subject: [PATCH] Add disableFlyCommand config option --- README.txt | 1 + src/main/java/party/_2a03/mc/command/FlyCommand.java | 5 +++++ src/main/java/party/_2a03/mc/util/Config.java | 1 + 3 files changed, 7 insertions(+) diff --git a/README.txt b/README.txt index 4fcbd48..af307d5 100644 --- a/README.txt +++ b/README.txt @@ -33,6 +33,7 @@ Config The config is stored in /config/minecraft-tweaks-2a03/2a03.json +disableFlyCommand: Disables the /fly command disableTntExplosions: Disables TNT explosions disableRespawnAnchorExplosions: Disables respawn anchor explosions iphubApiKey: API key for iphub.info, currently unused diff --git a/src/main/java/party/_2a03/mc/command/FlyCommand.java b/src/main/java/party/_2a03/mc/command/FlyCommand.java index 7f8ed13..d0b4e37 100644 --- a/src/main/java/party/_2a03/mc/command/FlyCommand.java +++ b/src/main/java/party/_2a03/mc/command/FlyCommand.java @@ -5,11 +5,16 @@ import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.LiteralText; +import party._2a03.mc.util.Config; public class FlyCommand { public static void register(CommandDispatcher dispatcher) { dispatcher.register(CommandManager.literal("fly").executes(ctx -> { ServerCommandSource source = ctx.getSource(); + if (Config.getBool("disableFlyCommand")) { + source.sendFeedback(new LiteralText("The /fly command is disabled"), true); + return 0; + } ServerPlayerEntity sender = source.getPlayer(); boolean flight = sender.abilities.allowFlying; sender.abilities.allowFlying = !flight; diff --git a/src/main/java/party/_2a03/mc/util/Config.java b/src/main/java/party/_2a03/mc/util/Config.java index c4e41ea..3179727 100644 --- a/src/main/java/party/_2a03/mc/util/Config.java +++ b/src/main/java/party/_2a03/mc/util/Config.java @@ -36,6 +36,7 @@ public class Config { } setDefault("persistentFlight", true); + setDefault("disableFlyCommand", true); setDefault("disableTntExplosions", false); setDefault("disableRespawnAnchorExplosions", false); setDefault("iphubApiKey", "");