Code Optimization
This commit is contained in:
parent
daa4973cac
commit
07f1875210
9 changed files with 107 additions and 92 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
@file:Suppress("UnstableApiUsage", "UnstableApiUsage", "UnstableApiUsage", "UnstableApiUsage")
|
||||||
|
|
||||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
import gg.essential.gradle.util.noServerRunConfigs
|
import gg.essential.gradle.util.noServerRunConfigs
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
|
|
||||||
@Cancelable
|
@Cancelable
|
||||||
public class PacketSentEvent extends Event {
|
public class PacketSentEvent extends Event {
|
||||||
public final Packet<?> packet;
|
private final Packet<?> packet;
|
||||||
|
|
||||||
public PacketSentEvent(Packet<?> packet) {
|
public PacketSentEvent(Packet<?> packet) {
|
||||||
this.packet = packet;
|
this.packet = packet;
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class SniperFlipperEvents {
|
||||||
private final Pattern boughtPattern = Pattern.compile("You purchased (\\w+(?:\\s+\\w+)*) for ([\\d,]+)\\s*(\\w+)!");
|
private final Pattern boughtPattern = Pattern.compile("You purchased (\\w+(?:\\s+\\w+)*) for ([\\d,]+)\\s*(\\w+)!");
|
||||||
private final Pattern boughtPattern2 = Pattern.compile("You claimed (.+?) from (.+?)'s auction!");
|
private final Pattern boughtPattern2 = Pattern.compile("You claimed (.+?) from (.+?)'s auction!");
|
||||||
private final Pattern boughtPattern3 = Pattern.compile("You (purchased|claimed)( (\\\\d+x))? ([^\\\\s]+(\\\\s+[^\\\\d,]+)*)((,| for) (\\\\d+,?)+ coins?(!)?)?");
|
private final Pattern boughtPattern3 = Pattern.compile("You (purchased|claimed)( (\\\\d+x))? ([^\\\\s]+(\\\\s+[^\\\\d,]+)*)((,| for) (\\\\d+,?)+ coins?(!)?)?");
|
||||||
public static List<String> postedNames = new ArrayList<>();
|
public static final List<String> postedNames = new ArrayList<>();
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onChat(ClientChatReceivedEvent event) throws InterruptedException {
|
public void onChat(ClientChatReceivedEvent event) throws InterruptedException {
|
||||||
|
@ -112,7 +112,7 @@ public class SniperFlipperEvents {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Runnable bazaarChilling = () -> {
|
private final Runnable bazaarChilling = () -> {
|
||||||
try {
|
try {
|
||||||
rotation.reset();
|
rotation.reset();
|
||||||
rotation.easeTo(103f, -11f, 1000);
|
rotation.easeTo(103f, -11f, 1000);
|
||||||
|
|
|
@ -107,31 +107,31 @@ public class AHConfig extends Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Slider(name = "Time per fetch (seconds)", min = 5, max = 15, step = 1, category = "Auction House", description = "Time between each fetch of the auction house, the faster the fetch, the more likely you will snipe the item")
|
@Slider(name = "Time per fetch (seconds)", min = 5, max = 15, step = 1, category = "Auction House", description = "Time between each fetch of the auction house, the faster the fetch, the more likely you will snipe the item")
|
||||||
public static int AUCTION_HOUSE_DELAY = 8;
|
public static final int AUCTION_HOUSE_DELAY = 8;
|
||||||
|
|
||||||
@Text(name = "Discord Webhook", placeholder = "URL", category = "Auction House", description = "Discord webhook to send messages to")
|
@Text(name = "Discord Webhook", placeholder = "URL", category = "Auction House", description = "Discord webhook to send messages to")
|
||||||
public static String WEBHOOK = "";
|
public static final String WEBHOOK = "";
|
||||||
|
|
||||||
@Switch(name = "Send message to webhook", category = "Auction House", description = "Send a message to the webhook when an item is bought")
|
@Switch(name = "Send message to webhook", category = "Auction House", description = "Send a message to the webhook when an item is bought")
|
||||||
public static boolean SEND_MESSAGE = true;
|
public static final boolean SEND_MESSAGE = true;
|
||||||
|
|
||||||
@Number(name = "Reconnect Delay", min = 5, max = 20, category = "Auction House", description = "Delay between each reconnect attempt to the server")
|
@Number(name = "Reconnect Delay", min = 5, max = 20, category = "Auction House", description = "Delay between each reconnect attempt to the server")
|
||||||
public static int RECONNECT_DELAY = 20;
|
public static final int RECONNECT_DELAY = 20;
|
||||||
|
|
||||||
@Switch(name = "Check Profit Percentage Before Buying", category = "Flipper", description = "Check the profit percentage before buying the item, if the profit percentage is too low, it will not buy the item")
|
@Switch(name = "Check Profit Percentage Before Buying", category = "Flipper", description = "Check the profit percentage before buying the item, if the profit percentage is too low, it will not buy the item")
|
||||||
public static boolean CHECK_PERCENTAGE = false;
|
public static final boolean CHECK_PERCENTAGE = false;
|
||||||
|
|
||||||
@Number(name = "ProfitPercentage", min = 100, max = 5000, step = 50, category = "Flipper", description = "Profit percentage to check before buying the item, if the profit percentage is too low, it will not buy the item")
|
@Number(name = "ProfitPercentage", min = 100, max = 5000, step = 50, category = "Flipper", description = "Profit percentage to check before buying the item, if the profit percentage is too low, it will not buy the item")
|
||||||
public static int PROFIT_PERCENTAGE = 400;
|
public static final int PROFIT_PERCENTAGE = 400;
|
||||||
|
|
||||||
@Switch(name = "Bed Spam & Skip Confirm", category = "Auction House", description = "Spam the bed to buy the item just after the grace period ends and skips the confirmation of buying the item")
|
@Switch(name = "Bed Spam & Skip Confirm", category = "Auction House", description = "Spam the bed to buy the item just after the grace period ends and skips the confirmation of buying the item")
|
||||||
public static boolean BED_SPAM = true;
|
public static final boolean BED_SPAM = true;
|
||||||
|
|
||||||
@Checkbox(name = "GUI", category = "GUI", description = "Enable the GUI")
|
@Checkbox(name = "GUI", category = "GUI", description = "Enable the GUI")
|
||||||
public static boolean GUI = true;
|
public static final boolean GUI = true;
|
||||||
|
|
||||||
@Color(name = "GUI_COLOR", category = "GUI")
|
@Color(name = "GUI_COLOR", category = "GUI")
|
||||||
public static OneColor GUI_COLOR = new OneColor(0, 49, 83);
|
public static final OneColor GUI_COLOR = new OneColor(0, 49, 83);
|
||||||
|
|
||||||
@Button(name = "Add Item", text = "Click to add an item to snipe", category = "Auction House")
|
@Button(name = "Add Item", text = "Click to add an item to snipe", category = "Auction House")
|
||||||
public static void addItem() {
|
public static void addItem() {
|
||||||
|
@ -142,123 +142,123 @@ public class AHConfig extends Config {
|
||||||
public static int value = 0;
|
public static int value = 0;
|
||||||
|
|
||||||
@Text(name = "Item 1 Name", placeholder = "Item Name")
|
@Text(name = "Item 1 Name", placeholder = "Item Name")
|
||||||
public static String ITEM_1_NAME = " ";
|
public static final String ITEM_1_NAME = " ";
|
||||||
|
|
||||||
@Text(name = "Item 1 Type", placeholder = "Item Type")
|
@Text(name = "Item 1 Type", placeholder = "Item Type")
|
||||||
public static String ITEM_1_TYPE = "ANY";
|
public static final String ITEM_1_TYPE = "ANY";
|
||||||
|
|
||||||
@Number(name = "Item 1 Price", min = 1, max = 1000000000)
|
@Number(name = "Item 1 Price", min = 1, max = 1000000000)
|
||||||
public static int ITEM_1_PRICE = 1;
|
public static final int ITEM_1_PRICE = 1;
|
||||||
|
|
||||||
@Text(name = "Item 1 Tier", placeholder = "Item Tier")
|
@Text(name = "Item 1 Tier", placeholder = "Item Tier")
|
||||||
public static String ITEM_1_TIER = "ANY";
|
public static final String ITEM_1_TIER = "ANY";
|
||||||
|
|
||||||
@Text(name = "Item 2 Name", placeholder = "Item Name")
|
@Text(name = "Item 2 Name", placeholder = "Item Name")
|
||||||
public static String ITEM_2_NAME = " ";
|
public static final String ITEM_2_NAME = " ";
|
||||||
|
|
||||||
@Text(name = "Item 2 Type", placeholder = "Item Type")
|
@Text(name = "Item 2 Type", placeholder = "Item Type")
|
||||||
public static String ITEM_2_TYPE = "ANY";
|
public static final String ITEM_2_TYPE = "ANY";
|
||||||
|
|
||||||
@Number(name = "Item 2 Price", min = 1, max = 1000000000)
|
@Number(name = "Item 2 Price", min = 1, max = 1000000000)
|
||||||
public static int ITEM_2_PRICE = 1;
|
public static final int ITEM_2_PRICE = 1;
|
||||||
|
|
||||||
@Text(name = "Item 2 Tier", placeholder = "Item Tier")
|
@Text(name = "Item 2 Tier", placeholder = "Item Tier")
|
||||||
public static String ITEM_2_TIER = "ANY";
|
public static final String ITEM_2_TIER = "ANY";
|
||||||
|
|
||||||
@Text(name = "Item 3 Name", placeholder = "Item Name")
|
@Text(name = "Item 3 Name", placeholder = "Item Name")
|
||||||
public static String ITEM_3_NAME = " ";
|
public static final String ITEM_3_NAME = " ";
|
||||||
|
|
||||||
@Text(name = "Item 3 Type", placeholder = "Item Type")
|
@Text(name = "Item 3 Type", placeholder = "Item Type")
|
||||||
public static String ITEM_3_TYPE = "ANY";
|
public static final String ITEM_3_TYPE = "ANY";
|
||||||
|
|
||||||
@Number(name = "Item 3 Price", min = 1, max = 1000000000)
|
@Number(name = "Item 3 Price", min = 1, max = 1000000000)
|
||||||
public static int ITEM_3_PRICE = 1;
|
public static final int ITEM_3_PRICE = 1;
|
||||||
|
|
||||||
@Text(name = "Item 3 Tier", placeholder = "Item Tier")
|
@Text(name = "Item 3 Tier", placeholder = "Item Tier")
|
||||||
public static String ITEM_3_TIER = "ANY";
|
public static final String ITEM_3_TIER = "ANY";
|
||||||
|
|
||||||
@Text(name = "Item 4 Name", placeholder = "Item Name")
|
@Text(name = "Item 4 Name", placeholder = "Item Name")
|
||||||
public static String ITEM_4_NAME = " ";
|
public static final String ITEM_4_NAME = " ";
|
||||||
|
|
||||||
@Text(name = "Item 4 Type", placeholder = "Item Type")
|
@Text(name = "Item 4 Type", placeholder = "Item Type")
|
||||||
public static String ITEM_4_TYPE = "ANY";
|
public static final String ITEM_4_TYPE = "ANY";
|
||||||
|
|
||||||
@Number(name = "Item 4 Price", min = 1, max = 1000000000)
|
@Number(name = "Item 4 Price", min = 1, max = 1000000000)
|
||||||
public static int ITEM_4_PRICE = 1;
|
public static final int ITEM_4_PRICE = 1;
|
||||||
|
|
||||||
@Text(name = "Item 4 Tier", placeholder = "Item Tier")
|
@Text(name = "Item 4 Tier", placeholder = "Item Tier")
|
||||||
public static String ITEM_4_TIER = "ANY";
|
public static final String ITEM_4_TIER = "ANY";
|
||||||
|
|
||||||
@Text(name = "Item 5 Name", placeholder = "Item Name")
|
@Text(name = "Item 5 Name", placeholder = "Item Name")
|
||||||
public static String ITEM_5_NAME = " ";
|
public static final String ITEM_5_NAME = " ";
|
||||||
|
|
||||||
@Text(name = "Item 5 Type", placeholder = "Item Type")
|
@Text(name = "Item 5 Type", placeholder = "Item Type")
|
||||||
public static String ITEM_5_TYPE = "ANY";
|
public static final String ITEM_5_TYPE = "ANY";
|
||||||
|
|
||||||
@Number(name = "Item 5 Price", min = 1, max = 1000000000)
|
@Number(name = "Item 5 Price", min = 1, max = 1000000000)
|
||||||
public static int ITEM_5_PRICE = 1;
|
public static final int ITEM_5_PRICE = 1;
|
||||||
|
|
||||||
@Text(name = "Item 5 Tier", placeholder = "Item Tier")
|
@Text(name = "Item 5 Tier", placeholder = "Item Tier")
|
||||||
public static String ITEM_5_TIER = "ANY";
|
public static final String ITEM_5_TIER = "ANY";
|
||||||
|
|
||||||
@Text(name = "Item 6 Name", placeholder = "Item Name")
|
@Text(name = "Item 6 Name", placeholder = "Item Name")
|
||||||
public static String ITEM_6_NAME = " ";
|
public static final String ITEM_6_NAME = " ";
|
||||||
|
|
||||||
@Text(name = "Item 6 Type", placeholder = "Item Type")
|
@Text(name = "Item 6 Type", placeholder = "Item Type")
|
||||||
public static String ITEM_6_TYPE = "ANY";
|
public static final String ITEM_6_TYPE = "ANY";
|
||||||
|
|
||||||
@Number(name = "Item 6 Price", min = 1, max = 1000000000)
|
@Number(name = "Item 6 Price", min = 1, max = 1000000000)
|
||||||
public static int ITEM_6_PRICE = 1;
|
public static final int ITEM_6_PRICE = 1;
|
||||||
|
|
||||||
@Text(name = "Item 6 Tier", placeholder = "Item Tier")
|
@Text(name = "Item 6 Tier", placeholder = "Item Tier")
|
||||||
public static String ITEM_6_TIER = "ANY";
|
public static final String ITEM_6_TIER = "ANY";
|
||||||
|
|
||||||
@Text(name = "Item 7 Name", placeholder = "Item Name")
|
@Text(name = "Item 7 Name", placeholder = "Item Name")
|
||||||
public static String ITEM_7_NAME = " ";
|
public static final String ITEM_7_NAME = " ";
|
||||||
|
|
||||||
@Text(name = "Item 7 Type", placeholder = "Item Type")
|
@Text(name = "Item 7 Type", placeholder = "Item Type")
|
||||||
public static String ITEM_7_TYPE = "ANY";
|
public static final String ITEM_7_TYPE = "ANY";
|
||||||
|
|
||||||
@Number(name = "Item 7 Price", min = 1, max = 1000000000)
|
@Number(name = "Item 7 Price", min = 1, max = 1000000000)
|
||||||
public static int ITEM_7_PRICE = 1;
|
public static final int ITEM_7_PRICE = 1;
|
||||||
|
|
||||||
@Text(name = "Item 7 Tier", placeholder = "Item Tier")
|
@Text(name = "Item 7 Tier", placeholder = "Item Tier")
|
||||||
public static String ITEM_7_TIER = "ANY";
|
public static final String ITEM_7_TIER = "ANY";
|
||||||
|
|
||||||
@Text(name = "Item 8 Name", placeholder = "Item Name")
|
@Text(name = "Item 8 Name", placeholder = "Item Name")
|
||||||
public static String ITEM_8_NAME = " ";
|
public static final String ITEM_8_NAME = " ";
|
||||||
|
|
||||||
@Text(name = "Item 8 Type", placeholder = "Item Type")
|
@Text(name = "Item 8 Type", placeholder = "Item Type")
|
||||||
public static String ITEM_8_TYPE = "ANY";
|
public static final String ITEM_8_TYPE = "ANY";
|
||||||
|
|
||||||
@Number(name = "Item 8 Price", min = 1, max = 1000000000)
|
@Number(name = "Item 8 Price", min = 1, max = 1000000000)
|
||||||
public static int ITEM_8_PRICE = 1;
|
public static final int ITEM_8_PRICE = 1;
|
||||||
|
|
||||||
@Text(name = "Item 8 Tier", placeholder = "Item Tier")
|
@Text(name = "Item 8 Tier", placeholder = "Item Tier")
|
||||||
public static String ITEM_8_TIER = "ANY";
|
public static final String ITEM_8_TIER = "ANY";
|
||||||
|
|
||||||
@Text(name = "Item 9 Name", placeholder = "Item Name")
|
@Text(name = "Item 9 Name", placeholder = "Item Name")
|
||||||
public static String ITEM_9_NAME = " ";
|
public static final String ITEM_9_NAME = " ";
|
||||||
|
|
||||||
@Text(name = "Item 9 Type", placeholder = "Item Type")
|
@Text(name = "Item 9 Type", placeholder = "Item Type")
|
||||||
public static String ITEM_9_TYPE = "ANY";
|
public static final String ITEM_9_TYPE = "ANY";
|
||||||
|
|
||||||
@Number(name = "Item 9 Price", min = 1, max = 1000000000)
|
@Number(name = "Item 9 Price", min = 1, max = 1000000000)
|
||||||
public static int ITEM_9_PRICE = 1;
|
public static final int ITEM_9_PRICE = 1;
|
||||||
|
|
||||||
@Text(name = "Item 9 Tier", placeholder = "Item Tier")
|
@Text(name = "Item 9 Tier", placeholder = "Item Tier")
|
||||||
public static String ITEM_9_TIER = "ANY";
|
public static final String ITEM_9_TIER = "ANY";
|
||||||
|
|
||||||
@Text(name = "Item 10 Name", placeholder = "Item Name")
|
@Text(name = "Item 10 Name", placeholder = "Item Name")
|
||||||
public static String ITEM_10_NAME = " ";
|
public static final String ITEM_10_NAME = " ";
|
||||||
|
|
||||||
@Text(name = "Item 10 Type", placeholder = "Item Type")
|
@Text(name = "Item 10 Type", placeholder = "Item Type")
|
||||||
public static String ITEM_10_TYPE = "ANY";
|
public static final String ITEM_10_TYPE = "ANY";
|
||||||
|
|
||||||
@Number(name = "Item 10 Price", min = 1, max = 1000000000)
|
@Number(name = "Item 10 Price", min = 1, max = 1000000000)
|
||||||
public static int ITEM_10_PRICE = 1;
|
public static final int ITEM_10_PRICE = 1;
|
||||||
|
|
||||||
@Text(name = "Item 10 Tier", placeholder = "Item Tier")
|
@Text(name = "Item 10 Tier", placeholder = "Item Tier")
|
||||||
public static String ITEM_10_TIER = "ANY";
|
public static final String ITEM_10_TIER = "ANY";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,15 @@ import java.util.Locale;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static me.night0721.lilase.features.ah.AHConfig.SEND_MESSAGE;
|
||||||
|
|
||||||
public class AuctionHouse {
|
public class AuctionHouse {
|
||||||
private Boolean open = false;
|
private Boolean open = false;
|
||||||
public Boolean buying = false;
|
public Boolean buying = false;
|
||||||
private int auctionsSniped = 0;
|
private int auctionsSniped = 0;
|
||||||
private int auctionsPosted = 0;
|
private int auctionsPosted = 0;
|
||||||
private int auctionsFlipped = 0;
|
private int auctionsFlipped = 0;
|
||||||
public DiscordWebhook webhook = new DiscordWebhook(ConfigUtils.getString("main", "Webhook"));
|
public final DiscordWebhook webhook = new DiscordWebhook(ConfigUtils.getString("main", "Webhook"));
|
||||||
private final List<Item> items = new ArrayList<>();
|
private final List<Item> items = new ArrayList<>();
|
||||||
private final List<Item> blacklist = new ArrayList<>();
|
private final List<Item> blacklist = new ArrayList<>();
|
||||||
private final List<String> posted = new ArrayList<>();
|
private final List<String> posted = new ArrayList<>();
|
||||||
|
@ -41,12 +43,19 @@ public class AuctionHouse {
|
||||||
|
|
||||||
public AuctionHouse() {
|
public AuctionHouse() {
|
||||||
for (int i = 1; i <= 99; i++) {
|
for (int i = 1; i <= 99; i++) {
|
||||||
if (!ConfigUtils.getString("item" + i, "Name").equals("") && !ConfigUtils.getString("item" + i, "Type").equals("") && !ConfigUtils.getString("item" + i, "Tier").equals("") && ConfigUtils.getInt("item" + i, "Price") != 0)
|
if (!ConfigUtils.getString("item" + i, "Name").equals("") && !ConfigUtils.getString("item" + i, "Type").equals("") && !ConfigUtils.getString("item" + i, "Tier").equals("") && ConfigUtils.getInt("item" + i, "Price") != 0){
|
||||||
|
try {
|
||||||
|
ItemType.valueOf(ConfigUtils.getString("item" + i, "Type"));
|
||||||
|
ItemType.valueOf(ConfigUtils.getString("item" + i, "Tier"));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
System.out.println("Invalid item type for item " + i + ", please check your config");
|
||||||
|
}
|
||||||
items.add(new Item(ConfigUtils.getString("item" + i, "Name"), ItemType.valueOf(ConfigUtils.getString("item" + i, "Type")), ConfigUtils.getInt("item" + i, "Price"), ItemTier.valueOf(ConfigUtils.getString("item" + i, "Tier"))));
|
items.add(new Item(ConfigUtils.getString("item" + i, "Name"), ItemType.valueOf(ConfigUtils.getString("item" + i, "Type")), ConfigUtils.getInt("item" + i, "Price"), ItemTier.valueOf(ConfigUtils.getString("item" + i, "Tier"))));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (int i = 1; i <= 99; i++) {
|
for (int i = 1; i <= 99; i++) {
|
||||||
if (!ConfigUtils.getString("blacklist" + i, "Name").equals("") && !ConfigUtils.getString("blacklist" + i, "Type").equals("") && !ConfigUtils.getString("blacklist" + i, "Tier").equals("") && ConfigUtils.getInt("blacklist" + i, "Price") != 0)
|
if (!ConfigUtils.getString("blacklist" + i, "Name").equals(""))
|
||||||
blacklist.add(new Item(ConfigUtils.getString("blacklist" + i, "Name"), ItemType.valueOf(ConfigUtils.getString("blacklist" + i, "Type")), ConfigUtils.getInt("blacklist" + i, "Price"), ItemTier.valueOf(ConfigUtils.getString("blacklist" + i, "Tier"))));
|
blacklist.add(new Item(ConfigUtils.getString("blacklist" + i, "Name"), null, null, null));
|
||||||
}
|
}
|
||||||
webhook.setUsername("Lilase - Auction House");
|
webhook.setUsername("Lilase - Auction House");
|
||||||
webhook.setAvatarUrl("https://th.bing.com/th/id/OIP.Lk2cSujieY70GbsgPZ0TyAHaEK?w=325&h=182&c=7&r=0&o=5&pid=1.7");
|
webhook.setAvatarUrl("https://th.bing.com/th/id/OIP.Lk2cSujieY70GbsgPZ0TyAHaEK?w=325&h=182&c=7&r=0&o=5&pid=1.7");
|
||||||
|
@ -85,7 +94,12 @@ public class AuctionHouse {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ConfigUtils.getString("main", "APIKey").equals("") || ConfigUtils.getString("main", "Webhook").equals("")) {
|
if (ConfigUtils.getString("main", "APIKey").equals("") || ConfigUtils.getString("main", "Webhook").equals("")) {
|
||||||
Utils.sendMessage("Missing APIKey or Webhook, stopping");
|
Utils.sendMessage("Missing APIKey, stopping");
|
||||||
|
open = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (SEND_MESSAGE && ConfigUtils.getString("main", "Webhook").equals("")) {
|
||||||
|
Utils.sendMessage("Sending message to Webhook is on but Webhook is missing, stopping");
|
||||||
open = false;
|
open = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +118,10 @@ public class AuctionHouse {
|
||||||
connection.setConnectTimeout(5000);
|
connection.setConnectTimeout(5000);
|
||||||
connection.setReadTimeout(5000);
|
connection.setReadTimeout(5000);
|
||||||
int status = connection.getResponseCode();
|
int status = connection.getResponseCode();
|
||||||
if (status != 200) return;
|
if (status != 200) {
|
||||||
|
Utils.sendMessage("Error getting data from Hypixel API, either API down or internal error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
String inputLine;
|
String inputLine;
|
||||||
StringBuilder content = new StringBuilder();
|
StringBuilder content = new StringBuilder();
|
||||||
|
|
|
@ -32,6 +32,6 @@ public class TextRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawCenteredString(String text, int x, int y, double scale) {
|
public void drawCenteredString(String text, int x, int y, double scale) {
|
||||||
drawString(text, x - Minecraft.getMinecraft().fontRendererObj.getStringWidth(text) / 2, y - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT / 2, 1);
|
drawString(text, x - Minecraft.getMinecraft().fontRendererObj.getStringWidth(text) / 2, y - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT / 2, scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -21,26 +21,26 @@ public class ConfigUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reloadConfig() {
|
public static void reloadConfig() {
|
||||||
if (!hasKey("main", "APIKey")) writeStringConfig("main", "APIKey", "");
|
if (hasNoKey("main", "APIKey")) writeStringConfig("main", "APIKey", "");
|
||||||
if (!hasKey("main", "SendMessageToWebhook")) writeBooleanConfig("main", "SendMessageToWebhook", true);
|
if (hasNoKey("main", "SendMessageToWebhook")) writeBooleanConfig("main", "SendMessageToWebhook", true);
|
||||||
if (!hasKey("main", "Webhook")) writeStringConfig("main", "Webhook", "");
|
if (hasNoKey("main", "Webhook")) writeStringConfig("main", "Webhook", "");
|
||||||
if (!hasKey("main", "ReconnectDelay")) writeIntConfig("main", "ReconnectDelay", 20);
|
if (hasNoKey("main", "ReconnectDelay")) writeIntConfig("main", "ReconnectDelay", 20);
|
||||||
if (!hasKey("main", "AuctionHouseDelay")) writeIntConfig("main", "AuctionHouseDelay", 8);
|
if (hasNoKey("main", "AuctionHouseDelay")) writeIntConfig("main", "AuctionHouseDelay", 8);
|
||||||
if (!hasKey("main", "checkProfitPercentageBeforeBuy")) writeBooleanConfig("main", "checkProfitPercentageBeforeBuy", false);
|
if (hasNoKey("main", "checkProfitPercentageBeforeBuy")) writeBooleanConfig("main", "checkProfitPercentageBeforeBuy", false);
|
||||||
if (!hasKey("main", "ProfitPercentage")) writeIntConfig("main", "ProfitPercentage", 400); //400%
|
if (hasNoKey("main", "ProfitPercentage")) writeIntConfig("main", "ProfitPercentage", 400); //400%
|
||||||
if (!hasKey("main", "GUI")) writeBooleanConfig("main", "GUI", true);
|
if (hasNoKey("main", "GUI")) writeBooleanConfig("main", "GUI", true);
|
||||||
if (!hasKey("main", "GUI_COLOR")) writeIntConfig("main", "GUI_COLOR", 0x003153);
|
if (hasNoKey("main", "GUI_COLOR")) writeIntConfig("main", "GUI_COLOR", 0x003153);
|
||||||
for (int i = 1; i <= 3; i++) {
|
for (int i = 1; i <= 3; i++) {
|
||||||
if (!hasKey("item" + i, "Name")) writeStringConfig("item" + i, "Name", "");
|
if (hasNoKey("item" + i, "Name")) writeStringConfig("item" + i, "Name", "");
|
||||||
if (!hasKey("item" + i, "Type")) writeStringConfig("item" + i, "Type", "");
|
if (hasNoKey("item" + i, "Type")) writeStringConfig("item" + i, "Type", "");
|
||||||
if (!hasKey("item" + i, "Price")) writeIntConfig("item" + i, "Price", 0);
|
if (hasNoKey("item" + i, "Price")) writeIntConfig("item" + i, "Price", 0);
|
||||||
if (!hasKey("item" + i, "Tier")) writeStringConfig("item" + i, "Tier", "");
|
if (hasNoKey("item" + i, "Tier")) writeStringConfig("item" + i, "Tier", "");
|
||||||
}
|
}
|
||||||
for (int i = 1; i <= 3; i++) {
|
for (int i = 1; i <= 3; i++) {
|
||||||
if (!hasKey("blacklist" + i, "Name")) writeStringConfig("blacklist" + i, "Name", "");
|
if (hasNoKey("blacklist" + i, "Name")) writeStringConfig("blacklist" + i, "Name", "");
|
||||||
if (!hasKey("blacklist" + i, "Type")) writeStringConfig("blacklist" + i, "Type", "");
|
if (hasNoKey("blacklist" + i, "Type")) writeStringConfig("blacklist" + i, "Type", "");
|
||||||
if (!hasKey("blacklist" + i, "Price")) writeIntConfig("blacklist" + i, "Price", 0);
|
if (hasNoKey("blacklist" + i, "Price")) writeIntConfig("blacklist" + i, "Price", 0);
|
||||||
if (!hasKey("blacklist" + i, "Tier")) writeStringConfig("blacklist" + i, "Tier", "");
|
if (hasNoKey("blacklist" + i, "Tier")) writeStringConfig("blacklist" + i, "Tier", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ public class ConfigUtils {
|
||||||
config = new Configuration(new File(file));
|
config = new Configuration(new File(file));
|
||||||
try {
|
try {
|
||||||
config.load();
|
config.load();
|
||||||
int set = config.get(category, key, value).getInt();
|
// int set = config.get(category, key, value).getInt();
|
||||||
config.getCategory(category).get(key).set(value);
|
config.getCategory(category).get(key).set(value);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -139,7 +139,7 @@ public class ConfigUtils {
|
||||||
config = new Configuration(new File(file));
|
config = new Configuration(new File(file));
|
||||||
try {
|
try {
|
||||||
config.load();
|
config.load();
|
||||||
double set = config.get(category, key, value).getDouble();
|
// double set = config.get(category, key, value).getDouble();
|
||||||
config.getCategory(category).get(key).set(value);
|
config.getCategory(category).get(key).set(value);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -153,7 +153,7 @@ public class ConfigUtils {
|
||||||
config = new Configuration(new File(file));
|
config = new Configuration(new File(file));
|
||||||
try {
|
try {
|
||||||
config.load();
|
config.load();
|
||||||
String set = config.get(category, key, value).getString();
|
// String set = config.get(category, key, value).getString();
|
||||||
config.getCategory(category).get(key).set(value);
|
config.getCategory(category).get(key).set(value);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -167,7 +167,7 @@ public class ConfigUtils {
|
||||||
config = new Configuration(new File(file));
|
config = new Configuration(new File(file));
|
||||||
try {
|
try {
|
||||||
config.load();
|
config.load();
|
||||||
boolean set = config.get(category, key, value).getBoolean();
|
// boolean set = config.get(category, key, value).getBoolean();
|
||||||
config.getCategory(category).get(key).set(value);
|
config.getCategory(category).get(key).set(value);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -176,19 +176,19 @@ public class ConfigUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasKey(String category, String key) {
|
public static boolean hasNoKey(String category, String key) {
|
||||||
category = category.toLowerCase();
|
category = category.toLowerCase();
|
||||||
config = new Configuration(new File(file));
|
config = new Configuration(new File(file));
|
||||||
try {
|
try {
|
||||||
config.load();
|
config.load();
|
||||||
if (!config.hasCategory(category)) return false;
|
if (!config.hasCategory(category)) return true;
|
||||||
return config.getCategory(category).containsKey(key);
|
return !config.getCategory(category).containsKey(key);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteCategory(String category) {
|
public static void deleteCategory(String category) {
|
||||||
|
|
|
@ -18,10 +18,6 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
||||||
public class InventoryUtils {
|
public class InventoryUtils {
|
||||||
static int opened = 0;
|
|
||||||
/*
|
|
||||||
* @Author Mostly Apfelsaft
|
|
||||||
*/
|
|
||||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,7 +150,7 @@ public class InventoryUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ItemStack> getInventoryStacks() {
|
public static List<ItemStack> getInventoryStacks() {
|
||||||
final List<ItemStack> ret = new ArrayList<ItemStack>();
|
final List<ItemStack> ret = new ArrayList<>();
|
||||||
for (int i = 9; i < 44; ++i) {
|
for (int i = 9; i < 44; ++i) {
|
||||||
final Slot slot = InventoryUtils.mc.thePlayer.inventoryContainer.getSlot(i);
|
final Slot slot = InventoryUtils.mc.thePlayer.inventoryContainer.getSlot(i);
|
||||||
if (slot != null) {
|
if (slot != null) {
|
||||||
|
|
|
@ -11,9 +11,9 @@ public class Rotation {
|
||||||
private long startTime;
|
private long startTime;
|
||||||
private long endTime;
|
private long endTime;
|
||||||
|
|
||||||
MutablePair<Float, Float> start = new MutablePair<>(0f, 0f);
|
final MutablePair<Float, Float> start = new MutablePair<>(0f, 0f);
|
||||||
MutablePair<Float, Float> target = new MutablePair<>(0f, 0f);
|
final MutablePair<Float, Float> target = new MutablePair<>(0f, 0f);
|
||||||
MutablePair<Float, Float> difference = new MutablePair<>(0f, 0f);
|
final MutablePair<Float, Float> difference = new MutablePair<>(0f, 0f);
|
||||||
|
|
||||||
public void easeTo(float yaw, float pitch, long time) {
|
public void easeTo(float yaw, float pitch, long time) {
|
||||||
completed = false;
|
completed = false;
|
||||||
|
|
Loading…
Reference in a new issue