Use sign with plot schematic
Tweak world unloading
This commit is contained in:
Jesse Boyd
2017-09-24 00:13:05 +10:00
parent 2360782234
commit 92f94ecedc
7 changed files with 98 additions and 12 deletions

View File

@ -200,7 +200,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
public void run() {
unload();
}
}, 20);
}, 5);
}
}
@ -211,19 +211,26 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
SinglePlotArea area = ((SinglePlotAreaManager) manager).getArea();
for (World world : Bukkit.getWorlds()) {
String name = world.getName();
char char0 = name.charAt(0);
if (!Character.isDigit(char0) && char0 != '-') continue;
if (!world.getPlayers().isEmpty()) continue;
PlotId id = PlotId.fromString(name);
if (id != null) {
Plot plot = area.getOwnedPlot(id);
if (plot != null) {
List<PlotPlayer> players = plot.getPlayersInPlot();
if (players.isEmpty() && PlotPlayer.wrap(plot.owner) == null) {
for (Chunk chunk : world.getLoadedChunks()) {
if (!chunk.unload(true, false)) return;
if (System.currentTimeMillis() - start > 20) {
return;
}
if (PlotPlayer.wrap(plot.owner) == null) {
if (world.getKeepSpawnInMemory()) {
world.setKeepSpawnInMemory(false);
return;
}
Chunk[] chunks = world.getLoadedChunks();
if (chunks.length == 0) {
if (!Bukkit.unloadWorld(world, true)) {
PS.debug("Failed to unload " + world.getName());
}
return;
}
Bukkit.unloadWorld(world, true);
}
}
}

View File

@ -119,7 +119,15 @@ public class BukkitUtil extends WorldUtil {
World world = getWorld(worldName);
Block block = world.getBlockAt(x, y, z);
// block.setType(Material.AIR);
block.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false);
Material type = block.getType();
if (type != Material.SIGN && type != Material.SIGN_POST) {
int data = 2;
if (world.getBlockAt(x, y, z + 1).getType().isSolid()) data = 2;
else if (world.getBlockAt(x + 1, y, z).getType().isSolid()) data = 4;
else if (world.getBlockAt(x, y, z - 1).getType().isSolid()) data = 3;
else if (world.getBlockAt(x - 1, y, z).getType().isSolid()) data = 5;
block.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) data, false);
}
BlockState blockstate = block.getState();
if (blockstate instanceof Sign) {
final Sign sign = (Sign) blockstate;