[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:
parent
f898e1f00c
commit
4367e3a36a
2
README
2
README
@ -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]
|
||||
|
28
src/net/TheDgtl/Stargate/BloxPopulator.java
Normal file
28
src/net/TheDgtl/Stargate/BloxPopulator.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user