Misc Finished, fixed togglecommand, commandmanager, updated value

This commit is contained in:
noil755 2019-11-29 23:06:11 -05:00
parent 8be3cd4dad
commit 7f560b58c2
12 changed files with 188 additions and 202 deletions

View File

@ -58,6 +58,16 @@ public class Value<T> {
}
}
public int getEnum(String input) {
for (int i = 0; i < this.value.getClass().getEnumConstants().length; i++) {
final Enum e = (Enum) this.value.getClass().getEnumConstants()[i];
if (input.equalsIgnoreCase(e.name())) {
return i;
}
}
return -1;
}
public void setEnumValue(String value) {
for (Enum e : ((Enum) this.value).getClass().getEnumConstants()) {
if (e.name().equalsIgnoreCase(value)) {

View File

@ -3,7 +3,6 @@ package me.rigamortis.seppuku.impl.command;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.command.Command;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.old.OptionalValue;
/**
* Author Seth
@ -12,7 +11,7 @@ import me.rigamortis.seppuku.api.value.old.OptionalValue;
public final class ToggleCommand extends Command {
public ToggleCommand() {
super("Toggle", new String[] {"T", "Tog"}, "Allows you to toggle modules or between two mode options", "Toggle <Module>\nToggle <Module> <Mode> <Option> <Option>");
super("Toggle", new String[]{"T", "Tog"}, "Allows you to toggle modules or between two mode options", "Toggle <Module>\nToggle <Module> <Mode> <Option> <Option>");
}
@Override
@ -26,59 +25,19 @@ public final class ToggleCommand extends Command {
final Module mod = Seppuku.INSTANCE.getModuleManager().find(split[1]);
if(mod != null) {
if(mod.getType() == Module.ModuleType.HIDDEN) {
if (mod != null) {
if (mod.getType() == Module.ModuleType.HIDDEN) {
Seppuku.INSTANCE.errorChat("Cannot toggle " + "\247f\"" + mod.getDisplayName() + "\"");
}else{
if(split.length > 2) {
if (!this.clamp(input, 5, 5)) {
this.printUsage();
return;
}
final OptionalValue val = (OptionalValue)mod.find(split[2]);
if(val != null) {
//TODO support numbers too
final int firstOption = val.getOption(split[3]);
if(firstOption != -1) {
final int secondOption = val.getOption(split[4]);
if(secondOption != -1) {
if(firstOption != secondOption) {
if(val.getInt() == firstOption) {
val.setInt(secondOption);
Seppuku.INSTANCE.logChat(mod.getDisplayName() + " \247c" + val.getDisplayName() + "\247f set to " + val.getOptions()[secondOption]);
Seppuku.INSTANCE.getConfigManager().saveAll();
}else{
val.setInt(firstOption);
Seppuku.INSTANCE.logChat(mod.getDisplayName() + " \247c" + val.getDisplayName() + "\247f set to " + val.getOptions()[firstOption]);
Seppuku.INSTANCE.getConfigManager().saveAll();
}
}else{
Seppuku.INSTANCE.errorChat("Both options are the same");
}
}else{
Seppuku.INSTANCE.errorChat("Invalid input " + "\"" + split[4] + "\" expected a name");
}
}else{
Seppuku.INSTANCE.errorChat("Invalid input " + "\"" + split[3] + "\" expected a name");
}
}else{
Seppuku.INSTANCE.errorChat("Unknown Mode \"" + split[2] + "\"");
//TODO similar values?
}
}else{
mod.toggle();
Seppuku.INSTANCE.logChat("Toggled " + (mod.isEnabled() ? "\247a" : "\247c") + mod.getDisplayName());
}
} else {
mod.toggle();
Seppuku.INSTANCE.logChat("Toggled " + (mod.isEnabled() ? "\247a" : "\247c") + mod.getDisplayName());
}
Seppuku.INSTANCE.getConfigManager().saveAll();
}else{
} else {
Seppuku.INSTANCE.errorChat("Unknown module " + "\247f\"" + split[1] + "\"");
final Module similar = Seppuku.INSTANCE.getModuleManager().findSimilar(split[1]);
if(similar != null) {
if (similar != null) {
Seppuku.INSTANCE.logChat("Did you mean " + "\247c" + similar.getDisplayName() + "\247f?");
}
}

View File

@ -6,7 +6,7 @@ import me.rigamortis.seppuku.api.event.command.EventCommandLoad;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.util.ReflectionUtil;
import me.rigamortis.seppuku.api.util.StringUtil;
import me.rigamortis.seppuku.api.value.old.*;
import me.rigamortis.seppuku.api.value.Value;
import me.rigamortis.seppuku.impl.command.*;
import java.io.File;
@ -126,103 +126,100 @@ public final class CommandManager {
final Value v = module.find(split[1]);
if (v != null) {
if (v instanceof BooleanValue) {
final BooleanValue val = (BooleanValue) v;
if (v.getValue() instanceof Boolean) {
if (split.length == 3) {
if (split[2].equalsIgnoreCase("true") || split[2].equalsIgnoreCase("false") || split[2].equalsIgnoreCase("1") || split[2].equalsIgnoreCase("0")) {
if (split[2].equalsIgnoreCase("1")) {
val.setValue(true);
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + val.getDisplayName() + "\247f set to true");
v.setValue(true);
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to true");
Seppuku.INSTANCE.getConfigManager().saveAll();
} else if (split[2].equalsIgnoreCase("0")) {
val.setValue(false);
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + val.getDisplayName() + "\247f set to false");
v.setValue(false);
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to false");
Seppuku.INSTANCE.getConfigManager().saveAll();
} else {
val.setValue(Boolean.parseBoolean(split[2]));
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + val.getDisplayName() + "\247f set to " + Boolean.parseBoolean(split[2]));
v.setValue(Boolean.parseBoolean(split[2]));
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + Boolean.parseBoolean(split[2]));
Seppuku.INSTANCE.getConfigManager().saveAll();
}
} else {
Seppuku.INSTANCE.errorChat("Invalid input " + "\"" + split[2] + "\" expected true/false");
}
}else{
val.setBoolean(!val.getBoolean());
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + val.getDisplayName() + "\247f set to " + val.getBoolean());
} else {
v.setValue(!((Boolean) v.getValue()));
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + v.getValue());
Seppuku.INSTANCE.getConfigManager().saveAll();
}
}
if(v instanceof StringValue) {
if (v.getValue() instanceof String) {
if (!this.clamp(input, 3, 3)) {
this.printUsage();
return;
}
final StringValue val = (StringValue) v;
val.setValue(split[2]);
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + val.getDisplayName() + "\247f set to " + split[2]);
v.setValue(split[2]);
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + split[2]);
Seppuku.INSTANCE.getConfigManager().saveAll();
}
if (v instanceof NumberValue && !(v instanceof OptionalValue)) {
if (v.getValue() instanceof Number && !(v.getValue() instanceof Enum)) {
if (!this.clamp(input, 3, 3)) {
this.printUsage();
return;
}
final NumberValue val = (NumberValue) v;
if (val.getType() == Float.class) {
if (v.getValue().getClass() == Float.class) {
if (StringUtil.isFloat(split[2])) {
val.setValue(Float.parseFloat(split[2]));
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + val.getDisplayName() + "\247f set to " + Float.parseFloat(split[2]));
v.setValue(Float.parseFloat(split[2]));
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + Float.parseFloat(split[2]));
Seppuku.INSTANCE.getConfigManager().saveAll();
} else {
Seppuku.INSTANCE.errorChat("Invalid input " + "\"" + split[2] + "\" expected a number");
}
}
if (val.getType() == Double.class) {
if (v.getValue().getClass() == Double.class) {
if (StringUtil.isDouble(split[2])) {
val.setValue(Double.parseDouble(split[2]));
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + val.getDisplayName() + "\247f set to " + Double.parseDouble(split[2]));
v.setValue(Double.parseDouble(split[2]));
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + Double.parseDouble(split[2]));
Seppuku.INSTANCE.getConfigManager().saveAll();
} else {
Seppuku.INSTANCE.errorChat("Invalid input " + "\"" + split[2] + "\" expected a number");
}
}
if (val.getType() == Integer.class) {
if (v.getValue().getClass() == Integer.class) {
if (StringUtil.isInt(split[2])) {
val.setValue(Integer.parseInt(split[2]));
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + val.getDisplayName() + "\247f set to " + Integer.parseInt(split[2]));
v.setValue(Integer.parseInt(split[2]));
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + Integer.parseInt(split[2]));
Seppuku.INSTANCE.getConfigManager().saveAll();
} else {
Seppuku.INSTANCE.errorChat("Invalid input " + "\"" + split[2] + "\" expected a number");
}
}
}
if (v instanceof OptionalValue) {
if (v.getValue() instanceof Enum) {
if (!this.clamp(input, 3, 3)) {
this.printUsage();
return;
}
final OptionalValue val = (OptionalValue) v;
final int op = val.getOption(split[2]);
final int op = v.getEnum(split[2]);
if (op != -1) {
val.setValue(op);
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + val.getDisplayName() + "\247f set to " + val.getOptions()[op]);
v.setValue(op);
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + ((Enum) v.getValue()).name());
Seppuku.INSTANCE.getConfigManager().saveAll();
} else if (StringUtil.isInt(split[2])) {
final int mode = Integer.parseInt(split[2]);
if (mode > val.getOptions().length - 1) {
if (mode > v.getValue().getClass().getEnumConstants().length - 1) {
Seppuku.INSTANCE.errorChat("Invalid mode " + "\"" + split[2] + "\"");
StringBuilder sb = new StringBuilder();
final int size = val.getOptions().length;
for (int i = 0; i < val.getOptions().length; i++) {
String option = val.getOptions()[i];
sb.append(option + " (" + i + ")" + ((i == size - 1) ? "" : ", "));
final int size = v.getValue().getClass().getEnumConstants().length;
for (int i = 0; i < size; i++) {
final Enum option = (Enum) v.getValue().getClass().getEnumConstants()[i];
sb.append(option.name() + " (" + i + ")" + ((i == size - 1) ? "" : ", "));
}
Seppuku.INSTANCE.logChat("Valid Options:");
@ -232,17 +229,17 @@ public final class CommandManager {
Seppuku.INSTANCE.errorChat("Invalid mode " + "\"" + split[2] + "\"");
StringBuilder sb = new StringBuilder();
final int size = val.getOptions().length;
for (int i = 0; i < val.getOptions().length; i++) {
String option = val.getOptions()[i];
sb.append(option + " (" + i + ")" + ((i == size - 1) ? "" : ", "));
final int size = v.getValue().getClass().getEnumConstants().length;
for (int i = 0; i < size; i++) {
final Enum option = (Enum) v.getValue().getClass().getEnumConstants()[i];
sb.append(option.name() + " (" + i + ")" + ((i == size - 1) ? "" : ", "));
}
Seppuku.INSTANCE.logChat("Valid Options: " + sb.toString());
return;
} else {
val.setValue(mode);
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + val.getDisplayName() + "\247f set to " + val.getOptions()[mode]);
v.setValue(mode);
Seppuku.INSTANCE.logChat(module.getDisplayName() + " \247c" + v.getName() + "\247f set to " + ((Enum) v.getValue()).name());
Seppuku.INSTANCE.getConfigManager().saveAll();
}
} else {
@ -299,7 +296,7 @@ public final class CommandManager {
}
public void unload() {
for(Command cmd : this.commandList) {
for (Command cmd : this.commandList) {
Seppuku.INSTANCE.getEventManager().removeEventListener(cmd);
}
this.commandList.clear();

View File

@ -3,7 +3,7 @@ package me.rigamortis.seppuku.impl.module.misc;
import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.network.EventReceivePacket;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.old.OptionalValue;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.network.play.server.SPacketChat;
import net.minecraft.util.text.TextComponentString;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
@ -17,7 +17,12 @@ import java.util.Date;
*/
public final class ChatTimeStampsModule extends Module {
public final OptionalValue mode = new OptionalValue("Mode", new String[]{"Mode", "M"}, 0, new String[]{"12", "24"});
public final Value<Mode> mode = new Value<Mode>("Mode", new String[]{"Mode", "M"}, "Time format, 12 hour or 24 hour.", Mode.TWELVE);
private enum Mode {
TWELVE, TWENTY_FOUR
}
public ChatTimeStampsModule() {
super("ChatTimeStamps", new String[]{"ChatStamp", "ChatStamps"}, "Appends a time stamp on chat messages", "NONE", -1, ModuleType.MISC);
@ -25,7 +30,7 @@ public final class ChatTimeStampsModule extends Module {
@Override
public String getMetaData() {
return this.mode.getSelectedOption();
return this.mode.getValue().name();
}
@Listener
@ -39,11 +44,11 @@ public final class ChatTimeStampsModule extends Module {
String date = "";
switch (this.mode.getInt()) {
case 0:
switch (this.mode.getValue()) {
case TWELVE:
date = new SimpleDateFormat("h:mm a").format(new Date());
break;
case 1:
case TWENTY_FOUR:
date = new SimpleDateFormat("k:mm").format(new Date());
break;
}

View File

@ -4,7 +4,7 @@ import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.network.EventReceivePacket;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.old.OptionalValue;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.SPacketChunkData;
@ -16,16 +16,20 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
*/
public final class ChestAlertModule extends Module {
public final OptionalValue mode = new OptionalValue("Mode", new String[]{"Mode", "M"}, 0, new String[]{"Chat", "Notification", "Both"});
public final Value<Mode> mode = new Value<Mode>("Mode", new String[]{"Mode", "M"}, "Change between alert modes.", Mode.CHAT);
private enum Mode {
CHAT, NOTIFICATION, BOTH
}
public ChestAlertModule() {
super("ChestAlert", new String[] {"ChestAlerts"}, "Alerts you how many chests are in a chunk when it's loaded", "NONE", -1, ModuleType.MISC);
super("ChestAlert", new String[]{"ChestAlerts"}, "Alerts you how many chests are in a chunk when it's loaded", "NONE", -1, ModuleType.MISC);
}
@Listener
public void recievePacket(EventReceivePacket event) {
if(event.getStage() == EventStageable.EventStage.POST) {
if(event.getPacket() instanceof SPacketChunkData) {
if (event.getStage() == EventStageable.EventStage.POST) {
if (event.getPacket() instanceof SPacketChunkData) {
final SPacketChunkData packet = (SPacketChunkData) event.getPacket();
final Minecraft mc = Minecraft.getMinecraft();
@ -42,10 +46,10 @@ public final class ChestAlertModule extends Module {
if(count > 0) {
final String message = count + " Chests located at X: " + packet.getChunkX() * 16 + " Z: " + packet.getChunkZ() * 16;
if (this.mode.getInt() == 0 || this.mode.getInt() == 2) {
if (this.mode.getValue() == Mode.CHAT || this.mode.getValue() == Mode.BOTH) {
Seppuku.INSTANCE.logChat(message);
}
if (this.mode.getInt() == 1 || this.mode.getInt() == 2) {
if (this.mode.getValue() == Mode.NOTIFICATION || this.mode.getValue() == Mode.BOTH) {
Seppuku.INSTANCE.getNotificationManager().addNotification("", message);
}
}

View File

@ -4,8 +4,7 @@ import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.network.EventReceivePacket;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.old.BooleanValue;
import me.rigamortis.seppuku.api.value.old.OptionalValue;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.client.Minecraft;
import net.minecraft.init.SoundEvents;
import net.minecraft.network.play.server.SPacketEffect;
@ -22,13 +21,17 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
*/
public final class CoordLoggerModule extends Module {
public final OptionalValue mode = new OptionalValue("Mode", new String[]{"Mode", "M"}, 0, new String[]{"Vanilla", "Spigot"});
public final Value<Mode> mode = new Value<Mode>("Mode", new String[]{"Mode", "M"}, "Change between various coord-logger modes.", Mode.VANILLA);
public final BooleanValue thunder = new BooleanValue("Thunder", new String[]{"thund"}, true);
public final BooleanValue endPortal = new BooleanValue("EndPortal", new String[]{"portal"}, true);
public final BooleanValue wither = new BooleanValue("Wither", new String[]{"with"}, true);
public final BooleanValue endDragon = new BooleanValue("EndDragon", new String[]{"dragon"}, true);
public final BooleanValue slimes = new BooleanValue("Slimes", new String[]{"slime"}, true);
private enum Mode {
VANILLA, SPIGOT
}
public final Value<Boolean> thunder = new Value<Boolean>("Thunder", new String[]{"thund"}, "Logs positions of thunder/lightning sounds.", true);
public final Value<Boolean> endPortal = new Value<Boolean>("EndPortal", new String[]{"portal"}, "Logs position of end portal creation sound.", true);
public final Value<Boolean> wither = new Value<Boolean>("Wither", new String[]{"with"}, "Logs positions of wither sounds.", true);
public final Value<Boolean> endDragon = new Value<Boolean>("EndDragon", new String[]{"dragon"}, "Logs positions of end dragon sounds.", true);
public final Value<Boolean> slimes = new Value<Boolean>("Slimes", new String[]{"slime"}, "Logs positions of slime spawns.", false);
public CoordLoggerModule() {
super("CoordLogger", new String[]{"CoordLog", "CLogger", "CLog"}, "Logs useful coordinates", "NONE", -1, ModuleType.MISC);
@ -36,7 +39,7 @@ public final class CoordLoggerModule extends Module {
@Override
public String getMetaData() {
return this.mode.getSelectedOption();
return this.mode.getValue().name();
}
@Listener
@ -45,7 +48,7 @@ public final class CoordLoggerModule extends Module {
if (event.getPacket() instanceof SPacketSpawnMob) {
final SPacketSpawnMob packet = (SPacketSpawnMob) event.getPacket();
if (this.slimes.getBoolean()) {
if (this.slimes.getValue()) {
final Minecraft mc = Minecraft.getMinecraft();
if (packet.getEntityType() == 55 && packet.getY() <= 40 && !mc.world.getBiome(mc.player.getPosition()).getBiomeName().toLowerCase().contains("swamp")) {
@ -57,7 +60,7 @@ public final class CoordLoggerModule extends Module {
if (event.getPacket() instanceof SPacketSoundEffect) {
final SPacketSoundEffect packet = (SPacketSoundEffect) event.getPacket();
if (this.thunder.getBoolean()) {
if (this.thunder.getValue()) {
if (packet.getCategory() == SoundCategory.WEATHER && packet.getSound() == SoundEvents.ENTITY_LIGHTNING_THUNDER) {
float yaw = 0;
final double difX = packet.getX() - Minecraft.getMinecraft().player.posX;
@ -71,18 +74,18 @@ public final class CoordLoggerModule extends Module {
}
if (event.getPacket() instanceof SPacketEffect) {
final SPacketEffect packet = (SPacketEffect) event.getPacket();
if (this.endPortal.getBoolean()) {
if (this.endPortal.getValue()) {
if (packet.getSoundType() == 1038) {
Seppuku.INSTANCE.logChat("End Portal activated at X:" + packet.getSoundPos().getX() + " Y:" + packet.getSoundPos().getY() + " Z:" + packet.getSoundPos().getZ());
}
}
if (this.wither.getBoolean()) {
if (this.wither.getValue()) {
if (packet.getSoundType() == 1023) {
switch (this.mode.getInt()) {
case 0:
switch (this.mode.getValue()) {
case VANILLA:
Seppuku.INSTANCE.logChat("Wither spawned at X:" + packet.getSoundPos().getX() + " Y:" + packet.getSoundPos().getY() + " Z:" + packet.getSoundPos().getZ());
break;
case 1:
case SPIGOT:
float yaw = 0;
final double difX = packet.getSoundPos().getX() - Minecraft.getMinecraft().player.posX;
final double difZ = packet.getSoundPos().getZ() - Minecraft.getMinecraft().player.posZ;
@ -94,7 +97,7 @@ public final class CoordLoggerModule extends Module {
}
}
}
if (this.endDragon.getBoolean()) {
if (this.endDragon.getValue()) {
if (packet.getSoundType() == 1028) {
float yaw = 0;
final double difX = packet.getSoundPos().getX() - Minecraft.getMinecraft().player.posX;

View File

@ -28,7 +28,7 @@ public class DiscordBypassModule extends Module {
final CPacketChatMessage packet = (CPacketChatMessage) event.getPacket();
final CommandsModule commands = (CommandsModule) Seppuku.INSTANCE.getModuleManager().find(CommandsModule.class);
if (commands != null) {
if (packet.getMessage().startsWith(commands.prefix.getString()) || packet.getMessage().startsWith("/"))
if (packet.getMessage().startsWith(commands.prefix.getValue()) || packet.getMessage().startsWith("/"))
return;
//Technically the "spawn area" is usually around 23x23 chunks, but jj might've changed it... or perhaps he might not be using the spawn chunks at all.
//Just in case he's going to the "anarchy definition" of spawn, I set it to 1k. Better safe than sorry, nobody except jj will notice the extra #.

View File

@ -4,7 +4,7 @@ import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.event.player.EventPlayerJoin;
import me.rigamortis.seppuku.api.event.player.EventPlayerLeave;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.old.OptionalValue;
import me.rigamortis.seppuku.api.value.Value;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
/**
@ -13,7 +13,11 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
*/
public final class GreeterModule extends Module {
public final OptionalValue mode = new OptionalValue("Mode", new String[]{"Mode", "M"}, 0, new String[]{"Client", "Server"});
public final Value<Mode> mode = new Value<Mode>("Mode", new String[]{"Mode", "M"}, "Change between greeter modes. Client mode will only appear for you, Server mode will broadcast the greeting message for everyone.", Mode.CLIENT);
private enum Mode {
CLIENT, SERVER
}
public GreeterModule() {
super("Greeter", new String[]{"Greet"}, "Automatically announces when a player joins and leaves", "NONE", -1, ModuleType.MISC);
@ -21,16 +25,16 @@ public final class GreeterModule extends Module {
@Override
public String getMetaData() {
return this.mode.getSelectedOption();
return this.mode.getValue().name();
}
@Listener
public void onPlayerJoin(EventPlayerJoin event) {
switch (mode.getInt()) {
case 0:
switch (this.mode.getValue()) {
case CLIENT:
Seppuku.INSTANCE.logChat(event.getName() + " has joined the game");
break;
case 1:
case SERVER:
Seppuku.INSTANCE.getChatManager().add(event.getName() + " has joined the game");
break;
}
@ -38,11 +42,11 @@ public final class GreeterModule extends Module {
@Listener
public void onPlayerLeave(EventPlayerLeave event) {
switch (mode.getInt()) {
case 0:
switch (this.mode.getValue()) {
case CLIENT:
Seppuku.INSTANCE.logChat(event.getName() + " has left the game");
break;
case 1:
case SERVER:
Seppuku.INSTANCE.getChatManager().add(event.getName() + " has left the game");
break;
}

View File

@ -3,8 +3,7 @@ package me.rigamortis.seppuku.impl.module.misc;
import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.player.EventPlayerUpdate;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.old.NumberValue;
import me.rigamortis.seppuku.api.value.old.OptionalValue;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
@ -26,9 +25,13 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
*/
public final class LaggerModule extends Module {
public final OptionalValue mode = new OptionalValue("Mode", new String[]{"Mode", "M"}, 0, new String[]{"Boxer", "Swap", "Movement", "Sign", "Nbt"});
public final Value<Mode> mode = new Value<Mode>("Mode", new String[]{"Mode", "M"}, "Change between various lagger modes, each utilizing a different exploit to cause lag.", Mode.BOXER);
public final NumberValue packets = new NumberValue("Packets", new String[]{"pckts", "packet"}, 500, Integer.class, 0, 5000, 1);
private enum Mode {
BOXER, SWAP, MOVEMENT, SIGN, NBT
}
public final Value<Integer> packets = new Value<Integer>("Packets", new String[]{"pckts", "packet"}, "Amount of packets to send each tick while running the chosen lag mode.", 500, 0, 5000, 1);
final Minecraft mc = Minecraft.getMinecraft();
@ -38,25 +41,25 @@ public final class LaggerModule extends Module {
@Override
public String getMetaData() {
return this.mode.getSelectedOption();
return this.mode.getValue().name();
}
@Listener
public void onUpdate(EventPlayerUpdate event) {
if (event.getStage() == EventStageable.EventStage.PRE) {
switch (this.mode.getInt()) {
case 0:
for (int i = 0; i <= this.packets.getInt(); i++) {
switch (this.mode.getValue()) {
case BOXER:
for (int i = 0; i <= this.packets.getValue(); i++) {
mc.player.connection.sendPacket(new CPacketAnimation(EnumHand.MAIN_HAND));
}
break;
case 1:
for (int i = 0; i <= this.packets.getInt(); i++) {
case SWAP:
for (int i = 0; i <= this.packets.getValue(); i++) {
mc.player.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.SWAP_HELD_ITEMS, BlockPos.ORIGIN, mc.player.getHorizontalFacing()));
}
break;
case 2:
for (int i = 0; i <= this.packets.getInt(); i++) {
case MOVEMENT:
for (int i = 0; i <= this.packets.getValue(); i++) {
final Entity riding = mc.player.getRidingEntity();
if (riding != null) {
riding.posX = mc.player.posX;
@ -66,18 +69,18 @@ public final class LaggerModule extends Module {
}
}
break;
case 3:
case SIGN:
for (TileEntity te : mc.world.loadedTileEntityList) {
if (te instanceof TileEntitySign) {
final TileEntitySign tileEntitySign = (TileEntitySign) te;
for (int i = 0; i <= this.packets.getInt(); i++) {
for (int i = 0; i <= this.packets.getValue(); i++) {
mc.player.connection.sendPacket(new CPacketUpdateSign(tileEntitySign.getPos(), new TextComponentString[]{new TextComponentString("give"), new TextComponentString("riga"), new TextComponentString("the"), new TextComponentString("green book")}));
}
}
}
break;
case 4:
case NBT:
final ItemStack itemStack = new ItemStack(Items.WRITABLE_BOOK);
final NBTTagList pages = new NBTTagList();
@ -91,7 +94,7 @@ public final class LaggerModule extends Module {
tag.setTag("pages", pages);
itemStack.setTagCompound(tag);
for (int i = 0; i <= this.packets.getInt(); i++) {
for (int i = 0; i <= this.packets.getValue(); i++) {
mc.player.connection.sendPacket(new CPacketCreativeInventoryAction(0, itemStack));
//mc.player.connection.sendPacket(new CPacketClickWindow(0, 0, 0, ClickType.PICKUP, itemStack, (short)0));
}

View File

@ -6,8 +6,7 @@ import me.rigamortis.seppuku.api.event.world.EventFoliageColor;
import me.rigamortis.seppuku.api.event.world.EventGrassColor;
import me.rigamortis.seppuku.api.event.world.EventWaterColor;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.old.NumberValue;
import me.rigamortis.seppuku.api.value.old.OptionalValue;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.client.Minecraft;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
@ -17,20 +16,24 @@ import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
*/
public final class NoBiomeColorModule extends Module {
public final OptionalValue mode = new OptionalValue("Mode", new String[]{"Mode", "M"}, 0, new String[]{"Default", "Custom"});
public final Value<Mode> mode = new Value<Mode>("Mode", new String[]{"Mode", "M"}, "Change between NoBiomeColor modes, Default to use vanilla colors, Custom to use specified RGB values.", Mode.DEFAULT);
public final NumberValue red = new NumberValue("Red", new String[]{"R"}, 255.0f, Float.class, 0.0f, 255.0f, 1.0f);
public final NumberValue green = new NumberValue("Green", new String[]{"G"}, 255.0f, Float.class, 0.0f, 255.0f, 1.0f);
public final NumberValue blue = new NumberValue("Blue", new String[]{"B"}, 255.0f, Float.class, 0.0f, 255.0f, 1.0f);
private enum Mode {
DEFAULT, CUSTOM
}
public final Value<Float> red = new Value<Float>("Red", new String[]{"R"}, "Red value for custom biome color.", 255.0f, 0.0f, 255.0f, 1.0f);
public final Value<Float> green = new Value<Float>("Green", new String[]{"G"}, "Green value for custom biome color.", 255.0f, 0.0f, 255.0f, 1.0f);
public final Value<Float> blue = new Value<Float>("Blue", new String[]{"B"}, "Blue value for custom biome color.", 255.0f, 0.0f, 255.0f, 1.0f);
private float prevRed;
private float prevGreen;
private float prevBlue;
private int prevMode;
private Mode prevMode;
public NoBiomeColorModule() {
super("NoBiomeColor", new String[]{"AntiBiomeColor", "NoBiomeC", "NoBiome"}, "Prevents the game from altering the color of foliage, water and grass in biomes", "NONE", -1, ModuleType.RENDER);
super("NoBiomeColor", new String[]{"AntiBiomeColor", "NoBiomeC", "NoBiome"}, "Prevents the game from altering the color of foliage, water and grass in biomes.", "NONE", -1, ModuleType.RENDER);
}
@Override
@ -47,13 +50,13 @@ public final class NoBiomeColorModule extends Module {
@Override
public String getMetaData() {
return this.mode.getSelectedOption();
return this.mode.getValue().name();
}
private void reload() {
final Minecraft mc = Minecraft.getMinecraft();
if(mc.world != null) {
if (mc.world != null) {
mc.renderGlobal.markBlockRangeForRenderUpdate(
(int) mc.player.posX - 256,
(int) mc.player.posY - 256,
@ -65,26 +68,26 @@ public final class NoBiomeColorModule extends Module {
}
private int getHex() {
return (255 << 24) | ((int)this.red.getFloat() << 16) | ((int)this.green.getFloat() << 8 | (int)this.blue.getFloat());
return (255 << 24) | (this.red.getValue().intValue() << 16) | (this.green.getValue().intValue() << 8 | this.blue.getValue().intValue());
}
@Listener
public void onUpdate(EventPlayerUpdate event) {
if (event.getStage() == EventStageable.EventStage.PRE) {
if (this.prevRed != this.red.getFloat()) {
this.prevRed = this.red.getFloat();
if (this.prevRed != this.red.getValue()) {
this.prevRed = this.red.getValue();
this.reload();
}
if (this.prevGreen != this.green.getFloat()) {
this.prevGreen = this.green.getFloat();
if (this.prevGreen != this.green.getValue()) {
this.prevGreen = this.green.getValue();
this.reload();
}
if (this.prevBlue != this.blue.getFloat()) {
this.prevBlue = this.blue.getFloat();
if (this.prevBlue != this.blue.getValue()) {
this.prevBlue = this.blue.getValue();
this.reload();
}
if(this.prevMode != this.mode.getInt()) {
this.prevMode = this.mode.getInt();
if (this.prevMode != this.mode.getValue()) {
this.prevMode = this.mode.getValue();
this.reload();
}
}
@ -92,11 +95,11 @@ public final class NoBiomeColorModule extends Module {
@Listener
public void getGrassColor(EventGrassColor event) {
switch (this.mode.getInt()) {
case 0:
switch (this.mode.getValue()) {
case DEFAULT:
event.setColor(0x79c05a);
break;
case 1:
case CUSTOM:
event.setColor(this.getHex());
break;
}
@ -105,11 +108,11 @@ public final class NoBiomeColorModule extends Module {
@Listener
public void getFoliageColor(EventFoliageColor event) {
switch (this.mode.getInt()) {
case 0:
switch (this.mode.getValue()) {
case DEFAULT:
event.setColor(0x59ae30);
break;
case 1:
case CUSTOM:
event.setColor(this.getHex());
break;
}
@ -118,11 +121,11 @@ public final class NoBiomeColorModule extends Module {
@Listener
public void getWaterColor(EventWaterColor event) {
switch (this.mode.getInt()) {
case 0:
switch (this.mode.getValue()) {
case DEFAULT:
event.setColor(0x1E97F2);
break;
case 1:
case CUSTOM:
event.setColor(this.getHex());
break;
}

View File

@ -5,7 +5,7 @@ import me.rigamortis.seppuku.api.event.EventStageable;
import me.rigamortis.seppuku.api.event.network.EventReceivePacket;
import me.rigamortis.seppuku.api.event.network.EventSendPacket;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.old.BooleanValue;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.network.Packet;
import net.minecraft.util.StringUtils;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
@ -19,15 +19,13 @@ public final class PacketLoggerModule extends Module {
private Packet[] packets;
public final BooleanValue incoming = new BooleanValue("Incoming", new String[]{"in"}, true);
public final Value<Boolean> incoming = new Value<Boolean>("Incoming", new String[]{"in"}, "Log incoming packets when enabled.", true);
public final Value<Boolean> outgoing = new Value<Boolean>("Outgoing", new String[]{"out"}, "Log outgoing packets when enabled.", true);
public final BooleanValue outgoing = new BooleanValue("Outgoing", new String[]{"out"}, true);
public final Value<Boolean> chat = new Value<Boolean>("Chat", new String[]{"ch"}, "Logs packet traffic to chat.", true);
public final Value<Boolean> console = new Value<Boolean>("Console", new String[]{"con"}, "Logs packet traffic to console.", true);
public final BooleanValue chat = new BooleanValue("Chat", new String[]{"ch"}, true);
public final BooleanValue console = new BooleanValue("Console", new String[]{"con"}, true);
public final BooleanValue data = new BooleanValue("Data", new String[]{"dat"}, true);
public final Value<Boolean> data = new Value<Boolean>("Data", new String[]{"dat"}, "Include data about the packet's class in the log when enabled.", true);
public PacketLoggerModule() {
super("PacketLogger", new String[]{"pktlgr"}, "Log incoming and/or outgoing packets to console.", "NONE", -1, ModuleType.MISC);
@ -41,12 +39,12 @@ public final class PacketLoggerModule extends Module {
@Listener
public void receivePacket(EventReceivePacket event) {
if (this.incoming.getBoolean()) {
if (this.incoming.getValue()) {
if (event.getStage() == EventStageable.EventStage.PRE) {
if (this.console.getBoolean()) {
if (this.console.getValue()) {
System.out.println("\2477IN: \247r" + event.getPacket().getClass().getSimpleName() + " {");
if (this.data.getBoolean()) {
if (this.data.getValue()) {
try {
Class clazz = event.getPacket().getClass();
@ -72,10 +70,10 @@ public final class PacketLoggerModule extends Module {
System.out.println("}");
}
if (this.chat.getBoolean()) {
if (this.chat.getValue()) {
Seppuku.INSTANCE.logChat("\2477IN: \247r" + event.getPacket().getClass().getSimpleName() + " {");
if (this.data.getBoolean()) {
if (this.data.getValue()) {
try {
Class clazz = event.getPacket().getClass();
@ -106,12 +104,12 @@ public final class PacketLoggerModule extends Module {
@Listener
public void sendPacket(EventSendPacket event) {
if (this.outgoing.getBoolean()) {
if (this.outgoing.getValue()) {
if (event.getStage() == EventStageable.EventStage.PRE) {
if (this.console.getBoolean()) {
if (this.console.getValue()) {
System.out.println("\2477OUT: \247r" + event.getPacket().getClass().getSimpleName() + " {");
if (this.data.getBoolean()) {
if (this.data.getValue()) {
try {
Class clazz = event.getPacket().getClass();
@ -137,10 +135,10 @@ public final class PacketLoggerModule extends Module {
System.out.println("}");
}
if (this.chat.getBoolean()) {
if (this.chat.getValue()) {
Seppuku.INSTANCE.logChat("\2477OUT: \247r" + event.getPacket().getClass().getSimpleName() + " {");
if (this.data.getBoolean()) {
if (this.data.getValue()) {
try {
Class clazz = event.getPacket().getClass();

View File

@ -6,7 +6,7 @@ import me.rigamortis.seppuku.api.event.minecraft.EventRunTick;
import me.rigamortis.seppuku.api.event.network.EventSendPacket;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.util.Timer;
import me.rigamortis.seppuku.api.value.old.NumberValue;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiDisconnected;
import net.minecraft.client.multiplayer.GuiConnecting;
@ -25,7 +25,7 @@ public final class ReconnectModule extends Module {
private boolean reconnect;
private Timer timer = new Timer();
public final NumberValue delay = new NumberValue("Delay", new String[]{"Del"}, 3000.0f, Float.class, 0.0f, 10000.0f, 500.0f);
public final Value<Float> delay = new Value<Float>("Delay", new String[]{"Del"}, "Delay in MS (milliseconds) between reconnect attempts.", 3000.0f, 0.0f, 10000.0f, 500.0f);
public ReconnectModule() {
super("Reconnect", new String[]{"Rejoin", "Recon", "AutoReconnect"}, "Automatically reconnects to the last server after being kicked", "NONE", -1, ModuleType.MISC);
@ -46,9 +46,9 @@ public final class ReconnectModule extends Module {
@Listener
public void runTick(EventRunTick event) {
if(event.getStage() == EventStageable.EventStage.POST) {
if(this.lastIp != null && this.lastPort > 0 && this.reconnect) {
if(this.timer.passed(delay.getFloat())) {
if (event.getStage() == EventStageable.EventStage.POST) {
if (this.lastIp != null && this.lastPort > 0 && this.reconnect) {
if (this.timer.passed(this.delay.getValue())) {
Minecraft.getMinecraft().displayGuiScreen(new GuiConnecting(null, Minecraft.getMinecraft(), this.lastIp, this.lastPort));
this.timer.reset();
this.reconnect = false;