Changed WorldEdit API access method.

This commit is contained in:
Steven Lawson 2013-07-11 20:35:09 -04:00
parent 1fcda4a8fc
commit b9bd046105
3 changed files with 49 additions and 59 deletions

View File

@ -1,5 +1,5 @@
#Wed, 10 Jul 2013 21:43:33 -0400 #Thu, 11 Jul 2013 20:20:19 -0400
program.VERSION=2.21 program.VERSION=2.21
program.BUILDNUM=300 program.BUILDNUM=301
program.BUILDDATE=07/10/2013 09\:43 PM program.BUILDDATE=07/11/2013 08\:20 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Wed Jul 10 21:43:33 EDT 2013 #Thu Jul 11 20:20:19 EDT 2013
build.number=301 build.number=302

View File

@ -2,8 +2,6 @@ package me.StevenLawson.TotalFreedomMod;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.bukkit.BukkitServerInterface;
import com.sk89q.worldedit.bukkit.WorldEditAPI;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -12,8 +10,6 @@ import org.bukkit.plugin.Plugin;
public class TFM_WorldEditBridge public class TFM_WorldEditBridge
{ {
private WorldEditPlugin worldEditPlugin = null; private WorldEditPlugin worldEditPlugin = null;
private WorldEditAPI worldEditAPI = null;
private BukkitServerInterface bukkitServerInterface = null;
private TFM_WorldEditBridge() private TFM_WorldEditBridge()
{ {
@ -23,57 +19,56 @@ public class TFM_WorldEditBridge
{ {
if (this.worldEditPlugin == null) if (this.worldEditPlugin == null)
{ {
Plugin we = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"); try
if (we != null)
{ {
if (we instanceof WorldEditPlugin) Plugin we = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
if (we != null)
{ {
this.worldEditPlugin = (WorldEditPlugin) we; if (we instanceof WorldEditPlugin)
{
this.worldEditPlugin = (WorldEditPlugin) we;
}
} }
} }
catch (Exception ex)
{
TFM_Log.severe(ex);
}
} }
return this.worldEditPlugin; return this.worldEditPlugin;
} }
public WorldEditAPI getWorldEditAPI()
{
if (this.worldEditAPI == null)
{
WorldEditPlugin wep = getWorldEditPlugin();
if (wep != null)
{
this.worldEditAPI = new WorldEditAPI(wep);
}
}
return this.worldEditAPI;
}
public BukkitServerInterface getBukkitServerInterface()
{
if (this.bukkitServerInterface == null)
{
WorldEditPlugin wep = this.getWorldEditPlugin();
if (wep != null)
{
this.bukkitServerInterface = new BukkitServerInterface(wep, Bukkit.getServer());
}
}
return this.bukkitServerInterface;
}
public BukkitPlayer getBukkitPlayer(Player p) public BukkitPlayer getBukkitPlayer(Player p)
{ {
WorldEditPlugin wep = this.getWorldEditPlugin(); try
BukkitServerInterface bsi = this.getBukkitServerInterface();
if (wep != null && bsi != null)
{ {
return new BukkitPlayer(wep, bsi, p); WorldEditPlugin wep = this.getWorldEditPlugin();
if (wep != null)
{
return wep.wrapPlayer(p);
}
} }
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return null;
}
public LocalSession getPlayerSession(Player p)
{
try
{
WorldEditPlugin wep = this.getWorldEditPlugin();
if (wep != null)
{
return wep.getSession(p);
}
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
return null; return null;
} }
@ -81,13 +76,12 @@ public class TFM_WorldEditBridge
{ {
try try
{ {
WorldEditAPI api = this.getWorldEditAPI(); LocalSession session = getPlayerSession(p);
if (api != null) if (session != null)
{ {
LocalSession session = api.getSession(p); BukkitPlayer bukkitPlayer = this.getBukkitPlayer(p);
if (session != null) if (bukkitPlayer != null)
{ {
BukkitPlayer bukkitPlayer = this.getBukkitPlayer(p);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer); session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
@ -105,14 +99,10 @@ public class TFM_WorldEditBridge
{ {
try try
{ {
WorldEditAPI api = this.getWorldEditAPI(); LocalSession session = getPlayerSession(p);
if (api != null) if (session != null)
{ {
LocalSession session = api.getSession(p); session.setBlockChangeLimit(limit);
if (session != null)
{
session.setBlockChangeLimit(limit);
}
} }
} }
catch (Exception ex) catch (Exception ex)