[v0.0.3] Added /sgc owner <player> command

This commit is contained in:
Steven Scott
2012-09-16 16:31:18 -07:00
parent 11463109fa
commit 7c44e0c9b7
4 changed files with 52 additions and 8 deletions

5
README
View File

@@ -11,7 +11,7 @@ StargateCommand is an addon for Stargate that adds three very useful commands: i
=============
Dependencies
=============
Stargate -- http://thedgtl.net/bukkit/
Stargate v0.7.8.0 -- http://thedgtl.net/bukkit/
=============
Permissions
@@ -74,6 +74,9 @@ If the network is not supplied, the default Stargate network will be used. If th
=============
Changes
=============
[Version 0.0.3]
- Added /sgc owner <player> command
- Now requires at least Stargate v0.7.8.0
[Version 0.0.2]
- Fix an issue with dialing on a specific network
- Change permission checks to use Stargate, this allows proper permission debugging

View File

@@ -23,12 +23,23 @@ public class SGCListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
// We want right-click block only
if (event.getAction() != org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK) return;
Player player = event.getPlayer();
Block block = event.getClickedBlock();
Block block = null;
if (event.isCancelled() && event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_AIR) {
try {
block = player.getTargetBlock(null, 5);
} catch (IllegalStateException ex) {
// We can safely ignore this exception, it only happens in void or max height
return;
}
} else {
block = event.getClickedBlock();
}
if (block == null || block.getType() == Material.AIR) return;
SGCPlayer sPlayer = sgc.players.get(player);
if (sPlayer == null || block == null) return;
if (sPlayer == null) return;
if (sPlayer.action == Action.IMPORT) {
event.setCancelled(true);
event.setUseInteractedBlock(Result.DENY);
@@ -77,6 +88,20 @@ public class SGCListener implements Listener {
sgc.exportGate(player, block);
sgc.players.remove(player);
}
} else if (sPlayer.action == Action.OWNER) {
event.setCancelled(true);
event.setUseInteractedBlock(Result.DENY);
event.setUseItemInHand(Result.DENY);
Portal portal = Portal.getByBlock(block);
if (portal == null) {
StargateCommand.sendMessage(player, "You did not select a gate, exiting", true);
sgc.players.remove(player);
return;
}
portal.setOwner(sPlayer.args[1]);
Portal.saveAllGates(portal.getWorld());
sgc.players.remove(player);
StargateCommand.sendMessage(player, "Owner of " + portal.getName() + " on network " + portal.getNetwork() + " set to " + sPlayer.args[1], false);
}
}

View File

@@ -341,6 +341,17 @@ public class StargateCommand extends JavaPlugin {
} else if (args[0].equalsIgnoreCase("cancel")) {
players.remove(player);
StargateCommand.sendMessage(player, "Command cancelled", false);
} else if (args[0].equalsIgnoreCase("owner")) {
if (!Stargate.hasPerm(player, "stargate.command.owner")) {
StargateCommand.sendMessage(player, "Permission Denied", true);
return true;
}
if (args.length != 2) {
StargateCommand.sendMessage(player, "Usage: /sgc owner <player>", false);
return true;
}
StargateCommand.sendMessage(player, "Please right-click a target gate to assign ownership", false);
players.put(player, new SGCPlayer(player, Action.OWNER, args));
}
return true;
} else if (command.getName().equalsIgnoreCase("dial")) {
@@ -393,6 +404,7 @@ public class StargateCommand extends JavaPlugin {
public enum Action {
IMPORT,
EXPORT,
DIAL
DIAL,
OWNER
}
}

View File

@@ -1,24 +1,28 @@
name: StargateCommand
main: net.TheDgtl.StargateCommand.StargateCommand
version: 0.0.2
version: 0.0.3
description: Command addon for the Stargate plugin for Bukkit
author: Drakia
depend: [Stargate]
website: http://www.thedgtl.net
commands:
sgc:
description: StargateCommand import/export commands.
description: StargateCommand import/export/owner commands.
usage: |
/<command> <import/export/cancel> <gate> [force]
Type: "/<command> import" for help with import
Type: "/<command> export" for help with export
Type: "/<command> cancel" to cancel any pending SGC action
/<command> owner <player>
dial:
description: Dial a stargate
usage: |
/<command> <destination>
/<command> <source> <destination> [network]
permissions:
stargate.command.owner:
description: Allow the user of /sgc owner
default: op
stargate.command.import:
description: Allow the use of /sgc import
default: op