Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45afa7182d | ||
|
|
35fbb8da8d | ||
|
|
aca66990b0 | ||
|
|
cd510e98de | ||
|
|
c071727d02 | ||
|
|
9cd3c053fd | ||
|
|
83aa263d01 |
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
||||
46
README.md
46
README.md
@@ -1,2 +1,44 @@
|
||||
# Countroll
|
||||
A java program to make counting bots a bit more interesting
|
||||
|
||||
# Countroll - Description
|
||||
|
||||
Countroll is designed to make using counting bots a bit more interesting. It turns integers into complex, unreadable
|
||||
mathematical expressions, perfect for showing off your mathematical knowledge to you friends!
|
||||
Countroll uses the following operators to make your integer as complex as possible
|
||||
|
||||
- Addition | +
|
||||
- Subtraction | +
|
||||
- Multiplication | *
|
||||
- Division | /
|
||||
- Square Root | sqrt()
|
||||
- Exponentiation | ^
|
||||
|
||||
## Compatibility
|
||||
|
||||
Countroll is currently only compatible with [Numselli's counting bot](https://counting.numselli.xyz/), although I hope to be able to support more counting bots soon!
|
||||
|
||||
## Usage
|
||||
|
||||
1. Compile the Java program from the source, or download a Precompiled Jar
|
||||
2. Execute it through the command-line `java -jar Countroll-<version>.jar [args]`
|
||||
3. Enter a target integer. (Whole number ie: 1, 16, 4096)
|
||||
4. Copy the outputed expression and use it wherever you'd like!
|
||||
|
||||
## Arguments
|
||||
|
||||
There are multiple command line arguments you can use for ease of use
|
||||
|
||||
| Argument | Alias(es) | Description |
|
||||
|-----------|-----------|---------------------------------------------------|
|
||||
| --copy | -c | Automatically copies the output to your clipboard |
|
||||
| --verbose | -v | Enables verbose output for debugging |
|
||||
| --color | -rgb | Enables colored output for debug/it looks cool |
|
||||
| --deep | -d | Will run the Complexers on the Increaser values |
|
||||
| --help | --h, -h | Shows a message like this table |
|
||||
|
||||
# Compiling
|
||||
Make sure you have Java 17 or higher installed on your system!
|
||||
1. Clone the repo `$ git clone https://github.com/thetrouper/Countroll/`
|
||||
2. Change directory to the repo `$ cd Countroll`
|
||||
3. Build with gradle `$ ./gradlew build`
|
||||
4. Build will be output to `/Countroll/build/libs`
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'me.trouper'
|
||||
version '0.0.1'
|
||||
version '0.0.2'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
49
src/main/java/me/trouper/Data/MC2Ansi.java
Normal file
49
src/main/java/me/trouper/Data/MC2Ansi.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package me.trouper.Data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MC2Ansi {
|
||||
public static Map<String, String> getColors() {
|
||||
Map<String, String> minecraftToAnsi = new HashMap<>();
|
||||
minecraftToAnsi.put("<&0>", "\u001B[0;30m");
|
||||
minecraftToAnsi.put("<&1>", "\u001B[0;34m");
|
||||
minecraftToAnsi.put("<&2>", "\u001B[0;32m");
|
||||
minecraftToAnsi.put("<&3>", "\u001B[0;36m");
|
||||
minecraftToAnsi.put("<&4>", "\u001B[0;31m");
|
||||
minecraftToAnsi.put("<&5>", "\u001B[0;35m");
|
||||
minecraftToAnsi.put("<&6>", "\u001B[0;33m");
|
||||
minecraftToAnsi.put("<&7>", "\u001B[0;37m");
|
||||
minecraftToAnsi.put("<&8>", "\u001B[1;30m");
|
||||
minecraftToAnsi.put("<&9>", "\u001B[1;34m");
|
||||
minecraftToAnsi.put("<&a>", "\u001B[1;32m");
|
||||
minecraftToAnsi.put("<&b>", "\u001B[1;36m");
|
||||
minecraftToAnsi.put("<&c>", "\u001B[1;31m");
|
||||
minecraftToAnsi.put("<&d>", "\u001B[1;35m");
|
||||
minecraftToAnsi.put("<&e>", "\u001B[1;33m");
|
||||
minecraftToAnsi.put("<&f>", "\u001B[1;37m");
|
||||
minecraftToAnsi.put("<&r>", "\u001B[0m");
|
||||
return minecraftToAnsi;
|
||||
}
|
||||
public static Map<String, String> getBackgrounds() {
|
||||
Map<String, String> minecraftToAnsiBG = new HashMap<>();
|
||||
minecraftToAnsiBG.put("<&0h>", "\u001B[40m");
|
||||
minecraftToAnsiBG.put("<&1h>", "\u001B[44m");
|
||||
minecraftToAnsiBG.put("<&2h>", "\u001B[42m");
|
||||
minecraftToAnsiBG.put("<&3h>", "\u001B[46m");
|
||||
minecraftToAnsiBG.put("<&4h>", "\u001B[41m");
|
||||
minecraftToAnsiBG.put("<&5h>", "\u001B[45m");
|
||||
minecraftToAnsiBG.put("<&6h>", "\u001B[43m");
|
||||
minecraftToAnsiBG.put("<&7h>", "\u001B[47m");
|
||||
minecraftToAnsiBG.put("<&8h>", "\u001B[40;1m");
|
||||
minecraftToAnsiBG.put("<&9h>", "\u001B[44;1m");
|
||||
minecraftToAnsiBG.put("<&ah>", "\u001B[42;1m");
|
||||
minecraftToAnsiBG.put("<&bh>", "\u001B[46;1m");
|
||||
minecraftToAnsiBG.put("<&ch>", "\u001B[41;1m");
|
||||
minecraftToAnsiBG.put("<&dh>", "\u001B[45;1m");
|
||||
minecraftToAnsiBG.put("<&eh>", "\u001B[43;1m");
|
||||
minecraftToAnsiBG.put("<&fh>", "\u001B[47;1m");
|
||||
return minecraftToAnsiBG;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ public class Complexers {
|
||||
Random random = new Random();
|
||||
int factor = random.nextInt(9)+1;
|
||||
int doubled = i * factor;
|
||||
String result = "(" + doubled + "/" + factor + ")";
|
||||
String result = "<&f>(<&r><&e>" + doubled + "<&b>/<&r><&e>" + factor + "<&f>)<&r>";
|
||||
|
||||
if (eval(result) == i) {
|
||||
return result;
|
||||
@@ -17,24 +17,10 @@ public class Complexers {
|
||||
return "(" + i + ")";
|
||||
}
|
||||
|
||||
public static String multiply(int i, int factor) {
|
||||
String result = "(" + i + "*" + factor + ")";
|
||||
if (eval(result) == i * factor) {
|
||||
return result;
|
||||
}
|
||||
return "(" + i + ")";
|
||||
}
|
||||
public static String power(int i, int exp) {
|
||||
String result = "(" + i + "^" + exp + ")";
|
||||
if (eval(result) == Math.pow(i,exp)) {
|
||||
return result;
|
||||
}
|
||||
return "(" + i + ")";
|
||||
}
|
||||
|
||||
public static String root(int i) {
|
||||
int squared = (int) Math.pow(i,2);
|
||||
String result = "sqrt(" + squared + ")";
|
||||
String result = "<&9>sqrt<&r><&f>(<&r><&e>" + squared + "<&f>)<&r>";
|
||||
|
||||
if (eval(result) == i){
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package me.trouper.Functions;
|
||||
|
||||
import me.trouper.Utils.Utils;
|
||||
import net.objecthunter.exp4j.Expression;
|
||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||
|
||||
public class Eval {
|
||||
public static double eval(String expression) {
|
||||
Expression exp = new ExpressionBuilder(expression).build();
|
||||
final String cleaned = Utils.removeColors(expression);
|
||||
Utils.verbose("Evaluating Expression: " + cleaned);
|
||||
Expression exp = new ExpressionBuilder(cleaned).build();
|
||||
return exp.evaluate();
|
||||
}
|
||||
public static boolean isPerfectSquare(int num) {
|
||||
|
||||
22
src/main/java/me/trouper/Functions/Increasers.java
Normal file
22
src/main/java/me/trouper/Functions/Increasers.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package me.trouper.Functions;
|
||||
|
||||
import static me.trouper.Functions.Eval.eval;
|
||||
|
||||
public class Increasers {
|
||||
public static String multiply(int i, int factor) {
|
||||
String result = "<&7>(<&r><&2>" + i + "<&b>*<&r><&2>" + factor + "<&7>)<&r>";
|
||||
|
||||
if (eval(result) == i * factor) {
|
||||
return result;
|
||||
}
|
||||
return "(" + i + ")";
|
||||
}
|
||||
public static String power(int i, int exp) {
|
||||
String result = "<&7>(<&r><&2>" + i + "<&b>^<&r><&2>" + exp + "<&7>)<&r>";
|
||||
|
||||
if (eval(result) == Math.pow(i,exp)) {
|
||||
return result;
|
||||
}
|
||||
return "(" + i + ")";
|
||||
}
|
||||
}
|
||||
123
src/main/java/me/trouper/Functions/Obf.java
Normal file
123
src/main/java/me/trouper/Functions/Obf.java
Normal file
@@ -0,0 +1,123 @@
|
||||
package me.trouper.Functions;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static me.trouper.Functions.Eval.*;
|
||||
import static me.trouper.Functions.Eval.eval;
|
||||
import static me.trouper.Utils.Utils.removeColors;
|
||||
import static me.trouper.Utils.Utils.verbose;
|
||||
|
||||
public class Obf {
|
||||
public static String obfInt(int target, boolean deep) {
|
||||
if (deep) System.out.println("Deep Obfuscation is coming soon!");
|
||||
StringBuilder expression = new StringBuilder();
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
int initializer = random.nextInt(9)+1;
|
||||
verbose("Initializing Expression: " + initializer);
|
||||
expression.append("<&dh><&f>").append(initializer).append("<&r>");
|
||||
|
||||
int cubeCount = 0;
|
||||
int factorCount = 0;
|
||||
int addCount = 0;
|
||||
int subCount = 0;
|
||||
int rootCount = 0;
|
||||
int divideCount = 0;
|
||||
int perfectCount = 0;
|
||||
int total = 0;
|
||||
|
||||
while (eval(expression.toString()) != target) {
|
||||
total++;
|
||||
int eval = (int) eval(expression.toString());
|
||||
int ri = random.nextInt(9)+1;
|
||||
int op = random.nextInt(2);
|
||||
boolean mult = false;
|
||||
|
||||
if (!isInt(eval(expression.toString()))) {
|
||||
System.out.println("Something went horribly wrong, Here is the relevant info." +
|
||||
"\nEvaluation: " + eval(expression.toString()) +
|
||||
"\nRandom Pick: " + ri +
|
||||
"\nOperation: " + op +
|
||||
"\nCaught at: \n" + removeColors(expression.toString()));
|
||||
break;
|
||||
}
|
||||
|
||||
verbose("Random: " + ri);
|
||||
verbose("Current: " + eval(expression.toString()));
|
||||
|
||||
if (isPerfectSquare(eval) && eval != 1) {
|
||||
perfectCount++;
|
||||
verbose("PERFECT SQUARE TIME! (" + perfectCount+ ")");
|
||||
expression.insert(0,"<&eh><&b>sqrt(<&r>").append("<&eh><&b>)<&r>");
|
||||
eval = (int) eval(expression.toString());
|
||||
}
|
||||
if (target - eval > 4069) {
|
||||
mult = true;
|
||||
cubeCount++;
|
||||
verbose("Large than (" + cubeCount + ")");
|
||||
final String toAdd = Increasers.power(ri,3);
|
||||
expression.append("<&b>+<&r><&a>").append(toAdd).append("<&r>");
|
||||
} else if (target - eval > 1048) {
|
||||
mult = true;
|
||||
cubeCount++;
|
||||
verbose("Large than (" + cubeCount + ")");
|
||||
final String toAdd = Increasers.power(ri,2);
|
||||
expression.append("<&b>+<&r><&a>").append(toAdd).append("<&r>");
|
||||
} else if (target - eval > 128) {
|
||||
factorCount++;
|
||||
verbose("Big than (" + factorCount + ")");
|
||||
final String toAdd = Increasers.multiply(ri,9);
|
||||
expression.append("<&b>+<&r><&a>").append(toAdd).append("<&r>");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (eval < target) {
|
||||
addCount++;
|
||||
if (op == 0) {
|
||||
divideCount++;
|
||||
} else {
|
||||
rootCount++;
|
||||
}
|
||||
|
||||
final String toAdd = (op == 0) ? Complexers.divide(ri) : Complexers.root(ri);
|
||||
|
||||
expression.append((mult) ? "<&b>*<&r>" : "<&b>+<&r><&e>").append(toAdd).append("<&r>");
|
||||
verbose("Less than (" + addCount + ")");
|
||||
}
|
||||
|
||||
if (eval > target) {
|
||||
subCount++;
|
||||
if (op == 0) {
|
||||
divideCount++;
|
||||
} else {
|
||||
rootCount++;
|
||||
}
|
||||
|
||||
final String toAdd = (op == 0) ? Complexers.divide(ri) : Complexers.root(ri);
|
||||
/*
|
||||
String colored = Utils.highlightReg(toAdd);
|
||||
if (deep) {
|
||||
colored = Utils.highlightDeep(toAdd);
|
||||
}*/
|
||||
expression.insert(0,"<&c>(<&r>").append("<&c>)<&r>");
|
||||
expression.append("<&b>-<&r><&e>").append(toAdd).append("<&r>");
|
||||
verbose("Greater than (" + subCount + ")");
|
||||
}
|
||||
}
|
||||
|
||||
verbose("Broke out of loop. Value: " + eval(expression.toString()));
|
||||
verbose("Expression: " + expression);
|
||||
verbose("Expression (Cleaned): " + removeColors(expression.toString()));
|
||||
System.out.println("\n\n\n\nStatistics: " +
|
||||
"\nCubes: " + cubeCount +
|
||||
"\nFactors: " + factorCount +
|
||||
"\nAdditions: " + addCount +
|
||||
"\nSubtractions: " + subCount +
|
||||
"\nRoots Taken: " + rootCount +
|
||||
"\nDivisors: " + divideCount +
|
||||
"\nPerfect Squares Found: " + perfectCount +
|
||||
"\nTotal steps taken: " + total);
|
||||
return expression.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,55 @@
|
||||
package me.trouper;
|
||||
|
||||
import me.trouper.Functions.Complexers;
|
||||
import me.trouper.Functions.Obf;
|
||||
import me.trouper.Utils.Timer;
|
||||
import me.trouper.Utils.Utils;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Scanner;
|
||||
|
||||
import static me.trouper.Functions.Eval.*;
|
||||
import static me.trouper.Functions.Eval.eval;
|
||||
import static me.trouper.Utils.Utils.removeColors;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static boolean verbose;
|
||||
public static boolean deep;
|
||||
public static boolean color;
|
||||
public static boolean printHelp;
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
boolean doCopy = false;
|
||||
|
||||
|
||||
for (String arg : args) {
|
||||
switch (arg) {
|
||||
case "--copy", "-c" -> doCopy = true;
|
||||
case "--verbose", "-v" -> verbose = true;
|
||||
case "--deep", "-d" -> deep = true;
|
||||
case "--color", "-rgb" -> color = true;
|
||||
case "--help", "--h", "-h" -> printHelp = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (printHelp) Utils.printHelp();
|
||||
if (color) Utils.printColorKey();
|
||||
|
||||
while (true) {
|
||||
System.out.print("Enter Target Integer: ");
|
||||
if (scanner.hasNextInt()) {
|
||||
int target = scanner.nextInt();
|
||||
String expression = obfInt(target);
|
||||
double output = eval(expression);
|
||||
Timer obfTimer = Timer.start();
|
||||
String expression = Obf.obfInt(target, deep);
|
||||
long obfTime = obfTimer.end().timePassed();
|
||||
double output = eval(removeColors(expression));
|
||||
|
||||
System.out.println("\nTarget Integer: " + target);
|
||||
System.out.println("\nElapsed Time: " + obfTime + "ms");
|
||||
|
||||
|
||||
if (output == target) {
|
||||
System.out.println("Expression Verified Correct: \n" + expression);
|
||||
System.out.println(Utils.activateColors("<&2h><&f>Expression Correct<&r>\n\n" + ((color) ? expression : removeColors(expression))));
|
||||
if (doCopy) Utils.copyToClip(removeColors(expression));
|
||||
} else {
|
||||
System.out.println("!!!! INCORRECT !!!! \n" + expression);
|
||||
System.out.println(Utils.activateColors("<&ch><&0>!!!! INCORRECT !!!!<&r>\n\n" + ((color) ? expression : removeColors(expression))));
|
||||
}
|
||||
} else {
|
||||
System.out.println("Exiting the program.");
|
||||
@@ -33,95 +59,4 @@ public class Main {
|
||||
|
||||
scanner.close();
|
||||
}
|
||||
|
||||
public static String obfInt(int target) {
|
||||
StringBuilder expression = new StringBuilder();
|
||||
Random random = new Random();
|
||||
|
||||
int initializer = random.nextInt(9)+1;
|
||||
System.out.println("Initializing Expression: " + initializer);
|
||||
expression.append(initializer);
|
||||
|
||||
int cubeCount = 0;
|
||||
int factorCount = 0;
|
||||
int addCount = 0;
|
||||
int subCount = 0;
|
||||
int rootCount = 0;
|
||||
int divideCount = 0;
|
||||
int perfectCount = 0;
|
||||
int total = 0;
|
||||
|
||||
while (eval(expression.toString()) != target) {
|
||||
total++;
|
||||
int eval = (int) eval(expression.toString());
|
||||
int ri = random.nextInt(9)+1;
|
||||
int op = random.nextInt(2);
|
||||
|
||||
if (!isInt(eval(expression.toString()))) {
|
||||
System.out.println("Something went horribly wrong, Here is the relevant info." +
|
||||
"\nEvaluation: " + eval(expression.toString()) +
|
||||
"\nRandom Pick: " + ri +
|
||||
"\nOperation: " + op +
|
||||
"\nCaught at: \n" + expression);
|
||||
break;
|
||||
}
|
||||
|
||||
System.out.println("Random: " + ri);
|
||||
System.out.println("Current: " + eval(expression.toString()));
|
||||
|
||||
if (isPerfectSquare(eval)) {
|
||||
perfectCount++;
|
||||
System.out.println("PERFECT SQUARE TIME! (" + perfectCount+ ")");
|
||||
expression.insert(0,"sqrt(").append(")");
|
||||
eval = (int) eval(expression.toString());
|
||||
}
|
||||
|
||||
if (target - eval > 1000) {
|
||||
cubeCount++;
|
||||
System.out.println("Enormous than (" + cubeCount + ")");
|
||||
expression.append("+").append(Complexers.power(ri,3));
|
||||
} else if (target - eval > 100) {
|
||||
factorCount++;
|
||||
System.out.println("Large than (" + factorCount + ")");
|
||||
expression.append("+").append(Complexers.multiply(ri,10));
|
||||
}
|
||||
|
||||
if (eval < target) {
|
||||
addCount++;
|
||||
if (op == 0) {
|
||||
divideCount++;
|
||||
} else {
|
||||
rootCount++;
|
||||
}
|
||||
expression.append("+").append((op == 0) ? Complexers.divide(ri) : Complexers.root(ri));
|
||||
System.out.println("Less than (" + addCount + ")");
|
||||
}
|
||||
|
||||
if (eval > target) {
|
||||
subCount++;
|
||||
if (op == 0) {
|
||||
divideCount++;
|
||||
} else {
|
||||
rootCount++;
|
||||
}
|
||||
expression.insert(0,"(").append(")");
|
||||
|
||||
expression.append("-").append((op == 0) ? Complexers.divide(ri) : Complexers.root(ri));
|
||||
System.out.println("Greater than (" + subCount + ")");
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Broke out of loop. Value: " + eval(expression.toString()));
|
||||
System.out.println("Expression: " + expression.toString());
|
||||
System.out.println("Statistics: " +
|
||||
"\nCubes: " + cubeCount +
|
||||
"\nFactors: " + factorCount +
|
||||
"\nAdditions: " + addCount +
|
||||
"\nSubtractions: " + subCount +
|
||||
"\nRoots Taken: " + rootCount +
|
||||
"\nDivisors " + divideCount +
|
||||
"\nPerfect Squares Found: " + perfectCount +
|
||||
"\nTotal steps taken: " + total);
|
||||
return expression.toString();
|
||||
}
|
||||
}
|
||||
|
||||
93
src/main/java/me/trouper/Utils/Timer.java
Normal file
93
src/main/java/me/trouper/Utils/Timer.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package me.trouper.Utils;
|
||||
|
||||
public class Timer {
|
||||
|
||||
/* Timer Curtosy of ImproperIssues
|
||||
* https://your-mom-is-so-fat-we-couldnt-fit-her-in-this-doma.in/tugdkppa.png
|
||||
* Yes, I got permission to use it this time! */
|
||||
|
||||
public static final long MILLIS_IN_SECOND = 1000L;
|
||||
public static final long MILLIS_IN_MINUTE = MILLIS_IN_SECOND * 60L;
|
||||
public static final long MILLIS_IN_HOUR = MILLIS_IN_MINUTE * 60L;
|
||||
public static final long MILLIS_IN_DAY = MILLIS_IN_HOUR * 24L;
|
||||
private long start;
|
||||
|
||||
private Timer() {
|
||||
this.start = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public static Timer start() {
|
||||
return new Timer();
|
||||
}
|
||||
|
||||
public static End zero() {
|
||||
return new End(0);
|
||||
}
|
||||
|
||||
public End end() {
|
||||
return new End(start);
|
||||
}
|
||||
|
||||
|
||||
public static class End {
|
||||
|
||||
private final long start;
|
||||
private final long end;
|
||||
|
||||
private End(long start) {
|
||||
this.end = System.currentTimeMillis();
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public long timePassed() {
|
||||
return end - start;
|
||||
}
|
||||
|
||||
public String getStamp(boolean day, boolean hr, boolean min, boolean sec, boolean ms) {
|
||||
long time = timePassed();
|
||||
String stamp = "";
|
||||
|
||||
if (day) {
|
||||
long l = (long)Math.floor((double)time / (double)MILLIS_IN_DAY);
|
||||
time -= l * MILLIS_IN_DAY;
|
||||
if (l > 0L) stamp += l + "d";
|
||||
}
|
||||
if (hr) {
|
||||
long l = (long)Math.floor((double)time / (double)MILLIS_IN_HOUR);
|
||||
time -= l * MILLIS_IN_HOUR;
|
||||
if (l > 0L) stamp += " " + l + "hr";
|
||||
}
|
||||
if (min) {
|
||||
long l = (long)Math.floor((double)time / (double)MILLIS_IN_MINUTE);
|
||||
time -= l * MILLIS_IN_MINUTE;
|
||||
if (l > 0L) stamp += " " + l + "min";
|
||||
}
|
||||
if (sec) {
|
||||
long l = (long)Math.floor((double)time / (double)MILLIS_IN_SECOND);
|
||||
time -= l * MILLIS_IN_SECOND;
|
||||
if (l > 0L) stamp += " " + l + "sec";
|
||||
}
|
||||
if (ms) {
|
||||
if (time > 0L) stamp += " " + time + "ms";
|
||||
}
|
||||
|
||||
return stamp.trim();
|
||||
}
|
||||
|
||||
public String getStampStandard() {
|
||||
return getStamp(false, true, true, false, false);
|
||||
}
|
||||
|
||||
public String getStampLogger() {
|
||||
return getStamp(false, true, true, true, false);
|
||||
}
|
||||
|
||||
public String getStampPrecise() {
|
||||
return getStamp(false, false, true, true, true);
|
||||
}
|
||||
|
||||
public String getStampFull() {
|
||||
return getStamp(true, true, true, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
106
src/main/java/me/trouper/Utils/Utils.java
Normal file
106
src/main/java/me/trouper/Utils/Utils.java
Normal file
@@ -0,0 +1,106 @@
|
||||
package me.trouper.Utils;
|
||||
|
||||
import me.trouper.Data.MC2Ansi;
|
||||
import me.trouper.Main;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.util.Map;
|
||||
|
||||
public class Utils {
|
||||
public static void copyToClip(String text) {
|
||||
StringSelection parsed = new StringSelection(text);
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(parsed,null);
|
||||
}
|
||||
public static void verbose(String text) {
|
||||
if (Main.verbose) System.out.println(text);
|
||||
}
|
||||
public static String removeColors(String input) {
|
||||
return input.replaceAll("<&[0-9a-fr]>|<&[0-9a-frh]h>", "");
|
||||
}
|
||||
public static String activateColors(String input) {
|
||||
Map<String, String> minecraftToAnsi = MC2Ansi.getColors();
|
||||
|
||||
Map<String, String> minecraftBackgroundsToAnsi = MC2Ansi.getBackgrounds();
|
||||
|
||||
for (Map.Entry<String, String> entry : minecraftToAnsi.entrySet()) {
|
||||
input = input.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> entry : minecraftBackgroundsToAnsi.entrySet()) {
|
||||
input = input.replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
input += "\u001B[0m\u001B[49m";
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
public static void printHelp() {
|
||||
System.out.println("Usage: java -jar Countroll-<version>.jar [options]");
|
||||
System.out.println("Options:");
|
||||
System.out.println(" --copy, -c Copy the generated expression to the clipboard");
|
||||
System.out.println(" --verbose, -v Enable verbose mode");
|
||||
System.out.println(" --deep, -d Enable deep obfuscation (under development)");
|
||||
System.out.println(" --color, -rgb Enable colored output");
|
||||
System.out.println(" --help, --h, -h Show this help message");
|
||||
System.out.println("Note: When using multiple options, separate them with spaces.");
|
||||
System.exit(0);
|
||||
}
|
||||
public static void printColorKey() {
|
||||
String colorKey = "\nColor Key: " +
|
||||
"\n<&c>Red Parentheses:<&r> Gets Subtracted" +
|
||||
"\n<&b><&eh>Blue/Yellow:<&r> Perfect Square" +
|
||||
"\n<&a>Green:<&r> Increaser" +
|
||||
"\n<&9>Blue:<&r> Operation" +
|
||||
"\n<&e>Yellow:<&r> Complexer";
|
||||
System.out.println(activateColors(colorKey));
|
||||
}
|
||||
/*
|
||||
public static String highlightReg(String exp) {
|
||||
final String result = exp
|
||||
.replaceAll("\\(", ANSI.WHITE + "(" + ANSI.RESET)
|
||||
.replaceAll("\\)", ANSI.WHITE + ")" + ANSI.RESET)
|
||||
.replaceAll("\\*", ANSI.BLUE + "*" + ANSI.RESET)
|
||||
.replaceAll("/", ANSI.BLUE + "/" + ANSI.RESET)
|
||||
.replaceAll("\\+", ANSI.BLUE + "+" + ANSI.RESET)
|
||||
.replaceAll("-", ANSI.BLUE + "-" + ANSI.RESET)
|
||||
.replaceAll("\\^", ANSI.BLUE + "^" + ANSI.RESET)
|
||||
.replaceAll("\\d+", ANSI.GREEN + "$0" + ANSI.RESET);
|
||||
verbose("Attempting Ansi Highlight: " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String highlightDeep(String exp) {
|
||||
final String result = exp
|
||||
.replaceAll("\\(", ANSI.CYAN + "*" + ANSI.RESET)
|
||||
.replaceAll("\\)", ANSI.CYAN + "*" + ANSI.RESET)
|
||||
.replaceAll("\\*", ANSI.BLUE + "*" + ANSI.RESET)
|
||||
.replaceAll("/", ANSI.BLUE + "/" + ANSI.RESET)
|
||||
.replaceAll("\\+", ANSI.BLUE + "+" + ANSI.RESET)
|
||||
.replaceAll("-", ANSI.BLUE + "-" + ANSI.RESET)
|
||||
.replaceAll("\\^", ANSI.BLUE + "^" + ANSI.RESET)
|
||||
.replaceAll("\\d+", ANSI.PURPLE + "$0" + ANSI.RESET);
|
||||
verbose("Attempting Ansi Highlight (Deep): " + result);
|
||||
return result;
|
||||
}
|
||||
public static String fixAnsi(String input) {
|
||||
Pattern pattern = Pattern.compile("(\\[\\d+m)");
|
||||
Matcher matcher = pattern.matcher(input);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
while (matcher.find()) {
|
||||
// Check if the escape code was not properly closed (e.g., missing reset code)
|
||||
if (input.substring(matcher.start()).indexOf(ANSI.RESET) < 0) {
|
||||
String escapeCode = matcher.group(1);
|
||||
// Re-escape the ANSI escape code
|
||||
matcher.appendReplacement(sb, escapeCode);
|
||||
}
|
||||
}
|
||||
matcher.appendTail(sb);
|
||||
|
||||
return sb.toString();
|
||||
}*/
|
||||
}
|
||||
Reference in New Issue
Block a user