forked from LogBlock/LogBlock
WorldEdit restored to soft dependency instead of dependency
This commit is contained in:
@@ -338,7 +338,7 @@ public class CommandsHandler implements CommandExecutor
|
|||||||
sender.sendMessage(ChatColor.RED + "You are not allowed to rollback more than " + rollbackMaxTime + " minutes");
|
sender.sendMessage(ChatColor.RED + "You are not allowed to rollback more than " + rollbackMaxTime + " minutes");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (rollbackMaxArea > 0 && (params.sel == null && params.loc == null || params.radius > rollbackMaxArea || params.sel != null && (params.sel.getLength() > rollbackMaxArea || params.sel.getWidth() > rollbackMaxArea))) {
|
if (rollbackMaxArea > 0 && (params.sel == null && params.loc == null || params.radius > rollbackMaxArea || params.sel != null && (params.sel.getSelection().getLength() > rollbackMaxArea || params.sel.getSelection().getWidth() > rollbackMaxArea))) {
|
||||||
sender.sendMessage(ChatColor.RED + "You are not allowed to rollback an area larger than " + rollbackMaxArea + " blocks");
|
sender.sendMessage(ChatColor.RED + "You are not allowed to rollback an area larger than " + rollbackMaxArea + " blocks");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -88,11 +88,7 @@ public class LogBlock extends JavaPlugin
|
|||||||
}
|
}
|
||||||
if (noDb)
|
if (noDb)
|
||||||
return;
|
return;
|
||||||
if (pm.getPlugin("WorldEdit") == null) {
|
if (pm.getPlugin("WorldEdit") != null) {
|
||||||
new Exception("WorldEdit is not installed please download and install").printStackTrace();
|
|
||||||
pm.disablePlugin(this);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
LogBlockEditSessionFactory.initialize();
|
LogBlockEditSessionFactory.initialize();
|
||||||
}
|
}
|
||||||
commandsHandler = new CommandsHandler(this);
|
commandsHandler = new CommandsHandler(this);
|
||||||
|
@@ -1,26 +1,7 @@
|
|||||||
package de.diddiz.LogBlock;
|
package de.diddiz.LogBlock;
|
||||||
|
|
||||||
import static de.diddiz.LogBlock.Session.getSession;
|
import de.diddiz.util.Block;
|
||||||
import static de.diddiz.LogBlock.config.Config.defaultDist;
|
import de.diddiz.worldedit.RegionContainer;
|
||||||
import static de.diddiz.LogBlock.config.Config.defaultTime;
|
|
||||||
import static de.diddiz.LogBlock.config.Config.getWorldConfig;
|
|
||||||
import static de.diddiz.LogBlock.config.Config.isLogged;
|
|
||||||
import static de.diddiz.LogBlock.config.Config.isLogging;
|
|
||||||
import static de.diddiz.util.BukkitUtils.friendlyWorldname;
|
|
||||||
import static de.diddiz.util.BukkitUtils.getBlockEquivalents;
|
|
||||||
import static de.diddiz.util.MaterialName.materialName;
|
|
||||||
import static de.diddiz.util.Utils.isInt;
|
|
||||||
import static de.diddiz.util.Utils.join;
|
|
||||||
import static de.diddiz.util.Utils.listing;
|
|
||||||
import static de.diddiz.util.Utils.parseTimeSpec;
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@@ -28,8 +9,18 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import de.diddiz.LogBlock.config.Config;
|
import java.util.ArrayList;
|
||||||
import de.diddiz.util.Block;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static de.diddiz.LogBlock.Session.getSession;
|
||||||
|
import static de.diddiz.LogBlock.config.Config.*;
|
||||||
|
import static de.diddiz.util.BukkitUtils.friendlyWorldname;
|
||||||
|
import static de.diddiz.util.BukkitUtils.getBlockEquivalents;
|
||||||
|
import static de.diddiz.util.MaterialName.materialName;
|
||||||
|
import static de.diddiz.util.Utils.*;
|
||||||
|
|
||||||
public final class QueryParams implements Cloneable
|
public final class QueryParams implements Cloneable
|
||||||
{
|
{
|
||||||
@@ -42,7 +33,7 @@ public final class QueryParams implements Cloneable
|
|||||||
public List<String> killers = new ArrayList<String>();
|
public List<String> killers = new ArrayList<String>();
|
||||||
public List<String> victims = new ArrayList<String>();
|
public List<String> victims = new ArrayList<String>();
|
||||||
public boolean excludePlayersMode = false, excludeKillersMode = false, excludeVictimsMode = false, prepareToolQuery = false, silent = false;
|
public boolean excludePlayersMode = false, excludeKillersMode = false, excludeVictimsMode = false, prepareToolQuery = false, silent = false;
|
||||||
public Selection sel = null;
|
public RegionContainer sel = null;
|
||||||
public SummarizationMode sum = SummarizationMode.NONE;
|
public SummarizationMode sum = SummarizationMode.NONE;
|
||||||
public List<Block> types = new ArrayList<Block>();
|
public List<Block> types = new ArrayList<Block>();
|
||||||
public World world = null;
|
public World world = null;
|
||||||
@@ -285,7 +276,9 @@ public final class QueryParams implements Cloneable
|
|||||||
else if (radius > 0)
|
else if (radius > 0)
|
||||||
where.append("x > '").append(loc.getBlockX() - radius).append("' AND x < '").append(loc.getBlockX() + radius).append("' AND y > '").append(loc.getBlockY() - radius).append("' AND y < '").append(loc.getBlockY() + radius).append("' AND z > '").append(loc.getBlockZ() - radius).append("' AND z < '").append(loc.getBlockZ() + radius).append("' AND ");
|
where.append("x > '").append(loc.getBlockX() - radius).append("' AND x < '").append(loc.getBlockX() + radius).append("' AND y > '").append(loc.getBlockY() - radius).append("' AND y < '").append(loc.getBlockY() + radius).append("' AND z > '").append(loc.getBlockZ() - radius).append("' AND z < '").append(loc.getBlockZ() + radius).append("' AND ");
|
||||||
} else if (sel != null)
|
} else if (sel != null)
|
||||||
where.append("x >= '").append(sel.getMinimumPoint().getBlockX()).append("' AND x <= '").append(sel.getMaximumPoint().getBlockX()).append("' AND y >= '").append(sel.getMinimumPoint().getBlockY()).append("' AND y <= '").append(sel.getMaximumPoint().getBlockY()).append("' AND z >= '").append(sel.getMinimumPoint().getBlockZ()).append("' AND z <= '").append(sel.getMaximumPoint().getBlockZ()).append("' AND ");
|
where.append("x >= '").append(sel.getSelection().getMinimumPoint().getBlockX()).append("' AND x <= '").append(sel.getSelection().getMaximumPoint().getBlockX())
|
||||||
|
.append("' AND y >= '").append(sel.getSelection().getMinimumPoint().getBlockY()).append("' AND y <= '").append(sel.getSelection().getMaximumPoint().getBlockY())
|
||||||
|
.append("' AND z >= '").append(sel.getSelection().getMinimumPoint().getBlockZ()).append("' AND z <= '").append(sel.getSelection().getMaximumPoint().getBlockZ()).append("' AND ");
|
||||||
} else {
|
} else {
|
||||||
switch (blockChangeType) {
|
switch (blockChangeType) {
|
||||||
case ALL:
|
case ALL:
|
||||||
@@ -381,7 +374,9 @@ public final class QueryParams implements Cloneable
|
|||||||
else if (radius > 0)
|
else if (radius > 0)
|
||||||
where.append("x > '").append(loc.getBlockX() - radius).append("' AND x < '").append(loc.getBlockX() + radius).append("' AND y > '").append(loc.getBlockY() - radius).append("' AND y < '").append(loc.getBlockY() + radius).append("' AND z > '").append(loc.getBlockZ() - radius).append("' AND z < '").append(loc.getBlockZ() + radius).append("' AND ");
|
where.append("x > '").append(loc.getBlockX() - radius).append("' AND x < '").append(loc.getBlockX() + radius).append("' AND y > '").append(loc.getBlockY() - radius).append("' AND y < '").append(loc.getBlockY() + radius).append("' AND z > '").append(loc.getBlockZ() - radius).append("' AND z < '").append(loc.getBlockZ() + radius).append("' AND ");
|
||||||
} else if (sel != null)
|
} else if (sel != null)
|
||||||
where.append("x >= '").append(sel.getMinimumPoint().getBlockX()).append("' AND x <= '").append(sel.getMaximumPoint().getBlockX()).append("' AND y >= '").append(sel.getMinimumPoint().getBlockY()).append("' AND y <= '").append(sel.getMaximumPoint().getBlockY()).append("' AND z >= '").append(sel.getMinimumPoint().getBlockZ()).append("' AND z <= '").append(sel.getMaximumPoint().getBlockZ()).append("' AND ");
|
where.append("x >= '").append(sel.getSelection().getMinimumPoint().getBlockX()).append("' AND x <= '").append(sel.getSelection().getMaximumPoint().getBlockX())
|
||||||
|
.append("' AND y >= '").append(sel.getSelection().getMinimumPoint().getBlockY()).append("' AND y <= '").append(sel.getSelection().getMaximumPoint().getBlockY()).
|
||||||
|
append("' AND z >= '").append(sel.getSelection().getMinimumPoint().getBlockZ()).append("' AND z <= '").append(sel.getSelection().getMaximumPoint().getBlockZ()).append("' AND ");
|
||||||
}
|
}
|
||||||
if (!players.isEmpty() && sum != SummarizationMode.PLAYERS && blockChangeType != BlockChangeType.KILLS)
|
if (!players.isEmpty() && sum != SummarizationMode.PLAYERS && blockChangeType != BlockChangeType.KILLS)
|
||||||
if (!excludePlayersMode) {
|
if (!excludePlayersMode) {
|
||||||
@@ -526,14 +521,11 @@ public final class QueryParams implements Cloneable
|
|||||||
if (player == null)
|
if (player == null)
|
||||||
throw new IllegalArgumentException("You have to ba a player to use selection");
|
throw new IllegalArgumentException("You have to ba a player to use selection");
|
||||||
final Plugin we = player.getServer().getPluginManager().getPlugin("WorldEdit");
|
final Plugin we = player.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
if (we == null)
|
if (we != null) {
|
||||||
throw new IllegalArgumentException("WorldEdit plugin not found");
|
setSelection(RegionContainer.fromPlayerSelection(player, we));
|
||||||
final Selection selection = ((WorldEditPlugin)we).getSelection(player);
|
} else {
|
||||||
if (selection == null)
|
throw new IllegalArgumentException("WorldEdit not found!");
|
||||||
throw new IllegalArgumentException("No selection defined");
|
}
|
||||||
if (!(selection instanceof CuboidSelection))
|
|
||||||
throw new IllegalArgumentException("You have to define a cuboid selection");
|
|
||||||
setSelection(selection);
|
|
||||||
} else if (param.equals("time") || param.equals("since")) {
|
} else if (param.equals("time") || param.equals("since")) {
|
||||||
since = values.length > 0 ? parseTimeSpec(values) : defaultTime;
|
since = values.length > 0 ? parseTimeSpec(values) : defaultTime;
|
||||||
if (since == -1)
|
if (since == -1)
|
||||||
@@ -634,9 +626,9 @@ public final class QueryParams implements Cloneable
|
|||||||
world = loc.getWorld();
|
world = loc.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelection(Selection sel) {
|
public void setSelection(RegionContainer container) {
|
||||||
this.sel = sel;
|
this.sel = container;
|
||||||
world = sel.getWorld();
|
world = sel.getSelection().getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayer(String playerName) {
|
public void setPlayer(String playerName) {
|
||||||
|
@@ -1,11 +1,14 @@
|
|||||||
package de.diddiz.LogBlock.listeners;
|
package de.diddiz.LogBlock.listeners;
|
||||||
|
|
||||||
import static de.diddiz.LogBlock.Session.getSession;
|
import de.diddiz.LogBlock.CommandsHandler;
|
||||||
import static de.diddiz.LogBlock.Session.hasSession;
|
import de.diddiz.LogBlock.LogBlock;
|
||||||
import static de.diddiz.LogBlock.config.Config.isLogged;
|
import de.diddiz.LogBlock.QueryParams;
|
||||||
import static de.diddiz.LogBlock.config.Config.toolsByType;
|
import de.diddiz.LogBlock.Session;
|
||||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
import de.diddiz.LogBlock.Tool;
|
||||||
import java.util.Map.Entry;
|
import de.diddiz.LogBlock.ToolBehavior;
|
||||||
|
import de.diddiz.LogBlock.ToolData;
|
||||||
|
import de.diddiz.LogBlock.ToolMode;
|
||||||
|
import de.diddiz.worldedit.RegionContainer;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
@@ -17,14 +20,13 @@ import org.bukkit.event.player.PlayerChangedWorldEvent;
|
|||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import de.diddiz.LogBlock.CommandsHandler;
|
|
||||||
import de.diddiz.LogBlock.LogBlock;
|
import java.util.Map.Entry;
|
||||||
import de.diddiz.LogBlock.QueryParams;
|
|
||||||
import de.diddiz.LogBlock.Session;
|
import static de.diddiz.LogBlock.Session.getSession;
|
||||||
import de.diddiz.LogBlock.Tool;
|
import static de.diddiz.LogBlock.Session.hasSession;
|
||||||
import de.diddiz.LogBlock.ToolBehavior;
|
import static de.diddiz.LogBlock.config.Config.isLogged;
|
||||||
import de.diddiz.LogBlock.ToolData;
|
import static de.diddiz.LogBlock.config.Config.toolsByType;
|
||||||
import de.diddiz.LogBlock.ToolMode;
|
|
||||||
|
|
||||||
public class ToolListener implements Listener
|
public class ToolListener implements Listener
|
||||||
{
|
{
|
||||||
@@ -56,11 +58,17 @@ public class ToolListener implements Listener
|
|||||||
else if (block.getTypeId() != 54 || tool.params.radius != 0)
|
else if (block.getTypeId() != 54 || tool.params.radius != 0)
|
||||||
params.setLocation(block.getLocation());
|
params.setLocation(block.getLocation());
|
||||||
else {
|
else {
|
||||||
for (final BlockFace face : new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST})
|
if (logblock.getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
|
||||||
if (block.getRelative(face).getTypeId() == 54)
|
for (final BlockFace face : new BlockFace[]{BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST}) {
|
||||||
params.setSelection(new CuboidSelection(event.getPlayer().getWorld(), block.getLocation(), block.getRelative(face).getLocation()));
|
if (block.getRelative(face).getTypeId() == 54) {
|
||||||
if (params.sel == null)
|
params.setSelection(RegionContainer.fromCorners(event.getPlayer().getWorld(),
|
||||||
params.setLocation(block.getLocation());
|
block.getLocation(), block.getRelative(face).getLocation()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (params.sel == null) {
|
||||||
|
params.setLocation(block.getLocation());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (toolData.mode == ToolMode.ROLLBACK)
|
if (toolData.mode == ToolMode.ROLLBACK)
|
||||||
|
41
src/main/java/de/diddiz/worldedit/RegionContainer.java
Normal file
41
src/main/java/de/diddiz/worldedit/RegionContainer.java
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package de.diddiz.worldedit;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||||
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class RegionContainer {
|
||||||
|
|
||||||
|
private Selection selection;
|
||||||
|
|
||||||
|
public RegionContainer(Selection sel) {
|
||||||
|
this.selection = sel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RegionContainer fromPlayerSelection(Player player, Plugin plugin) {
|
||||||
|
final Selection selection = ((WorldEditPlugin) plugin).getSelection(player);
|
||||||
|
if (selection == null) {
|
||||||
|
throw new IllegalArgumentException("No selection defined");
|
||||||
|
}
|
||||||
|
if (!(selection instanceof CuboidSelection)) {
|
||||||
|
throw new IllegalArgumentException("You have to define a cuboid selection");
|
||||||
|
}
|
||||||
|
return new RegionContainer(selection);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RegionContainer fromCorners(World world, Location first, Location second) {
|
||||||
|
return new RegionContainer(new CuboidSelection(world, first, second));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Selection getSelection() {
|
||||||
|
return selection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelection(Selection selection) {
|
||||||
|
this.selection = selection;
|
||||||
|
}
|
||||||
|
}
|
@@ -5,8 +5,7 @@ authors: [md_5, ammar2]
|
|||||||
website: http://dev.bukkit.org/server-mods/logblock/
|
website: http://dev.bukkit.org/server-mods/logblock/
|
||||||
main: de.diddiz.LogBlock.LogBlock
|
main: de.diddiz.LogBlock.LogBlock
|
||||||
description: ${project.description}
|
description: ${project.description}
|
||||||
softdepend: [LogBlockQuestioner]
|
softdepend: [LogBlockQuestioner, WorldEdit]
|
||||||
depend: [WorldEdit]
|
|
||||||
commands:
|
commands:
|
||||||
lb:
|
lb:
|
||||||
description: 'LogBlock plugin commands'
|
description: 'LogBlock plugin commands'
|
||||||
|
Reference in New Issue
Block a user