From fd9803c6f110e5665616a3ad41b06c3f9dd22d7d Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 28 Nov 2020 01:17:22 +0100 Subject: [PATCH] Some fixes It's really slow now and I don't know why --- .../src/main/java/sznp/virtualcomputer/PluginMain.java | 4 ++-- .../main/java/sznp/virtualcomputer/renderer/GPURenderer.java | 2 +- .../java/sznp/virtualcomputer/renderer/MCFrameBuffer.java | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/VirtualComputer-Core/src/main/java/sznp/virtualcomputer/PluginMain.java b/VirtualComputer-Core/src/main/java/sznp/virtualcomputer/PluginMain.java index 1d6ed42..fb9411f 100644 --- a/VirtualComputer-Core/src/main/java/sznp/virtualcomputer/PluginMain.java +++ b/VirtualComputer-Core/src/main/java/sznp/virtualcomputer/PluginMain.java @@ -65,6 +65,7 @@ public class PluginMain extends ButtonPlugin { @Override public void pluginEnable() { registerCommand(new ComputerCommand()); + Instance = this; if (autoEnable.get()) pluginEnableInternal(); else @@ -75,7 +76,6 @@ public class PluginMain extends ButtonPlugin { if (pluginEnabled) return; pluginEnabled = true; - Instance = this; try { ConsoleCommandSender ccs = getServer().getConsoleSender(); sendAll = getConfig().getBoolean("sendAll", true); @@ -149,7 +149,7 @@ public class PluginMain extends ButtonPlugin { for (short i = 0; i < MCX * MCY; i++) renderers.add(new BukkitRenderer((short) (startID.get() + i), Bukkit.getWorlds().get(0), i * 128 * 128 * 4)); direct = false; - ccs.sendMessage("§6Compatibility error, using slower renderer"); + ccs.sendMessage("§6Using Bukkit renderer"); } private void error(String message) { diff --git a/VirtualComputer-Core/src/main/java/sznp/virtualcomputer/renderer/GPURenderer.java b/VirtualComputer-Core/src/main/java/sznp/virtualcomputer/renderer/GPURenderer.java index 01ec91b..31ad1c7 100644 --- a/VirtualComputer-Core/src/main/java/sznp/virtualcomputer/renderer/GPURenderer.java +++ b/VirtualComputer-Core/src/main/java/sznp/virtualcomputer/renderer/GPURenderer.java @@ -27,7 +27,7 @@ public class GPURenderer extends MapRenderer implements IRenderer { private static int[] colors_; private int changedX = 0, changedY = 0, changedWidth = 640, changedHeight = 480; private BiConsumer flagDirty; //This way it's version independent, as long as it's named the same - private static ArrayList renderers = new ArrayList<>(); + private static final ArrayList renderers = new ArrayList<>(); private static Method flagDirtyMethod; private static boolean enabled = true; private static boolean warned = false; diff --git a/VirtualComputer-Core/src/main/java/sznp/virtualcomputer/renderer/MCFrameBuffer.java b/VirtualComputer-Core/src/main/java/sznp/virtualcomputer/renderer/MCFrameBuffer.java index 61d8a40..1c88134 100644 --- a/VirtualComputer-Core/src/main/java/sznp/virtualcomputer/renderer/MCFrameBuffer.java +++ b/VirtualComputer-Core/src/main/java/sznp/virtualcomputer/renderer/MCFrameBuffer.java @@ -76,7 +76,7 @@ public class MCFrameBuffer implements IMCFrameBuffer { public void notifyUpdate(long x, long y, long width, long height) { /*if (this.width > 1024 || this.height > 768) return;*/ - if(shouldUpdate.get()) + if (!PluginMain.direct || shouldUpdate.get()) return; //Don't wait for lock, ignore update since we're updating everything anyway - TODO: Not always synchronized (this) { shouldUpdate.set(true); @@ -90,6 +90,8 @@ public class MCFrameBuffer implements IMCFrameBuffer { } public void start() { + if (!PluginMain.direct) + return; running = true; Bukkit.getScheduler().runTaskAsynchronously(PluginMain.Instance, () -> { try {