aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/lwjgl
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/lwjgl')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/IOUtil.java56
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/font/FontManager.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java4
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider.java (renamed from src/main/java/cc/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider.java)2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/Scissor.java (renamed from src/main/java/cc/polyfrost/oneconfig/lwjgl/Scissor.java)2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java (renamed from src/main/java/cc/polyfrost/oneconfig/lwjgl/ScissorManager.java)3
8 files changed, 11 insertions, 66 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java
index 914c483..285875a 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/BlurHandler.java
@@ -109,7 +109,7 @@ public class BlurHandler {
su.set(progress);
}
} catch (IllegalArgumentException ex) {
- this.logger.error("An error occurred while updating ToggleChat's blur. Please report this!", ex);
+ this.logger.error("An error occurred while updating OneConfig's blur. Please report this!", ex);
}
this.mc.mcProfiler.endSection();
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/IOUtil.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/IOUtil.java
deleted file mode 100644
index 1394239..0000000
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/IOUtil.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package cc.polyfrost.oneconfig.lwjgl;
-
-import org.apache.commons.io.IOUtils;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.nio.Buffer;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.file.Files;
-
-public final class IOUtil {
-
- private IOUtil() {
- }
-
- /**
- * Taken from legui under MIT License
- * <a href="https://github.com/SpinyOwl/legui/blob/develop/LICENSE">https://github.com/SpinyOwl/legui/blob/develop/LICENSE</a>
- */
- public static ByteBuffer resourceToByteBuffer(String path) throws IOException {
- byte[] bytes;
- path = path.trim();
- if (path.startsWith("http")) {
- bytes = IOUtils.toByteArray(new URL(path));
- } else {
- InputStream stream;
- File file = new File(path);
- if (file.exists() && file.isFile()) {
- stream = Files.newInputStream(file.toPath());
- } else {
- stream = IOUtil.class.getResourceAsStream(path);
- }
- if (stream == null) {
- throw new FileNotFoundException(path);
- }
- bytes = IOUtils.toByteArray(stream);
- }
- ByteBuffer data = ByteBuffer.allocateDirect(bytes.length).order(ByteOrder.nativeOrder())
- .put(bytes);
- ((Buffer) data).flip();
- return data;
- }
-
- public static ByteBuffer resourceToByteBufferNullable(String path) {
- try {
- return resourceToByteBuffer(path);
- } catch (Exception ignored) {
- return null;
- }
- }
-
-} \ No newline at end of file
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/FontManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/FontManager.java
index 0974019..534795b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/FontManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/font/FontManager.java
@@ -1,6 +1,6 @@
package cc.polyfrost.oneconfig.lwjgl.font;
-import cc.polyfrost.oneconfig.lwjgl.IOUtil;
+import cc.polyfrost.oneconfig.utils.IOUtils;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -15,7 +15,7 @@ public class FontManager {
Font font = fonts.font;
int loaded = -1;
try {
- ByteBuffer buffer = IOUtil.resourceToByteBuffer(font.getFileName());
+ ByteBuffer buffer = IOUtils.resourceToByteBuffer(font.getFileName());
loaded = nvgCreateFontMem(vg, font.getName(), buffer, 0);
font.setBuffer(buffer);
} catch (IOException e) {
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
index 8e72828..479104c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
@@ -1,6 +1,6 @@
package cc.polyfrost.oneconfig.lwjgl.image;
-import cc.polyfrost.oneconfig.lwjgl.IOUtil;
+import cc.polyfrost.oneconfig.utils.IOUtils;
import org.lwjgl.nanovg.NanoVG;
import org.lwjgl.stb.STBImage;
@@ -17,7 +17,7 @@ public class ImageLoader {
int[] height = {0};
int[] channels = {0};
- ByteBuffer image = IOUtil.resourceToByteBufferNullable(fileName);
+ ByteBuffer image = IOUtils.resourceToByteBufferNullable(fileName);
if (image == null) {
return false;
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java
index c34f3b8..858d615 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/ClassTransformer.java
@@ -23,11 +23,11 @@ public class ClassTransformer implements IClassTransformer {
InsnList list = new InsnList();
list.add(new VarInsnNode(Opcodes.LLOAD, 0));
- list.add(new TypeInsnNode(Opcodes.NEW, "cc/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider"));
+ list.add(new TypeInsnNode(Opcodes.NEW, "cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider"));
list.add(new InsnNode(Opcodes.DUP));
list.add(new MethodInsnNode(
Opcodes.INVOKESPECIAL,
- "cc/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider",
+ "cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider",
"<init>",
"()V",
false
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider.java
index e00570e..4cef17c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/Lwjgl2FunctionProvider.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/plugin/Lwjgl2FunctionProvider.java
@@ -1,4 +1,4 @@
-package cc.polyfrost.oneconfig.lwjgl;
+package cc.polyfrost.oneconfig.lwjgl.plugin;
import org.lwjgl.opengl.GLContext;
import org.lwjgl.system.FunctionProvider;
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/Scissor.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/Scissor.java
index 5709823..9523865 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/Scissor.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/Scissor.java
@@ -1,4 +1,4 @@
-package cc.polyfrost.oneconfig.lwjgl;
+package cc.polyfrost.oneconfig.lwjgl.scissor;
public class Scissor {
public float x;
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/ScissorManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java
index db85e86..a3f3780 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/ScissorManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java
@@ -1,5 +1,6 @@
-package cc.polyfrost.oneconfig.lwjgl;
+package cc.polyfrost.oneconfig.lwjgl.scissor;
+import cc.polyfrost.oneconfig.lwjgl.scissor.Scissor;
import org.lwjgl.nanovg.NanoVG;
import java.util.ArrayList;