new mmoinfo command and JSON click events

This commit is contained in:
nossr50
2019-01-10 01:17:47 -08:00
parent 0cb9bbb530
commit d5a4103858
14 changed files with 285 additions and 24 deletions

View File

@ -43,6 +43,7 @@ public final class Permissions {
* COMMANDS
*/
public static boolean mmoinfo(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mmoinfo"); }
public static boolean addlevels(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.addlevels"); }
public static boolean addlevelsOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.addlevels.others"); }

View File

@ -252,6 +252,7 @@ public class TextComponentFactory {
//Insertion
textComponent.setInsertion(skillName);
textComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/mmoinfo "+subSkillType.getNiceNameNoSpaces(subSkillType)));
subSkillTextComponents.put(key, textComponent);
return subSkillTextComponents.get(key);
@ -285,6 +286,7 @@ public class TextComponentFactory {
//Insertion
textComponent.setInsertion(skillName);
textComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/mmoinfo "+abstractSubSkill.getConfigKeyName()));
subSkillTextComponents.put(key, textComponent);
return subSkillTextComponents.get(key);
@ -295,7 +297,6 @@ public class TextComponentFactory {
private static BaseComponent[] getBaseComponent(Player player, AbstractSubSkill abstractSubSkill)
{
int curRank = RankUtils.getRank(player, abstractSubSkill);
String key = abstractSubSkill.getConfigKeyName();

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import com.gmail.nossr50.commands.chat.McChatSpy;
import com.gmail.nossr50.commands.skills.*;
import org.bukkit.command.PluginCommand;
import com.gmail.nossr50.mcMMO;
@ -37,21 +38,6 @@ import com.gmail.nossr50.commands.player.MccooldownCommand;
import com.gmail.nossr50.commands.player.McrankCommand;
import com.gmail.nossr50.commands.player.McstatsCommand;
import com.gmail.nossr50.commands.player.MctopCommand;
import com.gmail.nossr50.commands.skills.AcrobaticsCommand;
import com.gmail.nossr50.commands.skills.AlchemyCommand;
import com.gmail.nossr50.commands.skills.ArcheryCommand;
import com.gmail.nossr50.commands.skills.AxesCommand;
import com.gmail.nossr50.commands.skills.ExcavationCommand;
import com.gmail.nossr50.commands.skills.FishingCommand;
import com.gmail.nossr50.commands.skills.HerbalismCommand;
import com.gmail.nossr50.commands.skills.MiningCommand;
import com.gmail.nossr50.commands.skills.RepairCommand;
import com.gmail.nossr50.commands.skills.SalvageCommand;
import com.gmail.nossr50.commands.skills.SmeltingCommand;
import com.gmail.nossr50.commands.skills.SwordsCommand;
import com.gmail.nossr50.commands.skills.TamingCommand;
import com.gmail.nossr50.commands.skills.UnarmedCommand;
import com.gmail.nossr50.commands.skills.WoodcuttingCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.PrimarySkill;
import com.gmail.nossr50.locale.LocaleLoader;
@ -170,6 +156,15 @@ public final class CommandRegistrationManager {
command.setExecutor(new McgodCommand());
}
private static void registerMmoInfoCommand() {
PluginCommand command = mcMMO.p.getCommand("mmoinfo");
command.setDescription(LocaleLoader.getString("Commands.Description.mmoinfo"));
command.setPermission("mcmmo.commands.mmoinfo");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mmoinfo", "[" + LocaleLoader.getString("Commands.Usage.SubSkill") + "]"));
command.setExecutor(new MmoInfo());
}
private static void registerMcChatSpyCommand() {
PluginCommand command = mcMMO.p.getCommand("mcchatspy");
command.setDescription(LocaleLoader.getString("Commands.Description.mcchatspy"));
@ -441,6 +436,7 @@ public final class CommandRegistrationManager {
public static void registerCommands() {
// Generic Commands
registerMmoInfoCommand();
registerMcImportCommand();
registerKrakenCommand();
registerMcabilityCommand();

View File

@ -311,6 +311,19 @@ public class SkillUtils {
}
}
public static double getChanceOfSuccess(int skillLevel, double maxLevelBonus, double curve)
{
return getChanceOfSuccess((double) skillLevel, maxLevelBonus, curve);
}
public static double getChanceOfSuccess(double skillLevel, double maxLevelBonus, double curve)
{
if(skillLevel > maxLevelBonus)
return maxLevelBonus / curve;
return skillLevel / curve;
}
/* NEW VERSION */
public static boolean isActivationSuccessful(SkillActivationType skillActivationType, AbstractSubSkill abstractSubSkill, Player player, double maxChance, int maxBonusLevel)
{