Several changes:

- Several API improvements
- persistent WorldEdit bypass toggle
- persistent plot chat toggle
- Plot BO3 exporting (useful f
- Fix fastmode clearing unclaim border
- Add player-interact flag for NPC interaction etc. Fixes #543
- Several fixes for sponge
- some code cleanup
- Closes #529
This commit is contained in:
boy0001 2015-08-18 23:20:11 +10:00
parent fcfd6616be
commit b059de5098
43 changed files with 1067 additions and 473 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<artifactId>PlotSquared</artifactId> <artifactId>PlotSquared</artifactId>
<version>3.0.17</version> <version>3.1.0</version>
<name>PlotSquared</name> <name>PlotSquared</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>

View File

@ -168,12 +168,12 @@ public class PS {
IMP.runEntityTask(); IMP.runEntityTask();
} }
// Events // Events
IMP.registerWorldEditEvents();
IMP.registerCommands(); IMP.registerCommands();
IMP.registerPlayerEvents(); IMP.registerPlayerEvents();
IMP.registerInventoryEvents(); IMP.registerInventoryEvents();
IMP.registerPlotPlusEvents(); IMP.registerPlotPlusEvents();
IMP.registerForceFieldEvents(); IMP.registerForceFieldEvents();
IMP.registerWorldEditEvents();
IMP.registerWorldEvents(); IMP.registerWorldEvents();
if (Settings.METRICS) { if (Settings.METRICS) {
IMP.startMetrics(); IMP.startMetrics();
@ -1645,6 +1645,7 @@ public class PS {
FlagManager.addFlag(new AbstractFlag("animal-attack", new FlagValue.BooleanValue())); FlagManager.addFlag(new AbstractFlag("animal-attack", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("tamed-interact", new FlagValue.BooleanValue())); FlagManager.addFlag(new AbstractFlag("tamed-interact", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("tamed-attack", new FlagValue.BooleanValue())); FlagManager.addFlag(new AbstractFlag("tamed-attack", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("player-interact", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("misc-interact", new FlagValue.BooleanValue())); FlagManager.addFlag(new AbstractFlag("misc-interact", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("misc-place", new FlagValue.BooleanValue())); FlagManager.addFlag(new AbstractFlag("misc-place", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("misc-break", new FlagValue.BooleanValue())); FlagManager.addFlag(new AbstractFlag("misc-break", new FlagValue.BooleanValue()));
@ -1799,6 +1800,7 @@ public class PS {
// Schematics // Schematics
options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH);
options.put("bo3.save_path", Settings.BO3_SAVE_PATH);
// Web // Web
options.put("web.url", Settings.WEB_URL); options.put("web.url", Settings.WEB_URL);
@ -1906,6 +1908,7 @@ public class PS {
// Schematics // Schematics
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");
Settings.BO3_SAVE_PATH = config.getString("bo3.save_path");
// Web // Web
Settings.WEB_URL = config.getString("web.url"); Settings.WEB_URL = config.getString("web.url");

View File

@ -24,8 +24,10 @@ package com.intellectualcrafters.plot.api;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -67,22 +69,27 @@ public class PlotAPI {
/** /**
* Permission that allows for admin access, this permission node will allow the player to use any part of the * Permission that allows for admin access, this permission node will allow the player to use any part of the
* plugin, without limitations. * plugin, without limitations.
* @deprecated Use C.PERMISSION_ADMIN.s() instead
*/ */
public static final String ADMIN_PERMISSION = "plots.admin"; @Deprecated
public static final String ADMIN_PERMISSION = C.PERMISSION_ADMIN.s();
/** /**
* Constructor. Insert any Plugin. (Optimally the plugin that is accessing the method) * @deprecated Use new PlotAPI() instead
*
* @param plugin Plugin used to access this method
*
* @throws com.intellectualcrafters.plot.util.PlotSquaredException if the program fails to fetch the PlotSquared
* instance
* @see com.intellectualcrafters.plot.PS
*/ */
@Deprecated @Deprecated
public PlotAPI(final JavaPlugin plugin) { public PlotAPI(final JavaPlugin plugin) {
} }
/**
* @param plugin Plugin used to access this method
*
* @throws com.intellectualcrafters.plot.util.PlotSquaredException if the program fails to fetch the PlotSquared
* instance
* @see com.intellectualcrafters.plot.PS
*
* @deprecated Use new PlotAPI() instead
*/
public PlotAPI() { public PlotAPI() {
} }
@ -241,16 +248,22 @@ public class PlotAPI {
} }
/** /**
* Do not use this. Instead use Permissions.[method] in your code. * Do not use this. Instead use C.PERMISSION_[method] in your code.
* - Basic permission management stuff * - Basic permission management stuff
* *
* @return MainUtil * @return Array of strings
* *
* @see com.intellectualcrafters.plot.util.Permissions * @see com.intellectualcrafters.plot.util.Permissions
*/ */
@Deprecated @Deprecated
public Permissions[] getPermissions() { public String[] getPermissions() {
return Permissions.values(); ArrayList<String> perms = new ArrayList<>();
for (C c : C.values()) {
if (c.getCat().equals("static.permissions")) {
perms.add(c.s());
}
}
return perms.toArray(new String[0]);
} }
/** /**
@ -671,4 +684,54 @@ public class PlotAPI {
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer pp = BukkitUtil.getPlayer(player);
return MainUtil.getAllowedPlots(pp); return MainUtil.getAllowedPlots(pp);
} }
/**
* Get the PlotPlayer for a player<br>
* - The PlotPlayer is usually cached and will provide useful functions relating to players
*
* @see PlotPlayer.wrap(Player|OfflinePlayer|String|UUID)
*
* @param player
* @return
*/
public PlotPlayer wrapPlayer(Player player) {
return PlotPlayer.wrap(player);
}
/**
* Get the PlotPlayer for a UUID (Please note that PlotSquared can be configured to provide different UUIDs than bukkit)
*
* @see PlotPlayer.wrap(UUID uuid)
*
* @param player
* @return
*/
public PlotPlayer wrapPlayer(UUID uuid) {
return PlotPlayer.wrap(uuid);
}
/**
* Get the PlotPlayer for a username
*
* @see PlotPlayer.wrap(String name)
*
* @param player
* @return
*/
public PlotPlayer wrapPlayer(String player) {
return PlotPlayer.wrap(player);
}
/**
* Get the PlotPlayer for an offline player<br>
* Note that this will work if the player is offline, however not all functionality will work
*
* @see PlotPlayer.wrap(OfflinePlayer op)
*
* @param player
* @return
*/
public PlotPlayer wrapPlayer(OfflinePlayer player) {
return PlotPlayer.wrap(player);
}
} }

View File

@ -153,7 +153,7 @@ public class Auto extends SubCommand {
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
return true; return true;
} }
if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !Permissions.hasPermission(plr, "plots.admin.command.schematic")) {
MainUtil.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); MainUtil.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
return true; return true;
} }

View File

@ -0,0 +1,90 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
// PlotSquared - A plot manager and world generator for the Bukkit API /
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
// /
// This program is free software; you can redistribute it and/or modify /
// it under the terms of the GNU General Public License as published by /
// the Free Software Foundation; either version 3 of the License, or /
// (at your option) any later version. /
// /
// This program is distributed in the hope that it will be useful, /
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
// GNU General Public License for more details. /
// /
// You should have received a copy of the GNU General Public License /
// along with this program; if not, write to the Free Software Foundation, /
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
// /
// You can contact us via: support@intellectualsites.com /
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.BO3Handler;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(
command = "bo3",
aliases = {"bo2"},
description = "Mark a plot as done",
permission = "plots.done",
category = CommandCategory.ACTIONS,
requiredType = RequiredType.NONE
)
public class BO3 extends SubCommand {
public void noArgs(PlotPlayer plr) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 export [category] [alias] [-r]");
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 import <file>");
}
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location loc = plr.getLocation();
final Plot plot = MainUtil.getPlot(loc);
if (plot == null || !plot.hasOwner()) {
return !sendMessage(plr, C.NOT_IN_PLOT);
}
if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.bo3")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}
if (args.length == 0) {
noArgs(plr);
return false;
}
switch (args[0].toLowerCase()) {
case "output":
case "save":
case "export": {
return BO3Handler.saveBO3(plr, plot);
}
case "paste":
case "load":
case "import":
case "input": {
// TODO NOT IMPLEMENTED YET
MainUtil.sendMessage(plr, "NOT IMPLEMENTED YET!!!");
return false;
}
default: {
noArgs(plr);
return false;
}
}
}
}

View File

@ -17,25 +17,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
public class Chat extends SubCommand { public class Chat extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String ... args) { public boolean onCommand(final PlotPlayer player, final String ... args) {
return MainCommand.onCommand(player, "plot", new String[] {"toggle", "chat"});
final String world = plr.getLocation().getWorld();
if (!PS.get().isPlotWorld(world)) {
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
}
boolean enable = !(plr.getMeta("chat") != null && (Boolean) plr.getMeta("chat"));
if (args.length > 0) {
if (args[0].equalsIgnoreCase("on")) {
enable = true;
} else if (args[0].equalsIgnoreCase("off")) {
enable = false;
}
}
final PlotWorld plotworld = PS.get().getPlotWorld(world);
if (!enable && plotworld.PLOT_CHAT) {
return !sendMessage(plr, C.PLOT_CHAT_FORCED);
}
plr.setMeta("chat", enable);
return sendMessage(plr, enable ? C.PLOT_CHAT_ON : C.PLOT_CHAT_OFF);
} }
} }

View File

@ -129,7 +129,7 @@ public class Claim extends SubCommand {
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) { if (!world.SCHEMATICS.contains(schematic.toLowerCase())) {
return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic); return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
} }
if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) { if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !Permissions.hasPermission(plr, "plots.admin.command.schematic")) {
return sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); return sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
} }
} }

View File

@ -39,7 +39,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration( @CommandDeclaration(
command = "continue", command = "continue",
description = "Continue a plot that was previously marked as done", description = "Continue a plot that was previously marked as done",
permission = "plots.done", permission = "plots.continue",
category = CommandCategory.ACTIONS, category = CommandCategory.ACTIONS,
requiredType = RequiredType.NONE requiredType = RequiredType.NONE
) )
@ -52,7 +52,7 @@ public class Continue extends SubCommand {
if (plot == null || !plot.hasOwner()) { if (plot == null || !plot.hasOwner()) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(plr, C.NOT_IN_PLOT);
} }
if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) { if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.continue")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;
} }

View File

@ -54,7 +54,7 @@ public class Copy extends SubCommand {
if (plot1 == null) { if (plot1 == null) {
return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT); return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
} }
if (!plot1.isAdded(plr.getUUID()) && !plr.hasPermission(Permissions.ADMIN.s)) { if (!plot1.isAdded(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;
} }

View File

@ -157,9 +157,6 @@ public class DebugExec extends SubCommand {
for (Enum<?> value : C.values()) { for (Enum<?> value : C.values()) {
scope.put("C_" + value.name(), value); scope.put("C_" + value.name(), value);
} }
for (Enum<?> value : Permissions.values()) {
scope.put("Permissions_" + value.name(), value);
}
} }
@Override @Override

View File

@ -53,7 +53,7 @@ public class Done extends SubCommand {
if (plot == null || !plot.hasOwner()) { if (plot == null || !plot.hasOwner()) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(plr, C.NOT_IN_PLOT);
} }
if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) { if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.done")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;
} }

View File

@ -78,7 +78,7 @@ public class FlagCmd extends SubCommand {
sendMessage(player, C.PLOT_NOT_CLAIMED); sendMessage(player, C.PLOT_NOT_CLAIMED);
return false; return false;
} }
if (!plot.isAdded(player.getUUID()) && !Permissions.hasPermission(player, "plots.set.flag.other")) { if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.set.flag.other")) {
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag.other"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag.other");
return false; return false;
} }

View File

@ -129,6 +129,8 @@ public class MainCommand extends CommandManager<PlotPlayer> {
createCommand(new Chat()); createCommand(new Chat());
createCommand(new Trim()); createCommand(new Trim());
createCommand(new Done()); createCommand(new Done());
createCommand(new Continue());
createCommand(new BO3());
if (Settings.ENABLE_CLUSTERS) { if (Settings.ENABLE_CLUSTERS) {
MainCommand.getInstance().addCommand(new Cluster()); MainCommand.getInstance().addCommand(new Cluster());
} }
@ -419,7 +421,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
} }
return CommandHandlingOutput.CALLER_OF_WRONG_TYPE; return CommandHandlingOutput.CALLER_OF_WRONG_TYPE;
} }
if (!plr.hasPermission(cmd.getPermission())) { if (!Permissions.hasPermission(plr, cmd.getPermission())) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, cmd.getPermission()); MainUtil.sendMessage(plr, C.NO_PERMISSION, cmd.getPermission());
return CommandHandlingOutput.NOT_PERMITTED; return CommandHandlingOutput.NOT_PERMITTED;
} }

View File

@ -175,8 +175,8 @@ public class Merge extends SubCommand {
multiUUID.add(u2); multiUUID.add(u2);
} }
if (multiMerge) { if (multiMerge) {
if (!Permissions.hasPermission(plr, Permissions.MERGE_OTHER)) { if (!Permissions.hasPermission(plr, C.PERMISSION_MERGE_OTHER)) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, Permissions.MERGE_OTHER.s); MainUtil.sendMessage(plr, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER.s());
return false; return false;
} }
for (final UUID uuid : multiUUID) { for (final UUID uuid : multiUUID) {

View File

@ -56,7 +56,7 @@ public class Move extends SubCommand {
if (plot1 == null) { if (plot1 == null) {
return !sendMessage(plr, C.NOT_IN_PLOT); return !sendMessage(plr, C.NOT_IN_PLOT);
} }
if (!plot1.isAdded(plr.getUUID()) && !plr.hasPermission(Permissions.ADMIN.s)) { if (!plot1.isAdded(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false; return false;
} }

View File

@ -75,7 +75,7 @@ public class Set extends SubCommand {
sendMessage(plr, C.PLOT_NOT_CLAIMED); sendMessage(plr, C.PLOT_NOT_CLAIMED);
return false; return false;
} }
if (!plot.isAdded(plr.getUUID())) { if (!plot.isOwner(plr.getUUID())) {
if (!Permissions.hasPermission(plr, "plots.set.other")) { if (!Permissions.hasPermission(plr, "plots.set.other")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set.other"); MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set.other");
return false; return false;

View File

@ -20,17 +20,25 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map.Entry;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.bukkit.BukkitMain;
import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandCaller;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
// TOGGLE("toggle", "attribute"),
@CommandDeclaration( @CommandDeclaration(
command = "toggle", command = "toggle",
aliases = {"attribute"}, aliases = {"attribute"},
permission = "plots.toggle", permission = "plots.use",
description = "Toggle per user settings", description = "Toggle per user settings",
usage = "/plot toggle <setting>", usage = "/plot toggle <setting>",
requiredType = RequiredType.NONE, requiredType = RequiredType.NONE,
@ -40,7 +48,66 @@ public class Toggle extends SubCommand {
public void noArgs(PlotPlayer plr) { public void noArgs(PlotPlayer plr) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot toggle <setting>"); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot toggle <setting>");
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + "titles"); ArrayList<String> options = new ArrayList<>();
for (Entry<String, Command<PlotPlayer>> entry : toggles.entrySet()) {
if (Permissions.hasPermission(plr, entry.getValue().getPermission())) {
options.add(entry.getKey());
}
}
if (options.size() > 0) {
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringMan.join(options, ","));
}
}
private HashMap<String, Command<PlotPlayer>> toggles;
public Toggle() {
toggles = new HashMap<>();
toggles.put("titles",
new Command<PlotPlayer>("titles", "/plot toggle titles", "Toggle titles for yourself", C.PERMISSION_PLOT_TOGGLE_TITLES.s()) {
@Override
public boolean onCommand(PlotPlayer player, String[] args) {
if (toggle(player, "disabletitles")) {
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, getCommand());
}
else {
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, getCommand());
}
return true;
}
});
toggles.put("chat",
new Command<PlotPlayer>("chat", "/plot toggle chat", "Toggle plot chat for yourself", C.PERMISSION_PLOT_TOGGLE_CHAT.s()) {
@Override
public boolean onCommand(PlotPlayer player, String[] args) {
if (toggle(player, "chat")) {
MainUtil.sendMessage(player, C.PLOT_CHAT_OFF);
}
else {
MainUtil.sendMessage(player, C.PLOT_CHAT_ON);
}
return true;
}
});
if (BukkitMain.worldEdit != null) {
toggles.put("worldedit",
new Command<PlotPlayer>("worldedit", "/plot toggle worldedit", "Toggle worldedit bypass", C.PERMISSION_WORLDEDIT_BYPASS.s()) {
@Override
public boolean onCommand(PlotPlayer player, String[] args) {
if (toggle(player, "worldedit")) {
MainUtil.sendMessage(player, C.WORLDEDIT_RESTRICTED);
}
else {
MainUtil.sendMessage(player, C.WORLDEDIT_UNMASKED);
}
return true;
}
});
}
} }
@Override @Override
@ -49,20 +116,16 @@ public class Toggle extends SubCommand {
noArgs(player); noArgs(player);
return false; return false;
} }
switch (args[0].toLowerCase()) { Command<PlotPlayer> cmd = toggles.get(args[0].toLowerCase());
case "titles": { if (cmd == null) {
if (toggle(player, "disabletitles")) { noArgs(player);
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, args[0]);
}
else {
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, args[0]);
}
return true;
}
default: {
return false; return false;
} }
if (!Permissions.hasPermission(player, cmd.getPermission())) {
C.NO_PERMISSION.send(player, cmd.getPermission());
return false;
} }
return cmd.onCommand(player, Arrays.copyOfRange(args, 1, args.length));
} }
public boolean toggle(PlotPlayer player, String key) { public boolean toggle(PlotPlayer player, String key) {

View File

@ -37,25 +37,13 @@ import com.plotsquared.general.commands.CommandDeclaration;
requiredType = RequiredType.NONE, requiredType = RequiredType.NONE,
category = CommandCategory.DEBUG category = CommandCategory.DEBUG
) )
@Deprecated
public class WE_Anywhere extends SubCommand { public class WE_Anywhere extends SubCommand {
@Override @Override
public boolean onCommand(PlotPlayer player, String[] arguments) { public boolean onCommand(PlotPlayer player, String[] arguments) {
if (BukkitMain.worldEdit == null) { return MainCommand.onCommand(player, "plot", new String[] {"toggle", "worldedit"});
MainUtil.sendMessage(player, "&cWorldEdit is not enabled on this server");
return true;
}
if (Permissions.hasPermission(player, "plots.worldedit.bypass")) {
if (WEManager.bypass.contains(player.getName())) {
WEManager.bypass.remove(player.getName());
MainUtil.sendMessage(player, C.WORLDEDIT_RESTRICTED);
}
else {
WEManager.bypass.add(player.getName());
MainUtil.sendMessage(player, C.WORLDEDIT_UNMASKED);
}
}
return true;
} }
} }

View File

@ -42,6 +42,45 @@ import com.plotsquared.general.commands.CommandCaller;
*/ */
public enum C { public enum C {
/*
* Static flags
*/
FLAG_USE("use","static.flags"),
FLAG_PLACE("place","static.flags"),
FLAG_PVP("pvp","static.flags"),
FLAG_HANGING_PLACE("hanging-place","static.flags"),
FLAG_HANGING_BREAK("hanging-break","static.flags"),
FLAG_HOSTILE_INTERACT("hostile-interact","static.flags"),
FLAG_ANIMAL_INTERACT("animal-interact","static.flags"),
FLAG_VEHICLE_USE("vehicle-use","static.flags"),
FLAG_PLAYER_INTERACT("player-interact","static.flags"),
FLAG_TAMED_INTERACT("tamed-interact","static.flags"),
FLAG_DISABLE_PHYSICS("disable-physics","static.flags"),
/*
* Static permission
*/
PERMISSION_STAR("*","static.permissions"),
PERMISSION_ADMIN("plots.admin","static.permissions"),
PERMISSION_PROJECTILE_UNOWNED("plots.projectile.unowned","static.permissions"),
PERMISSION_PROJECTILE_OTHER("plots.projectile.other","static.permissions"),
PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS("plots.admin.interact.blockedcommands","static.permissions"),
PERMISSION_WORLDEDIT_BYPASS("plots.worldedit.bypass","static.permissions"),
PERMISSION_PLOT_TOGGLE_TITLES("plots.toggle.titles","static.permissions"),
PERMISSION_PLOT_TOGGLE_CHAT("plots.toggle.chat","static.permissions"),
PERMISSION_ADMIN_EXIT_DENIED("plots.admin.exit.denied","static.permissions"),
PERMISSION_ADMIN_ENTRY_DENIED("plots.admin.entry.denied","static.permissions"),
PERMISSION_COMMANDS_CHAT("plots.admin.command.chat","static.permissions"),
PERMISSION_MERGE_OTHER("plots.merge.other","static.permissions"),
PERMISSION_ADMIN_DESTROY_UNOWNED("plots.admin.destroy.unowned","static.permissions"),
PERMISSION_ADMIN_DESTROY_OTHER( "plots.admin.destroy.other","static.permissions"),
PERMISSION_ADMIN_DESTROY_ROAD("plots.admin.destroy.road","static.permissions"),
PERMISSION_ADMIN_BUILD_ROAD("plots.admin.build.road","static.permissions"),
PERMISSION_ADMIN_BUILD_UNOWNED("plots.admin.build.unowned","static.permissions"),
PERMISSION_ADMIN_BUILD_OTHER("plots.admin.build.other","static.permissions"),
PERMISSION_ADMIN_INTERACT_ROAD("plots.admin.interact.road","static.permissions"),
PERMISSION_ADMIN_INTERACT_UNOWNED("plots.admin.interact.unowned","static.permissions"),
PERMISSION_ADMIN_INTERACT_OTHER("plots.admin.interact.other","static.permissions"),
PERMISSION_ADMIN_BUILD_HEIGHTLIMIT("plots.admin.build.heightlimit","static.permissions"),
/* /*
* Confirm * Confirm
*/ */
@ -108,6 +147,7 @@ public enum C {
WORLDEDIT_ITERATIONS("$2You cannot iterate %current% times. The maximum number of iterations allowed is %max%.", "WorldEdit Masks"), WORLDEDIT_ITERATIONS("$2You cannot iterate %current% times. The maximum number of iterations allowed is %max%.", "WorldEdit Masks"),
WORLDEDIT_UNSAFE("$2Access to that command has been blocked", "WorldEdit Masks"), WORLDEDIT_UNSAFE("$2Access to that command has been blocked", "WorldEdit Masks"),
WORLDEDIT_BYPASS("$2&oTo bypass your restrictions use $4/plot wea", "WorldEdit Masks"), WORLDEDIT_BYPASS("$2&oTo bypass your restrictions use $4/plot wea", "WorldEdit Masks"),
WORLDEDIT_BYPASSED("$2Currently bypassing WorldEdit restriction.", "WorldEdit Masks"),
WORLDEDIT_UNMASKED("$1Your WorldEdit is now unrestricted.", "WorldEdit Masks"), WORLDEDIT_UNMASKED("$1Your WorldEdit is now unrestricted.", "WorldEdit Masks"),
WORLDEDIT_RESTRICTED("$1Your WorldEdit is now restricted.", "WorldEdit Masks"), WORLDEDIT_RESTRICTED("$1Your WorldEdit is now restricted.", "WorldEdit Masks"),
@ -581,6 +621,11 @@ public enum C {
this(d, true, cat.toLowerCase()); this(d, true, cat.toLowerCase());
} }
@Override
public String toString() {
return s;
}
public static String format(String m, Object... args) { public static String format(String m, Object... args) {
if (args.length == 0) { if (args.length == 0) {
return m; return m;
@ -638,6 +683,9 @@ public enum C {
String node = split[split.length - 1].toUpperCase(); String node = split[split.length - 1].toUpperCase();
C caption = allNames.contains(node) ? valueOf(node) : null; C caption = allNames.contains(node) ? valueOf(node) : null;
if (caption != null) { if (caption != null) {
if (caption.cat.startsWith("static")) {
continue;
}
String value = yml.getString(key); String value = yml.getString(key);
if (!split[0].equalsIgnoreCase(caption.cat)) { if (!split[0].equalsIgnoreCase(caption.cat)) {
changed = true; changed = true;
@ -670,6 +718,9 @@ public enum C {
replacements.put("&-", "\n"); replacements.put("&-", "\n");
for (C caption : all) { for (C caption : all) {
if (!captions.contains(caption)) { if (!captions.contains(caption)) {
if (caption.cat.startsWith("static")) {
continue;
}
changed = true; changed = true;
yml.set(caption.cat + "." + caption.name().toLowerCase(), caption.d); yml.set(caption.cat + "." + caption.name().toLowerCase(), caption.d);
} }

View File

@ -115,6 +115,10 @@ public class Settings {
* Schematic Save Path * Schematic Save Path
*/ */
public static String SCHEMATIC_SAVE_PATH = "/var/www/schematics"; public static String SCHEMATIC_SAVE_PATH = "/var/www/schematics";
/**
* BO3 Save Path
*/
public static String BO3_SAVE_PATH = "BO3";
/** /**
* Max allowed plots * Max allowed plots
*/ */

View File

@ -14,7 +14,7 @@ import com.intellectualcrafters.plot.util.SetBlockQueue;
/** /**
* A plot manager with square plots which tesselate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot) * A plot manager with square plots which tesselate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot)
*/ */
public abstract class ClassicPlotManager extends SquarePlotManager { public class ClassicPlotManager extends SquarePlotManager {
@Override @Override
public boolean setComponent(final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks) { public boolean setComponent(final PlotWorld plotworld, final PlotId plotid, final String component, final PlotBlock[] blocks) {
switch (component) { switch (component) {
@ -34,6 +34,17 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
return false; return false;
} }
@Override
public boolean unclaimPlot(PlotWorld plotworld, Plot plot, Runnable whenDone) {
final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld);
setWallFilling(dpw, plot.id, new PlotBlock[] { dpw.WALL_FILLING });
if (dpw.WALL_BLOCK.id != 0 || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) {
setWall(dpw, plot.id, new PlotBlock[] { dpw.WALL_BLOCK });
}
SetBlockQueue.addNotify(whenDone);
return true;
}
public boolean setFloor(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) { public boolean setFloor(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld; final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
final Location pos1 = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1); final Location pos1 = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid).add(1, 0, 1);

View File

@ -167,7 +167,7 @@ public class HybridPlotManager extends ClassicPlotManager {
* to have 512x512 sized plots * to have 512x512 sized plots
*/ */
@Override @Override
public boolean clearPlot(final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) { public boolean clearPlot(final PlotWorld plotworld, final Plot plot, final Runnable whenDone) {
final String world = plotworld.worldname; final String world = plotworld.worldname;
final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld); final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld);
@ -181,8 +181,6 @@ public class HybridPlotManager extends ClassicPlotManager {
final PlotBlock[] bedrock = (dpw.PLOT_BEDROCK ? new PlotBlock[] { new PlotBlock((short) 7, (byte) 0) } : filling); final PlotBlock[] bedrock = (dpw.PLOT_BEDROCK ? new PlotBlock[] { new PlotBlock((short) 7, (byte) 0) } : filling);
final PlotBlock air = new PlotBlock((short) 0, (byte) 0); final PlotBlock air = new PlotBlock((short) 0, (byte) 0);
setWallFilling(dpw, plot.id, new PlotBlock[] { dpw.WALL_FILLING });
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() { ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
@Override @Override
public void run() { public void run() {
@ -216,11 +214,6 @@ public class HybridPlotManager extends ClassicPlotManager {
}, new Runnable() { }, new Runnable() {
@Override @Override
public void run() { public void run() {
// When we are done with the inside of the plot, we can reset the wall / border
final PlotBlock wall = isDelete ? dpw.WALL_BLOCK : dpw.CLAIMED_WALL_BLOCK;
if (wall.id != 0 || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) {
setWall(dpw, plot.id, new PlotBlock[] { wall });
}
// And notify whatever called this when plot clearing is done // And notify whatever called this when plot clearing is done
SetBlockQueue.addNotify(whenDone); SetBlockQueue.addNotify(whenDone);
} }

View File

@ -13,7 +13,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
*/ */
public abstract class SquarePlotManager extends GridPlotManager { public abstract class SquarePlotManager extends GridPlotManager {
@Override @Override
public boolean clearPlot(final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) { public boolean clearPlot(final PlotWorld plotworld, final Plot plot, final Runnable whenDone) {
final Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); final Location pos1 = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
final Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id); final Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id);
ChunkManager.manager.regenerateRegion(pos1, pos2, whenDone); ChunkManager.manager.regenerateRegion(pos1, pos2, whenDone);

View File

@ -0,0 +1,46 @@
package com.intellectualcrafters.plot.object;
public class BO3 {
private final ChunkLoc chunk;
private final StringBuilder blocks;
private final StringBuilder children;
private final String name;
public BO3(String name, ChunkLoc loc) {
this.name = name;
this.chunk = loc;
this.blocks = new StringBuilder();
this.children = new StringBuilder();
}
public void addChild(BO3 child) {
ChunkLoc childloc = child.getLoc();
children.append("Branch(" + (childloc.x - chunk.x) + ",0," + (childloc.z - chunk.z) + "," + name + "_" + childloc.x + "_" + childloc.z + ")\n");
}
public ChunkLoc getLoc() {
return this.chunk;
}
public String getName() {
return name;
}
public void addBlock(int x, int y, int z, PlotBlock block) {
if (block.data == 0) {
// Block(-3,1,-2,AIR)
blocks.append("Block(" + x + "," + y + "," + z + "," + block.id + ")\n");
}
else {
blocks.append("Block(" + x + "," + y + "," + z + "," + block.id + ":" + block.data + ")\n");
}
}
public String getBlocks() {
return blocks.toString();
}
public String getChildren() {
return children.toString();
}
}

View File

@ -20,6 +20,8 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.object; package com.intellectualcrafters.plot.object;
import java.io.File;
import java.net.URL;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -28,13 +30,18 @@ import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.UUID; import java.util.UUID;
import com.intellectualcrafters.jnbt.CompoundTag;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Configuration; import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.util.BO3Handler;
import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
/** /**
@ -717,6 +724,71 @@ public class Plot {
return false; return false;
} }
/**
* Export the plot as a schematic to the configured output directory
* @return
*/
public void export(final RunnableVal<Boolean> whenDone) {
SchematicHandler.manager.getCompoundTag(world, id, new RunnableVal<CompoundTag>() {
@Override
public void run() {
if (value == null) {
if (whenDone != null) {
whenDone.value = false;
TaskManager.runTask(whenDone);
}
}
else {
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
String name = id+ "," + world + "," + MainUtil.getName(owner);
final boolean result = SchematicHandler.manager.save(value, Settings.SCHEMATIC_SAVE_PATH + File.separator + name + ".schematic");
if (whenDone != null) {
whenDone.value = result;
TaskManager.runTask(whenDone);
}
}
});
}
}
});
}
/**
* Export the plot as a BO3 object
* @param whenDone value will be false if exporting fails
*/
public void exportBO3(final RunnableVal<Boolean> whenDone) {
boolean result = BO3Handler.saveBO3(this);
if (whenDone != null) {
whenDone.value = result;
}
TaskManager.runTask(whenDone);
}
/**
* Upload the plot to the configured web interface
* @param whenDone value will be null if uploading fails
*/
public void upload(final RunnableVal<URL> whenDone) {
SchematicHandler.manager.getCompoundTag(world, id, new RunnableVal<CompoundTag>() {
@Override
public void run() {
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
URL url = SchematicHandler.manager.upload(value, null, null);
if (whenDone != null) {
whenDone.value = url;
}
TaskManager.runTask(whenDone);
}
});
}
});
}
@Override @Override
public boolean equals(final Object obj) { public boolean equals(final Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -45,10 +45,12 @@ public abstract class PlotManager {
/* /*
* Plot clearing (return false if you do not support some method) * Plot clearing (return false if you do not support some method)
*/ */
public abstract boolean clearPlot(final PlotWorld plotworld, final Plot plot, boolean isDelete, Runnable whenDone); public abstract boolean clearPlot(final PlotWorld plotworld, final Plot plot, Runnable whenDone);
public abstract boolean claimPlot(final PlotWorld plotworld, final Plot plot); public abstract boolean claimPlot(final PlotWorld plotworld, final Plot plot);
public abstract boolean unclaimPlot(final PlotWorld plotworld, final Plot plot, Runnable whenDone);
public abstract Location getSignLoc(final PlotWorld plotworld, final Plot plot); public abstract Location getSignLoc(final PlotWorld plotworld, final Plot plot);
/* /*

View File

@ -176,8 +176,12 @@ public abstract class PlotPlayer implements CommandCaller {
public abstract Location getLocationFull(); public abstract Location getLocationFull();
/** /**
* Get the player's UUID * Get the player's UUID<br>
* @return * === !IMPORTANT ===<br>
* The UUID is dependent on the mode chosen in the settings.yml and may not be the same as Bukkit has
* (especially if using an old version of Bukkit that does not support UUIDs)
*
* @return UUID
*/ */
public abstract UUID getUUID(); public abstract UUID getUUID();

View File

@ -1,70 +0,0 @@
package com.intellectualcrafters.plot.object;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings({"unused"})
public class StaticStrings {
public static final String
PERMISSION_ADMIN = "plots.admin",
PERMISSION_PROJECTILE_UNOWNED = "plots.projectile.unowned",
PERMISSION_PROJECTILE_OTHER = "plots.projectile.other",
PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS = "plots.admin.interact.blockedcommands",
PERMISSION_WORLDEDIT_BYPASS = "plots.worldedit.bypass",
PERMISSION_ADMIN_EXIT_DENIED = "plots.admin.exit.denied",
PERMISSION_ADMIN_ENTRY_DENIED = "plots.admin.entry.denied",
PERMISSION_COMMANDS_CHAT = "plots.admin.command.chat",
PERMISSION_ADMIN_DESTROY_UNOWNED = "plots.admin.destroy.unowned",
PERMISSION_ADMIN_DESTROY_OTHER = "plots.admin.destroy.other",
PERMISSION_ADMIN_DESTROY_ROAD = "plots.admin.destroy.road",
PERMISSION_ADMIN_BUILD_ROAD = "plots.admin.build.road",
PERMISSION_ADMIN_BUILD_UNOWNED = "plots.admin.build.unowned",
PERMISSION_ADMIN_BUILD_OTHER = "plots.admin.build.other",
PERMISSION_ADMIN_INTERACT_ROAD = "plots.admin.interact.road",
PERMISSION_ADMIN_INTERACT_UNOWNED = "plots.admin.interact.unowned",
PERMISSION_ADMIN_INTERACT_OTHER = "plots.admin.interact.other",
PERMISSION_ADMIN_BUILD_HEIGHTLIMIT = "plots.admin.build.heightlimit";
public static final String
FLAG_USE = "use",
FLAG_PLACE = "place",
FLAG_PVP = "pvp",
FLAG_HANGING_PLACE = "hanging-place",
FLAG_HANGING_BREAK = "hanging-break",
FLAG_HOSTILE_INTERACT = "hostile-interact",
FLAG_ANIMAL_INTERACT = "animal-interact",
FLAG_VEHICLE_USE = "vehicle-use",
FLAG_TAMED_INTERACT = "tamed-interact",
FLAG_DISABLE_PHYSICS = "disable-physics";
public static final String
META_INVENTORY = "inventory";
public static final String
PREFIX_META = "META_",
PREFIX_FLAG = "FLAG_",
PREFIX_PERMISSION = "PERMISSION_";
public static Map<String, String> getStrings(final String prefix) {
final Field[] fields = StaticStrings.class.getDeclaredFields();
Map<String, String> strings = new HashMap<>();
for (final Field field : fields) {
if (field.getGenericType() != String.class) {
continue;
}
if (field.getName().startsWith(prefix)) {
field.setAccessible(true);
try {
String value = field.get(StaticStrings.class).toString();
strings.put(field.getName(), value);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
return strings;
}
}

View File

@ -0,0 +1,160 @@
package com.intellectualcrafters.plot.util;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
import com.intellectualcrafters.plot.object.BO3;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
public class BO3Handler {
/**
* @see #saveBO3(null, Plot)
* @param plot
* @return if successfully exported
*/
public static boolean saveBO3(Plot plot) {
return saveBO3(null, plot);
}
/**
* Save a plot as a BO3 file<br>
* - Use null for the player object if no player is applicable
* @param plr
* @param plot
* @return
*/
public static boolean saveBO3(PlotPlayer plr, Plot plot) {
PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
if (!(plotworld instanceof ClassicPlotWorld) || plotworld.TYPE != 0) {
MainUtil.sendMessage(plr, "BO3 exporting only supports type 0 classic generation.");
return false;
}
String alias = plot.toString();
Location pos1 = plot.getBottom().add(1, 0, 1);
Location pos2 = plot.getTop();
ClassicPlotWorld cpw = (ClassicPlotWorld) plotworld;
int height = cpw.PLOT_HEIGHT;
int cx = (pos1.getX() + pos2.getX()) / 2;
int cz = (pos1.getZ() + pos2.getZ()) / 2;
HashMap<ChunkLoc, BO3> map = new HashMap<>();
boolean content = false;
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
int X = ((x + 7) - cx) >> 4;
int xx = (x - cx) % 16;
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
int Z = ((z + 7) - cz) >> 4;
int zz = (z - cz) % 16;
ChunkLoc loc = new ChunkLoc(X, Z);
BO3 bo3 = map.get(loc);
for (int y = height + 1; y < 256; y++) {
PlotBlock block = BlockManager.manager.getBlock(new Location(plot.world, x, y, z));
if (block != null && block.id != 0) {
if (bo3 == null) {
bo3 = new BO3(alias, loc);
map.put(loc, bo3);
content = true;
}
bo3.addBlock(xx, y - height - 1, zz, block);
}
}
}
}
if (!content) {
MainUtil.sendMessage(plr, "No content found!");
return false;
}
for (Entry<ChunkLoc, BO3> entry : map.entrySet()) {
ChunkLoc chunk = entry.getKey();
BO3 bo3 = entry.getValue();
if (chunk.x == 0 && chunk.z == 0) {
continue;
}
int x = chunk.x;
int z = chunk.z;
if (Math.abs(chunk.x) > Math.abs(chunk.z)) {
x += chunk.x > 0 ? -1 : 1;
}
else {
z += chunk.z > 0 ? -1 : 1;
}
ChunkLoc parentLoc = new ChunkLoc(x, z);
if (!map.containsKey(parentLoc)) {
parentLoc = null;
for (Entry<ChunkLoc, BO3> entry2 : map.entrySet()) {
ChunkLoc other = entry2.getKey();
if ((other.x == chunk.x - 1 && other.z == chunk.z) || (other.z == chunk.z - 1 && other.x == chunk.x)) {
parentLoc = other;
}
}
if (parentLoc == null) {
MainUtil.sendMessage(plr, "Exporting BO3 cancelled due to detached chunk: " + chunk + " - Make sure you only have one object per plot");
return false;
}
}
map.get(parentLoc).addChild(bo3);
}
for (Entry<ChunkLoc, BO3> entry : map.entrySet()) {
save(plot, entry.getValue());
}
MainUtil.sendMessage(plr, "BO3 exporting was successful!");
return true;
}
public static boolean save(Plot plot, BO3 bo3) {
File base = getBaseFile(plot.world);
try {
List<String> lines = Files.readAllLines(base.toPath(), StandardCharsets.UTF_8);
for (int i = 0; i < lines.size(); i++) {
String line = lines.get(i).trim();
String result = StringMan.replaceAll(line, "%owner%", MainUtil.getName(plot.owner), "%alias%", plot.toString(), "%blocks%", bo3.getBlocks(), "%branches%", bo3.getChildren());
if (!StringMan.isEqual(result, line)) {
lines.set(i, result);
}
}
File bo3File;
if (bo3.getLoc().x == 0 && bo3.getLoc().z == 0) {
bo3File = new File(base.getParentFile(), bo3.getName() + ".bo3");
}
else {
bo3File = new File(base.getParentFile(), bo3.getName() + "_" + bo3.getLoc().x + "_" + bo3.getLoc().z + ".bo3");
}
bo3File.createNewFile();
Files.write(bo3File.toPath(), StringMan.join(lines, System.getProperty("line.separator")).getBytes(), StandardOpenOption.WRITE);
return true;
}
catch (Exception e) {
e.printStackTrace();
return false;
}
}
public static File getBaseFile(String category) {
File base = new File(PS.get().IMP.getDirectory(), Settings.BO3_SAVE_PATH + File.separator + category + File.separator + "base.yml");
if (!base.exists()) {
PS.get().copyFile("base.yml", Settings.BO3_SAVE_PATH + File.separator + category);
}
return base;
}
}

View File

@ -5,6 +5,7 @@ import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
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.LazyBlock; import com.intellectualcrafters.plot.object.LazyBlock;
@ -81,85 +82,85 @@ public abstract class EventUtil {
} }
case BREAK_BLOCK: { case BREAK_BLOCK: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, Permissions.BREAK_ROAD.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, Permissions.BREAK_UNOWNED.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED.s(), notifyPerms);
} }
Flag flag = FlagManager.getPlotFlag(plot, "break"); Flag flag = FlagManager.getPlotFlag(plot, "break");
HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, Permissions.BREAK_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER.s(), notifyPerms);
} }
return true; return true;
} }
case BREAK_HANGING: case BREAK_HANGING:
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, Permissions.BREAK_ROAD.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD.s(), notifyPerms);
} }
if (FlagManager.isPlotFlagTrue(plot, "hanging-break")) { if (FlagManager.isPlotFlagTrue(plot, "hanging-break")) {
return true; return true;
} }
if (plot.hasOwner()) { if (plot.hasOwner()) {
return Permissions.hasPermission(pp, Permissions.BREAK_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER.s(), notifyPerms);
} }
return Permissions.hasPermission(pp, Permissions.BREAK_UNOWNED.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED.s(), notifyPerms);
case BREAK_MISC: case BREAK_MISC:
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, Permissions.BREAK_ROAD.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD.s(), notifyPerms);
} }
if (FlagManager.isPlotFlagTrue(plot, "misc-break")) { if (FlagManager.isPlotFlagTrue(plot, "misc-break")) {
return true; return true;
} }
if (plot.hasOwner()) { if (plot.hasOwner()) {
return Permissions.hasPermission(pp, Permissions.BREAK_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER.s(), notifyPerms);
} }
return Permissions.hasPermission(pp, Permissions.BREAK_UNOWNED.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED.s(), notifyPerms);
case BREAK_VEHICLE: case BREAK_VEHICLE:
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, Permissions.BREAK_ROAD.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD.s(), notifyPerms);
} }
if (FlagManager.isPlotFlagTrue(plot, "vehicle-break")) { if (FlagManager.isPlotFlagTrue(plot, "vehicle-break")) {
return true; return true;
} }
if (plot.hasOwner()) { if (plot.hasOwner()) {
return Permissions.hasPermission(pp, Permissions.BREAK_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER.s(), notifyPerms);
} }
return Permissions.hasPermission(pp, Permissions.BREAK_UNOWNED.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED.s(), notifyPerms);
case INTERACT_BLOCK: { case INTERACT_BLOCK: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, Permissions.INTERACT_ROAD.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, Permissions.INTERACT_UNOWNED.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
Flag flag = FlagManager.getPlotFlag(plot, "use"); Flag flag = FlagManager.getPlotFlag(plot, "use");
HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
} }
return true; return true;
} }
case PLACE_BLOCK: { case PLACE_BLOCK: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, Permissions.BUILD_ROAD.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, Permissions.BUILD_UNOWNED.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED.s(), notifyPerms);
} }
Flag flag = FlagManager.getPlotFlag(plot, "place"); Flag flag = FlagManager.getPlotFlag(plot, "place");
HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, Permissions.BUILD_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER.s(), notifyPerms);
} }
return true; return true;
} }
case TRIGGER_PHYSICAL: { case TRIGGER_PHYSICAL: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, Permissions.INTERACT_ROAD.s, false); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), false);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, Permissions.INTERACT_UNOWNED.s, false); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), false);
} }
if (FlagManager.isPlotFlagTrue(plot, "device-interact")) { if (FlagManager.isPlotFlagTrue(plot, "device-interact")) {
return true; return true;
@ -167,16 +168,16 @@ public abstract class EventUtil {
Flag flag = FlagManager.getPlotFlag(plot, "use"); Flag flag = FlagManager.getPlotFlag(plot, "use");
HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
} }
return true; return true;
} }
case INTERACT_HANGING: { case INTERACT_HANGING: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, Permissions.INTERACT_ROAD.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, Permissions.INTERACT_UNOWNED.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (FlagManager.isPlotFlagTrue(plot, "hanging-interact")) { if (FlagManager.isPlotFlagTrue(plot, "hanging-interact")) {
return true; return true;
@ -184,16 +185,16 @@ public abstract class EventUtil {
Flag flag = FlagManager.getPlotFlag(plot, "use"); Flag flag = FlagManager.getPlotFlag(plot, "use");
HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
} }
return true; return true;
} }
case INTERACT_MISC: { case INTERACT_MISC: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, Permissions.INTERACT_ROAD.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, Permissions.INTERACT_UNOWNED.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (FlagManager.isPlotFlagTrue(plot, "misc-interact")) { if (FlagManager.isPlotFlagTrue(plot, "misc-interact")) {
return true; return true;
@ -201,16 +202,16 @@ public abstract class EventUtil {
Flag flag = FlagManager.getPlotFlag(plot, "use"); Flag flag = FlagManager.getPlotFlag(plot, "use");
HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
} }
return true; return true;
} }
case INTERACT_VEHICLE: { case INTERACT_VEHICLE: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, Permissions.INTERACT_ROAD.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, Permissions.INTERACT_UNOWNED.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (FlagManager.isPlotFlagTrue(plot, "vehicle-use")) { if (FlagManager.isPlotFlagTrue(plot, "vehicle-use")) {
return true; return true;
@ -218,16 +219,16 @@ public abstract class EventUtil {
Flag flag = FlagManager.getPlotFlag(plot, "use"); Flag flag = FlagManager.getPlotFlag(plot, "use");
HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
} }
return true; return true;
} }
case SPAWN_MOB: { case SPAWN_MOB: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, Permissions.INTERACT_UNOWNED.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (FlagManager.isPlotFlagTrue(plot, "mob-place")) { if (FlagManager.isPlotFlagTrue(plot, "mob-place")) {
@ -236,16 +237,16 @@ public abstract class EventUtil {
Flag flag = FlagManager.getPlotFlag(plot, "place"); Flag flag = FlagManager.getPlotFlag(plot, "place");
HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
} }
return true; return true;
} }
case PLACE_HANGING: { case PLACE_HANGING: {
// if (plot == null) { // if (plot == null) {
// return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms); // return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
// } // }
// if (!plot.hasOwner()) { // if (!plot.hasOwner()) {
// return Permissions.hasPermission(pp, Permissions.INTERACT_UNOWNED.s, notifyPerms); // return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
// } // }
// //
// if (FlagManager.isPlotFlagTrue(plot, "hanging-place")) { // if (FlagManager.isPlotFlagTrue(plot, "hanging-place")) {
@ -254,16 +255,16 @@ public abstract class EventUtil {
// Flag flag = FlagManager.getPlotFlag(plot, "place"); // Flag flag = FlagManager.getPlotFlag(plot, "place");
// HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); // HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
// if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { // if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
// return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms); // return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
// } // }
return true; return true;
} }
case PLACE_MISC: { case PLACE_MISC: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, Permissions.INTERACT_UNOWNED.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (FlagManager.isPlotFlagTrue(plot, "misc-place")) { if (FlagManager.isPlotFlagTrue(plot, "misc-place")) {
@ -272,16 +273,16 @@ public abstract class EventUtil {
Flag flag = FlagManager.getPlotFlag(plot, "place"); Flag flag = FlagManager.getPlotFlag(plot, "place");
HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
} }
return true; return true;
} }
case PLACE_VEHICLE: { case PLACE_VEHICLE: {
if (plot == null) { if (plot == null) {
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, Permissions.INTERACT_UNOWNED.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (FlagManager.isPlotFlagTrue(plot, "vehicle-place")) { if (FlagManager.isPlotFlagTrue(plot, "vehicle-place")) {
@ -290,7 +291,7 @@ public abstract class EventUtil {
Flag flag = FlagManager.getPlotFlag(plot, "place"); Flag flag = FlagManager.getPlotFlag(plot, "place");
HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue(); HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) { if (value == null || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
return Permissions.hasPermission(pp, Permissions.INTERACT_OTHER.s, notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
} }
return true; return true;
} }

View File

@ -1033,25 +1033,30 @@ public class MainUtil {
System.currentTimeMillis(); System.currentTimeMillis();
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world); final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
runners.put(plot, 1); runners.put(plot, 1);
if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) { final Runnable run = new Runnable() {
final Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id); @Override
ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { public void run() {
if (isDelete) {
manager.unclaimPlot(plotworld, plot, new Runnable() {
@Override @Override
public void run() { public void run() {
runners.remove(plot); runners.remove(plot);
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
} }
}); });
return;
} }
final Runnable run = new Runnable() { else {
@Override
public void run() {
runners.remove(plot); runners.remove(plot);
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
} }
}
}; };
manager.clearPlot(plotworld, plot, isDelete, run); if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) {
final Location pos2 = MainUtil.getPlotTopLoc(plot.world, plot.id);
ChunkManager.manager.regenerateRegion(pos1, pos2, run);
return;
}
manager.clearPlot(plotworld, plot, run);
} }
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) {
@ -1648,6 +1653,29 @@ public class MainUtil {
return true; return true;
} }
/**
* Send a message to the player
*
* @param plr Player to recieve message
* @param c Caption to send
*
* @return boolean success
*/
public static boolean sendMessage(final PlotPlayer plr, final C c, final Object... args) {
if (c.s().length() > 1) {
String msg = c.s();
if ((args != null) && (args.length > 0)) {
msg = C.format(c, args);
}
if (plr == null) {
PS.log(msg);
} else {
sendMessage(plr, msg, c.usePrefix());
}
}
return true;
}
public static Plot getBottomPlot(final Plot plot) { public static Plot getBottomPlot(final Plot plot) {
if (plot.getSettings().getMerged(0)) { if (plot.getSettings().getMerged(0)) {
final Plot p = PS.get().getPlot(plot.world, new PlotId(plot.id.x, plot.id.y - 1)); final Plot p = PS.get().getPlot(plot.world, new PlotId(plot.id.x, plot.id.y - 1));

View File

@ -2,41 +2,19 @@ package com.intellectualcrafters.plot.util;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.general.commands.CommandCaller;
public enum Permissions { public class Permissions {
// ADMIN public static boolean hasPermission(final PlotPlayer player, final C c) {
ADMIN("plots.admin", "do-not-change"), return hasPermission(player, c.s());
STAR("*", "do-not-change"),
// BUILD
BUILD_OTHER("plots.admin.build.other", "build"),
BUILD_ROAD("plots.admin.build.road", "build"),
BUILD_UNOWNED("plots.admin.build.unowned", "build"),
// INTERACT
INTERACT_OTHER("plots.admin.interact.other", "interact"),
INTERACT_ROAD("plots.admin.interact.road", "interact"),
INTERACT_UNOWNED("plots.admin.interact.unowned", "interact"),
// BREAK
BREAK_OTHER("plots.admin.break.other", "break"),
BREAK_ROAD("plots.admin.break.road", "break"),
BREAK_UNOWNED("plots.admin.break.unowned", "break"),
// MERGE
MERGE_OTHER("plots.merge.other", "merge");
public String s;
public String cat;
Permissions(String perm, String cat) {
this.s = perm;
this.cat = cat;
} }
public static boolean hasPermission(final PlotPlayer player, final Permissions perm) {
return hasPermission(player, perm.s);
}
public static boolean hasPermission(final PlotPlayer player, final String perm) { public static boolean hasPermission(final PlotPlayer player, final String perm) {
if ((player == null) || player.hasPermission(ADMIN.s) || player.hasPermission(STAR.s)) { return hasPermission((CommandCaller) player, perm);
}
public static boolean hasPermission(final CommandCaller player, final String perm) {
if ((player == null) || player.hasPermission(C.PERMISSION_ADMIN.s()) || player.hasPermission(C.PERMISSION_STAR.s())) {
return true; return true;
} }
if (player.hasPermission(perm)) { if (player.hasPermission(perm)) {
@ -46,7 +24,7 @@ public enum Permissions {
final StringBuilder n = new StringBuilder(); final StringBuilder n = new StringBuilder();
for (int i = 0; i < (nodes.length - 1); i++) { for (int i = 0; i < (nodes.length - 1); i++) {
n.append(nodes[i] + (".")); n.append(nodes[i] + ("."));
if (player.hasPermission(n + STAR.s)) { if (player.hasPermission(n + C.PERMISSION_STAR.s())) {
return true; return true;
} }
} }
@ -64,7 +42,7 @@ public enum Permissions {
} }
public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) { public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) {
if ((player == null) || player.hasPermission(ADMIN.s) || player.hasPermission(STAR.s)) { if ((player == null) || player.hasPermission(C.PERMISSION_ADMIN.s()) || player.hasPermission(C.PERMISSION_STAR.s())) {
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
} }
if (player.hasPermission(stub + ".*")) { if (player.hasPermission(stub + ".*")) {

View File

@ -13,8 +13,9 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.StaticStrings;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
@ -35,7 +36,7 @@ public class ChatListener implements Listener {
} }
final PlotWorld plotworld = PS.get().getPlotWorld(world); final PlotWorld plotworld = PS.get().getPlotWorld(world);
final PlotPlayer plr = BukkitUtil.getPlayer(player); final PlotPlayer plr = BukkitUtil.getPlayer(player);
if (!plotworld.PLOT_CHAT && (plr.getMeta("chat") == null || !(Boolean) plr.getMeta("chat"))) { if (!plotworld.PLOT_CHAT && (plr.getAttribute("chat"))) {
return; return;
} }
final Location loc = BukkitUtil.getLocation(player); final Location loc = BukkitUtil.getLocation(player);
@ -54,7 +55,7 @@ public class ChatListener implements Listener {
if (plot.equals(recipient.getCurrentPlot())) { if (plot.equals(recipient.getCurrentPlot())) {
recipient.sendMessage(toSend); recipient.sendMessage(toSend);
} }
else if (recipient.hasPermission(StaticStrings.PERMISSION_COMMANDS_CHAT)) { else if (Permissions.hasPermission(recipient, C.PERMISSION_COMMANDS_CHAT)) {
recipient.sendMessage(toSend); recipient.sendMessage(toSend);
} }
} }

View File

@ -1,34 +1,5 @@
package com.plotsquared.bukkit.listeners; package com.plotsquared.bukkit.listeners;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_ANIMAL_INTERACT;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_DISABLE_PHYSICS;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_HANGING_BREAK;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_HANGING_PLACE;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_HOSTILE_INTERACT;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_PLACE;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_PVP;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_TAMED_INTERACT;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_USE;
import static com.intellectualcrafters.plot.object.StaticStrings.FLAG_VEHICLE_USE;
import static com.intellectualcrafters.plot.object.StaticStrings.META_INVENTORY;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_BUILD_OTHER;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_BUILD_ROAD;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_BUILD_UNOWNED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_DESTROY_OTHER;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_DESTROY_ROAD;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_DESTROY_UNOWNED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_ENTRY_DENIED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_EXIT_DENIED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_INTERACT_OTHER;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_INTERACT_ROAD;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_INTERACT_UNOWNED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_COMMANDS_CHAT;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_PROJECTILE_OTHER;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_PROJECTILE_UNOWNED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_WORLDEDIT_BYPASS;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -187,33 +158,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
@EventHandler @EventHandler
public void onRedstoneEvent(BlockRedstoneEvent event) { public void onRedstoneEvent(BlockRedstoneEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
Location loc = BukkitUtil.getLocation(block.getLocation());
if (!PS.get().isPlotWorld(loc.getWorld())) {
return;
}
Plot plot = MainUtil.getPlot(loc);
if (plot == null || !plot.hasOwner()) {
return;
}
if (Settings.REDSTONE_DISABLER) {
if (UUIDHandler.getPlayer(plot.owner) == null) {
boolean disable = true;
for (UUID trusted : plot.getTrusted()) {
if (UUIDHandler.getPlayer(trusted) != null) {
disable = false;
break;
}
}
if (disable) {
event.setNewCurrent(0);
return;
}
}
}
Flag redstone = FlagManager.getPlotFlag(plot, "redstone");
if (redstone == null || (Boolean) redstone.getValue()) {
return;
}
switch (block.getType()) { switch (block.getType()) {
case REDSTONE_LAMP_OFF: case REDSTONE_LAMP_OFF:
case REDSTONE_LAMP_ON: case REDSTONE_LAMP_ON:
@ -244,6 +188,36 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return; return;
} }
default: { default: {
Location loc = BukkitUtil.getLocation(block.getLocation());
if (!PS.get().isPlotWorld(loc.getWorld())) {
return;
}
Plot plot = MainUtil.getPlot(loc);
if (plot == null || !plot.hasOwner()) {
return;
}
Flag redstone = FlagManager.getPlotFlag(plot, "redstone");
if (Settings.REDSTONE_DISABLER) {
if (redstone != null && (Boolean) redstone.getValue()) {
return;
}
if (UUIDHandler.getPlayer(plot.owner) == null) {
boolean disable = true;
for (UUID trusted : plot.getTrusted()) {
if (UUIDHandler.getPlayer(trusted) != null) {
disable = false;
break;
}
}
if (disable) {
event.setNewCurrent(0);
return;
}
}
}
if (redstone == null || (Boolean) redstone.getValue()) {
return;
}
event.setNewCurrent(0); event.setNewCurrent(0);
} }
} }
@ -310,7 +284,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
else if ((shooter instanceof Player)) { else if ((shooter instanceof Player)) {
PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter); PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter);
if (plot == null) { if (plot == null) {
if (!pp.hasPermission(PERMISSION_PROJECTILE_UNOWNED)) { if (!Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_UNOWNED)) {
entity.remove(); entity.remove();
} }
return; return;
@ -318,7 +292,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (plot.isAdded(pp.getUUID())) { if (plot.isAdded(pp.getUUID())) {
return; return;
} }
if (pp.hasPermission(PERMISSION_PROJECTILE_OTHER)) { if (Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
return; return;
} }
entity.remove(); entity.remove();
@ -358,7 +332,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
Flag flag; Flag flag;
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS) && (flag = FlagManager.getPlotFlag(plot, "blocked-cmds")) != null) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS) && (flag = FlagManager.getPlotFlag(plot, "blocked-cmds")) != null) {
List<String> v = (List<String>) flag.getValue(); List<String> v = (List<String>) flag.getValue();
String msg = event.getMessage().toLowerCase().replaceFirst("/", ""); String msg = event.getMessage().toLowerCase().replaceFirst("/", "");
@ -460,11 +434,11 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
UUIDHandler.add(name, uuid); UUIDHandler.add(name, uuid);
ExpireManager.dates.put(uuid, System.currentTimeMillis()); ExpireManager.dates.put(uuid, System.currentTimeMillis());
if (BukkitMain.worldEdit != null) { if (BukkitMain.worldEdit != null) {
if (Permissions.hasPermission(pp, PERMISSION_WORLDEDIT_BYPASS)) { if (pp.getAttribute("worldedit")) {
WEManager.bypass.add(pp.getName()); MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASSED);
} }
} }
if (PS.get().update != null && pp.hasPermission("plots.admin")) { if (PS.get().update != null && Permissions.hasPermission(pp, C.PERMISSION_ADMIN)) {
TaskManager.runTaskLater(new Runnable() { TaskManager.runTaskLater(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -506,7 +480,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
Plot lastPlot = (Plot) pp.getMeta("lastplot"); Plot lastPlot = (Plot) pp.getMeta("lastplot");
if (id == null) { if (id == null) {
if (lastPlot != null && !plotExit(pp, lastPlot)) { if (lastPlot != null && !plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_EXIT_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) { if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
player.teleport(from); player.teleport(from);
} }
@ -523,7 +497,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
else { else {
Plot plot = MainUtil.getPlot(worldname, id); Plot plot = MainUtil.getPlot(worldname, id);
if (!plotEntry(pp, plot)) { if (!plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_ENTRY_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) { if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
player.teleport(from); player.teleport(from);
} }
@ -569,7 +543,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
Plot lastPlot = (Plot) pp.getMeta("lastplot"); Plot lastPlot = (Plot) pp.getMeta("lastplot");
if (id == null) { if (id == null) {
if (lastPlot != null && !plotExit(pp, lastPlot)) { if (lastPlot != null && !plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_EXIT_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) { if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
player.teleport(from); player.teleport(from);
} }
@ -586,7 +560,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
else { else {
Plot plot = MainUtil.getPlot(worldname, id); Plot plot = MainUtil.getPlot(worldname, id);
if (!plotEntry(pp, plot)) { if (!plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_ENTRY_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) { if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
player.teleport(from); player.teleport(from);
} }
@ -637,7 +611,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
final Set<Player> recipients = event.getRecipients(); final Set<Player> recipients = event.getRecipients();
recipients.clear(); recipients.clear();
for (final Player p : Bukkit.getOnlinePlayers()) { for (final Player p : Bukkit.getOnlinePlayers()) {
if (p.hasPermission(PERMISSION_COMMANDS_CHAT) || plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(p)))) { PlotPlayer pp = BukkitUtil.getPlayer(p);
if (Permissions.hasPermission(pp, C.PERMISSION_COMMANDS_CHAT) || plot.equals(pp.getCurrentPlot())) {
recipients.add(p); recipients.add(p);
} }
} }
@ -662,10 +637,10 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
final PlotPlayer pp = BukkitUtil.getPlayer(player); final PlotPlayer pp = BukkitUtil.getPlayer(player);
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_UNOWNED)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -675,15 +650,15 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
return; return;
} }
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_OTHER)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true); event.setCancelled(true);
} }
else if (plot.getSettings().flags.containsKey("done")) { else if (plot.getSettings().flags.containsKey("done")) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -691,11 +666,11 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return; return;
} }
final PlotPlayer pp = BukkitUtil.getPlayer(player); final PlotPlayer pp = BukkitUtil.getPlayer(player);
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_ROAD)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
return; return;
} }
if (MainUtil.isPlotAreaAbs(loc)) { if (MainUtil.isPlotAreaAbs(loc)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_ROAD); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_ROAD);
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -743,11 +718,10 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot"); BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot");
if (BukkitMain.worldEdit != null) { if (BukkitMain.worldEdit != null) {
if (!Permissions.hasPermission(pp, PERMISSION_WORLDEDIT_BYPASS)) { if (!Permissions.hasPermission(pp, C.PERMISSION_WORLDEDIT_BYPASS)) {
WEManager.bypass.remove(pp.getName()); if (pp.getAttribute("worldedit")) {
pp.removeAttribute("worldedit");
} }
else {
WEManager.bypass.add(pp.getName());
} }
} }
if (Settings.PERMISSION_CACHING) { if (Settings.PERMISSION_CACHING) {
@ -775,24 +749,24 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (plot == null) { if (plot == null) {
if (MainUtil.isPlotAreaAbs(loc)) { if (MainUtil.isPlotAreaAbs(loc)) {
final PlotPlayer pp = BukkitUtil.getPlayer(p); final PlotPlayer pp = BukkitUtil.getPlayer(p);
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_ROAD)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_ROAD); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
event.setCancelled(true); event.setCancelled(true);
} }
} }
} else { } else {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
final PlotPlayer pp = BukkitUtil.getPlayer(p); final PlotPlayer pp = BukkitUtil.getPlayer(p);
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_UNOWNED)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
} }
} else { } else {
final PlotPlayer pp = BukkitUtil.getPlayer(p); final PlotPlayer pp = BukkitUtil.getPlayer(p);
if (!plot.isAdded(pp.getUUID())) { if (!plot.isAdded(pp.getUUID())) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
if (MainUtil.isPlotArea(loc)) { if (MainUtil.isPlotArea(loc)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -867,10 +841,10 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
final PlotPlayer pp = BukkitUtil.getPlayer(player); final PlotPlayer pp = BukkitUtil.getPlayer(player);
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_UNOWNED)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -881,21 +855,21 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
return; return;
} }
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_OTHER)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
return; return;
} }
final PlotPlayer pp = BukkitUtil.getPlayer(player); final PlotPlayer pp = BukkitUtil.getPlayer(player);
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_ROAD)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
return; return;
} }
if (MainUtil.isPlotArea(loc)) { if (MainUtil.isPlotArea(loc)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_ROAD); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_ROAD);
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -1389,24 +1363,24 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (plot == null) { if (plot == null) {
if (MainUtil.isPlotAreaAbs(loc)) { if (MainUtil.isPlotAreaAbs(loc)) {
final PlotPlayer pp = BukkitUtil.getPlayer(p); final PlotPlayer pp = BukkitUtil.getPlayer(p);
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_ROAD)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_ROAD); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
e.setCancelled(true); e.setCancelled(true);
} }
} }
} else { } else {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
final PlotPlayer pp = BukkitUtil.getPlayer(p); final PlotPlayer pp = BukkitUtil.getPlayer(p);
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_UNOWNED)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
e.setCancelled(true); e.setCancelled(true);
} }
} else { } else {
final PlotPlayer pp = BukkitUtil.getPlayer(p); final PlotPlayer pp = BukkitUtil.getPlayer(p);
if (!plot.isAdded(pp.getUUID())) { if (!plot.isAdded(pp.getUUID())) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
if (MainUtil.isPlotArea(loc)) { if (MainUtil.isPlotArea(loc)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -1446,7 +1420,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return; return;
} }
if (!plotExit(pp, lastPlot)) { if (!plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_EXIT_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) { if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
player.teleport(from); player.teleport(from);
} }
@ -1463,7 +1437,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
else { else {
Plot plot = MainUtil.getPlot(worldname, id); Plot plot = MainUtil.getPlot(worldname, id);
if (!plotEntry(pp, plot)) { if (!plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_ENTRY_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) { if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
player.teleport(from); player.teleport(from);
} }
@ -1512,7 +1486,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return; return;
} }
if (!plotExit(pp, lastPlot)) { if (!plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_EXIT_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) { if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
player.teleport(from); player.teleport(from);
} }
@ -1529,7 +1503,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
else { else {
Plot plot = MainUtil.getPlot(worldname, id); Plot plot = MainUtil.getPlot(worldname, id);
if (!plotEntry(pp, plot)) { if (!plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_ENTRY_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) { if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
player.teleport(from); player.teleport(from);
} }
@ -1566,29 +1540,29 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
Plot plot = MainUtil.getPlot(loc); Plot plot = MainUtil.getPlot(loc);
if (plot == null) { if (plot == null) {
if (MainUtil.isPlotAreaAbs(loc)) { if (MainUtil.isPlotAreaAbs(loc)) {
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_ROAD)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_ROAD); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
e.setCancelled(true); e.setCancelled(true);
} }
} else { } else {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_UNOWNED)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
e.setCancelled(true); e.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
final Flag use = FlagManager.getPlotFlag(plot, FLAG_USE); final Flag use = FlagManager.getPlotFlag(plot, C.FLAG_USE.s());
if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) { if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) e.getBucket().getId(), (byte) 0))) {
return; return;
} }
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
return; return;
} }
if (MainUtil.isPlotArea(loc)) { if (MainUtil.isPlotArea(loc)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -1604,7 +1578,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
Player player = (Player) clicker; Player player = (Player) clicker;
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer pp = BukkitUtil.getPlayer(player);
PlotInventory inv = (PlotInventory) pp.getMeta(META_INVENTORY); PlotInventory inv = (PlotInventory) pp.getMeta("inventory");
if (inv != null && event.getRawSlot() == event.getSlot()) { if (inv != null && event.getRawSlot() == event.getSlot()) {
if (!inv.onClick(event.getSlot())) { if (!inv.onClick(event.getSlot())) {
event.setCancelled(true); event.setCancelled(true);
@ -1620,7 +1594,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return; return;
} }
Player player = (Player) closer; Player player = (Player) closer;
BukkitUtil.getPlayer(player).deleteMeta(META_INVENTORY); BukkitUtil.getPlayer(player).deleteMeta("inventory");
} }
@ -1629,9 +1603,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
ExpireManager.dates.put(pp.getUUID(), System.currentTimeMillis()); ExpireManager.dates.put(pp.getUUID(), System.currentTimeMillis());
EventUtil.unregisterPlayer(pp); EventUtil.unregisterPlayer(pp);
if (BukkitMain.worldEdit != null) {
WEManager.bypass.remove(pp.getName());
}
if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) {
for (final Plot plot : PS.get().getPlotsInWorld(pp.getName())) { for (final Plot plot : PS.get().getPlotsInWorld(pp.getName())) {
plot.deletePlot(null); plot.deletePlot(null);
@ -1651,30 +1622,30 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
Plot plot = MainUtil.getPlot(loc); Plot plot = MainUtil.getPlot(loc);
if (plot == null) { if (plot == null) {
if (MainUtil.isPlotAreaAbs(loc)) { if (MainUtil.isPlotAreaAbs(loc)) {
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_ROAD)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_ROAD); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
e.setCancelled(true); e.setCancelled(true);
} }
} else { } else {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_UNOWNED)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
e.setCancelled(true); e.setCancelled(true);
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
final Flag use = FlagManager.getPlotFlag(plot, FLAG_USE); final Flag use = FlagManager.getPlotFlag(plot, C.FLAG_USE.s());
final Block block = e.getBlockClicked(); final Block block = e.getBlockClicked();
if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) { if ((use != null) && ((HashSet<PlotBlock>) use.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
return; return;
} }
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
return; return;
} }
if (MainUtil.isPlotArea(loc)) { if (MainUtil.isPlotArea(loc)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -1702,24 +1673,24 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
Plot plot = MainUtil.getPlot(loc); Plot plot = MainUtil.getPlot(loc);
if (plot == null) { if (plot == null) {
if (MainUtil.isPlotAreaAbs(loc)) { if (MainUtil.isPlotAreaAbs(loc)) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_ROAD)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_ROAD); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
e.setCancelled(true); e.setCancelled(true);
} }
} }
} else { } else {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_UNOWNED)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
e.setCancelled(true); e.setCancelled(true);
} }
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
if (FlagManager.isPlotFlagTrue(plot, FLAG_HANGING_PLACE)) { if (FlagManager.isPlotFlagTrue(plot, C.FLAG_HANGING_PLACE.s())) {
return; return;
} }
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
if (MainUtil.isPlotArea(loc)) { if (MainUtil.isPlotArea(loc)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -1739,24 +1710,24 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
Plot plot = MainUtil.getPlot(l); Plot plot = MainUtil.getPlot(l);
if (plot == null) { if (plot == null) {
if (MainUtil.isPlotAreaAbs(l)) { if (MainUtil.isPlotAreaAbs(l)) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_ROAD)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_ROAD); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_ROAD);
e.setCancelled(true); e.setCancelled(true);
} }
} }
} else { } else {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_UNOWNED)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
e.setCancelled(true); e.setCancelled(true);
} }
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
if (FlagManager.isPlotFlagTrue(plot, FLAG_HANGING_BREAK)) { if (FlagManager.isPlotFlagTrue(plot, C.FLAG_HANGING_BREAK.s())) {
return; return;
} }
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_OTHER)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
if (MainUtil.isPlotArea(l)) { if (MainUtil.isPlotArea(l)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -1772,15 +1743,15 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(e.getEntity())); Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(e.getEntity()));
if (plot != null) { if (plot != null) {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(player, PERMISSION_ADMIN_DESTROY_UNOWNED)) { if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_UNOWNED); MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
e.setCancelled(true); e.setCancelled(true);
} }
} else if (!plot.isAdded(player.getUUID())) { } else if (!plot.isAdded(player.getUUID())) {
if (!FlagManager.isPlotFlagTrue(plot, FLAG_HANGING_BREAK)){ if (!FlagManager.isPlotFlagTrue(plot, C.FLAG_HANGING_BREAK.s())){
if (!Permissions.hasPermission(player, PERMISSION_ADMIN_DESTROY_OTHER)) { if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
if (MainUtil.isPlotArea(BukkitUtil.getLocation(e.getEntity()))) { if (MainUtil.isPlotArea(BukkitUtil.getLocation(e.getEntity()))) {
MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_OTHER); MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -1805,33 +1776,36 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (!MainUtil.isPlotAreaAbs(l)) { if (!MainUtil.isPlotAreaAbs(l)) {
return; return;
} }
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_INTERACT_ROAD)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_INTERACT_ROAD); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_ROAD);
e.setCancelled(true); e.setCancelled(true);
} }
} else { } else {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_INTERACT_UNOWNED)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_INTERACT_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_UNOWNED);
e.setCancelled(true); e.setCancelled(true);
} }
} else if (!plot.isAdded(pp.getUUID())) { } else if (!plot.isAdded(pp.getUUID())) {
final Entity entity = e.getRightClicked(); final Entity entity = e.getRightClicked();
if ((entity instanceof Monster) && FlagManager.isPlotFlagTrue(plot, FLAG_HOSTILE_INTERACT)) { if ((entity instanceof Monster) && FlagManager.isPlotFlagTrue(plot, C.FLAG_HOSTILE_INTERACT.s())) {
return; return;
} }
if ((entity instanceof Animals) && FlagManager.isPlotFlagTrue(plot, FLAG_ANIMAL_INTERACT)) { if ((entity instanceof Animals) && FlagManager.isPlotFlagTrue(plot, C.FLAG_ANIMAL_INTERACT.s())) {
return; return;
} }
if ((entity instanceof Tameable) && ((Tameable) entity).isTamed() && FlagManager.isPlotFlagTrue(plot, FLAG_TAMED_INTERACT)) { if ((entity instanceof Tameable) && ((Tameable) entity).isTamed() && FlagManager.isPlotFlagTrue(plot, C.FLAG_TAMED_INTERACT.s())) {
return; return;
} }
if ((entity instanceof RideableMinecart) && FlagManager.isPlotFlagTrue(plot, FLAG_VEHICLE_USE)) { if ((entity instanceof RideableMinecart) && FlagManager.isPlotFlagTrue(plot, C.FLAG_VEHICLE_USE.s())) {
return; return;
} }
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_INTERACT_OTHER)) { if ((entity instanceof Player) && FlagManager.isPlotFlagTrue(plot, C.FLAG_PLAYER_INTERACT.s())) {
return;
}
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER)) {
if (MainUtil.isPlotArea(l)) { if (MainUtil.isPlotArea(l)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_INTERACT_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_OTHER);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -1989,7 +1963,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
} }
else if (victim instanceof Player) { else if (victim instanceof Player) {
if (plot != null) { if (plot != null) {
Flag pvp = FlagManager.getPlotFlag(plot, FLAG_PVP); Flag pvp = FlagManager.getPlotFlag(plot, C.FLAG_PVP.s());
if (pvp == null) { if (pvp == null) {
return true; return true;
} else { } else {
@ -2082,43 +2056,43 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
final Plot plot = MainUtil.getPlot(loc); final Plot plot = MainUtil.getPlot(loc);
if (plot != null) { if (plot != null) {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_UNOWNED)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
else if (!plot.isAdded(pp.getUUID())) { else if (!plot.isAdded(pp.getUUID())) {
final Flag place = FlagManager.getPlotFlag(plot, FLAG_PLACE); final Flag place = FlagManager.getPlotFlag(plot, C.FLAG_PLACE.s());
final Block block = event.getBlock(); final Block block = event.getBlock();
if (((place == null) || !((HashSet<PlotBlock>) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) && !Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { if (((place == null) || !((HashSet<PlotBlock>) place.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
else if (plot.getSettings().flags.containsKey("done")) { else if (plot.getSettings().flags.containsKey("done")) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
if (FlagManager.isPlotFlagTrue(plot, FLAG_DISABLE_PHYSICS)) { if (FlagManager.isPlotFlagTrue(plot, C.FLAG_DISABLE_PHYSICS.s())) {
Block block = event.getBlockPlaced(); Block block = event.getBlockPlaced();
if (block.getType().hasGravity()) { if (block.getType().hasGravity()) {
sendBlockChange(block.getLocation(), block.getType(), block.getData()); sendBlockChange(block.getLocation(), block.getType(), block.getData());
} }
} }
PlotWorld pw = PS.get().getPlotWorld(loc.getWorld()); PlotWorld pw = PS.get().getPlotWorld(loc.getWorld());
if (loc.getY() >= pw.MAX_BUILD_HEIGHT && !Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) { if (loc.getY() >= pw.MAX_BUILD_HEIGHT && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
event.setCancelled(true); event.setCancelled(true);
MainUtil.sendMessage(pp, C.HEIGHT_LIMIT.s().replace("{limit}", "" + pw.MAX_BUILD_HEIGHT)); MainUtil.sendMessage(pp, C.HEIGHT_LIMIT.s().replace("{limit}", "" + pw.MAX_BUILD_HEIGHT));
} }
} }
else if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { else if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
if (MainUtil.isPlotAreaAbs(loc)) { if (MainUtil.isPlotAreaAbs(loc)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_ROAD); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -147,8 +147,7 @@ public class WEListener implements Listener {
long maxVolume = Settings.WE_MAX_VOLUME; long maxVolume = Settings.WE_MAX_VOLUME;
long maxIterations = Settings.WE_MAX_ITERATIONS; long maxIterations = Settings.WE_MAX_ITERATIONS;
if (pp.getAttribute("worldedit" )) {
if (WEManager.bypass.contains(pp.getName())) {
return true; return true;
} }
if (split.length >= 2) { if (split.length >= 2) {

View File

@ -13,7 +13,7 @@ import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
public class WEManager { public class WEManager {
public static HashSet<String> bypass = new HashSet<>(); // public static HashSet<String> bypass = new HashSet<>();
public static boolean maskContains(HashSet<RegionWrapper> mask, int x, int z) { public static boolean maskContains(HashSet<RegionWrapper> mask, int x, int z) {
for (RegionWrapper region : mask) { for (RegionWrapper region : mask) {

View File

@ -16,6 +16,7 @@ import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.util.eventbus.Subscribe;
public class WESubscriber { public class WESubscriber {
@Subscribe(priority=Priority.VERY_EARLY) @Subscribe(priority=Priority.VERY_EARLY)
public void onEditSession(EditSessionEvent event) { public void onEditSession(EditSessionEvent event) {
String world = event.getWorld().getName(); String world = event.getWorld().getName();
@ -25,7 +26,8 @@ public class WESubscriber {
Actor actor = event.getActor(); Actor actor = event.getActor();
if (actor != null && actor.isPlayer()) { if (actor != null && actor.isPlayer()) {
String name = actor.getName(); String name = actor.getName();
if (WEManager.bypass.contains(name)) { PlotPlayer pp = PlotPlayer.wrap(name);
if (pp != null && pp.getAttribute("worldedit")) {
return; return;
} }

View File

@ -132,12 +132,20 @@ public class BukkitPlayer extends PlotPlayer {
@Override @Override
public void setAttribute(String key) { public void setAttribute(String key) {
key = "plotsquared_user_attributes." + key; key = "plotsquared_user_attributes." + key;
if (EconHandler.manager == null) {
setMeta(key, true);
return;
}
EconHandler.manager.setPermission(getName(), key, true); EconHandler.manager.setPermission(getName(), key, true);
} }
@Override @Override
public boolean getAttribute(String key) { public boolean getAttribute(String key) {
key = "plotsquared_user_attributes." + key; key = "plotsquared_user_attributes." + key;
if (EconHandler.manager == null) {
Object v = getMeta(key);
return v == null ? false : (Boolean) v;
}
Permission perm = Bukkit.getServer().getPluginManager().getPermission(key); Permission perm = Bukkit.getServer().getPluginManager().getPermission(key);
if (perm == null) { if (perm == null) {
perm = new Permission(key, PermissionDefault.FALSE); perm = new Permission(key, PermissionDefault.FALSE);
@ -150,6 +158,10 @@ public class BukkitPlayer extends PlotPlayer {
@Override @Override
public void removeAttribute(String key) { public void removeAttribute(String key) {
key = "plotsquared_user_attributes." + key; key = "plotsquared_user_attributes." + key;
if (EconHandler.manager == null) {
deleteMeta(key);
return;
}
EconHandler.manager.setPermission(getName(), key, false); EconHandler.manager.setPermission(getName(), key, false);
} }

View File

@ -8,6 +8,7 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.util.Permissions;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class CommandManager<T extends CommandCaller> { public class CommandManager<T extends CommandCaller> {
@ -106,7 +107,7 @@ public class CommandManager<T extends CommandCaller> {
if (!cmd.getRequiredType().allows(plr)) { if (!cmd.getRequiredType().allows(plr)) {
return CommandHandlingOutput.CALLER_OF_WRONG_TYPE; return CommandHandlingOutput.CALLER_OF_WRONG_TYPE;
} }
if (!plr.hasPermission(cmd.getPermission())) { if (!Permissions.hasPermission(plr, cmd.getPermission())) {
return CommandHandlingOutput.NOT_PERMITTED; return CommandHandlingOutput.NOT_PERMITTED;
} }
Argument<?>[] requiredArguments = cmd.getRequiredArguments(); Argument<?>[] requiredArguments = cmd.getRequiredArguments();

View File

@ -1,18 +1,5 @@
package com.plotsquared.sponge.listener; package com.plotsquared.sponge.listener;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_BUILD_OTHER;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_BUILD_ROAD;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_BUILD_UNOWNED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_DESTROY_OTHER;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_DESTROY_ROAD;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_DESTROY_UNOWNED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_ENTRY_DENIED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_EXIT_DENIED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_INTERACT_OTHER;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_INTERACT_ROAD;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_ADMIN_INTERACT_UNOWNED;
import static com.intellectualcrafters.plot.object.StaticStrings.PERMISSION_COMMANDS_CHAT;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -122,9 +109,9 @@ public class MainListener {
} }
return; return;
} }
event.filterLocations(new Predicate<org.spongepowered.api.world.Location>() { event.filterLocations(new Predicate<org.spongepowered.api.world.Location<World>>() {
@Override @Override
public boolean apply(org.spongepowered.api.world.Location loc) { public boolean apply(org.spongepowered.api.world.Location<World> loc) {
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) { if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
return false; return false;
} }
@ -282,7 +269,7 @@ public class MainListener {
if (!PS.get().isPlotWorld(worldname)) { if (!PS.get().isPlotWorld(worldname)) {
return; return;
} }
event.filterLocations(new Predicate<org.spongepowered.api.world.Location>() { event.filterLocations(new Predicate<org.spongepowered.api.world.Location<World>>() {
@Override @Override
public boolean apply(org.spongepowered.api.world.Location loc) { public boolean apply(org.spongepowered.api.world.Location loc) {
if (MainUtil.isPlotRoad(SpongeUtil.getLocation(worldname, loc))) { if (MainUtil.isPlotRoad(SpongeUtil.getLocation(worldname, loc))) {
@ -342,7 +329,7 @@ public class MainListener {
if (plot.equals(MainUtil.getPlot(user.getLocation()))) { if (plot.equals(MainUtil.getPlot(user.getLocation()))) {
toSend = newMessage; toSend = newMessage;
} }
else if (Permissions.hasPermission(user, PERMISSION_COMMANDS_CHAT)) { else if (Permissions.hasPermission(user, C.PERMISSION_COMMANDS_CHAT)) {
((SpongePlayer) user).player.sendMessage(forcedMessage); ((SpongePlayer) user).player.sendMessage(forcedMessage);
continue; continue;
} }
@ -380,7 +367,7 @@ public class MainListener {
final Plot plot = MainUtil.getPlot(loc); final Plot plot = MainUtil.getPlot(loc);
if ((plot != null) && plot.hasOwner()) { if ((plot != null) && plot.hasOwner()) {
if (FlagManager.isPlotFlagTrue(plot, "explosion")) { if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
event.filterLocations(new Predicate<org.spongepowered.api.world.Location>() { event.filterLocations(new Predicate<org.spongepowered.api.world.Location<World>>() {
@Override @Override
public boolean apply(org.spongepowered.api.world.Location loc) { public boolean apply(org.spongepowered.api.world.Location loc) {
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) { if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
@ -417,7 +404,7 @@ public class MainListener {
return; return;
} else { } else {
if (FlagManager.isPlotFlagTrue(plot, "explosion")) { if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
event.filterLocations(new Predicate<org.spongepowered.api.world.Location>() { event.filterLocations(new Predicate<org.spongepowered.api.world.Location<World>>() {
@Override @Override
public boolean apply(org.spongepowered.api.world.Location loc) { public boolean apply(org.spongepowered.api.world.Location loc) {
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) { if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
@ -509,10 +496,10 @@ public class MainListener {
} }
final PlotPlayer pp = SpongeUtil.getPlayer(player); final PlotPlayer pp = SpongeUtil.getPlayer(player);
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_UNOWNED)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -522,15 +509,15 @@ public class MainListener {
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) { if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) {
return; return;
} }
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_OTHER)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true); event.setCancelled(true);
} }
else if (plot.getSettings().flags.containsKey("done")) { else if (plot.getSettings().flags.containsKey("done")) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -538,11 +525,11 @@ public class MainListener {
return; return;
} }
final PlotPlayer pp = SpongeUtil.getPlayer(player); final PlotPlayer pp = SpongeUtil.getPlayer(player);
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_ROAD)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
return; return;
} }
if (MainUtil.isPlotArea(loc)) { if (MainUtil.isPlotArea(loc)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_ROAD); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_ROAD);
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -562,10 +549,10 @@ public class MainListener {
} }
final PlotPlayer pp = SpongeUtil.getPlayer(player); final PlotPlayer pp = SpongeUtil.getPlayer(player);
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_UNOWNED)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -575,15 +562,15 @@ public class MainListener {
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) { if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) {
return; return;
} }
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true); event.setCancelled(true);
} }
else if (plot.getSettings().flags.containsKey("done")) { else if (plot.getSettings().flags.containsKey("done")) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -591,11 +578,11 @@ public class MainListener {
return; return;
} }
final PlotPlayer pp = SpongeUtil.getPlayer(player); final PlotPlayer pp = SpongeUtil.getPlayer(player);
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_ROAD)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD)) {
return; return;
} }
if (MainUtil.isPlotArea(loc)) { if (MainUtil.isPlotArea(loc)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_ROAD); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -615,10 +602,10 @@ public class MainListener {
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
final PlotPlayer pp = SpongeUtil.getPlayer(player); final PlotPlayer pp = SpongeUtil.getPlayer(player);
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_INTERACT_UNOWNED)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_INTERACT_UNOWNED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_UNOWNED);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -629,20 +616,20 @@ public class MainListener {
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) { if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) {
return; return;
} }
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_INTERACT_OTHER)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER)) {
return; return;
} }
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_INTERACT_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_OTHER);
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
} }
final PlotPlayer pp = SpongeUtil.getPlayer(player); final PlotPlayer pp = SpongeUtil.getPlayer(player);
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_INTERACT_ROAD)) { if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD)) {
return; return;
} }
if (MainUtil.isPlotArea(loc)) { if (MainUtil.isPlotArea(loc)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_INTERACT_ROAD); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_ROAD);
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -737,7 +724,7 @@ public class MainListener {
return; return;
} }
if (!PlotListener.plotExit(pp, lastPlot)) { if (!PlotListener.plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_EXIT_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) { if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setNewLocation(from); event.setNewLocation(from);
} }
@ -753,7 +740,7 @@ public class MainListener {
else { else {
Plot plot = MainUtil.getPlot(worldname, id); Plot plot = MainUtil.getPlot(worldname, id);
if (!PlotListener.plotEntry(pp, plot)) { if (!PlotListener.plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_ENTRY_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) { if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setNewLocation(from); event.setNewLocation(from);
} }
@ -804,7 +791,7 @@ public class MainListener {
return; return;
} }
if (!PlotListener.plotExit(pp, lastPlot)) { if (!PlotListener.plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_EXIT_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) { if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setNewLocation(from); event.setNewLocation(from);
} }
@ -820,7 +807,7 @@ public class MainListener {
else { else {
Plot plot = MainUtil.getPlot(worldname, id); Plot plot = MainUtil.getPlot(worldname, id);
if (!PlotListener.plotEntry(pp, plot)) { if (!PlotListener.plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_ENTRY_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) { if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setNewLocation(from); event.setNewLocation(from);
} }
@ -878,7 +865,7 @@ public class MainListener {
return; return;
} }
if (!PlotListener.plotExit(pp, lastPlot)) { if (!PlotListener.plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_EXIT_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) { if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setNewLocation(from); event.setNewLocation(from);
} }
@ -894,7 +881,7 @@ public class MainListener {
else { else {
Plot plot = MainUtil.getPlot(worldname, id); Plot plot = MainUtil.getPlot(worldname, id);
if (!PlotListener.plotEntry(pp, plot)) { if (!PlotListener.plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_ENTRY_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) { if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setNewLocation(from); event.setNewLocation(from);
} }
@ -945,7 +932,7 @@ public class MainListener {
return; return;
} }
if (!PlotListener.plotExit(pp, lastPlot)) { if (!PlotListener.plotExit(pp, lastPlot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_EXIT_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) { if (lastPlot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setNewLocation(from); event.setNewLocation(from);
} }
@ -961,7 +948,7 @@ public class MainListener {
else { else {
Plot plot = MainUtil.getPlot(worldname, id); Plot plot = MainUtil.getPlot(worldname, id);
if (!PlotListener.plotEntry(pp, plot)) { if (!PlotListener.plotEntry(pp, plot)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_ENTRY_DENIED); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) { if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(worldname, from)))) {
event.setNewLocation(from); event.setNewLocation(from);
} }

View File

@ -1,6 +1,10 @@
package com.plotsquared.sponge.util; package com.plotsquared.sponge.util;
import javax.swing.border.Border;
import org.spongepowered.api.text.title.Title; import org.spongepowered.api.text.title.Title;
import org.spongepowered.api.text.title.TitleBuilder;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.AbstractTitle; import com.intellectualcrafters.plot.util.AbstractTitle;
@ -11,6 +15,14 @@ public class SpongeTitleManager extends AbstractTitle {
@Override @Override
public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) { public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {
((SpongePlayer) player).player.sendTitle(new Title(SpongeMain.THIS.getText(head), SpongeMain.THIS.getText(sub), in * 20, delay * 20, out * 20, false, false)); Title title = new TitleBuilder()
.title(SpongeMain.THIS.getText(head))
.subtitle(SpongeMain.THIS.getText(sub))
.fadeIn(in * 20)
.stay(delay * 20)
.fadeOut(out * 20)
.build();
((SpongePlayer) player).player.sendTitle(title);
} }
} }

134
src/main/resources/base.yml Normal file
View File

@ -0,0 +1,134 @@
#######################################################################
# +-----------------------------------------------------------------+ #
# | BO3 object | #
# +-----------------------------------------------------------------+ #
#######################################################################
# This is the config file of a custom object.
# If you add this object correctly to your BiomeConfigs, it will spawn in the world.
# This is the creator of this BO3 object
Author: %owner%
# A short description of this BO3 object
Description: %alias%
# The BO3 version, don't change this! It can be used by external applications to do a version check.
Version: 3
# The settings mode, WriteAll, WriteWithoutComments or WriteDisable. See WorldConfig.
SettingsMode: WriteDisable
#######################################################################
# +-----------------------------------------------------------------+ #
# | Main settings | #
# +-----------------------------------------------------------------+ #
#######################################################################
# This needs to be set to true to spawn the object in the Tree and Sapling resources.
Tree: false
# The frequency of the BO3 from 1 to 200. Tries this many times to spawn this BO3 when using the CustomObject(...) resource.
# Ignored by Tree(..), Sapling(..) and CustomStructure(..)
Frequency: 5
# The rarity of the BO3 from 0 to 100. Each spawn attempt has rarity% chance to succeed when using the CustomObject(...) resource.
# Ignored by Tree(..), Sapling(..) and CustomStructure(..)
Rarity: 10.0
# If you set this to true, the BO3 will be placed with a random rotation.
RotateRandomly: false
# The spawn height of the BO3 - randomY, highestBlock or highestSolidBlock.
SpawnHeight: highestBlock
# The height limits for the BO3.
MinHeight: 0
MaxHeight: 256
# Objects can have other objects attacthed to it: branches. Branches can also
# have branches attached to it, which can also have branches, etc. This is the
# maximum branch depth for this objects.
MaxBranchDepth: 16
# When spawned with the UseWorld keyword, this BO3 should NOT spawn in the following biomes.
# If you writer.write the BO3 name directly in the BiomeConfigs, this will be ignored.
ExcludedBiomes: All
#######################################################################
# +-----------------------------------------------------------------+ #
# | Source block settings | #
# +-----------------------------------------------------------------+ #
#######################################################################
# The block(s) the BO3 should spawn in.
SourceBlocks: AIR
# The maximum percentage of the BO3 that can be outside the SourceBlock.
# The BO3 won't be placed on a location with more blocks outside the SourceBlock than this percentage.
MaxPercentageOutsideSourceBlock: 100
# What to do when a block is about to be placed outside the SourceBlock? (dontPlace, placeAnyway)
OutsideSourceBlock: placeAnyway
#######################################################################
# +-----------------------------------------------------------------+ #
# | Blocks | #
# +-----------------------------------------------------------------+ #
#######################################################################
# All the blocks used in the BO3 are listed here. Possible blocks:
# Block(x,y,z,id[.data][,nbtfile.nbt)
# RandomBlock(x,y,z,id[:data][,nbtfile.nbt],chance[,id[:data][,nbtfile.nbt],chance[,...]])
# So RandomBlock(0,0,0,CHEST,chest.nbt,50,CHEST,anotherchest.nbt,100) will spawn a chest at
# the BO3 origin, and give it a 50% chance to have the contents of chest.nbt, or, if that
# fails, a 100% percent chance to have the contents of anotherchest.nbt.
%blocks%
#######################################################################
# +-----------------------------------------------------------------+ #
# | BO3 checks | #
# +-----------------------------------------------------------------+ #
#######################################################################
# Require a condition at a certain location in order for the BO3 to be spawned.
# BlockCheck(x,y,z,BlockName[,BlockName[,...]]) - one of the blocks must be at the location
# BlockCheckNot(x,y,z,BlockName[,BlockName[,...]]) - all the blocks must not be at the location
# LightCheck(x,y,z,minLightLevel,maxLightLevel) - light must be between min and max (inclusive)
# You can use "Solid" as a BlockName for matching all solid blocks or "All" to match all blocks that aren't air.
# Examples:
# BlockCheck(0,-1,0,GRASS,DIRT) Require grass or dirt just below the object
# BlockCheck(0,-1,0,Solid) Require any solid block just below the object
# BlockCheck(0,-1,0,WOOL) Require any type of wool just below the object
# BlockCheck(0,-1,0,WOOL:0) Require white wool just below the object
# BlockCheckNot(0,-1,0,WOOL:0) Require that there is no white wool below the object
# LightCheck(0,0,0,0,1) Require almost complete darkness just below the object
BlockCheck(0,-1,0,Solid)
#######################################################################
# +-----------------------------------------------------------------+ #
# | Branches | #
# +-----------------------------------------------------------------+ #
#######################################################################
# Branches are objects that will spawn when this object spawns when it is used in
# the CustomStructure resource. Branches can also have branches, making complex
# structures possible. See the wiki for more details.
# Regular Branches spawn each branch with an independent chance of spawning.
# Branch(x,y,z,branchName,rotation,chance[,anotherBranchName,rotation,chance[,...]][IndividualChance])
# branchName - name of the object to spawn.
# rotation - NORTH, SOUTH, EAST or WEST.
# IndividualChance - The chance each branch has to spawn, assumed to be 100 when left blank
# Weighted Branches spawn branches with a dependent chance of spawning.
# WeightedBranch(x,y,z,branchName,rotation,chance[,anotherBranchName,rotation,chance[,...]][MaxChanceOutOf])
# MaxChanceOutOf - The chance all branches have to spawn out of, assumed to be 100 when left blank
%branches%

View File

@ -56,6 +56,7 @@ permissions:
plots.set.flag.vehicle-use: true plots.set.flag.vehicle-use: true
plots.set.flag.vehicle-place: true plots.set.flag.vehicle-place: true
plots.set.flag.vehicle-break: true plots.set.flag.vehicle-break: true
plots.set.flag.player-interact: true
plots.set.flag.place: true plots.set.flag.place: true
plots.set.flag.break: true plots.set.flag.break: true
plots.set.flag.use: true plots.set.flag.use: true
@ -109,6 +110,7 @@ permissions:
plots.confirm: true plots.confirm: true
plots.toggle: true plots.toggle: true
plots.toggle.titles: true plots.toggle.titles: true
plots.toggle.chat: true
plots.set.biome: true plots.set.biome: true
plots.set.home: true plots.set.home: true
plots.merge: true plots.merge: true
@ -124,6 +126,8 @@ permissions:
plots.kick: true plots.kick: true
plots.download: true plots.download: true
plots.save: true plots.save: true
plots.done: true
plots.continue: true
plots.worldedit.bypass: plots.worldedit.bypass:
default: false default: false
plots.gamemode.bypass: plots.gamemode.bypass: