summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorementalo <suror@gmx.co.uk>2011-12-07 01:13:08 +0000
committerementalo <suror@gmx.co.uk>2011-12-07 01:13:08 +0000
commit9ca0e51dacab71fd0664246720bd36f96b365304 (patch)
treea659f90d3f506e020870df8549bd41b1ad6cf9e2
parent10597cec2f3f70628e753616ff5371f65fa39f5f (diff)
parentb49a9ef1654146ef056cec93c2d6964b04fc9bf2 (diff)
downloadEssentials-9ca0e51dacab71fd0664246720bd36f96b365304.tar
Essentials-9ca0e51dacab71fd0664246720bd36f96b365304.tar.gz
Essentials-9ca0e51dacab71fd0664246720bd36f96b365304.tar.lz
Essentials-9ca0e51dacab71fd0664246720bd36f96b365304.tar.xz
Essentials-9ca0e51dacab71fd0664246720bd36f96b365304.zip
Merge branch 'master' of github.com:essentials/Essentials
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java37
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandlightning.java23
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandmail.java36
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandnick.java23
-rw-r--r--Essentials/src/plugin.yml6
5 files changed, 122 insertions, 3 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java b/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java
new file mode 100644
index 000000000..2fff20e8c
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java
@@ -0,0 +1,37 @@
+package com.earth2me.essentials.commands;
+
+import org.bukkit.Server;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+
+
+public class Commanditemdb extends EssentialsCommand
+{
+ public Commanditemdb()
+ {
+ super("find");
+ }
+
+ @Override
+ protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
+ {
+ ItemStack itemStack = null;
+ if (args.length < 1)
+ {
+ if (sender instanceof Player)
+ {
+ itemStack = ((Player)sender).getItemInHand();
+ }
+ if (itemStack == null)
+ {
+ throw new NotEnoughArgumentsException();
+ }
+ }
+ else
+ {
+ itemStack = ess.getItemDb().get(args[0]);
+ }
+ sender.sendMessage(itemStack.getType().toString() + "- " + itemStack.getTypeId() + ":" + Integer.toString(itemStack.getData().getData()));
+ }
+}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java b/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java
index 582f048a1..be9ac61f5 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java
@@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
+import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.Player;
@@ -34,10 +35,30 @@ public class Commandlightning extends EssentialsCommand
throw new Exception(_("playerNotFound"));
}
+ int power = 1;
+ if (args.length > 1)
+ {
+ try
+ {
+ power = Integer.parseInt(args[1]);
+ }
+ catch (NumberFormatException ex)
+ {
+ }
+ }
+
for (Player matchPlayer : server.matchPlayer(args[0]))
{
sender.sendMessage(_("lightningUse", matchPlayer.getDisplayName()));
- matchPlayer.getWorld().strikeLightning(matchPlayer.getLocation());
+ if (power <= 0)
+ {
+ matchPlayer.getWorld().strikeLightningEffect(matchPlayer.getLocation());
+ }
+ else
+ {
+ LightningStrike strike = matchPlayer.getWorld().strikeLightning(matchPlayer.getLocation());
+ matchPlayer.damage(power - 1, strike);
+ }
if (!ess.getUser(matchPlayer).isGodModeEnabled())
{
matchPlayer.setHealth(matchPlayer.getHealth() < 5 ? 0 : matchPlayer.getHealth() - 5);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
index d02e5a13a..8a2787d82 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
@@ -63,6 +63,14 @@ public class Commandmail extends EssentialsCommand
user.sendMessage(_("mailSent"));
return;
}
+ if (args.length >= 1 && "sendall".equalsIgnoreCase(args[0]))
+ {
+ if (!user.isAuthorized("essentials.mail.sendall"))
+ {
+ throw new Exception(_("noMailSendPerm"));
+ }
+ ess.scheduleAsyncDelayedTask(new SendAll(ChatColor.stripColor(user.getDisplayName()) + ": " + getFinalArg(args, 2)));
+ }
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
{
user.setMails(null);
@@ -103,6 +111,10 @@ public class Commandmail extends EssentialsCommand
sender.sendMessage(_("mailSent"));
return;
}
+ else if (args.length >= 1 && "sendall".equalsIgnoreCase(args[0]))
+ {
+ ess.scheduleAsyncDelayedTask(new SendAll("Server: " + getFinalArg(args, 2)));
+ }
else if (args.length >= 2)
{
//allow sending from console without "send" argument, since it's the only thing the console can do
@@ -126,4 +138,28 @@ public class Commandmail extends EssentialsCommand
}
throw new NotEnoughArgumentsException();
}
+
+
+ private class SendAll implements Runnable
+ {
+ String message;
+
+ public SendAll(String message)
+ {
+ this.message = message;
+ }
+
+ @Override
+ public void run()
+ {
+ for (String username : ess.getUserMap().getAllUniqueUsers())
+ {
+ User user = ess.getUserMap().getUser(username);
+ if (user != null)
+ {
+ user.addMail(message);
+ }
+ }
+ }
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
index a1f1c77ca..95ad5ea84 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
@@ -50,7 +50,14 @@ public class Commandnick extends EssentialsCommand
{
throw new Exception(_("nickDisplayName"));
}
- setNickname(server, getPlayer(server, args, 0), formatNickname(null, args[1]));
+ if ((args[0].equalsIgnoreCase("*") || args[0].equalsIgnoreCase("all")) && args[1].equalsIgnoreCase("off"))
+ {
+ resetAllNicknames(server);
+ }
+ else
+ {
+ setNickname(server, getPlayer(server, args, 0), formatNickname(null, args[1]));
+ }
sender.sendMessage(_("nickChanged"));
}
@@ -63,6 +70,20 @@ public class Commandnick extends EssentialsCommand
return nick;
}
+ private void resetAllNicknames(final Server server)
+ {
+ for (Player player : server.getOnlinePlayers())
+ {
+ try
+ {
+ setNickname(server, ess.getUser(player), "off");
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+ }
+
private void setNickname(final Server server, final User target, final String nick) throws Exception
{
if (nick.matches("[^a-zA-Z_0-9]"))
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index e6bf865b7..ac1ced96e 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -102,6 +102,10 @@ commands:
description: Satisfy the hunger.
usage: /<command> [player]
aliases: [efeed]
+ itemdb:
+ description: Searches for an item.
+ usage: /<command> <item>
+ aliases: [eitemdb]
fireball:
description: Throw a fireball.
usage: /<command> [small]
@@ -188,7 +192,7 @@ commands:
aliases: [playerlist,who,online,elist,ewho,eplayerlist,eonline]
lightning:
description: The power of Thor. Strike at cursor or player.
- usage: /<command> [player]
+ usage: /<command> [player] [power]
aliases: [strike,smite,thor,shock,elightning,estrike,esmite,ethor,eshock]
mail:
description: Manages inter-player, intra-server mail.