mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-13 10:34:09 +01:00
h
This commit is contained in:
parent
d11679aa1e
commit
2b7053895c
@ -256,7 +256,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain {
|
|||||||
final Entity[] entities = chunk.getEntities();
|
final Entity[] entities = chunk.getEntities();
|
||||||
Entity entity;
|
Entity entity;
|
||||||
for (int i = entities.length - 1; i >= 0; i--) {
|
for (int i = entities.length - 1; i >= 0; i--) {
|
||||||
if (!((entity = entities[i]) instanceof Player) && !PlotListener.isInPlot(entity.getLocation())) {
|
if (!((entity = entities[i]) instanceof Player) && !.isInPlot(entity.getLocation())) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,10 @@ public class PlotSquared {
|
|||||||
plotworlds.remove(world);
|
plotworlds.remove(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HashMap<String, HashMap<PlotId, Plot>> getAllPlotsRaw() {
|
||||||
|
return plots;
|
||||||
|
}
|
||||||
|
|
||||||
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
|
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
|
||||||
PlotSquared.plots = plots;
|
PlotSquared.plots = plots;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.listeners;
|
package com.intellectualcrafters.plot.listeners;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -82,6 +83,7 @@ import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
|||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
import org.bukkit.event.world.StructureGrowEvent;
|
import org.bukkit.event.world.StructureGrowEvent;
|
||||||
import org.bukkit.event.world.WorldInitEvent;
|
import org.bukkit.event.world.WorldInitEvent;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.BukkitMain;
|
import com.intellectualcrafters.plot.BukkitMain;
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
@ -93,6 +95,7 @@ import com.intellectualcrafters.plot.flag.Flag;
|
|||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
@ -101,6 +104,7 @@ import com.intellectualcrafters.plot.util.PlayerFunctions;
|
|||||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
|
||||||
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player Events involving plots
|
* Player Events involving plots
|
||||||
@ -112,7 +116,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public static void onWorldInit(final WorldInitEvent event) {
|
public static void onWorldInit(final WorldInitEvent event) {
|
||||||
PlotSquared.loadWorld(event.getWorld());
|
World world = event.getWorld();
|
||||||
|
ChunkGenerator gen = world.getGenerator();
|
||||||
|
if (gen instanceof PlotGenerator) {
|
||||||
|
PlotSquared.loadWorld(world.getName(), (PlotGenerator) gen);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PlotSquared.loadWorld(world.getName(), null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -145,7 +156,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
// textures(event.getPlayer());
|
// textures(event.getPlayer());
|
||||||
if (isInPlot(event.getPlayer().getLocation())) {
|
if (isInPlot(event.getPlayer().getLocation())) {
|
||||||
if (Settings.TELEPORT_ON_LOGIN) {
|
if (Settings.TELEPORT_ON_LOGIN) {
|
||||||
event.getPlayer().teleport(PlotHelper.getPlotHomeDefault(getPlot(event.getPlayer())));
|
BukkitUtil.teleportPlayer(player, PlotHelper.getPlotHomeDefault(getPlot(event.getPlayer())));
|
||||||
PlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD);
|
PlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD);
|
||||||
} else {
|
} else {
|
||||||
plotEntry(event.getPlayer(), getCurrentPlot(event.getPlayer().getLocation()));
|
plotEntry(event.getPlayer(), getCurrentPlot(event.getPlayer().getLocation()));
|
||||||
@ -225,7 +236,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
if (!isPlotWorld(world)) {
|
if (!isPlotWorld(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(world.getName());
|
||||||
if (!plotworld.PLOT_CHAT) {
|
if (!plotworld.PLOT_CHAT) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -700,19 +711,16 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public static void onLeave(final PlayerQuitEvent event) {
|
public static void onLeave(final PlayerQuitEvent event) {
|
||||||
if (PlotSelection.currentSelection.containsKey(event.getPlayer().getName())) {
|
|
||||||
PlotSelection.currentSelection.remove(event.getPlayer().getName());
|
|
||||||
}
|
|
||||||
if (Setup.setupMap.containsKey(event.getPlayer().getName())) {
|
if (Setup.setupMap.containsKey(event.getPlayer().getName())) {
|
||||||
Setup.setupMap.remove(event.getPlayer().getName());
|
Setup.setupMap.remove(event.getPlayer().getName());
|
||||||
}
|
}
|
||||||
if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) {
|
if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) {
|
||||||
final Set<Plot> plots = PlotSquared.getPlots(event.getPlayer());
|
final Collection<Plot> plots = PlotSquared.getPlots(event.getPlayer().getName()).values();
|
||||||
for (final Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world);
|
PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world);
|
||||||
final PlotManager manager = PlotSquared.getPlotManager(plot.world);
|
final PlotManager manager = PlotSquared.getPlotManager(plot.world);
|
||||||
manager.clearPlot(null, plotworld, plot, true, null);
|
manager.clearPlot(plotworld, plot, true, null);
|
||||||
DBFunc.delete(plot.world.getName(), plot);
|
DBFunc.delete(plot.world, plot);
|
||||||
PlotSquared.log(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
|
PlotSquared.log(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,15 +25,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.WeatherType;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Biome;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
@ -41,6 +32,7 @@ import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
|
|||||||
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
@ -56,7 +48,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
@SuppressWarnings({"unused", "deprecation"}) public class PlotListener {
|
@SuppressWarnings({"unused", "deprecation"}) public class PlotListener {
|
||||||
|
|
||||||
public static void textures(final Player p) {
|
public static void textures(final Player p) {
|
||||||
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld())) {
|
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld().getName())) {
|
||||||
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
|
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,15 +65,11 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInPlot(final Player player) {
|
public static boolean isInPlot(String world, int x, int y, int z) {
|
||||||
return PlayerFunctions.isInPlot(player);
|
return (PlayerFunctions.getPlot(new Location(world, x, y, z)) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Plot getPlot(final Player player) {
|
public static boolean isPlotWorld(final String world) {
|
||||||
return PlayerFunctions.getCurrentPlot(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isPlotWorld(final World world) {
|
|
||||||
return PlotSquared.isPlotWorld(world);
|
return PlotSquared.isPlotWorld(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,10 +81,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlotWorld getPlotWorld(final World world) {
|
|
||||||
return PlotSquared.getWorldSettings(world);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getName(final UUID id) {
|
private static String getName(final UUID id) {
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
return "none";
|
return "none";
|
||||||
@ -113,15 +97,15 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean enteredPlot(final Location l1, final Location l2) {
|
public static boolean enteredPlot(final Location l1, final Location l2) {
|
||||||
final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 0, l1.getBlockZ()));
|
final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getX(), 0, l1.getZ()));
|
||||||
final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 0, l2.getBlockZ()));
|
final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getX(), 0, l2.getZ()));
|
||||||
return (p2 != null) && ((p1 == null) || !p1.equals(p2));
|
return (p2 != null) && ((p1 == null) || !p1.equals(p2));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean leftPlot(final Location l1, final Location l2) {
|
public static boolean leftPlot(final Location l1, final Location l2) {
|
||||||
final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getBlockX(), 0, l1.getBlockZ()));
|
final PlotId p1 = PlayerFunctions.getPlot(new Location(l1.getWorld(), l1.getX(), 0, l1.getZ()));
|
||||||
final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getBlockX(), 0, l2.getBlockZ()));
|
final PlotId p2 = PlayerFunctions.getPlot(new Location(l2.getWorld(), l2.getX(), 0, l2.getZ()));
|
||||||
return (p1 != null) && ((p2 == null) || !p1.equals(p2));
|
return (p1 != null) && ((p2 == null) || !p1.equals(p2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,11 +122,11 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
if (id == null) {
|
if (id == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final World world = loc.getWorld();
|
final String world = loc.getWorld();
|
||||||
if (PlotSquared.getPlots(world).containsKey(id)) {
|
if (PlotSquared.getPlots(world).containsKey(id)) {
|
||||||
return PlotSquared.getPlots(world).get(id);
|
return PlotSquared.getPlots(world).get(id);
|
||||||
}
|
}
|
||||||
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), loc.getWorld().getName());
|
return new Plot(id, null, Biome.FOREST, new ArrayList<UUID>(), new ArrayList<UUID>(), loc.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WeatherType getWeatherType(String str) {
|
private static WeatherType getWeatherType(String str) {
|
||||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
@ -35,4 +36,8 @@ public abstract class AChunkManager {
|
|||||||
public abstract boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone);
|
public abstract boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone);
|
||||||
|
|
||||||
public abstract boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone);
|
public abstract boolean regenerateRegion(final Location pos1, final Location pos2, final Runnable whenDone);
|
||||||
|
|
||||||
|
public abstract void update(Location loc);
|
||||||
|
|
||||||
|
public abstract void clearAllEntities(final Plot plot);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang.mutable.MutableInt;
|
import org.apache.commons.lang.mutable.MutableInt;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -35,16 +36,19 @@ import org.bukkit.block.banner.Pattern;
|
|||||||
import org.bukkit.block.banner.PatternType;
|
import org.bukkit.block.banner.PatternType;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.BukkitMain;
|
import com.intellectualcrafters.plot.BukkitMain;
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
|
import com.intellectualcrafters.plot.listeners.PlotListener;
|
||||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.entity.EntityWrapper;
|
import com.intellectualcrafters.plot.object.entity.EntityWrapper;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
|
||||||
@ -741,4 +745,33 @@ public class ChunkManager extends AChunkManager {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clearAllEntities(final Plot plot) {
|
||||||
|
final List<Entity> entities = BukkitUtil.getEntities(plot.world);
|
||||||
|
for (final Entity entity : entities) {
|
||||||
|
final PlotId id = PlayerFunctions.getPlot(BukkitUtil.getLocation(entity));
|
||||||
|
if (plot.id.equals(id)) {
|
||||||
|
if (entity instanceof Player) {
|
||||||
|
final Player player = (Player) entity;
|
||||||
|
BukkitMain.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
|
||||||
|
PlotListener.plotExit(player, plot);
|
||||||
|
} else {
|
||||||
|
entity.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Location loc) {
|
||||||
|
ArrayList<Chunk> chunks = new ArrayList<>();
|
||||||
|
final int distance = Bukkit.getViewDistance();
|
||||||
|
for (int cx = -distance; cx < distance; cx++) {
|
||||||
|
for (int cz = -distance; cz < distance; cz++) {
|
||||||
|
Chunk chunk = BukkitUtil.getChunkAt(loc.getWorld(), loc.getX(), loc.getZ());
|
||||||
|
chunks.add(chunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AbstractSetBlock.setBlockManager.update(chunks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,10 +32,7 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
|||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.ChatPaginator;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -49,6 +46,99 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("javadoc") public class PlayerFunctions {
|
@SuppressWarnings("javadoc") public class PlayerFunctions {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear a plot. Use null player if no player is present
|
||||||
|
* @param player
|
||||||
|
* @param world
|
||||||
|
* @param plot
|
||||||
|
* @param isDelete
|
||||||
|
*/
|
||||||
|
public static void clear(final Player player, final String world, final Plot plot, final boolean isDelete) {
|
||||||
|
|
||||||
|
if (runners.containsKey(plot)) {
|
||||||
|
PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
|
|
||||||
|
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||||
|
|
||||||
|
final int prime = 31;
|
||||||
|
int h = 1;
|
||||||
|
h = (prime * h) + pos1.getX();
|
||||||
|
h = (prime * h) + pos1.getZ();
|
||||||
|
state = h;
|
||||||
|
|
||||||
|
final long start = System.currentTimeMillis();
|
||||||
|
final Location location = PlotHelper.getPlotHomeDefault(plot);
|
||||||
|
PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
|
runners.put(plot, 1);
|
||||||
|
if (plotworld.TERRAIN != 0) {
|
||||||
|
final Location pos2 = PlotHelper.getPlotTopLoc(world, plot.id);
|
||||||
|
AChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (player != null && player.isOnline()) {
|
||||||
|
PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start))));
|
||||||
|
}
|
||||||
|
runners.remove(plot);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Runnable run = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
PlotHelper.setBiome(world, plot, Biome.FOREST);
|
||||||
|
runners.remove(plot);
|
||||||
|
if (player != null && player.isOnline()) {
|
||||||
|
PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start))));
|
||||||
|
}
|
||||||
|
update(location);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
manager.clearPlot(plotworld, plot, isDelete, run);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges all plots in the arraylist (with cost)
|
||||||
|
*
|
||||||
|
* @param plr
|
||||||
|
* @param world
|
||||||
|
* @param plotIds
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean mergePlots(final Player plr, final String world, final ArrayList<PlotId> plotIds) {
|
||||||
|
|
||||||
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
||||||
|
if ((PlotSquared.economy != null) && plotworld.USE_ECONOMY) {
|
||||||
|
final double cost = plotIds.size() * plotworld.MERGE_PRICE;
|
||||||
|
if (cost > 0d) {
|
||||||
|
final Economy economy = PlotSquared.economy;
|
||||||
|
if (economy.getBalance(plr) < cost) {
|
||||||
|
PlayerFunctions.sendMessage(plr, C.CANNOT_AFFORD_MERGE, "" + cost);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
economy.withdrawPlayer(plr, cost);
|
||||||
|
PlayerFunctions.sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mergePlots(world, plotIds, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getPlayerName(final UUID uuid) {
|
||||||
|
if (uuid == null) {
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
final OfflinePlayer plr = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
||||||
|
if (!plr.hasPlayedBefore()) {
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
return plr.getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param player player
|
* @param player player
|
||||||
*
|
*
|
||||||
@ -58,16 +148,6 @@ import java.util.UUID;
|
|||||||
return getCurrentPlot(player) != null;
|
return getCurrentPlot(player) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<PlotId> getPlotSelectionIds(PlotId pos1, final PlotId pos2) {
|
|
||||||
final ArrayList<PlotId> myplots = new ArrayList<>();
|
|
||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
|
||||||
myplots.add(new PlotId(x, y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return myplots;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
|
public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,19 +27,10 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Sign;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.BukkitMain;
|
import com.intellectualcrafters.plot.BukkitMain;
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
@ -126,33 +117,16 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static ArrayList<PlotId> getPlotSelectionIds(PlotId pos1, final PlotId pos2) {
|
||||||
* Merges all plots in the arraylist (with cost)
|
final ArrayList<PlotId> myplots = new ArrayList<>();
|
||||||
*
|
for (int x = pos1.x; x <= pos2.x; x++) {
|
||||||
* @param plr
|
for (int y = pos1.y; y <= pos2.y; y++) {
|
||||||
* @param world
|
myplots.add(new PlotId(x, y));
|
||||||
* @param plotIds
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static boolean mergePlots(final Player plr, final String world, final ArrayList<PlotId> plotIds) {
|
|
||||||
|
|
||||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(world);
|
|
||||||
if ((PlotSquared.economy != null) && plotworld.USE_ECONOMY) {
|
|
||||||
final double cost = plotIds.size() * plotworld.MERGE_PRICE;
|
|
||||||
if (cost > 0d) {
|
|
||||||
final Economy economy = PlotSquared.economy;
|
|
||||||
if (economy.getBalance(plr) < cost) {
|
|
||||||
PlayerFunctions.sendMessage(plr, C.CANNOT_AFFORD_MERGE, "" + cost);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
economy.withdrawPlayer(plr, cost);
|
|
||||||
PlayerFunctions.sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mergePlots(world, plotIds, true);
|
return myplots;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Completely merges a set of plots<br> <b>(There are no checks to make sure you supply the correct
|
* Completely merges a set of plots<br> <b>(There are no checks to make sure you supply the correct
|
||||||
* arguments)</b><br> - Misuse of this method can result in unusable plots<br> - the set of plots must belong to one
|
* arguments)</b><br> - Misuse of this method can result in unusable plots<br> - the set of plots must belong to one
|
||||||
@ -303,17 +277,6 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
BukkitUtil.setSign(p.world, loc.getX(), loc.getY(), loc.getZ(), lines);
|
BukkitUtil.setSign(p.world, loc.getX(), loc.getY(), loc.getZ(), lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPlayerName(final UUID uuid) {
|
|
||||||
if (uuid == null) {
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
final OfflinePlayer plr = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid);
|
|
||||||
if (!plr.hasPlayedBefore()) {
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
return plr.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getStringSized(final int max, final String string) {
|
public static String getStringSized(final int max, final String string) {
|
||||||
if (string.length() > max) {
|
if (string.length() > max) {
|
||||||
return string.substring(0, max);
|
return string.substring(0, max);
|
||||||
@ -321,18 +284,16 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void autoMerge(final String world, final Plot plot, final Player player) {
|
public static void autoMerge(final String world, final Plot plot, final UUID uuid) {
|
||||||
|
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plot.owner == null) {
|
if (plot.owner == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!plot.owner.equals(UUIDHandler.getUUID(player))) {
|
if (!plot.owner.equals(uuid)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<PlotId> plots;
|
ArrayList<PlotId> plots;
|
||||||
boolean merge = true;
|
boolean merge = true;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -343,32 +304,32 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
count++;
|
count++;
|
||||||
final PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id;
|
final PlotId bot = PlayerFunctions.getBottomPlot(world, plot).id;
|
||||||
final PlotId top = PlayerFunctions.getTopPlot(world, plot).id;
|
final PlotId top = PlayerFunctions.getTopPlot(world, plot).id;
|
||||||
plots = PlayerFunctions.getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
plots = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
||||||
if (ownsPlots(world, plots, player, 0)) {
|
if (ownsPlots(world, plots, uuid, 0)) {
|
||||||
final boolean result = mergePlots(world, plots, true);
|
final boolean result = mergePlots(world, plots, true);
|
||||||
if (result) {
|
if (result) {
|
||||||
merge = true;
|
merge = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plots = PlayerFunctions.getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
||||||
if (ownsPlots(world, plots, player, 1)) {
|
if (ownsPlots(world, plots, uuid, 1)) {
|
||||||
final boolean result = mergePlots(world, plots, true);
|
final boolean result = mergePlots(world, plots, true);
|
||||||
if (result) {
|
if (result) {
|
||||||
merge = true;
|
merge = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plots = PlayerFunctions.getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
||||||
if (ownsPlots(world, plots, player, 2)) {
|
if (ownsPlots(world, plots, uuid, 2)) {
|
||||||
final boolean result = mergePlots(world, plots, true);
|
final boolean result = mergePlots(world, plots, true);
|
||||||
if (result) {
|
if (result) {
|
||||||
merge = true;
|
merge = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plots = PlayerFunctions.getPlotSelectionIds(new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
plots = getPlotSelectionIds(new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
||||||
if (ownsPlots(world, plots, player, 3)) {
|
if (ownsPlots(world, plots, uuid, 3)) {
|
||||||
final boolean result = mergePlots(world, plots, true);
|
final boolean result = mergePlots(world, plots, true);
|
||||||
if (result) {
|
if (result) {
|
||||||
merge = true;
|
merge = true;
|
||||||
@ -377,16 +338,16 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
}
|
}
|
||||||
merge = false;
|
merge = false;
|
||||||
}
|
}
|
||||||
update(BukkitUtil.getLocation(player));
|
AChunkManager.manager.update(getPlotHome(world, plot));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean ownsPlots(final String world, final ArrayList<PlotId> plots, final Player player, final int dir) {
|
private static boolean ownsPlots(final String world, final ArrayList<PlotId> plots, final UUID uuid, final int dir) {
|
||||||
|
|
||||||
final PlotId id_min = plots.get(0);
|
final PlotId id_min = plots.get(0);
|
||||||
final PlotId id_max = plots.get(plots.size() - 1);
|
final PlotId id_max = plots.get(plots.size() - 1);
|
||||||
for (final PlotId myid : plots) {
|
for (final PlotId myid : plots) {
|
||||||
final Plot myplot = PlotSquared.getPlots(world).get(myid);
|
final Plot myplot = PlotSquared.getPlots(world).get(myid);
|
||||||
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(player)))) {
|
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(uuid))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotId top = PlayerFunctions.getTopPlot(world, myplot).id;
|
final PlotId top = PlayerFunctions.getTopPlot(world, myplot).id;
|
||||||
@ -401,18 +362,6 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void update(Location loc) {
|
|
||||||
ArrayList<Chunk> chunks = new ArrayList<>();
|
|
||||||
final int distance = Bukkit.getViewDistance();
|
|
||||||
for (int cx = -distance; cx < distance; cx++) {
|
|
||||||
for (int cz = -distance; cz < distance; cz++) {
|
|
||||||
Chunk chunk = BukkitUtil.getChunkAt(loc.getWorld(), loc.getX(), loc.getZ());
|
|
||||||
chunks.add(chunk);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AbstractSetBlock.setBlockManager.update(chunks);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateWorldBorder(Plot plot) {
|
public static void updateWorldBorder(Plot plot) {
|
||||||
if (!worldBorder.containsKey(plot.world)) {
|
if (!worldBorder.containsKey(plot.world)) {
|
||||||
return;
|
return;
|
||||||
@ -434,16 +383,14 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
/**
|
/**
|
||||||
* Create a plot and notify the world border and plot merger
|
* Create a plot and notify the world border and plot merger
|
||||||
*/
|
*/
|
||||||
public static boolean createPlot(final Player player, final Plot plot) {
|
public static boolean createPlot(final UUID uuid, final Plot plot) {
|
||||||
if (PlotHelper.worldBorder.containsKey(plot.world)) {
|
if (PlotHelper.worldBorder.containsKey(plot.world)) {
|
||||||
updateWorldBorder(plot);
|
updateWorldBorder(plot);
|
||||||
}
|
}
|
||||||
String w = BukkitUtil.getWorld(player);
|
|
||||||
UUID uuid = UUIDHandler.getUUID(player);
|
|
||||||
Plot p = createPlotAbs(uuid, plot);
|
Plot p = createPlotAbs(uuid, plot);
|
||||||
final PlotWorld plotworld = PlotSquared.getWorldSettings(w);
|
final PlotWorld plotworld = PlotSquared.getWorldSettings(plot.world);
|
||||||
if (plotworld.AUTO_MERGE) {
|
if (plotworld.AUTO_MERGE) {
|
||||||
autoMerge(w, p, player);
|
autoMerge(plot.world, p, uuid);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -475,39 +422,25 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
return new short[]{Short.parseShort(block), 0};
|
return new short[]{Short.parseShort(block), 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearAllEntities(final String world, final Plot plot, final boolean tile) {
|
|
||||||
final List<Entity> entities = BukkitUtil.getEntities(world);
|
|
||||||
for (final Entity entity : entities) {
|
|
||||||
final PlotId id = PlayerFunctions.getPlot(BukkitUtil.getLocation(entity));
|
|
||||||
if (plot.id.equals(id)) {
|
|
||||||
if (entity instanceof Player) {
|
|
||||||
final Player player = (Player) entity;
|
|
||||||
BukkitMain.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
|
|
||||||
PlotListener.plotExit(player, plot);
|
|
||||||
} else {
|
|
||||||
entity.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear a plot. Use null player if no player is present
|
* Clear a plot and associated sections: [sign, entities, border]
|
||||||
* @param player
|
*
|
||||||
* @param world
|
* @param requester
|
||||||
* @param plot
|
* @param plot
|
||||||
* @param isDelete
|
|
||||||
*/
|
*/
|
||||||
public static void clear(final Player player, final String world, final Plot plot, final boolean isDelete) {
|
public static boolean clear(UUID uuid, final Plot plot, final boolean isDelete, final Runnable whenDone) {
|
||||||
|
|
||||||
if (runners.containsKey(plot)) {
|
if (runners.containsKey(plot)) {
|
||||||
PlayerFunctions.sendMessage(null, C.WAIT_FOR_TIMER);
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
AChunkManager.manager.clearAllEntities(plot);
|
||||||
|
clear(plot.world, plot, isDelete, whenDone);
|
||||||
|
removeSign(plot);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clear(final String world, final Plot plot, final boolean isDelete, final Runnable whenDone) {
|
||||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
final PlotManager manager = PlotSquared.getPlotManager(world);
|
||||||
|
|
||||||
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
final Location pos1 = PlotHelper.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||||
|
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int h = 1;
|
int h = 1;
|
||||||
h = (prime * h) + pos1.getX();
|
h = (prime * h) + pos1.getX();
|
||||||
@ -523,10 +456,8 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
AChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() {
|
AChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (player != null && player.isOnline()) {
|
|
||||||
PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start))));
|
|
||||||
}
|
|
||||||
runners.remove(plot);
|
runners.remove(plot);
|
||||||
|
TaskManager.runTask(whenDone);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -536,42 +467,13 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
public void run() {
|
public void run() {
|
||||||
PlotHelper.setBiome(world, plot, Biome.FOREST);
|
PlotHelper.setBiome(world, plot, Biome.FOREST);
|
||||||
runners.remove(plot);
|
runners.remove(plot);
|
||||||
if (player != null && player.isOnline()) {
|
TaskManager.runTask(whenDone);
|
||||||
PlayerFunctions.sendMessage(player, C.CLEARING_DONE.s().replaceAll("%time%", "" + ((System.currentTimeMillis() - start))));
|
AChunkManager.manager.update(location);
|
||||||
}
|
|
||||||
update(location);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
manager.clearPlot(plotworld, plot, isDelete, run);
|
manager.clearPlot(plotworld, plot, isDelete, run);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear a plot and associated sections: [sign, entities, border]
|
|
||||||
*
|
|
||||||
* @param requester
|
|
||||||
* @param plot
|
|
||||||
*/
|
|
||||||
public static void clear(final Player requester, final Plot plot, final boolean isDelete) {
|
|
||||||
if (requester == null) {
|
|
||||||
clearAllEntities(plot.world, plot, false);
|
|
||||||
clear(requester, plot.world, plot, isDelete);
|
|
||||||
removeSign(plot);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (runners.containsKey(plot)) {
|
|
||||||
PlayerFunctions.sendMessage(requester, C.WAIT_FOR_TIMER);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
|
|
||||||
|
|
||||||
String world = requester.getWorld().getName();
|
|
||||||
|
|
||||||
clearAllEntities(world, plot, false);
|
|
||||||
clear(requester, world, plot, isDelete);
|
|
||||||
removeSign(plot);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) {
|
public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) {
|
||||||
if (blocks.length == 1) {
|
if (blocks.length == 1) {
|
||||||
setSimpleCuboid(world, pos1, pos2, blocks[0]);
|
setSimpleCuboid(world, pos1, pos2, blocks[0]);
|
||||||
@ -874,7 +776,7 @@ import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|||||||
|
|
||||||
int offset_x = newPlot.x - pos1.id.x;
|
int offset_x = newPlot.x - pos1.id.x;
|
||||||
int offset_y = newPlot.y - pos1.id.y;
|
int offset_y = newPlot.y - pos1.id.y;
|
||||||
final ArrayList<PlotId> selection = PlayerFunctions.getPlotSelectionIds(pos1.id, pos2.id);
|
final ArrayList<PlotId> selection = getPlotSelectionIds(pos1.id, pos2.id);
|
||||||
for (PlotId id : selection) {
|
for (PlotId id : selection) {
|
||||||
DBFunc.movePlot(world, new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y));
|
DBFunc.movePlot(world, new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y));
|
||||||
Plot plot = PlotSquared.getPlots(world).get(id);
|
Plot plot = PlotSquared.getPlots(world).get(id);
|
||||||
|
Loading…
Reference in New Issue
Block a user