mirror of
https://github.com/essentials/Essentials.git
synced 2025-02-24 16:32:35 +01:00
Merge branch 'master' of github.com:essentials/Essentials
This commit is contained in:
commit
64db184e7d
@ -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()));
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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]"))
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user