mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
WorldEdit 6 + /plot setup (in progress)
This commit is contained in:
parent
9409ebd7cb
commit
8b50bdd330
@ -8,7 +8,6 @@ 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;
|
||||
|
||||
/**
|
||||
@ -27,42 +26,80 @@ public class PWE {
|
||||
} else {
|
||||
s = PlotMain.worldEdit.getSession(p);
|
||||
}
|
||||
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.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
|
||||
r = true;
|
||||
} else if (p.hasPermission("plots.we.bypass")) {
|
||||
s.setMask(null);
|
||||
|
||||
PlotId id = PlayerFunctions.getPlot(l);
|
||||
if (id != null) {
|
||||
Plot plot = PlotMain.getPlots(l.getWorld()).get(id);
|
||||
if (plot!=null) {
|
||||
boolean r;
|
||||
r = plot.getOwner() != null && plot.getOwner().equals(p.getUniqueId());
|
||||
|
||||
if (!r) {
|
||||
if (p.hasPermission("plots.worldedit.member") && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
|
||||
r = true;
|
||||
} else if (p.hasPermission("plots.worldedit.bypass")) {
|
||||
removeMask(p, s);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
World w = p.getWorld();
|
||||
|
||||
Location bloc = PlotHelper.getPlotBottomLoc(w, plot.id);
|
||||
Location tloc = PlotHelper.getPlotTopLoc(w, plot.id);
|
||||
|
||||
Vector bvec = new Vector(bloc.getBlockX() + 1, bloc.getBlockY() + 1, bloc.getBlockZ() + 1);
|
||||
Vector tvec = new Vector(tloc.getBlockX(), tloc.getBlockY(), tloc.getBlockZ());
|
||||
|
||||
LocalWorld lw = PlotMain.worldEdit.wrapPlayer(p).getWorld();
|
||||
|
||||
CuboidRegion region = new CuboidRegion(lw, bvec, tvec);
|
||||
com.sk89q.worldedit.masks.RegionMask mask = new com.sk89q.worldedit.masks.RegionMask(region);
|
||||
|
||||
s.setMask(mask);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (s.getMask() == null) {
|
||||
if (noMask(s)) {
|
||||
System.out.print("NONE");
|
||||
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)));
|
||||
Vector p1 = new Vector(69, 69, 69), p2 = new Vector(69, 69, 69);
|
||||
|
||||
s.setMask(new com.sk89q.worldedit.masks.RegionMask(new CuboidRegion(plr.getWorld(), p1, p2)));
|
||||
}
|
||||
} catch(Exception e) {
|
||||
throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean noMask(LocalSession s) {
|
||||
try {
|
||||
com.sk89q.worldedit.masks.Mask mask = s.getMask();
|
||||
return mask==null;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeMask(Player p, LocalSession s) {
|
||||
System.out.print(0);
|
||||
try {
|
||||
System.out.print(1);
|
||||
s.setMask(null);
|
||||
System.out.print(2);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
System.out.print(3);
|
||||
com.sk89q.worldedit.masks.Mask mask = null;
|
||||
s.setMask(mask);
|
||||
System.out.print(4);
|
||||
}
|
||||
System.out.print(5);
|
||||
}
|
||||
|
||||
public static void removeMask(Player p) {
|
||||
try {
|
||||
LocalSession s;
|
||||
@ -71,7 +108,7 @@ public class PWE {
|
||||
} else {
|
||||
s = PlotMain.worldEdit.getSession(p);
|
||||
}
|
||||
s.setMask(null);
|
||||
removeMask(p, s);
|
||||
} catch(Exception e) {
|
||||
throw new PlotSquaredException(PlotSquaredException.PlotError.MISSING_DEPENDENCY, "WorldEdit == Null?");
|
||||
}
|
||||
|
@ -145,6 +145,41 @@ public class PlotMain extends JavaPlugin {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a player for a permission<br>
|
||||
* - Op has all permissions <br>
|
||||
* - checks for '*' nodes
|
||||
* @param player
|
||||
* @param perm
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasPermissions(Player player, String[] perms) {
|
||||
if (player.isOp()) {
|
||||
return true;
|
||||
}
|
||||
for (String perm:perms) {
|
||||
boolean hasperm = false;
|
||||
if (player.hasPermission(perm)) {
|
||||
hasperm = true;
|
||||
}
|
||||
else {
|
||||
String[] nodes = perm.split("\\.");
|
||||
StringBuilder n = new StringBuilder();
|
||||
for(int i = 0; i < nodes.length-1; i++) {
|
||||
n.append(nodes[i]+".");
|
||||
if (player.hasPermission(n+"*")) {
|
||||
hasperm = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hasperm)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a player for a permission<br>
|
||||
* - Op has all permissions <br>
|
||||
|
@ -3,7 +3,13 @@ package com.intellectualcrafters.plot.commands;
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.PlotWorld;
|
||||
import com.intellectualcrafters.plot.WorldGenerator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
@ -17,41 +23,36 @@ public class Setup extends SubCommand implements Listener {
|
||||
|
||||
public static Map<String, SetupObject> setupMap = new HashMap<>();
|
||||
|
||||
/*
|
||||
ROAD_HEIGHT
|
||||
PLOT_HEIGHT
|
||||
WALL_HEIGHT
|
||||
PLOT_WIDTH
|
||||
ROAD_WIDTH
|
||||
PLOT_BIOME
|
||||
MAIN_BLOCK
|
||||
TOP_BLOCK
|
||||
WALL_BLOCK
|
||||
WALL_FILLING
|
||||
ROAD_STRIPES
|
||||
ROAD_STRIPES_ENABLED
|
||||
ROAD_BLOCK
|
||||
PLOT_CHAT
|
||||
BLOCKS
|
||||
SCHEMATIC_ON_CLAIM
|
||||
SCHEMATIC_FILE
|
||||
DEFAULT_FLAGS
|
||||
*/
|
||||
private static class SetupStep {
|
||||
private String constant;
|
||||
private Object default_value;
|
||||
private String description;
|
||||
private Object value = 0;
|
||||
private String type;
|
||||
public SetupStep(String constant, Object default_value, String description, String type) {
|
||||
private Class type;
|
||||
public SetupStep(String constant, Object default_value, String description, Class type) {
|
||||
this.constant = constant;
|
||||
this.default_value = default_value;
|
||||
this.description = description;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return this.type;
|
||||
public Class getType() {
|
||||
if (this.type == Integer.class) {
|
||||
return Integer.class;
|
||||
}
|
||||
if (this.type == Boolean.class) {
|
||||
return Boolean.class;
|
||||
}
|
||||
if (this.type == Double.class) {
|
||||
return Double.class;
|
||||
}
|
||||
if (this.type == Float.class) {
|
||||
return Float.class;
|
||||
}
|
||||
if (this.type == String.class) {
|
||||
return String.class;
|
||||
}
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
public boolean setValue(Object o) {
|
||||
@ -59,7 +60,29 @@ public class Setup extends SubCommand implements Listener {
|
||||
}
|
||||
|
||||
public boolean validValue(String string) {
|
||||
return true;
|
||||
try {
|
||||
if (this.type == Integer.class) {
|
||||
Integer.parseInt(string);
|
||||
return true;
|
||||
}
|
||||
if (this.type == Boolean.class) {
|
||||
Boolean.parseBoolean(string);
|
||||
return true;
|
||||
}
|
||||
if (this.type == Double.class) {
|
||||
Double.parseDouble(string);
|
||||
return true;
|
||||
}
|
||||
if (this.type == Float.class) {
|
||||
Float.parseFloat(string);
|
||||
return true;
|
||||
}
|
||||
if (this.type == String.class) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
@ -83,24 +106,30 @@ public class Setup extends SubCommand implements Listener {
|
||||
String world;
|
||||
int current = 0;
|
||||
PlotWorld p;
|
||||
|
||||
SetupStep[] step = new SetupStep[] {
|
||||
new SetupStep("road_height", 64, "Height of road", "integer") {
|
||||
@Override
|
||||
public boolean validValue(String string) {
|
||||
try {
|
||||
int t = Integer.parseInt(string);
|
||||
} catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
/*
|
||||
ROAD_HEIGHT - Integer
|
||||
PLOT_HEIGHT - Integer
|
||||
WALL_HEIGHT - Integer
|
||||
PLOT_WIDTH - Integer
|
||||
ROAD_WIDTH - Integer
|
||||
PLOT_BIOME - BIOME
|
||||
MAIN_BLOCK - Block[] (as you can have several blocks, with IDS)
|
||||
TOP_BLOCK - Block[] (as you can have several blocks, with IDS)
|
||||
WALL_BLOCK - Block
|
||||
WALL_FILLING - Block
|
||||
ROAD_STRIPES - Block
|
||||
ROAD_STRIPES_ENABLED - Boolean
|
||||
ROAD_BLOCK - Block
|
||||
PLOT_CHAT - Boolean
|
||||
BLOCKS - wtf is this?
|
||||
SCHEMATIC_ON_CLAIM - Boolean
|
||||
SCHEMATIC_FILE - String
|
||||
DEFAULT_FLAGS - String[]
|
||||
*/
|
||||
SetupStep[] step = new SetupStep[] { new SetupStep("road_height", 64, "Height of road", Integer.class) };
|
||||
|
||||
public SetupObject(String world) {
|
||||
this.world = world;
|
||||
|
||||
this.p = new PlotWorld();
|
||||
}
|
||||
|
||||
@ -121,6 +150,28 @@ public class Setup extends SubCommand implements Listener {
|
||||
super("setup", "plots.admin", "Setup a PlotWorld", "/plot setup {world}", "setup", CommandCategory.ACTIONS);
|
||||
}
|
||||
|
||||
/*
|
||||
* /plot setup {world} <default> - setup a world using default values
|
||||
* (display current default settings)
|
||||
* (use ordinary chat to get/set)
|
||||
* <value> <option> - modify a value
|
||||
* /plot setup create - create the world
|
||||
*
|
||||
* /plot setup {world} <world> - setup a world using the values for an existing world
|
||||
* (display current world settings)
|
||||
* (use ordinary chat to get/set)
|
||||
* <value> <option> - modify a value
|
||||
* /plot setup create - create the world
|
||||
*
|
||||
* /plot setup {world} - setup the world manually
|
||||
* (display current world settings)
|
||||
* (use ordinary chat to set)
|
||||
* <option> - set the current value
|
||||
* back - to go back a step
|
||||
* /plot setup create - create the world
|
||||
*
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean execute(Player plr, String... args) {
|
||||
if(setupMap.containsKey(plr.getName())) {
|
||||
@ -128,11 +179,18 @@ public class Setup extends SubCommand implements Listener {
|
||||
if(object.getCurrent() == object.getMax()) {
|
||||
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
||||
setupMap.remove(plr.getName());
|
||||
|
||||
// Save stuff to config
|
||||
|
||||
// Generate a world
|
||||
// String name = "{world}";
|
||||
// World world = WorldCreator.name(name).generator(new WorldGenerator(name)).createWorld();
|
||||
|
||||
return true;
|
||||
}
|
||||
SetupStep step = object.step[object.current];
|
||||
if(args.length < 1) {
|
||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType(), step.getDefaultValue() + "");
|
||||
sendMessage(plr, C.SETUP_STEP, object.current + 1 + "", step.getDescription(), step.getType().getName(), step.getDefaultValue() + "");
|
||||
return true;
|
||||
} else {
|
||||
boolean valid = step.validValue(args[0]);
|
||||
|
@ -200,7 +200,7 @@ public class PlayerEvents implements Listener {
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Gotta catch them all.
|
||||
// Gotta catch 'em all.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
package com.intellectualcrafters.plot.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -10,8 +11,20 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.PWE;
|
||||
import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotHelper;
|
||||
import com.intellectualcrafters.plot.PlotId;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -20,69 +33,88 @@ import org.bukkit.event.player.*;
|
||||
*/
|
||||
public class WorldEditListener implements Listener {
|
||||
|
||||
public final Set<String> blockedcmds = new HashSet<String>(Arrays.asList("/gmask", "//gmask", "/worldedit:gmask"));
|
||||
public final Set<String> restrictedcmds = new HashSet<String>(Arrays.asList("/up", "//up", "/worldedit:up"));
|
||||
|
||||
private boolean isPlotWorld(Location l) {
|
||||
return (PlotMain.isPlotWorld(l.getWorld()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerMove(final PlayerMoveEvent e) {
|
||||
if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) {
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
Block b = e.getClickedBlock();
|
||||
if (b == null) {
|
||||
return;
|
||||
}
|
||||
Location f = e.getFrom();
|
||||
Location t = e.getTo();
|
||||
boolean cm = false;
|
||||
Player p = e.getPlayer();
|
||||
if (t == null) {
|
||||
PWE.removeMask(p);
|
||||
} else {
|
||||
if (f != null) {
|
||||
if (!f.getWorld().getName().equalsIgnoreCase(t.getWorld().getName())) {
|
||||
cm = true;
|
||||
} else if ((f.getBlockX() != t.getBlockX()) || (f.getBlockZ() != t.getBlockZ())) {
|
||||
PlotId idF = PlayerFunctions.getPlot(f);
|
||||
PlotId idT = PlayerFunctions.getPlot(t);
|
||||
if (!(idF == idT)) {
|
||||
cm = true;
|
||||
}
|
||||
}
|
||||
Location l = b.getLocation();
|
||||
if (!isPlotWorld(l)) {
|
||||
return;
|
||||
}
|
||||
p.getItemInHand();
|
||||
if ((p.getItemInHand() == null) || (p.getItemInHand().getType() == Material.AIR)) {
|
||||
return;
|
||||
}
|
||||
Plot plot = PlotHelper.getCurrentPlot(b.getLocation());
|
||||
if (plot != null) {
|
||||
if ((plot != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
|
||||
PWE.setMask(p, l);
|
||||
}
|
||||
if (cm) {
|
||||
if (isPlotWorld(t)) {
|
||||
PWE.setMask(p, p.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (PlotMain.hasPermission(p, "plots.worldedit.bypass") || !PlotMain.isPlotWorld(p.getWorld())) {
|
||||
return;
|
||||
}
|
||||
String cmd = e.getMessage().toLowerCase();
|
||||
|
||||
if (cmd.contains(" ")) {
|
||||
cmd = cmd.substring(0, cmd.indexOf(" "));
|
||||
}
|
||||
if (this.restrictedcmds.contains(cmd)) {
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(p);
|
||||
if ((plot == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else if (this.blockedcmds.contains(cmd)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerJoin(final PlayerJoinEvent e) {
|
||||
if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) {
|
||||
Player p = e.getPlayer();
|
||||
if (PlotMain.hasPermission(p, "plots.worldedit.bypass")) {
|
||||
return;
|
||||
}
|
||||
Player p = e.getPlayer();
|
||||
if (isPlotWorld(p.getLocation())) {
|
||||
PWE.setMask(p, p.getLocation());
|
||||
Location l = p.getLocation();
|
||||
if (isPlotWorld(l)) {
|
||||
PWE.setMask(p, l);
|
||||
} else {
|
||||
PWE.removeMask(p);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onTeleport(final PlayerTeleportEvent e) {
|
||||
if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) {
|
||||
public void onPlayerMove(final PlayerMoveEvent e) {
|
||||
Location t = e.getTo();
|
||||
if (!isPlotWorld(t)) {
|
||||
return;
|
||||
}
|
||||
Location f = e.getFrom();
|
||||
Player p = e.getPlayer();
|
||||
Location f = e.getFrom(), t = e.getTo();
|
||||
|
||||
if (t == null) {
|
||||
PWE.removeMask(p);
|
||||
} else {
|
||||
if ((f != null) && isPlotWorld(f) && !isPlotWorld(t)) {
|
||||
PWE.removeMask(p);
|
||||
} else if (isPlotWorld(t)) {
|
||||
PWE.setMask(p, p.getLocation());
|
||||
if ((f.getBlockX() != t.getBlockX()) || (f.getBlockZ() != t.getBlockZ())) {
|
||||
PlotId idF = PlayerFunctions.getPlot(f);
|
||||
PlotId idT = PlayerFunctions.getPlot(t);
|
||||
if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) {
|
||||
return;
|
||||
}
|
||||
if (idT!=null && !(idF == idT)) {
|
||||
PWE.setMask(p, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,53 +125,35 @@ public class WorldEditListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Player p = e.getPlayer();
|
||||
Location f = e.getFrom(), t = e.getTo();
|
||||
if (t == null) {
|
||||
PWE.removeMask(p);
|
||||
} else {
|
||||
if ((f != null) && isPlotWorld(f) && !isPlotWorld(t)) {
|
||||
Location t = e.getTo();
|
||||
Location f = e.getFrom();
|
||||
if (!isPlotWorld(t)) {
|
||||
if (isPlotWorld(f)) {
|
||||
PWE.removeMask(p);
|
||||
} else if (isPlotWorld(t)) {
|
||||
PWE.setMask(p, p.getLocation());
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
PWE.setMask(p, t);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerCommand(PlayerCommandPreprocessEvent e) {
|
||||
public void onTeleport(final PlayerTeleportEvent e) {
|
||||
if (PlotMain.hasPermission(e.getPlayer(), "plots.worldedit.bypass")) {
|
||||
return;
|
||||
}
|
||||
Player p = e.getPlayer();
|
||||
if (isPlotWorld(p.getLocation())) {
|
||||
String msg = e.getMessage().toLowerCase();
|
||||
if (msg.startsWith("//gmask") || msg.startsWith("/gmask") || msg.startsWith("/worldedit:gmask") || msg.startsWith("/worldedit:/gmask")) {
|
||||
e.setCancelled(true);
|
||||
} else if (msg.startsWith("/up") || msg.startsWith("//up") || msg.startsWith("/worldedit:up") || msg.startsWith("/worldedit:/up")) {
|
||||
Plot plot = PlayerFunctions.getCurrentPlot(p);
|
||||
if ((p == null) || !(plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (PlotMain.hasPermission(p, "plots.worldedit.bypass")) {
|
||||
return;
|
||||
}
|
||||
if (!p.hasPermission("plots.admin") && isPlotWorld(p.getLocation())) {
|
||||
if (((e.getAction() == Action.LEFT_CLICK_BLOCK) || (e.getAction() == Action.RIGHT_CLICK_BLOCK)) && (p.getItemInHand() != null) && (p.getItemInHand().getType() != Material.AIR)) {
|
||||
Block b = e.getClickedBlock();
|
||||
Plot plot = PlotHelper.getCurrentPlot(b.getLocation());
|
||||
if ((plot != null) && (plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(p.getUniqueId()))) {
|
||||
PWE.setMask(p, b.getLocation());
|
||||
} else {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
Location t = e.getTo();
|
||||
Location f = e.getFrom();
|
||||
if (!isPlotWorld(t)) {
|
||||
if (isPlotWorld(f)) {
|
||||
PWE.removeMask(p);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
PWE.setMask(p, t);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user