mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
World border
This commit is contained in:
parent
c8d396a1a5
commit
a29484a825
@ -928,22 +928,19 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
sendConsoleSenderMessage(C.PREFIX.s() + "&3 - plotworld: &7" + plotWorld.getClass().getName());
|
||||
sendConsoleSenderMessage(C.PREFIX.s() + "&3 - manager: &7" + plotManager.getClass().getName());
|
||||
}
|
||||
|
||||
if (!config.contains(path)) {
|
||||
config.createSection(path);
|
||||
}
|
||||
|
||||
plotWorld.saveConfiguration(config.getConfigurationSection(path));
|
||||
plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path));
|
||||
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Now add it
|
||||
addPlotWorld(world, plotWorld, plotManager);
|
||||
PlotHelper.setupBorder(world);
|
||||
} else {
|
||||
if (worlds.contains(world)) {
|
||||
sendConsoleSenderMessage("&cWorld '" + world + "' in settings.yml is not using PlotSquared generator!");
|
||||
|
@ -37,6 +37,10 @@ import com.intellectualsites.translation.bukkit.BukkitTranslation;
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public enum C {
|
||||
/*
|
||||
* Border
|
||||
*/
|
||||
BORDER("&cYou are outside the current map border"),
|
||||
/*
|
||||
* Unclaim
|
||||
*/
|
||||
|
@ -93,7 +93,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
* @author Citymonstret
|
||||
* @author Empire92
|
||||
*/
|
||||
@SuppressWarnings("unused") public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener {
|
||||
public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public static void onWorldLoad(final WorldLoadEvent event) {
|
||||
@ -136,6 +136,24 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
if (!isPlotWorld(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
String worldname = q.getWorld().getName();
|
||||
if (PlotHelper.worldBorder.containsKey(worldname)) {
|
||||
int border = PlotHelper.worldBorder.get(worldname);
|
||||
boolean passed = false;
|
||||
if (t.getBlockX() >= border) {
|
||||
q.setX(border);
|
||||
passed = true;
|
||||
}
|
||||
if (t.getBlockZ() >= border) {
|
||||
q.setZ(border);
|
||||
passed = true;
|
||||
}
|
||||
if (passed) {
|
||||
event.setTo(q);
|
||||
PlayerFunctions.sendMessage(player, C.BORDER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (enteredPlot(f, q)) {
|
||||
final Plot plot = getCurrentPlot(q);
|
||||
final boolean admin = PlotMain.hasPermission(player, "plots.admin.entry.denied");
|
||||
|
@ -58,6 +58,7 @@ public abstract class PlotWorld {
|
||||
public final static boolean SPAWN_EGGS_DEFAULT = false;
|
||||
public final static boolean SPAWN_CUSTOM_DEFAULT = true;
|
||||
public final static boolean SPAWN_BREEDING_DEFAULT = false;
|
||||
public final static boolean WORLD_BORDER_DEFAULT = false;
|
||||
// TODO make this configurable
|
||||
// make non static and static_default_valu + add config option
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -285,6 +286,7 @@ public abstract class PlotWorld {
|
||||
public boolean SPAWN_EGGS;
|
||||
public boolean SPAWN_CUSTOM;
|
||||
public boolean SPAWN_BREEDING;
|
||||
public boolean WORLD_BORDER;
|
||||
|
||||
public PlotWorld(final String worldname) {
|
||||
this.worldname = worldname;
|
||||
@ -308,6 +310,7 @@ public abstract class PlotWorld {
|
||||
this.MERGE_PRICE = config.getDouble("economy.prices.merge");
|
||||
this.SELL_PRICE = config.getDouble("economy.prices.sell");
|
||||
this.PLOT_CHAT = config.getBoolean("chat.enabled");
|
||||
this.WORLD_BORDER = config.getBoolean("world.border");
|
||||
List<String> flags = config.getStringList("flags.default");
|
||||
if (flags == null) {
|
||||
this.DEFAULT_FLAGS = new Flag[] {};
|
||||
@ -357,6 +360,7 @@ public abstract class PlotWorld {
|
||||
options.put("event.spawn.egg", PlotWorld.SPAWN_EGGS_DEFAULT);
|
||||
options.put("event.spawn.custom", PlotWorld.SPAWN_CUSTOM_DEFAULT);
|
||||
options.put("event.spawn.breeding", PlotWorld.SPAWN_BREEDING_DEFAULT);
|
||||
options.put("world.border", PlotWorld.WORLD_BORDER_DEFAULT);
|
||||
final ConfigurationNode[] settings = getSettingNodes();
|
||||
/*
|
||||
* Saving generator specific settings
|
||||
|
@ -64,8 +64,26 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
public static boolean canSendChunk = false;
|
||||
public static ArrayList<String> runners_p = new ArrayList<>();
|
||||
static long state = 1;
|
||||
public static HashMap<String, PlotId> lastPlot;
|
||||
public static HashMap<String, Integer> worldBorder;
|
||||
public static HashMap<String, PlotId> lastPlot = new HashMap<>();
|
||||
public static HashMap<String, Integer> worldBorder = new HashMap<>();
|
||||
|
||||
public static int getBorder(World world) {
|
||||
String worldname = world.getName();
|
||||
if (worldBorder.containsKey(worldname)) {
|
||||
return worldBorder.get(worldname);
|
||||
}
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public static void setupBorder(String world) {
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
if (!plotworld.WORLD_BORDER) {
|
||||
return;
|
||||
}
|
||||
for (Plot plot : PlotMain.getPlots(world).values()) {
|
||||
updateWorldBorder(plot);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* direction 0 = north, 1 = south, etc:
|
||||
@ -435,7 +453,26 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void updateWorldBorder(Plot plot) {
|
||||
String world = plot.world;
|
||||
PlotManager manager = PlotMain.getPlotManager(world);
|
||||
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
Location bot = manager.getPlotBottomLocAbs(plotworld, plot.id);
|
||||
Location top = manager.getPlotTopLocAbs(plotworld, plot.id);
|
||||
int border = worldBorder.get(plot.world);
|
||||
int botmax = Math.max(Math.abs(bot.getBlockX()), Math.abs(bot.getBlockZ()));
|
||||
int topmax = Math.max(Math.abs(top.getBlockX()), Math.abs(top.getBlockZ()));
|
||||
int max = Math.max(botmax, topmax);
|
||||
if (max > border ) {
|
||||
worldBorder.put(plot.world, max);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean createPlot(final Player player, final Plot plot) {
|
||||
|
||||
if (PlotHelper.worldBorder.containsKey(plot.world)) {
|
||||
updateWorldBorder(plot);
|
||||
}
|
||||
final World w = plot.getWorld();
|
||||
final Plot p = new Plot(plot.id, UUIDHandler.getUUID(player), plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
|
||||
PlotMain.updatePlot(p);
|
||||
|
Loading…
Reference in New Issue
Block a user