diff --git a/pom.xml b/pom.xml
index 8c23e65..7c92bfc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
UTF-8
1.4-SNAPSHOT
- 1.8-R0.1-SNAPSHOT
+ 1.8.3-R0.1-SNAPSHOT
@@ -41,9 +41,9 @@
http://repo.ja-s.de/mvn
-
+
- bukkit-repo
+ spigot-repo
http://repo.bukkit.org/content/groups/public
@@ -91,6 +91,12 @@
worldguard
6.0.0-SNAPSHOT
+
+
+ com.sk89q
+ worldedit
+ 6.0.0-SNAPSHOT
+
uk.org.whoami
@@ -133,7 +139,7 @@
coreprotect
2.0.8
-
+
org.mcstats.bukkit
metrics
@@ -158,9 +164,6 @@
de.jaschastarke.maven.AnnotationProcessor
-
- **/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/*
-
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModBlockStates.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModBlockStates.java
index 370cfd5..3dc9021 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModBlockStates.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/ModBlockStates.java
@@ -1,8 +1,11 @@
package de.jaschastarke.minecraft.limitedcreative;
+
import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitRunnable;
+import com.sk89q.worldedit.WorldEdit;
+
import de.jaschastarke.bukkit.lib.CoreModule;
import de.jaschastarke.bukkit.lib.commands.AliasHelpedCommand;
import de.jaschastarke.bukkit.lib.modules.AdditionalBlockBreaks;
@@ -12,12 +15,11 @@ import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockListener;
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockStateCommand;
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockStateConfig;
import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel;
-import de.jaschastarke.minecraft.limitedcreative.blockstate.DependencyListener;
import de.jaschastarke.minecraft.limitedcreative.blockstate.HangingListener;
import de.jaschastarke.minecraft.limitedcreative.blockstate.PlayerListener;
import de.jaschastarke.minecraft.limitedcreative.blockstate.SyncronizedModel;
-import de.jaschastarke.minecraft.limitedcreative.blockstate.ThreadedModel;
-//import de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit.LCEditSessionFactory;
+import de.jaschastarke.minecraft.limitedcreative.blockstate.ThreadedModel;
+import de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit.EditSessionListener;
import de.jaschastarke.modularize.IModule;
import de.jaschastarke.modularize.ModuleEntry;
@@ -50,7 +52,6 @@ public class ModBlockStates extends CoreModule {
listeners.addListener(new BlockListener(this));
listeners.addListener(new HangingListener(this));
listeners.addListener(new PlayerListener(this));
- listeners.addListener(new DependencyListener(this));
command = new BlockStateCommand(this);
}
@@ -77,12 +78,11 @@ public class ModBlockStates extends CoreModule {
new BukkitRunnable() {
@Override
public void run() {
- getLog().warn("WorldEdit Integration is not Supported in this Version! Lookout for updates!");
- /*try {
- LCEditSessionFactory.initFactory(ModBlockStates.this);
+ try {
+ WorldEdit.getInstance().getEventBus().register(new EditSessionListener(ModBlockStates.this));
} catch (Exception e) {
getLog().warn(plugin.getLocale().trans("block_state.warning.worldedit_sessionfactory_failed", e.getMessage()));
- }*/
+ }
}
}.runTaskLater(plugin, 1L);
}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/DependencyListener.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/DependencyListener.java
deleted file mode 100644
index 1da1d24..0000000
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/DependencyListener.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package de.jaschastarke.minecraft.limitedcreative.blockstate;
-
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.server.PluginEnableEvent;
-
-import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
-import de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit.LCEditSessionFactory;
-
-public class DependencyListener implements Listener {
- private ModBlockStates mod;
-
- public DependencyListener(ModBlockStates mod) {
- this.mod = mod;
- }
-
- @EventHandler
- public void onPluginLoaded(PluginEnableEvent event) {
- if (event.getPlugin().getName().equals("LogBlock") || event.getPlugin().getName().equals("WorldEdit")) {
- try {
- if (mod.getPlugin().getServer().getPluginManager().isPluginEnabled("WorldEdit"))
- LCEditSessionFactory.initFactory(mod);
- } catch (Exception e) {
- mod.getLog().warn(mod.getPlugin().getLocale().trans("block_state.warning.worldedit_sessionfactory_failed", e.getMessage()));
- }
- }
- }
-}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/EditSessionExtent.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/EditSessionExtent.java
new file mode 100644
index 0000000..3120b65
--- /dev/null
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/EditSessionExtent.java
@@ -0,0 +1,58 @@
+package de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit;
+
+import java.util.Date;
+
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.entity.Player;
+
+import com.sk89q.worldedit.Vector;
+import com.sk89q.worldedit.blocks.BaseBlock;
+import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.extent.logging.AbstractLoggingExtent;
+
+import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
+import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState;
+import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState.Source;
+
+public class EditSessionExtent extends AbstractLoggingExtent {
+ private ModBlockStates mod;
+ private Player player = null;
+ private World world;
+
+ public EditSessionExtent(Extent extent, ModBlockStates mod, Player player, World world) {
+ super(extent);
+ this.mod = mod;
+ this.player = player;
+ this.world = world;
+ }
+
+ /**
+ * Called when a block is being changed.
+ *
+ * @param position the position
+ * @param newBlock the new block to replace the old one
+ */
+ protected void onBlockChange(Vector pt, BaseBlock newBlock) {
+ if (mod.isDebug())
+ mod.getLog().debug("WorldEdit-Integration: BlockChange: "+pt.toString()+" BB: " + newBlock.toString());
+ Location loc = new Location(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
+ if (newBlock.getType() == 0) {
+ mod.getModel().removeState(loc.getBlock());
+ } else {
+ BlockState s = mod.getModel().getState(loc.getBlock());
+ if (s == null) {
+ s = new BlockState();
+ s.setLocation(loc);
+ }
+ s.setGameMode(null);
+ s.setPlayerName(player.getName());
+ s.setDate(new Date());
+ s.setSource(Source.EDIT);
+ if (mod.isDebug())
+ mod.getLog().debug("WorldEdit-Integration: Saving BlockState: " + s.toString());
+
+ mod.getModel().setState(s);
+ }
+ }
+}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/EditSessionListener.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/EditSessionListener.java
new file mode 100644
index 0000000..c51ed3a
--- /dev/null
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/EditSessionListener.java
@@ -0,0 +1,38 @@
+package de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit;
+
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+
+import com.sk89q.worldedit.EditSession.Stage;
+import com.sk89q.worldedit.bukkit.BukkitWorld;
+import com.sk89q.worldedit.event.extent.EditSessionEvent;
+import com.sk89q.worldedit.extension.platform.Actor;
+import com.sk89q.worldedit.util.eventbus.Subscribe;
+import com.sk89q.worldedit.world.World;
+
+import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
+
+public class EditSessionListener {
+ private ModBlockStates mod;
+
+ public EditSessionListener(ModBlockStates mod) {
+ this.mod = mod;
+ }
+
+ @Subscribe
+ public void onEditSession(EditSessionEvent event) {
+ if (mod.getConfig().getWorldeditIntegration()) {
+ if (event.getStage() == Stage.BEFORE_CHANGE) {
+ if (mod.isDebug())
+ mod.getLog().debug("WorldEdit-Integration: New EditSession: "+event.getActor().getName()+" in World "+event.getWorld().getName()); // + " (" + event.getStage() + ")");
+ Actor actor = event.getActor();
+ World world = event.getWorld();
+ if (actor != null && actor.isPlayer() && world != null && world instanceof BukkitWorld) {
+ Player player = Bukkit.getPlayer(actor.getUniqueId());
+ event.setExtent(new EditSessionExtent(event.getExtent(), mod, player, ((BukkitWorld) event.getWorld()).getWorld()));
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/LCEditSession.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/LCEditSession.java
deleted file mode 100644
index edb8f13..0000000
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/LCEditSession.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit;
-
-import com.sk89q.worldedit.EditSession;
-import com.sk89q.worldedit.LocalPlayer;
-import com.sk89q.worldedit.LocalWorld;
-import com.sk89q.worldedit.MaxChangedBlocksException;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.bags.BlockBag;
-import com.sk89q.worldedit.blocks.BaseBlock;
-import com.sk89q.worldedit.patterns.Pattern;
-import com.sk89q.worldedit.regions.Region;
-
-import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.DBTransaction;
-
-public class LCEditSession extends EditSession {
- private LCEditSessionFactory factory;
- private LocalPlayer player;
-
- public LCEditSession(LCEditSessionFactory factory, LocalWorld world, int maxBlocks, BlockBag blockBag, LocalPlayer player) {
- super(world, maxBlocks, blockBag);
- this.factory = factory;
- this.player = player;
- }
-
- public LCEditSession(LCEditSessionFactory factory, LocalWorld world, int maxBlocks, LocalPlayer player) {
- super(world, maxBlocks);
- this.factory = factory;
- this.player = player;
- }
-
- private DBTransaction transaction;
-
- @Override
- public void flushQueue() {
- transaction = factory.getModel().groupUpdate();
- super.flushQueue();
- if (transaction != null) {
- transaction.finish();
- transaction = null;
- }
- }
-
- @Override
- public int setBlocks(Region region, BaseBlock block) throws MaxChangedBlocksException {
- boolean useTransaction = false;
- if (transaction == null) {
- transaction = factory.getModel().groupUpdate();
- useTransaction = true;
- }
- int ret;
- try {
- ret = super.setBlocks(region, block);
- } catch (MaxChangedBlocksException e) {
- transaction = null;
- throw e;
- }
- if (transaction != null && useTransaction) {
- transaction.finish();
- transaction = null;
- }
- return ret;
- }
-
- @Override
- public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
- boolean useTransaction = false;
- if (transaction == null) {
- transaction = factory.getModel().groupUpdate();
- useTransaction = true;
- }
- int ret;
- try {
- ret = super.setBlocks(region, pattern);
- } catch (MaxChangedBlocksException e) {
- transaction = null;
- throw e;
- }
- if (transaction != null && useTransaction) {
- transaction.finish();
- transaction = null;
- }
- return ret;
- }
-
- @Override
- public boolean rawSetBlock(Vector pt, BaseBlock block) {
- boolean success = super.rawSetBlock(pt, block);
- if (success) {
- if (transaction != null) {
- factory.onTransactionBlockEdit(transaction, player, pt, block);
- } else {
- factory.onBlockEdit(player, pt, block);
- }
- }
- return success;
- }
-}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/LCEditSessionFactory.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/LCEditSessionFactory.java
deleted file mode 100644
index 7eeef83..0000000
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/LCEditSessionFactory.java
+++ /dev/null
@@ -1,216 +0,0 @@
-package de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Date;
-
-import org.bukkit.Location;
-
-import com.sk89q.worldedit.EditSession;
-import com.sk89q.worldedit.EditSessionFactory;
-import com.sk89q.worldedit.LocalPlayer;
-import com.sk89q.worldedit.LocalWorld;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.WorldEdit;
-import com.sk89q.worldedit.bags.BlockBag;
-import com.sk89q.worldedit.blocks.BaseBlock;
-import com.sk89q.worldedit.bukkit.BukkitWorld;
-
-import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
-import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState;
-import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState.Source;
-import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel;
-import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.DBTransaction;
-
-public class LCEditSessionFactory extends EditSessionFactory {
- private ModBlockStates mod;
- private EditSessionParent parent;
-
- static enum EditSessionParent {
- WORLDEDIT,
- LOGBLOCK("de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit.LCEditSession_LogBlock"),
- COREPROTECT("de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit.LCEditSession_CoreProtect");
-
- private String cls = null;
- EditSessionParent() {
- }
- EditSessionParent(String cls) {
- this.cls = cls;
- }
- public EditSession createInstance(LCEditSessionFactory factory, LocalWorld world, int maxBlocks, LocalPlayer player) {
- if (this.cls != null) {
- try {
- @SuppressWarnings("unchecked")
- Class sessClass = (Class) Class.forName(cls);
- return sessClass.getConstructor(LCEditSessionFactory.class, LocalWorld.class, int.class, LocalPlayer.class)
- .newInstance(factory, world, maxBlocks, player);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (SecurityException e) {
- e.printStackTrace();
- }
- }
- return new LCEditSession(factory, world, maxBlocks, player);
- }
-
- public EditSession createInstance(LCEditSessionFactory factory, LocalWorld world, int maxBlocks, BlockBag blockBag, LocalPlayer player) {
- if (this.cls != null) {
- try {
- @SuppressWarnings("unchecked")
- Class sessClass = (Class) Class.forName(cls);
- return sessClass.getConstructor(LCEditSessionFactory.class, LocalWorld.class, int.class, LocalPlayer.class)
- .newInstance(factory, world, maxBlocks, player);
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (SecurityException e) {
- e.printStackTrace();
- }
- }
- return new LCEditSession(factory, world, maxBlocks, player);
- }
- }
-
- public ModBlockStates getLimitedCreativeModule() {
- return mod;
- }
-
- public LCEditSessionFactory(ModBlockStates mod, EditSessionParent parent) {
- this.mod = mod;
- this.parent = parent;
- }
-
- @Override
- public EditSession getEditSession(LocalWorld world, int maxBlocks, LocalPlayer player) {
- return parent.createInstance(this, world, maxBlocks, player);
- /*switch (parent) {
- case LOGBLOCK:
- return new LCEditSession_LogBlock(this, world, maxBlocks, player);
- default:
- return new LCEditSession(this, world, maxBlocks, player);
- }*/
- }
-
- // Without Player, the world isn't know, so we can't opporate
- /*@Override
- public EditSession getEditSession(LocalWorld world, int maxBlocks) {
- return new LCEditSession(this, world, maxBlocks, null);
- }*/
-
- @Override
- public EditSession getEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag, LocalPlayer player) {
- return parent.createInstance(this, world, maxBlocks, blockBag, player);
- /*switch (parent) {
- case LOGBLOCK:
- return new LCEditSession_LogBlock(this, world, maxBlocks, blockBag, player);
- default:
- return new LCEditSession(this, world, maxBlocks, blockBag, player);
- }*/
- }
-
- /*@Override
- public EditSession getEditSession(LocalWorld world, int maxBlocks, BlockBag blockBag) {
- return new LCEditSession(this, world, maxBlocks, blockBag, null);
- }*/
-
- public static void initFactory(ModBlockStates mod) throws Exception {
- EditSessionFactory currentEditSessionFactory = WorldEdit.getInstance().getEditSessionFactory();
- if (currentEditSessionFactory instanceof LCEditSessionFactory) {
- if (mod.isDebug())
- mod.getLog().debug("WorlEdit-SessionFactory is already hooked");
- } else if (currentEditSessionFactory.getClass().equals(EditSessionFactory.class)) { // not overridden
- if (mod.isDebug())
- mod.getLog().debug("Replacing WorldEdits SessionFactory");
- WorldEdit.getInstance().setEditSessionFactory(new LCEditSessionFactory(mod, EditSessionParent.WORLDEDIT));
- } else if (currentEditSessionFactory.getClass().getName().equals("de.diddiz.worldedit.LogBlockEditSessionFactory")) {
- if (mod.isDebug())
- mod.getLog().debug("Replacing LogBlocks WorldEdit-SessionFactory");
- WorldEdit.getInstance().setEditSessionFactory(new LCEditSessionFactory(mod, EditSessionParent.LOGBLOCK));
- } else if (currentEditSessionFactory.getClass().getName().equals("net.coreprotect.worldedit.CoreProtectEditSessionFactory")) {
- if (mod.isDebug())
- mod.getLog().debug("Replacing CoreProtects WorldEdit-SessionFactory");
- WorldEdit.getInstance().setEditSessionFactory(new LCEditSessionFactory(mod, EditSessionParent.COREPROTECT));
- } else {
- throw new Exception("WorldEdit-SessionFactory is hooked by an unknown another Plugin (" + currentEditSessionFactory.getClass().getName() + ").");
- }
- }
-
- /*public void onBlockEdit(Vector pt, BaseBlock block) {
- this.onBlockEdit(null, pt, block);
- }*/
-
- public DBModel getModel() {
- return mod.getModel();
- }
-
- public boolean onBlockEdit(LocalPlayer player, Vector pt, BaseBlock block) {
- if (player != null) {
- Location loc = new Location(((BukkitWorld) player.getWorld()).getWorld(), pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
- if (block.getType() == 0) {
- mod.getModel().removeState(loc.getBlock());
- } else {
- BlockState s = mod.getModel().getState(loc.getBlock());
- if (s == null) {
- s = new BlockState();
- s.setLocation(loc);
- }
- s.setGameMode(null);
- s.setPlayerName(player.getName());
- s.setDate(new Date());
- s.setSource(Source.EDIT);
- if (mod.isDebug())
- mod.getLog().debug("Saving BlockState: " + s.toString());
-
- mod.getModel().setState(s);
- }
- return true;
- } else {
- return false;
- }
- }
-
- public boolean onTransactionBlockEdit(DBTransaction transaction, LocalPlayer player, Vector pt, BaseBlock block) {
- if (player != null) {
- Location loc = new Location(((BukkitWorld) player.getWorld()).getWorld(), pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
- if (block.getType() == 0) {
- transaction.removeState(loc.getBlock());
- } else {
- BlockState s = mod.getModel().getState(loc.getBlock());
- if (s == null) {
- s = new BlockState();
- s.setLocation(loc);
- }
- s.setGameMode(null);
- s.setPlayerName(player.getName());
- s.setDate(new Date());
- s.setSource(Source.EDIT);
- if (mod.isDebug())
- mod.getLog().debug("Saving BlockState: " + s.toString());
-
- transaction.setState(s);
- }
- return true;
- } else {
- return false;
- }
- }
-
-}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/LCEditSession_CoreProtect.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/LCEditSession_CoreProtect.java
deleted file mode 100644
index e2ec4ff..0000000
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/LCEditSession_CoreProtect.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit;
-
-import net.coreprotect.CoreProtect;
-import net.coreprotect.worldedit.CoreProtectEditSession;
-
-import com.sk89q.worldedit.LocalPlayer;
-import com.sk89q.worldedit.LocalWorld;
-import com.sk89q.worldedit.MaxChangedBlocksException;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.bags.BlockBag;
-import com.sk89q.worldedit.blocks.BaseBlock;
-import com.sk89q.worldedit.patterns.Pattern;
-import com.sk89q.worldedit.regions.Region;
-
-import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.DBTransaction;
-
-public class LCEditSession_CoreProtect extends CoreProtectEditSession {
- private LCEditSessionFactory factory;
- private LocalPlayer player;
-
- public LCEditSession_CoreProtect(LCEditSessionFactory factory, LocalWorld world, int maxBlocks, BlockBag blockBag, LocalPlayer player) {
- super(world, maxBlocks, blockBag, player, CoreProtect.getInstance());
- this.factory = factory;
- this.player = player;
- }
-
- public LCEditSession_CoreProtect(LCEditSessionFactory factory, LocalWorld world, int maxBlocks, LocalPlayer player) {
- super(world, maxBlocks, player, CoreProtect.getInstance());
- this.factory = factory;
- this.player = player;
- }
-
- private DBTransaction transaction;
-
- @Override
- public void flushQueue() {
- transaction = factory.getModel().groupUpdate();
- super.flushQueue();
- if (transaction != null) {
- transaction.finish();
- transaction = null;
- }
- }
-
- @Override
- public int setBlocks(Region region, BaseBlock block) throws MaxChangedBlocksException {
- boolean useTransaction = false;
- if (transaction == null) {
- transaction = factory.getModel().groupUpdate();
- useTransaction = true;
- }
- int ret;
- try {
- ret = super.setBlocks(region, block);
- } catch (MaxChangedBlocksException e) {
- transaction = null;
- throw e;
- }
- if (transaction != null && useTransaction) {
- transaction.finish();
- transaction = null;
- }
- return ret;
- }
-
- @Override
- public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
- boolean useTransaction = false;
- if (transaction == null) {
- transaction = factory.getModel().groupUpdate();
- useTransaction = true;
- }
- int ret;
- try {
- ret = super.setBlocks(region, pattern);
- } catch (MaxChangedBlocksException e) {
- transaction = null;
- throw e;
- }
- if (transaction != null && useTransaction) {
- transaction.finish();
- transaction = null;
- }
- return ret;
- }
-
- @Override
- public boolean rawSetBlock(Vector pt, BaseBlock block) {
- boolean success = super.rawSetBlock(pt, block);
- if (success) {
- if (transaction != null) {
- factory.onTransactionBlockEdit(transaction, player, pt, block);
- } else {
- factory.onBlockEdit(player, pt, block);
- }
- }
- return success;
- }
-}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/LCEditSession_LogBlock.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/LCEditSession_LogBlock.java
deleted file mode 100644
index 00b90b4..0000000
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/LCEditSession_LogBlock.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit;
-
-import com.sk89q.worldedit.LocalPlayer;
-import com.sk89q.worldedit.LocalWorld;
-import com.sk89q.worldedit.MaxChangedBlocksException;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.bags.BlockBag;
-import com.sk89q.worldedit.blocks.BaseBlock;
-import com.sk89q.worldedit.patterns.Pattern;
-import com.sk89q.worldedit.regions.Region;
-
-import de.diddiz.LogBlock.LogBlock;
-import de.diddiz.worldedit.LogBlockEditSession;
-import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.DBTransaction;
-
-public class LCEditSession_LogBlock extends LogBlockEditSession {
- private LCEditSessionFactory factory;
- private LocalPlayer player;
-
- public LCEditSession_LogBlock(LCEditSessionFactory factory, LocalWorld world, int maxBlocks, BlockBag blockBag, LocalPlayer player) {
- super(world, maxBlocks, blockBag, player, LogBlock.getInstance());
- this.factory = factory;
- this.player = player;
- }
-
- public LCEditSession_LogBlock(LCEditSessionFactory factory, LocalWorld world, int maxBlocks, LocalPlayer player) {
- super(world, maxBlocks, player, LogBlock.getInstance());
- this.factory = factory;
- this.player = player;
- }
-
- private DBTransaction transaction;
-
- @Override
- public void flushQueue() {
- transaction = factory.getModel().groupUpdate();
- super.flushQueue();
- if (transaction != null) {
- transaction.finish();
- transaction = null;
- }
- }
-
- @Override
- public int setBlocks(Region region, BaseBlock block) throws MaxChangedBlocksException {
- boolean useTransaction = false;
- if (transaction == null) {
- transaction = factory.getModel().groupUpdate();
- useTransaction = true;
- }
- int ret;
- try {
- ret = super.setBlocks(region, block);
- } catch (MaxChangedBlocksException e) {
- transaction = null;
- throw e;
- }
- if (transaction != null && useTransaction) {
- transaction.finish();
- transaction = null;
- }
- return ret;
- }
-
- @Override
- public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
- boolean useTransaction = false;
- if (transaction == null) {
- transaction = factory.getModel().groupUpdate();
- useTransaction = true;
- }
- int ret;
- try {
- ret = super.setBlocks(region, pattern);
- } catch (MaxChangedBlocksException e) {
- transaction = null;
- throw e;
- }
- if (transaction != null && useTransaction) {
- transaction.finish();
- transaction = null;
- }
- return ret;
- }
-
- @Override
- public boolean rawSetBlock(Vector pt, BaseBlock block) {
- boolean success = super.rawSetBlock(pt, block);
- if (success) {
- if (transaction != null) {
- factory.onTransactionBlockEdit(transaction, player, pt, block);
- } else {
- factory.onBlockEdit(player, pt, block);
- }
- }
- return success;
- }
-}