From 7a7820cebd632d1936fcdc3e7526a14b13e7786f Mon Sep 17 00:00:00 2001 From: Bella Date: Sun, 12 Apr 2020 14:53:31 -0400 Subject: [PATCH] close #689 --- .../kami/command/commands/AutoEZCommand.java | 37 ++++++++++++++++ .../kami/module/modules/chat/CustomChat.java | 2 +- .../kami/module/modules/combat/AutoEZ.java | 42 +++++++++++++------ 3 files changed, 67 insertions(+), 14 deletions(-) create mode 100644 src/main/java/me/zeroeightsix/kami/command/commands/AutoEZCommand.java diff --git a/src/main/java/me/zeroeightsix/kami/command/commands/AutoEZCommand.java b/src/main/java/me/zeroeightsix/kami/command/commands/AutoEZCommand.java new file mode 100644 index 000000000..558f54d86 --- /dev/null +++ b/src/main/java/me/zeroeightsix/kami/command/commands/AutoEZCommand.java @@ -0,0 +1,37 @@ +package me.zeroeightsix.kami.command.commands; + +import me.zeroeightsix.kami.command.Command; +import me.zeroeightsix.kami.command.syntax.ChunkBuilder; +import me.zeroeightsix.kami.module.modules.combat.AutoEZ; + +import static me.zeroeightsix.kami.KamiMod.MODULE_MANAGER; + +public class AutoEZCommand extends Command { + public AutoEZCommand() { + super("autoez", new ChunkBuilder().append("message").build()); + setDescription("Allows you to customize AutoEZ's custom setting"); + } + + @Override + public void call(String[] args) { + AutoEZ az = MODULE_MANAGER.getModuleT(AutoEZ.class); + if (az == null) { + Command.sendErrorMessage("&cThe AutoEZ module is not available for some reason. Make sure the name you're calling is correct and that you have the module installed!!"); + return; + } + if (!az.isEnabled()) { + Command.sendWarningMessage("&6Warning: The AutoEZ module is not enabled!"); + Command.sendWarningMessage("The command will still work, but will not visibly do anything."); + } + if (!az.mode.getValue().equals(AutoEZ.Mode.CUSTOM)) { + Command.sendWarningMessage("&6Warning: You don't have custom mode enabled in AutoEZ!"); + Command.sendWarningMessage("The command will still work, but will not visibly do anything."); + } + for (String s : args) { + if (s == null) + continue; + az.customText.setValue(s); + Command.sendChatMessage("Set the Custom Mode to <" + s + ">"); + } + } +} diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/chat/CustomChat.java b/src/main/java/me/zeroeightsix/kami/module/modules/chat/CustomChat.java index 0da0b3d93..cd74950f8 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/chat/CustomChat.java +++ b/src/main/java/me/zeroeightsix/kami/module/modules/chat/CustomChat.java @@ -9,7 +9,7 @@ import me.zeroeightsix.kami.setting.Setting; import me.zeroeightsix.kami.setting.Settings; import net.minecraft.network.play.client.CPacketChatMessage; -import static me.zeroeightsix.kami.KamiMod.*; +import static me.zeroeightsix.kami.KamiMod.separator; /** * Created by 086 on 8/04/2018. diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/combat/AutoEZ.java b/src/main/java/me/zeroeightsix/kami/module/modules/combat/AutoEZ.java index aa997d441..7521f8b41 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/combat/AutoEZ.java +++ b/src/main/java/me/zeroeightsix/kami/module/modules/combat/AutoEZ.java @@ -2,6 +2,7 @@ package me.zeroeightsix.kami.module.modules.combat; import me.zero.alpine.listener.EventHandler; import me.zero.alpine.listener.Listener; +import me.zeroeightsix.kami.command.Command; import me.zeroeightsix.kami.event.events.GuiScreenEvent; import me.zeroeightsix.kami.module.Module; import me.zeroeightsix.kami.setting.Setting; @@ -14,39 +15,46 @@ import net.minecraftforge.event.entity.player.AttackEntityEvent; * @author polymer * @author cookiedragon234 * Updated by polymer 10 March 2020 - * Updated by S-B99 on 10/04/20 + * Updated by S-B99 on 12/04/20 */ @Module.Info(name = "AutoEZ", category = Module.Category.COMBAT, description = "Sends an insult in chat after killing someone") public class AutoEZ extends Module { - private Setting mode = register(Settings.e("Mode", Mode.ONTOP)); + public Setting mode = register(Settings.e("Mode", Mode.ONTOP)); + public Setting customText = register(Settings.stringBuilder("Custom Text").withValue("unchanged").withConsumer((old, value) -> {}).build()); + EntityPlayer focus; int hasBeenCombat; public enum Mode { - GG("gg, "), - ONTOP("KAMI BLUE on top! ez "), - EZD("You just got ez'd "), - EZ_HYPIXEL("E Z Win "), - NAENAE("You just got naenae'd by kami blue plus, "); + GG("gg, $NAME"), + ONTOP("KAMI BLUE on top! ez $NAME"), + EZD("You just got ez'd $NAME"), + EZ_HYPIXEL("E Z Win $NAME"), + NAENAE("You just got naenae'd by kami blue plus, $NAME"), + CUSTOM(); private String text; Mode(String text) { this.text = text; } + Mode() { } // yes } - private String getText(Mode m) { - return m.text; + private String getText(Mode m, String playerName) { + if (m.equals(Mode.CUSTOM)) { + return customText.getValue().replace("$NAME", playerName); + } + return m.text.replace("$NAME", playerName); } - + @EventHandler public Listener livingDeathEventListener = new Listener<>(event -> { if (event.getTarget() instanceof EntityPlayer) { focus = (EntityPlayer) event.getTarget(); if (event.getEntityPlayer().getUniqueID() == mc.player.getUniqueID()) { if (focus.getHealth() <= 0.0 || focus.isDead || !mc.world.playerEntities.contains(focus)) { - mc.player.sendChatMessage(getText(mode.getValue()) + event.getTarget().getName()); + mc.player.sendChatMessage(getText(mode.getValue(), event.getTarget().getName())); return; } hasBeenCombat = 1000; @@ -61,15 +69,23 @@ public class AutoEZ extends Module { hasBeenCombat = 0; } }); - + + private static long startTime = 0; @Override public void onUpdate() { if (mc.player == null) return; if (hasBeenCombat > 0 && (focus.getHealth() <= 0.0f || focus.isDead || !mc.world.playerEntities.contains(focus))) { - mc.player.sendChatMessage(getText(mode.getValue())+focus.getName()); + mc.player.sendChatMessage(getText(mode.getValue(), focus.getName())); hasBeenCombat = 0; } --hasBeenCombat; + if (startTime == 0) startTime = System.currentTimeMillis(); + if (startTime + 5000 <= System.currentTimeMillis()) { // 5 seconds in milliseconds + if (mode.getValue().equals(Mode.CUSTOM) && customText.getValue().equalsIgnoreCase("unchanged") && mc.player != null) { + Command.sendWarningMessage(getChatName() + " Warning: In order to use the custom " + getName() + ", please run the &7" + Command.getCommandPrefix() + "autoez&r command to change it, with '&7$NAME&f' being the username of the killed player"); + } + startTime = System.currentTimeMillis(); + } } }