[Version 0.7.6]

- Moved gate opening/closing to a Queue/Runnable system to resolve
server lag issues with very large gates
This commit is contained in:
Steven Scott 2012-03-10 16:17:29 -08:00
parent f898e1f00c
commit 4367e3a36a
5 changed files with 52 additions and 3 deletions

2
README
View File

@ -202,6 +202,8 @@ createConflict=Gate conflicts with existing gate
=============
Changes
=============
[Version 0.7.6]
- Moved gate opening/closing to a Queue/Runnable system to resolve server lag issues with very large gates
[Version 0.7.5.11]
- PEX now returns accurate results without requiring use of the bridge.
[Version 0.7.5.10]

View File

@ -0,0 +1,28 @@
package net.TheDgtl.Stargate;
public class BloxPopulator {
private Blox blox;
private int nextMat;
public BloxPopulator(Blox b, int m) {
blox = b;
nextMat = m;
}
public void setBlox(Blox b) {
blox = b;
}
public void setMat(int m) {
nextMat = m;
}
public Blox getBlox() {
return blox;
}
public int getMat() {
return nextMat;
}
}

View File

@ -320,8 +320,9 @@ public class Portal {
getWorld().loadChunk(getWorld().getChunkAt(topLeft.getBlock()));
int openType = gate.getPortalBlockOpen();
for (Blox inside : getEntrances()) {
inside.setType(gate.getPortalBlockOpen());
Stargate.blockPopulatorQueue.add(new BloxPopulator(inside, openType));
}
isOpen = true;
@ -356,8 +357,9 @@ public class Portal {
if (isAlwaysOn() && !force) return; // Only close always-open if forced
// Close this gate, then the dest gate.
int closedType = gate.getPortalBlockClosed();
for (Blox inside : getEntrances()) {
inside.setType(gate.getPortalBlockClosed());
Stargate.blockPopulatorQueue.add(new BloxPopulator(inside, closedType));
}
player = null;

View File

@ -2,6 +2,8 @@ package net.TheDgtl.Stargate;
import java.io.File;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -103,6 +105,9 @@ public class Stargate extends JavaPlugin {
public static ConcurrentLinkedQueue<Portal> openList = new ConcurrentLinkedQueue<Portal>();
public static ConcurrentLinkedQueue<Portal> activeList = new ConcurrentLinkedQueue<Portal>();
// Used for populating gate open/closed material.
public static Queue<BloxPopulator> blockPopulatorQueue = new LinkedList<BloxPopulator>();
public void onDisable() {
Portal.closeAllGates();
Portal.clearGates();
@ -152,6 +157,7 @@ public class Stargate extends JavaPlugin {
}
getServer().getScheduler().scheduleSyncRepeatingTask(this, new SGThread(), 0L, 100L);
getServer().getScheduler().scheduleSyncRepeatingTask(this, new BlockPopulatorThread(), 0L, 1L);
}
public void loadConfig() {
@ -1129,6 +1135,17 @@ public class Stargate extends JavaPlugin {
}
}
private class BlockPopulatorThread implements Runnable {
public void run() {
long sTime = System.nanoTime();
while (System.nanoTime() - sTime < 50000000) {
BloxPopulator b = Stargate.blockPopulatorQueue.poll();
if (b == null) return;
b.getBlox().getBlock().setTypeId(b.getMat());
}
}
}
private class SGThread implements Runnable {
public void run() {
long time = System.currentTimeMillis() / 1000;

View File

@ -1,6 +1,6 @@
name: Stargate
main: net.TheDgtl.Stargate.Stargate
version: 0.7.5.11
version: 0.7.6.0
description: Stargate mod for Bukkit
author: Drakia
website: http://www.thedgtl.net