mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Exp command cleanup
This commit is contained in:
parent
9b9a6a3148
commit
051af644a7
4 changed files with 78 additions and 115 deletions
|
@ -7,6 +7,7 @@ import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
public class Commandexp extends EssentialsCommand
|
public class Commandexp extends EssentialsCommand
|
||||||
{
|
{
|
||||||
public Commandexp()
|
public Commandexp()
|
||||||
|
@ -14,120 +15,90 @@ public class Commandexp extends EssentialsCommand
|
||||||
super("exp");
|
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
|
@Override
|
||||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
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]))
|
User target = ess.getUser(matchPlayer);
|
||||||
{
|
setExp(user, target, args[2], false);
|
||||||
if ((args.length == 3) && (args[1].trim().length() > 2) && (user.isAuthorized("essentials.exp.set.others")))
|
foundUser = true;
|
||||||
{
|
|
||||||
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 (foundUser == false)
|
||||||
if (args[0].equalsIgnoreCase("give"))
|
|
||||||
{
|
|
||||||
if (args.length > 1)
|
|
||||||
{
|
{
|
||||||
for (Player p : server.matchPlayer(args[1]))
|
throw new NoSuchFieldException(_("playerNotFound"));
|
||||||
{
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
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]))
|
User target = ess.getUser(matchPlayer);
|
||||||
{
|
setExp(user, target, args[2], true);
|
||||||
if ((args.length == 2) && (args[1].trim().length() > 2) && (user.isAuthorized("essentials.exp.others")))
|
foundUser = true;
|
||||||
{
|
|
||||||
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 (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")))
|
search = args[1].trim();
|
||||||
{
|
}
|
||||||
if (SetExpFix.getTotalExperience(user) < 0)
|
if (search.equalsIgnoreCase("show") || !user.isAuthorized("essentials.exp.others"))
|
||||||
{
|
{
|
||||||
user.sendMessage(_("expfix"));
|
showExp(user, user);
|
||||||
user.setExp(0);
|
return;
|
||||||
user.setLevel(0);
|
}
|
||||||
user.setTotalExperience(0);
|
for (Player matchPlayer : server.matchPlayer(search))
|
||||||
}
|
{
|
||||||
else if (SetExpFix.getTotalExperience(user) >= 0)
|
User target = ess.getUser(matchPlayer);
|
||||||
{
|
showExp(user, target);
|
||||||
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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
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
|
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}
|
essentialsReload=\u00a77Essentials Reloaded {0}
|
||||||
exp=\u00a77You have \u00a7c{0} \u00a77exp and you need \u00a7c{1}\u00a77 more exp to level up.
|
exp=\u00a7c{0}\u00a77 has \u00a7c{1} \u00a77exp (level {2}) and needs \u00a7c{3} \u00a77more exp to level up.
|
||||||
expfix=\u00a77You have negative exp; fixing it.
|
expset=\u00a7c{0} \u00a77now has \u00a7c{1} \u00a77exp.
|
||||||
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.
|
extinguish=\u00a77You extinguished yourself.
|
||||||
extinguishOthers=\u00a77You extinguished {0}.
|
extinguishOthers=\u00a77You extinguished {0}.
|
||||||
failedToCloseConfig=Failed to close config {0}
|
failedToCloseConfig=Failed to close config {0}
|
||||||
|
|
|
@ -334,7 +334,7 @@ survival=survival
|
||||||
takenFromAccount=\u00a7c{0} bylo odecteno z tveho uctu.
|
takenFromAccount=\u00a7c{0} bylo odecteno z tveho uctu.
|
||||||
takenFromOthersAccount=\u00a7c{0} bylo odebrano z {1}\u00a7c uctu. Nova hodnota: {2}
|
takenFromOthersAccount=\u00a7c{0} bylo odebrano z {1}\u00a7c uctu. Nova hodnota: {2}
|
||||||
teleportAAll=\u00a77Zadost o teleportaci odeslana vsem hracum...
|
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.
|
teleportAtoB=\u00a77{0}\u00a77 vas teleportoval k {1}\u00a77.
|
||||||
teleportDisabled={0} mas teleportaci zablokovanou.
|
teleportDisabled={0} mas teleportaci zablokovanou.
|
||||||
teleportHereRequest=\u00a7c{0}\u00a7c vas pozadal aby jste se warpnul k nemu.
|
teleportHereRequest=\u00a7c{0}\u00a7c vas pozadal aby jste se warpnul k nemu.
|
||||||
|
@ -424,3 +424,5 @@ year=rok
|
||||||
years=roky
|
years=roky
|
||||||
youAreHealed=\u00a77Byl jsi uzdraven.
|
youAreHealed=\u00a77Byl jsi uzdraven.
|
||||||
youHaveNewMail=\u00a7cMas {0} zprav!\u00a7f Napis \u00a77/mail read\u00a7f aby jsi si precetl sve zpravy.
|
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:
|
essentials:
|
||||||
description: Reloads essentials.
|
description: Reloads essentials.
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
|
aliases: [ess]
|
||||||
exp:
|
exp:
|
||||||
description: give, set or look at a players exp.
|
description: Give, set or look at a players exp.
|
||||||
usage: /<command> [player|set|give|fix] [playername] [amount]
|
usage: /<command> [show|set|give|fix] [playername [amount]]
|
||||||
aliases: [eexp]
|
aliases: [eexp,xp]
|
||||||
ext:
|
ext:
|
||||||
description: Extinguish players.
|
description: Extinguish players.
|
||||||
usage: /<command> [player]
|
usage: /<command> [player]
|
||||||
|
|
Loading…
Reference in a new issue