[v0.0.3] Added /sgc owner <player> command
This commit is contained in:
5
README
5
README
@@ -11,7 +11,7 @@ StargateCommand is an addon for Stargate that adds three very useful commands: i
|
|||||||
=============
|
=============
|
||||||
Dependencies
|
Dependencies
|
||||||
=============
|
=============
|
||||||
Stargate -- http://thedgtl.net/bukkit/
|
Stargate v0.7.8.0 -- http://thedgtl.net/bukkit/
|
||||||
|
|
||||||
=============
|
=============
|
||||||
Permissions
|
Permissions
|
||||||
@@ -74,6 +74,9 @@ If the network is not supplied, the default Stargate network will be used. If th
|
|||||||
=============
|
=============
|
||||||
Changes
|
Changes
|
||||||
=============
|
=============
|
||||||
|
[Version 0.0.3]
|
||||||
|
- Added /sgc owner <player> command
|
||||||
|
- Now requires at least Stargate v0.7.8.0
|
||||||
[Version 0.0.2]
|
[Version 0.0.2]
|
||||||
- Fix an issue with dialing on a specific network
|
- Fix an issue with dialing on a specific network
|
||||||
- Change permission checks to use Stargate, this allows proper permission debugging
|
- Change permission checks to use Stargate, this allows proper permission debugging
|
||||||
|
|||||||
@@ -23,12 +23,23 @@ public class SGCListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
// We want right-click block only
|
// We want right-click block only
|
||||||
if (event.getAction() != org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK) return;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
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);
|
SGCPlayer sPlayer = sgc.players.get(player);
|
||||||
if (sPlayer == null || block == null) return;
|
if (sPlayer == null) return;
|
||||||
if (sPlayer.action == Action.IMPORT) {
|
if (sPlayer.action == Action.IMPORT) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.setUseInteractedBlock(Result.DENY);
|
event.setUseInteractedBlock(Result.DENY);
|
||||||
@@ -77,6 +88,20 @@ public class SGCListener implements Listener {
|
|||||||
sgc.exportGate(player, block);
|
sgc.exportGate(player, block);
|
||||||
sgc.players.remove(player);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -341,6 +341,17 @@ public class StargateCommand extends JavaPlugin {
|
|||||||
} else if (args[0].equalsIgnoreCase("cancel")) {
|
} else if (args[0].equalsIgnoreCase("cancel")) {
|
||||||
players.remove(player);
|
players.remove(player);
|
||||||
StargateCommand.sendMessage(player, "Command cancelled", false);
|
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;
|
return true;
|
||||||
} else if (command.getName().equalsIgnoreCase("dial")) {
|
} else if (command.getName().equalsIgnoreCase("dial")) {
|
||||||
@@ -393,6 +404,7 @@ public class StargateCommand extends JavaPlugin {
|
|||||||
public enum Action {
|
public enum Action {
|
||||||
IMPORT,
|
IMPORT,
|
||||||
EXPORT,
|
EXPORT,
|
||||||
DIAL
|
DIAL,
|
||||||
|
OWNER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,28 @@
|
|||||||
name: StargateCommand
|
name: StargateCommand
|
||||||
main: net.TheDgtl.StargateCommand.StargateCommand
|
main: net.TheDgtl.StargateCommand.StargateCommand
|
||||||
version: 0.0.2
|
version: 0.0.3
|
||||||
description: Command addon for the Stargate plugin for Bukkit
|
description: Command addon for the Stargate plugin for Bukkit
|
||||||
author: Drakia
|
author: Drakia
|
||||||
depend: [Stargate]
|
depend: [Stargate]
|
||||||
website: http://www.thedgtl.net
|
website: http://www.thedgtl.net
|
||||||
commands:
|
commands:
|
||||||
sgc:
|
sgc:
|
||||||
description: StargateCommand import/export commands.
|
description: StargateCommand import/export/owner commands.
|
||||||
usage: |
|
usage: |
|
||||||
/<command> <import/export/cancel> <gate> [force]
|
/<command> <import/export/cancel> <gate> [force]
|
||||||
Type: "/<command> import" for help with import
|
Type: "/<command> import" for help with import
|
||||||
Type: "/<command> export" for help with export
|
Type: "/<command> export" for help with export
|
||||||
Type: "/<command> cancel" to cancel any pending SGC action
|
Type: "/<command> cancel" to cancel any pending SGC action
|
||||||
|
/<command> owner <player>
|
||||||
dial:
|
dial:
|
||||||
description: Dial a stargate
|
description: Dial a stargate
|
||||||
usage: |
|
usage: |
|
||||||
/<command> <destination>
|
/<command> <destination>
|
||||||
/<command> <source> <destination> [network]
|
/<command> <source> <destination> [network]
|
||||||
permissions:
|
permissions:
|
||||||
|
stargate.command.owner:
|
||||||
|
description: Allow the user of /sgc owner
|
||||||
|
default: op
|
||||||
stargate.command.import:
|
stargate.command.import:
|
||||||
description: Allow the use of /sgc import
|
description: Allow the use of /sgc import
|
||||||
default: op
|
default: op
|
||||||
|
|||||||
Reference in New Issue
Block a user