mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
2.8.7: Plot home sorting, critical world init fix, piston fix
This commit is contained in:
parent
e6fc6e070e
commit
0c3b084f73
@ -8,7 +8,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>2.8.4</version>
|
||||
<version>2.8.7</version>
|
||||
<name>PlotSquared</name>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
|
@ -198,6 +198,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
|
||||
PlotSquared.GEN_WORLD = world;
|
||||
if (!PlotSquared.setupPlotWorld(world, id)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -72,6 +72,7 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
public class PlotSquared {
|
||||
public static final String MAIN_PERMISSION = "plots.use";
|
||||
public static final String ADMIN_PERMISSION = "plots.admin";
|
||||
public static String GEN_WORLD = "__PLACEHOLDER__";
|
||||
public static File styleFile;
|
||||
public static YamlConfiguration style;
|
||||
public static File configFile;
|
||||
|
@ -20,6 +20,8 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -46,11 +48,11 @@ public class Home extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(final PlotPlayer plr, String... args) {
|
||||
final Plot[] plots = PlotSquared.getPlots(plr).toArray(new Plot[0]);
|
||||
if (plots.length == 1) {
|
||||
MainUtil.teleportPlayer(plr, plr.getLocation(), plots[0]);
|
||||
final ArrayList<Plot> plots = PlotSquared.sortPlots(PlotSquared.getPlots(plr), plr.getLocation().getWorld());
|
||||
if (plots.size() == 1) {
|
||||
MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0));
|
||||
return true;
|
||||
} else if (plots.length > 1) {
|
||||
} else if (plots.size() > 1) {
|
||||
if (args.length < 1) {
|
||||
args = new String[] { "1" };
|
||||
}
|
||||
@ -72,11 +74,11 @@ public class Home extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||
return true;
|
||||
}
|
||||
if ((id > (plots.length)) || (id < 1)) {
|
||||
if ((id > (plots.size())) || (id < 1)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||
return false;
|
||||
}
|
||||
MainUtil.teleportPlayer(plr, plr.getLocation(), plots[id - 1]);
|
||||
MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(id - 1));
|
||||
return true;
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOTS);
|
||||
|
@ -55,7 +55,7 @@ public class Visit extends SubCommand {
|
||||
final UUID uuid = UUIDHandler.getUUID(username);
|
||||
List<Plot> plots = null;
|
||||
if (uuid != null) {
|
||||
plots = getPlots(uuid);
|
||||
plots = PlotSquared.sortPlots(getPlots(uuid), plr.getLocation().getWorld());
|
||||
}
|
||||
if ((uuid == null) || plots.isEmpty()) {
|
||||
return sendMessage(plr, C.FOUND_NO_PLOTS);
|
||||
|
@ -347,7 +347,6 @@ public class FlagManager {
|
||||
split = flagstrings.get(i).split(":");
|
||||
}
|
||||
if (split.length == 1) {
|
||||
System.out.print(split[0]);
|
||||
flags[i] = new Flag(getFlag(split[0], true), "");
|
||||
} else {
|
||||
flags[i] = new Flag(getFlag(split[0], true), split[1]);
|
||||
|
@ -115,12 +115,14 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
if (LAST == 0) {
|
||||
LAST = System.currentTimeMillis();
|
||||
}
|
||||
AV = (System.currentTimeMillis() - LAST + AV) / 2;
|
||||
if (AV < 1050) {
|
||||
long current = System.currentTimeMillis() - LAST;
|
||||
AV = Math.max(current, (current + AV * 5) / 6);
|
||||
LAST = System.currentTimeMillis();
|
||||
if (AV < 1500) {
|
||||
try {
|
||||
final ChunkLoc loc = chunks.get(0);
|
||||
PlotSquared.log("Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 256 chunks)");
|
||||
PlotSquared.log("Remaining regions: " + chunks.size());
|
||||
PlotSquared.log("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)");
|
||||
PlotSquared.log(" - Remaining: " + chunks.size());
|
||||
regenerateChunkChunk(world, loc);
|
||||
chunks.remove(0);
|
||||
} catch (final Exception e) {
|
||||
@ -133,14 +135,16 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
ChunkManager.manager.unloadChunk(world, new ChunkLoc(x, z));
|
||||
}
|
||||
}
|
||||
PlotSquared.log("&d - Potentially skipping 256 chunks");
|
||||
PlotSquared.log("&d - Potentially skipping 1024 chunks");
|
||||
PlotSquared.log("&d - TODO: recommend chunkster if corrupt");
|
||||
}
|
||||
}
|
||||
else {
|
||||
System.out.print("TPS LOW: " + (System.currentTimeMillis() - LAST) + " | " + AV);
|
||||
double tps = (20000.0/Math.min(AV, current));
|
||||
if (tps < 19) {
|
||||
System.out.print("waiting for chunks to unload...");
|
||||
}
|
||||
}
|
||||
LAST = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}, 20, 20);
|
||||
|
@ -32,6 +32,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
@ -88,9 +89,6 @@ public class HybridGen extends PlotGenerator {
|
||||
* Initialize variables, and create plotworld object used in calculations
|
||||
*/
|
||||
public void init(PlotWorld plotworld) {
|
||||
if (this.plotworld == null) {
|
||||
this.plotworld = (HybridPlotWorld) plotworld;
|
||||
}
|
||||
this.plotsize = this.plotworld.PLOT_WIDTH;
|
||||
this.pathsize = this.plotworld.ROAD_WIDTH;
|
||||
this.roadblock = this.plotworld.ROAD_BLOCK.id;
|
||||
@ -198,24 +196,7 @@ public class HybridGen extends PlotGenerator {
|
||||
/**
|
||||
* Return the block populator
|
||||
*/
|
||||
public List<BlockPopulator> getPopulators(final World world) {
|
||||
// disabling spawning for this world
|
||||
if (!this.plotworld.MOB_SPAWNING) {
|
||||
if (!this.plotworld.SPAWN_EGGS) {
|
||||
world.setSpawnFlags(false, false);
|
||||
}
|
||||
world.setAmbientSpawnLimit(0);
|
||||
world.setAnimalSpawnLimit(0);
|
||||
world.setMonsterSpawnLimit(0);
|
||||
world.setWaterAnimalSpawnLimit(0);
|
||||
}
|
||||
else {
|
||||
world.setSpawnFlags(true, true);
|
||||
world.setAmbientSpawnLimit(-1);
|
||||
world.setAnimalSpawnLimit(-1);
|
||||
world.setMonsterSpawnLimit(-1);
|
||||
world.setWaterAnimalSpawnLimit(-1);
|
||||
}
|
||||
public List<BlockPopulator> getPopulators(final String world) {
|
||||
// You can have as many populators as you would like, e.g. tree
|
||||
// populator, ore populator
|
||||
return Arrays.asList((BlockPopulator) new HybridPop(this.plotworld));
|
||||
|
@ -541,7 +541,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
if (block.getType() != Material.PISTON_STICKY_BASE) {
|
||||
if (block.getType() != Material.PISTON_STICKY_BASE && block.getType() != Material.PISTON_MOVING_PIECE) {
|
||||
return;
|
||||
}
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
|
@ -21,7 +21,10 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
@ -29,13 +32,32 @@ import org.bukkit.generator.ChunkGenerator;
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
|
||||
public abstract class PlotGenerator extends ChunkGenerator {
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getDefaultPopulators(World world) {
|
||||
PlotSquared.loadWorld(world.getName(), this);
|
||||
return getPopulators(world);
|
||||
PlotSquared.loadWorld(PlotSquared.GEN_WORLD, this);
|
||||
// world = Bukkit.getWorld(PlotSquared.GEN_WORLD);
|
||||
PlotWorld plotworld = PlotSquared.getPlotWorld(PlotSquared.GEN_WORLD);
|
||||
if (!plotworld.MOB_SPAWNING) {
|
||||
if (!plotworld.SPAWN_EGGS) {
|
||||
world.setSpawnFlags(false, false);
|
||||
}
|
||||
world.setAmbientSpawnLimit(0);
|
||||
world.setAnimalSpawnLimit(0);
|
||||
world.setMonsterSpawnLimit(0);
|
||||
world.setWaterAnimalSpawnLimit(0);
|
||||
}
|
||||
else {
|
||||
world.setSpawnFlags(true, true);
|
||||
world.setAmbientSpawnLimit(-1);
|
||||
world.setAnimalSpawnLimit(-1);
|
||||
world.setMonsterSpawnLimit(-1);
|
||||
world.setWaterAnimalSpawnLimit(-1);
|
||||
}
|
||||
return getPopulators(PlotSquared.GEN_WORLD);
|
||||
}
|
||||
|
||||
public abstract List<BlockPopulator> getPopulators(World world);
|
||||
public abstract List<BlockPopulator> getPopulators(String world);
|
||||
|
||||
public abstract void init(PlotWorld plotworld);
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
package com.intellectualcrafters.plot.util.bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
@ -13,6 +16,7 @@ import com.intellectualcrafters.plot.object.BukkitOfflinePlayer;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
|
||||
@ -86,17 +90,7 @@ public class UUIDHandler {
|
||||
PlotSquared.log(C.PREFIX.s() + "&6Starting player data caching");
|
||||
UUIDHandler.CACHED = true;
|
||||
|
||||
for (OfflinePlotPlayer op : uuidWrapper.getOfflinePlayers()) {
|
||||
if (op.getLastPlayed() != 0) {
|
||||
String name = op.getName();
|
||||
StringWrapper wrap = new StringWrapper(name);
|
||||
UUID uuid = uuidWrapper.getUUID(op);
|
||||
add(wrap, uuid);
|
||||
}
|
||||
}
|
||||
|
||||
// OLD UUID CACHING SYSTEM
|
||||
/*
|
||||
final HashSet<String> worlds = new HashSet<>();
|
||||
worlds.add(world);
|
||||
worlds.add("world");
|
||||
@ -139,7 +133,7 @@ public class UUIDHandler {
|
||||
final UUIDWrapper wrapper = new DefaultUUIDWrapper();
|
||||
for (UUID uuid : uuids) {
|
||||
try {
|
||||
final BukkitOfflinePlayer player = wrapper.getOfflinePlayer(uuid);
|
||||
final OfflinePlotPlayer player = wrapper.getOfflinePlayer(uuid);
|
||||
uuid = UUIDHandler.uuidWrapper.getUUID(player);
|
||||
final StringWrapper name = new StringWrapper(player.getName());
|
||||
add(name, uuid);
|
||||
@ -152,8 +146,18 @@ public class UUIDHandler {
|
||||
final StringWrapper nameWrap = new StringWrapper(name);
|
||||
add(nameWrap, uuid);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
if (uuidMap.size() == 0) {
|
||||
for (OfflinePlotPlayer op : uuidWrapper.getOfflinePlayers()) {
|
||||
if (op.getLastPlayed() != 0) {
|
||||
String name = op.getName();
|
||||
StringWrapper wrap = new StringWrapper(name);
|
||||
UUID uuid = uuidWrapper.getUUID(op);
|
||||
add(wrap, uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
// add the Everyone '*' UUID
|
||||
add(new StringWrapper("*"), DBFunc.everyone);
|
||||
PlotSquared.log(C.PREFIX.s() + "&6Cached a total of: " + UUIDHandler.uuidMap.size() + " UUIDs");
|
||||
|
Loading…
Reference in New Issue
Block a user