mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-18 16:45:37 +01:00
Fixes made, added /exp fix [playername] this fixes negative exp.
This commit is contained in:
parent
9846362836
commit
853d7cb668
@ -5,7 +5,6 @@ import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Commandexp extends EssentialsCommand
|
||||
@ -16,70 +15,119 @@ public class Commandexp extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, 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
|
||||
{
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(onlinePlayer);
|
||||
if (args.length == 0)
|
||||
{
|
||||
if (user.isAuthorized("essentials.exp"))
|
||||
{
|
||||
if (args.length < 1 && 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));
|
||||
sender.sendMessage(_("exp", SetExpFix.getTotalExperience(user), expleft));
|
||||
}
|
||||
if (args.length == 1 && user.isAuthorized("essentials.exp.others"))
|
||||
{
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
User player = getPlayer(server, args, 1);
|
||||
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));
|
||||
sender.sendMessage(_("expothers", player.getDisplayName(), SetExpFix.getTotalExperience(p), expleft));
|
||||
}
|
||||
}
|
||||
if(args.length >= 1)
|
||||
if (args[0].equalsIgnoreCase("set"))
|
||||
{
|
||||
if (args.length >= 2)
|
||||
for (Player p : server.matchPlayer(args[1]))
|
||||
if ((args.length == 3) && (user.isAuthorized("essentials.exp.set.others")))
|
||||
{
|
||||
User player = getPlayer(server, args, 1);
|
||||
int exp = Integer.parseInt(args[2]);
|
||||
SetExpFix.setTotalExperience(p, exp);
|
||||
sender.sendMessage(_("expsetothers", player.getDisplayName(), exp));
|
||||
}
|
||||
else if ((args.length == 2) && (user.isAuthorized("essentials.exp.set")))
|
||||
{
|
||||
int exp = Integer.parseInt(args[1]);
|
||||
SetExpFix.setTotalExperience(user, exp);
|
||||
sender.sendMessage(_("expset", exp));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("give"))
|
||||
{
|
||||
if (args.length >= 2)
|
||||
for (Player p : server.matchPlayer(args[1]))
|
||||
if ((args.length == 3) && (user.isAuthorized("essentials.exp.give.others")))
|
||||
{
|
||||
User player = getPlayer(server, args, 1);
|
||||
int amount = Integer.parseInt(args[2]);
|
||||
p.giveExp(amount);
|
||||
sender.sendMessage(_("expgiveothers", player.getDisplayName(), amount));
|
||||
}
|
||||
else if ((args.length == 2) && (user.isAuthorized("essentials.exp.give")))
|
||||
{
|
||||
int amount = Integer.parseInt(args[1]);
|
||||
user.giveExp(amount);
|
||||
sender.sendMessage(_("expgive", amount));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -86,11 +86,18 @@ essentialsHelp1=The file is broken and Essentials can't open it. Essentials is n
|
||||
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.
|
||||
expgive=\u00a77You have given yourself {0}\u00a77 exp.
|
||||
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}
|
||||
|
@ -92,7 +92,7 @@ commands:
|
||||
usage: /<command>
|
||||
exp:
|
||||
description: give, set or look at a players exp.
|
||||
usage: /<command> [player|set|give] [playername] [amount]
|
||||
usage: /<command> [player|set|give|fix] [playername] [amount]
|
||||
aliases: [eexp]
|
||||
ext:
|
||||
description: Extinguish players.
|
||||
|
Loading…
Reference in New Issue
Block a user