This commit is contained in:
boy0001 2015-04-26 16:29:58 +10:00
parent c09c5b048e
commit ec80151cd9
25 changed files with 417 additions and 371 deletions

View File

@ -30,11 +30,13 @@ import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.listeners.APlotListener;
import com.intellectualcrafters.plot.listeners.ChunkListener;
import com.intellectualcrafters.plot.listeners.ForceFieldListener;
import com.intellectualcrafters.plot.listeners.InventoryListener;
import com.intellectualcrafters.plot.listeners.PlayerEvents;
import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8;
import com.intellectualcrafters.plot.listeners.PlotListener;
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
import com.intellectualcrafters.plot.listeners.TNTListener;
import com.intellectualcrafters.plot.listeners.WorldEvents;
@ -107,13 +109,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
} else {
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
}
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
// Experimental
if (Settings.CHUNK_PROCESSOR) {
getServer().getPluginManager().registerEvents(new ChunkListener(), this);
}
List<World> worlds = Bukkit.getWorlds();
if (worlds.size() > 0) {
UUIDHandler.cacheAll(worlds.get(0).getName());
@ -398,4 +393,19 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
public void unregister(PlotPlayer player) {
BukkitUtil.removePlayer(player.getName());
}
@Override
public APlotListener initPlotListener() {
return new PlotListener();
}
@Override
public void registerChunkProcessor() {
getServer().getPluginManager().registerEvents(new ChunkListener(), this);
}
@Override
public void registerWorldEvents() {
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
}
}

View File

@ -7,6 +7,7 @@ import net.milkbowl.vault.economy.Economy;
import org.bukkit.generator.ChunkGenerator;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.listeners.APlotListener;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.ChunkManager;
@ -61,4 +62,10 @@ public interface IPlotMain {
public void unregister(PlotPlayer player);
public ChunkGenerator getGenerator(String world, String name);
public APlotListener initPlotListener();
public void registerChunkProcessor();
public void registerWorldEvents();
}

View File

@ -48,6 +48,7 @@ import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.generator.SquarePlotManager;
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
import com.intellectualcrafters.plot.listeners.APlotListener;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotCluster;
@ -528,6 +529,10 @@ public class PlotSquared {
IMP.registerPlotPlusEvents();
IMP.registerForceFieldEvents();
IMP.registerWorldEditEvents();
IMP.registerWorldEvents();
if (Settings.CHUNK_PROCESSOR) {
IMP.registerChunkProcessor();
}
// create UUIDWrapper
UUIDHandler.uuidWrapper = IMP.initUUIDHandler();
// create event util class
@ -540,6 +545,9 @@ public class PlotSquared {
BlockManager.manager = IMP.initBlockManager();
// Set chunk
ChunkManager.manager = IMP.initChunkManager();
// Plot listener
APlotListener.manager = IMP.initPlotListener();
// PlotMe
if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) {
TaskManager.runTaskLater(new Runnable() {

View File

@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.flag.AbstractFlag;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.flag.FlagValue;
import com.intellectualcrafters.plot.listeners.PlotListener;
import com.intellectualcrafters.plot.listeners.APlotListener;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
@ -125,7 +125,7 @@ public class FlagCmd extends SubCommand {
return false;
}
MainUtil.sendMessage(player, C.FLAG_ADDED);
PlotListener.plotEntry(player, plot);
APlotListener.manager.plotEntry(player, plot);
return true;
}
case "remove": {
@ -163,7 +163,7 @@ public class FlagCmd extends SubCommand {
}
}
MainUtil.sendMessage(player, C.FLAG_REMOVED);
PlotListener.plotEntry(player, plot);
APlotListener.manager.plotEntry(player, plot);
return true;
}
case "add": {
@ -203,7 +203,7 @@ public class FlagCmd extends SubCommand {
}
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
MainUtil.sendMessage(player, C.FLAG_ADDED);
PlotListener.plotEntry(player, plot);
APlotListener.manager.plotEntry(player, plot);
return true;
}
case "list": {

View File

@ -23,12 +23,9 @@ package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
@ -42,7 +39,6 @@ import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class SchematicCmd extends SubCommand {
private int counter = 0;

View File

@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.AbstractFlag;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.listeners.PlotListener;
import com.intellectualcrafters.plot.listeners.APlotListener;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
@ -90,8 +90,6 @@ public class Set extends SubCommand {
break;
}
}
/* TODO: Implement option */
// final boolean advanced_permissions = true;
if (!Permissions.hasPermission(plr, "plots.set." + args[0].toLowerCase())) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase());
return false;
@ -127,7 +125,7 @@ public class Set extends SubCommand {
return false;
}
MainUtil.sendMessage(plr, C.FLAG_REMOVED);
PlotListener.plotEntry(plr, plot);
APlotListener.manager.plotEntry(plr, plot);
return true;
}
try {
@ -144,7 +142,7 @@ public class Set extends SubCommand {
return false;
}
MainUtil.sendMessage(plr, C.FLAG_ADDED);
PlotListener.plotEntry(plr, plot);
APlotListener.manager.plotEntry(plr, plot);
return true;
} catch (final Exception e) {
MainUtil.sendMessage(plr, "&c" + e.getMessage());

View File

@ -22,9 +22,7 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.listeners.worldedit.WEListener;
import com.intellectualcrafters.plot.listeners.worldedit.WEManager;
import com.intellectualcrafters.plot.listeners.worldedit.WESubscriber;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;

View File

@ -97,13 +97,19 @@ public class SQLManager implements AbstractDB {
TaskManager.runTaskRepeat(new Runnable() {
@Override
public void run() {
try {
SQLManager.this.connection = PlotSquared.getMySQL().forceConnection();
} catch (final Exception e) {
e.printStackTrace();
}
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
System.out.print("CONNECTIN");
SQLManager.this.connection = PlotSquared.getMySQL().forceConnection();
} catch (final Exception e) {
e.printStackTrace();
}
}
});
}
}, 11000);
}, 1);
}
updateTables();
}

View File

@ -94,6 +94,18 @@ public class FlagManager {
}
return null;
}
public static boolean isBooleanFlag(final Plot plot, final String key, final boolean defaultValue) {
final Flag flag = FlagManager.getPlotFlag(plot, key);
if (flag == null) {
return defaultValue;
}
final Object value = flag.getValue();
if (value instanceof Boolean) {
return (boolean) value;
}
return defaultValue;
}
/**
* Get the value of a flag for a plot (respects flag defaults)

View File

@ -2,8 +2,8 @@ package com.intellectualcrafters.plot.generator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
import java.util.Map.Entry;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;

View File

@ -0,0 +1,13 @@
package com.intellectualcrafters.plot.listeners;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
public abstract class APlotListener {
public static APlotListener manager;
public abstract void plotExit(final PlotPlayer player, final Plot plot);
public abstract void plotEntry(final PlotPlayer player, final Plot plot);
}

View File

@ -3,14 +3,11 @@ package com.intellectualcrafters.plot.listeners;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;

View File

@ -105,7 +105,7 @@ public class ForceFieldListener implements Listener {
return;
}
if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) {
if (!PlotListener.booleanFlag(plot, "forcefield", false)) {
if (!FlagManager.isBooleanFlag(plot, "forcefield", false)) {
final UUID uuid = pp.getUUID();
if (plot.isAdded(uuid)) {
final Set<Player> players = getNearbyPlayers(player, plot);

View File

@ -9,6 +9,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
@ -25,34 +26,35 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
return;
}
final Location l = BukkitUtil.getLocation(e.getRightClicked().getLocation());
if (isPlotWorld(l)) {
e.getPlayer();
final PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
if (!isInPlot(l)) {
if (!isPlotArea(l)) {
return;
}
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road");
String world = l.getWorld();
if (!PlotSquared.isPlotWorld(world)) {
return;
}
Plot plot = MainUtil.getPlot(l);
PlotPlayer pp = BukkitUtil.getPlayer(e.getPlayer());
if (plot == null) {
if (!MainUtil.isPlotArea(l)) {
return;
}
if (!Permissions.hasPermission(pp, "plots.admin.interact.road")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.road");
e.setCancelled(true);
}
}
else {
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned");
e.setCancelled(true);
}
} else {
final Plot plot = MainUtil.getPlot(l);
if ((plot == null) || !plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.unowned")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.unowned");
}
else {
final UUID uuid = pp.getUUID();
if (!plot.isAdded(uuid)) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other");
e.setCancelled(true);
}
} else {
final UUID uuid = pp.getUUID();
if (!plot.isAdded(uuid)) {
if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) {
if (isPlotArea(l)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.interact.other");
e.setCancelled(true);
}
}
}
}
}
}

View File

@ -37,56 +37,23 @@ import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.BukkitPlayer;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.titles.AbstractTitle;
import com.intellectualcrafters.plot.util.ClusterManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
/**
* @author Citymonstret
* @author Empire92
*/
public class PlotListener {
public static void textures(final Player p) {
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && isPlotWorld(p.getWorld().getName())) {
public class PlotListener extends APlotListener {
public void textures(final Player p) {
if ((Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1) && PlotSquared.isPlotWorld(p.getWorld().getName())) {
p.setResourcePack(Settings.PLOT_SPECIFIC_RESOURCE_PACK);
}
}
public static boolean booleanFlag(final Plot plot, final String key, final boolean defaultValue) {
final Flag flag = FlagManager.getPlotFlag(plot, key);
if (flag == null) {
return defaultValue;
}
final Object value = flag.getValue();
if (value instanceof Boolean) {
return (boolean) value;
}
return defaultValue;
}
public static boolean isInPlot(final String world, final int x, final int y, final int z) {
return (MainUtil.getPlot(new Location(world, x, y, z)) != null);
}
public static boolean isPlotWorld(final String world) {
return PlotSquared.isPlotWorld(world);
}
public static boolean isPlotArea(final Location location) {
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
if (plotworld.TYPE == 2) {
return ClusterManager.getCluster(location) != null;
}
return true;
}
private static String getName(final UUID id) {
private String getName(final UUID id) {
if (id == null) {
return "none";
}
@ -97,39 +64,7 @@ public class PlotListener {
return name;
}
public static UUID getUUID(final String name) {
return UUIDHandler.getUUID(name);
}
public static boolean enteredPlot(final Location l1, final Location l2) {
final PlotId p1 = MainUtil.getPlotId(l1);
final PlotId p2 = MainUtil.getPlotId(l2);
return (p2 != null) && ((p1 == null) || !p1.equals(p2));
}
public static boolean leftPlot(final Location l1, final Location l2) {
final PlotId p1 = MainUtil.getPlotId(l1);
final PlotId p2 = MainUtil.getPlotId(l2);
return (p1 != null) && ((p2 == null) || !p1.equals(p2));
}
public static boolean isPlotWorld(final Location l) {
return PlotSquared.isPlotWorld(l.getWorld());
}
public static boolean isInPlot(final Location loc) {
return getCurrentPlot(loc) != null;
}
public static Plot getCurrentPlot(final Location loc) {
final PlotId id = MainUtil.getPlotId(loc);
if (id == null) {
return null;
}
return MainUtil.getPlot(loc.getWorld(), id);
}
private static WeatherType getWeatherType(String str) {
private WeatherType getWeatherType(String str) {
str = str.toLowerCase();
if (str.equals("rain")) {
return WeatherType.DOWNFALL;
@ -138,7 +73,7 @@ public class PlotListener {
}
}
private static GameMode getGameMode(final String str) {
private GameMode getGameMode(final String str) {
switch (str) {
case "creative":
return GameMode.CREATIVE;
@ -151,11 +86,12 @@ public class PlotListener {
}
}
public static void plotEntry(final PlotPlayer player, final Plot plot) {
public void plotEntry(final PlotPlayer player, final Plot plot) {
plotEntry(((BukkitPlayer) player).player, plot);
}
public static void plotEntry(final Player player, final Plot plot) {
public void plotEntry(final Player pp, final Plot plot) {
Player player = ((BukkitPlayer) pp).player;
if (plot.hasOwner()) {
final Flag gamemodeFlag = FlagManager.getPlotFlag(plot, "gamemode");
if (gamemodeFlag != null) {
@ -178,7 +114,7 @@ public class PlotListener {
if (weatherFlag != null) {
player.setPlayerWeather(getWeatherType(weatherFlag.getValueString()));
}
if ((booleanFlag(plot, "titles", Settings.TITLES)) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) {
if ((FlagManager.isBooleanFlag(plot, "titles", Settings.TITLES)) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) {
final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "");
final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner));
if (AbstractTitle.TITLE_CLASS != null) {
@ -192,11 +128,10 @@ public class PlotListener {
}
}
public static void plotExit(final Player player, final Plot plot) {
{
final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
Bukkit.getPluginManager().callEvent(callEvent);
}
public void plotExit(final PlotPlayer pp, final Plot plot) {
Player player = ((BukkitPlayer) pp).player;
final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
Bukkit.getPluginManager().callEvent(callEvent);
if (FlagManager.getPlotFlag(plot, "fly") != null) {
player.setAllowFlight(Bukkit.getAllowFlight());
}
@ -211,7 +146,7 @@ public class PlotListener {
}
}
public static boolean getFlagValue(final String value) {
public boolean getFlagValue(final String value) {
return Arrays.asList("true", "on", "enabled", "yes").contains(value.toLowerCase());
}
}

View File

@ -160,7 +160,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
if (plot == null) {
return;
}
if (booleanFlag(plot, "instabreak", false)) {
if (FlagManager.isBooleanFlag(plot, "instabreak", false)) {
event.getBlock().breakNaturally();
}
}
@ -175,7 +175,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
if (plot == null) {
return;
}
if (booleanFlag(plot, "invincible", false)) {
if (FlagManager.isBooleanFlag(plot, "invincible", false)) {
event.setCancelled(true);
}
}
@ -189,7 +189,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
return;
}
final UUID uuid = pp.getUUID();
if (plot.isAdded(uuid) && booleanFlag(plot, "drop-protection", false)) {
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "drop-protection", false)) {
event.setCancelled(true);
}
}
@ -203,7 +203,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
return;
}
final UUID uuid = pp.getUUID();
if (plot.isAdded(uuid) && booleanFlag(plot, "item-drop", false)) {
if (plot.isAdded(uuid) && FlagManager.isBooleanFlag(plot, "item-drop", false)) {
event.setCancelled(true);
}
}
@ -214,7 +214,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
if (FlagManager.getPlotFlag(plot, "greeting") != null) {
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "greeting").getValueString()));
}
if (booleanFlag(plot, "notify-enter", false)) {
if (FlagManager.isBooleanFlag(plot, "notify-enter", false)) {
final Player trespasser = event.getPlayer();
final PlotPlayer pt = BukkitUtil.getPlayer(trespasser);
if (Permissions.hasPermission(pt, "plots.flag.notify-enter.bypass")) {
@ -265,7 +265,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
if (healRunnable.containsKey(leaver)) {
healRunnable.remove(leaver);
}
if (booleanFlag(plot, "notify-leave", false)) {
if (FlagManager.isBooleanFlag(plot, "notify-leave", false)) {
if (Permissions.hasPermission(pl, "plots.flag.notify-leave.bypass")) {
return;
}

View File

@ -3,8 +3,6 @@ package com.intellectualcrafters.plot.listeners.worldedit;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@ -16,26 +14,14 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.selections.Selection;
import com.sk89q.worldedit.event.extent.EditSessionEvent;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
import com.sk89q.worldedit.util.eventbus.Subscribe;
public class WEListener implements Listener {

View File

@ -141,9 +141,9 @@ public class ClusterManager {
public static PlotCluster getCluster(final Plot plot) {
return getCluster(plot.world, plot.id);
}
public static PlotCluster getCluster(final Location loc) {
final String world = loc.getWorld();
public static PlotCluster getClusterAbs(final Location loc) {
String world = loc.getWorld();
if ((last != null) && last.world.equals(world)) {
if (contains(last, loc)) {
return last;
@ -164,6 +164,16 @@ public class ClusterManager {
}
return null;
}
public static PlotCluster getCluster(final Location loc) {
final String world = loc.getWorld();
PlotManager manager = PlotSquared.getPlotManager(world);
PlotId id = manager.getPlotIdAbs(PlotSquared.getPlotWorld(world), loc.getX(), loc.getY(), loc.getZ());
if (id != null) {
return getCluster(world, id);
}
return getClusterAbs(loc);
}
public static PlotCluster getCluster(final String world, final PlotId id) {
if ((last != null) && last.world.equals(world)) {

View File

@ -58,6 +58,54 @@ public class MainUtil {
public static HashMap<String, Integer> worldBorder = new HashMap<>();
static PseudoRandom random = new PseudoRandom();
public static boolean isPlotArea(final Location location) {
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
if (plotworld.TYPE == 2) {
return ClusterManager.getCluster(location) != null;
}
return true;
}
public static boolean isPlotAreaAbs(final Location location) {
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
if (plotworld.TYPE == 2) {
return ClusterManager.getClusterAbs(location) != null;
}
return true;
}
public static boolean isPlotRoad(final Location location) {
final PlotWorld plotworld = PlotSquared.getPlotWorld(location.getWorld());
if (plotworld.TYPE == 2) {
PlotCluster cluster = ClusterManager.getCluster(location);
if (cluster == null) {
return false;
}
}
PlotManager manager = PlotSquared.getPlotManager(location.getWorld());
return manager.getPlotId(plotworld, location.getX(), location.getY(), location.getZ()) == null;
}
public static boolean isPlotArea(final Plot plot) {
final PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
if (plotworld.TYPE == 2) {
return ClusterManager.getCluster(plot) != null;
}
return true;
}
public static boolean enteredPlot(final Location l1, final Location l2) {
final PlotId p1 = MainUtil.getPlotId(l1);
final PlotId p2 = MainUtil.getPlotId(l2);
return (p2 != null) && ((p1 == null) || !p1.equals(p2));
}
public static boolean leftPlot(final Location l1, final Location l2) {
final PlotId p1 = MainUtil.getPlotId(l1);
final PlotId p2 = MainUtil.getPlotId(l2);
return (p1 != null) && ((p2 == null) || !p1.equals(p2));
}
public static ArrayList<PlotId> getMaxPlotSelectionIds(final String world, PlotId pos1, PlotId pos2) {
final Plot plot1 = PlotSquared.getPlots(world).get(pos1);

View File

@ -25,7 +25,6 @@ import com.intellectualcrafters.jnbt.NBTOutputStream;
import com.intellectualcrafters.jnbt.ShortTag;
import com.intellectualcrafters.jnbt.Tag;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.commands.SchematicCmd;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;

View File

@ -7,7 +7,6 @@ import java.util.Map.Entry;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.util.TaskManager;
public class SetBlockQueue {

View File

@ -5,7 +5,6 @@ import java.util.Map;
import org.bukkit.generator.ChunkGenerator;
import com.intellectualcrafters.plot.object.PlotGenerator;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.SetupObject;

View File

@ -46,13 +46,14 @@ import org.bukkit.plugin.Plugin;
import com.intellectualcrafters.plot.BukkitMain;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.listeners.PlotListener;
import com.intellectualcrafters.plot.listeners.APlotListener;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.ChunkLoc;
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.RegionWrapper;
import com.intellectualcrafters.plot.object.entity.EntityWrapper;
import com.intellectualcrafters.plot.util.ChunkManager;
@ -771,8 +772,9 @@ public class BukkitChunkManager extends ChunkManager {
if (plot.id.equals(id)) {
if (entity instanceof Player) {
final Player player = (Player) entity;
BukkitUtil.getPlayer(player).teleport(MainUtil.getDefaultHome(plot));
PlotListener.plotExit(player, plot);
PlotPlayer pp = BukkitUtil.getPlayer(player);
pp.teleport(MainUtil.getDefaultHome(plot));
APlotListener.manager.plotExit(pp, plot);
} else {
entity.remove();
}

View File

@ -13,7 +13,6 @@ import org.bukkit.plugin.Plugin;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.config.ConfigurationNode;
import com.intellectualcrafters.plot.object.PlotGenerator;
import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.SetupUtils;