2014-09-22 13:02:14 +02:00
|
|
|
package com.intellectualcrafters.plot;
|
|
|
|
|
2014-09-29 19:05:03 +02:00
|
|
|
import com.sk89q.worldedit.*;
|
2014-09-22 13:02:14 +02:00
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
|
|
|
import com.sk89q.worldedit.masks.RegionMask;
|
|
|
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author Citymonstret
|
2014-09-24 22:21:43 +10:00
|
|
|
*
|
2014-09-22 13:02:14 +02:00
|
|
|
*/
|
|
|
|
public class PWE {
|
2014-09-24 22:21:43 +10:00
|
|
|
|
2014-09-29 19:05:03 +02:00
|
|
|
@SuppressWarnings("unused")
|
2014-09-24 22:21:43 +10:00
|
|
|
public static void setMask(Player p, Location l) {
|
2014-09-29 19:05:03 +02:00
|
|
|
try {
|
|
|
|
LocalSession s;
|
|
|
|
if (PlotMain.worldEdit == null) {
|
|
|
|
s = WorldEdit.getInstance().getSession(p.getName());
|
2014-09-24 22:21:43 +10:00
|
|
|
} else {
|
2014-09-29 19:05:03 +02:00
|
|
|
s = PlotMain.worldEdit.getSession(p);
|
2014-09-24 22:21:43 +10:00
|
|
|
}
|
2014-09-29 19:05:03 +02:00
|
|
|
Plot plot = PlayerFunctions.getCurrentPlot(p);
|
|
|
|
if (plot != null) {
|
|
|
|
boolean r;
|
|
|
|
r = plot.getOwner() != null && plot.getOwner().equals(p.getUniqueId());
|
|
|
|
if (!r) {
|
|
|
|
if (p.hasPermission("plots.we.member") && plot.hasRights(p)) {
|
|
|
|
r = true;
|
|
|
|
} else if (p.hasPermission("plots.we.bypass")) {
|
|
|
|
s.setMask(null);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (r) {
|
|
|
|
World w = p.getWorld();
|
|
|
|
Location b = PlotHelper.getPlotBottomLoc(w, plot.id);
|
|
|
|
Location t = PlotHelper.getPlotTopLoc(w, plot.id);
|
|
|
|
Vector p1 = new Vector(b.getBlockX(), b.getBlockY(), b.getBlockZ());
|
|
|
|
Vector p2 = new Vector(t.getBlockX(), t.getBlockY(), t.getBlockZ());
|
|
|
|
LocalWorld world = PlotMain.worldEdit.wrapPlayer(p).getWorld();
|
|
|
|
CuboidRegion cr = new CuboidRegion(world, p1, p2);
|
|
|
|
RegionMask rm = new RegionMask(cr);
|
|
|
|
s.setMask(rm);
|
2014-09-24 22:21:43 +10:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2014-09-29 19:05:03 +02:00
|
|
|
if (s.getMask() == null) {
|
|
|
|
BukkitPlayer plr = PlotMain.worldEdit.wrapPlayer(p);
|
|
|
|
LocalWorld world = plr.getWorld();
|
|
|
|
Vector p1 = new Vector(0, 0, 0), p2 = new Vector(0, 0, 0);
|
|
|
|
s.setMask(new RegionMask(new CuboidRegion(world, p1, p2)));
|
2014-09-24 22:21:43 +10:00
|
|
|
}
|
2014-09-29 19:05:03 +02:00
|
|
|
} catch(Exception e) {
|
|
|
|
throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
|
2014-09-22 13:02:14 +02:00
|
|
|
}
|
2014-09-24 22:21:43 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void removeMask(Player p) {
|
2014-09-29 19:05:03 +02:00
|
|
|
try {
|
|
|
|
LocalSession s;
|
|
|
|
if(PlotMain.worldEdit == null) {
|
|
|
|
s = WorldEdit.getInstance().getSession(p.getName());
|
|
|
|
} else {
|
|
|
|
s = PlotMain.worldEdit.getSession(p);
|
|
|
|
}
|
|
|
|
s.setMask(null);
|
|
|
|
} catch(Exception e) {
|
|
|
|
throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
|
|
|
|
}
|
2014-09-24 22:21:43 +10:00
|
|
|
}
|
2014-09-22 13:02:14 +02:00
|
|
|
}
|