|
| 1 | +/* |
| 2 | + * Copyright (c) 2014-2025 Wurst-Imperium and contributors. |
| 3 | + * |
| 4 | + * This source code is subject to the terms of the GNU General Public |
| 5 | + * License, version 3. If a copy of the GPL was not distributed with this |
| 6 | + * file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt |
| 7 | + */ |
| 8 | +package net.wurstclient.commands; |
| 9 | + |
| 10 | +import net.wurstclient.WurstClient; |
| 11 | +import net.wurstclient.command.CmdException; |
| 12 | +import net.wurstclient.command.CmdSyntaxError; |
| 13 | +import net.wurstclient.command.Command; |
| 14 | +import net.wurstclient.util.ChatUtils; |
| 15 | +import net.wurstclient.util.MathUtils; |
| 16 | + |
| 17 | +public final class AboveGroundCmd extends Command |
| 18 | +{ |
| 19 | + public AboveGroundCmd() |
| 20 | + { |
| 21 | + super("aboveground", |
| 22 | + "Global above-ground ESP filter for supported hacks.", |
| 23 | + ".aboveground (on|off|toggle)", ".aboveground y <value>", |
| 24 | + ".aboveground <value>"); |
| 25 | + } |
| 26 | + |
| 27 | + @Override |
| 28 | + public void call(String[] args) throws CmdException |
| 29 | + { |
| 30 | + if(args.length == 0) |
| 31 | + throw new CmdSyntaxError(); |
| 32 | + String a = args[0].toLowerCase(); |
| 33 | + // Single-word actions |
| 34 | + if(args.length == 1) |
| 35 | + { |
| 36 | + if(a.equals("on")) |
| 37 | + { |
| 38 | + WurstClient.INSTANCE.getHax().setAboveGroundFilterEnabled(true); |
| 39 | + ChatUtils.message( |
| 40 | + "Above-ground filter enabled for supported hacks."); |
| 41 | + return; |
| 42 | + } |
| 43 | + if(a.equals("off")) |
| 44 | + { |
| 45 | + WurstClient.INSTANCE.getHax() |
| 46 | + .setAboveGroundFilterEnabled(false); |
| 47 | + ChatUtils.message( |
| 48 | + "Above-ground filter disabled for supported hacks."); |
| 49 | + return; |
| 50 | + } |
| 51 | + if(a.equals("toggle")) |
| 52 | + { |
| 53 | + // Toggle: invert by enabling when currently all disabled is |
| 54 | + // unknown. |
| 55 | + // We'll simply enable if arg toggled on; user can set |
| 56 | + // explicitly. |
| 57 | + // For simplicity, toggle will enable when called. |
| 58 | + WurstClient.INSTANCE.getHax().setAboveGroundFilterEnabled(true); |
| 59 | + ChatUtils.message("Above-ground filter toggled (enabled)."); |
| 60 | + return; |
| 61 | + } |
| 62 | + // numeric provided -> set Y |
| 63 | + if(MathUtils.isDouble(a)) |
| 64 | + { |
| 65 | + int y = (int)Double.parseDouble(a); |
| 66 | + WurstClient.INSTANCE.getHax().setAboveGroundFilterY(y); |
| 67 | + ChatUtils.message( |
| 68 | + "Above-ground Y set to " + y + " for supported hacks."); |
| 69 | + return; |
| 70 | + } |
| 71 | + throw new CmdSyntaxError(); |
| 72 | + } |
| 73 | + |
| 74 | + // Two-argument forms: "y <value>" or "on/off <value>" to enable and set |
| 75 | + // Y |
| 76 | + if(args.length == 2) |
| 77 | + { |
| 78 | + if(a.equals("y") || a.equals("set")) |
| 79 | + { |
| 80 | + if(!MathUtils.isDouble(args[1])) |
| 81 | + throw new CmdSyntaxError("Y must be a number."); |
| 82 | + int y = (int)Double.parseDouble(args[1]); |
| 83 | + WurstClient.INSTANCE.getHax().setAboveGroundFilterY(y); |
| 84 | + ChatUtils.message( |
| 85 | + "Above-ground Y set to " + y + " for supported hacks."); |
| 86 | + return; |
| 87 | + } |
| 88 | + if(a.equals("on") || a.equals("off")) |
| 89 | + { |
| 90 | + boolean enabled = a.equals("on"); |
| 91 | + WurstClient.INSTANCE.getHax() |
| 92 | + .setAboveGroundFilterEnabled(enabled); |
| 93 | + if(!MathUtils.isDouble(args[1])) |
| 94 | + { |
| 95 | + ChatUtils.message("Above-ground filter " |
| 96 | + + (enabled ? "enabled" : "disabled") + "."); |
| 97 | + return; |
| 98 | + } |
| 99 | + int y = (int)Double.parseDouble(args[1]); |
| 100 | + WurstClient.INSTANCE.getHax().setAboveGroundFilterY(y); |
| 101 | + ChatUtils.message( |
| 102 | + "Above-ground filter " + (enabled ? "enabled" : "disabled") |
| 103 | + + " and Y set to " + y + "."); |
| 104 | + return; |
| 105 | + } |
| 106 | + throw new CmdSyntaxError(); |
| 107 | + } |
| 108 | + throw new CmdSyntaxError(); |
| 109 | + } |
| 110 | +} |
0 commit comments