mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Queue still needed
Added in beginnings for fastqueue
This commit is contained in:
parent
82e34a5b02
commit
5d4d4d3498
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<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_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<Block> changeQueue = new ArrayDeque<Block>();
|
||||
|
||||
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();
|
||||
|
||||
|
@ -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<Block> queue;
|
||||
|
||||
public ChangeDataValueTimer(mcMMO instance) {
|
||||
this.plugin = instance;
|
||||
public ChangeDataValueTimer(ArrayDeque<Block> 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user