mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 16:46:46 +01:00
Added /addlevels command (Implements MCCORE-23)
This commit is contained in:
parent
73f1c08366
commit
649bccb0d0
@ -17,6 +17,7 @@ Version 1.3.00-dev
|
|||||||
+ Added Blast Mining subskills to Mining
|
+ Added Blast Mining subskills to Mining
|
||||||
+ Added Fast Food Service subskill to Taming
|
+ Added Fast Food Service subskill to Taming
|
||||||
+ Added size limit to Tree Feller in config as Tree Feller Threshold
|
+ Added size limit to Tree Feller in config as Tree Feller Threshold
|
||||||
|
+ Added /addlevels command
|
||||||
+ Re-added mcMMO reporting damage events
|
+ Re-added mcMMO reporting damage events
|
||||||
= Fixed bug where Swords command showed Bleed Length twice instead of Bleed Chance
|
= 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
|
= Fixed bug where Tree Feller wasn't checking for Tree Feller permission
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -44,7 +44,7 @@ public class LoadProperties {
|
|||||||
mccEnable, mcmmoEnable, partyEnable, inviteEnable, acceptEnable,
|
mccEnable, mcmmoEnable, partyEnable, inviteEnable, acceptEnable,
|
||||||
whoisEnable, mcstatsEnable, addxpEnable, ptpEnable, mmoeditEnable,
|
whoisEnable, mcstatsEnable, addxpEnable, ptpEnable, mmoeditEnable,
|
||||||
clearmyspawnEnable, mcgodEnable, mcabilityEnable, mctopEnable,
|
clearmyspawnEnable, mcgodEnable, mcabilityEnable, mctopEnable,
|
||||||
mcrefreshEnable, aEnable, pEnable, enableMotd, enableMySpawn,
|
addlevelsEnable, mcrefreshEnable, aEnable, pEnable, enableMotd, enableMySpawn,
|
||||||
enableCobbleToMossy, useMySQL, toolsLoseDurabilityFromAbilities,
|
enableCobbleToMossy, useMySQL, toolsLoseDurabilityFromAbilities,
|
||||||
pvpxp, miningrequirespickaxe, excavationRequiresShovel,
|
pvpxp, miningrequirespickaxe, excavationRequiresShovel,
|
||||||
woodcuttingrequiresaxe, anvilmessages, mayDowngradeEnchants,
|
woodcuttingrequiresaxe, anvilmessages, mayDowngradeEnchants,
|
||||||
@ -400,6 +400,7 @@ public class LoadProperties {
|
|||||||
xprateEnable = readBoolean("Commands.xprate.Enabled", true);
|
xprateEnable = readBoolean("Commands.xprate.Enabled", true);
|
||||||
mctopEnable = readBoolean("Commands.mctop.Enabled", true);
|
mctopEnable = readBoolean("Commands.mctop.Enabled", true);
|
||||||
addxpEnable = readBoolean("Commands.addxp.Enabled", true);
|
addxpEnable = readBoolean("Commands.addxp.Enabled", true);
|
||||||
|
addlevelsEnable = readBoolean("Commands.addlevels.Enabled", true);
|
||||||
mcabilityEnable = readBoolean("Commands.mcability.Enabled", true);
|
mcabilityEnable = readBoolean("Commands.mcability.Enabled", true);
|
||||||
mcrefreshEnable = readBoolean("Commands.mcrefresh.Enabled", true);
|
mcrefreshEnable = readBoolean("Commands.mcrefresh.Enabled", true);
|
||||||
mcmmoEnable = readBoolean("Commands.mcmmo.Enabled", true);
|
mcmmoEnable = readBoolean("Commands.mcmmo.Enabled", true);
|
||||||
|
@ -1069,9 +1069,45 @@ public class PlayerProfile
|
|||||||
skillsXp.put(SkillType.FISHING, 0);
|
skillsXp.put(SkillType.FISHING, 0);
|
||||||
} else {
|
} else {
|
||||||
skills.put(skillType, newvalue);
|
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)
|
public Integer getXpToLevel(SkillType skillType)
|
||||||
{
|
{
|
||||||
return (int) ((1020+(skills.get(skillType) * 20)));
|
return (int) ((1020+(skills.get(skillType) * 20)));
|
||||||
|
@ -313,6 +313,7 @@ public class mcMMO extends JavaPlugin
|
|||||||
|
|
||||||
//Other commands
|
//Other commands
|
||||||
if(LoadProperties.addxpEnable) getCommand("addxp").setExecutor(new AddxpCommand(this));
|
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.clearmyspawnEnable) getCommand("clearmyspawn").setExecutor(new ClearmyspawnCommand());
|
||||||
if(LoadProperties.mmoeditEnable) getCommand("mmoedit").setExecutor(new MmoeditCommand(this));
|
if(LoadProperties.mmoeditEnable) getCommand("mmoedit").setExecutor(new MmoeditCommand(this));
|
||||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
||||||
|
@ -1134,6 +1134,8 @@ Commands:
|
|||||||
Enabled: true
|
Enabled: true
|
||||||
addxp:
|
addxp:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
addlevels:
|
||||||
|
Enabled: true
|
||||||
clearmyspawn:
|
clearmyspawn:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
ptp:
|
ptp:
|
||||||
|
@ -24,6 +24,9 @@ commands:
|
|||||||
addxp:
|
addxp:
|
||||||
description: Add XP to a user
|
description: Add XP to a user
|
||||||
permission: mcmmo.tools.mmoedit
|
permission: mcmmo.tools.mmoedit
|
||||||
|
addlevels:
|
||||||
|
description: Add levels to a user
|
||||||
|
permission: mcmmo.tools.mmoedit
|
||||||
mcability:
|
mcability:
|
||||||
description: Toggle whether or not abilities get readied on right click
|
description: Toggle whether or not abilities get readied on right click
|
||||||
permission: mcmmo.commands.ability
|
permission: mcmmo.commands.ability
|
||||||
|
Loading…
Reference in New Issue
Block a user