Optimize some code

This commit is contained in:
BuildTools 2023-01-01 10:42:36 -07:00
parent 80418d8d89
commit 2c573bdca0
29 changed files with 254 additions and 3711 deletions

View File

@ -1,18 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="bin/main" path="src/main/java">
<classpathentry output="bin/main" kind="src" path="src/main/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/teavm/java">
<classpathentry output="bin/main" kind="src" path="src/teavm/java">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry sourcepath="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-classlib/0.6.1/ed928987ac8c74c3279dbc00d777ea87155469bc/teavm-classlib-0.6.1-sources.jar" kind="lib" path="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-classlib/0.6.1/3b0f0cb8c3d879f6dd9d9d0101e0032d57f5fa8/teavm-classlib-0.6.1.jar">
<attributes>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry sourcepath="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-platform/0.6.1/69815866360883bc945cc2704e01c2aafc1ce296/teavm-platform-0.6.1-sources.jar" kind="lib" path="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-platform/0.6.1/18dfcd3bf6c2e379e23cf168549585aae98857f/teavm-platform-0.6.1.jar">
<attributes>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry sourcepath="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-jso-impl/0.6.1/e39d63686c38ec74d4eaa4d12d5259ac0e8483b9/teavm-jso-impl-0.6.1-sources.jar" kind="lib" path="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-jso-impl/0.6.1/b5caec1ba7fed15254b9f8b50340549023cce240/teavm-jso-impl-0.6.1.jar">
<attributes>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry sourcepath="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-jso-apis/0.6.1/55274af88c7746aea55fcfef45dc9397228c8a38/teavm-jso-apis-0.6.1-sources.jar" kind="lib" path="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-jso-apis/0.6.1/622597700c7debce22e5d0997b649016447d67f7/teavm-jso-apis-0.6.1.jar">
<attributes>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry sourcepath="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-jso/0.6.1/78c94b8a7aba6960a5ce43331c66d6c2c5ff968a/teavm-jso-0.6.1-sources.jar" kind="lib" path="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-jso/0.6.1/9d86da37b45a9c60644818536959459222083936/teavm-jso-0.6.1.jar">
<attributes>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry sourcepath="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-metaprogramming-impl/0.6.1/aa2d2217e5dd4e612baa393d0a0003a066cd1f16/teavm-metaprogramming-impl-0.6.1-sources.jar" kind="lib" path="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-metaprogramming-impl/0.6.1/5eab0c2ab199d76b004265af824f36f1706b7d62/teavm-metaprogramming-impl-0.6.1.jar">
<attributes>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry sourcepath="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-metaprogramming-api/0.6.1/f103f71f184e676b2d7e6f5872e148f7d794a93c/teavm-metaprogramming-api-0.6.1-sources.jar" kind="lib" path="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-metaprogramming-api/0.6.1/2c3da6a61a58ed2c3d10cf405dffad90488ed6a2/teavm-metaprogramming-api-0.6.1.jar">
<attributes>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry sourcepath="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/com.jcraft/jzlib/1.1.3/3102d5e0e3e6cdb601b42f7bdcbff13167a2226d/jzlib-1.1.3-sources.jar" kind="lib" path="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/com.jcraft/jzlib/1.1.3/c01428efa717624f7aabf4df319939dda9646b2d/jzlib-1.1.3.jar">
<attributes>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry sourcepath="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/joda-time/joda-time/2.7/1fc633cf2a3f5a1767ef28b81ebc5d0ecfa1ffda/joda-time-2.7-sources.jar" kind="lib" path="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/joda-time/joda-time/2.7/5599707a3eaad13e889f691b3af78c8c03842195/joda-time-2.7.jar">
<attributes>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry sourcepath="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-interop/0.6.1/6f27194568262d33bd82a443632e8d1a778c7c1a/teavm-interop-0.6.1-sources.jar" kind="lib" path="C:/Users/kay_j/.gradle/caches/modules-2/files-2.1/org.teavm/teavm-interop/0.6.1/556d85e513f13e867435c34f2128e79d98995c41/teavm-interop-0.6.1.jar">
<attributes>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
</classpath>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

View File

@ -1,2 +1,2 @@
#Tue Dec 27 18:31:16 UTC 2022
gradle.version=6.0
#Sun Jan 01 10:34:46 MST 2023
gradle.version=7.3.1

BIN
.gradle/file-system.probe Normal file

Binary file not shown.

6
.idea/compiler.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="1.8" />
</component>
</project>

16
.idea/gradle.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

20
.idea/jarRepositories.xml Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="MavenRepo" />
<option name="name" value="MavenRepo" />
<option name="url" value="https://repo.maven.apache.org/maven2/" />
</remote-repository>
</component>
</project>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="zulu-17" project-jdk-type="JavaSDK">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="azul-13" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/classes" />
</component>
</project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/eaglercraft-workspace.iml" filepath="$PROJECT_DIR$/eaglercraft-workspace.iml" />
</modules>
</component>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -2,29 +2,27 @@
<projectDescription>
<name>eaglercraft-workspace</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<projects/>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments/>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments/>
</buildCommand>
</buildSpec>
<linkedResources/>
<filteredResources>
<filter>
<id>0</id>
<name></name>
<id>1</id>
<type>30</type>
<name/>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>

View File

@ -1,5 +1,5 @@
#
#Wed Dec 28 20:02:09 UTC 2022
#Sun Jan 01 10:34:48 MST 2023
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager">
<conelement value="org.eclipse.buildship.core.gradleclasspathcontainer" />
<src_description expected_position="0">
<src_folder value="file://$MODULE_DIR$/src/main/java" expected_position="0" />
<src_folder value="file://$MODULE_DIR$/src/teavm/java" expected_position="1" />
</src_description>
</component>
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/bin/default" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/teavm/java" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="inheritedJdk" />
<orderEntry type="library" name="org.eclipse.buildship.core.gradleclasspathcontainer" level="application" />
</component>
</module>

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -1,16 +1,7 @@
package dev.resent;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import dev.resent.event.impl.Event;
import dev.resent.module.base.Mod;
import dev.resent.module.base.ModManager;
import dev.resent.module.base.RenderModule;
import dev.resent.setting.BooleanSetting;
import dev.resent.setting.ModeSetting;
import dev.resent.setting.Setting;
import net.kyori.event.EventBus;
import net.minecraft.client.Minecraft;

View File

@ -1,6 +1,7 @@
package dev.resent.module.base;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import dev.resent.setting.Setting;
@ -16,7 +17,7 @@ public class Mod {
public boolean enabled = false;
public boolean hasSetting;
public List<Setting> settings = new ArrayList<Setting>();
public List<Setting> settings = new ArrayList<>();
public Mod(String name, Category cat) {
this.name = name;
@ -30,9 +31,7 @@ public class Mod {
}
public void addSetting(Setting... settings) {
for (Setting s : settings) {
this.settings.add(s);
}
this.settings.addAll(Arrays.asList(settings));
}
public void onEnable() {

View File

@ -43,7 +43,7 @@ import net.minecraft.client.Minecraft;
public class ModManager {
public List<Mod> modules = new ArrayList<Mod>();
public List<Mod> modules = new ArrayList<>();
public Minecraft mc = Minecraft.getMinecraft();
public static String currentModDragging = null;
@ -73,7 +73,6 @@ public class ModManager {
public static AutoWalk autoWalk;
public static AutoJump autoJump;
public static SelfNametag selfNametag = new SelfNametag();
public static Scoreboard scoreboard2;
public static ClearChat clearChat = new ClearChat();
public static Tooltips tooltips;
public static SmoothCamera smoothCamera;
@ -147,9 +146,9 @@ public class ModManager {
public List<Mod> getModulesByCategory(Category c) {
List<Mod> modules1 = new ArrayList<Mod>();
for(int i = 0; i < modules.size(); i++){
if (modules.get(i).category == c) {
modules1.add(modules.get(i));
for (Mod module : modules) {
if (module.category == c) {
modules1.add(module);
}
}
return modules1;

View File

@ -4,6 +4,8 @@ import net.lax1dude.eaglercraft.v1_8.Mouse;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import java.util.Objects;
public class RenderModule extends Mod {
public int x, y, width, height;
@ -60,23 +62,23 @@ public class RenderModule extends Mod {
}
private void draggingFix(int mouseX, int mouseY) {
if (this.dragging && (ModManager.currentModDragging == this.name || ModManager.currentModDragging == null)) {
if (this.dragging && (Objects.equals(ModManager.currentModDragging, this.name) || ModManager.currentModDragging == null)) {
this.x = mouseX + this.lastX;
this.y = mouseY + this.lastY;
if (ModManager.currentModDragging == null)
ModManager.currentModDragging = this.name;
if (!Mouse.isButtonDown(0))
this.dragging = false;
if (ModManager.currentModDragging == this.name)
if (Objects.equals(ModManager.currentModDragging, this.name))
ModManager.currentModDragging = null;
if (this.x >= GuiScreen.width - getWidth()) {
this.dragging = false;
if (ModManager.currentModDragging == this.name)
if (Objects.equals(ModManager.currentModDragging, this.name))
ModManager.currentModDragging = null;
}
if (this.y >= GuiScreen.height - getHeight()) {
this.dragging = false;
if (ModManager.currentModDragging == this.name)
if (Objects.equals(ModManager.currentModDragging, this.name))
ModManager.currentModDragging = null;
}
}
@ -87,15 +89,12 @@ public class RenderModule extends Mod {
boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + getWidth()
&& mouseY < getY() + this.getHeight();
if (hovered) {
}
boolean mouseOverX = (mouseX >= this.x && mouseX <= this.x + this.getWidth());
boolean mouseOverY = (mouseY >= this.y && mouseY <= this.y + this.getHeight());
boolean drag = (mouseOverX && mouseOverY && Mouse.isButtonDown(0));
draggingFix(mouseX, mouseY);
if (drag && (ModManager.currentModDragging == null || ModManager.currentModDragging == this.name)) {
if (drag && (ModManager.currentModDragging == null || ModManager.currentModDragging.equals(this.name))) {
if (!this.dragging) {
this.lastX = x - mouseX;
this.lastY = y - mouseY;