Skip to content

Commit 64815ab

Browse files
workin the corner store
1 parent 6f5f5a0 commit 64815ab

21 files changed

+945
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
3+
4+
5+
package com.gamesense.client.command;
6+
7+
import net.minecraft.client.*;
8+
9+
public abstract class Command
10+
{
11+
protected static final Minecraft mc;
12+
public static String commandPrefix;
13+
String commandName;
14+
String[] commandAlias;
15+
String commandSyntax;
16+
17+
public Command(final String commandName) {
18+
this.commandName = commandName;
19+
}
20+
21+
public static String getCommandPrefix() {
22+
return Command.commandPrefix;
23+
}
24+
25+
public String getCommandName() {
26+
return this.commandName;
27+
}
28+
29+
public String getCommandSyntax() {
30+
return this.commandSyntax;
31+
}
32+
33+
public String[] getCommandAlias() {
34+
return this.commandAlias;
35+
}
36+
37+
public static void setCommandPrefix(final String prefix) {
38+
Command.commandPrefix = prefix;
39+
}
40+
41+
public void setCommandSyntax(final String syntax) {
42+
this.commandSyntax = syntax;
43+
}
44+
45+
public void setCommandAlias(final String[] alias) {
46+
this.commandAlias = alias;
47+
}
48+
49+
public abstract void onCommand(final String p0, final String[] p1) throws Exception;
50+
51+
static {
52+
mc = Minecraft.getMinecraft();
53+
Command.commandPrefix = "-";
54+
}
55+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
3+
4+
5+
package com.gamesense.client.command;
6+
7+
import com.gamesense.client.command.commands.*;
8+
import java.util.*;
9+
import com.gamesense.api.util.misc.*;
10+
11+
public class CommandManager
12+
{
13+
public static ArrayList<Command> commands;
14+
boolean isValidCommand;
15+
16+
public CommandManager() {
17+
this.isValidCommand = false;
18+
}
19+
20+
public static void registerCommands() {
21+
addCommand(new AutoGearCommand());
22+
addCommand(new AutoGGCommand());
23+
addCommand(new AutoReplyCommand());
24+
addCommand(new AutoRespawnCommand());
25+
addCommand(new BindCommand());
26+
addCommand(new CmdListCommand());
27+
addCommand(new DisableAllCommand());
28+
addCommand(new DrawnCommand());
29+
addCommand(new EnemyCommand());
30+
addCommand(new FixGUICommand());
31+
addCommand(new FixHUDCommand());
32+
addCommand(new FontCommand());
33+
addCommand(new FriendCommand());
34+
addCommand(new ModulesCommand());
35+
addCommand(new OpenFolderCommand());
36+
addCommand(new PrefixCommand());
37+
addCommand(new SaveConfigCommand());
38+
addCommand(new SetCommand());
39+
addCommand(new ToggleCommand());
40+
}
41+
42+
public static void addCommand(final Command command) {
43+
CommandManager.commands.add(command);
44+
}
45+
46+
public static ArrayList<Command> getCommands() {
47+
return CommandManager.commands;
48+
}
49+
50+
public static Command getCommandByName(final String name) {
51+
for (final Command command : CommandManager.commands) {
52+
if (command.getCommandName() == name) {
53+
return command;
54+
}
55+
}
56+
return null;
57+
}
58+
59+
public void callCommand(final String input) {
60+
final String[] split = input.split(" (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)");
61+
final String command2 = split[0];
62+
final String args = input.substring(command2.length()).trim();
63+
this.isValidCommand = false;
64+
final String[] array;
65+
int length;
66+
int i = 0;
67+
String string;
68+
final String s;
69+
final String s2;
70+
CommandManager.commands.forEach(command -> {
71+
command.getCommandAlias();
72+
for (length = array.length; i < length; ++i) {
73+
string = array[i];
74+
if (string.equalsIgnoreCase(s)) {
75+
this.isValidCommand = true;
76+
try {
77+
command.onCommand(s2, s2.split(" (?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"));
78+
}
79+
catch (Exception e) {
80+
MessageBus.sendCommandMessage(command.getCommandSyntax(), true);
81+
}
82+
}
83+
}
84+
return;
85+
});
86+
if (!this.isValidCommand) {
87+
MessageBus.sendCommandMessage("Error! Invalid command!", true);
88+
}
89+
}
90+
91+
static {
92+
CommandManager.commands = new ArrayList<Command>();
93+
}
94+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
3+
4+
5+
package com.gamesense.client.command.commands;
6+
7+
import com.gamesense.client.command.*;
8+
import com.gamesense.client.module.modules.misc.*;
9+
import com.gamesense.api.util.misc.*;
10+
11+
public class AutoGGCommand extends Command
12+
{
13+
public AutoGGCommand() {
14+
super("AutoGG");
15+
this.setCommandSyntax(Command.getCommandPrefix() + "autogg add/del [message] (use _ for spaces)");
16+
this.setCommandAlias(new String[] { "autogg", "gg" });
17+
}
18+
19+
public void onCommand(final String command, final String[] message) throws Exception {
20+
final String main = message[0];
21+
final String value = message[1].replace("_", " ");
22+
if (main.equalsIgnoreCase("add") && !AutoGG.getAutoGgMessages().contains(value)) {
23+
AutoGG.addAutoGgMessage(value);
24+
MessageBus.sendCommandMessage("Added AutoGG message: " + value + "!", true);
25+
}
26+
else if (main.equalsIgnoreCase("del") && AutoGG.getAutoGgMessages().contains(value)) {
27+
AutoGG.getAutoGgMessages().remove(value);
28+
MessageBus.sendCommandMessage("Deleted AutoGG message: " + value + "!", true);
29+
}
30+
}
31+
}
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
2+
3+
4+
5+
package com.gamesense.client.command.commands;
6+
7+
import com.gamesense.client.command.*;
8+
import com.gamesense.api.util.misc.*;
9+
import com.google.gson.*;
10+
import com.gamesense.client.module.modules.combat.*;
11+
import net.minecraft.item.*;
12+
import java.util.*;
13+
import java.io.*;
14+
15+
public class AutoGearCommand extends Command
16+
{
17+
private static final String pathSave = "KiefSense/Misc/AutoGear.json";
18+
private static final HashMap<String, String> errorMessage;
19+
20+
public AutoGearCommand() {
21+
super("AutoGear");
22+
this.setCommandSyntax(Command.getCommandPrefix() + "gear set/save/del/list [name]");
23+
this.setCommandAlias(new String[] { "gear", "gr", "kit" });
24+
}
25+
26+
public void onCommand(final String command, final String[] message) throws Exception {
27+
final String lowerCase = message[0].toLowerCase();
28+
switch (lowerCase) {
29+
case "list": {
30+
if (message.length == 1) {
31+
this.listMessage();
32+
break;
33+
}
34+
errorMessage("NoPar");
35+
break;
36+
}
37+
case "set": {
38+
if (message.length == 2) {
39+
this.set(message[1]);
40+
break;
41+
}
42+
errorMessage("NoPar");
43+
break;
44+
}
45+
case "save":
46+
case "add":
47+
case "create": {
48+
if (message.length == 2) {
49+
this.save(message[1]);
50+
break;
51+
}
52+
errorMessage("NoPar");
53+
break;
54+
}
55+
case "del": {
56+
if (message.length == 2) {
57+
this.delete(message[1]);
58+
break;
59+
}
60+
errorMessage("NoPar");
61+
break;
62+
}
63+
default: {
64+
MessageBus.sendCommandMessage("AutoGear message is: gear set/save/del/list [name]", true);
65+
break;
66+
}
67+
}
68+
}
69+
70+
private void listMessage() {
71+
JsonObject completeJson = new JsonObject();
72+
try {
73+
completeJson = new JsonParser().parse((Reader)new FileReader("KiefSense/Misc/AutoGear.json")).getAsJsonObject();
74+
for (int lenghtJson = completeJson.entrySet().size(), i = 0; i < lenghtJson; ++i) {
75+
final String item = new JsonParser().parse((Reader)new FileReader("KiefSense/Misc/AutoGear.json")).getAsJsonObject().entrySet().toArray()[i].toString().split("=")[0];
76+
if (!item.equals("pointer")) {
77+
PistonCrystal.printChat("Kit avaible: " + item, false);
78+
}
79+
}
80+
}
81+
catch (IOException e) {
82+
errorMessage("NoEx");
83+
}
84+
}
85+
86+
private void delete(final String name) {
87+
JsonObject completeJson = new JsonObject();
88+
try {
89+
completeJson = new JsonParser().parse((Reader)new FileReader("KiefSense/Misc/AutoGear.json")).getAsJsonObject();
90+
if (completeJson.get(name) != null && !name.equals("pointer")) {
91+
completeJson.remove(name);
92+
if (completeJson.get("pointer").getAsString().equals(name)) {
93+
completeJson.addProperty("pointer", "none");
94+
}
95+
this.saveFile(completeJson, name, "deleted");
96+
}
97+
else {
98+
errorMessage("NoEx");
99+
}
100+
}
101+
catch (IOException e) {
102+
errorMessage("NoEx");
103+
}
104+
}
105+
106+
private void set(final String name) {
107+
JsonObject completeJson = new JsonObject();
108+
try {
109+
completeJson = new JsonParser().parse((Reader)new FileReader("KiefSense/Misc/AutoGear.json")).getAsJsonObject();
110+
if (completeJson.get(name) != null && !name.equals("pointer")) {
111+
completeJson.addProperty("pointer", name);
112+
this.saveFile(completeJson, name, "selected");
113+
}
114+
else {
115+
errorMessage("NoEx");
116+
}
117+
}
118+
catch (IOException e) {
119+
errorMessage("NoEx");
120+
}
121+
}
122+
123+
private void save(final String name) {
124+
JsonObject completeJson = new JsonObject();
125+
try {
126+
completeJson = new JsonParser().parse((Reader)new FileReader("KiefSense/Misc/AutoGear.json")).getAsJsonObject();
127+
if (completeJson.get(name) != null && !name.equals("pointer")) {
128+
errorMessage("Exist");
129+
return;
130+
}
131+
}
132+
catch (IOException e) {
133+
completeJson.addProperty("pointer", "none");
134+
}
135+
final StringBuilder jsonInventory = new StringBuilder();
136+
for (final ItemStack item : AutoGearCommand.mc.player.inventory.mainInventory) {
137+
jsonInventory.append(item.getItem().getRegistryName().toString() + item.getMetadata()).append(" ");
138+
}
139+
completeJson.addProperty(name, jsonInventory.toString());
140+
this.saveFile(completeJson, name, "saved");
141+
}
142+
143+
private void saveFile(final JsonObject completeJson, final String name, final String operation) {
144+
try {
145+
final BufferedWriter bw = new BufferedWriter(new FileWriter("KiefSense/Misc/AutoGear.json"));
146+
bw.write(completeJson.toString());
147+
bw.close();
148+
PistonCrystal.printChat("Kit " + name + " " + operation, false);
149+
}
150+
catch (IOException e) {
151+
errorMessage("Saving");
152+
}
153+
}
154+
155+
private static void errorMessage(final String e) {
156+
PistonCrystal.printChat("Error: " + AutoGearCommand.errorMessage.get(e), true);
157+
}
158+
159+
public static String getCurrentSet() {
160+
JsonObject completeJson = new JsonObject();
161+
try {
162+
completeJson = new JsonParser().parse((Reader)new FileReader("KiefSense/Misc/AutoGear.json")).getAsJsonObject();
163+
if (!completeJson.get("pointer").getAsString().equals("none")) {
164+
return completeJson.get("pointer").getAsString();
165+
}
166+
}
167+
catch (IOException ex) {}
168+
errorMessage("NoEx");
169+
return "";
170+
}
171+
172+
public static String getInventoryKit(final String kit) {
173+
JsonObject completeJson = new JsonObject();
174+
try {
175+
completeJson = new JsonParser().parse((Reader)new FileReader("KiefSense/Misc/AutoGear.json")).getAsJsonObject();
176+
return completeJson.get(kit).getAsString();
177+
}
178+
catch (IOException ex) {
179+
errorMessage("NoEx");
180+
return "";
181+
}
182+
}
183+
184+
static {
185+
errorMessage = new HashMap<String, String>() {
186+
{
187+
this.put("NoPar", "Not enough parameters");
188+
this.put("Exist", "This kit arleady exist");
189+
this.put("Saving", "Error saving the file");
190+
this.put("NoEx", "Kit not found");
191+
}
192+
};
193+
}
194+
}

0 commit comments

Comments
 (0)