From 5d4d4d34981542645840b7892571df895918b077 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Thu, 16 Feb 2012 23:37:14 -0500 Subject: [PATCH] Queue still needed Added in beginnings for fastqueue --- .../com/gmail/nossr50/listeners/mcBlockListener.java | 8 ++++++-- src/main/java/com/gmail/nossr50/mcMMO.java | 11 +++++++---- .../nossr50/runnables/ChangeDataValueTimer.java | 12 +++++++----- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java index 09126ee70..b223036a9 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java @@ -93,11 +93,15 @@ public class mcBlockListener implements Listener if (id == 17 || id == 73 || id == 74 || id == 81 || id == 83 || id == 86 || id == 91 || id == 106 || id == 98) plugin.misc.blockWatchList.add(block); else { - block.setData((byte) 5); //Change the byte + //block.setData((byte) 5); //Change the byte //The following is a method to get around a breakage in 1.1-R2 and onward //it should be removed as soon as functionality to change a block //in this event returns. -// plugin.changeQueue.push(block); + if(id == 0) { // ids of blocks that can be mined very quickly and need to be worked on fast + plugin.fastChangeQueue.push(block); + } else { + plugin.changeQueue.push(block); + } } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index a88b7f578..ad9506f69 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -72,10 +72,15 @@ public class mcMMO extends JavaPlugin private final mcPlayerListener playerListener = new mcPlayerListener(this); private final mcBlockListener blockListener = new mcBlockListener(this); private final mcEntityListener entityListener = new mcEntityListener(this); + + //Queue for block data change for R2+ fix + public ArrayDeque changeQueue = new ArrayDeque(); + public ArrayDeque fastChangeQueue = new ArrayDeque(); private Runnable mcMMO_Timer = new mcTimer(this); //BLEED AND REGENERATION private Runnable mcMMO_SaveTimer = new mcSaveTimer(this); //Periodic saving of Player Data - private Runnable ChangeDataValueTimer = new ChangeDataValueTimer(this); //R2 block place workaround + private Runnable ChangeDataValueTimer = new ChangeDataValueTimer(changeQueue); //R2 block place workaround + private Runnable FastChangeDataValueTimer = new ChangeDataValueTimer(fastChangeQueue); //private Timer mcMMO_SpellTimer = new Timer(true); //Alias - Command @@ -88,9 +93,6 @@ public class mcMMO extends JavaPlugin LoadProperties config; //Jar stuff public static File mcmmo; - - //Queue for block data change for R2+ fix - public ArrayDeque changeQueue = new ArrayDeque(); public void onEnable() { @@ -156,6 +158,7 @@ public class mcMMO extends JavaPlugin Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, mcMMO_Timer, 0, 20); //R2+ block place fix Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, ChangeDataValueTimer, 0, 10); + Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, FastChangeDataValueTimer, 0, 1); registerCommands(); diff --git a/src/main/java/com/gmail/nossr50/runnables/ChangeDataValueTimer.java b/src/main/java/com/gmail/nossr50/runnables/ChangeDataValueTimer.java index c2cbab52e..2a1bde34d 100644 --- a/src/main/java/com/gmail/nossr50/runnables/ChangeDataValueTimer.java +++ b/src/main/java/com/gmail/nossr50/runnables/ChangeDataValueTimer.java @@ -16,6 +16,8 @@ */ package com.gmail.nossr50.runnables; +import java.util.ArrayDeque; + import org.bukkit.block.Block; import com.gmail.nossr50.mcMMO; @@ -25,21 +27,21 @@ import com.gmail.nossr50.mcMMO; * It should be removed afterwards if the breakage is removed. */ public class ChangeDataValueTimer implements Runnable { - private mcMMO plugin; + private ArrayDeque queue; - public ChangeDataValueTimer(mcMMO instance) { - this.plugin = instance; + public ChangeDataValueTimer(ArrayDeque queue) { + this.queue = queue; } public void run() { - int size = plugin.changeQueue.size(); + int size = queue.size(); if(size == 0) return; if(size > 25) { size = (int) Math.floor(size / 10); } for(int i = 0; i < size; i++) { - Block change = plugin.changeQueue.poll(); + Block change = queue.poll(); if(change == null) continue; change.setData((byte) 5); }