summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-03-11 23:59:59 +0000
committerKHobbits <rob@khobbits.co.uk>2012-03-11 23:59:59 +0000
commit8dcd591beb12bd0bc03f2a3d6092ce1a7654495b (patch)
treeb10de103bf251223e1b2127684fc59ebe0ab2bf1
parenta40c936bcff0a05887d3acc9ab096aaab4b9df2d (diff)
downloadEssentials-8dcd591beb12bd0bc03f2a3d6092ce1a7654495b.tar
Essentials-8dcd591beb12bd0bc03f2a3d6092ce1a7654495b.tar.gz
Essentials-8dcd591beb12bd0bc03f2a3d6092ce1a7654495b.tar.lz
Essentials-8dcd591beb12bd0bc03f2a3d6092ce1a7654495b.tar.xz
Essentials-8dcd591beb12bd0bc03f2a3d6092ce1a7654495b.zip
Update setworth to allow /setworth <price> ingame
Allow /setworth to be used from console.
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java29
-rw-r--r--Essentials/src/plugin.yml2
2 files changed, 29 insertions, 2 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java
index 1d236b70a..734d9244d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import org.bukkit.Server;
+import org.bukkit.command.CommandSender;
import org.bukkit.inventory.ItemStack;
@@ -21,8 +22,34 @@ public class Commandsetworth extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
+ ItemStack stack;
+ String price;
+
+ if (args.length == 1)
+ {
+ stack = user.getInventory().getItemInHand();
+ price = args[0];
+ }
+ else
+ {
+ stack = ess.getItemDb().get(args[0]);
+ price = args[1];
+ }
+
+ ess.getWorth().setPrice(stack, Double.parseDouble(price));
+ user.sendMessage(_("worthSet"));
+ }
+
+ @Override
+ public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
+ {
+ if (args.length < 2)
+ {
+ throw new NotEnoughArgumentsException();
+ }
+
ItemStack stack = ess.getItemDb().get(args[0]);
ess.getWorth().setPrice(stack, Double.parseDouble(args[1]));
- user.sendMessage(_("worthSet"));
+ sender.sendMessage(_("worthSet"));
}
}
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index 714abde4b..27541d782 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -295,7 +295,7 @@ commands:
aliases: [createwarp,esetwarp]
setworth:
description: Set the sell value of an item.
- usage: /<command> <itemname|id> <price>
+ usage: /<command> [itemname|id] <price>
aliases: [esetworth]
socialspy:
description: Toggles if you can see msg/mail commands in chat.