CoreProtect WE-Integration support

This commit is contained in:
Jascha Starke 2013-10-29 13:09:17 +01:00
parent fcb1e92f90
commit 808b50fb61
6 changed files with 64 additions and 9 deletions

10
pom.xml
View file

@ -9,6 +9,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plib.version>1.4-SNAPSHOT</plib.version> <plib.version>1.4-SNAPSHOT</plib.version>
<bukkit.version>1.6.4-R1.0</bukkit.version>
</properties> </properties>
<scm> <scm>
@ -77,7 +78,7 @@
<!-- http://dl.bukkit.org/ --> <!-- http://dl.bukkit.org/ -->
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
<version>1.6.2-R0.1</version> <version>${bukkit.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<!-- http://dev.bukkit.org/server-mods/worldguard/ --> <!-- http://dev.bukkit.org/server-mods/worldguard/ -->
@ -121,6 +122,12 @@
<artifactId>logblock</artifactId> <artifactId>logblock</artifactId>
<version>dev-SNAPSHOT</version> <version>dev-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<!-- http://dev.bukkit.org/bukkit-plugins/coreprotect/ -->
<groupId>net.coreprotect</groupId>
<artifactId>coreprotect</artifactId>
<version>2.0.8</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -165,6 +172,7 @@
<param>Multiverse-Inventories</param> <param>Multiverse-Inventories</param>
<param>Vault</param> <param>Vault</param>
<param>LogBlock</param> <param>LogBlock</param>
<param>CoreProtect</param>
</softdepend> </softdepend>
<custom> <custom>
<dev-url>http://dev.bukkit.org/server-mods/limited-creative/</dev-url> <dev-url>http://dev.bukkit.org/server-mods/limited-creative/</dev-url>

View file

@ -1,6 +1,7 @@
package de.jaschastarke.minecraft.limitedcreative; package de.jaschastarke.minecraft.limitedcreative;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.scheduler.BukkitRunnable;
import de.jaschastarke.bukkit.lib.CoreModule; import de.jaschastarke.bukkit.lib.CoreModule;
import de.jaschastarke.bukkit.lib.commands.AliasHelpedCommand; import de.jaschastarke.bukkit.lib.commands.AliasHelpedCommand;
@ -72,11 +73,17 @@ public class ModBlockStates extends CoreModule<LimitedCreative> {
return; return;
} }
super.onEnable(); super.onEnable();
try { if (plugin.getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
if (plugin.getServer().getPluginManager().isPluginEnabled("WorldEdit")) new BukkitRunnable() {
LCEditSessionFactory.initFactory(this); @Override
} catch (Exception e) { public void run() {
getLog().warn(plugin.getLocale().trans("block_state.warning.worldedit_sessionfactory_failed", e.getMessage())); try {
LCEditSessionFactory.initFactory(ModBlockStates.this);
} catch (Exception e) {
getLog().warn(plugin.getLocale().trans("block_state.warning.worldedit_sessionfactory_failed", e.getMessage()));
}
}
}.runTaskLater(plugin, 1L);
} }
plugin.getCommandHandler().registerCommand(command); plugin.getCommandHandler().registerCommand(command);

View file

@ -25,7 +25,8 @@ public class LCEditSessionFactory extends EditSessionFactory {
static enum EditSessionParent { static enum EditSessionParent {
WORLDEDIT, WORLDEDIT,
LOGBLOCK("de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit.LCEditSession_LogBlock"); LOGBLOCK("de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit.LCEditSession_LogBlock"),
COREPROTECT("de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit.LCEditSession_CoreProtect");
private String cls = null; private String cls = null;
EditSessionParent() { EditSessionParent() {
@ -141,6 +142,10 @@ public class LCEditSessionFactory extends EditSessionFactory {
if (mod.isDebug()) if (mod.isDebug())
mod.getLog().debug("Replacing LogBlocks WorldEdit-SessionFactory"); mod.getLog().debug("Replacing LogBlocks WorldEdit-SessionFactory");
WorldEdit.getInstance().setEditSessionFactory(new LCEditSessionFactory(mod, EditSessionParent.LOGBLOCK)); 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 { } else {
throw new Exception("WorldEdit-SessionFactory is hooked by an unknown another Plugin (" + currentEditSessionFactory.getClass().getName() + ")."); throw new Exception("WorldEdit-SessionFactory is hooked by an unknown another Plugin (" + currentEditSessionFactory.getClass().getName() + ").");
} }

View file

@ -0,0 +1,35 @@
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.Vector;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.blocks.BaseBlock;
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;
}
@Override
public boolean rawSetBlock(Vector pt, BaseBlock block) {
boolean success = super.rawSetBlock(pt, block);
if (success)
factory.onBlockEdit(player, pt, block);
return success;
}
}

View file

@ -69,7 +69,7 @@ blocked.break: You are not allowed to break this type of block
blocked.region.piston: Moving {0} block out of creative area was blocked at {1} blocked.region.piston: Moving {0} block out of creative area was blocked at {1}
blocked.region.piston_in: Moving {0} block into creative area was blocked at {1} blocked.region.piston_in: Moving {0} block into creative area was blocked at {1}
block_state.warning.worldedit_sessionfactory_failed: Failed to hook into WorldEdit. WorldEdit-actions can''t be traced. Error: block_state.warning.worldedit_sessionfactory_failed: Failed to hook into WorldEdit. WorldEdit-actions can''t be traced. Error: {0}
block_state.tool_info.seed: This {0}-Block is generated by the god who created this world block_state.tool_info.seed: This {0}-Block is generated by the god who created this world
block_state.tool_info.player: This {0}-Block was created by ''{1}'' in {2}-mode on {3} block_state.tool_info.player: This {0}-Block was created by ''{1}'' in {2}-mode on {3}
block_state.tool_info.edit: This {0}-Block was modified with WorldEdit by ''{1}'' on {3} block_state.tool_info.edit: This {0}-Block was modified with WorldEdit by ''{1}'' on {3}

View file

@ -69,7 +69,7 @@ blocked.break: Du darfst diesen Block nicht zerst
blocked.region.piston: Verschieben eines {0} Blocks aus einem GameMode-Bereich wurde bei {1} verhindet blocked.region.piston: Verschieben eines {0} Blocks aus einem GameMode-Bereich wurde bei {1} verhindet
blocked.region.piston_in: Verschieben eines {0} Blocks in einen GameMode-Bereich wurde bei {1} verhindet blocked.region.piston_in: Verschieben eines {0} Blocks in einen GameMode-Bereich wurde bei {1} verhindet
block_state.warning.worldedit_sessionfactory_failed: Fehler beim Einhängen in WorldEdit. WorldEdit-Aktionen können nicht nachvollzogen werden. Fehler: block_state.warning.worldedit_sessionfactory_failed: Fehler beim Einhängen in WorldEdit. WorldEdit-Aktionen können nicht nachvollzogen werden. Fehler: {0}
block_state.tool_info.seed: Dieser {0}-Block wurde von dem Gott generiert der diese Welt erschuf block_state.tool_info.seed: Dieser {0}-Block wurde von dem Gott generiert der diese Welt erschuf
block_state.tool_info.player: Dieser {0}-Block wurde am {3} von ''{1}'' im {2}-Modus gebaut block_state.tool_info.player: Dieser {0}-Block wurde am {3} von ''{1}'' im {2}-Modus gebaut
block_state.tool_info.edit: Der {0}-Block wurde am {3} von ''{1}'' mit WorldEdit gesetzt block_state.tool_info.edit: Der {0}-Block wurde am {3} von ''{1}'' mit WorldEdit gesetzt