2012-01-09 20:00:13 +01:00
|
|
|
package com.gmail.nossr50.commands.general;
|
|
|
|
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandExecutor;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.Users;
|
|
|
|
import com.gmail.nossr50.m;
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
|
import com.gmail.nossr50.mcPermissions;
|
|
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
|
|
import com.gmail.nossr50.locale.mcLocale;
|
|
|
|
import com.gmail.nossr50.skills.Skills;
|
|
|
|
|
|
|
|
public class MmoeditCommand implements CommandExecutor {
|
|
|
|
private final mcMMO plugin;
|
|
|
|
|
|
|
|
public MmoeditCommand(mcMMO instance) {
|
|
|
|
this.plugin = instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
2012-02-11 15:01:46 +01:00
|
|
|
Player player = null;
|
2012-03-06 22:46:04 +01:00
|
|
|
if (sender instanceof Player)
|
|
|
|
{
|
2012-02-11 15:01:46 +01:00
|
|
|
player = (Player) sender;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (player != null && !mcPermissions.getInstance().mmoedit(player)) {
|
2012-01-09 20:00:13 +01:00
|
|
|
sender.sendMessage("This command requires permissions.");
|
|
|
|
return true;
|
|
|
|
}
|
2012-03-06 22:46:04 +01:00
|
|
|
|
|
|
|
PlayerProfile PPt = Users.getOfflineProfile(args[0]);
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-03-06 22:46:04 +01:00
|
|
|
if (!(sender instanceof Player))
|
|
|
|
{
|
|
|
|
if (args.length < 2)
|
|
|
|
{
|
2012-01-31 09:36:07 +01:00
|
|
|
System.out.println("Usage is /mmoedit playername skillname newvalue");
|
2012-01-09 20:00:13 +01:00
|
|
|
return true;
|
2012-03-06 22:46:04 +01:00
|
|
|
} else if (args.length == 3)
|
|
|
|
{
|
|
|
|
if(!PPt.isLoaded())
|
|
|
|
{
|
|
|
|
sender.sendMessage("Player does not exist in the database!");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m.isInt(args[2]) && Skills.isSkill(args[1]))
|
|
|
|
{
|
2012-01-09 20:00:13 +01:00
|
|
|
int newvalue = Integer.valueOf(args[2]);
|
2012-03-06 22:46:04 +01:00
|
|
|
Users.getOfflineProfile(args[0]).modifyskill(Skills.getSkillType(args[1]), newvalue);
|
2012-01-09 20:00:13 +01:00
|
|
|
System.out.println(args[1] + " has been modified for " + plugin.getServer().getPlayer(args[0]).getName() + ".");
|
|
|
|
}
|
2012-03-06 22:46:04 +01:00
|
|
|
} else
|
|
|
|
{
|
2012-01-31 09:36:07 +01:00
|
|
|
System.out.println("Usage is /mmoedit playername skillname newvalue");
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-03-06 22:46:04 +01:00
|
|
|
if (!mcPermissions.getInstance().mmoedit(player))
|
|
|
|
{
|
2012-01-09 20:00:13 +01:00
|
|
|
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
|
|
|
|
return true;
|
|
|
|
}
|
2012-03-06 22:46:04 +01:00
|
|
|
|
|
|
|
if (args.length < 2)
|
|
|
|
{
|
2012-01-31 09:36:07 +01:00
|
|
|
player.sendMessage(ChatColor.RED + "Usage is /mmoedit playername skillname newvalue");
|
2012-01-09 20:00:13 +01:00
|
|
|
return true;
|
|
|
|
}
|
2012-03-06 22:46:04 +01:00
|
|
|
if (args.length == 3)
|
|
|
|
{
|
|
|
|
if(!PPt.isLoaded())
|
|
|
|
{
|
|
|
|
sender.sendMessage("Player does not exist in the database!");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m.isInt(args[2]) && Skills.isSkill(args[1]))
|
|
|
|
{
|
2012-01-09 20:00:13 +01:00
|
|
|
int newvalue = Integer.valueOf(args[2]);
|
2012-03-06 22:46:04 +01:00
|
|
|
Users.getOfflineProfile(args[0]).modifyskill(Skills.getSkillType(args[1]), newvalue);
|
|
|
|
player.sendMessage(ChatColor.RED + args[1] + " has been modified for "+args[0]);
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|
2012-03-06 22:46:04 +01:00
|
|
|
} else if (args.length == 2)
|
|
|
|
{
|
|
|
|
if (m.isInt(args[1]) && Skills.isSkill(args[0]))
|
|
|
|
{
|
|
|
|
PlayerProfile PP = Users.getProfile(player);
|
2012-01-09 20:00:13 +01:00
|
|
|
int newvalue = Integer.valueOf(args[1]);
|
|
|
|
PP.modifyskill(Skills.getSkillType(args[0]), newvalue);
|
|
|
|
player.sendMessage(ChatColor.RED + args[0] + " has been modified.");
|
|
|
|
}
|
2012-03-06 22:46:04 +01:00
|
|
|
} else
|
|
|
|
{
|
2012-01-31 09:36:07 +01:00
|
|
|
player.sendMessage(ChatColor.RED + "Usage is /mmoedit playername skillname newvalue");
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|