Queue still needed

Added in beginnings for fastqueue
This commit is contained in:
NuclearW 2012-02-16 23:37:14 -05:00
parent 82e34a5b02
commit 5d4d4d3498
3 changed files with 20 additions and 11 deletions

View File

@ -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) if (id == 17 || id == 73 || id == 74 || id == 81 || id == 83 || id == 86 || id == 91 || id == 106 || id == 98)
plugin.misc.blockWatchList.add(block); plugin.misc.blockWatchList.add(block);
else { 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 //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 //it should be removed as soon as functionality to change a block
//in this event returns. //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);
}
} }
} }

View File

@ -73,9 +73,14 @@ public class mcMMO extends JavaPlugin
private final mcBlockListener blockListener = new mcBlockListener(this); private final mcBlockListener blockListener = new mcBlockListener(this);
private final mcEntityListener entityListener = new mcEntityListener(this); private final mcEntityListener entityListener = new mcEntityListener(this);
//Queue for block data change for R2+ fix
public ArrayDeque<Block> changeQueue = new ArrayDeque<Block>();
public ArrayDeque<Block> fastChangeQueue = new ArrayDeque<Block>();
private Runnable mcMMO_Timer = new mcTimer(this); //BLEED AND REGENERATION private Runnable mcMMO_Timer = new mcTimer(this); //BLEED AND REGENERATION
private Runnable mcMMO_SaveTimer = new mcSaveTimer(this); //Periodic saving of Player Data 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); //private Timer mcMMO_SpellTimer = new Timer(true);
//Alias - Command //Alias - Command
@ -89,9 +94,6 @@ public class mcMMO extends JavaPlugin
//Jar stuff //Jar stuff
public static File mcmmo; public static File mcmmo;
//Queue for block data change for R2+ fix
public ArrayDeque<Block> changeQueue = new ArrayDeque<Block>();
public void onEnable() public void onEnable()
{ {
final Plugin thisPlugin = this; final Plugin thisPlugin = this;
@ -156,6 +158,7 @@ public class mcMMO extends JavaPlugin
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, mcMMO_Timer, 0, 20); Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, mcMMO_Timer, 0, 20);
//R2+ block place fix //R2+ block place fix
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, ChangeDataValueTimer, 0, 10); Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, ChangeDataValueTimer, 0, 10);
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, FastChangeDataValueTimer, 0, 1);
registerCommands(); registerCommands();

View File

@ -16,6 +16,8 @@
*/ */
package com.gmail.nossr50.runnables; package com.gmail.nossr50.runnables;
import java.util.ArrayDeque;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
@ -25,21 +27,21 @@ import com.gmail.nossr50.mcMMO;
* It should be removed afterwards if the breakage is removed. * It should be removed afterwards if the breakage is removed.
*/ */
public class ChangeDataValueTimer implements Runnable { public class ChangeDataValueTimer implements Runnable {
private mcMMO plugin; private ArrayDeque<Block> queue;
public ChangeDataValueTimer(mcMMO instance) { public ChangeDataValueTimer(ArrayDeque<Block> queue) {
this.plugin = instance; this.queue = queue;
} }
public void run() { public void run() {
int size = plugin.changeQueue.size(); int size = queue.size();
if(size == 0) return; if(size == 0) return;
if(size > 25) { if(size > 25) {
size = (int) Math.floor(size / 10); size = (int) Math.floor(size / 10);
} }
for(int i = 0; i < size; i++) { for(int i = 0; i < size; i++) {
Block change = plugin.changeQueue.poll(); Block change = queue.poll();
if(change == null) continue; if(change == null) continue;
change.setData((byte) 5); change.setData((byte) 5);
} }