Using more OOPs, so I would at least increase a bit of performance rather than static abuse
This commit is contained in:
parent
08386174ba
commit
49657c4fd1
7 changed files with 53 additions and 33 deletions
|
@ -81,7 +81,6 @@ jar {
|
||||||
"ForceLoadAsMod": true,
|
"ForceLoadAsMod": true,
|
||||||
"MixinConfigs": "mixins.night0721.json",
|
"MixinConfigs": "mixins.night0721.json",
|
||||||
"ModSide": "CLIENT",
|
"ModSide": "CLIENT",
|
||||||
// "TweakClass": "gg.essential.loader.stage0.EssentialSetupTweaker",
|
|
||||||
"TweakClass": "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker",
|
"TweakClass": "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker",
|
||||||
"TweakOrder": "0")
|
"TweakOrder": "0")
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
|
@ -4,7 +4,7 @@ import cc.polyfrost.oneconfig.events.EventManager;
|
||||||
import cc.polyfrost.oneconfig.events.event.InitializationEvent;
|
import cc.polyfrost.oneconfig.events.event.InitializationEvent;
|
||||||
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
|
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
|
||||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||||
import me.night0721.lilase.config.AHConfig;
|
import me.night0721.lilase.features.ah.AHConfig;
|
||||||
import me.night0721.lilase.events.PacketReceivedEvent;
|
import me.night0721.lilase.events.PacketReceivedEvent;
|
||||||
import me.night0721.lilase.features.ah.AuctionHouse;
|
import me.night0721.lilase.features.ah.AuctionHouse;
|
||||||
import me.night0721.lilase.features.flip.Flipper;
|
import me.night0721.lilase.features.flip.Flipper;
|
||||||
|
@ -29,8 +29,8 @@ import org.lwjgl.opengl.Display;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static me.night0721.lilase.config.AHConfig.AUCTION_HOUSE_DELAY;
|
import static me.night0721.lilase.features.ah.AHConfig.AUCTION_HOUSE_DELAY;
|
||||||
import static me.night0721.lilase.config.AHConfig.RECONNECT_DELAY;
|
import static me.night0721.lilase.features.ah.AHConfig.RECONNECT_DELAY;
|
||||||
|
|
||||||
@Mod(modid = Lilase.MODID, name = Lilase.MOD_NAME, version = Lilase.VERSION, acceptedMinecraftVersions = "[1.8.9]")
|
@Mod(modid = Lilase.MODID, name = Lilase.MOD_NAME, version = Lilase.VERSION, acceptedMinecraftVersions = "[1.8.9]")
|
||||||
public class Lilase {
|
public class Lilase {
|
||||||
|
@ -73,7 +73,7 @@ public class Lilase {
|
||||||
if (tickAmount % 2400 == 0) {
|
if (tickAmount % 2400 == 0) {
|
||||||
ConfigUtils.checkWebhookAndAPI();
|
ConfigUtils.checkWebhookAndAPI();
|
||||||
}
|
}
|
||||||
Flipper.switchStates();
|
AuctionHouse.flipper.switchStates();
|
||||||
if ((mc.currentScreen instanceof GuiDisconnected)) {
|
if ((mc.currentScreen instanceof GuiDisconnected)) {
|
||||||
if (waitTime >= (RECONNECT_DELAY * 20)) {
|
if (waitTime >= (RECONNECT_DELAY * 20)) {
|
||||||
waitTime = 0;
|
waitTime = 0;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package me.night0721.lilase.events;
|
package me.night0721.lilase.events;
|
||||||
|
|
||||||
import me.night0721.lilase.Lilase;
|
import me.night0721.lilase.Lilase;
|
||||||
import me.night0721.lilase.config.AHConfig;
|
import me.night0721.lilase.features.ah.AHConfig;
|
||||||
import me.night0721.lilase.features.flip.Flipper;
|
import me.night0721.lilase.features.flip.Flipper;
|
||||||
import me.night0721.lilase.features.flip.FlipperState;
|
import me.night0721.lilase.features.flip.FlipperState;
|
||||||
import me.night0721.lilase.gui.TextRenderer;
|
import me.night0721.lilase.gui.TextRenderer;
|
||||||
|
@ -27,17 +27,15 @@ import java.io.IOException;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import static me.night0721.lilase.config.AHConfig.GUI_COLOR;
|
import static me.night0721.lilase.features.ah.AHConfig.GUI_COLOR;
|
||||||
import static me.night0721.lilase.features.ah.AuctionHouse.flipper;
|
import static me.night0721.lilase.features.ah.AuctionHouse.flipper;
|
||||||
import static me.night0721.lilase.features.ah.AuctionHouse.webhook;
|
|
||||||
import static me.night0721.lilase.features.flip.Flipper.rotation;
|
import static me.night0721.lilase.features.flip.Flipper.rotation;
|
||||||
import static me.night0721.lilase.features.flip.FlipperState.START;
|
import static me.night0721.lilase.features.flip.FlipperState.START;
|
||||||
import static me.night0721.lilase.utils.PlayerUtils.sendPacketWithoutEvent;
|
import static me.night0721.lilase.utils.PlayerUtils.sendPacketWithoutEvent;
|
||||||
|
|
||||||
public class SniperFlipperEvents {
|
public class SniperFlipperEvents {
|
||||||
Thread bzchillingthread;
|
private int windowId = 1;
|
||||||
private static int windowId = 1;
|
private boolean buying = false;
|
||||||
private static boolean buying = false;
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onChat(ClientChatReceivedEvent event) throws InterruptedException, IOException {
|
public void onChat(ClientChatReceivedEvent event) throws InterruptedException, IOException {
|
||||||
|
@ -56,7 +54,7 @@ public class SniperFlipperEvents {
|
||||||
ConfigUtils.writeStringConfig("main", "APIKey", apiKey);
|
ConfigUtils.writeStringConfig("main", "APIKey", apiKey);
|
||||||
} else if (message.equals("Claiming BIN auction...") && buying) {
|
} else if (message.equals("Claiming BIN auction...") && buying) {
|
||||||
Utils.debugLog("[Sniper] Bought an item, starting to sell");
|
Utils.debugLog("[Sniper] Bought an item, starting to sell");
|
||||||
webhook.execute();
|
Lilase.auctionHouse.webhook.execute();
|
||||||
flipper.sellItem();
|
flipper.sellItem();
|
||||||
} else if (message.equals("Your starting bid must be at least 10 coins!")) {
|
} else if (message.equals("Your starting bid must be at least 10 coins!")) {
|
||||||
InventoryUtils.clickOpenContainerSlot(13);
|
InventoryUtils.clickOpenContainerSlot(13);
|
||||||
|
@ -72,10 +70,10 @@ public class SniperFlipperEvents {
|
||||||
} else if (message.contains("You were spawned in Limbo")) {
|
} else if (message.contains("You were spawned in Limbo")) {
|
||||||
Utils.sendMessage("Detected in Limbo, stopping everything for 5 minutes");
|
Utils.sendMessage("Detected in Limbo, stopping everything for 5 minutes");
|
||||||
Flipper.state = FlipperState.NONE;
|
Flipper.state = FlipperState.NONE;
|
||||||
if (Lilase.auctionHouse.open) Lilase.auctionHouse.toggleAuction();
|
if (Lilase.auctionHouse.getOpen()) Lilase.auctionHouse.toggleAuction();
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
Utils.sendServerMessage("/hub");
|
Utils.sendServerMessage("/hub");
|
||||||
bzchillingthread = new Thread(bazaarChilling);
|
Thread bzchillingthread = new Thread(bazaarChilling);
|
||||||
bzchillingthread.start();
|
bzchillingthread.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +159,12 @@ public class SniperFlipperEvents {
|
||||||
int hour = cal.get(Calendar.HOUR_OF_DAY);
|
int hour = cal.get(Calendar.HOUR_OF_DAY);
|
||||||
int minute = cal.get(Calendar.MINUTE);
|
int minute = cal.get(Calendar.MINUTE);
|
||||||
String time = String.format("%02d:%02d", hour, minute);
|
String time = String.format("%02d:%02d", hour, minute);
|
||||||
String lines = "X: " + Math.round(PlayerUtils.mc.thePlayer.posX) + "\n" + "Y: " + Math.round(PlayerUtils.mc.thePlayer.posY) + "\n" + "Z: " + Math.round(PlayerUtils.mc.thePlayer.posZ) + "\n" + time + "\n" + "FPS: " + Minecraft.getDebugFPS();
|
String lines = "X: " + Math.round(PlayerUtils.mc.thePlayer.posX) + "\n" +
|
||||||
|
"Y: " + Math.round(PlayerUtils.mc.thePlayer.posY) + "\n" +
|
||||||
|
"Z: " + Math.round(PlayerUtils.mc.thePlayer.posZ) + "\n" +
|
||||||
|
time + "\n" +
|
||||||
|
"FPS: " + Minecraft.getDebugFPS() + "\n" +
|
||||||
|
"Auctions Sniped" + Lilase.auctionHouse.getAuctionsSniped();
|
||||||
TextRenderer.drawString(lines, 0, 0, 1.5, GUI_COLOR.getRGB());
|
TextRenderer.drawString(lines, 0, 0, 1.5, GUI_COLOR.getRGB());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night0721.lilase.config;
|
package me.night0721.lilase.features.ah;
|
||||||
|
|
||||||
import cc.polyfrost.oneconfig.config.Config;
|
import cc.polyfrost.oneconfig.config.Config;
|
||||||
import cc.polyfrost.oneconfig.config.annotations.Number;
|
import cc.polyfrost.oneconfig.config.annotations.Number;
|
|
@ -23,14 +23,14 @@ import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class AuctionHouse {
|
public class AuctionHouse {
|
||||||
private static String uuid;
|
private String uuid;
|
||||||
private static String message_toSend;
|
private String message_toSend;
|
||||||
public static Flipper flipper;
|
private Boolean open = false;
|
||||||
public static final DiscordWebhook webhook = new DiscordWebhook(ConfigUtils.getString("main", "Webhook"));
|
private int auctionsSniped = 0;
|
||||||
|
public DiscordWebhook webhook = new DiscordWebhook(ConfigUtils.getString("main", "Webhook"));
|
||||||
public Boolean open = false;
|
|
||||||
private final List<Item> items = new ArrayList<>();
|
private final List<Item> items = new ArrayList<>();
|
||||||
private final List<String> posted = new ArrayList<>();
|
private final List<String> posted = new ArrayList<>();
|
||||||
|
public static Flipper flipper;
|
||||||
|
|
||||||
public AuctionHouse() {
|
public AuctionHouse() {
|
||||||
if (!ConfigUtils.getString("item1", "Name").equals("") && !ConfigUtils.getString("item1", "Type").equals("") && !ConfigUtils.getString("item1", "Tier").equals("") && ConfigUtils.getInt("item1", "Price") != 0)
|
if (!ConfigUtils.getString("item1", "Name").equals("") && !ConfigUtils.getString("item1", "Type").equals("") && !ConfigUtils.getString("item1", "Tier").equals("") && ConfigUtils.getInt("item1", "Price") != 0)
|
||||||
|
@ -166,7 +166,7 @@ public class AuctionHouse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendAuction() {
|
private void sendAuction() {
|
||||||
Utils.sendServerMessage("/viewauction " + uuid);
|
Utils.sendServerMessage("/viewauction " + uuid);
|
||||||
Utils.sendMessage(message_toSend);
|
Utils.sendMessage(message_toSend);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,6 @@ public class AuctionHouse {
|
||||||
private final List<String> timesString = Arrays.asList("year", "month", "day", "hour", "minute", "second");
|
private final List<String> timesString = Arrays.asList("year", "month", "day", "hour", "minute", "second");
|
||||||
|
|
||||||
public String toDuration(long duration) {
|
public String toDuration(long duration) {
|
||||||
|
|
||||||
StringBuilder res = new StringBuilder();
|
StringBuilder res = new StringBuilder();
|
||||||
for (int i = 0; i < times.size(); i++) {
|
for (int i = 0; i < times.size(); i++) {
|
||||||
Long current = times.get(i);
|
Long current = times.get(i);
|
||||||
|
@ -189,12 +188,11 @@ public class AuctionHouse {
|
||||||
else return res.toString();
|
else return res.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTimeSinceDate(long timeSinceDate) {
|
private String getTimeSinceDate(long timeSinceDate) {
|
||||||
long seconds = TimeUnit.MILLISECONDS.toSeconds(timeSinceDate);
|
long seconds = TimeUnit.MILLISECONDS.toSeconds(timeSinceDate);
|
||||||
long minutes = TimeUnit.MILLISECONDS.toMinutes(timeSinceDate);
|
long minutes = TimeUnit.MILLISECONDS.toMinutes(timeSinceDate);
|
||||||
long hours = TimeUnit.MILLISECONDS.toHours(timeSinceDate);
|
long hours = TimeUnit.MILLISECONDS.toHours(timeSinceDate);
|
||||||
long days = TimeUnit.MILLISECONDS.toDays(timeSinceDate);
|
long days = TimeUnit.MILLISECONDS.toDays(timeSinceDate);
|
||||||
|
|
||||||
if (seconds < 60) return "in " + seconds + " seconds";
|
if (seconds < 60) return "in " + seconds + " seconds";
|
||||||
else if (minutes < 60) return "in " + minutes + " minutes";
|
else if (minutes < 60) return "in " + minutes + " minutes";
|
||||||
else if (hours < 24) return "in " + hours + " hours";
|
else if (hours < 24) return "in " + hours + " hours";
|
||||||
|
@ -215,6 +213,22 @@ public class AuctionHouse {
|
||||||
} else Utils.sendMessage("Detected not in hub, please go to hub to start");
|
} else Utils.sendMessage("Detected not in hub, please go to hub to start");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getOpen() {
|
||||||
|
return open;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpen(Boolean open) {
|
||||||
|
this.open = open;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAuctionsSniped() {
|
||||||
|
return auctionsSniped;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementAuctionsSniped() {
|
||||||
|
this.auctionsSniped += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class Flipper {
|
||||||
private final int itemprice;
|
private final int itemprice;
|
||||||
public static FlipperState state = FlipperState.NONE;
|
public static FlipperState state = FlipperState.NONE;
|
||||||
public static final Rotation rotation = new Rotation();
|
public static final Rotation rotation = new Rotation();
|
||||||
private static final Clock buyWait = new Clock();
|
private final Clock buyWait = new Clock();
|
||||||
|
|
||||||
public Flipper(String name, String data, int price) {
|
public Flipper(String name, String data, int price) {
|
||||||
itemname = name;
|
itemname = name;
|
||||||
|
@ -42,13 +42,13 @@ public class Flipper {
|
||||||
|
|
||||||
public void sellItem() {
|
public void sellItem() {
|
||||||
Utils.sendMessage("Flipper is running, stopping, will resume when flipper is done");
|
Utils.sendMessage("Flipper is running, stopping, will resume when flipper is done");
|
||||||
if (Lilase.auctionHouse.open) Lilase.auctionHouse.toggleAuction();
|
if (Lilase.auctionHouse.getOpen()) Lilase.auctionHouse.toggleAuction();
|
||||||
UngrabUtils.ungrabMouse();
|
UngrabUtils.ungrabMouse();
|
||||||
Utils.sendServerMessage("/hub");
|
Utils.sendServerMessage("/hub");
|
||||||
state = FlipperState.WALKING_TO_FIRST_POINT;
|
state = FlipperState.WALKING_TO_FIRST_POINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void switchStates() {
|
public void switchStates() {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case WALKING_TO_FIRST_POINT:
|
case WALKING_TO_FIRST_POINT:
|
||||||
if (PlayerUtils.mc.currentScreen != null) {
|
if (PlayerUtils.mc.currentScreen != null) {
|
||||||
|
@ -99,7 +99,7 @@ public class Flipper {
|
||||||
if (InventoryUtils.getSlotForItem(itemname) == -1) {
|
if (InventoryUtils.getSlotForItem(itemname) == -1) {
|
||||||
Utils.sendMessage("Cannot find item in inventory, stopping flipper");
|
Utils.sendMessage("Cannot find item in inventory, stopping flipper");
|
||||||
state = FlipperState.NONE;
|
state = FlipperState.NONE;
|
||||||
Lilase.auctionHouse.open = true;
|
Lilase.auctionHouse.setOpen(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
InventoryUtils.clickOpenContainerSlot(InventoryUtils.getSlotForItem(itemname));
|
InventoryUtils.clickOpenContainerSlot(InventoryUtils.getSlotForItem(itemname));
|
||||||
|
@ -125,7 +125,10 @@ public class Flipper {
|
||||||
buyWait.schedule(1000);
|
buyWait.schedule(1000);
|
||||||
} else if (InventoryUtils.inventoryNameContains("BIN Auction View") && buyWait.passed()) {
|
} else if (InventoryUtils.inventoryNameContains("BIN Auction View") && buyWait.passed()) {
|
||||||
InventoryUtils.clickOpenContainerSlot(49);
|
InventoryUtils.clickOpenContainerSlot(49);
|
||||||
|
Lilase.auctionHouse.incrementAuctionsSniped();
|
||||||
|
buyWait.schedule(500);
|
||||||
PlayerUtils.mc.thePlayer.closeScreen();
|
PlayerUtils.mc.thePlayer.closeScreen();
|
||||||
|
buyWait.schedule(500);
|
||||||
Utils.sendMessage("Posted item on Auction House, continue sniping now");
|
Utils.sendMessage("Posted item on Auction House, continue sniping now");
|
||||||
state = FlipperState.NONE;
|
state = FlipperState.NONE;
|
||||||
Lilase.auctionHouse.toggleAuction();
|
Lilase.auctionHouse.toggleAuction();
|
||||||
|
@ -158,15 +161,15 @@ public class Flipper {
|
||||||
return new JSONObject(content.toString());
|
return new JSONObject(content.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float distanceToFirstPoint() {
|
private float distanceToFirstPoint() {
|
||||||
return (float) Math.sqrt(Math.pow(PlayerUtils.mc.thePlayer.posX - (-2.5), 2) + Math.pow(PlayerUtils.mc.thePlayer.posZ - (-91.5), 2));
|
return (float) Math.sqrt(Math.pow(PlayerUtils.mc.thePlayer.posX - (-2.5), 2) + Math.pow(PlayerUtils.mc.thePlayer.posZ - (-91.5), 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float distanceToAuctionMaster() {
|
private float distanceToAuctionMaster() {
|
||||||
return (float) Math.sqrt(Math.pow(PlayerUtils.mc.thePlayer.posX - (-45), 2) + Math.pow(PlayerUtils.mc.thePlayer.posZ - (-90), 2));
|
return (float) Math.sqrt(Math.pow(PlayerUtils.mc.thePlayer.posX - (-45), 2) + Math.pow(PlayerUtils.mc.thePlayer.posZ - (-90), 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Entity getAuctionMaster() {
|
private Entity getAuctionMaster() {
|
||||||
for (final Entity e : PlayerUtils.mc.theWorld.loadedEntityList) {
|
for (final Entity e : PlayerUtils.mc.theWorld.loadedEntityList) {
|
||||||
if (e instanceof EntityArmorStand) {
|
if (e instanceof EntityArmorStand) {
|
||||||
final String name = StringUtils.stripControlCodes(e.getDisplayName().getUnformattedText());
|
final String name = StringUtils.stripControlCodes(e.getDisplayName().getUnformattedText());
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
"package": "me.night0721.lilase.mixins",
|
"package": "me.night0721.lilase.mixins",
|
||||||
"refmap": "mixins.night0721.refmap.json",
|
"refmap": "mixins.night0721.refmap.json",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
|
"minVersion": "0.8.2",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinNetworkManager"
|
"MixinNetworkManager"
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue