Some fixes

It's really slow now and I don't know why
This commit is contained in:
Norbi Peti 2020-11-28 01:17:22 +01:00
parent 2c6eb3a610
commit fd9803c6f1
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
3 changed files with 6 additions and 4 deletions

View file

@ -65,6 +65,7 @@ public class PluginMain extends ButtonPlugin {
@Override @Override
public void pluginEnable() { public void pluginEnable() {
registerCommand(new ComputerCommand()); registerCommand(new ComputerCommand());
Instance = this;
if (autoEnable.get()) if (autoEnable.get())
pluginEnableInternal(); pluginEnableInternal();
else else
@ -75,7 +76,6 @@ public class PluginMain extends ButtonPlugin {
if (pluginEnabled) if (pluginEnabled)
return; return;
pluginEnabled = true; pluginEnabled = true;
Instance = this;
try { try {
ConsoleCommandSender ccs = getServer().getConsoleSender(); ConsoleCommandSender ccs = getServer().getConsoleSender();
sendAll = getConfig().getBoolean("sendAll", true); sendAll = getConfig().getBoolean("sendAll", true);
@ -149,7 +149,7 @@ public class PluginMain extends ButtonPlugin {
for (short i = 0; i < MCX * MCY; i++) for (short i = 0; i < MCX * MCY; i++)
renderers.add(new BukkitRenderer((short) (startID.get() + i), Bukkit.getWorlds().get(0), i * 128 * 128 * 4)); renderers.add(new BukkitRenderer((short) (startID.get() + i), Bukkit.getWorlds().get(0), i * 128 * 128 * 4));
direct = false; direct = false;
ccs.sendMessage("§6Compatibility error, using slower renderer"); ccs.sendMessage("§6Using Bukkit renderer");
} }
private void error(String message) { private void error(String message) {

View file

@ -27,7 +27,7 @@ public class GPURenderer extends MapRenderer implements IRenderer {
private static int[] colors_; private static int[] colors_;
private int changedX = 0, changedY = 0, changedWidth = 640, changedHeight = 480; private int changedX = 0, changedY = 0, changedWidth = 640, changedHeight = 480;
private BiConsumer<Integer, Integer> flagDirty; //This way it's version independent, as long as it's named the same private BiConsumer<Integer, Integer> flagDirty; //This way it's version independent, as long as it's named the same
private static ArrayList<GPURenderer> renderers = new ArrayList<>(); private static final ArrayList<GPURenderer> renderers = new ArrayList<>();
private static Method flagDirtyMethod; private static Method flagDirtyMethod;
private static boolean enabled = true; private static boolean enabled = true;
private static boolean warned = false; private static boolean warned = false;

View file

@ -76,7 +76,7 @@ public class MCFrameBuffer implements IMCFrameBuffer {
public void notifyUpdate(long x, long y, long width, long height) { public void notifyUpdate(long x, long y, long width, long height) {
/*if (this.width > 1024 || this.height > 768) /*if (this.width > 1024 || this.height > 768)
return;*/ 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 return; //Don't wait for lock, ignore update since we're updating everything anyway - TODO: Not always
synchronized (this) { synchronized (this) {
shouldUpdate.set(true); shouldUpdate.set(true);
@ -90,6 +90,8 @@ public class MCFrameBuffer implements IMCFrameBuffer {
} }
public void start() { public void start() {
if (!PluginMain.direct)
return;
running = true; running = true;
Bukkit.getScheduler().runTaskAsynchronously(PluginMain.Instance, () -> { Bukkit.getScheduler().runTaskAsynchronously(PluginMain.Instance, () -> {
try { try {