mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-18 16:45:37 +01:00
Exp command cleanup
This commit is contained in:
parent
9b9a6a3148
commit
051af644a7
@ -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));
|
||||
}
|
||||
}
|
||||
else if (args.length > 0)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("set"))
|
||||
showExp(user, user);
|
||||
return;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.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;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("fix"))
|
||||
setExp(user, user, args[1], true);
|
||||
}
|
||||
else
|
||||
{
|
||||
String search = args[0].trim();
|
||||
if (args.length == 2)
|
||||
{
|
||||
{ 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
search = args[1].trim();
|
||||
}
|
||||
if (search.equalsIgnoreCase("show") || !user.isAuthorized("essentials.exp.others"))
|
||||
{
|
||||
showExp(user, user);
|
||||
return;
|
||||
}
|
||||
for (Player matchPlayer : server.matchPlayer(search))
|
||||
{
|
||||
User target = ess.getUser(matchPlayer);
|
||||
showExp(user, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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}
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user