diff --git a/Changelog.txt b/Changelog.txt index 9ea3cd6e8..b5ec10c41 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -17,6 +17,7 @@ Version 1.3.00-dev + Added Blast Mining subskills to Mining + Added Fast Food Service subskill to Taming + Added size limit to Tree Feller in config as Tree Feller Threshold + + Added /addlevels command + Re-added mcMMO reporting damage events = Fixed bug where Swords command showed Bleed Length twice instead of Bleed Chance = Fixed bug where Tree Feller wasn't checking for Tree Feller permission diff --git a/src/main/java/com/gmail/nossr50/commands/general/AddlevelsCommand.java b/src/main/java/com/gmail/nossr50/commands/general/AddlevelsCommand.java new file mode 100644 index 000000000..398c692c7 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/commands/general/AddlevelsCommand.java @@ -0,0 +1,87 @@ +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.config.LoadProperties; +import com.gmail.nossr50.datatypes.PlayerProfile; +import com.gmail.nossr50.locale.mcLocale; +import com.gmail.nossr50.skills.Skills; + +public class AddlevelsCommand implements CommandExecutor{ + private final mcMMO plugin; + + public AddlevelsCommand(mcMMO instance) { + this.plugin = instance; + } + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + Player player = null; + if (sender instanceof Player) { + player = (Player) sender; + } + + if (player != null && !mcPermissions.getInstance().mmoedit(player)) { + sender.sendMessage("This command requires permissions."); + return true; + } + + if (!LoadProperties.addlevelsEnable) { + sender.sendMessage("This command is not enabled."); + return true; + } + + if (!(sender instanceof Player)) { + if (args.length < 2) { + System.out.println("Usage is /addlevels playername skillname levels"); + return true; + } else if (args.length == 3) { + if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) { + int levels = Integer.valueOf(args[2]); + Users.getProfile(plugin.getServer().getPlayer(args[0])).addLevels(Skills.getSkillType(args[1]), levels); + System.out.println(args[1] + " has been modified for " + plugin.getServer().getPlayer(args[0]).getName() + "."); + } + } else { + System.out.println("Usage is /addlevels playername skillname levels"); + } + + return true; + } + + PlayerProfile PP = Users.getProfile(player); + + if (!mcPermissions.getInstance().mmoedit(player)) { + player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); + return true; + } + if (args.length < 2) { + player.sendMessage(ChatColor.RED + "Usage is /addlevels playername skillname levels"); + return true; + } + if (args.length == 3) { + if ((plugin.getServer().getPlayer(args[0]) != null) && m.isInt(args[2]) && Skills.isSkill(args[1])) { + int levels = Integer.valueOf(args[2]); + Users.getProfile(plugin.getServer().getPlayer(args[0])).addLevels(Skills.getSkillType(args[1]), levels); + player.sendMessage(ChatColor.RED + args[1] + " has been modified."); + } + } else if (args.length == 2) { + if (m.isInt(args[1]) && Skills.isSkill(args[0])) { + int levels = Integer.valueOf(args[1]); + PP.addLevels(Skills.getSkillType(args[0]), levels); + player.sendMessage(ChatColor.RED + args[0] + " has been modified."); + } + } else { + player.sendMessage(ChatColor.RED + "Usage is /addlevels playername skillname newvalue"); + } + + return true; + } +} diff --git a/src/main/java/com/gmail/nossr50/config/LoadProperties.java b/src/main/java/com/gmail/nossr50/config/LoadProperties.java index 6fd1471ea..f728cd7f9 100644 --- a/src/main/java/com/gmail/nossr50/config/LoadProperties.java +++ b/src/main/java/com/gmail/nossr50/config/LoadProperties.java @@ -44,7 +44,7 @@ public class LoadProperties { mccEnable, mcmmoEnable, partyEnable, inviteEnable, acceptEnable, whoisEnable, mcstatsEnable, addxpEnable, ptpEnable, mmoeditEnable, clearmyspawnEnable, mcgodEnable, mcabilityEnable, mctopEnable, - mcrefreshEnable, aEnable, pEnable, enableMotd, enableMySpawn, + addlevelsEnable, mcrefreshEnable, aEnable, pEnable, enableMotd, enableMySpawn, enableCobbleToMossy, useMySQL, toolsLoseDurabilityFromAbilities, pvpxp, miningrequirespickaxe, excavationRequiresShovel, woodcuttingrequiresaxe, anvilmessages, mayDowngradeEnchants, @@ -400,6 +400,7 @@ public class LoadProperties { xprateEnable = readBoolean("Commands.xprate.Enabled", true); mctopEnable = readBoolean("Commands.mctop.Enabled", true); addxpEnable = readBoolean("Commands.addxp.Enabled", true); + addlevelsEnable = readBoolean("Commands.addlevels.Enabled", true); mcabilityEnable = readBoolean("Commands.mcability.Enabled", true); mcrefreshEnable = readBoolean("Commands.mcrefresh.Enabled", true); mcmmoEnable = readBoolean("Commands.mcmmo.Enabled", true); diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index 97c2f7d98..f3d3c9c81 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -1069,9 +1069,45 @@ public class PlayerProfile skillsXp.put(SkillType.FISHING, 0); } else { skills.put(skillType, newvalue); - skillsXp.put(skillType, newvalue); + skillsXp.put(skillType, 0); } } + + public void addLevels(SkillType skillType, int levels) + { + if(skillType == SkillType.ALL) + { + skills.put(SkillType.TAMING, skills.get(SkillType.TAMING)+levels); + skills.put(SkillType.MINING, skills.get(SkillType.MINING)+levels); + skills.put(SkillType.WOODCUTTING, skills.get(SkillType.WOODCUTTING)+levels); + skills.put(SkillType.REPAIR, skills.get(SkillType.REPAIR)+levels); + skills.put(SkillType.HERBALISM, skills.get(SkillType.HERBALISM)+levels); + skills.put(SkillType.ACROBATICS, skills.get(SkillType.ACROBATICS)+levels); + skills.put(SkillType.SWORDS, skills.get(SkillType.SWORDS)+levels); + skills.put(SkillType.ARCHERY, skills.get(SkillType.ARCHERY)+levels); + skills.put(SkillType.UNARMED, skills.get(SkillType.UNARMED)+levels); + skills.put(SkillType.EXCAVATION, skills.get(SkillType.EXCAVATION)+levels); + skills.put(SkillType.AXES, skills.get(SkillType.AXES)+levels); + skills.put(SkillType.FISHING, skills.get(SkillType.FISHING)+levels); + + skillsXp.put(SkillType.TAMING, 0); + skillsXp.put(SkillType.MINING, 0); + skillsXp.put(SkillType.WOODCUTTING, 0); + skillsXp.put(SkillType.REPAIR, 0); + skillsXp.put(SkillType.HERBALISM, 0); + skillsXp.put(SkillType.ACROBATICS, 0); + skillsXp.put(SkillType.SWORDS, 0); + skillsXp.put(SkillType.ARCHERY, 0); + skillsXp.put(SkillType.UNARMED, 0); + skillsXp.put(SkillType.EXCAVATION, 0); + skillsXp.put(SkillType.AXES, 0); + skillsXp.put(SkillType.FISHING, 0); + } else { + skills.put(skillType, skills.get(skillType)+levels); + skillsXp.put(skillType, 0); + } + } + public Integer getXpToLevel(SkillType skillType) { return (int) ((1020+(skills.get(skillType) * 20))); diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 60014c549..7ae4b3959 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -313,6 +313,7 @@ public class mcMMO extends JavaPlugin //Other commands if(LoadProperties.addxpEnable) getCommand("addxp").setExecutor(new AddxpCommand(this)); + if(LoadProperties.addlevelsEnable) getCommand("addlevels").setExecutor(new AddlevelsCommand(this)); if(LoadProperties.clearmyspawnEnable) getCommand("clearmyspawn").setExecutor(new ClearmyspawnCommand()); if(LoadProperties.mmoeditEnable) getCommand("mmoedit").setExecutor(new MmoeditCommand(this)); getCommand("mmoupdate").setExecutor(new MmoupdateCommand()); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 5f3c2834e..64a260c66 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1134,6 +1134,8 @@ Commands: Enabled: true addxp: Enabled: true + addlevels: + Enabled: true clearmyspawn: Enabled: true ptp: diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7f8531ebb..20bf18c39 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -24,6 +24,9 @@ commands: addxp: description: Add XP to a user permission: mcmmo.tools.mmoedit + addlevels: + description: Add levels to a user + permission: mcmmo.tools.mmoedit mcability: description: Toggle whether or not abilities get readied on right click permission: mcmmo.commands.ability