From e42be555b1acf03df7200cc58075ec899e8b8565 Mon Sep 17 00:00:00 2001 From: sk89q Date: Thu, 25 Nov 2010 02:37:50 -0800 Subject: [PATCH] Fixed spelling error in /god and allowed use of /god on others. --- src/WorldGuardListener.java | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/WorldGuardListener.java b/src/WorldGuardListener.java index ed6f5d85..aa29e443 100644 --- a/src/WorldGuardListener.java +++ b/src/WorldGuardListener.java @@ -307,12 +307,36 @@ public boolean onCommand(Player player, String[] split) { return true; } else if (split[0].equalsIgnoreCase("/god") && player.canUseCommand("/god")) { - if (!invinciblePlayers.contains(player.getName())) { - invinciblePlayers.add(player.getName()); - player.sendMessage(Colors.Yellow + "You are now invicible!"); + // Allow setting other people invincible + if (split.length > 1) { + if (!player.canUseCommand("/godother")) { + player.sendMessage(Colors.Rose + "You don't have permission to make others invincible."); + return true; + } + + Player other = etc.getServer().matchPlayer(split[1]); + if (other == null) { + player.sendMessage(Colors.Rose + "Player not found."); + } else { + if (!invinciblePlayers.contains(other.getName())) { + invinciblePlayers.add(other.getName()); + player.sendMessage(Colors.Yellow + other.getName() + " is now invincible!"); + other.sendMessage(Colors.Yellow + player.getName() + " has made you invincible!"); + } else { + invinciblePlayers.remove(other.getName()); + player.sendMessage(Colors.Yellow + other.getName() + " is no longer invincible."); + other.sendMessage(Colors.Yellow + player.getName() + " has taken away your invincibility."); + } + } + // Invincibility for one's self } else { - invinciblePlayers.remove(player.getName()); - player.sendMessage(Colors.Yellow + "You are no longer invicible."); + if (!invinciblePlayers.contains(player.getName())) { + invinciblePlayers.add(player.getName()); + player.sendMessage(Colors.Yellow + "You are now invincible!"); + } else { + invinciblePlayers.remove(player.getName()); + player.sendMessage(Colors.Yellow + "You are no longer invincible."); + } } return true; }