summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-05-19 21:52:54 +0100
committerKHobbits <rob@khobbits.co.uk>2012-05-19 21:52:54 +0100
commit051af644a7e73c327fc44a182281068f405dde11 (patch)
treeb0a561640cde1e82386d7542cb4345ef3f6ff3fe
parent9b9a6a3148bb0466f9057910515d55d21bf971b9 (diff)
downloadEssentials-051af644a7e73c327fc44a182281068f405dde11.tar
Essentials-051af644a7e73c327fc44a182281068f405dde11.tar.gz
Essentials-051af644a7e73c327fc44a182281068f405dde11.tar.lz
Essentials-051af644a7e73c327fc44a182281068f405dde11.tar.xz
Essentials-051af644a7e73c327fc44a182281068f405dde11.zip
Exp command cleanup
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandexp.java165
-rw-r--r--Essentials/src/messages.properties15
-rw-r--r--Essentials/src/messages_cs.properties4
-rw-r--r--Essentials/src/plugin.yml7
4 files changed, 77 insertions, 114 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandexp.java b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java
index fddcdca09..2ca0ec1b5 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandexp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java
@@ -7,6 +7,7 @@ import com.earth2me.essentials.craftbukkit.SetExpFix;
import org.bukkit.Server;
import org.bukkit.entity.Player;
+
public class Commandexp extends EssentialsCommand
{
public Commandexp()
@@ -14,120 +15,90 @@ public class Commandexp extends EssentialsCommand
super("exp");
}
+ private void showExp(final User user, final User target)
+ {
+ final int totalExp = SetExpFix.getTotalExperience(target);
+ final int expLeft = (int)Util.roundDouble(((((3.5 * target.getLevel()) + 6.7) - (totalExp - ((1.75 * (target.getLevel() * target.getLevel())) + (5.00 * target.getLevel())))) + 1));
+ user.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), expLeft));
+ }
+
+ private void setExp(final User user, final User target, final String strAmount, final boolean give)
+ {
+ Long amount = Long.parseLong(strAmount);
+ if (give)
+ {
+ amount += SetExpFix.getTotalExperience(target);
+ }
+ if (amount > Integer.MAX_VALUE) {
+ amount = (long)Integer.MAX_VALUE;
+ }
+ SetExpFix.setTotalExperience(target, amount.intValue());
+ user.sendMessage(_("expset", target.getDisplayName(), amount));
+ }
+
@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));
- }
+ {
+ showExp(user, user);
+ return;
}
- else if (args.length > 0)
+ if (args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set"))
{
- if (args[0].equalsIgnoreCase("set"))
+ if (args.length == 3)
{
- if (args.length > 1)
+ Boolean foundUser = false;
+ for (Player matchPlayer : server.matchPlayer(args[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));
- }
+ User target = ess.getUser(matchPlayer);
+ setExp(user, target, args[2], false);
+ foundUser = true;
}
- }
- if (args[0].equalsIgnoreCase("give"))
- {
- if (args.length > 1)
+ if (foundUser == false)
{
- 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));
- }
-
+ throw new NoSuchFieldException(_("playerNotFound"));
}
+ return;
}
- if (args[0].equalsIgnoreCase("player"))
+ setExp(user, user, args[1], false);
+ }
+ else if (args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give"))
+ {
+ if (args.length == 3)
{
- if (args.length > 1)
+ Boolean foundUser = false;
+ for (Player matchPlayer : server.matchPlayer(args[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));
- }
- }
+ User target = ess.getUser(matchPlayer);
+ setExp(user, target, args[2], true);
+ foundUser = true;
}
+ if (foundUser == false)
+ {
+ throw new NoSuchFieldException(_("playerNotFound"));
+ }
+ return;
+ }
+ setExp(user, user, args[1], true);
+ }
+ else
+ {
+ String search = args[0].trim();
+ if (args.length == 2)
+ {
+ search = args[1].trim();
}
- if (args[0].equalsIgnoreCase("fix"))
+ if (search.equalsIgnoreCase("show") || !user.isAuthorized("essentials.exp.others"))
{
- { 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()));
- }
- }
- }
- }
+ showExp(user, user);
+ return;
+ }
+ for (Player matchPlayer : server.matchPlayer(search))
+ {
+ User target = ess.getUser(matchPlayer);
+ showExp(user, target);
}
}
- }
+ }
}
diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties
index 9c2182c10..317fe6dc4 100644
--- a/Essentials/src/messages.properties
+++ b/Essentials/src/messages.properties
@@ -85,19 +85,8 @@ 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.
+exp=\u00a7c{0}\u00a77 has \u00a7c{1} \u00a77exp (level {2}) and needs \u00a7c{3} \u00a77more exp to level up.
+expset=\u00a7c{0} \u00a77now has \u00a7c{1} \u00a77exp.
extinguish=\u00a77You extinguished yourself.
extinguishOthers=\u00a77You extinguished {0}.
failedToCloseConfig=Failed to close config {0}
diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties
index 21d1d6e97..7a43b559d 100644
--- a/Essentials/src/messages_cs.properties
+++ b/Essentials/src/messages_cs.properties
@@ -334,7 +334,7 @@ survival=survival
takenFromAccount=\u00a7c{0} bylo odecteno z tveho uctu.
takenFromOthersAccount=\u00a7c{0} bylo odebrano z {1}\u00a7c uctu. Nova hodnota: {2}
teleportAAll=\u00a77Zadost o teleportaci odeslana vsem hracum...
-teleportAll=\u00a77Teleportuji všechny hrace...
+teleportAll=\u00a77Teleportuji v\u00c5\u00a1echny hrace...
teleportAtoB=\u00a77{0}\u00a77 vas teleportoval k {1}\u00a77.
teleportDisabled={0} mas teleportaci zablokovanou.
teleportHereRequest=\u00a7c{0}\u00a7c vas pozadal aby jste se warpnul k nemu.
@@ -424,3 +424,5 @@ year=rok
years=roky
youAreHealed=\u00a77Byl jsi uzdraven.
youHaveNewMail=\u00a7cMas {0} zprav!\u00a7f Napis \u00a77/mail read\u00a7f aby jsi si precetl sve zpravy.
+currentWorld=Current World: {0}
+kickedAll=\u00a7cKicked all players from server
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index 10ef00494..f778ab4dc 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -90,10 +90,11 @@ commands:
essentials:
description: Reloads essentials.
usage: /<command>
+ aliases: [ess]
exp:
- description: give, set or look at a players exp.
- usage: /<command> [player|set|give|fix] [playername] [amount]
- aliases: [eexp]
+ description: Give, set or look at a players exp.
+ usage: /<command> [show|set|give|fix] [playername [amount]]
+ aliases: [eexp,xp]
ext:
description: Extinguish players.
usage: /<command> [player]