mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Changed WorldEdit API access method.
This commit is contained in:
parent
1fcda4a8fc
commit
b9bd046105
@ -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.BUILDNUM=300
|
||||
program.BUILDDATE=07/10/2013 09\:43 PM
|
||||
program.BUILDNUM=301
|
||||
program.BUILDDATE=07/11/2013 08\:20 PM
|
||||
|
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Wed Jul 10 21:43:33 EDT 2013
|
||||
build.number=301
|
||||
#Thu Jul 11 20:20:19 EDT 2013
|
||||
build.number=302
|
||||
|
@ -2,8 +2,6 @@ package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
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 org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -12,8 +10,6 @@ import org.bukkit.plugin.Plugin;
|
||||
public class TFM_WorldEditBridge
|
||||
{
|
||||
private WorldEditPlugin worldEditPlugin = null;
|
||||
private WorldEditAPI worldEditAPI = null;
|
||||
private BukkitServerInterface bukkitServerInterface = null;
|
||||
|
||||
private TFM_WorldEditBridge()
|
||||
{
|
||||
@ -22,6 +18,8 @@ public class TFM_WorldEditBridge
|
||||
public WorldEditPlugin getWorldEditPlugin()
|
||||
{
|
||||
if (this.worldEditPlugin == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
Plugin we = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
if (we != null)
|
||||
@ -32,48 +30,45 @@ public class TFM_WorldEditBridge
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
WorldEditPlugin wep = this.getWorldEditPlugin();
|
||||
BukkitServerInterface bsi = this.getBukkitServerInterface();
|
||||
|
||||
if (wep != null && bsi != null)
|
||||
try
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -81,13 +76,12 @@ public class TFM_WorldEditBridge
|
||||
{
|
||||
try
|
||||
{
|
||||
WorldEditAPI api = this.getWorldEditAPI();
|
||||
if (api != null)
|
||||
{
|
||||
LocalSession session = api.getSession(p);
|
||||
LocalSession session = getPlayerSession(p);
|
||||
if (session != null)
|
||||
{
|
||||
BukkitPlayer bukkitPlayer = this.getBukkitPlayer(p);
|
||||
if (bukkitPlayer != null)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
|
||||
@ -105,16 +99,12 @@ public class TFM_WorldEditBridge
|
||||
{
|
||||
try
|
||||
{
|
||||
WorldEditAPI api = this.getWorldEditAPI();
|
||||
if (api != null)
|
||||
{
|
||||
LocalSession session = api.getSession(p);
|
||||
LocalSession session = getPlayerSession(p);
|
||||
if (session != null)
|
||||
{
|
||||
session.setBlockChangeLimit(limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
|
Loading…
Reference in New Issue
Block a user