mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Some plot area restructuring
This commit is contained in:
parent
a07ed4eafd
commit
5d6f4c6668
55 changed files with 716 additions and 176 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -136,4 +136,5 @@ Nukkit/build/classes/
|
|||
Nukkit/build/dependency-cache/
|
||||
checkstyle.xml
|
||||
classes/
|
||||
p2error.txt
|
||||
p2error.txt
|
||||
*.bat
|
|
@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.object.chat.PlainChatManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SingleWorldGenerator;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.block.QueueProvider;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
|
@ -408,9 +409,14 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||
initPlotMeConverter();
|
||||
Settings.Enabled_Components.PLOTME_CONVERTER = false;
|
||||
}
|
||||
IndependentPlotGenerator result = PS.get().IMP.getDefaultGenerator();
|
||||
if (!PS.get().setupPlotWorld(world, id, result)) {
|
||||
return null;
|
||||
IndependentPlotGenerator result;
|
||||
if (id != null && id.equalsIgnoreCase("single")) {
|
||||
result = new SingleWorldGenerator();
|
||||
} else {
|
||||
result = PS.get().IMP.getDefaultGenerator();
|
||||
if (!PS.get().setupPlotWorld(world, id, result)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return (ChunkGenerator) result.specify(world);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
|||
plots.put(key, plot);
|
||||
}
|
||||
for (Plot plot : plots.values()) {
|
||||
HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.getArea().worldname);
|
||||
HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.getWorldName());
|
||||
if (mergeMap != null) {
|
||||
if (mergeMap.containsKey(plot.getId())) {
|
||||
plot.setMerged(mergeMap.get(plot.getId()));
|
||||
|
@ -174,10 +174,10 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
|||
HashMap<String, HashMap<PlotId, Plot>> processed = new HashMap<>();
|
||||
|
||||
for (Plot plot : plots.values()) {
|
||||
HashMap<PlotId, Plot> map = processed.get(plot.getArea().worldname);
|
||||
HashMap<PlotId, Plot> map = processed.get(plot.getWorldName());
|
||||
if (map == null) {
|
||||
map = new HashMap<>();
|
||||
processed.put(plot.getArea().worldname, map);
|
||||
processed.put(plot.getWorldName(), map);
|
||||
}
|
||||
map.put(plot.getId(), plot);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class PlotClearEvent extends PlotEvent implements Cancellable {
|
|||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return getPlot().getArea().worldname;
|
||||
return getPlot().getWorldName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,7 +37,7 @@ public class PlotComponentSetEvent extends PlotEvent {
|
|||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return getPlot().getArea().worldname;
|
||||
return getPlot().getWorldName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,7 +35,7 @@ public class PlotDeleteEvent extends PlotEvent {
|
|||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return getPlot().getArea().worldname;
|
||||
return getPlot().getWorldName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,17 +19,16 @@ import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
|||
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.block.GenChunk;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ import com.intellectualcrafters.plot.object.PlotId;
|
|||
import com.intellectualcrafters.plot.object.PlotInventory;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
|
@ -29,6 +31,18 @@ import com.plotsquared.bukkit.util.BukkitUtil;
|
|||
import com.plotsquared.bukkit.util.BukkitVersion;
|
||||
import com.plotsquared.listener.PlayerBlockEventType;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
@ -92,6 +106,7 @@ import org.bukkit.event.hanging.HangingPlaceEvent;
|
|||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
|
@ -100,6 +115,7 @@ import org.bukkit.event.player.PlayerEggThrowEvent;
|
|||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
@ -116,18 +132,6 @@ import org.bukkit.projectiles.BlockProjectileSource;
|
|||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Player Events involving plots.
|
||||
*
|
||||
|
@ -489,9 +493,23 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onTeleport(PlayerTeleportEvent event) {
|
||||
if (event.getTo() == null || event.getFrom() == null) {
|
||||
if (event.getTo() == null || event.getFrom() == null || !event.getFrom().getWorld().equals(event.getTo().getWorld())) {
|
||||
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location");
|
||||
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot");
|
||||
org.bukkit.Location to = event.getTo();
|
||||
if (to != null) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = PlotPlayer.wrap(player);
|
||||
Location loc = BukkitUtil.getLocation(to);
|
||||
PlotArea area = PS.get().getPlotAreaAbs(loc);
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getPlot(loc);
|
||||
if (plot != null) {
|
||||
plotEntry(pp, plot);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
playerMove(event);
|
||||
|
@ -786,15 +804,12 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||
public void onWorldChanged(PlayerChangedWorldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
||||
|
||||
// Delete last location
|
||||
pp.deleteMeta("location");
|
||||
Plot plot = (Plot) pp.deleteMeta("lastplot");
|
||||
if (plot != null) {
|
||||
plotExit(pp, plot);
|
||||
}
|
||||
|
||||
if (PS.get().worldedit != null) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_WORLDEDIT_BYPASS)) {
|
||||
if (pp.getAttribute("worldedit")) {
|
||||
|
@ -805,6 +820,15 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||
if (Settings.Enabled_Components.PERMISSION_CACHE) {
|
||||
pp.deleteMeta("perm");
|
||||
}
|
||||
Location loc = pp.getLocation();
|
||||
PlotArea area = PS.get().getPlotAreaAbs(loc);
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
plot = area.getPlot(loc);
|
||||
if (plot != null) {
|
||||
plotEntry(pp, plot);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.plotsquared.bukkit.listeners;
|
|||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -16,6 +18,14 @@ public class WorldEvents implements Listener {
|
|||
public void onWorldInit(WorldInitEvent event) {
|
||||
World world = event.getWorld();
|
||||
String name = world.getName();
|
||||
PlotAreaManager manager = PS.get().getPlotAreaManager();
|
||||
if (manager instanceof SinglePlotAreaManager) {
|
||||
SinglePlotAreaManager single = (SinglePlotAreaManager) manager;
|
||||
if (single.isWorld(name)) {
|
||||
world.setKeepSpawnInMemory(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ChunkGenerator gen = world.getGenerator();
|
||||
if (gen instanceof GeneratorWrapper) {
|
||||
PS.get().loadWorld(name, (GeneratorWrapper<?>) gen);
|
||||
|
|
|
@ -85,7 +85,7 @@ public class BukkitEventUtil extends EventUtil {
|
|||
|
||||
@Override
|
||||
public boolean callMerge(Plot plot, ArrayList<PlotId> plots) {
|
||||
return callEvent(new PlotMergeEvent(BukkitUtil.getWorld(plot.getArea().worldname), plot, plots));
|
||||
return callEvent(new PlotMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, plots));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,18 +9,20 @@ import com.intellectualcrafters.plot.object.PlotArea;
|
|||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class BukkitSetupUtils extends SetupUtils {
|
||||
|
||||
|
@ -52,6 +54,28 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload(String worldName, boolean save) {
|
||||
World world = Bukkit.getWorld(worldName);
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
World dw = Bukkit.getWorlds().get(0);
|
||||
for (Player player : world.getPlayers()) {
|
||||
player.teleport(dw.getSpawnLocation());
|
||||
}
|
||||
if (save) {
|
||||
for (Chunk chunk : world.getLoadedChunks()) {
|
||||
chunk.unload(true, false);
|
||||
}
|
||||
} else {
|
||||
for (Chunk chunk : world.getLoadedChunks()) {
|
||||
chunk.unload(false, false);
|
||||
}
|
||||
}
|
||||
Bukkit.unloadWorld(world, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String setupWorld(SetupObject object) {
|
||||
SetupUtils.manager.updateGenerators();
|
||||
|
@ -59,13 +83,13 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||
String world = object.world;
|
||||
int type = object.type;
|
||||
String worldPath = "worlds." + object.world;
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
switch (type) {
|
||||
case 2: {
|
||||
if (object.id != null) {
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
String areaName = object.id + "-" + object.min + "-" + object.max;
|
||||
String areaPath = "areas." + areaName;
|
||||
if (!worldSection.contains(areaPath)) {
|
||||
|
@ -101,7 +125,11 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 1: {
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
|
@ -116,11 +144,19 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||
object.setupGenerator = null;
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
case 0: {
|
||||
if (steps.length != 0) {
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
PS.get().worlds.save(PS.get().worldsFile);
|
||||
|
@ -147,6 +183,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||
WorldCreator wc = new WorldCreator(object.world);
|
||||
wc.generator(object.setupGenerator);
|
||||
wc.environment(Environment.NORMAL);
|
||||
wc.type(WorldType.FLAT);
|
||||
Bukkit.createWorld(wc);
|
||||
setGenerator(world, object.setupGenerator);
|
||||
} else {
|
||||
|
@ -163,7 +200,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||
return world;
|
||||
}
|
||||
}
|
||||
Bukkit.createWorld(new WorldCreator(object.world).environment(World.Environment.NORMAL));
|
||||
World bw = Bukkit.createWorld(new WorldCreator(object.world).environment(Environment.NORMAL));
|
||||
}
|
||||
return object.world;
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ import com.intellectualcrafters.plot.object.RegionWrapper;
|
|||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -80,15 +80,7 @@ public class BukkitUtil extends WorldUtil {
|
|||
}
|
||||
|
||||
public static World getWorld(String string) {
|
||||
if (StringMan.isEqual(string, lastString)) {
|
||||
if (lastWorld != null) {
|
||||
return lastWorld;
|
||||
}
|
||||
}
|
||||
World world = Bukkit.getWorld(string);
|
||||
lastString = string;
|
||||
lastWorld = world;
|
||||
return world;
|
||||
return Bukkit.getWorld(string);
|
||||
}
|
||||
|
||||
public static String getWorld(Entity entity) {
|
||||
|
@ -96,7 +88,8 @@ public class BukkitUtil extends WorldUtil {
|
|||
}
|
||||
|
||||
public static List<Entity> getEntities(String worldName) {
|
||||
return getWorld(worldName).getEntities();
|
||||
World world = getWorld(worldName);
|
||||
return world != null ? world.getEntities() : new ArrayList<Entity>();
|
||||
}
|
||||
|
||||
public static Location getLocation(Entity entity) {
|
||||
|
|
|
@ -89,7 +89,7 @@ public class SendChunk {
|
|||
Location location = null;
|
||||
String world;
|
||||
if (plot != null) {
|
||||
world = plot.getArea().worldname;
|
||||
world = plot.getWorldName();
|
||||
} else {
|
||||
location = pp.getLocation();
|
||||
world = location.getWorld();
|
||||
|
|
|
@ -30,6 +30,8 @@ import com.intellectualcrafters.plot.object.RunnableVal;
|
|||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.object.worlds.DefaultPlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotArea;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.ChatManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
|
@ -125,7 +127,6 @@ public class PS{
|
|||
*/
|
||||
public PS(IPlotMain iPlotMain, String platform) {
|
||||
PS.instance = this;
|
||||
this.manager = new DefaultPlotAreaManager();
|
||||
this.thread = Thread.currentThread();
|
||||
this.IMP = iPlotMain;
|
||||
this.logger = iPlotMain;
|
||||
|
@ -152,6 +153,13 @@ public class PS{
|
|||
MainUtil.getFile(this.IMP.getDirectory(), Settings.Paths.TRANSLATIONS + File.separator + IMP.getPluginName() + ".use_THIS.yml");
|
||||
C.load(this.translationFile);
|
||||
|
||||
// Setup manager
|
||||
if (Settings.Enabled_Components.WORLDS) {
|
||||
this.manager = new SinglePlotAreaManager();
|
||||
} else {
|
||||
this.manager = new DefaultPlotAreaManager();
|
||||
}
|
||||
|
||||
// Database
|
||||
if (Settings.Enabled_Components.DATABASE) {
|
||||
setupDatabase();
|
||||
|
@ -275,11 +283,9 @@ public class PS{
|
|||
if (world.equals("CheckingPlotSquaredGenerator")) {
|
||||
continue;
|
||||
}
|
||||
if (!WorldUtil.IMP.isWorld(world)) {
|
||||
if (!WorldUtil.IMP.isWorld(world) && !world.equals("*")) {
|
||||
debug("&c`" + world + "` was not properly loaded - " + IMP.getPluginName() + " will now try to load it properly: ");
|
||||
debug(
|
||||
"&8 - &7Are you trying to delete this world? Remember to remove it from the settings.yml, bukkit.yml and "
|
||||
+ "multiverse worlds.yml");
|
||||
debug("&8 - &7Are you trying to delete this world? Remember to remove it from the settings.yml, bukkit.yml and multiverse worlds.yml");
|
||||
debug("&8 - &7Your world management plugin may be faulty (or non existent)");
|
||||
PS.this.IMP.setGenerator(world);
|
||||
}
|
||||
|
@ -1599,6 +1605,16 @@ public class PS{
|
|||
}
|
||||
DBFunc.dbManager = new SQLManager(database, Storage.PREFIX, false);
|
||||
this.plots_tmp = DBFunc.getPlots();
|
||||
if (manager instanceof SinglePlotAreaManager) {
|
||||
SinglePlotArea area = ((SinglePlotAreaManager) manager).getArea();
|
||||
addPlotArea(area);
|
||||
ConfigurationSection section = worlds.getConfigurationSection("worlds.*");
|
||||
if (section == null) {
|
||||
section = worlds.createSection("worlds.*");
|
||||
}
|
||||
area.saveConfiguration(section);
|
||||
area.loadDefaultConfiguration(section);
|
||||
}
|
||||
this.clusters_tmp = DBFunc.getClusters();
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
PS.log(C.PREFIX + "&cFailed to open DATABASE connection. The plugin will disable itself.");
|
||||
|
|
|
@ -110,7 +110,7 @@ public class Auto extends SubCommand {
|
|||
int diff = currentPlots - player.getAllowedPlots();
|
||||
if (diff + size_x * size_z > 0) {
|
||||
if (diff < 0) {
|
||||
MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
|
||||
MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
|
||||
return false;
|
||||
} else if (player.hasPersistentMeta("grantedPlots")) {
|
||||
int grantedPlots = ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots"));
|
||||
|
@ -176,7 +176,6 @@ public class Auto extends SubCommand {
|
|||
MainUtil.sendMessage(player, C.NO_FREE_PLOTS);
|
||||
return false;
|
||||
}
|
||||
plotarea.setMeta("lastPlot", new PlotId(0, 0));
|
||||
while (true) {
|
||||
PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
|
||||
PlotId end = new PlotId(start.x + size_x - 1, start.y + size_z - 1);
|
||||
|
@ -197,7 +196,6 @@ public class Auto extends SubCommand {
|
|||
break;
|
||||
}
|
||||
}
|
||||
plotarea.setMeta("lastPlot", new PlotId(0, 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotArea;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugimportworlds",
|
||||
permission = "plots.admin",
|
||||
description = "Import worlds by player name",
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
category = CommandCategory.TELEPORT)
|
||||
public class DebugImportWorlds extends Command {
|
||||
public DebugImportWorlds() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
// UUID.nameUUIDFromBytes(("OfflinePlayer:" + player.getName()).getBytes(Charsets.UTF_8))
|
||||
PlotAreaManager pam = PS.get().getPlotAreaManager();
|
||||
if (!(pam instanceof SinglePlotAreaManager)) {
|
||||
player.sendMessage("Must be a single plot area!");
|
||||
return;
|
||||
}
|
||||
SinglePlotArea area = ((SinglePlotAreaManager) pam).getArea();
|
||||
PlotId id = new PlotId(0, 0);
|
||||
File container = PS.imp().getWorldContainer();
|
||||
for (File folder : container.listFiles()) {
|
||||
String name = folder.getName();
|
||||
if (!WorldUtil.IMP.isWorld(name) && PlotId.fromString(name) == null) {
|
||||
UUID uuid = UUIDHandler.getUUID(name, null);
|
||||
if (uuid == null) {
|
||||
uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
while (new File(container, id.toCommaSeparatedString()).exists()) {
|
||||
id = Auto.getNextPlotId(id, 1);
|
||||
}
|
||||
File newDir = new File(container, id.toCommaSeparatedString());
|
||||
if (folder.renameTo(newDir)) {
|
||||
area.getPlot(id).setOwner(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
player.sendMessage("Done!");
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
|
@ -98,7 +99,19 @@ public class Deny extends SubCommand {
|
|||
if (player.getGameMode() == PlotGameMode.SPECTATOR) {
|
||||
player.stopSpectating();
|
||||
}
|
||||
player.teleport(WorldUtil.IMP.getSpawn(player.getLocation().getWorld()));
|
||||
Location loc = player.getLocation();
|
||||
Location spawn = WorldUtil.IMP.getSpawn(loc.getWorld());
|
||||
MainUtil.sendMessage(player, C.YOU_GOT_DENIED);
|
||||
if (plot.equals(spawn.getPlot())) {
|
||||
Location newSpawn = WorldUtil.IMP.getSpawn(PS.get().getPlotAreaManager().getAllWorlds()[0]);
|
||||
if (plot.equals(newSpawn.getPlot())) {
|
||||
// Kick from server if you can't be teleported to spawn
|
||||
player.kick(C.YOU_GOT_DENIED.s());
|
||||
} else {
|
||||
player.teleport(newSpawn);
|
||||
}
|
||||
} else {
|
||||
player.teleport(spawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,6 +55,10 @@ public class Download extends SubCommand {
|
|||
return false;
|
||||
}
|
||||
if (args.length == 0 || (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "sch", "schem", "schematic"))) {
|
||||
if (plot.getVolume() > Integer.MAX_VALUE) {
|
||||
C.SCHEMATIC_TOO_LARGE.send(player);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
|
@ -78,7 +79,7 @@ public class Kick extends SubCommand {
|
|||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
||||
C.YOU_GOT_KICKED.send(player2);
|
||||
if (plot.equals(spawn.getPlot())) {
|
||||
Location newSpawn = WorldUtil.IMP.getSpawn(player2);
|
||||
Location newSpawn = WorldUtil.IMP.getSpawn(PS.get().getPlotAreaManager().getAllWorlds()[0]);
|
||||
if (plot.equals(newSpawn.getPlot())) {
|
||||
// Kick from server if you can't be teleported to spawn
|
||||
player2.kick(C.YOU_GOT_KICKED.s());
|
||||
|
|
|
@ -91,7 +91,6 @@ public class MainCommand extends Command {
|
|||
new DebugFixFlags();
|
||||
new Move();
|
||||
new Condense();
|
||||
new Condense();
|
||||
new Copy();
|
||||
new Chat();
|
||||
new Trim();
|
||||
|
@ -107,6 +106,7 @@ public class MainCommand extends Command {
|
|||
new Alias();
|
||||
new SetHome();
|
||||
new Cluster();
|
||||
new DebugImportWorlds();
|
||||
// Referenced commands
|
||||
instance.toggle = new Toggle();
|
||||
instance.help = new Help(instance);
|
||||
|
|
|
@ -65,7 +65,7 @@ public class Owner extends SetCommand {
|
|||
return false;
|
||||
}
|
||||
int size = plots.size();
|
||||
int currentPlots = (Settings.Limit.GLOBAL ? other.getPlotCount() : other.getPlotCount(plot.getArea().worldname)) + size;
|
||||
int currentPlots = (Settings.Limit.GLOBAL ? other.getPlotCount() : other.getPlotCount(plot.getWorldName())) + size;
|
||||
if (currentPlots > other.getAllowedPlots()) {
|
||||
sendMessage(player, C.CANT_TRANSFER_MORE_PLOTS);
|
||||
return false;
|
||||
|
|
|
@ -92,7 +92,7 @@ public class Purge extends SubCommand {
|
|||
}
|
||||
final HashSet<Plot> toDelete = new HashSet<>();
|
||||
for (Plot plot : PS.get().getBasePlots()) {
|
||||
if (world != null && !plot.getArea().worldname.equalsIgnoreCase(world)) {
|
||||
if (world != null && !plot.getWorldName().equalsIgnoreCase(world)) {
|
||||
continue;
|
||||
}
|
||||
if (area != null && !plot.getArea().equals(area)) {
|
||||
|
|
|
@ -146,6 +146,9 @@ public class Set extends SubCommand {
|
|||
}
|
||||
Command cmd = MainCommand.getInstance().getCommand("set" + args[0]);
|
||||
if (cmd != null) {
|
||||
if (!Permissions.hasPermission(player, cmd.getPermission(), true)) {
|
||||
return false;
|
||||
}
|
||||
cmd.execute(player, Arrays.copyOfRange(args, 1, args.length), null, null);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,6 @@ public class Settings extends Config {
|
|||
|
||||
// Web
|
||||
Web.URL = config.getString("web.url", Web.URL);
|
||||
Web.SERVER_IP = config.getString("web.server-ip", Web.SERVER_IP);
|
||||
|
||||
// Caching
|
||||
Enabled_Components.PERMISSION_CACHE = config.getBoolean("cache.permissions", Enabled_Components.PERMISSION_CACHE);
|
||||
|
@ -204,10 +203,20 @@ public class Settings extends Config {
|
|||
}
|
||||
|
||||
public static class Web {
|
||||
@Comment("We are already hosting a web interface for you:")
|
||||
@Comment({
|
||||
"The web interface for schematics",
|
||||
" - All schematics are anonymous and private",
|
||||
" - Downloads can be deleted by the user",
|
||||
" - Supports plot uploads, downloads and saves",
|
||||
})
|
||||
public static String URL = "http://empcraft.com/plots/";
|
||||
@Comment("The ip that will show up in the interface")
|
||||
public static String SERVER_IP = "your.ip.here";
|
||||
@Comment({
|
||||
"The web interface for assets",
|
||||
" - All schematics are organized and public",
|
||||
" - Assets can be searched, selected and downloaded",
|
||||
})
|
||||
public static String ASSETS = "http://empcraft.com/assetpack/";
|
||||
|
||||
}
|
||||
|
||||
public static final class Done {
|
||||
|
@ -306,6 +315,8 @@ public class Settings extends Config {
|
|||
public static boolean KILL_ROAD_VEHICLES = false;
|
||||
@Comment("Notify a player of any missed comments upon plot entry")
|
||||
public static boolean COMMENT_NOTIFIER = false;
|
||||
@Comment("Let player's claim entire worlds with PlotSquared")
|
||||
public static boolean WORLDS = false;
|
||||
@Comment("Actively purge invalid database entries")
|
||||
public static boolean DATABASE_PURGER = false;
|
||||
@Comment("Delete plots when a player is banned")
|
||||
|
|
|
@ -152,7 +152,7 @@ public class SQLManager implements AbstractDB {
|
|||
}
|
||||
} else {
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -1040,7 +1040,7 @@ public class SQLManager implements AbstractDB {
|
|||
stmt.setInt(1, plot.getId().x);
|
||||
stmt.setInt(2, plot.getId().y);
|
||||
stmt.setString(3, plot.owner.toString());
|
||||
stmt.setString(4, plot.getArea().toString());
|
||||
stmt.setString(4, plot.getArea().worldname);
|
||||
stmt.setTimestamp(5, new Timestamp(plot.getTimestamp()));
|
||||
}
|
||||
|
||||
|
|
|
@ -208,8 +208,12 @@ public class FlagManager {
|
|||
flags.put(flag.getKey(), flag.getValue());
|
||||
}
|
||||
return flags;
|
||||
} else if (flags == null) {
|
||||
return settings.flags;
|
||||
} else {
|
||||
flags.putAll(settings.flags);
|
||||
}
|
||||
return settings.flags;
|
||||
return flags;
|
||||
}
|
||||
|
||||
public static Map<Flag<?>, Object> getSettingFlags(PlotArea area, PlotSettings settings) {
|
||||
|
|
|
@ -93,7 +93,7 @@ public abstract class HybridUtils {
|
|||
}
|
||||
RegionWrapper region = zones.poll();
|
||||
final Runnable task = this;
|
||||
analyzeRegion(origin.getArea().worldname, region, new RunnableVal<PlotAnalysis>() {
|
||||
analyzeRegion(origin.getWorldName(), region, new RunnableVal<PlotAnalysis>() {
|
||||
@Override
|
||||
public void run(PlotAnalysis value) {
|
||||
analysis.add(value);
|
||||
|
@ -167,13 +167,13 @@ public abstract class HybridUtils {
|
|||
return;
|
||||
}
|
||||
RegionWrapper region = zones.poll();
|
||||
Location pos1 = new Location(plot.getArea().worldname, region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(plot.getArea().worldname, region.maxX, region.maxY, region.maxZ);
|
||||
Location pos1 = new Location(plot.getWorldName(), region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(plot.getWorldName(), region.maxX, region.maxY, region.maxZ);
|
||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||
@Override
|
||||
public void run(int[] value) {
|
||||
ChunkLoc loc = new ChunkLoc(value[0], value[1]);
|
||||
ChunkManager.manager.loadChunk(plot.getArea().worldname, loc, false);
|
||||
ChunkManager.manager.loadChunk(plot.getWorldName(), loc, false);
|
||||
int bx = value[2];
|
||||
int bz = value[3];
|
||||
int ex = value[4];
|
||||
|
@ -314,7 +314,7 @@ public abstract class HybridUtils {
|
|||
}
|
||||
|
||||
public boolean setupRoadSchematic(Plot plot) {
|
||||
final String world = plot.getArea().worldname;
|
||||
final String world = plot.getWorldName();
|
||||
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
||||
Location bot = plot.getBottomAbs().subtract(1, 0, 1);
|
||||
Location top = plot.getTopAbs();
|
||||
|
|
|
@ -31,8 +31,8 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||
Iterator<RegionWrapper> iterator = regions.iterator();
|
||||
RegionWrapper region = iterator.next();
|
||||
iterator.remove();
|
||||
Location pos1 = new Location(plot.getArea().worldname, region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(plot.getArea().worldname, region.maxX, region.maxY, region.maxZ);
|
||||
Location pos1 = new Location(plot.getWorldName(), region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(plot.getWorldName(), region.maxX, region.maxY, region.maxZ);
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, false, this);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -209,6 +209,10 @@ public class Plot {
|
|||
this.temp = temp;
|
||||
}
|
||||
|
||||
public String getWorldName() {
|
||||
return area.worldname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot from a string e.g. [area];[id]
|
||||
* @param defaultArea If no area is specified
|
||||
|
@ -771,7 +775,7 @@ public class Plot {
|
|||
@Override
|
||||
public void run() {
|
||||
for (RegionWrapper region : regions) {
|
||||
Location[] corners = region.getCorners(Plot.this.area.worldname);
|
||||
Location[] corners = region.getCorners(getWorldName());
|
||||
ChunkManager.manager.clearAllEntities(corners[0], corners[1]);
|
||||
}
|
||||
TaskManager.runTask(whenDone);
|
||||
|
@ -797,7 +801,7 @@ public class Plot {
|
|||
};
|
||||
if (!isMerged() && this.area.getRegion().equals(getLargestRegion())) {
|
||||
final LocalBlockQueue blockQueue = area.getQueue(false);
|
||||
ChunkManager.largeRegionTask(this.area.worldname, this.area.getRegion(), new RunnableVal<ChunkLoc>() {
|
||||
ChunkManager.largeRegionTask(this.getWorldName(), this.area.getRegion(), new RunnableVal<ChunkLoc>() {
|
||||
@Override
|
||||
public void run(ChunkLoc value) {
|
||||
blockQueue.regenChunk(value.x, value.z);
|
||||
|
@ -831,15 +835,15 @@ public class Plot {
|
|||
return;
|
||||
}
|
||||
RegionWrapper region = regions.poll();
|
||||
Location pos1 = new Location(Plot.this.area.worldname, region.minX - extendBiome, region.minY, region.minZ - extendBiome);
|
||||
Location pos2 = new Location(Plot.this.area.worldname, region.maxX + extendBiome, region.maxY, region.maxZ + extendBiome);
|
||||
Location pos1 = new Location(getWorldName(), region.minX - extendBiome, region.minY, region.minZ - extendBiome);
|
||||
Location pos2 = new Location(getWorldName(), region.maxX + extendBiome, region.maxY, region.maxZ + extendBiome);
|
||||
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
|
||||
@Override
|
||||
public void run(int[] value) {
|
||||
ChunkLoc loc = new ChunkLoc(value[0], value[1]);
|
||||
ChunkManager.manager.loadChunk(Plot.this.area.worldname, loc, false);
|
||||
MainUtil.setBiome(Plot.this.area.worldname, value[2], value[3], value[4], value[5], biome);
|
||||
ChunkManager.manager.unloadChunk(Plot.this.area.worldname, loc, true, true);
|
||||
ChunkManager.manager.loadChunk(getWorldName(), loc, false);
|
||||
MainUtil.setBiome(getWorldName(), value[2], value[3], value[4], value[5], biome);
|
||||
ChunkManager.manager.unloadChunk(getWorldName(), loc, true, true);
|
||||
}
|
||||
}, this, 5);
|
||||
|
||||
|
@ -916,6 +920,7 @@ public class Plot {
|
|||
* @param name
|
||||
*/
|
||||
public void setSign(final String name) {
|
||||
if (!isLoaded()) return;
|
||||
if (!PS.get().isMainThread(Thread.currentThread())) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
|
@ -934,10 +939,14 @@ public class Plot {
|
|||
C.OWNER_SIGN_LINE_2.formatted().replaceAll("%id%", id).replaceAll("%plr%", name),
|
||||
C.OWNER_SIGN_LINE_3.formatted().replaceAll("%id%", id).replaceAll("%plr%", name),
|
||||
C.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll("%plr%", name)};
|
||||
WorldUtil.IMP.setSign(this.area.worldname, loc.getX(), loc.getY(), loc.getZ(), lines);
|
||||
WorldUtil.IMP.setSign(this.getWorldName(), loc.getX(), loc.getY(), loc.getZ(), lines);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isLoaded() {
|
||||
return WorldUtil.IMP.isWorld(getWorldName());
|
||||
}
|
||||
|
||||
/**
|
||||
* This will return null if the plot hasn't been analyzed
|
||||
* @return analysis of plot
|
||||
|
@ -1118,9 +1127,13 @@ public class Plot {
|
|||
Location[] corners = getCorners();
|
||||
Location top = corners[0];
|
||||
Location bot = corners[1];
|
||||
Location loc = new Location(this.area.worldname, MathMan.average(bot.getX(), top.getX()), MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
||||
loc.setY(1 + Math.max(WorldUtil.IMP.getHighestBlock(this.area.worldname, loc.getX(), loc.getZ()),
|
||||
getManager().getSignLoc(this.area, this).getY()));
|
||||
Location loc = new Location(this.getWorldName(), MathMan.average(bot.getX(), top.getX()), MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
||||
if (!isLoaded()) return loc;
|
||||
int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), loc.getX(), loc.getZ()) : 64;
|
||||
if (area.ALLOW_SIGNS) {
|
||||
y = Math.max(y, getManager().getSignLoc(area, this).getY());
|
||||
}
|
||||
loc.setY(1 + y);
|
||||
return loc;
|
||||
}
|
||||
|
||||
|
@ -1129,8 +1142,11 @@ public class Plot {
|
|||
int x = (largest.maxX >> 1) - (largest.minX >> 1) + largest.minX;
|
||||
int z = largest.minZ - 1;
|
||||
PlotManager manager = getManager();
|
||||
int y = Math.max(WorldUtil.IMP.getHighestBlock(area.worldname, x, z), manager.getSignLoc(area, this).getY());
|
||||
return new Location(area.worldname, x, y + 1, z);
|
||||
int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), x, z) : 64;
|
||||
if (area.ALLOW_SIGNS) {
|
||||
y = Math.max(y, manager.getSignLoc(area, this).getY());
|
||||
}
|
||||
return new Location(getWorldName(), x, y + 1, z);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1144,8 +1160,9 @@ public class Plot {
|
|||
} else {
|
||||
Location bot = this.getBottomAbs();
|
||||
Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y, bot.getZ() + home.z, home.yaw, home.pitch);
|
||||
if (!isLoaded()) return loc;
|
||||
if (WorldUtil.IMP.getBlock(loc).id != 0) {
|
||||
loc.setY(Math.max(WorldUtil.IMP.getHighestBlock(this.area.worldname, loc.getX(), loc.getZ()), bot.getY()));
|
||||
loc.setY(Math.max(WorldUtil.IMP.getHighestBlock(this.getWorldName(), loc.getX(), loc.getZ()), bot.getY()));
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
|
@ -1189,8 +1206,8 @@ public class Plot {
|
|||
x = bot.getX() + this.area.DEFAULT_HOME.x;
|
||||
z = bot.getZ() + this.area.DEFAULT_HOME.z;
|
||||
}
|
||||
int y = WorldUtil.IMP.getHighestBlock(plot.area.worldname, x, z);
|
||||
return new Location(plot.area.worldname, x, y + 1, z);
|
||||
int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(plot.getWorldName(), x, z) : 64;
|
||||
return new Location(plot.getWorldName(), x, y + 1, z);
|
||||
}
|
||||
// Side
|
||||
return plot.getSide();
|
||||
|
@ -1273,7 +1290,7 @@ public class Plot {
|
|||
* This should not need to be called
|
||||
*/
|
||||
public void refreshChunks() {
|
||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(area.worldname, false);
|
||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false);
|
||||
HashSet<ChunkLoc> chunks = new HashSet<>();
|
||||
for (RegionWrapper region : Plot.this.getRegions()) {
|
||||
for (int x = region.minX >> 4; x <= region.maxX >> 4; x++) {
|
||||
|
@ -1293,7 +1310,7 @@ public class Plot {
|
|||
return;
|
||||
}
|
||||
Location loc = manager.getSignLoc(this.area, this);
|
||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(area.worldname, false);
|
||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false);
|
||||
queue.setBlock(loc.getX(), loc.getY(), loc.getZ(), 0);
|
||||
queue.flush();
|
||||
}
|
||||
|
@ -1425,7 +1442,9 @@ public class Plot {
|
|||
* @return
|
||||
*/
|
||||
public Location getTopAbs() {
|
||||
return this.area.getPlotManager().getPlotTopLocAbs(this.area, this.id);
|
||||
Location top = this.area.getPlotManager().getPlotTopLocAbs(this.area, this.id);
|
||||
top.setWorld(getWorldName());
|
||||
return top;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1433,7 +1452,9 @@ public class Plot {
|
|||
* @return
|
||||
*/
|
||||
public Location getBottomAbs() {
|
||||
return this.area.getPlotManager().getPlotBottomLocAbs(this.area, this.id);
|
||||
Location loc = this.area.getPlotManager().getPlotBottomLocAbs(this.area, this.id);
|
||||
loc.setWorld(getWorldName());
|
||||
return loc;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1552,7 +1573,7 @@ public class Plot {
|
|||
if (!this.isMerged()) {
|
||||
return new Location[]{this.getBottomAbs(), this.getTopAbs()};
|
||||
}
|
||||
return MainUtil.getCorners(this.area.worldname, this.getRegions());
|
||||
return MainUtil.getCorners(this.getWorldName(), this.getRegions());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1567,8 +1588,8 @@ public class Plot {
|
|||
Plot other = this.getRelative(1);
|
||||
Location bot = other.getBottomAbs();
|
||||
Location top = this.getTopAbs();
|
||||
Location pos1 = new Location(this.area.worldname, top.getX(), 0, bot.getZ());
|
||||
Location pos2 = new Location(this.area.worldname, bot.getX(), 256, top.getZ());
|
||||
Location pos1 = new Location(this.getWorldName(), top.getX(), 0, bot.getZ());
|
||||
Location pos2 = new Location(this.getWorldName(), bot.getX(), 256, top.getZ());
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, true, null);
|
||||
} else {
|
||||
this.area.getPlotManager().removeRoadEast(this.area, this);
|
||||
|
@ -1660,6 +1681,7 @@ public class Plot {
|
|||
return this.area + ";" + this.id.x + ";" + this.id.y;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove a denied player (use DBFunc as well)<br>
|
||||
* Using the * uuid will remove all users
|
||||
|
@ -2070,8 +2092,8 @@ public class Plot {
|
|||
Plot other = this.getRelative(2);
|
||||
Location bot = other.getBottomAbs();
|
||||
Location top = this.getTopAbs();
|
||||
Location pos1 = new Location(this.area.worldname, bot.getX(), 0, top.getZ());
|
||||
Location pos2 = new Location(this.area.worldname, top.getX(), 256, bot.getZ());
|
||||
Location pos1 = new Location(this.getWorldName(), bot.getX(), 0, top.getZ());
|
||||
Location pos2 = new Location(this.getWorldName(), top.getX(), 256, bot.getZ());
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, true, null);
|
||||
} else {
|
||||
this.getManager().removeRoadSouth(this.area, this);
|
||||
|
@ -2555,7 +2577,7 @@ public class Plot {
|
|||
int x = (int) MathMan.inverseRound(coords[0]);
|
||||
int z = (int) MathMan.inverseRound(coords[1]);
|
||||
if (type != 4) {
|
||||
locs.add(new Location(this.area.worldname, x, 0, z));
|
||||
locs.add(new Location(this.getWorldName(), x, 0, z));
|
||||
}
|
||||
}
|
||||
return locs;
|
||||
|
@ -2772,11 +2794,11 @@ public class Plot {
|
|||
}
|
||||
final Runnable task = this;
|
||||
RegionWrapper region = regions.poll();
|
||||
Location[] corners = region.getCorners(Plot.this.area.worldname);
|
||||
Location[] corners = region.getCorners(getWorldName());
|
||||
final Location pos1 = corners[0];
|
||||
final Location pos2 = corners[1];
|
||||
Location newPos = pos1.clone().add(offsetX, 0, offsetZ);
|
||||
newPos.setWorld(destination.area.worldname);
|
||||
newPos.setWorld(destination.getWorldName());
|
||||
ChunkManager.manager.copyRegion(pos1, pos2, newPos, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -2793,13 +2815,13 @@ public class Plot {
|
|||
return;
|
||||
}
|
||||
RegionWrapper region = regions.poll();
|
||||
Location[] corners = region.getCorners(Plot.this.area.worldname);
|
||||
Location[] corners = region.getCorners(getWorldName());
|
||||
Location pos1 = corners[0];
|
||||
Location pos2 = corners[1];
|
||||
Location pos3 = pos1.clone().add(offsetX, 0, offsetZ);
|
||||
Location pos4 = pos2.clone().add(offsetX, 0, offsetZ);
|
||||
pos3.setWorld(destination.area.worldname);
|
||||
pos4.setWorld(destination.area.worldname);
|
||||
pos3.setWorld(destination.getWorldName());
|
||||
pos4.setWorld(destination.getWorldName());
|
||||
ChunkManager.manager.swap(pos1, pos2, pos3, pos4, this);
|
||||
}
|
||||
};
|
||||
|
@ -2881,11 +2903,11 @@ public class Plot {
|
|||
return;
|
||||
}
|
||||
RegionWrapper region = regions.poll();
|
||||
Location[] corners = region.getCorners(Plot.this.area.worldname);
|
||||
Location[] corners = region.getCorners(getWorldName());
|
||||
Location pos1 = corners[0];
|
||||
Location pos2 = corners[1];
|
||||
Location newPos = pos1.clone().add(offsetX, 0, offsetZ);
|
||||
newPos.setWorld(destination.area.worldname);
|
||||
newPos.setWorld(destination.getWorldName());
|
||||
ChunkManager.manager.copyRegion(pos1, pos2, newPos, this);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -43,7 +43,7 @@ public abstract class PlotArea {
|
|||
public final int worldhash;
|
||||
private final PlotId min;
|
||||
private final PlotId max;
|
||||
private final ConcurrentHashMap<PlotId, Plot> plots = new ConcurrentHashMap<>();
|
||||
protected final ConcurrentHashMap<PlotId, Plot> plots = new ConcurrentHashMap<>();
|
||||
private final IndependentPlotGenerator generator;
|
||||
public int MAX_PLOT_MEMBERS = 128;
|
||||
public boolean AUTO_MERGE = false;
|
||||
|
|
|
@ -33,7 +33,7 @@ public class PlotId {
|
|||
if (string == null) {
|
||||
return null;
|
||||
}
|
||||
String[] parts = string.split(";");
|
||||
String[] parts = string.split("[;|,]");
|
||||
if (parts.length < 2) {
|
||||
return null;
|
||||
}
|
||||
|
@ -119,6 +119,12 @@ public class PlotId {
|
|||
return this.x + ";" + this.y;
|
||||
}
|
||||
|
||||
public String toCommaSeparatedString() {
|
||||
return this.x + "," + this.y;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The PlotId object caches the hashcode for faster mapping/fetching/sorting<br>
|
||||
* - Recalculation is required if the x/y values change
|
||||
|
|
|
@ -13,7 +13,6 @@ import com.intellectualcrafters.plot.util.PlotWeather;
|
|||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
|
||||
import com.plotsquared.general.commands.CommandCaller;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class DefaultPlotAreaManager implements PlotAreaManager {
|
||||
|
@ -23,7 +24,7 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
|
|||
// Optimization if there are no hash collisions
|
||||
private boolean plotAreaHasCollision = false;
|
||||
private final HashSet<Integer> plotAreaHashCheck = new HashSet<>();
|
||||
private final PlotArea[] noPlotAreas = new PlotArea[0];
|
||||
protected final PlotArea[] noPlotAreas = new PlotArea[0];
|
||||
private String[] worlds = new String[0];
|
||||
|
||||
@Override
|
||||
|
@ -222,7 +223,7 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
|
|||
if (!this.plotAreaHasCollision && !this.plotAreaHashCheck.add(worldName.hashCode())) {
|
||||
this.plotAreaHasCollision = true;
|
||||
}
|
||||
Set<String> tmp = new HashSet<>();
|
||||
Set<String> tmp = new LinkedHashSet<>();
|
||||
Collections.addAll(tmp, worlds);
|
||||
tmp.add(worldName);
|
||||
worlds = tmp.toArray(new String[tmp.size()]);
|
||||
|
@ -230,7 +231,7 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
|
|||
|
||||
@Override
|
||||
public void removeWorld(String worldName) {
|
||||
Set<String> tmp = new HashSet<>();
|
||||
Set<String> tmp = new LinkedHashSet<>();
|
||||
Collections.addAll(tmp, worlds);
|
||||
tmp.remove(worldName);
|
||||
worlds = tmp.toArray(new String[tmp.size()]);
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package com.intellectualcrafters.plot.object.worlds;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SinglePlot extends Plot {
|
||||
public SinglePlot(PlotArea area, PlotId id, UUID owner) {
|
||||
super(area, id, owner);
|
||||
}
|
||||
|
||||
public SinglePlot(PlotArea area, PlotId id) {
|
||||
super(area, id);
|
||||
}
|
||||
|
||||
public SinglePlot(PlotArea area, PlotId id, UUID owner, int temp) {
|
||||
super(area, id, owner, temp);
|
||||
}
|
||||
|
||||
public SinglePlot(PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members, HashSet<UUID> denied, String alias, BlockLoc position, Collection<Flag> flags, PlotArea area, boolean[] merged, long timestamp, int temp) {
|
||||
super(id, owner, trusted, members, denied, alias, position, flags, area, merged, timestamp, temp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
return getId().toCommaSeparatedString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SinglePlotArea getArea() {
|
||||
return (SinglePlotArea) super.getArea();
|
||||
}
|
||||
|
||||
public boolean teleportPlayer(final PlotPlayer player) {
|
||||
getArea().loadWorld(getId());
|
||||
return super.teleportPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isLoaded() {
|
||||
getArea().loadWorld(getId());
|
||||
return super.isLoaded();
|
||||
}
|
||||
// getCenter getSide getHome getDefaultHome getBiome
|
||||
}
|
|
@ -1,23 +1,116 @@
|
|||
package com.intellectualcrafters.plot.object.worlds;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.generator.GridPlotWorld;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
|
||||
public class SinglePlotArea extends PlotArea {
|
||||
public SinglePlotArea(String worldName, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||
super(worldName, id, generator, min, max);
|
||||
public class SinglePlotArea extends GridPlotWorld {
|
||||
|
||||
private final SinglePlotArea instance;
|
||||
public boolean VOID = false;
|
||||
|
||||
public SinglePlotArea() {
|
||||
super("*", null, new SingleWorldGenerator(), null, null);
|
||||
instance = this;
|
||||
this.ALLOW_SIGNS = false;
|
||||
this.DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadConfiguration(ConfigurationSection config) {
|
||||
VOID = config.getBoolean("void", false);
|
||||
}
|
||||
|
||||
public void loadWorld(PlotId id) {
|
||||
String worldName = id.toCommaSeparatedString();
|
||||
if (WorldUtil.IMP.isWorld(worldName)) return;
|
||||
SetupObject setup = new SetupObject();
|
||||
setup.plotManager = "PlotSquared:single";
|
||||
setup.setupGenerator = "PlotSquared:single";
|
||||
setup.type = 0;
|
||||
setup.terrain = 0;
|
||||
setup.step = new ConfigurationNode[0];
|
||||
setup.world = worldName;
|
||||
SetupUtils.manager.setupWorld(setup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationNode[] getSettingNodes() {
|
||||
return new ConfigurationNode[0];
|
||||
return new ConfigurationNode[] {
|
||||
new ConfigurationNode("void", this.VOID, "Void world", Configuration.BOOLEAN) };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plot getOwnedPlot(Location location) {
|
||||
PlotId pid = PlotId.fromString(location.getWorld());
|
||||
if (pid == null) {
|
||||
return null;
|
||||
}
|
||||
Plot plot = this.plots.get(pid);
|
||||
return plot == null ? null : plot.getBasePlot(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plot getOwnedPlotAbs(Location location) {
|
||||
PlotId pid = PlotId.fromString(location.getWorld());
|
||||
if (pid == null) {
|
||||
return null;
|
||||
}
|
||||
return plots.get(pid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plot getPlot(Location location) {
|
||||
PlotId pid = PlotId.fromString(location.getWorld());
|
||||
if (pid == null) {
|
||||
return null;
|
||||
}
|
||||
return getPlot(pid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plot getPlotAbs(Location location) {
|
||||
PlotId pid = PlotId.fromString(location.getWorld());
|
||||
if (pid == null) {
|
||||
return null;
|
||||
}
|
||||
return getPlotAbs(pid);
|
||||
}
|
||||
|
||||
public boolean addPlot(Plot p) {
|
||||
PlotSettings s = p.getSettings();
|
||||
p = new SinglePlot(p.getId(), p.owner, p.getTrusted(), p.getMembers(), p.getDenied(), s.alias, s.getPosition(), null, this, s.merged, p.getTimestamp(), p.temp);
|
||||
p.getSettings().flags = s.flags;
|
||||
for (PlotPlayer pp : p.getPlayersInPlot()) {
|
||||
pp.setMeta("lastplot", p);
|
||||
}
|
||||
return this.plots.put(p.getId(), p) == null;
|
||||
}
|
||||
|
||||
public Plot getPlotAbs(PlotId id) {
|
||||
Plot plot = getOwnedPlotAbs(id);
|
||||
if (plot == null) {
|
||||
return new SinglePlot(this, id);
|
||||
}
|
||||
return plot;
|
||||
}
|
||||
|
||||
public Plot getPlot(PlotId id) {
|
||||
// TODO
|
||||
Plot plot = getOwnedPlotAbs(id);
|
||||
if (plot == null) {
|
||||
return new SinglePlot(this, id);
|
||||
}
|
||||
return plot.getBasePlot(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,40 +4,90 @@ import com.intellectualcrafters.plot.object.Location;
|
|||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.ArrayUtil;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
|
||||
public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
||||
private final SinglePlotArea area;
|
||||
private final SinglePlotArea[] array;
|
||||
private PlotArea[] all;
|
||||
|
||||
public SinglePlotAreaManager(SinglePlotArea area) {
|
||||
this.area = area;
|
||||
public SinglePlotAreaManager() {
|
||||
this.area = new SinglePlotArea();
|
||||
this.array = new SinglePlotArea[] { area };
|
||||
this.all = new PlotArea[] { area };
|
||||
SetupUtils.generators.put("PlotSquared:single", new SingleWorldGenerator().specify("CheckingPlotSquaredGenerator"));
|
||||
}
|
||||
|
||||
public SinglePlotArea getArea() {
|
||||
return area;
|
||||
}
|
||||
|
||||
public boolean isWorld(String id) {
|
||||
int mode = 0;
|
||||
char[] chars = id.toCharArray();
|
||||
if (chars.length == 1 && chars[0] == '*') {
|
||||
return true;
|
||||
}
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
char c = chars[i];
|
||||
switch (mode) {
|
||||
case 0:
|
||||
mode = 1;
|
||||
if (c == '-') {
|
||||
continue;
|
||||
}
|
||||
case 1:
|
||||
if ((c <= '/') || (c >= ':')) {
|
||||
if (c == ';' || c == ',') {
|
||||
mode = 2;
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
case 2:
|
||||
mode = 3;
|
||||
if (c == '-') {
|
||||
continue;
|
||||
}
|
||||
case 3:
|
||||
if ((c <= '/') || (c >= ':')) {
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea getApplicablePlotArea(Location location) {
|
||||
PlotArea found = super.getApplicablePlotArea(location);
|
||||
return found != null ? found : area;
|
||||
if (found != null) return found;
|
||||
String world = location.getWorld();
|
||||
return isWorld(world) || world.equals("*") || super.getAllPlotAreas().length == 0 ? area : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea getPlotArea(Location location) {
|
||||
PlotArea found = super.getPlotArea(location);
|
||||
return found != null ? found : area;
|
||||
if (found != null) return found;
|
||||
return isWorld(location.getWorld()) ? area : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea getPlotArea(String world, String id) {
|
||||
PlotArea found = super.getPlotArea(world, id);
|
||||
return found != null ? found : area;
|
||||
if (found != null) return found;
|
||||
return isWorld(world) || world.equals("*") ? area : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea[] getPlotAreas(String world, RegionWrapper region) {
|
||||
PlotArea[] found = super.getPlotAreas(world, region);
|
||||
return found != null ? found : array;
|
||||
if (found != null && found.length != 0) return found;
|
||||
return isWorld(world) || world.equals("*") ? array : noPlotAreas;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,6 +102,9 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
|||
|
||||
@Override
|
||||
public void addPlotArea(PlotArea area) {
|
||||
if(area == this.area) {
|
||||
return;
|
||||
}
|
||||
super.addPlotArea(area);
|
||||
all = ArrayUtil.concatAll(super.getAllPlotAreas(), array);
|
||||
}
|
||||
|
@ -73,5 +126,4 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
|
|||
public void removeWorld(String worldName) {
|
||||
super.removeWorld(worldName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,47 +1,57 @@
|
|||
package com.intellectualcrafters.plot.object.worlds;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SinglePlotManager extends PlotManager {
|
||||
@Override
|
||||
public PlotId getPlotIdAbs(PlotArea plotArea, int x, int y, int z) {
|
||||
return null;
|
||||
return new PlotId(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotId getPlotId(PlotArea plotArea, int x, int y, int z) {
|
||||
return null;
|
||||
return new PlotId(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getPlotBottomLocAbs(PlotArea plotArea, PlotId plotId) {
|
||||
return null;
|
||||
return new Location(plotId.toCommaSeparatedString(), -30000000, 0, -30000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getPlotTopLocAbs(PlotArea plotArea, PlotId plotId) {
|
||||
return null;
|
||||
return new Location(plotId.toCommaSeparatedString(), 30000000, 0, 30000000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clearPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
||||
return false;
|
||||
SetupUtils.manager.unload(plot.getWorldName(), false);
|
||||
File worldFolder = new File(PS.get().IMP.getWorldContainer(), plot.getWorldName());
|
||||
MainUtil.deleteDirectory(worldFolder);
|
||||
if (whenDone != null) whenDone.run();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean claimPlot(PlotArea plotArea, Plot plot) {
|
||||
return false;
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
||||
return false;
|
||||
if (whenDone != null) whenDone.run();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package com.intellectualcrafters.plot.object.worlds;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
|
||||
|
||||
public class SingleWorldGenerator extends IndependentPlotGenerator {
|
||||
private Location bedrock1 = new Location(null, 0, 0, 0);
|
||||
private Location bedrock2 = new Location(null, 15, 0, 15);
|
||||
private Location dirt1 = new Location(null, 0, 1, 0);
|
||||
private Location dirt2 = new Location(null, 15, 2, 15);
|
||||
private Location grass1 = new Location(null, 0, 3, 0);
|
||||
private Location grass2 = new Location(null, 15, 3, 15);
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PlotSquared:single";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateChunk(ScopedLocalBlockQueue result, PlotArea settings, PseudoRandom random) {
|
||||
SinglePlotArea area = (SinglePlotArea) settings;
|
||||
if (area.VOID) {
|
||||
Location min = result.getMin();
|
||||
if (min.getX() == 0 && min.getZ() == 0) {
|
||||
result.setBlock(0, 0, 0, 7, 0);
|
||||
}
|
||||
} else {
|
||||
result.setCuboid(bedrock1, bedrock2, PlotBlock.get(7, 0));
|
||||
result.setCuboid(dirt1, dirt2, PlotBlock.get(3, 0));
|
||||
result.setCuboid(grass1, grass2, PlotBlock.get(2, 0));
|
||||
}
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
result.setBiome(x, z, "PLAINS");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
||||
return ((SinglePlotAreaManager) PS.get().getPlotAreaManager()).getArea();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotManager getNewPlotManager() {
|
||||
return new SinglePlotManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(PlotArea area) {
|
||||
|
||||
}
|
||||
}
|
|
@ -99,7 +99,7 @@ public class BO3Handler {
|
|||
}
|
||||
}
|
||||
for (ChunkLoc loc : chunks) {
|
||||
ChunkManager.manager.loadChunk(plot.getArea().worldname, loc, false);
|
||||
ChunkManager.manager.loadChunk(plot.getWorldName(), loc, false);
|
||||
}
|
||||
|
||||
boolean content = false;
|
||||
|
@ -115,7 +115,7 @@ public class BO3Handler {
|
|||
ChunkLoc loc = new ChunkLoc(X, Z);
|
||||
BO3 bo3 = map.get(loc);
|
||||
for (int y = 1; y < height; y++) {
|
||||
PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z));
|
||||
PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getWorldName(), x, y, z));
|
||||
if (!contains(cpw.MAIN_BLOCK, block)) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, plotworld.worldname, loc);
|
||||
|
@ -125,7 +125,7 @@ public class BO3Handler {
|
|||
bo3.addBlock(xx, y - height - 1, zz, block);
|
||||
}
|
||||
}
|
||||
PlotBlock floor = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, height, z));
|
||||
PlotBlock floor = WorldUtil.IMP.getBlock(new Location(plot.getWorldName(), x, height, z));
|
||||
if (!contains(cpw.TOP_BLOCK, floor)) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, plotworld.worldname, loc);
|
||||
|
@ -135,7 +135,7 @@ public class BO3Handler {
|
|||
bo3.addBlock(xx, -1, zz, floor);
|
||||
}
|
||||
for (int y = height + 1; y < 256; y++) {
|
||||
PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getArea().worldname, x, y, z));
|
||||
PlotBlock block = WorldUtil.IMP.getBlock(new Location(plot.getWorldName(), x, y, z));
|
||||
if (block.id != 0) {
|
||||
if (bo3 == null) {
|
||||
bo3 = new BO3(alias, plotworld.worldname, loc);
|
||||
|
@ -265,7 +265,7 @@ public class BO3Handler {
|
|||
return false;
|
||||
}
|
||||
|
||||
File base = getBaseFile(plot.getArea().worldname);
|
||||
File base = getBaseFile(plot.getWorldName());
|
||||
try {
|
||||
List<String> lines = Files.readAllLines(base.toPath(), StandardCharsets.UTF_8);
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
|
|
|
@ -119,8 +119,8 @@ public abstract class ChunkManager {
|
|||
return;
|
||||
}
|
||||
RegionWrapper value = regions.remove(0);
|
||||
Location pos1 = new Location(plot.getArea().worldname, value.minX, 0, value.minZ);
|
||||
Location pos2 = new Location(plot.getArea().worldname, value.maxX, 0, value.maxZ);
|
||||
Location pos1 = new Location(plot.getWorldName(), value.minX, 0, value.minZ);
|
||||
Location pos2 = new Location(plot.getWorldName(), value.maxX, 0, value.maxZ);
|
||||
chunkTask(pos1, pos2, task, this, allocate);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -130,7 +130,7 @@ public class MainUtil {
|
|||
}
|
||||
final URL url;
|
||||
try {
|
||||
url = new URL(Settings.Web.URL + "?key=" + uuid + "&ip=" + Settings.Web.SERVER_IP + "&type=" + extension);
|
||||
url = new URL(Settings.Web.URL + "?key=" + uuid + "&type=" + extension);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
whenDone.run();
|
||||
|
@ -720,7 +720,7 @@ public class MainUtil {
|
|||
int num = plot.getConnectedPlots().size();
|
||||
String alias = !plot.getAlias().isEmpty() ? plot.getAlias() : C.NONE.s();
|
||||
Location bot = plot.getCorners()[0];
|
||||
String biome = WorldUtil.IMP.getBiome(plot.getArea().worldname, bot.getX(), bot.getZ());
|
||||
String biome = WorldUtil.IMP.getBiome(plot.getWorldName(), bot.getX(), bot.getZ());
|
||||
String trusted = getPlayerList(plot.getTrusted());
|
||||
String members = getPlayerList(plot.getMembers());
|
||||
String denied = getPlayerList(plot.getDenied());
|
||||
|
@ -800,6 +800,23 @@ public class MainUtil {
|
|||
whenDone.run(info);
|
||||
}
|
||||
|
||||
public static boolean deleteDirectory(File directory) {
|
||||
if (directory.exists()) {
|
||||
File[] files = directory.listFiles();
|
||||
if (null != files) {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
File file = files[i];
|
||||
if (file.isDirectory()) {
|
||||
deleteDirectory(files[i]);
|
||||
} else {
|
||||
PS.debug("Deleting file: " + file + " | " + file.delete());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (directory.delete());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of names given a list of uuids.<br>
|
||||
* - Uses the format {@link C#PLOT_USER_LIST} for the returned string
|
||||
|
|
|
@ -185,14 +185,14 @@ public abstract class SchematicHandler {
|
|||
if (pw instanceof ClassicPlotWorld) {
|
||||
y_offset_actual = yOffset + ((ClassicPlotWorld) pw).PLOT_HEIGHT;
|
||||
} else {
|
||||
y_offset_actual = yOffset + MainUtil.getHeighestBlock(plot.getArea().worldname, region.minX + 1, region.minZ + 1);
|
||||
y_offset_actual = yOffset + MainUtil.getHeighestBlock(plot.getWorldName(), region.minX + 1, region.minZ + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
y_offset_actual = yOffset;
|
||||
}
|
||||
Location pos1 = new Location(plot.getArea().worldname, region.minX + xOffset, y_offset_actual, region.minZ + zOffset);
|
||||
Location pos1 = new Location(plot.getWorldName(), region.minX + xOffset, y_offset_actual, region.minZ + zOffset);
|
||||
Location pos2 = pos1.clone().add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
|
||||
// TODO switch to ChunkManager.chunkTask(pos1, pos2, task, whenDone, allocate);
|
||||
final int p1x = pos1.getX();
|
||||
|
@ -597,7 +597,7 @@ public abstract class SchematicHandler {
|
|||
public abstract void getCompoundTag(String world, Set<RegionWrapper> regions, RunnableVal<CompoundTag> whenDone);
|
||||
|
||||
public void getCompoundTag(final Plot plot, final RunnableVal<CompoundTag> whenDone) {
|
||||
getCompoundTag(plot.getArea().worldname, plot.getRegions(), new RunnableVal<CompoundTag>() {
|
||||
getCompoundTag(plot.getWorldName(), plot.getRegions(), new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run(CompoundTag value) {
|
||||
if (!plot.getFlags().isEmpty()) {
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.intellectualcrafters.plot.util;
|
|||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public abstract class SetupUtils {
|
||||
|
@ -17,4 +16,6 @@ public abstract class SetupUtils {
|
|||
public abstract String getGenerator(final PlotArea plotArea);
|
||||
|
||||
public abstract String setupWorld(final SetupObject object);
|
||||
|
||||
public abstract void unload(String world, boolean save);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.intellectualcrafters.plot.object.RunnableVal;
|
|||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
@ -91,26 +92,44 @@ public class UUIDHandler {
|
|||
}
|
||||
|
||||
public static UUID getUUID(PlotPlayer player) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getUUID(player);
|
||||
}
|
||||
|
||||
public static UUID getUUID(OfflinePlotPlayer player) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getUUID(player);
|
||||
}
|
||||
|
||||
public static String getName(UUID uuid) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getName(uuid);
|
||||
}
|
||||
|
||||
public static PlotPlayer getPlayer(UUID uuid) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getPlayer(uuid);
|
||||
}
|
||||
|
||||
public static PlotPlayer getPlayer(String name) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getPlayer(name);
|
||||
}
|
||||
|
||||
public static UUID getUUIDFromString(String nameOrUUIDString) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
if (nameOrUUIDString.length() > 16) {
|
||||
return UUID.fromString(nameOrUUIDString);
|
||||
}
|
||||
|
@ -118,18 +137,30 @@ public class UUIDHandler {
|
|||
}
|
||||
|
||||
public static UUID getUUID(String name, RunnableVal<UUID> ifFetch) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getUUID(name, ifFetch);
|
||||
}
|
||||
|
||||
public static UUID getCachedUUID(String name, RunnableVal<UUID> ifFetch) {
|
||||
if (implementation == null) {
|
||||
return null;
|
||||
}
|
||||
return implementation.getUUIDMap().get(new StringWrapper(name));
|
||||
}
|
||||
|
||||
public static Map<String, PlotPlayer> getPlayers() {
|
||||
if (implementation == null) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
return implementation.getPlayers();
|
||||
}
|
||||
|
||||
public static void handleShutdown() {
|
||||
if (implementation == null) {
|
||||
return;
|
||||
}
|
||||
implementation.handleShutdown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
|
@ -14,6 +15,7 @@ import java.io.FileInputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
@ -66,8 +68,8 @@ public abstract class WorldUtil {
|
|||
@Override
|
||||
public void run(OutputStream output) {
|
||||
try (final ZipOutputStream zos = new ZipOutputStream(output)) {
|
||||
File dat = getDat(plot.getArea().worldname);
|
||||
Location spawn = getSpawn(plot.getArea().worldname);
|
||||
File dat = getDat(plot.getWorldName());
|
||||
Location spawn = getSpawn(plot.getWorldName());
|
||||
setSpawn(home);
|
||||
byte[] buffer = new byte[1024];
|
||||
if (dat != null) {
|
||||
|
@ -87,20 +89,22 @@ public abstract class WorldUtil {
|
|||
int brz = bot.getZ() >> 9;
|
||||
int trx = top.getX() >> 9;
|
||||
int trz = top.getZ() >> 9;
|
||||
for (int x = brx; x <= trx; x++) {
|
||||
for (int z = brz; z <= trz; z++) {
|
||||
File file = getMcr(plot.getArea().worldname, x, z);
|
||||
Set<ChunkLoc> files = ChunkManager.manager.getChunkChunks(bot.getWorld());
|
||||
for (ChunkLoc mca : files) {
|
||||
if (mca.x >= brx && mca.x <= trx && mca.z >= brz && mca.z <= trz) {
|
||||
final File file = getMcr(plot.getWorldName(), mca.x, mca.z);
|
||||
if (file != null) {
|
||||
//final String name = "r." + (x - cx) + "." + (z - cz) + ".mca";
|
||||
String name = file.getName();
|
||||
ZipEntry ze = new ZipEntry("world" + File.separator + "region" + File.separator + name);
|
||||
final ZipEntry ze = new ZipEntry("world" + File.separator + "region" + File.separator + name);
|
||||
zos.putNextEntry(ze);
|
||||
FileInputStream in = new FileInputStream(file);
|
||||
final FileInputStream in = new FileInputStream(file);
|
||||
int len;
|
||||
while ((len = in.read(buffer)) > 0) {
|
||||
zos.write(buffer, 0, len);
|
||||
}
|
||||
in.close();
|
||||
zos.closeEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public class PlotClearEvent extends PlotEvent implements Cancellable {
|
|||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return getPlot().getArea().worldname;
|
||||
return getPlot().getWorldName();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class PlotComponentSetEvent extends PlotEvent {
|
|||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return getPlot().getArea().worldname;
|
||||
return getPlot().getWorldName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,7 +35,7 @@ public class PlotDeleteEvent extends PlotEvent {
|
|||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return getPlot().getArea().worldname;
|
||||
return getPlot().getWorldName();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ public class NukkitEventUtil extends EventUtil {
|
|||
|
||||
@Override
|
||||
public boolean callMerge(Plot plot, ArrayList<PlotId> plots) {
|
||||
return callEvent(new PlotMergeEvent(NukkitUtil.getWorld(plot.getArea().worldname), plot, plots));
|
||||
return callEvent(new PlotMergeEvent(NukkitUtil.getWorld(plot.getWorldName()), plot, plots));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,11 @@ public class NukkitSetupUtils extends SetupUtils {
|
|||
Generator.addGenerator(NukkitHybridGen.class, "PlotSquared", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload(String world, boolean save) {
|
||||
plugin.getServer().unloadLevel(plugin.getServer().getLevelByName(world), save);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGenerators() {
|
||||
if (!SetupUtils.generators.isEmpty()) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class PlotClearEvent extends AbstractEvent implements Cancellable {
|
|||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return this.plot.getArea().worldname;
|
||||
return this.plot.getWorldName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,7 +36,7 @@ public class PlotComponentSetEvent extends AbstractEvent {
|
|||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return this.plot.getArea().worldname;
|
||||
return this.plot.getWorldName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ public class PlotDeleteEvent extends AbstractEvent {
|
|||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return plot.getArea().worldname;
|
||||
return plot.getWorldName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -81,7 +81,7 @@ public class SpongeEventUtil extends EventUtil {
|
|||
|
||||
@Override
|
||||
public boolean callMerge(Plot plot, ArrayList<PlotId> plots) {
|
||||
return callEvent(new PlotMergeEvent(SpongeUtil.getWorld(plot.getArea().worldname), plot, plots));
|
||||
return callEvent(new PlotMergeEvent(SpongeUtil.getWorld(plot.getWorldName()), plot, plots));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -47,6 +47,14 @@ public class SpongeSetupUtils extends SetupUtils {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload(String worldName, boolean safe) {
|
||||
Optional<World> world = Sponge.getServer().getWorld(worldName);
|
||||
if (world.isPresent()) {
|
||||
Sponge.getServer().unloadWorld(world.get());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGenerator(PlotArea plotArea) {
|
||||
if (SetupUtils.generators.isEmpty()) {
|
||||
|
|
Loading…
Reference in a new issue