summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-05-19 12:42:33 -0700
committerKHobbits <rob@khobbits.co.uk>2012-05-19 12:42:33 -0700
commita52addc72107d3520d4fcd68a78864bbe4eed766 (patch)
tree6e06ac6708ffc92dba1bb85466d48b1ef49f3006
parentbf3c5a02b1da04a54fa5af48db57884f04a03f82 (diff)
parentb18867fa0bbc1c988893746b4735a38382cef7fe (diff)
downloadEssentials-a52addc72107d3520d4fcd68a78864bbe4eed766.tar
Essentials-a52addc72107d3520d4fcd68a78864bbe4eed766.tar.gz
Essentials-a52addc72107d3520d4fcd68a78864bbe4eed766.tar.lz
Essentials-a52addc72107d3520d4fcd68a78864bbe4eed766.tar.xz
Essentials-a52addc72107d3520d4fcd68a78864bbe4eed766.zip
Merge pull request #70 from kukelekuuk00/master
/exp [set|give|player] [player] [amount]
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandexp.java133
-rw-r--r--Essentials/src/messages.properties13
-rw-r--r--Essentials/src/plugin.yml4
3 files changed, 150 insertions, 0 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandexp.java b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java
new file mode 100644
index 000000000..fddcdca09
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java
@@ -0,0 +1,133 @@
+package com.earth2me.essentials.commands;
+
+import static com.earth2me.essentials.I18n._;
+import com.earth2me.essentials.User;
+import com.earth2me.essentials.Util;
+import com.earth2me.essentials.craftbukkit.SetExpFix;
+import org.bukkit.Server;
+import org.bukkit.entity.Player;
+
+public class Commandexp extends EssentialsCommand
+{
+ public Commandexp()
+ {
+ super("exp");
+ }
+
+ @Override
+ public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
+ {
+ if (args.length == 0)
+ {
+ if (user.isAuthorized("essentials.exp"))
+ {
+ int totalexp = SetExpFix.getTotalExperience(user);
+ int expleft = (int)Util.roundDouble(((((3.5 * user.getLevel()) + 6.7) - (totalexp - ((1.75 * (user.getLevel() * user.getLevel())) + (5.00 * user.getLevel())))) + 1));
+ user.sendMessage(_("exp", totalexp, expleft));
+ }
+ }
+ else if (args.length > 0)
+ {
+ if (args[0].equalsIgnoreCase("set"))
+ {
+ if (args.length > 1)
+ {
+ for (Player p : server.matchPlayer(args[1]))
+ {
+ if ((args.length == 3) && (args[1].trim().length() > 2) && (user.isAuthorized("essentials.exp.set.others")))
+ {
+ User player = getPlayer(server, args, 1);
+ int amount = Integer.parseInt(args[2]);
+ SetExpFix.setTotalExperience(p, amount);
+ user.sendMessage(_("expsetothers", player.getDisplayName(), amount));
+ p.sendMessage(_("expsetothersreceive", amount));
+ }
+ }
+ if ((args.length == 2) && (user.isAuthorized("essentials.exp.set")))
+ {
+ int amount = Integer.parseInt(args[1]);
+ SetExpFix.setTotalExperience(user, amount);
+ user.sendMessage(_("expset", amount));
+ }
+ }
+ }
+ if (args[0].equalsIgnoreCase("give"))
+ {
+ if (args.length > 1)
+ {
+ for (Player p : server.matchPlayer(args[1]))
+ {
+ if ((args.length == 3) && (args[1].trim().length() > 2) && (user.isAuthorized("essentials.exp.give.others")))
+ {
+ User player = getPlayer(server, args, 1);
+ int amount = Integer.parseInt(args[2]);
+ p.giveExp(amount);
+ user.sendMessage(_("expgiveothers", player.getDisplayName(), amount));
+ p.sendMessage (_("expgiveothersreceive", amount));
+ }
+ }
+ if ((args.length == 2) && (user.isAuthorized("essentials.exp.give")))
+ {
+ int amount = Integer.parseInt(args[1]);
+ user.giveExp(amount);
+ user.sendMessage(_("expgive", amount));
+ }
+
+ }
+ }
+ if (args[0].equalsIgnoreCase("player"))
+ {
+ if (args.length > 1)
+ {
+ for (Player p : server.matchPlayer(args[1]))
+ {
+ if ((args.length == 2) && (args[1].trim().length() > 2) && (user.isAuthorized("essentials.exp.others")))
+ {
+ User player = getPlayer(server, args, 1);
+ int totalexp = SetExpFix.getTotalExperience(p);
+ int expleft = (int)Util.roundDouble(((((3.5 * p.getLevel()) + 6.7) - (totalexp - ((1.75 * (player.getLevel() * player.getLevel())) + (5.00 * player.getLevel())))) + 1));
+ user.sendMessage(_("expothers", player.getDisplayName(), SetExpFix.getTotalExperience(p), expleft));
+ }
+ }
+ }
+ }
+ if (args[0].equalsIgnoreCase("fix"))
+ {
+ { if ((args.length == 1) && (user.isAuthorized("essentials.exp.fix")))
+ {
+ if (SetExpFix.getTotalExperience(user) < 0)
+ {
+ user.sendMessage(_("expfix"));
+ user.setExp(0);
+ user.setLevel(0);
+ user.setTotalExperience(0);
+ }
+ else if (SetExpFix.getTotalExperience(user) >= 0)
+ {
+ user.sendMessage(_("expfixfalse"));
+ }
+ }
+ else if ((args.length == 2) && (user.isAuthorized("essentials.exp.fix.others")))
+ {
+ for (Player p : server.matchPlayer(args[1]))
+ {
+ if (SetExpFix.getTotalExperience(p) < 0)
+ {
+
+ user.sendMessage(_("expfixothers", p.getDisplayName()));
+ p.setExp(0);
+ p.setLevel(0);
+ p.setTotalExperience(0);
+ p.sendMessage(_("expfixothersreceive"));
+ }
+ else if (SetExpFix.getTotalExperience(p) >= 0)
+ {
+ user.sendMessage(_("expfixothersfalse", p.getDisplayName()));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties
index 11ed0d74b..9c2182c10 100644
--- a/Essentials/src/messages.properties
+++ b/Essentials/src/messages.properties
@@ -85,6 +85,19 @@ errorWithMessage=\u00a7cError: {0}
essentialsHelp1=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, go to http://tiny.cc/EssentialsChat
essentialsHelp2=The file is broken and Essentials can't open it. Essentials is now disabled. If you can't fix the file yourself, either type /essentialshelp in game or go to http://tiny.cc/EssentialsChat
essentialsReload=\u00a77Essentials Reloaded {0}
+exp=\u00a77You have \u00a7c{0} \u00a77exp and you need \u00a7c{1}\u00a77 more exp to level up.
+expfix=\u00a77You have negative exp; fixing it.
+expfixfalse=\u00a77You do not have negative exp.
+expfixothers=\u00a7c{0} \u00a77has negative exp; fixing it.
+expfixothersreceive=\u00a77Your no longer have negative exp.
+expfixothersfalse=\u00a7c{0} \u00a77does not have negative exp.
+expgive=\u00a77You have given yourself \u00a7c{0}\u00a77 exp.
+expgiveothers=\u00a77You have given \u00a7c{0} {1}\u00a77 exp.
+expgiveothersreceive=\u00a77You have received \u00a7c{0}\u00a77 exp.
+expothers=\u00a7c{0}\u00a77 has \u00a7c{1} \u00a77exp and needs \u00a7c{2} \u00a77more exp to level up.
+expset=\u00a77You now have \u00a7c{0} \u00a77exp.
+expsetothers=\u00a7c{0} \u00a77now has \u00a7c{1} \u00a77exp.
+expsetothersreceive=\u00a77You now have \u00a7c{0} \u00a77exp.
extinguish=\u00a77You extinguished yourself.
extinguishOthers=\u00a77You extinguished {0}.
failedToCloseConfig=Failed to close config {0}
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index d9d4179be..10ef00494 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -90,6 +90,10 @@ commands:
essentials:
description: Reloads essentials.
usage: /<command>
+ exp:
+ description: give, set or look at a players exp.
+ usage: /<command> [player|set|give|fix] [playername] [amount]
+ aliases: [eexp]
ext:
description: Extinguish players.
usage: /<command> [player]