@@ -2,12 +2,15 @@

import lgbt.audrey.pipe.Pipe;
import lgbt.audrey.pipe.command.Command;
import lgbt.audrey.pipe.command.CommandException;
import lgbt.audrey.pipe.command.CommandExecutor;
import lgbt.audrey.pipe.config.Option;
import lgbt.audrey.pipe.plugin.Plugin;
import lgbt.audrey.pipe.plugin.module.Module;
import lgbt.audrey.pipe.util.ArgumentTokenizer;
import lgbt.audrey.pipe.util.helpers.ChatHelper;

import java.util.List;
import java.util.Optional;

/**
@@ -16,57 +19,94 @@
*/
@SuppressWarnings("ConfusingOctalEscapeSequence")
public class CommandSet implements CommandExecutor {
private final String commandPrefix;

public CommandSet(final String commandPrefix) {
this.commandPrefix = commandPrefix;
}

@Override
public boolean executeCommand(final Command command, final String commandString, final String[] args) {
if(args.length >= 1) {
final String pmp = args[0];
final String[] split = pmp.split("\\.");
public boolean executeCommand(final Command command, final String commandString, final String[] args) throws CommandException {
if(!commandString.isEmpty()) {
final List<String> tokenize = ArgumentTokenizer.tokenize(commandString);
String pluginString = "";
String moduleString = "";
String optionString = "";
String valueString = "";
for(int i = 0; i < tokenize.size(); i++) {
switch(tokenize.get(i)) {
case "-p":
case "--plugin":
++i;
pluginString = tokenize.get(i);
break;
case "-m":
case "--module":
++i;
moduleString = tokenize.get(i);
break;
case "-o":
case "--option":
++i;
optionString = tokenize.get(i);
break;
case "-v":
case "--value":
++i;
valueString = tokenize.get(i);
break;
}
}
final String finalPluginString = pluginString;
final Optional<Plugin> pluginOptional = Pipe.pluginManager().getPlugins().stream()
.filter(p -> p.getName().replaceAll("\\s+", "").equalsIgnoreCase(split[0])).findFirst();
.filter(p -> p.getName().replaceAll("\\s+", "").equalsIgnoreCase(finalPluginString)).findFirst();

if(pluginOptional.isPresent()) {
final Plugin plugin = pluginOptional.get();
if(split.length > 1 && !split[1].isEmpty()) {
if(moduleString.isEmpty()) {
ChatHelper.log("\2477Plugin '\247e" + plugin.getName() +
"\2477' has the following modules available:");
plugin.getProvidedModules().forEach(m -> ChatHelper.log(" \2477* \247e" + m.getName()));
} else {
final String finalModuleString = moduleString;
final Optional<Module> moduleOptional = plugin.getProvidedModules().stream()
.filter(m -> m.getName().replaceAll("\\s+", "").equalsIgnoreCase(split[1])).findFirst();
.filter(m -> m.getName().replaceAll("\\s+", "").equalsIgnoreCase(finalModuleString)).findFirst();
if(moduleOptional.isPresent()) {
final Module module = moduleOptional.get();
if(split.length > 2 && !split[2].isEmpty()) {
final Option option = module.getOption(split[2].replaceAll("\\s+", ""));
if(optionString.isEmpty()) {
ChatHelper.log("\2477Module '\247e" + pluginString + ':' + moduleString +
"\2477' has the following options available:");
module.getOptions().forEach(o -> ChatHelper.log(" \2477* \247e" + o.name()));
} else {
final Option option = module.getOption(optionString.replaceAll("\\s+", ""));
if(option != null) {
if(args.length > 1 && !args[1].isEmpty()) {
// Set
option.set(args[1]);
ChatHelper.log("\2477Value of \247e" + pmp + "\2477 is now: \247c" + option + "\247r");
if(valueString != null && !valueString.isEmpty()) {
try {
// Set
option.set(valueString);
ChatHelper.log("\2477Value of \247e" + option.name() + "\2477 is now: \247c" + option.get() + "\247r");
} catch(final Exception e) {
throw new CommandException('\'' + valueString + "' is not a valid value for '"
+ pluginString + ':' + moduleString + ':' + optionString + "'!");
}
} else {
ChatHelper.log("\2477Value of \247e" + pmp + "\2477: \247c" + option + "\247r");
ChatHelper.log("\2477Value of \247e" + option.name() + "\2477: \247c" + option.get() + "\247r");
}
} else {
ChatHelper.warn("\2477Couldn't find: \247c" + pmp + "\247r");
}
} else {
ChatHelper.log("\247e" + split[0] + '.' + split[1] + "\2477 has the following properties:");
for(final Option<?> o : module.getOptions()) {
ChatHelper.log(" \2477*\247e " + o.name());
ChatHelper.warn("\2477Unknown option: \247c" + pluginString + ':' + moduleString + ':' + optionString);
ChatHelper.log("\2477Module '\247e" + pluginString + ':' + moduleString +
"\2477' has the following options available:");
module.getOptions().forEach(o -> ChatHelper.log(" \2477* \247e" + o.name()));
}
}
} else {
ChatHelper.warn("\2477Couldn't find: \247c" + split[0] + '.' + split[1] + "\247r");
ChatHelper.warn("\2477Unknown module: \247c" + pluginString + ':' + moduleString);
ChatHelper.log("\2477Plugin '\247e" + plugin.getName() +
"\2477' has the following modules available:");
plugin.getProvidedModules().forEach(m -> ChatHelper.log(" \2477* \247e" + m.getName()));
}
} else {
ChatHelper.log("\247e" + split[0] + "\2477 has the following modules:");
plugin.getProvidedModules().forEach(module -> ChatHelper.log(" \2477*\247e " + module.getName()));
}
} else {
ChatHelper.warn("\2477Couldn't find: \247c" + split[0] + "\247r");
ChatHelper.warn("\2477Unknown plugin: \247c" + pluginString);
ChatHelper.log("\2477The following plugins are available: ");
Pipe.getInstance().getPluginManager().getPlugins().forEach(p -> ChatHelper.log(" \2477* \247e" + p.getName()));
}
} else {
ChatHelper.log("\2477Usage: " + commandPrefix + "value <plugin>[.<module>[.<property>]] [value]");
throw new CommandException("Not enough arguments!");
}
return true;
}
@@ -4,7 +4,7 @@
import com.google.gson.GsonBuilder;
import lgbt.audrey.pipe.bytecode.Generator;
import lgbt.audrey.pipe.bytecode.Version;
import lgbt.audrey.pipe.command.Command.Builder;
import lgbt.audrey.pipe.command.Command.CommandBuilder;
import lgbt.audrey.pipe.command.CommandManager;
import lgbt.audrey.pipe.event.EventBus;
import lgbt.audrey.pipe.event.PipeEventBus;
@@ -132,6 +132,23 @@ public boolean isEnabled() {
public boolean isLoaded() {
return false;
}

@Override
public void onEnable() {
super.onEnable();
if(commandManager != null) {
commandManager.registerCommand(internalPlugin, new CommandBuilder()
.setName("reload").setDesc("Reloads all plugins.")
.setExecutor((command, commandString, args) -> {
ChatHelper.log("Reloading all plugins...");
reload();
ChatHelper.log("Plugins reloaded!");
return true;
}).build());
} else {
getLogger().warning("No command manager available; reload command will not be added.");
}
}
};

private Pipe() {
@@ -149,14 +166,7 @@ public void init() {
logger.info("Starting up Pipe...");
setupDirectories();
pluginManager.init();
commandManager.registerCommand(internalPlugin, new Builder()
.setName("reload").setDesc("Reloads all plugins.")
.setExecutor((command, commandString, args) -> {
ChatHelper.log("Reloading all plugins...");
reload();
ChatHelper.log("Plugins reloaded!");
return true;
}).build());
internalPlugin.onEnable();
for(final Generator generator : version.getGenerators()) {
Agent.defineClass(Pipe.class.getClassLoader(), generator.generate(), generator.getClassName());
logger.info("Generated: " + generator.getClassName());
@@ -204,6 +214,7 @@ public void reload() {
getPluginManager().shutdown();

getPluginManager().init();
internalPlugin.onEnable();
}

/**
@@ -1,46 +1,56 @@
package lgbt.audrey.pipe.command;

import lombok.Data;
import lombok.Getter;

/**
* @author audrey
* @since 10/8/15.
*/
@Data
@SuppressWarnings("ClassWithOnlyPrivateConstructors")
public class Command {
private String name;
public final class Command {
@Getter
private String name = "No name given!";
@Getter
private String description = "No description given!";
@Getter
private CommandExecutor executor;
@Getter
private String[] help;

private Command() {
}

public static class Builder {
public static class CommandBuilder {
private String name;
private String desc;
private CommandExecutor executor;
private String[] help;

public Builder setName(final String name) {
public CommandBuilder setName(final String name) {
this.name = name;
return this;
}

public Builder setDesc(final String desc) {
public CommandBuilder setDesc(final String desc) {
this.desc = desc;
return this;
}

public Builder setExecutor(final CommandExecutor executor) {
public CommandBuilder setExecutor(final CommandExecutor executor) {
this.executor = executor;
return this;
}

public CommandBuilder setHelp(final String[] help) {
this.help = help;
return this;
}

public Command build() {
final Command command = new Command();
command.name = name;
command.description = desc;
command.executor = executor;
command.help = help;
return command;
}
}
@@ -0,0 +1,14 @@
package lgbt.audrey.pipe.command;

/**
* @author audrey
* @since 3/21/16.
*/
public class CommandException extends Exception {
public CommandException() {
}

public CommandException(final String reason) {
super(reason);
}
}
@@ -1,6 +1,5 @@
package lgbt.audrey.pipe.command;

import lgbt.audrey.pipe.util.ArgumentTokenizer;
import lgbt.audrey.pipe.util.ArgumentTokenizer;

import java.util.List;
@@ -11,7 +10,7 @@
*/
@FunctionalInterface
public interface CommandExecutor {
boolean executeCommand(Command command, String commandString, String[] args);
boolean executeCommand(Command command, String commandString, String[] args) throws CommandException;

default List<String> tokenize(final String commandString) {
return ArgumentTokenizer.tokenize(commandString, true);
@@ -9,7 +9,7 @@
* @since 10/8/15.
*/
public interface CommandManager {
boolean executeCommand(@NonNull String commandString);
boolean executeCommand(@NonNull String commandString) throws CommandException;

Command findCommand(@NonNull String commandName);

@@ -92,9 +92,4 @@ public void unregisterModule(@NonNull final Module module) {
Pipe.getLogger().warning(String.format("[%s] Ignoring unregister for non-registered module \"%s\"!", name, module.getName()));
}
}

@Override
public final void finishEnabling() {
providedModules.forEach(Module::init);
}
}
@@ -85,16 +85,4 @@ public interface Plugin extends Loadable, Toggleable {
* once.
*/
void loadManifestData();

/**
* Finishes up whatever the plugin needs to do after onEnable(). This may
* include anything from registering routes to adding event handlers. Note
* that {@link BasicPlugin} uses this for:
* <pre>
* Registering {@link Module} routes
* Initializting Modules
* Setting up all event listeners
* </pre>
*/
void finishEnabling();
}
@@ -2,6 +2,7 @@

import lgbt.audrey.pipe.Pipe;
import lgbt.audrey.pipe.bytecode.ClassEnumerator;
import lgbt.audrey.pipe.plugin.module.Module;
import lombok.Getter;
import lombok.NonNull;

@@ -119,7 +120,7 @@ public void init() {
try {
p.loadManifestData();
p.onEnable();
p.finishEnabling();
p.getProvidedModules().forEach(Module::init);
p.setEnabled(true);
Pipe.getLogger().info("Enabled plugin: " + p.getName());
} catch(final Exception e) {

This file was deleted.

@@ -87,7 +87,6 @@ public static List<String> tokenize(final CharSequence arguments) {
* @return A list of parsed and properly escaped arguments.
*/
public static List<String> tokenize(final CharSequence arguments, final boolean stringify) {

final AbstractSequentialList<String> argList = new LinkedList<>();
StringBuilder currArg = new StringBuilder();
boolean escaped = false;
@@ -3,7 +3,12 @@
import lgbt.audrey.pipe.util.helpers.Helper;
import me.curlpipesh.gl.tessellation.Tessellator;
import me.curlpipesh.gl.tessellation.impl.VAOTessellator;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.GLU;

import java.nio.FloatBuffer;
import java.nio.IntBuffer;

import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL13.GL_MULTISAMPLE;
@@ -16,13 +21,18 @@
* @author c
* @since 4/30/15
*/
@SuppressWarnings("unused")
public final class GLRenderer {
/**
* The {@link Tessellator} to be used for rendering. By default, this is a
* {@link VAOTessellator}.
*/
private static final Tessellator tess = new VAOTessellator(16777216);

private static final FloatBuffer modelview = BufferUtils.createFloatBuffer(16);
private static final FloatBuffer projection = BufferUtils.createFloatBuffer(16);
private static final IntBuffer viewport = BufferUtils.createIntBuffer(16);

private GLRenderer() {
}

@@ -282,80 +292,88 @@ public static void drawEmbossedString(final String s, final float x, final float
/*
* Modified Copypasta from: https://github.com/lowell/SaferHUD/blob/master/src/main/java/com/zyin/zyinhud/helper/HUDEntityTrackerHelper.java
*/
/*public float[] worldToScreen(Object entity, float ySum){
@SuppressWarnings("ConstantConditions")
public static float[] worldToScreen(final Object entity, final float ySum, final float partialTickTime) {
final Vec3 lastPlayerPos = Helper.getEntityPrevVec(Helper.getPlayer()).clone();
final Vec3 playerPos = Helper.getEntityVec(Helper.getPlayer()).clone();
final Vec2 pRot = Helper.getEntityRotation(Helper.getPlayer()).clone();
final Vec3 lastEntityPos = Helper.getEntityPrevVec(entity).clone();
final Vec3 entityPos = Helper.getEntityVec(entity).clone();
final Vec2 eRot = Helper.getEntityRotation(entity).clone();

EntityClientPlayerMP me = mc.thePlayer;
double meX = me.lastTickPosX + (me.posX - me.lastTickPosX) * partialTickTime;
double meY = me.lastTickPosY + (me.posY - me.lastTickPosY) * partialTickTime;
double meZ = me.lastTickPosZ + (me.posZ - me.lastTickPosZ) * partialTickTime;
double pitch = ((me.rotationPitch + 90) * Math.PI) / 180;
double yaw = ((me.rotationYaw + 90) * Math.PI) / 180;
final double meX = lastPlayerPos.x() + (playerPos.x() - lastPlayerPos.x()) * partialTickTime;
final double meY = lastPlayerPos.y() + (playerPos.y() - lastPlayerPos.y()) * partialTickTime;
final double meZ = lastPlayerPos.z() + (playerPos.z() - lastPlayerPos.z()) * partialTickTime;
final double pitch = (pRot.x() + 90) * Math.PI / 180;
final double yaw = (pRot.y() + 90) * Math.PI / 180;
// direction the player is facing
Vec3 lookDir = Vec3.createVectorHelper(Math.sin(pitch) * Math.cos(yaw), Math.cos(pitch), Math.sin(pitch) * Math.sin(yaw));
if (mc.gameSettings.thirdPersonView == 2){
final Vec3 lookDir = new Vec3(Math.sin(pitch) * Math.cos(yaw), Math.cos(pitch), Math.sin(pitch) * Math.sin(yaw));
//Vec3.createVectorHelper(Math.sin(pitch) * Math.cos(yaw), Math.cos(pitch), Math.sin(pitch) * Math.sin(yaw));
/*if (mc.gameSettings.thirdPersonView == 2){
// reversed 3rd-person view; flip the look direction
lookDir.xCoord *= -1;
lookDir.yCoord *= -1;
lookDir.zCoord *= -1;
}
lookDir.x() *= -1;
lookDir.y() *= -1;
lookDir.z() *= -1;
}*/

IntBuffer viewport = BufferUtils.createIntBuffer(16);
GL11.glGetInteger(GL11.GL_VIEWPORT, viewport);
glGetFloat(GL_MODELVIEW_MATRIX, modelview);
glGetFloat(GL_PROJECTION_MATRIX, projection);
glGetInteger(GL_VIEWPORT, viewport);

ScaledResolution res = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
int width = res.getScaledWidth();
int height = res.getScaledHeight();
final int width = Helper.getWidth();
final int height = Helper.getHeight();


double entityX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTickTime;
double entityY = (entity.lastTickPosY + ySum) + ((entity.posY + ySum) - (entity.lastTickPosY + ySum)) * partialTickTime;
double entityZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTickTime;
final double entityX = lastEntityPos.x() + (entityPos.x() - lastEntityPos.x()) * partialTickTime;
final double entityY = lastEntityPos.y() + ySum + (entityPos.y() + ySum - (lastEntityPos.y() + ySum)) * partialTickTime;
final double entityZ = lastEntityPos.z() + (entityPos.z() - lastEntityPos.z()) * partialTickTime;
// direction to target entity
Vec3 toEntity = Vec3.createVectorHelper(entityX - meX, entityY - meY, entityZ - meZ);
float x = (float)toEntity.xCoord;
float y = (float)toEntity.yCoord;
float z = (float)toEntity.zCoord;
double dist = toEntity.lengthVector();
//Vec3 toEntity = Vec3.createVectorHelper(entityX - meX, entityY - meY, entityZ - meZ);
Vec3 toEntity = new Vec3(entityX - meX, entityY - meY, entityZ - meZ);
float x = (float) toEntity.x();
float y = (float) toEntity.y();
float z = (float) toEntity.z();
final double dist = toEntity.length();
toEntity = toEntity.normalize();

if (lookDir.dotProduct(toEntity) <= 0.02){
if(lookDir.dot(toEntity) <= 0.02) {
// angle between vectors is greater than about 89 degrees, so
// create a dummy target location that is 89 degrees away from look direction
// along the arc between look direction and direction to target entity
final double angle = 89.0 * pi / 180;
final double angle = 89.0 * Math.PI / 180;
final double sin = Math.sin(angle);
final double cos = Math.cos(angle);
Vec3 ortho = lookDir.crossProduct(toEntity); // vector orthogonal to look direction and direction to target entity
double ox = ortho.xCoord;
double oy = ortho.yCoord;
double oz = ortho.zCoord;
final Vec3 ortho = lookDir.cross(toEntity); // vector orthogonal to look direction and direction to target entity
final double ox = ortho.x();
final double oy = ortho.y();
final double oz = ortho.z();
// build a rotation matrix to rotate around a vector (ortho) by an angle (89 degrees)
// from http://en.wikipedia.org/wiki/Rotation_matrix#Rotation_matrix_from_axis_and_angle
double m00 = cos + ox*ox*(1-cos);
double m01 = ox*oy*(1-cos) - oz*sin;
double m02 = ox*oz*(1-cos) + oy*sin;
double m10 = oy*ox*(1-cos) + oz*sin;
double m11 = cos + oy*oy*(1-cos);
double m12 = oy*oz*(1-cos) - ox*sin;
double m20 = oz*ox*(1-cos) - oy*sin;
double m21 = oz*oy*(1-cos) + ox*sin;
double m22 = cos + oz*oz*(1-cos);
final double m00 = cos + ox * ox * (1 - cos);
final double m01 = ox * oy * (1 - cos) - oz * sin;
final double m02 = ox * oz * (1 - cos) + oy * sin;
final double m10 = oy * ox * (1 - cos) + oz * sin;
final double m11 = cos + oy * oy * (1 - cos);
final double m12 = oy * oz * (1 - cos) - ox * sin;
final double m20 = oz * ox * (1 - cos) - oy * sin;
final double m21 = oz * oy * (1 - cos) + ox * sin;
final double m22 = cos + oz * oz * (1 - cos);
// transform (multiply) look direction vector with rotation matrix and scale by distance to target entity;
// this produces the coordinates for the dummy target
x = (float)(dist * (m00*lookDir.xCoord + m01*lookDir.yCoord + m02*lookDir.zCoord));
y = (float)(dist * (m10*lookDir.xCoord + m11*lookDir.yCoord + m12*lookDir.zCoord));
z = (float)(dist * (m20*lookDir.xCoord + m21*lookDir.yCoord + m22*lookDir.zCoord));
x = (float) (dist * (m00 * lookDir.x() + m01 * lookDir.y() + m02 * lookDir.z()));
y = (float) (dist * (m10 * lookDir.x() + m11 * lookDir.y() + m12 * lookDir.z()));
z = (float) (dist * (m20 * lookDir.x() + m21 * lookDir.y() + m22 * lookDir.z()));
}

FloatBuffer screenCoords = BufferUtils.createFloatBuffer(3);
modelMatrix.rewind();
projMatrix.rewind();
final FloatBuffer screenCoords = BufferUtils.createFloatBuffer(3);
//modelMatrix.rewind();
//projMatrix.rewind();
// map target's object coordinates into window coordinates
// using world render transform matrices stored by StoreMatrices()
GLU.gluProject(x, y, z, ActiveRenderInfo.modelview, ActiveRenderInfo.projection, ActiveRenderInfo.viewport, screenCoords);
float hudX = screenCoords.get(0) / res.getScaleFactor();
float hudY = height - screenCoords.get(1) / res.getScaleFactor();
GLU.gluProject(x, y, z, modelview, projection, viewport, screenCoords);
final float hudX = screenCoords.get(0) / Helper.getScale();//res.getScaleFactor();
final float hudY = height - screenCoords.get(1) / Helper.getScale();//res.getScaleFactor();
//System.out.println(hudX + " : " + hudY);
return new float[] { hudX, hudY };
}*/
return new float[] {hudX, hudY};
}
}
@@ -174,6 +174,11 @@ public void y(final double y) {
this.y = y;
}

@SuppressWarnings("CloneDoesntCallSuperClone")
public Vec2 clone() {
return new Vec2(x, y);
}

/**
* Returns a String representation of this vector
*