From e36210b99a4aadaf9174fad5d8a5ab0c242190e9 Mon Sep 17 00:00:00 2001 From: Eric Stokes Date: Sat, 13 Aug 2011 14:58:43 -0600 Subject: [PATCH] Add spout tests --- pom.xml | 12 +++- .../MultiverseCore/MultiverseCore.java | 12 ++++ .../MultiverseCore/commands/CoordCommand.java | 1 - .../MultiverseCore/commands/SpoutCommand.java | 58 +++++++++++++++++++ .../listeners/MVPluginListener.java | 5 ++ 5 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/onarandombox/MultiverseCore/commands/SpoutCommand.java diff --git a/pom.xml b/pom.xml index 2f3cd96f..920017ac 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,10 @@ OnARandomBox http://repo.onarandombox.com/artifactory/repo + + GetSpout + http://repo.getspout.org/ + @@ -99,7 +103,13 @@ compile - + + + org.getspout + spoutapi + dev-SNAPSHOT + + cosine.boseconomy diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index db867c19..0f98fb9e 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -29,6 +29,7 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.config.Configuration; +import org.getspout.spoutapi.SpoutManager; import com.fernferret.allpay.AllPay; import com.fernferret.allpay.GenericBank; @@ -52,6 +53,7 @@ import com.onarandombox.MultiverseCore.commands.RemoveCommand; import com.onarandombox.MultiverseCore.commands.SetSpawnCommand; import com.onarandombox.MultiverseCore.commands.SleepCommand; import com.onarandombox.MultiverseCore.commands.SpawnCommand; +import com.onarandombox.MultiverseCore.commands.SpoutCommand; import com.onarandombox.MultiverseCore.commands.TeleportCommand; import com.onarandombox.MultiverseCore.commands.UnloadCommand; import com.onarandombox.MultiverseCore.commands.VersionCommand; @@ -115,6 +117,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { protected MVConfigMigrator migrator = new MVCoreConfigMigrator(this); protected int pluginCount; private DestinationFactory destFactory; + private SpoutManager spoutManager; @Override public void onLoad() { @@ -266,6 +269,7 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { // Misc Commands this.commandHandler.registerCommand(new EnvironmentCommand(this)); this.commandHandler.registerCommand(new SleepCommand(this)); + this.commandHandler.registerCommand(new SpoutCommand(this)); } @@ -814,4 +818,12 @@ public class MultiverseCore extends JavaPlugin implements LoggablePlugin { this.log(Level.SEVERE, e.getMessage()); } } + + public void setSpout(SpoutManager spoutManager) { + this.spoutManager = spoutManager; + } + + public SpoutManager getSpout() { + return this.spoutManager; + } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CoordCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CoordCommand.java index 300e4a3f..48d6619d 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/CoordCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CoordCommand.java @@ -42,7 +42,6 @@ public class CoordCommand extends MultiverseCommand { } MVWorld mvworld = this.plugin.getMVWorld(world.getName()); - // TODO: Convert to fancy stuff p.sendMessage(ChatColor.AQUA + "--- Location Information ---"); p.sendMessage(ChatColor.AQUA + "World: " + ChatColor.WHITE + world.getName()); diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/SpoutCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/SpoutCommand.java new file mode 100644 index 00000000..ae5e8fb3 --- /dev/null +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/SpoutCommand.java @@ -0,0 +1,58 @@ +package com.onarandombox.MultiverseCore.commands; + +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.permissions.PermissionDefault; +import org.getspout.spoutapi.SpoutManager; +import org.getspout.spoutapi.gui.GenericButton; +import org.getspout.spoutapi.gui.GenericPopup; +import org.getspout.spoutapi.gui.InGameHUD; +import org.getspout.spoutapi.gui.InGameScreen; +import org.getspout.spoutapi.gui.ItemWidget; +import org.getspout.spoutapi.gui.PopupScreen; +import org.getspout.spoutapi.player.SpoutPlayer; + +import com.onarandombox.MultiverseCore.MultiverseCore; + +public class SpoutCommand extends MultiverseCommand { + + public SpoutCommand(MultiverseCore plugin) { + super(plugin); + this.setName("Edit World with Spout"); + this.setCommandUsage("/mv spout"); + this.setArgRange(0, 0); + this.addKey("mv spout"); + this.setPermission("multiverse.core.spout", "Edit a world with spout.", PermissionDefault.OP); + this.addCommandExample("/mv spout"); + } + + @Override + public void runCommand(CommandSender sender, List args) { + if (!(sender instanceof Player)) { + sender.sendMessage(ChatColor.RED + "This command must be run as a player!"); + return; + } + if (plugin.getSpout() == null) { + sender.sendMessage(ChatColor.RED + "You need spout installed on this server to use it with Multiverse!"); + return; + } + SpoutPlayer p = (SpoutPlayer) sender; + if (!p.isSpoutCraftEnabled()) { + + sender.sendMessage(ChatColor.RED + p.getName() + "You need to be using the Spoutcraft client to run this command!"); + return; + } + PopupScreen pop = new GenericPopup(); + GenericButton button = new GenericButton("Fish"); + button.setX(50); + button.setY(50); + button.setWidth(100); + button.setHeight(40); + pop.attachWidget(this.plugin, button); + sender.sendMessage(ChatColor.GREEN + "YAY!"); + p.getMainScreen().attachPopupScreen(pop); + } +} diff --git a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPluginListener.java b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPluginListener.java index 1e9ce2a6..ad80a481 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPluginListener.java +++ b/src/main/java/com/onarandombox/MultiverseCore/listeners/MVPluginListener.java @@ -6,6 +6,7 @@ import java.util.logging.Level; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.ServerListener; +import org.getspout.spoutapi.SpoutManager; import com.fernferret.allpay.AllPay; import com.nijikokun.bukkit.Permissions.Permissions; @@ -41,6 +42,10 @@ public class MVPluginListener extends ServerListener { this.plugin.log(Level.WARNING, "I just disabled the old version of Multiverse for you. You should remove the JAR now, your configs have been migrated."); } } + if (event.getPlugin().getDescription().getName().equals("Spout")) { + this.plugin.setSpout(SpoutManager.getInstance()); + this.plugin.log(Level.INFO, "Spout integration enabled."); + } } /**