mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Got rid of dispatchCommand usage (where possible).
Added TFM_WorldEditBridge.
This commit is contained in:
parent
1d9e6ae931
commit
15fbd0e1f3
@ -1,5 +1,5 @@
|
|||||||
#Tue, 02 Jul 2013 19:01:31 -0400
|
#Wed, 03 Jul 2013 16:10:19 -0400
|
||||||
|
|
||||||
program.VERSION=2.20
|
program.VERSION=2.20
|
||||||
program.BUILDNUM=242
|
program.BUILDNUM=247
|
||||||
program.BUILDDATE=07/02/2013 07\:01 PM
|
program.BUILDDATE=07/03/2013 04\:10 PM
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Tue Jul 02 19:01:31 EDT 2013
|
#Wed Jul 03 16:10:19 EDT 2013
|
||||||
build.number=243
|
build.number=248
|
||||||
|
@ -32,7 +32,8 @@ jar.archive.disabled=${jnlp.enabled}
|
|||||||
jar.compress=false
|
jar.compress=false
|
||||||
jar.index=${jnlp.enabled}
|
jar.index=${jnlp.enabled}
|
||||||
javac.classpath=\
|
javac.classpath=\
|
||||||
${libs.CraftBukkit.classpath}
|
${libs.CraftBukkit.classpath}:\
|
||||||
|
${libs.WorldEdit.classpath}
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
|
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
|
||||||
javac.deprecation=false
|
javac.deprecation=false
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
|
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -34,17 +36,11 @@ public class Command_gtfo extends TFM_Command
|
|||||||
|
|
||||||
TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||||
|
|
||||||
|
|
||||||
// Op Player
|
|
||||||
p.setOp(true);
|
|
||||||
|
|
||||||
// Undo WorldEdits:
|
// Undo WorldEdits:
|
||||||
server.dispatchCommand(p, "/undo 15");
|
TFM_WorldEditBridge.getInstance().undo(p, 15);
|
||||||
|
|
||||||
// rollback
|
// rollback
|
||||||
|
TFM_RollbackManager.rollback(p);
|
||||||
server.dispatchCommand(sender, "rollback " + p.getName());
|
|
||||||
|
|
||||||
|
|
||||||
// deop
|
// deop
|
||||||
p.setOp(false);
|
p.setOp(false);
|
||||||
|
@ -40,7 +40,7 @@ public class Command_invis extends TFM_Command
|
|||||||
players.add(p.getName());
|
players.add(p.getName());
|
||||||
if (smite && !TFM_SuperadminList.isUserSuperadmin(p))
|
if (smite && !TFM_SuperadminList.isUserSuperadmin(p))
|
||||||
{
|
{
|
||||||
server.dispatchCommand(sender, "smite " + p.getName());
|
Command_smite.smite(p);
|
||||||
smites++;
|
smites++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||||
|
import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -12,34 +13,12 @@ public class Command_setl extends TFM_Command
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
//server.dispatchCommand(sender, "wildcard gcmd ? /limit 500"); - Madgeek: No, no, hell no.
|
|
||||||
|
|
||||||
TFM_Util.adminAction(sender.getName(), "Setting everyone's Worldedit block modification limit to 500.", true);
|
TFM_Util.adminAction(sender.getName(), "Setting everyone's Worldedit block modification limit to 500.", true);
|
||||||
|
TFM_WorldEditBridge web = TFM_WorldEditBridge.getInstance();
|
||||||
for (final Player p : server.getOnlinePlayers())
|
for (final Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final boolean isOp = p.isOp();
|
web.setLimit(p, 500);
|
||||||
|
|
||||||
if (!isOp)
|
|
||||||
{
|
|
||||||
p.setOp(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
server.dispatchCommand(p, "/limit 500");
|
|
||||||
|
|
||||||
if (!isOp)
|
|
||||||
{
|
|
||||||
server.getScheduler().runTaskLater(plugin, new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
p.setOp(false);
|
|
||||||
}
|
|
||||||
}, 20L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,13 @@ public class Command_smite extends TFM_Command
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
smite(p);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void smite(final Player p)
|
||||||
|
{
|
||||||
TFM_Util.bcastMsg(p.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
|
TFM_Util.bcastMsg(p.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
|
||||||
|
|
||||||
//Deop
|
//Deop
|
||||||
@ -57,7 +64,5 @@ public class Command_smite extends TFM_Command
|
|||||||
|
|
||||||
//Kill:
|
//Kill:
|
||||||
p.setHealth(0.0);
|
p.setHealth(0.0);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
133
src/me/StevenLawson/TotalFreedomMod/TFM_WorldEditBridge.java
Normal file
133
src/me/StevenLawson/TotalFreedomMod/TFM_WorldEditBridge.java
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
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;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class TFM_WorldEditBridge
|
||||||
|
{
|
||||||
|
private WorldEditPlugin worldEditPlugin = null;
|
||||||
|
private WorldEditAPI worldEditAPI = null;
|
||||||
|
private BukkitServerInterface bukkitServerInterface = null;
|
||||||
|
|
||||||
|
private TFM_WorldEditBridge()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldEditPlugin getWorldEditPlugin()
|
||||||
|
{
|
||||||
|
if (this.worldEditPlugin == null)
|
||||||
|
{
|
||||||
|
Plugin we = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
|
if (we != null)
|
||||||
|
{
|
||||||
|
if (we instanceof WorldEditPlugin)
|
||||||
|
{
|
||||||
|
this.worldEditPlugin = (WorldEditPlugin) we;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
return new BukkitPlayer(wep, bsi, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void undo(Player p, int count)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
WorldEditAPI api = this.getWorldEditAPI();
|
||||||
|
if (api != null)
|
||||||
|
{
|
||||||
|
LocalSession session = api.getSession(p);
|
||||||
|
if (session != null)
|
||||||
|
{
|
||||||
|
BukkitPlayer bukkitPlayer = this.getBukkitPlayer(p);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
TFM_Log.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLimit(Player p, int limit)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
WorldEditAPI api = this.getWorldEditAPI();
|
||||||
|
if (api != null)
|
||||||
|
{
|
||||||
|
LocalSession session = api.getSession(p);
|
||||||
|
if (session != null)
|
||||||
|
{
|
||||||
|
session.setBlockChangeLimit(limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
TFM_Log.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TFM_WorldEditBridge getInstance()
|
||||||
|
{
|
||||||
|
return TFM_WorldEditBridgeHolder.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class TFM_WorldEditBridgeHolder
|
||||||
|
{
|
||||||
|
private static final TFM_WorldEditBridge INSTANCE = new TFM_WorldEditBridge();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user