mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 20:56:45 +01:00
Squashed commit of the following:
commit91c78407cd
Author: Jesse Boyd <jessepaleg@gmail.com> Date: Sun Aug 7 11:29:59 2016 +1000 Use a queue for expiry commit395d6364be
Author: Jesse Boyd <jessepaleg@gmail.com> Date: Sun Aug 7 04:43:41 2016 +1000 Cache on fail as well commitfacd43700d
Author: Jesse Boyd <jessepaleg@gmail.com> Date: Sun Aug 7 04:00:50 2016 +1000 Cache entity count every second commit1ae694ff5b
Author: Jesse Boyd <jessepaleg@gmail.com> Date: Sun Aug 7 03:52:37 2016 +1000 Tweak entity counting commitc99dd1e74a
Author: Jesse Boyd <jessepaleg@gmail.com> Date: Sat Aug 6 00:10:11 2016 +1000 Needs sponge builds commitf408ac82be
Author: Alexander Söderberg <Sauilitired@users.noreply.github.com> Date: Fri Aug 5 12:13:39 2016 +0200 Update README.md commit9b95990ba6
Author: Alexander Söderberg <Sauilitired@users.noreply.github.com> Date: Thu Aug 4 16:50:37 2016 +0200 Update this here as well
This commit is contained in:
parent
77fb329c9e
commit
112da17614
@ -1,7 +1,7 @@
|
||||
repositories {
|
||||
maven {url "https://hub.spigotmc.org/nexus/content/groups/public/"}
|
||||
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/"}
|
||||
maven {url "http://nexus.theyeticave.net/content/repositories/pub_releases"}
|
||||
maven {url "http://nexus.hc.to/content/repositories/pub_releases"}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -39,4 +39,4 @@ shadowJar.doLast {
|
||||
ant.checksum file: task.archivePath
|
||||
}
|
||||
|
||||
build.dependsOn(shadowJar);
|
||||
build.dependsOn(shadowJar);
|
||||
|
@ -22,6 +22,9 @@ public class EntitySpawnListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlotAbs(location);
|
||||
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
switch (entity.getType()) {
|
||||
case ENDER_CRYSTAL:
|
||||
if (plot == null) {
|
||||
@ -34,8 +37,5 @@ public class EntitySpawnListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1408,13 +1408,48 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (cap == Integer.MAX_VALUE) {
|
||||
continue;
|
||||
}
|
||||
if (cap == 0) {
|
||||
return true;
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = plot.countEntities();
|
||||
}
|
||||
if (mobs[i] >= cap) {
|
||||
plot.setMeta("EntityCount", mobs);
|
||||
plot.setMeta("EntityCountTime", System.currentTimeMillis());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (mobs != null) {
|
||||
for (IntegerFlag flag : flags) {
|
||||
int i;
|
||||
switch (flag.getName()) {
|
||||
case "entity-cap":
|
||||
i = 0;
|
||||
break;
|
||||
case "mob-cap":
|
||||
i = 3;
|
||||
break;
|
||||
case "hostile-cap":
|
||||
i = 2;
|
||||
break;
|
||||
case "animal-cap":
|
||||
i = 1;
|
||||
break;
|
||||
case "vehicle-cap":
|
||||
i = 4;
|
||||
break;
|
||||
case "misc-cap":
|
||||
i = 5;
|
||||
break;
|
||||
default:
|
||||
i = 0;
|
||||
}
|
||||
mobs[i]++;
|
||||
}
|
||||
plot.setMeta("EntityCount", mobs);
|
||||
plot.setMeta("EntityCountTime", System.currentTimeMillis());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -425,6 +425,10 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
|
||||
@Override
|
||||
public int[] countEntities(Plot plot) {
|
||||
int[] existing = (int[]) plot.getMeta("EntityCount");
|
||||
if (existing != null && (System.currentTimeMillis() - (long) plot.getMeta("EntityCountTime") < 1000)) {
|
||||
return existing;
|
||||
}
|
||||
PlotArea area = plot.getArea();
|
||||
World world = BukkitUtil.getWorld(area.worldname);
|
||||
|
||||
@ -449,9 +453,9 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
|
||||
boolean doWhole = false;
|
||||
List<Entity> entities = null;
|
||||
if (size > 200) {
|
||||
if (size > 200 && chunks.size() > 200) {
|
||||
entities = world.getEntities();
|
||||
if (entities.size() < 16 + size * size / 64) {
|
||||
if (entities.size() < 16 + size / 8) {
|
||||
doWhole = true;
|
||||
}
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ public class GlobalBlockQueue {
|
||||
if (this.runnables.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
final ConcurrentLinkedDeque<Runnable> tmp = new ConcurrentLinkedDeque<>(this.runnables);
|
||||
final ArrayList<Runnable> tmp = new ArrayList<>(this.runnables);
|
||||
this.runnables.clear();
|
||||
for (final Runnable runnable : tmp) {
|
||||
runnable.run();
|
||||
|
@ -18,7 +18,6 @@ import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -26,9 +25,9 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
|
||||
public class ExpireManager {
|
||||
|
||||
@ -217,7 +216,7 @@ public class ExpireManager {
|
||||
return false;
|
||||
}
|
||||
this.running = 2;
|
||||
final Set<Plot> plots = PS.get().getPlots();
|
||||
final ConcurrentLinkedDeque<Plot> plots = new ConcurrentLinkedDeque<Plot>(PS.get().getPlots());
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -226,14 +225,12 @@ public class ExpireManager {
|
||||
return;
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
Iterator<Plot> iterator = plots.iterator();
|
||||
while (iterator.hasNext() && System.currentTimeMillis() - start < 2) {
|
||||
while (!plots.isEmpty()) {
|
||||
if (ExpireManager.this.running != 2) {
|
||||
ExpireManager.this.running = 0;
|
||||
return;
|
||||
}
|
||||
final Plot plot = iterator.next();
|
||||
iterator.remove();
|
||||
final Plot plot = plots.poll();
|
||||
PlotArea area = plot.getArea();
|
||||
final ArrayDeque<ExpiryTask> applicable = new ArrayDeque<>(tasks);
|
||||
final Collection<ExpiryTask> expired = isExpired(applicable, plot);
|
||||
@ -242,7 +239,13 @@ public class ExpireManager {
|
||||
}
|
||||
for (ExpiryTask expiryTask : expired) {
|
||||
if (!expiryTask.needsAnalysis()) {
|
||||
expiredTask.run(plot, this, expiryTask.requiresConfirmation());
|
||||
expiredTask.run(plot, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.IMP.taskLaterAsync(this, 1);
|
||||
}
|
||||
}, expiryTask.requiresConfirmation());
|
||||
return;
|
||||
}
|
||||
}
|
||||
final Runnable task = this;
|
||||
@ -252,7 +255,12 @@ public class ExpireManager {
|
||||
passesComplexity(changed, expired, new RunnableVal<Boolean>() {
|
||||
@Override
|
||||
public void run(Boolean confirmation) {
|
||||
expiredTask.run(plot, task, confirmation);
|
||||
expiredTask.run(plot, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TaskManager.IMP.taskLaterAsync(task, 1);
|
||||
}
|
||||
}, confirmation);
|
||||
}
|
||||
}, new Runnable() {
|
||||
@Override
|
||||
@ -280,7 +288,7 @@ public class ExpireManager {
|
||||
}, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
task.run();
|
||||
TaskManager.IMP.taskLaterAsync(task, 1);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -17,7 +17,7 @@ is to provide a lag-free and smooth experience.
|
||||
|
||||
### Developer Resources
|
||||
* [JavaDocs] Link Temporarily Unavailable
|
||||
* [Build Server] Link Temporarily Unavailable
|
||||
* [Build Server] [![Build Status](http://ci.plotsquared.com/buildStatus/icon?job=PlotSquared)](http://ci.athion.net/job/PlotSquared/)
|
||||
* [Maven Repo] Link Temporarily Unavailable
|
||||
|
||||
# Building
|
||||
|
Loading…
Reference in New Issue
Block a user