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,
|
||||
"MixinConfigs": "mixins.night0721.json",
|
||||
"ModSide": "CLIENT",
|
||||
// "TweakClass": "gg.essential.loader.stage0.EssentialSetupTweaker",
|
||||
"TweakClass": "cc.polyfrost.oneconfig.loader.stage0.LaunchWrapperTweaker",
|
||||
"TweakOrder": "0")
|
||||
enabled = false
|
||||
|
|
|
@ -4,7 +4,7 @@ import cc.polyfrost.oneconfig.events.EventManager;
|
|||
import cc.polyfrost.oneconfig.events.event.InitializationEvent;
|
||||
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
|
||||
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.features.ah.AuctionHouse;
|
||||
import me.night0721.lilase.features.flip.Flipper;
|
||||
|
@ -29,8 +29,8 @@ import org.lwjgl.opengl.Display;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import static me.night0721.lilase.config.AHConfig.AUCTION_HOUSE_DELAY;
|
||||
import static me.night0721.lilase.config.AHConfig.RECONNECT_DELAY;
|
||||
import static me.night0721.lilase.features.ah.AHConfig.AUCTION_HOUSE_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]")
|
||||
public class Lilase {
|
||||
|
@ -73,7 +73,7 @@ public class Lilase {
|
|||
if (tickAmount % 2400 == 0) {
|
||||
ConfigUtils.checkWebhookAndAPI();
|
||||
}
|
||||
Flipper.switchStates();
|
||||
AuctionHouse.flipper.switchStates();
|
||||
if ((mc.currentScreen instanceof GuiDisconnected)) {
|
||||
if (waitTime >= (RECONNECT_DELAY * 20)) {
|
||||
waitTime = 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package me.night0721.lilase.events;
|
||||
|
||||
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.FlipperState;
|
||||
import me.night0721.lilase.gui.TextRenderer;
|
||||
|
@ -27,17 +27,15 @@ import java.io.IOException;
|
|||
import java.util.Calendar;
|
||||
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.webhook;
|
||||
import static me.night0721.lilase.features.flip.Flipper.rotation;
|
||||
import static me.night0721.lilase.features.flip.FlipperState.START;
|
||||
import static me.night0721.lilase.utils.PlayerUtils.sendPacketWithoutEvent;
|
||||
|
||||
public class SniperFlipperEvents {
|
||||
Thread bzchillingthread;
|
||||
private static int windowId = 1;
|
||||
private static boolean buying = false;
|
||||
private int windowId = 1;
|
||||
private boolean buying = false;
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChat(ClientChatReceivedEvent event) throws InterruptedException, IOException {
|
||||
|
@ -56,7 +54,7 @@ public class SniperFlipperEvents {
|
|||
ConfigUtils.writeStringConfig("main", "APIKey", apiKey);
|
||||
} else if (message.equals("Claiming BIN auction...") && buying) {
|
||||
Utils.debugLog("[Sniper] Bought an item, starting to sell");
|
||||
webhook.execute();
|
||||
Lilase.auctionHouse.webhook.execute();
|
||||
flipper.sellItem();
|
||||
} else if (message.equals("Your starting bid must be at least 10 coins!")) {
|
||||
InventoryUtils.clickOpenContainerSlot(13);
|
||||
|
@ -72,10 +70,10 @@ public class SniperFlipperEvents {
|
|||
} else if (message.contains("You were spawned in Limbo")) {
|
||||
Utils.sendMessage("Detected in Limbo, stopping everything for 5 minutes");
|
||||
Flipper.state = FlipperState.NONE;
|
||||
if (Lilase.auctionHouse.open) Lilase.auctionHouse.toggleAuction();
|
||||
if (Lilase.auctionHouse.getOpen()) Lilase.auctionHouse.toggleAuction();
|
||||
Thread.sleep(5000);
|
||||
Utils.sendServerMessage("/hub");
|
||||
bzchillingthread = new Thread(bazaarChilling);
|
||||
Thread bzchillingthread = new Thread(bazaarChilling);
|
||||
bzchillingthread.start();
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +159,12 @@ public class SniperFlipperEvents {
|
|||
int hour = cal.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = cal.get(Calendar.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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.annotations.Number;
|
|
@ -23,14 +23,14 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
public class AuctionHouse {
|
||||
private static String uuid;
|
||||
private static String message_toSend;
|
||||
public static Flipper flipper;
|
||||
public static final DiscordWebhook webhook = new DiscordWebhook(ConfigUtils.getString("main", "Webhook"));
|
||||
|
||||
public Boolean open = false;
|
||||
private String uuid;
|
||||
private String message_toSend;
|
||||
private Boolean open = false;
|
||||
private int auctionsSniped = 0;
|
||||
public DiscordWebhook webhook = new DiscordWebhook(ConfigUtils.getString("main", "Webhook"));
|
||||
private final List<Item> items = new ArrayList<>();
|
||||
private final List<String> posted = new ArrayList<>();
|
||||
public static Flipper flipper;
|
||||
|
||||
public AuctionHouse() {
|
||||
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.sendMessage(message_toSend);
|
||||
}
|
||||
|
@ -175,7 +175,6 @@ public class AuctionHouse {
|
|||
private final List<String> timesString = Arrays.asList("year", "month", "day", "hour", "minute", "second");
|
||||
|
||||
public String toDuration(long duration) {
|
||||
|
||||
StringBuilder res = new StringBuilder();
|
||||
for (int i = 0; i < times.size(); i++) {
|
||||
Long current = times.get(i);
|
||||
|
@ -189,12 +188,11 @@ public class AuctionHouse {
|
|||
else return res.toString();
|
||||
}
|
||||
|
||||
private static String getTimeSinceDate(long timeSinceDate) {
|
||||
private String getTimeSinceDate(long timeSinceDate) {
|
||||
long seconds = TimeUnit.MILLISECONDS.toSeconds(timeSinceDate);
|
||||
long minutes = TimeUnit.MILLISECONDS.toMinutes(timeSinceDate);
|
||||
long hours = TimeUnit.MILLISECONDS.toHours(timeSinceDate);
|
||||
long days = TimeUnit.MILLISECONDS.toDays(timeSinceDate);
|
||||
|
||||
if (seconds < 60) return "in " + seconds + " seconds";
|
||||
else if (minutes < 60) return "in " + minutes + " minutes";
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
public static FlipperState state = FlipperState.NONE;
|
||||
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) {
|
||||
itemname = name;
|
||||
|
@ -42,13 +42,13 @@ public class Flipper {
|
|||
|
||||
public void sellItem() {
|
||||
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();
|
||||
Utils.sendServerMessage("/hub");
|
||||
state = FlipperState.WALKING_TO_FIRST_POINT;
|
||||
}
|
||||
|
||||
public static void switchStates() {
|
||||
public void switchStates() {
|
||||
switch (state) {
|
||||
case WALKING_TO_FIRST_POINT:
|
||||
if (PlayerUtils.mc.currentScreen != null) {
|
||||
|
@ -99,7 +99,7 @@ public class Flipper {
|
|||
if (InventoryUtils.getSlotForItem(itemname) == -1) {
|
||||
Utils.sendMessage("Cannot find item in inventory, stopping flipper");
|
||||
state = FlipperState.NONE;
|
||||
Lilase.auctionHouse.open = true;
|
||||
Lilase.auctionHouse.setOpen(true);
|
||||
return;
|
||||
}
|
||||
InventoryUtils.clickOpenContainerSlot(InventoryUtils.getSlotForItem(itemname));
|
||||
|
@ -125,7 +125,10 @@ public class Flipper {
|
|||
buyWait.schedule(1000);
|
||||
} else if (InventoryUtils.inventoryNameContains("BIN Auction View") && buyWait.passed()) {
|
||||
InventoryUtils.clickOpenContainerSlot(49);
|
||||
Lilase.auctionHouse.incrementAuctionsSniped();
|
||||
buyWait.schedule(500);
|
||||
PlayerUtils.mc.thePlayer.closeScreen();
|
||||
buyWait.schedule(500);
|
||||
Utils.sendMessage("Posted item on Auction House, continue sniping now");
|
||||
state = FlipperState.NONE;
|
||||
Lilase.auctionHouse.toggleAuction();
|
||||
|
@ -158,15 +161,15 @@ public class Flipper {
|
|||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
private static Entity getAuctionMaster() {
|
||||
private Entity getAuctionMaster() {
|
||||
for (final Entity e : PlayerUtils.mc.theWorld.loadedEntityList) {
|
||||
if (e instanceof EntityArmorStand) {
|
||||
final String name = StringUtils.stripControlCodes(e.getDisplayName().getUnformattedText());
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"package": "me.night0721.lilase.mixins",
|
||||
"refmap": "mixins.night0721.refmap.json",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"minVersion": "0.8.2",
|
||||
"mixins": [
|
||||
"MixinNetworkManager"
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue