2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2011-11-21 04:31:29 +00:00
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2011-11-21 04:31:29 +00:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
2019-11-21 05:13:56 +00:00
|
|
|
@CommandParameters(description = "Sets your experience level.", usage = "/<command> [level]")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_setlevel extends FreedomCommand
|
2011-11-21 04:31:29 +00:00
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2011-11-21 04:31:29 +00:00
|
|
|
@Override
|
2015-11-22 18:26:47 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2011-11-21 04:31:29 +00:00
|
|
|
{
|
|
|
|
if (args.length != 1)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-24 01:22:52 +00:00
|
|
|
|
2012-03-12 06:26:13 +00:00
|
|
|
int new_level;
|
2011-11-21 04:31:29 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2012-03-12 06:26:13 +00:00
|
|
|
new_level = Integer.parseInt(args[0]);
|
2012-11-24 01:22:52 +00:00
|
|
|
|
2012-03-12 06:26:13 +00:00
|
|
|
if (new_level < 0)
|
2011-11-21 04:31:29 +00:00
|
|
|
{
|
2012-03-12 06:26:13 +00:00
|
|
|
new_level = 0;
|
2011-11-21 04:31:29 +00:00
|
|
|
}
|
2012-03-12 06:26:13 +00:00
|
|
|
else if (new_level > 50)
|
2011-11-21 04:31:29 +00:00
|
|
|
{
|
2012-03-12 06:26:13 +00:00
|
|
|
new_level = 50;
|
2011-11-21 04:31:29 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-14 13:28:19 +00:00
|
|
|
catch (NumberFormatException ex)
|
2011-11-21 04:31:29 +00:00
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("Invalid level.", ChatColor.RED);
|
2011-11-21 04:31:29 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-03-12 06:26:13 +00:00
|
|
|
|
2015-11-22 18:26:47 +00:00
|
|
|
playerSender.setLevel(new_level);
|
2012-11-24 01:22:52 +00:00
|
|
|
|
2016-03-02 19:28:01 +00:00
|
|
|
msg("You have been set to level " + Integer.toString(new_level), ChatColor.AQUA);
|
2012-11-24 01:22:52 +00:00
|
|
|
|
2011-11-21 04:31:29 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|