mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 09:11:32 +01:00
(feat) saving/loading of custom crosshairs
This commit is contained in:
parent
a87875e565
commit
74696f8580
@ -13,6 +13,7 @@ import net.silentclient.client.utils.MenuBlurUtils;
|
|||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@ -190,6 +191,11 @@ public final class ConfigManager {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(set.isCellGrid()) {
|
||||||
|
try {
|
||||||
|
set.setCells(stringToBooleanArray(args[3]));
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}
|
||||||
if (set.isCombo()) {
|
if (set.isCombo()) {
|
||||||
try {
|
try {
|
||||||
if(set.getOptions().contains(args[3])) {
|
if(set.getOptions().contains(args[3])) {
|
||||||
@ -247,6 +253,32 @@ public final class ConfigManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String booleanArrayToString(boolean[][] cells) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (boolean[] row : cells) {
|
||||||
|
for (boolean cell : row) {
|
||||||
|
sb.append(cell ? '1' : '0');
|
||||||
|
}
|
||||||
|
sb.append('/');
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean[][] stringToBooleanArray(String input) {
|
||||||
|
String[] rows = input.trim().split("/");
|
||||||
|
int numRows = rows.length;
|
||||||
|
int numCols = rows[0].length();
|
||||||
|
boolean[][] result = new boolean[numRows][numCols];
|
||||||
|
|
||||||
|
for (int i = 0; i < numRows; i++) {
|
||||||
|
for (int j = 0; j < numCols; j++) {
|
||||||
|
result[i][j] = rows[i].charAt(j) == '1';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
Client.logger.info("Saving Config: " + this.configFile.getName());
|
Client.logger.info("Saving Config: " + this.configFile.getName());
|
||||||
try(PrintWriter writer = new PrintWriter(this.configFile)) {
|
try(PrintWriter writer = new PrintWriter(this.configFile)) {
|
||||||
@ -277,6 +309,9 @@ public final class ConfigManager {
|
|||||||
if(set.isKeybind()) {
|
if(set.isKeybind()) {
|
||||||
writer.println("SET:" + set.getName() + ":" + set.getParentMod().getName() + ":" + set.getKeybind());
|
writer.println("SET:" + set.getName() + ":" + set.getParentMod().getName() + ":" + set.getKeybind());
|
||||||
}
|
}
|
||||||
|
if(set.isCellGrid()) {
|
||||||
|
writer.println("SET:" + set.getName() + ":" + set.getParentMod().getName() + ":" + booleanArrayToString(set.getCells()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(AutoTextCommand command : Client.getInstance().getModInstances().getAutoText().getCommands()) {
|
for(AutoTextCommand command : Client.getInstance().getModInstances().getAutoText().getCommands()) {
|
||||||
|
@ -159,6 +159,10 @@ public class Setting implements Comparable<Setting> {
|
|||||||
return this.sval;
|
return this.sval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCells(boolean[][] cells) {
|
||||||
|
this.cells = cells;
|
||||||
|
}
|
||||||
|
|
||||||
public void setValString(String in) {
|
public void setValString(String in) {
|
||||||
if(onlyPremiumPlus) {
|
if(onlyPremiumPlus) {
|
||||||
if(Client.getInstance().getAccount() != null && Client.getInstance().getAccount().isPremiumPlus()) {
|
if(Client.getInstance().getAccount() != null && Client.getInstance().getAccount().isPremiumPlus()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user