Fixed plot home and add /debugallowunsafe

This commit is contained in:
Sauilitired 2015-07-15 21:57:11 +02:00
parent 1cc95d30d3
commit 572af771cd
7 changed files with 69 additions and 74 deletions

View File

@ -48,6 +48,10 @@
</plugins>
</build>
<repositories>
<repository>
<id>techcable-repo</id> <!-- Just leave the repositories section alone or bukkit won't work -->
<url>http://repo.techcable.net/content/groups/public/</url>
</repository>
<repository>
<id>empcraft-repo</id>
<url>http://empcraft.com/maven2</url>

View File

@ -12,6 +12,7 @@ import java.util.Map;
import java.util.Stack;
import java.util.UUID;
import com.intellectualcrafters.plot.commands.*;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
@ -27,69 +28,6 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader;
import com.intellectualcrafters.plot.commands.Add;
import com.intellectualcrafters.plot.commands.Auto;
import com.intellectualcrafters.plot.commands.BukkitCommand;
import com.intellectualcrafters.plot.commands.Chat;
import com.intellectualcrafters.plot.commands.Claim;
import com.intellectualcrafters.plot.commands.Clear;
import com.intellectualcrafters.plot.commands.Cluster;
import com.intellectualcrafters.plot.commands.Comment;
import com.intellectualcrafters.plot.commands.Condense;
import com.intellectualcrafters.plot.commands.Confirm;
import com.intellectualcrafters.plot.commands.Copy;
import com.intellectualcrafters.plot.commands.CreateRoadSchematic;
import com.intellectualcrafters.plot.commands.Database;
import com.intellectualcrafters.plot.commands.Debug;
import com.intellectualcrafters.plot.commands.DebugClaimTest;
import com.intellectualcrafters.plot.commands.DebugClear;
import com.intellectualcrafters.plot.commands.DebugExec;
import com.intellectualcrafters.plot.commands.DebugFill;
import com.intellectualcrafters.plot.commands.DebugFixFlags;
import com.intellectualcrafters.plot.commands.DebugLoadTest;
import com.intellectualcrafters.plot.commands.DebugRoadRegen;
import com.intellectualcrafters.plot.commands.DebugSaveTest;
import com.intellectualcrafters.plot.commands.DebugUUID;
import com.intellectualcrafters.plot.commands.Delete;
import com.intellectualcrafters.plot.commands.Deny;
import com.intellectualcrafters.plot.commands.Disable;
import com.intellectualcrafters.plot.commands.Download;
import com.intellectualcrafters.plot.commands.FlagCmd;
import com.intellectualcrafters.plot.commands.Help;
import com.intellectualcrafters.plot.commands.Home;
import com.intellectualcrafters.plot.commands.Inbox;
import com.intellectualcrafters.plot.commands.Info;
import com.intellectualcrafters.plot.commands.Inventory;
import com.intellectualcrafters.plot.commands.Kick;
import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.commands.Merge;
import com.intellectualcrafters.plot.commands.Move;
import com.intellectualcrafters.plot.commands.MusicSubcommand;
import com.intellectualcrafters.plot.commands.Purge;
import com.intellectualcrafters.plot.commands.Rate;
import com.intellectualcrafters.plot.commands.RegenAllRoads;
import com.intellectualcrafters.plot.commands.Reload;
import com.intellectualcrafters.plot.commands.Remove;
import com.intellectualcrafters.plot.commands.SchematicCmd;
import com.intellectualcrafters.plot.commands.Set;
import com.intellectualcrafters.plot.commands.SetOwner;
import com.intellectualcrafters.plot.commands.Setup;
import com.intellectualcrafters.plot.commands.Swap;
import com.intellectualcrafters.plot.commands.TP;
import com.intellectualcrafters.plot.commands.Target;
import com.intellectualcrafters.plot.commands.Template;
import com.intellectualcrafters.plot.commands.Toggle;
import com.intellectualcrafters.plot.commands.Trim;
import com.intellectualcrafters.plot.commands.Trust;
import com.intellectualcrafters.plot.commands.Unclaim;
import com.intellectualcrafters.plot.commands.Undeny;
import com.intellectualcrafters.plot.commands.Unlink;
import com.intellectualcrafters.plot.commands.Untrust;
import com.intellectualcrafters.plot.commands.Update;
import com.intellectualcrafters.plot.commands.Visit;
import com.intellectualcrafters.plot.commands.WE_Anywhere;
import com.intellectualcrafters.plot.commands.list;
import com.intellectualcrafters.plot.commands.plugin;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.plotme.ClassicPlotMeConnector;
@ -281,6 +219,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
MainCommand.subCommands.add(new DebugSaveTest());
MainCommand.subCommands.add(new DebugLoadTest());
MainCommand.subCommands.add(new CreateRoadSchematic());
MainCommand.subCommands.add(new DebugAllowUnsafe());
MainCommand.subCommands.add(new RegenAllRoads());
MainCommand.subCommands.add(new DebugClear());
MainCommand.subCommands.add(new Claim());

View File

@ -52,6 +52,7 @@ public enum Command {
DEBUGROADREGEN("debugroadregen"),
DEBUGFIXFLAGS("debugfixflags"),
REGENALLROADS("regenallroads"),
ALLOWUNSAFE("debugallowunsafe"),
DEBUGLOADTEST("debugloadtest"),
DEBUGSAVETEST("debugsavetest"),
UNCLAIM("unclaim"),

View File

@ -0,0 +1,39 @@
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.MainUtil;
import java.util.*;
public class DebugAllowUnsafe extends SubCommand {
public static final List<UUID> unsafeAllowed = new ArrayList<>();
public DebugAllowUnsafe() {
super(Command.ALLOWUNSAFE, "Allow unsafe actions until toggled off", "allowunsafe", CommandCategory.DEBUG, true);
}
@Override
public boolean execute(final PlotPlayer plr, final String... args) {
if (plr == null) {
MainUtil.sendMessage(plr, C.IS_CONSOLE);
return false;
}
if (unsafeAllowed.contains(plr.getUUID())) {
unsafeAllowed.remove(plr.getUUID());
sendMessage(plr, C.DEBUGALLOWUNSAFE_OFF);
} else {
unsafeAllowed.add(plr.getUUID());
sendMessage(plr, C.DEBUGALLOWUNSAFE_ON);
}
return true;
}
}

View File

@ -218,6 +218,9 @@ public class Set extends SubCommand {
final PlotWorld plotworld = PS.get().getPlotWorld(world);
final PlotManager manager = PS.get().getPlotManager(world);
final String[] components = manager.getPlotComponents(plotworld, plot.id);
boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(plr.getUUID());
for (final String component : components) {
if (component.equalsIgnoreCase(args[0])) {
if (!Permissions.hasPermission(plr, "plots.set." + component)) {
@ -251,15 +254,17 @@ public class Set extends SubCommand {
}
return false;
}
else if (!BlockManager.manager.isBlockSolid(block)) {
else if (!allowUnsafe && !BlockManager.manager.isBlockSolid(block)) {
MainUtil.sendMessage(plr, C.NOT_ALLOWED_BLOCK, block.toString());
return false;
}
}
for (PlotBlock block : blocks) {
if (!BlockManager.manager.isBlockSolid(block)) {
MainUtil.sendMessage(plr, C.NOT_ALLOWED_BLOCK, block.toString());
return false;
if (!allowUnsafe) {
for (PlotBlock block : blocks) {
if (!BlockManager.manager.isBlockSolid(block)) {
MainUtil.sendMessage(plr, C.NOT_ALLOWED_BLOCK, block.toString());
return false;
}
}
}
} catch (final Exception e2) {

View File

@ -319,6 +319,12 @@ public enum C {
* Set Block
*/
SET_BLOCK_ACTION_FINISHED("$1The last setblock action is now finished.", "Set Block"),
/*
AllowUnsafe
*/
DEBUGALLOWUNSAFE_ON("$2Unsafe actions allowed", "unsafe"),
DEBUGALLOWUNSAFE_OFF("$2Unsafe actions disabled", "unsafe"),
/*
* Debug
*/

View File

@ -134,7 +134,6 @@ public class MainUtil {
/**
* Merges all plots in the arraylist (with cost)
*
* @param plr
* @param world
* @param plotIds
*
@ -634,7 +633,7 @@ public class MainUtil {
return;
}
final Location loc = manager.getSignLoc(plotworld, p);
BlockManager.setBlocks(world, new int[] { loc.getX() }, new int[] { loc.getY() }, new int[] { loc.getZ() }, new int[] { 0 }, new byte[] { 0 });
BlockManager.setBlocks(world, new int[]{loc.getX()}, new int[]{loc.getY()}, new int[]{loc.getZ()}, new int[]{0}, new byte[]{0});
}
public static void setSign(final Plot p) {
@ -974,20 +973,22 @@ public class MainUtil {
if ((home == null) || ((home.x == 0) && (home.z == 0))) {
return getDefaultHome(plot);
} else {
final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y);
return bot.add(home.x, y, home.z);
Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y, bot.getZ() + home.z);
if (BukkitUtil.getBlock(loc).id != 0) {
sendConsoleMessage("ID was " + BukkitUtil.getBlock(loc).id);
loc.setY(Math.max(getHeighestBlock(w, bot.getX(), bot.getZ()), bot.getY()));
}
return loc;
}
}
/**
* Get the plot home
*
* @param w World
* @param plot Plot Object
*
* @return Plot Home Location
*
* @see #getPlotHome(String, Plot)
*/
public static Location getPlotHome(final Plot plot) {
return getPlotHome(plot.world, plot.id);