Moving stuff around, what a mess this is going to be.

This commit is contained in:
nossr50
2019-02-09 21:14:45 -08:00
parent 380d4be9c9
commit 4d4dad0ccb
90 changed files with 77 additions and 78 deletions

View File

@ -1,57 +0,0 @@
package com.gmail.nossr50.core.datatypes;
import org.bukkit.Location;
public class LimitedSizeList {
public Location[] limitedSizeOrderedList;
private final int size;
public LimitedSizeList(int size)
{
this.size = size;
limitedSizeOrderedList = new Location[size];
}
/**
* Adds objects to our limited size ordered list
* New objects are added to the front
* @param newItem
*/
public void add(Location newItem)
{
Location[] newList = new Location[size];
for(int i = 0; i < size-1; i++)
{
if(i != 0)
newList[i] = limitedSizeOrderedList[i-1];
else
newList[i] = newItem;
}
limitedSizeOrderedList = newList;
}
/**
* Returns true if the object is anywhere in our list
* @param targetLoc the object to check for
* @return true if the object is in our list
*/
public boolean contains(Location targetLoc)
{
for(Location iter : limitedSizeOrderedList)
{
if(iter == null)
continue;
if(iter.getX() == targetLoc.getX()
&& iter.getY() == targetLoc.getY()
&& iter.getZ() == targetLoc.getZ())
return true;
}
return false;
}
}

View File

@ -1,7 +0,0 @@
package com.gmail.nossr50.core.datatypes;
public enum MobHealthbarType {
HEARTS,
BAR,
DISABLED;
}

View File

@ -1,24 +0,0 @@
package com.gmail.nossr50.core.datatypes.chat;
import com.gmail.nossr50.locale.LocaleLoader;
public enum ChatMode {
ADMIN(LocaleLoader.getString("Commands.AdminChat.On"), LocaleLoader.getString("Commands.AdminChat.Off")),
PARTY(LocaleLoader.getString("Commands.Party.Chat.On"), LocaleLoader.getString("Commands.Party.Chat.Off"));
private String enabledMessage;
private String disabledMessage;
private ChatMode(String enabledMessage, String disabledMessage) {
this.enabledMessage = enabledMessage;
this.disabledMessage = disabledMessage;
}
public String getEnabledMessage() {
return enabledMessage;
}
public String getDisabledMessage() {
return disabledMessage;
}
}

View File

@ -1,24 +0,0 @@
package com.gmail.nossr50.core.datatypes.database;
public enum DatabaseType {
FLATFILE,
SQL,
CUSTOM;
public static DatabaseType getDatabaseType(String typeName) {
for (DatabaseType type : values()) {
if (type.name().equalsIgnoreCase(typeName)) {
return type;
}
}
if (typeName.equalsIgnoreCase("file")) {
return FLATFILE;
}
else if (typeName.equalsIgnoreCase("mysql")) {
return SQL;
}
return CUSTOM;
}
}

View File

@ -1,11 +0,0 @@
package com.gmail.nossr50.core.datatypes.database;
public class PlayerStat {
public String name;
public int statVal = 0;
public PlayerStat(String name, int value) {
this.name = name;
this.statVal = value;
}
}

View File

@ -1,17 +0,0 @@
package com.gmail.nossr50.core.datatypes.database;
public enum UpgradeType {
ADD_FISHING,
ADD_BLAST_MINING_COOLDOWN,
ADD_SQL_INDEXES,
ADD_MOB_HEALTHBARS,
DROP_SQL_PARTY_NAMES,
DROP_SPOUT,
ADD_ALCHEMY,
ADD_UUIDS,
ADD_UUIDS_PARTY,
ADD_SCOREBOARD_TIPS,
DROP_NAME_UNIQUENESS,
ADD_SKILL_TOTAL,
ADD_UNIQUE_PLAYER_DATA,
}

View File

@ -1,16 +0,0 @@
package com.gmail.nossr50.core.datatypes.experience;
public enum FormulaType {
LINEAR,
EXPONENTIAL,
UNKNOWN;
public static FormulaType getFormulaType(String string) {
try {
return valueOf(string);
}
catch (IllegalArgumentException ex) {
return UNKNOWN;
}
}
}

View File

@ -1,55 +0,0 @@
package com.gmail.nossr50.core.datatypes.experience;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.datatypes.skills.PrimarySkillType;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;
public class SkillXpGain implements Delayed {
private final long expiryTime;
private final float xp;
private final PrimarySkillType type;
public SkillXpGain(PrimarySkillType type, float xp) {
this.expiryTime = System.currentTimeMillis() + getDuration();
this.xp = xp;
this.type = type;
}
public PrimarySkillType getSkill() {
return type;
}
public float getXp() {
return xp;
}
private static long getDuration() {
return TimeUnit.MINUTES.toMillis(ExperienceConfig.getInstance().getDiminishedReturnsTimeInterval());
}
public int compareTo(SkillXpGain other) {
if (this.expiryTime < other.expiryTime) {
return -1;
}
else if (this.expiryTime > other.expiryTime) {
return 1;
}
return 0;
}
@Override
public int compareTo(Delayed other) {
if (other instanceof SkillXpGain) {
// Use more efficient method if possible (private fields)
return this.compareTo((SkillXpGain) other);
}
return (int) (getDelay(TimeUnit.MILLISECONDS) - other.getDelay(TimeUnit.MILLISECONDS));
}
@Override
public long getDelay(TimeUnit arg0) {
return arg0.convert(expiryTime - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
}
}

View File

@ -1,21 +0,0 @@
package com.gmail.nossr50.core.datatypes.experience;
public enum XPGainReason {
PVP,
PVE,
VAMPIRISM,
SHARED_PVP,
SHARED_PVE,
COMMAND,
UNKNOWN;
public static XPGainReason getXPGainReason(String reason) {
for (XPGainReason type : values()) {
if (type.name().equalsIgnoreCase(reason)) {
return type;
}
}
return null;
}
}

View File

@ -1,10 +0,0 @@
package com.gmail.nossr50.core.datatypes.experience;
public enum XPGainSource {
SELF,
VAMPIRISM, //From Vampirism kills
PASSIVE, //Smelting, Brewing, etc...
PARTY_MEMBERS, //From other members of a party
COMMAND,
CUSTOM, //Outside Sources
}

View File

@ -1,35 +0,0 @@
package com.gmail.nossr50.core.datatypes.interactions;
/**
* This class helps define the types of information interactions we will have with players
*/
public enum NotificationType {
XP_GAIN("ExperienceGain"),
HARDCORE_MODE("HardcoreMode"),
NO_PERMISSION("NoPermission"),
SUBSKILL_UNLOCKED("SubSkillUnlocked"),
LEVEL_UP_MESSAGE("LevelUps"),
HOLIDAY("Holiday"),
SUBSKILL_MESSAGE("SubSkillInteraction"),
SUBSKILL_MESSAGE_FAILED("SubSkillFailed"),
TOOL("ToolReady"),
REQUIREMENTS_NOT_MET("RequirementsNotMet"),
ABILITY_OFF("AbilityOff"),
ABILITY_COOLDOWN("AbilityCoolDown"),
ABILITY_REFRESHED("AbilityRefreshed"),
SUPER_ABILITY("SuperAbilityInteraction"),
SUPER_ABILITY_ALERT_OTHERS("SuperAbilityAlertOthers"),
ITEM_MESSAGE("ItemMessage"),
PARTY_MESSAGE("PartyMessage");
final String niceName;
NotificationType(String niceName)
{
this.niceName = niceName;
}
@Override
public String toString() {
return niceName;
}}

View File

@ -1,10 +0,0 @@
package com.gmail.nossr50.core.datatypes.json;
import net.md_5.bungee.api.chat.BaseComponent;
public class CustomBaseComponent extends BaseComponent {
@Override
public BaseComponent duplicate() {
return this;
}
}

View File

@ -1,31 +0,0 @@
package com.gmail.nossr50.core.datatypes.json;
public class McMMOUrl {
public static final String urlWebsite = "https://www.mcmmo.org";
public static final String urlDiscord = "https://discord.gg/bJ7pFS9";
public static final String urlPatreon = "https://www.patreon.com/com.gmail.nossr50";
public static final String urlWiki = "https://www.mcmmo.org/wiki/";
public static final String urlSpigot = "http://spigot.mcmmo.org";
public static final String urlTranslate = "https://www.mcmmo.org/translate/";
public static String getUrl(McMMOWebLinks webLinks)
{
switch(webLinks)
{
case WIKI:
return urlWiki;
case PATREON:
return urlPatreon;
case SPIGOT:
return urlSpigot;
case DISCORD:
return urlDiscord;
case WEBSITE:
return urlWebsite;
case HELP_TRANSLATE:
return urlTranslate;
default:
return "https://www.mcmmo.org";
}
}
}

View File

@ -1,44 +0,0 @@
package com.gmail.nossr50.core.datatypes.json;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils;
public enum McMMOWebLinks {
WEBSITE,
DISCORD,
PATREON,
SPIGOT,
HELP_TRANSLATE,
WIKI;
public String getUrl()
{
return McMMOUrl.getUrl(this);
}
public String getNiceTitle()
{
return StringUtils.getCapitalized(toString());
}
public String getLocaleDescription()
{
switch (this)
{
case WEBSITE:
return LocaleLoader.getString( "JSON.URL.Website");
case DISCORD:
return LocaleLoader.getString( "JSON.URL.Discord");
case PATREON:
return LocaleLoader.getString( "JSON.URL.Patreon");
case HELP_TRANSLATE:
return LocaleLoader.getString( "JSON.URL.Translation");
case SPIGOT:
return LocaleLoader.getString("JSON.URL.Spigot");
case WIKI:
return LocaleLoader.getString("JSON.URL.Wiki");
default:
return "";
}
}
}

View File

@ -1,15 +0,0 @@
package com.gmail.nossr50.core.datatypes.meta;
import com.gmail.nossr50.mcMMO;
import org.bukkit.metadata.FixedMetadataValue;
/**
* This class is for storing mob names since we switch them to heart values
*/
public class OldName extends FixedMetadataValue {
public OldName(String oldName, mcMMO plugin)
{
super(plugin, oldName);
}
}

View File

@ -1,25 +0,0 @@
package com.gmail.nossr50.core.datatypes.mods;
public class CustomBlock {
private int xpGain;
private boolean canDoubleDrop;
private int smeltingXpGain;
public CustomBlock(int xpGain, boolean canDoubleDrop, int smeltingXpGain) {
this.xpGain = xpGain;
this.canDoubleDrop = canDoubleDrop;
this.smeltingXpGain = smeltingXpGain;
}
public int getXpGain() {
return xpGain;
}
public boolean isDoubleDropEnabled() {
return canDoubleDrop;
}
public int getSmeltingXpGain() {
return smeltingXpGain;
}
}

View File

@ -1,45 +0,0 @@
package com.gmail.nossr50.core.datatypes.mods;
import org.bukkit.inventory.ItemStack;
public class CustomEntity {
private double xpMultiplier;
private boolean canBeTamed;
private int tamingXP;
private boolean canBeSummoned;
private ItemStack callOfTheWildItem;
private int callOfTheWildAmount;
public CustomEntity(double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) {
this.xpMultiplier = xpMultiplier;
this.canBeTamed = canBeTamed;
this.tamingXP = tamingXP;
this.canBeSummoned = canBeSummoned;
this.callOfTheWildItem = callOfTheWildItem;
this.callOfTheWildAmount = callOfTheWildAmount;
}
public double getXpMultiplier() {
return xpMultiplier;
}
public boolean canBeTamed() {
return canBeTamed;
}
public int getTamingXP() {
return tamingXP;
}
public boolean canBeSummoned() {
return canBeSummoned;
}
public ItemStack getCallOfTheWildItem() {
return callOfTheWildItem;
}
public int getCallOfTheWildAmount() {
return callOfTheWildAmount;
}
}

View File

@ -1,25 +0,0 @@
package com.gmail.nossr50.core.datatypes.mods;
public class CustomTool {
private double xpMultiplier;
private boolean abilityEnabled;
private int tier;
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier) {
this.xpMultiplier = xpMultiplier;
this.abilityEnabled = abilityEnabled;
this.tier = tier;
}
public double getXpMultiplier() {
return xpMultiplier;
}
public boolean isAbilityEnabled() {
return abilityEnabled;
}
public int getTier() {
return tier;
}
}

View File

@ -1,38 +0,0 @@
package com.gmail.nossr50.core.datatypes.party;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.inventory.ItemStack;
public enum ItemShareType {
LOOT,
MINING,
HERBALISM,
WOODCUTTING,
MISC;
public static ItemShareType getShareType(ItemStack itemStack) {
if (ItemUtils.isMobDrop(itemStack)) {
return LOOT;
}
else if (ItemUtils.isMiningDrop(itemStack)) {
return MINING;
}
else if (ItemUtils.isHerbalismDrop(itemStack)) {
return HERBALISM;
}
else if (ItemUtils.isWoodcuttingDrop(itemStack)) {
return WOODCUTTING;
}
else if (ItemUtils.isMiscDrop(itemStack)) {
return MISC;
}
return null;
}
public String getLocaleString() {
return LocaleLoader.getString("Party.ItemShare.Category." + StringUtils.getCapitalized(this.toString()));
}
}

View File

@ -1,375 +0,0 @@
package com.gmail.nossr50.core.datatypes.party;
import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.datatypes.experience.FormulaType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.UUID;
public class Party {
private final LinkedHashMap<UUID, String> members = new LinkedHashMap<UUID, String>();
private final List<Player> onlineMembers = new ArrayList<Player>();
private PartyLeader leader;
private String name;
private String password;
private boolean locked;
private Party ally;
private int level;
private float xp;
private ShareMode xpShareMode = ShareMode.NONE;
private ShareMode itemShareMode = ShareMode.NONE;
private boolean shareLootDrops = true;
private boolean shareMiningDrops = true;
private boolean shareHerbalismDrops = true;
private boolean shareWoodcuttingDrops = true;
private boolean shareMiscDrops = true;
public Party(String name) {
this.name = name;
}
public Party(PartyLeader leader, String name) {
this.leader = leader;
this.name = name;
this.locked = true;
this.level = 0;
}
public Party(PartyLeader leader, String name, String password) {
this.leader = leader;
this.name = name;
this.password = password;
this.locked = true;
this.level = 0;
}
public Party(PartyLeader leader, String name, String password, boolean locked) {
this.leader = leader;
this.name = name;
this.password = password;
this.locked = locked;
this.level = 0;
}
public LinkedHashMap<UUID, String> getMembers() {
return members;
}
public List<Player> getOnlineMembers() {
return onlineMembers;
}
public List<Player> getVisibleMembers(Player player)
{
ArrayList<Player> visibleMembers = new ArrayList<>();
for(Player p : onlineMembers)
{
if(player.canSee(p))
visibleMembers.add(p);
}
return visibleMembers;
}
public List<String> getOnlinePlayerNames(CommandSender sender) {
Player player = sender instanceof Player ? (Player) sender : null;
List<String> onlinePlayerNames = new ArrayList<String>();
for (Player onlinePlayer : getOnlineMembers()) {
if (player != null && player.canSee(onlinePlayer)) {
onlinePlayerNames.add(onlinePlayer.getName());
}
}
return onlinePlayerNames;
}
public boolean addOnlineMember(Player player) {
return onlineMembers.add(player);
}
public boolean removeOnlineMember(Player player) {
return onlineMembers.remove(player);
}
public String getName() {
return name;
}
public PartyLeader getLeader() {
return leader;
}
public String getPassword() {
return password;
}
public boolean isLocked() {
return locked;
}
public Party getAlly() {
return ally;
}
public List<String> getItemShareCategories() {
List<String> shareCategories = new ArrayList<String>();
for (ItemShareType shareType : ItemShareType.values()) {
if (sharingDrops(shareType)) {
shareCategories.add(shareType.getLocaleString());
}
}
return shareCategories;
}
public void setName(String name) {
this.name = name;
}
public void setLeader(PartyLeader leader) {
this.leader = leader;
}
public void setPassword(String password) {
this.password = password;
}
public void setLocked(boolean locked) {
this.locked = locked;
}
public void setAlly(Party ally) {
this.ally = ally;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public float getXp() {
return xp;
}
public void setXp(float xp) {
this.xp = xp;
}
public void addXp(float xp) {
setXp(getXp() + xp);
}
protected float levelUp() {
float xpRemoved = getXpToLevel();
setLevel(getLevel() + 1);
setXp(getXp() - xpRemoved);
return xpRemoved;
}
public int getXpToLevel() {
FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
return (mcMMO.getFormulaManager().getCachedXpToLevel(level, formulaType)) * (getOnlineMembers().size() + Config.getInstance().getPartyXpCurveMultiplier());
}
public String getXpToLevelPercentage() {
DecimalFormat percent = new DecimalFormat("##0.00%");
return percent.format(this.getXp() / getXpToLevel());
}
/**
* Applies an experience gain
*
* @param xp Experience amount to add
*/
public void applyXpGain(float xp) {
if (!EventUtils.handlePartyXpGainEvent(this, xp)) {
return;
}
if (getXp() < getXpToLevel()) {
return;
}
int levelsGained = 0;
float xpRemoved = 0;
while (getXp() >= getXpToLevel()) {
if (hasReachedLevelCap()) {
setXp(0);
return;
}
xpRemoved += levelUp();
levelsGained++;
}
if (!EventUtils.handlePartyLevelChangeEvent(this, levelsGained, xpRemoved)) {
return;
}
if (!Config.getInstance().getPartyInformAllMembers()) {
Player leader = mcMMO.p.getServer().getPlayer(this.leader.getUniqueId());
if (leader != null) {
leader.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, getLevel()));
if (Config.getInstance().getLevelUpSoundsEnabled()) {
SoundManager.sendSound(leader, leader.getLocation(), SoundType.LEVEL_UP);
}
}
return;
}
PartyManager.informPartyMembersLevelUp(this, levelsGained, getLevel());
}
public boolean hasReachedLevelCap() {
return Config.getInstance().getPartyLevelCap() < getLevel() + 1;
}
public void setXpShareMode(ShareMode xpShareMode) {
this.xpShareMode = xpShareMode;
}
public ShareMode getXpShareMode() {
return xpShareMode;
}
public void setItemShareMode(ShareMode itemShareMode) {
this.itemShareMode = itemShareMode;
}
public ShareMode getItemShareMode() {
return itemShareMode;
}
public boolean sharingDrops(ItemShareType shareType) {
switch (shareType) {
case HERBALISM:
return shareHerbalismDrops;
case LOOT:
return shareLootDrops;
case MINING:
return shareMiningDrops;
case MISC:
return shareMiscDrops;
case WOODCUTTING:
return shareWoodcuttingDrops;
default:
return false;
}
}
public void setSharingDrops(ItemShareType shareType, boolean enabled) {
switch (shareType) {
case HERBALISM:
shareHerbalismDrops = enabled;
break;
case LOOT:
shareLootDrops = enabled;
break;
case MINING:
shareMiningDrops = enabled;
break;
case MISC:
shareMiscDrops = enabled;
break;
case WOODCUTTING:
shareWoodcuttingDrops = enabled;
break;
default:
return;
}
}
public boolean hasMember(String memberName) {
return this.getMembers().values().contains(memberName);
}
public boolean hasMember(UUID uuid) {
return this.getMembers().keySet().contains(uuid);
}
public String createMembersList(Player player) {
StringBuilder memberList = new StringBuilder();
for (Player otherPlayer : this.getVisibleMembers(player)) {
String memberName = otherPlayer.getName();
if (this.getLeader().getUniqueId().equals(otherPlayer.getUniqueId())) {
memberList.append(ChatColor.GOLD);
if (otherPlayer == null) {
memberName = memberName.substring(0, 1) + ChatColor.GRAY + ChatColor.ITALIC + "" + memberName.substring(1);
}
}
else if (otherPlayer != null) {
memberList.append(ChatColor.WHITE);
}
else {
memberList.append(ChatColor.GRAY);
}
if (player.getName().equalsIgnoreCase(otherPlayer.getName())) {
memberList.append(ChatColor.ITALIC);
}
memberList.append(memberName).append(ChatColor.RESET).append(" ");
}
return memberList.toString();
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!(obj instanceof Party)) {
return false;
}
Party other = (Party) obj;
if ((this.getName() == null) || (other.getName() == null)) {
return false;
}
return this.getName().equals(other.getName());
}
}

View File

@ -1,50 +0,0 @@
package com.gmail.nossr50.core.datatypes.party;
import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.entity.Player;
public enum PartyFeature {
CHAT,
TELEPORT,
ALLIANCE,
ITEM_SHARE,
XP_SHARE;
public String getLocaleString() {
return LocaleLoader.getString("Party.Feature." + StringUtils.getPrettyPartyFeatureString(this).replace(" ", ""));
}
public String getFeatureLockedLocaleString() {
return LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Party.Feature.Locked." + StringUtils.getPrettyPartyFeatureString(this).replace(" ", ""), Config.getInstance().getPartyFeatureUnlockLevel(this)));
}
public boolean hasPermission(Player player) {
PartySubcommandType partySubCommandType;
switch (this) {
case CHAT:
partySubCommandType = PartySubcommandType.CHAT;
break;
case TELEPORT:
partySubCommandType = PartySubcommandType.TELEPORT;
break;
case ALLIANCE:
partySubCommandType = PartySubcommandType.ALLIANCE;
break;
case ITEM_SHARE:
partySubCommandType = PartySubcommandType.ITEMSHARE;
break;
case XP_SHARE:
partySubCommandType = PartySubcommandType.XPSHARE;
break;
default:
return false;
}
return Permissions.partySubcommand(player, partySubCommandType);
}
}

View File

@ -1,21 +0,0 @@
package com.gmail.nossr50.core.datatypes.party;
import java.util.UUID;
public class PartyLeader {
private UUID uuid;
private String playerName;
public PartyLeader(UUID uuid, String playerName) {
this.uuid = uuid;
this.playerName = playerName;
}
public UUID getUniqueId() {
return uuid;
}
public String getPlayerName() {
return playerName;
}
}

View File

@ -1,67 +0,0 @@
package com.gmail.nossr50.core.datatypes.party;
import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.util.Misc;
import org.bukkit.entity.Player;
public class PartyTeleportRecord {
private Player requestor;
private boolean enabled, confirmRequired;
private int timeout, lastUse;
public PartyTeleportRecord() {
requestor = null;
enabled = true;
confirmRequired = Config.getInstance().getPTPCommandConfirmRequired();
timeout = 0;
lastUse = 0;
}
public boolean isEnabled() {
return enabled;
}
public void toggleEnabled() {
enabled = !enabled;
}
public Player getRequestor() {
return requestor;
}
public void setRequestor(Player requestor) {
this.requestor = requestor;
}
public boolean hasRequest() {
return (requestor != null);
}
public void removeRequest() {
requestor = null;
}
public boolean isConfirmRequired() {
return confirmRequired;
}
public void toggleConfirmRequired() {
confirmRequired = !confirmRequired;
}
public int getLastUse() {
return lastUse;
}
public void actualizeLastUse() {
lastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
public int getTimeout() {
return timeout;
}
public void actualizeTimeout() {
timeout = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
}

View File

@ -1,25 +0,0 @@
package com.gmail.nossr50.core.datatypes.party;
import com.gmail.nossr50.util.commands.CommandUtils;
public enum ShareMode {
NONE,
EQUAL,
RANDOM;
public static ShareMode getShareMode(String string) {
try {
return valueOf(string);
}
catch (IllegalArgumentException ex) {
if (string.equalsIgnoreCase("even")) {
return EQUAL;
}
else if (CommandUtils.shouldDisableToggle(string)) {
return NONE;
}
return null;
}
}
}

View File

@ -1,386 +0,0 @@
package com.gmail.nossr50.core.datatypes.player;
import com.gmail.nossr50.core.config.skills.AdvancedConfig;
import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.datatypes.MobHealthbarType;
import com.gmail.nossr50.core.datatypes.experience.FormulaType;
import com.gmail.nossr50.core.datatypes.experience.SkillXpGain;
import com.gmail.nossr50.core.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.core.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.player.PlayerProfileSaveTask;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.core.data.UserManager;
import com.google.common.collect.ImmutableMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.DelayQueue;
public class PlayerProfile {
private final String playerName;
private UUID uuid;
private boolean loaded;
private volatile boolean changed;
/* HUDs */
private MobHealthbarType mobHealthbarType;
private int scoreboardTipsShown;
/* Skill Data */
private final Map<PrimarySkillType, Integer> skills = new HashMap<PrimarySkillType, Integer>(); // Skill & Level
private final Map<PrimarySkillType, Float> skillsXp = new HashMap<PrimarySkillType, Float>(); // Skill & XP
private final Map<SuperAbilityType, Integer> abilityDATS = new HashMap<SuperAbilityType, Integer>(); // Ability & Cooldown
private final Map<UniqueDataType, Integer> uniquePlayerData = new HashMap<>(); //Misc data that doesn't fit into other categories (chimaera wing, etc..)
// Store previous XP gains for deminished returns
private DelayQueue<SkillXpGain> gainedSkillsXp = new DelayQueue<SkillXpGain>();
private HashMap<PrimarySkillType, Float> rollingSkillsXp = new HashMap<PrimarySkillType, Float>();
@Deprecated
public PlayerProfile(String playerName) {
this(playerName, null);
}
public PlayerProfile(String playerName, UUID uuid) {
this.uuid = uuid;
this.playerName = playerName;
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
scoreboardTipsShown = 0;
for (SuperAbilityType superAbilityType : SuperAbilityType.values()) {
abilityDATS.put(superAbilityType, 0);
}
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
skills.put(primarySkillType, AdvancedConfig.getInstance().getStartingLevel());
skillsXp.put(primarySkillType, 0F);
}
//Misc Cooldowns
uniquePlayerData.put(UniqueDataType.CHIMAERA_WING_DATS, 0); //Chimaera wing
}
@Deprecated
public PlayerProfile(String playerName, boolean isLoaded) {
this(playerName);
this.loaded = isLoaded;
}
public PlayerProfile(String playerName, UUID uuid, boolean isLoaded) {
this(playerName, uuid);
this.loaded = isLoaded;
}
public PlayerProfile(String playerName, UUID uuid, Map<PrimarySkillType, Integer> levelData, Map<PrimarySkillType, Float> xpData, Map<SuperAbilityType, Integer> cooldownData, MobHealthbarType mobHealthbarType, int scoreboardTipsShown, Map<UniqueDataType, Integer> uniqueProfileData) {
this.playerName = playerName;
this.uuid = uuid;
this.mobHealthbarType = mobHealthbarType;
this.scoreboardTipsShown = scoreboardTipsShown;
skills.putAll(levelData);
skillsXp.putAll(xpData);
abilityDATS.putAll(cooldownData);
uniquePlayerData.putAll(uniqueProfileData);
loaded = true;
}
public void scheduleAsyncSave() {
new PlayerProfileSaveTask(this).runTaskAsynchronously(mcMMO.p);
}
public void save() {
if (!changed || !loaded) {
return;
}
// TODO should this part be synchronized?
PlayerProfile profileCopy = new PlayerProfile(playerName, uuid, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), mobHealthbarType, scoreboardTipsShown, ImmutableMap.copyOf(uniquePlayerData));
changed = !mcMMO.getDatabaseManager().saveUser(profileCopy);
if (changed) {
mcMMO.p.getLogger().warning("PlayerProfile saving failed for player: " + playerName + " " + uuid);
}
}
public String getPlayerName() {
return playerName;
}
public UUID getUniqueId() {
return uuid;
}
public void setUniqueId(UUID uuid) {
changed = true;
this.uuid = uuid;
}
public boolean isLoaded() {
return loaded;
}
/*
* Mob Healthbars
*/
public MobHealthbarType getMobHealthbarType() {
return mobHealthbarType;
}
public void setMobHealthbarType(MobHealthbarType mobHealthbarType) {
changed = true;
this.mobHealthbarType = mobHealthbarType;
}
public int getScoreboardTipsShown() {
return scoreboardTipsShown;
}
public void setScoreboardTipsShown(int scoreboardTipsShown) {
changed = true;
this.scoreboardTipsShown = scoreboardTipsShown;
}
public void increaseTipsShown() {
setScoreboardTipsShown(getScoreboardTipsShown() + 1);
}
/*
* Cooldowns
*/
public int getChimaerWingDATS() { return uniquePlayerData.get(UniqueDataType.CHIMAERA_WING_DATS);}
protected void setChimaeraWingDATS(int DATS) {
changed = true;
uniquePlayerData.put(UniqueDataType.CHIMAERA_WING_DATS, DATS);
}
public void setUniqueData(UniqueDataType uniqueDataType, int newData) {
changed = true;
uniquePlayerData.put(uniqueDataType, newData);
}
public long getUniqueData(UniqueDataType uniqueDataType) { return uniquePlayerData.get(uniqueDataType); }
/**
* Get the current deactivation timestamp of an ability.
*
* @param ability The {@link SuperAbilityType} to get the DATS for
* @return the deactivation timestamp for the ability
*/
public long getAbilityDATS(SuperAbilityType ability) {
return abilityDATS.get(ability);
}
/**
* Set the current deactivation timestamp of an ability.
*
* @param ability The {@link SuperAbilityType} to set the DATS for
* @param DATS the DATS of the ability
*/
protected void setAbilityDATS(SuperAbilityType ability, long DATS) {
changed = true;
abilityDATS.put(ability, (int) (DATS * .001D));
}
/**
* Reset all ability cooldowns.
*/
protected void resetCooldowns() {
changed = true;
for (SuperAbilityType ability : abilityDATS.keySet()) {
abilityDATS.put(ability, 0);
}
}
/*
* Xp Functions
*/
public int getSkillLevel(PrimarySkillType skill) {
return skill.isChildSkill() ? getChildSkillLevel(skill) : skills.get(skill);
}
public float getSkillXpLevelRaw(PrimarySkillType skill) {
return skillsXp.get(skill);
}
public int getSkillXpLevel(PrimarySkillType skill) {
return (int) Math.floor(getSkillXpLevelRaw(skill));
}
public void setSkillXpLevel(PrimarySkillType skill, float xpLevel) {
if (skill.isChildSkill()) {
return;
}
changed = true;
skillsXp.put(skill, xpLevel);
}
protected float levelUp(PrimarySkillType skill) {
float xpRemoved = getXpToLevel(skill);
changed = true;
skills.put(skill, skills.get(skill) + 1);
skillsXp.put(skill, skillsXp.get(skill) - xpRemoved);
return xpRemoved;
}
/**
* Remove Xp from a skill.
*
* @param skill Type of skill to modify
* @param xp Amount of xp to remove
*/
public void removeXp(PrimarySkillType skill, int xp) {
if (skill.isChildSkill()) {
return;
}
changed = true;
skillsXp.put(skill, skillsXp.get(skill) - xp);
}
public void removeXp(PrimarySkillType skill, float xp) {
if (skill.isChildSkill()) {
return;
}
changed = true;
skillsXp.put(skill, skillsXp.get(skill) - xp);
}
/**
* Modify a skill level.
*
* @param skill Type of skill to modify
* @param level New level value for the skill
*/
public void modifySkill(PrimarySkillType skill, int level) {
if (skill.isChildSkill()) {
return;
}
changed = true;
//Don't allow levels to be negative
if(level < 0)
level = 0;
skills.put(skill, level);
skillsXp.put(skill, 0F);
}
/**
* Add levels to a skill.
*
* @param skill Type of skill to add levels to
* @param levels Number of levels to add
*/
public void addLevels(PrimarySkillType skill, int levels) {
modifySkill(skill, skills.get(skill) + levels);
}
/**
* Add Experience to a skill.
*
* @param skill Type of skill to add experience to
* @param xp Number of experience to add
*/
public void addXp(PrimarySkillType skill, float xp) {
changed = true;
if (skill.isChildSkill()) {
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
float dividedXP = (xp / parentSkills.size());
for (PrimarySkillType parentSkill : parentSkills) {
skillsXp.put(parentSkill, skillsXp.get(parentSkill) + dividedXP);
}
}
else {
skillsXp.put(skill, skillsXp.get(skill) + xp);
}
}
/**
* Get the registered amount of experience gained
* This is used for diminished XP returns
*
* @return xp Experience amount registered
*/
public float getRegisteredXpGain(PrimarySkillType primarySkillType) {
float xp = 0F;
if (rollingSkillsXp.get(primarySkillType) != null) {
xp = rollingSkillsXp.get(primarySkillType);
}
return xp;
}
/**
* Register an experience gain
* This is used for diminished XP returns
*
* @param primarySkillType Skill being used
* @param xp Experience amount to add
*/
public void registerXpGain(PrimarySkillType primarySkillType, float xp) {
gainedSkillsXp.add(new SkillXpGain(primarySkillType, xp));
rollingSkillsXp.put(primarySkillType, getRegisteredXpGain(primarySkillType) + xp);
}
/**
* Remove experience gains older than a given time
* This is used for diminished XP returns
*/
public void purgeExpiredXpGains() {
SkillXpGain gain;
while ((gain = gainedSkillsXp.poll()) != null) {
rollingSkillsXp.put(gain.getSkill(), getRegisteredXpGain(gain.getSkill()) - gain.getXp());
}
}
/**
* Get the amount of Xp remaining before the next level.
*
* @param primarySkillType Type of skill to check
* @return the total amount of Xp until next level
*/
public int getXpToLevel(PrimarySkillType primarySkillType) {
int level = (ExperienceConfig.getInstance().getCumulativeCurveEnabled()) ? UserManager.getPlayer(playerName).getPowerLevel() : skills.get(primarySkillType);
FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
return mcMMO.getFormulaManager().getCachedXpToLevel(level, formulaType);
}
private int getChildSkillLevel(PrimarySkillType primarySkillType) {
Set<PrimarySkillType> parents = FamilyTree.getParents(primarySkillType);
int sum = 0;
for (PrimarySkillType parent : parents) {
sum += Math.min(getSkillLevel(parent), parent.getMaxLevel());
}
return sum / parents.size();
}
}

View File

@ -1,5 +0,0 @@
package com.gmail.nossr50.core.datatypes.player;
public enum UniqueDataType {
CHIMAERA_WING_DATS
}

View File

@ -1,7 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills;
public enum ItemType {
ARMOR,
TOOL,
OTHER;
}

View File

@ -1,43 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills;
import org.bukkit.Material;
public enum MaterialType {
STRING,
LEATHER,
WOOD,
STONE,
IRON,
GOLD,
DIAMOND,
OTHER;
public Material getDefaultMaterial() {
switch (this) {
case STRING:
return Material.STRING;
case LEATHER:
return Material.LEATHER;
case WOOD:
return Material.OAK_PLANKS;
case STONE:
return Material.COBBLESTONE;
case IRON:
return Material.IRON_INGOT;
case GOLD:
return Material.GOLD_INGOT;
case DIAMOND:
return Material.DIAMOND;
case OTHER:
default:
return null;
}
}
}

View File

@ -1,22 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills;
public enum ModConfigType {
BLOCKS,
TOOLS,
ARMOR,
UNKNOWN;
public static ModConfigType getModConfigType(String materialName) {
if (materialName.contains("HELM") || (materialName.contains("CHEST") && !materialName.contains("CHESTNUT")) || materialName.contains("LEGS") || materialName.contains("LEGGINGS") || materialName.contains("BOOT")) {
return ARMOR;
}
else if (materialName.contains("PICKAXE") || materialName.contains("AXE") || (materialName.contains("BOW") && !materialName.contains("BOWL")) || materialName.contains("HOE") || materialName.contains("SHOVEL") || materialName.contains("SWORD")) {
return TOOLS;
}
else if (materialName.contains("LOG") || materialName.contains("LEAVES") || materialName.contains("FLOWER") || materialName.contains("PLANT") || materialName.contains("CROP") || materialName.contains("ORE") || materialName.contains("DIRT") || materialName.contains("SAND") || materialName.contains("GRASS")) {
return BLOCKS;
}
return UNKNOWN;
}
}

View File

@ -1,238 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills;
import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
import com.gmail.nossr50.skills.archery.ArcheryManager;
import com.gmail.nossr50.skills.axes.AxesManager;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.Color;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public enum PrimarySkillType {
ACROBATICS(AcrobaticsManager.class, Color.WHITE, ImmutableList.of(SubSkillType.ACROBATICS_DODGE, SubSkillType.ACROBATICS_ROLL)),
ALCHEMY(AlchemyManager.class, Color.FUCHSIA, ImmutableList.of(SubSkillType.ALCHEMY_CATALYSIS, SubSkillType.ALCHEMY_CONCOCTIONS)),
ARCHERY(ArcheryManager.class, Color.MAROON, ImmutableList.of(SubSkillType.ARCHERY_DAZE, SubSkillType.ARCHERY_ARROW_RETRIEVAL, SubSkillType.ARCHERY_SKILL_SHOT)),
AXES(AxesManager.class, Color.AQUA, SuperAbilityType.SKULL_SPLITTER, ToolType.AXE, ImmutableList.of(SubSkillType.AXES_SKULL_SPLITTER, SubSkillType.AXES_ARMOR_IMPACT, SubSkillType.AXES_AXE_MASTERY, SubSkillType.AXES_CRITICAL_STRIKES, SubSkillType.AXES_GREATER_IMPACT)),
EXCAVATION(ExcavationManager.class, Color.fromRGB(139, 69, 19), SuperAbilityType.GIGA_DRILL_BREAKER, ToolType.SHOVEL, ImmutableList.of(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, SubSkillType.EXCAVATION_ARCHAEOLOGY)),
FISHING(FishingManager.class, Color.NAVY, ImmutableList.of(SubSkillType.FISHING_FISHERMANS_DIET, SubSkillType.FISHING_TREASURE_HUNTER, SubSkillType.FISHING_ICE_FISHING, SubSkillType.FISHING_MAGIC_HUNTER, SubSkillType.FISHING_MASTER_ANGLER, SubSkillType.FISHING_SHAKE)),
HERBALISM(HerbalismManager.class, Color.GREEN, SuperAbilityType.GREEN_TERRA, ToolType.HOE, ImmutableList.of(SubSkillType.HERBALISM_GREEN_TERRA, SubSkillType.HERBALISM_FARMERS_DIET, SubSkillType.HERBALISM_GREEN_THUMB, SubSkillType.HERBALISM_DOUBLE_DROPS, SubSkillType.HERBALISM_HYLIAN_LUCK, SubSkillType.HERBALISM_SHROOM_THUMB)),
MINING(MiningManager.class, Color.GRAY, SuperAbilityType.SUPER_BREAKER, ToolType.PICKAXE, ImmutableList.of(SubSkillType.MINING_SUPER_BREAKER, SubSkillType.MINING_DEMOLITIONS_EXPERTISE, SubSkillType.MINING_BIGGER_BOMBS, SubSkillType.MINING_BLAST_MINING, SubSkillType.MINING_DOUBLE_DROPS)),
REPAIR(RepairManager.class, Color.SILVER, ImmutableList.of(SubSkillType.REPAIR_ARCANE_FORGING, SubSkillType.REPAIR_REPAIR_MASTERY, SubSkillType.REPAIR_SUPER_REPAIR)),
SALVAGE(SalvageManager.class, Color.ORANGE, ImmutableList.of(SubSkillType.SALVAGE_ADVANCED_SALVAGE, SubSkillType.SALVAGE_ARCANE_SALVAGE)),
SMELTING(SmeltingManager.class, Color.YELLOW, ImmutableList.of(SubSkillType.SMELTING_UNDERSTANDING_THE_ART, SubSkillType.SMELTING_FLUX_MINING, SubSkillType.SMELTING_FUEL_EFFICIENCY, SubSkillType.SMELTING_SECOND_SMELT)),
SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), SuperAbilityType.SERRATED_STRIKES, ToolType.SWORD, ImmutableList.of(SubSkillType.SWORDS_SERRATED_STRIKES, SubSkillType.SWORDS_RUPTURE, SubSkillType.SWORDS_COUNTER_ATTACK)),
TAMING(TamingManager.class, Color.PURPLE, ImmutableList.of(SubSkillType.TAMING_BEAST_LORE, SubSkillType.TAMING_CALL_OF_THE_WILD, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE, SubSkillType.TAMING_FAST_FOOD_SERVICE, SubSkillType.TAMING_GORE, SubSkillType.TAMING_HOLY_HOUND, SubSkillType.TAMING_SHARPENED_CLAWS, SubSkillType.TAMING_SHOCK_PROOF, SubSkillType.TAMING_THICK_FUR, SubSkillType.TAMING_PUMMEL)),
UNARMED(UnarmedManager.class, Color.BLACK, SuperAbilityType.BERSERK, ToolType.FISTS, ImmutableList.of(SubSkillType.UNARMED_BERSERK, SubSkillType.UNARMED_BLOCK_CRACKER, SubSkillType.UNARMED_ARROW_DEFLECT, SubSkillType.UNARMED_DISARM, SubSkillType.UNARMED_IRON_ARM_STYLE, SubSkillType.UNARMED_IRON_GRIP)),
WOODCUTTING(WoodcuttingManager.class, Color.OLIVE, SuperAbilityType.TREE_FELLER, ToolType.AXE, ImmutableList.of(SubSkillType.WOODCUTTING_LEAF_BLOWER, SubSkillType.WOODCUTTING_TREE_FELLER, SubSkillType.WOODCUTTING_HARVEST_LUMBER));
private Class<? extends SkillManager> managerClass;
private Color runescapeColor;
private SuperAbilityType ability;
private ToolType tool;
private List<SubSkillType> subSkillTypes;
public static final List<String> SKILL_NAMES;
public static final List<String> SUBSKILL_NAMES;
public static final List<PrimarySkillType> CHILD_SKILLS;
public static final List<PrimarySkillType> NON_CHILD_SKILLS;
public static final List<PrimarySkillType> COMBAT_SKILLS = ImmutableList.of(ARCHERY, AXES, SWORDS, TAMING, UNARMED);
public static final List<PrimarySkillType> GATHERING_SKILLS = ImmutableList.of(EXCAVATION, FISHING, HERBALISM, MINING, WOODCUTTING);
public static final List<PrimarySkillType> MISC_SKILLS = ImmutableList.of(ACROBATICS, ALCHEMY, REPAIR, SALVAGE, SMELTING);
static {
List<PrimarySkillType> childSkills = new ArrayList<PrimarySkillType>();
List<PrimarySkillType> nonChildSkills = new ArrayList<PrimarySkillType>();
ArrayList<String> names = new ArrayList<String>();
ArrayList<String> subSkillNames = new ArrayList<>();
for (PrimarySkillType skill : values()) {
if (skill.isChildSkill()) {
childSkills.add(skill);
}
else {
nonChildSkills.add(skill);
}
for(SubSkillType subSkillType : skill.subSkillTypes)
{
subSkillNames.add(subSkillType.getNiceNameNoSpaces(subSkillType));
}
names.add(skill.getName());
}
Collections.sort(names);
SKILL_NAMES = ImmutableList.copyOf(names);
SUBSKILL_NAMES = ImmutableList.copyOf(subSkillNames);
CHILD_SKILLS = ImmutableList.copyOf(childSkills);
NON_CHILD_SKILLS = ImmutableList.copyOf(nonChildSkills);
}
private PrimarySkillType(Class<? extends SkillManager> managerClass, Color runescapeColor, List<SubSkillType> subSkillTypes) {
this(managerClass, runescapeColor, null, null, subSkillTypes);
}
private PrimarySkillType(Class<? extends SkillManager> managerClass, Color runescapeColor, SuperAbilityType ability, ToolType tool, List<SubSkillType> subSkillTypes) {
this.managerClass = managerClass;
this.runescapeColor = runescapeColor;
this.ability = ability;
this.tool = tool;
this.subSkillTypes = subSkillTypes;
}
public Class<? extends SkillManager> getManagerClass() {
return managerClass;
}
public SuperAbilityType getAbility() {
return ability;
}
/**
* Get the max level of this skill.
*
* @return the max level of this skill
*/
public int getMaxLevel() {
return Config.getInstance().getLevelCap(this);
}
public boolean isSuperAbilityUnlocked(Player player) { return RankUtils.getRank(player, getAbility().getSubSkillTypeDefinition()) >= 1; }
public boolean getPVPEnabled() {
return Config.getInstance().getPVPEnabled(this);
}
public boolean getPVEEnabled() {
return Config.getInstance().getPVEEnabled(this);
}
public boolean getDoubleDropsDisabled() {
return Config.getInstance().getDoubleDropsDisabled(this);
}
public boolean getHardcoreStatLossEnabled() {
return Config.getInstance().getHardcoreStatLossEnabled(this);
}
public void setHardcoreStatLossEnabled(boolean enable) {
Config.getInstance().setHardcoreStatLossEnabled(this, enable);
}
public boolean getHardcoreVampirismEnabled() {
return Config.getInstance().getHardcoreVampirismEnabled(this);
}
public void setHardcoreVampirismEnabled(boolean enable) {
Config.getInstance().setHardcoreVampirismEnabled(this, enable);
}
public ToolType getTool() {
return tool;
}
public List<SubSkillType> getSkillAbilities() {
return subSkillTypes;
}
public double getXpModifier() {
return ExperienceConfig.getInstance().getFormulaSkillModifier(this);
}
public static PrimarySkillType getSkill(String skillName) {
if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) {
for (PrimarySkillType type : values()) {
if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(type.name()) + ".SkillName"))) {
return type;
}
}
}
for (PrimarySkillType type : values()) {
if (type.name().equalsIgnoreCase(skillName)) {
return type;
}
}
if (!skillName.equalsIgnoreCase("all")) {
mcMMO.p.getLogger().warning("Invalid mcMMO skill (" + skillName + ")"); //TODO: Localize
}
return null;
}
// TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them
public boolean isChildSkill() {
switch (this) {
case SALVAGE:
case SMELTING:
return true;
default:
return false;
}
}
public static PrimarySkillType bySecondaryAbility(SubSkillType subSkillType) {
for (PrimarySkillType type : values()) {
if (type.getSkillAbilities().contains(subSkillType)) {
return type;
}
}
return null;
}
public static PrimarySkillType byAbility(SuperAbilityType ability) {
for (PrimarySkillType type : values()) {
if (type.getAbility() == ability) {
return type;
}
}
return null;
}
public String getName() {
return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName"));
}
public boolean getPermissions(Player player) {
return Permissions.skillEnabled(player, this);
}
public void celebrateLevelUp(Player player) {
ParticleEffectUtils.fireworkParticleShower(player, runescapeColor);
}
public boolean shouldProcess(Entity target) {
return (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) ? getPVPEnabled() : getPVEEnabled();
}
}

View File

@ -1,19 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills;
public class SubSkillFlags {
/*
* Bitwise Flags
* These are so I can flag properties for subskills
* Flags are in the power of 2 because binary is a base-2 system
*/
public static final int ACTIVE = 1; //Active subskills are ones that aren't passive
public static final int SUPERABILITY = 2; // Super abilities are redundantly active
public static final int RNG = 4; //If the subskill makes use of RNG
public static final int PVP = 8; //If the subskill has properties that change in PVP conditions
public static final int TIMED = 16; //If the subskill has a duration or time component
public static final int TARGET_COLLECTION = 32; //If the subskill has multiple target types
public static final int REWARD_COLLECTION = 64; //If the subskill has multiple reward types
public static final int CHARGES = 128;
public static final int LIMITED = 256;
//public static final int RANDOM_ACTIVATION = 128; //If the subskill has random activation
}

View File

@ -1,310 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils;
public enum SubSkillType {
/* !! Warning -- Do not let subskills share a name with any existing PrimarySkillType as it will clash with the static import !! */
/* ACROBATICS */
ACROBATICS_DODGE(1),
ACROBATICS_ROLL,
/* ALCHEMY */
ALCHEMY_CATALYSIS(1),
ALCHEMY_CONCOCTIONS(8),
/* ARCHERY */
ARCHERY_ARROW_RETRIEVAL(1),
ARCHERY_DAZE,
ARCHERY_SKILL_SHOT(20),
/* Axes */
AXES_ARMOR_IMPACT(20),
AXES_AXE_MASTERY(4),
AXES_CRITICAL_STRIKES(1),
AXES_GREATER_IMPACT(1),
AXES_SKULL_SPLITTER(1),
/* Excavation */
EXCAVATION_ARCHAEOLOGY(8),
EXCAVATION_GIGA_DRILL_BREAKER(1),
/* Fishing */
FISHING_FISHERMANS_DIET(5),
FISHING_ICE_FISHING(1),
FISHING_MAGIC_HUNTER(1),
FISHING_MASTER_ANGLER(1),
FISHING_TREASURE_HUNTER(8),
FISHING_SHAKE(1),
/* Herbalism */
HERBALISM_DOUBLE_DROPS,
HERBALISM_FARMERS_DIET(5),
HERBALISM_GREEN_TERRA(1),
HERBALISM_GREEN_THUMB(4),
HERBALISM_HYLIAN_LUCK,
HERBALISM_SHROOM_THUMB,
/* Mining */
MINING_BIGGER_BOMBS(1),
MINING_BLAST_MINING(8),
MINING_DEMOLITIONS_EXPERTISE(1),
MINING_DOUBLE_DROPS,
MINING_SUPER_BREAKER(1),
/* Repair */
REPAIR_ARCANE_FORGING(8),
REPAIR_REPAIR_MASTERY(1),
REPAIR_SUPER_REPAIR(1),
/* Salvage */
SALVAGE_ADVANCED_SALVAGE(1),
SALVAGE_ARCANE_SALVAGE(8),
/* Smelting */
SMELTING_FLUX_MINING(1),
SMELTING_FUEL_EFFICIENCY,
SMELTING_SECOND_SMELT,
SMELTING_UNDERSTANDING_THE_ART(8),
/* Swords */
SWORDS_COUNTER_ATTACK(1),
SWORDS_RUPTURE(4),
SWORDS_SERRATED_STRIKES(1),
/* Taming */
TAMING_BEAST_LORE(1),
TAMING_CALL_OF_THE_WILD(1),
TAMING_ENVIRONMENTALLY_AWARE(1),
TAMING_FAST_FOOD_SERVICE(1),
TAMING_GORE(1),
TAMING_HOLY_HOUND(1),
TAMING_PUMMEL(1),
TAMING_SHARPENED_CLAWS(1),
TAMING_SHOCK_PROOF(1),
TAMING_THICK_FUR(1),
/* Unarmed */
UNARMED_ARROW_DEFLECT(1),
UNARMED_BERSERK(1),
UNARMED_BLOCK_CRACKER,
UNARMED_DISARM(1),
UNARMED_IRON_ARM_STYLE(5),
UNARMED_IRON_GRIP(1),
/* Woodcutting */
/* WOODCUTTING_BARK_SURGEON(3),*/
WOODCUTTING_HARVEST_LUMBER(1),
WOODCUTTING_LEAF_BLOWER(1),
/* WOODCUTTING_NATURES_BOUNTY(3),
WOODCUTTING_SPLINTER(3),*/
WOODCUTTING_TREE_FELLER(1);
private final int numRanks;
//TODO: SuperAbilityType should also contain flags for active by default? Not sure if it should work that way.
/**
* If our SubSkillType has more than 1 rank define it
* @param numRanks The number of ranks our SubSkillType has
*/
SubSkillType(int numRanks)
{
this.numRanks = numRanks;
}
SubSkillType()
{
this.numRanks = 0;
}
public int getNumRanks()
{
return numRanks;
}
/**
* !!! This relies on the immutable lists in PrimarySkillType being populated !!!
* If we add skills, those immutable lists need to be updated
* @return
*/
public PrimarySkillType getParentSkill() { return PrimarySkillType.bySecondaryAbility(this); }
/**
* Returns the root address for this skill in the advanced.yml file
* @return the root address for this skill in advanced.yml
*/
public String getAdvConfigAddress() {
return "Skills." + StringUtils.getCapitalized(getParentSkill().toString()) + "." + getConfigName(toString());
}
/**
* Returns the root address for this skill in the rankskills.yml file
* @return the root address for this skill in rankskills.yml
*/
public String getRankConfigAddress() {
return StringUtils.getCapitalized(getParentSkill().toString()) + "." + getConfigName(toString());
}
/**
* Get the string representation of the permission node for this subskill
* @return the permission node for this subskill
*/
public String getPermissionNodeAddress()
{
//TODO: This could be optimized
return "mcmmo.ability." + getParentSkill().toString().toLowerCase() + "." + getConfigName(toString()).toLowerCase();
}
/**
* Returns the name of the skill as it is used in advanced.yml and other config files
* @return the yaml identifier for this skill
*/
private String getConfigName(String subSkillName) {
/*
* Our ENUM constants name is something like PREFIX_SUB_SKILL_NAME
* We need to remove the prefix and then format the subskill to follow the naming conventions of our yaml configs
*
* So this method uses this kind of formatting
* "PARENTSKILL_COOL_SUBSKILL_ULTRA" -> "Cool Subskill Ultra" - > "CoolSubskillUltra"
*
*/
/*
* Find where to begin our substring (after the prefix)
*/
String endResult = "";
int subStringIndex = getSubStringIndex(subSkillName);
/*
* Split the string up so we can capitalize each part
*/
String subskillNameWithoutPrefix = subSkillName.substring(subStringIndex);
if(subskillNameWithoutPrefix.contains("_"))
{
String splitStrings[] = subskillNameWithoutPrefix.split("_");
for(String string : splitStrings)
{
endResult += StringUtils.getCapitalized(string);
}
} else {
endResult += StringUtils.getCapitalized(subskillNameWithoutPrefix);
}
return endResult;
}
public String getWikiName(String subSkillName) {
/*
* Find where to begin our substring (after the prefix)
*/
String endResult = "";
int subStringIndex = getSubStringIndex(subSkillName);
/*
* Split the string up so we can capitalize each part
*/
String subskillNameWithoutPrefix = subSkillName.substring(subStringIndex);
if(subskillNameWithoutPrefix.contains("_"))
{
String splitStrings[] = subskillNameWithoutPrefix.split("_");
for(int i = 0; i < splitStrings.length; i++)
{
if(i+1 >= splitStrings.length)
endResult+=StringUtils.getCapitalized(splitStrings[i]);
else {
endResult += StringUtils.getCapitalized(splitStrings[i]);
endResult += "_";
}
}
} else {
endResult += StringUtils.getCapitalized(subskillNameWithoutPrefix);
}
return endResult;
}
/**
* Returns the name of the parent skill from the Locale file
* @return The parent skill as defined in the locale
*/
public String getParentNiceNameLocale()
{
return LocaleLoader.getString(StringUtils.getCapitalized(getParentSkill().toString())+".SkillName");
}
/**
* Gets the "nice" name of the subskill without spaces
* @param subSkillType target subskill
* @return the "nice" name without spaces
*/
public String getNiceNameNoSpaces(SubSkillType subSkillType)
{
return getConfigName(subSkillType.toString());
}
/**
* This finds the substring index for our SubSkillType's name after its parent name prefix
* @param subSkillName The name to process
* @return The value of the substring index after our parent's prefix
*/
private int getSubStringIndex(String subSkillName) {
char[] enumNameCharArray = subSkillName.toCharArray();
int subStringIndex = 0;
//Find where to start our substring for this constants name
for (int i = 0; i < enumNameCharArray.length; i++) {
if (enumNameCharArray[i] == '_') {
subStringIndex = i + 1; //Start the substring after this char
break;
}
}
return subStringIndex;
}
public String getLocaleKeyRoot()
{
return StringUtils.getCapitalized(getParentSkill().toString())+".SubSkill."+getConfigName(toString());
}
public String getLocaleName()
{
return getFromLocaleSubAddress(".Name");
}
public String getLocaleDescription()
{
return getFromLocaleSubAddress(".Description");
}
public String getLocaleStatDescription() { return getFromLocaleSubAddress(".Stat"); }
public String getLocaleKeyStatDescription() { return getLocaleKeyFromSubAddress(".Stat"); }
public String getLocaleStatExtraDescription() { return getFromLocaleSubAddress(".Stat.Extra"); }
public String getLocaleKeyStatExtraDescription() { return getLocaleKeyFromSubAddress(".Stat.Extra"); }
public String getLocaleStat(String... vars)
{
String statMsg = LocaleLoader.getString("Ability.Generic.Template", (Object[]) vars);
return statMsg;
}
public String getCustomLocaleStat(String... vars)
{
String statMsg = LocaleLoader.getString("Ability.Generic.Template.Custom", (Object[]) vars);
return statMsg;
}
private String getFromLocaleSubAddress(String s) {
return LocaleLoader.getString(getLocaleKeyRoot() + s);
}
private String getLocaleKeyFromSubAddress(String s)
{
return getLocaleKeyRoot() + s;
}
}

View File

@ -1,227 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills;
import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
public enum SuperAbilityType {
BERSERK(
"Unarmed.Skills.Berserk.On",
"Unarmed.Skills.Berserk.Off",
"Unarmed.Skills.Berserk.Other.On",
"Unarmed.Skills.Berserk.Refresh",
"Unarmed.Skills.Berserk.Other.Off"),
SUPER_BREAKER(
"Mining.Skills.SuperBreaker.On",
"Mining.Skills.SuperBreaker.Off",
"Mining.Skills.SuperBreaker.Other.On",
"Mining.Skills.SuperBreaker.Refresh",
"Mining.Skills.SuperBreaker.Other.Off"),
GIGA_DRILL_BREAKER(
"Excavation.Skills.GigaDrillBreaker.On",
"Excavation.Skills.GigaDrillBreaker.Off",
"Excavation.Skills.GigaDrillBreaker.Other.On",
"Excavation.Skills.GigaDrillBreaker.Refresh",
"Excavation.Skills.GigaDrillBreaker.Other.Off"),
GREEN_TERRA(
"Herbalism.Skills.GTe.On",
"Herbalism.Skills.GTe.Off",
"Herbalism.Skills.GTe.Other.On",
"Herbalism.Skills.GTe.Refresh",
"Herbalism.Skills.GTe.Other.Off"),
SKULL_SPLITTER(
"Axes.Skills.SS.On",
"Axes.Skills.SS.Off",
"Axes.Skills.SS.Other.On",
"Axes.Skills.SS.Refresh",
"Axes.Skills.SS.Other.Off"),
TREE_FELLER(
"Woodcutting.Skills.TreeFeller.On",
"Woodcutting.Skills.TreeFeller.Off",
"Woodcutting.Skills.TreeFeller.Other.On",
"Woodcutting.Skills.TreeFeller.Refresh",
"Woodcutting.Skills.TreeFeller.Other.Off"),
SERRATED_STRIKES(
"Swords.Skills.SS.On",
"Swords.Skills.SS.Off",
"Swords.Skills.SS.Other.On",
"Swords.Skills.SS.Refresh",
"Swords.Skills.SS.Other.Off"),
/**
* Has cooldown - but has to share a skill with Super Breaker, so needs special treatment
*/
BLAST_MINING(
null,
null,
"Mining.Blast.Other.On",
"Mining.Blast.Refresh",
null),
;
/*
* Defining their associated SubSkillType definitions
* This is a bit of a band-aid fix until the new skill system is in place
*/
static {
BERSERK.subSkillTypeDefinition = SubSkillType.UNARMED_BERSERK;
SUPER_BREAKER.subSkillTypeDefinition = SubSkillType.MINING_SUPER_BREAKER;
GIGA_DRILL_BREAKER.subSkillTypeDefinition = SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER;
GREEN_TERRA.subSkillTypeDefinition = SubSkillType.HERBALISM_GREEN_TERRA;
SKULL_SPLITTER.subSkillTypeDefinition = SubSkillType.AXES_SKULL_SPLITTER;
TREE_FELLER.subSkillTypeDefinition = SubSkillType.WOODCUTTING_TREE_FELLER;
SERRATED_STRIKES.subSkillTypeDefinition = SubSkillType.SWORDS_SERRATED_STRIKES;
BLAST_MINING.subSkillTypeDefinition = SubSkillType.MINING_BLAST_MINING;
}
private String abilityOn;
private String abilityOff;
private String abilityPlayer;
private String abilityRefresh;
private String abilityPlayerOff;
private SubSkillType subSkillTypeDefinition;
private SuperAbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
this.abilityOn = abilityOn;
this.abilityOff = abilityOff;
this.abilityPlayer = abilityPlayer;
this.abilityRefresh = abilityRefresh;
this.abilityPlayerOff = abilityPlayerOff;
}
public int getCooldown() {
return Config.getInstance().getCooldown(this);
}
public int getMaxLength() {
return Config.getInstance().getMaxLength(this);
}
public String getAbilityOn() {
return abilityOn;
}
public String getAbilityOff() {
return abilityOff;
}
public String getAbilityPlayer() {
return abilityPlayer;
}
public String getAbilityPlayerOff() {
return abilityPlayerOff;
}
public String getAbilityRefresh() {
return abilityRefresh;
}
public String getName() {
return StringUtils.getPrettyAbilityString(this);
}
@Override
public String toString() {
String baseString = name();
String[] substrings = baseString.split("_");
String formattedString = "";
int size = 1;
for (String string : substrings) {
formattedString = formattedString.concat(StringUtils.getCapitalized(string));
if (size < substrings.length) {
formattedString = formattedString.concat("_");
}
size++;
}
return formattedString;
}
/**
* Get the permissions for this ability.
*
* @param player Player to check permissions for
* @return true if the player has permissions, false otherwise
*/
public boolean getPermissions(Player player) {
switch (this) {
case BERSERK:
return Permissions.berserk(player);
case BLAST_MINING:
return Permissions.remoteDetonation(player);
case GIGA_DRILL_BREAKER:
return Permissions.gigaDrillBreaker(player);
case GREEN_TERRA:
return Permissions.greenTerra(player);
case SERRATED_STRIKES:
return Permissions.serratedStrikes(player);
case SKULL_SPLITTER:
return Permissions.skullSplitter(player);
case SUPER_BREAKER:
return Permissions.superBreaker(player);
case TREE_FELLER:
return Permissions.treeFeller(player);
default:
return false;
}
}
/**
* Check if a block is affected by this ability.
*
* @param blockState the block to check
* @return true if the block is affected by this ability, false otherwise
*/
public boolean blockCheck(BlockState blockState) {
switch (this) {
case BERSERK:
return (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW);
case GIGA_DRILL_BREAKER:
return BlockUtils.affectedByGigaDrillBreaker(blockState);
case GREEN_TERRA:
return BlockUtils.canMakeMossy(blockState);
case SUPER_BREAKER:
return BlockUtils.affectedBySuperBreaker(blockState);
case TREE_FELLER:
return BlockUtils.isLog(blockState);
default:
return false;
}
}
/**
* Grabs the associated SubSkillType definition for this SuperAbilityType
* @return the matching SubSkillType definition for this SuperAbilityType
*/
public SubSkillType getSubSkillTypeDefinition() {
return subSkillTypeDefinition;
}
}

View File

@ -1,61 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills;
import com.gmail.nossr50.util.ItemUtils;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public enum ToolType {
AXE("Axes.Ability.Lower", "Axes.Ability.Ready"),
FISTS("Unarmed.Ability.Lower", "Unarmed.Ability.Ready"),
HOE("Herbalism.Ability.Lower", "Herbalism.Ability.Ready"),
PICKAXE("Mining.Ability.Lower", "Mining.Ability.Ready"),
SHOVEL("Excavation.Ability.Lower", "Excavation.Ability.Ready"),
SWORD("Swords.Ability.Lower", "Swords.Ability.Ready");
private String lowerTool;
private String raiseTool;
private ToolType(String lowerTool, String raiseTool) {
this.lowerTool = lowerTool;
this.raiseTool = raiseTool;
}
public String getLowerTool() {
return lowerTool;
}
public String getRaiseTool() {
return raiseTool;
}
/**
* Check to see if the item is of the appropriate type.
*
* @param itemStack The item to check
* @return true if the item is the right type, false otherwise
*/
public boolean inHand(ItemStack itemStack) {
switch (this) {
case AXE:
return ItemUtils.isAxe(itemStack);
case FISTS:
return itemStack.getType() == Material.AIR;
case HOE:
return ItemUtils.isHoe(itemStack);
case PICKAXE:
return ItemUtils.isPickaxe(itemStack);
case SHOVEL:
return ItemUtils.isShovel(itemStack);
case SWORD:
return ItemUtils.isSword(itemStack);
default:
return false;
}
}
}

View File

@ -1,167 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.alchemy;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class AlchemyPotion {
private Material material;
private PotionData data;
private String name;
private List<String> lore;
private List<PotionEffect> effects;
private Color color;
private Map<ItemStack, String> children;
public AlchemyPotion(Material material, PotionData data, String name, List<String> lore, List<PotionEffect> effects, Color color, Map<ItemStack, String> children) {
this.material = material;
this.data = data;
this.lore = lore;
this.name = name;
this.effects = effects;
this.children = children;
this.color = color;
}
public String toString() {
return "AlchemyPotion{" + data + ", " + name + ", Effects[" + effects.size() + "], Children[" + children.size() + "]}";
}
public ItemStack toItemStack(int amount) {
ItemStack potion = new ItemStack(material, amount);
PotionMeta meta = (PotionMeta) potion.getItemMeta();
meta.setBasePotionData(data);
if (this.getName() != null) {
meta.setDisplayName(this.getName());
}
if (this.getLore() != null && !this.getLore().isEmpty()) {
meta.setLore(this.getLore());
}
if (!this.getEffects().isEmpty()) {
for (PotionEffect effect : this.getEffects()) {
meta.addCustomEffect(effect, true);
}
}
if (this.getColor() != null) {
meta.setColor(this.getColor());
}
potion.setItemMeta(meta);
return potion;
}
public Material getMaterial() {
return material;
}
public Potion toPotion(int amount) {
return Potion.fromItemStack(this.toItemStack(amount));
}
public PotionData getData() {
return data;
}
public void setData(PotionData data) {
this.data = data;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getLore() {
return lore;
}
public void setLore(List<String> lore) {
this.lore = lore;
}
public List<PotionEffect> getEffects() {
return effects;
}
public void setEffects(List<PotionEffect> effects) {
this.effects = effects;
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public Map<ItemStack, String> getChildren() {
return children;
}
public void setChildren(Map<ItemStack, String> children) {
this.children = children;
}
public AlchemyPotion getChild(ItemStack ingredient) {
if (!children.isEmpty()) {
for (Entry<ItemStack, String> child : children.entrySet()) {
if (ingredient.isSimilar(child.getKey())) {
return PotionConfig.getInstance().getPotion(child.getValue());
}
}
}
return null;
}
public boolean isSimilar(ItemStack item) {
if (item.getType() != material) {
return false;
}
if (!item.hasItemMeta()) {
return false;
}
PotionMeta meta = (PotionMeta) item.getItemMeta();
PotionData that = meta.getBasePotionData();
if (data.getType() != that.getType()) {
return false;
}
if (data.isExtended() != that.isExtended()) {
return false;
}
if (data.isUpgraded() != that.isUpgraded()) {
return false;
}
for (PotionEffect effect : effects) {
if (!meta.hasCustomEffect(effect.getType())) {
return false;
}
}
if (!meta.hasLore() && !lore.isEmpty()) {
return false;
}
if (!(lore.isEmpty() && !meta.hasLore()) && !meta.getLore().equals(lore)) {
return false;
}
if (!meta.hasDisplayName() && name != null) {
return false;
}
return (name == null && !meta.hasDisplayName()) || meta.getDisplayName().equals(name);
}
}

View File

@ -1,86 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.alchemy;
import org.bukkit.Material;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionType;
import java.util.List;
public enum PotionStage {
FIVE(5),
FOUR(4),
THREE(3),
TWO(2),
ONE(1);
int numerical;
private PotionStage(int numerical) {
this.numerical = numerical;
}
public int toNumerical() {
return numerical;
}
private static PotionStage getPotionStageNumerical(int numerical) {
for (PotionStage potionStage : values()) {
if (numerical >= potionStage.toNumerical()) {
return potionStage;
}
}
return ONE;
}
public static PotionStage getPotionStage(AlchemyPotion input, AlchemyPotion output) {
PotionStage potionStage = getPotionStage(output);
if (!isWaterBottle(input) && getPotionStage(input) == potionStage) {
potionStage = PotionStage.FIVE;
}
return potionStage;
}
private static boolean isWaterBottle(AlchemyPotion input) {
return input.getData().getType() == PotionType.WATER;
}
public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) {
PotionData data = alchemyPotion.getData();
List<PotionEffect> effects = alchemyPotion.getEffects();
int stage = 1;
// Check if potion has an effect of any sort
if (data.getType().getEffectType() != null || !effects.isEmpty()) {
stage++;
}
// Check if potion has a glowstone dust amplifier
// Else check if the potion has a custom effect with an amplifier added by mcMMO
if (data.isUpgraded()) {
stage++;
} else if(!effects.isEmpty()) {
for (PotionEffect effect : effects){
if(effect.getAmplifier() > 0){
stage++;
break;
}
}
}
// Check if potion has a redstone dust amplifier
if (data.isExtended()) {
stage++;
}
// Check if potion has a gunpowder amplifier
if (alchemyPotion.getMaterial() == Material.SPLASH_POTION || alchemyPotion.getMaterial() == Material.LINGERING_POTION) {
stage++;
}
return PotionStage.getPotionStageNumerical(stage);
}
}

View File

@ -1,11 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.interfaces;
import com.gmail.nossr50.core.datatypes.skills.PrimarySkillType;
public interface ChildSkill extends Skill {
/**
* Get's the other parent for this Skill
* @return the other parent
*/
PrimarySkillType getSecondParent();
}

View File

@ -1,17 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.interfaces;
import com.gmail.nossr50.core.datatypes.skills.SubSkillType;
/**
* This interface is mostly here to maintain backwards compatibility with other mcMMO plugins
* Only Core Skills will make use of this
* Previously in mcMMO subskills were basically defined by the SecondaryAbility ENUM
* In the new system which I'm gradually converting all the existing skills to, skills instead are unique instances of AbstractSubSkill
*/
public interface CoreSkill {
/**
* Gets the associated SubSkillType for this subskill
* @return the associated SubSkillType ENUM definition
*/
SubSkillType getSubSkillType();
}

View File

@ -1,19 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.interfaces;
/**
* Localized interface represents skills which have localizations
* Skills with localizations will use their localization names/descriptions when being printed
*/
public interface Localized {
/**
* The translated name for this locale
* @return the translated name for this locale
*/
String getLocaleName();
/**
* The translated name for this subskill description
* @return
*/
String getLocaleDescription();
}

View File

@ -1,17 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.interfaces;
import com.gmail.nossr50.core.datatypes.skills.PrimarySkillType;
public interface Skill {
/**
* The primary skill
* @return this primary skill
*/
PrimarySkillType getPrimarySkill();
/**
* Returns the key name used for this skill in conjunction with config files
* @return config file key name
*/
String getPrimaryKeyName();
}

View File

@ -1,20 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.interfaces;
import org.bukkit.inventory.ItemStack;
import java.util.Collection;
public interface Toolable {
/**
* Whether or not this Skill requires a tool
* Not all skills will require a tool
* @return true if tool is required
*/
boolean requiresTool();
/**
* The tools associated with this Skill
* @return the tools
*/
Collection<ItemStack> getTools();
}

View File

@ -1,17 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.progression;
import com.gmail.nossr50.core.datatypes.skills.subskills.interfaces.InteractType;
import org.bukkit.event.Event;
public interface Progression {
/**
* The interaction vector for gaining XP
* @return the interaction vector for gaining XP
*/
InteractType getXpGainInteractType();
/**
* Executes the interaction for gaining XP
*/
void doXpGainInteraction(Event event);
}

View File

@ -1,66 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.subskills;
import com.gmail.nossr50.core.config.skills.CoreSkillsConfig;
import com.gmail.nossr50.core.datatypes.skills.SubSkillType;
import com.gmail.nossr50.core.datatypes.skills.subskills.interfaces.Interaction;
import com.gmail.nossr50.core.datatypes.skills.subskills.interfaces.Rank;
import com.gmail.nossr50.core.datatypes.skills.subskills.interfaces.SubSkill;
import com.gmail.nossr50.core.datatypes.skills.subskills.interfaces.SubSkillProperties;
import com.gmail.nossr50.locale.LocaleLoader;
import org.bukkit.entity.Player;
public abstract class AbstractSubSkill implements SubSkill, Interaction, Rank, SubSkillProperties {
/*
* The name of the subskill is important is used to pull Locale strings and config settings
*/
protected String configKeySubSkill;
protected String configKeyPrimary;
protected SubSkillType subSkillType;
public AbstractSubSkill(String configKeySubSkill, String configKeyPrimary, SubSkillType subSkillType)
{
this.configKeySubSkill = configKeySubSkill;
this.configKeyPrimary = configKeyPrimary;
this.subSkillType = subSkillType;
}
/**
* Returns the simple description of this subskill from the locale
*
* @return the simple description of this subskill from the locale
*/
@Override
public String getDescription() {
return LocaleLoader.getString(getPrimaryKeyName()+".SubSkill."+getConfigKeyName()+".Description");
}
/**
* Whether or not this subskill is enabled
*
* @return true if enabled
*/
@Override @Deprecated
public boolean isEnabled() {
//TODO: This might be troublesome...
return CoreSkillsConfig.getInstance().isSkillEnabled(this);
}
/**
* Prints detailed info about this subskill to the player
*
* @param player the target player
*/
@Override
public void printInfo(Player player) {
/* DEFAULT SETTINGS PRINT THE BARE MINIMUM */
//TextComponentFactory.sendPlayerUrlHeader(player);
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", getConfigKeyName()));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));
}
public SubSkillType getSubSkillType() {
return subSkillType;
}
}

View File

@ -1,115 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.subskills.acrobatics;
import com.gmail.nossr50.core.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.core.datatypes.skills.SubSkillType;
import com.gmail.nossr50.core.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.core.datatypes.skills.subskills.interfaces.InteractType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
public abstract class AcrobaticsSubSkill extends AbstractSubSkill {
protected EventPriority interactionPriority;
public AcrobaticsSubSkill(String configKeySub, EventPriority interactionPriority, SubSkillType subSkillType) {
super(configKeySub, "Acrobatics", subSkillType);
this.interactionPriority = interactionPriority;
}
/**
* The name of this subskill
* Core mcMMO skills will pull the name from Locale with this method
*
* @return the subskill name
*/
@Override
public String getNiceName() {
return LocaleLoader.getString(getPrimaryKeyName()+".SubSkill."+getConfigKeyName()+".Name");
}
/**
* This is the name that represents our subskill in the config
*
* @return the config key name
*/
@Override
public String getConfigKeyName() {
return configKeySubSkill;
}
/**
* Grabs tips for the subskill
*
* @return tips for the subskill
*/
@Override
public String getTips() {
return LocaleLoader.getString("JSON."+ StringUtils.getCapitalized(getPrimarySkill().toString())+".SubSkill."+getConfigKeyName()+".Details.Tips");
}
/**
* The name of the primary skill
*
* @return The name of the primary skill
*/
@Override
public PrimarySkillType getPrimarySkill() {
return PrimarySkillType.ACROBATICS;
}
/**
* Returns the key name used for this skill in conjunction with config files
*
* @return config file key name
*/
@Override
public String getPrimaryKeyName() {
return configKeyPrimary;
}
/**
* The type of event used for interaction in this subskill for Minecraft
*
* @return the event for interaction
*/
@Override
public InteractType getInteractType() {
return InteractType.ON_ENTITY_DAMAGE;
}
/**
* Executes the interaction between this subskill and Minecraft
*
* @param event the vector of interaction
* @param plugin the mcMMO plugin instance
* @return true if interaction wasn't cancelled
*/
@Override
public boolean doInteraction(Event event, mcMMO plugin) {
return false;
}
/**
* The priority for this interaction
*
* @return the priority for interaction
*/
@Override
public EventPriority getEventPriority() {
return interactionPriority;
}
/**
* Not all skills have ranks
*
* @return true if the skill has ranks
*/
@Override
public boolean hasRanks() {
return (getNumRanks() > 0);
}
}

View File

@ -1,442 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.subskills.acrobatics;
import com.gmail.nossr50.core.config.skills.AdvancedConfig;
import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.datatypes.LimitedSizeList;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.interactions.NotificationType;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.util.random.RandomChanceSkill;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import net.md_5.bungee.api.chat.ComponentBuilder;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.SoundCategory;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
public class Roll extends AcrobaticsSubSkill {
protected HashMap<Player, LimitedSizeList> fallLocationMap;
public Roll() {
super("Roll", EventPriority.HIGHEST, SubSkillType.ACROBATICS_ROLL);
fallLocationMap = new HashMap<>();
}
/**
* Executes the interaction between this subskill and Minecraft
*
* @param event the vector of interaction
* @return true if interaction wasn't cancelled
*/
@Override
public boolean doInteraction(Event event, mcMMO plugin) {
//TODO: Go through and API this up
/*
* Roll is a SubSkill which allows players to negate fall damage from certain heights with sufficient Acrobatics skill and luck
* Roll is activated when a player takes damage from a fall
* If a player holds shift, they double their odds at a successful roll and upon success are told they did a graceful roll.
*/
//Casting
EntityDamageEvent entityDamageEvent = (EntityDamageEvent) event;
//Make sure a real player was damaged in this event
if(!EventUtils.isRealPlayerDamaged(entityDamageEvent))
return false;
switch (entityDamageEvent.getCause()) {
case FALL:
//Grab the player
McMMOPlayer mcMMOPlayer = EventUtils.getMcMMOPlayer(entityDamageEvent.getEntity());
/*
* Check for success
*/
Player player = (Player) ((EntityDamageEvent) event).getEntity();
if (canRoll(player)) {
entityDamageEvent.setDamage(rollCheck(player, mcMMOPlayer, entityDamageEvent.getDamage()));
if (entityDamageEvent.getFinalDamage() == 0) {
entityDamageEvent.setCancelled(true);
return true;
}
}
break;
default:
break;
}
return false;
}
/**
* Grabs the permission node for this skill
*
* @return permission node address
*/
@Override
public String getPermissionNode() {
return ("mcmmo.ability."+getPrimaryKeyName()+"."+getConfigKeyName()).toLowerCase();
}
/**
* Checks if a player has permission to use this skill
*
* @param player target player
* @return true if player has permission
*/
@Override
public boolean hasPermission(Player player) {
return Permissions.isSubSkillEnabled(player, this);
}
/**
* Adds detailed stats specific to this skill
*
* @param componentBuilder target component builder
* @param player target player
*/
@Override
public void addStats(ComponentBuilder componentBuilder, Player player) {
String rollChance, rollChanceLucky, gracefulRollChance, gracefulRollChanceLucky;
/* Values related to the player */
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
float skillValue = playerProfile.getSkillLevel(getPrimarySkill());
boolean isLucky = Permissions.lucky(player, getPrimarySkill());
String[] rollStrings = RandomChanceUtil.calculateAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL);
rollChance = rollStrings[0];
rollChanceLucky = rollStrings[1];
/*
* Graceful is double the odds of a normal roll
*/
String[] gracefulRollStrings = RandomChanceUtil.calculateAbilityDisplayValuesCustom(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL, 2.0D);
gracefulRollChance = gracefulRollStrings[0];
gracefulRollChanceLucky = gracefulRollStrings[1];
/*
* Append the messages
*/
/*componentBuilder.append(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3")));
componentBuilder.append("\n");*/
//Acrobatics.SubSkill.Roll.Chance
componentBuilder.append(LocaleLoader.getString("Acrobatics.SubSkill.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : ""));
componentBuilder.append("\n");
componentBuilder.append(LocaleLoader.getString("Acrobatics.SubSkill.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : ""));
//Activation Tips
componentBuilder.append("\n").append(LocaleLoader.getString("JSON.Hover.Tips")).append("\n");
componentBuilder.append(getTips());
componentBuilder.append("\n");
//Advanced
//Lucky Notice
if(isLucky)
{
componentBuilder.append(LocaleLoader.getString("JSON.JWrapper.Perks.Header"));
componentBuilder.append("\n");
componentBuilder.append(LocaleLoader.getString("JSON.JWrapper.Perks.Lucky", "33"));
}
}
@Override
public boolean isSuperAbility() {
return false;
}
@Override
public boolean isActiveUse() {
return true;
}
@Override
public boolean isPassive() {
return true;
}
private boolean canRoll(Player player) {
return RankUtils.hasUnlockedSubskill(player, SubSkillType.ACROBATICS_ROLL) && Permissions.isSubSkillEnabled(player, SubSkillType.ACROBATICS_ROLL);
}
/**
* Handle the damage reduction and XP gain from the Roll ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
private double rollCheck(Player player, McMMOPlayer mcMMOPlayer, double damage) {
int skillLevel = mcMMOPlayer.getSkillLevel(getPrimarySkill());
if (player.isSneaking()) {
return gracefulRollCheck(player, mcMMOPlayer, damage, skillLevel);
}
double modifiedDamage = calculateModifiedRollDamage(damage, AdvancedConfig.getInstance().getRollDamageThreshold());
if (!isFatal(player, modifiedDamage)
&& RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ACROBATICS_ROLL, player)) {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Roll.Text");
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS);
//player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
//if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
if(!isExploiting(player))
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
//}
addFallLocation(player);
return modifiedDamage;
}
else if (!isFatal(player, damage)) {
//if (!SkillUtils.cooldownExpired((long) mcMMOPlayer.getTeleportATS(), Config.getInstance().getXPAfterTeleportCooldown())) {
if(!isExploiting(player))
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
//}
}
addFallLocation(player);
return damage;
}
private int getActivationChance(McMMOPlayer mcMMOPlayer) {
return PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), getPrimarySkill());
}
/**
* Handle the damage reduction and XP gain from the Graceful Roll ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
private double gracefulRollCheck(Player player, McMMOPlayer mcMMOPlayer, double damage, int skillLevel) {
double modifiedDamage = calculateModifiedRollDamage(damage, AdvancedConfig.getInstance().getRollDamageThreshold() * 2);
RandomChanceSkill rcs = new RandomChanceSkill(player, subSkillType);
rcs.setSkillLevel(rcs.getSkillLevel() * 2); //Double the effective odds
if (!isFatal(player, modifiedDamage)
&& RandomChanceUtil.checkRandomChanceExecutionSuccess(rcs))
{
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Acrobatics.Ability.Proc");
SoundManager.sendCategorizedSound(player, player.getLocation(), SoundType.ROLL_ACTIVATED, SoundCategory.PLAYERS,0.5F);
if(!isExploiting(player))
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, true), XPGainReason.PVE);
addFallLocation(player);
return modifiedDamage;
}
else if (!isFatal(player, damage)) {
if(!isExploiting(player))
SkillUtils.applyXpGain(mcMMOPlayer, getPrimarySkill(), calculateRollXP(player, damage, false), XPGainReason.PVE);
addFallLocation(player);
}
return damage;
}
/**
* Check if the player is "farming" Acrobatics XP using
* exploits in the game.
*
* @return true if exploits are detected, false otherwise
*/
private boolean isExploiting(Player player) {
if (!Config.getInstance().getAcrobaticsPreventAFK()) {
return false;
}
if (player.getInventory().getItemInMainHand().getType() == Material.ENDER_PEARL || player.isInsideVehicle()) {
return true;
}
if(fallLocationMap.get(player) == null)
fallLocationMap.put(player, new LimitedSizeList(50));
LimitedSizeList fallLocations = fallLocationMap.get(player);
if(fallLocations.contains(getBlockLocation(player)))
return true;
return false; //NOT EXPLOITING
/*
Location fallLocation = player.getLocation();
int maxTries = Config.getInstance().getAcrobaticsAFKMaxTries();
boolean sameLocation = (lastFallLocation != null && Misc.isNear(lastFallLocation, fallLocation, 2));
fallTries = sameLocation ? Math.min(fallTries + 1, maxTries) : Math.max(fallTries - 1, 0);
lastFallLocation = fallLocation;
return fallTries + 1 > maxTries;*/
}
private float calculateRollXP(Player player, double damage, boolean isRoll) {
ItemStack boots = player.getInventory().getBoots();
float xp = (float) (damage * (isRoll ? ExperienceConfig.getInstance().getRollXPModifier() : ExperienceConfig.getInstance().getFallXPModifier()));
if (boots != null && boots.containsEnchantment(Enchantment.PROTECTION_FALL)) {
xp *= ExperienceConfig.getInstance().getFeatherFallXPModifier();
}
return xp;
}
protected static double calculateModifiedRollDamage(double damage, double damageThreshold) {
return Math.max(damage - damageThreshold, 0.0);
}
private boolean isFatal(Player player, double damage) {
return player.getHealth() - damage <= 0;
}
/**
* Gets the number of ranks for this subskill, 0 for no ranks
*
* @return the number of ranks for this subskill, 0 for no ranks
*/
@Override
public int getNumRanks() {
return 0;
}
/**
* Prints detailed info about this subskill to the player
*
* @param player the target player
*/
@Override
public void printInfo(Player player) {
//Header
super.printInfo(player);
//Start the description string.
//player.sendMessage(getDescription());
//Player stats
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Stats",
LocaleLoader.getString("Acrobatics.SubSkill.Roll.Stats", getStats(player)[0], getStats(player)[1])));
//Mechanics
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Mechanics"));
player.sendMessage(getMechanics());
}
/**
* Returns a collection of strings about how a skill works
* Used in the MMO Info command
*
* @return
*/
@Override
public String getMechanics() {
//Vars passed to locale
//0 = chance to roll at half max level
//1 = chance to roll with grace at half max level
//2 = level where maximum bonus is reached
//3 = additive chance to succeed per level
/*
Roll:
# ChanceMax: Maximum chance of rolling when on <MaxBonusLevel> or higher
# MaxBonusLevel: On this level or higher, the roll chance will not go higher than <ChanceMax>
# DamageThreshold: The max damage a player can negate with a roll
ChanceMax: 100.0
MaxBonusLevel: 100
DamageThreshold: 7.0
*/
double rollChanceHalfMax, graceChanceHalfMax, damageThreshold, chancePerLevel;
//Chance to roll at half max skill
RandomChanceSkill rollHalfMaxSkill = new RandomChanceSkill(null, subSkillType);
int halfMaxSkillValue = mcMMO.isRetroModeEnabled() ? 500 : 50;
rollHalfMaxSkill.setSkillLevel(halfMaxSkillValue);
//Chance to graceful roll at full skill
RandomChanceSkill rollGraceHalfMaxSkill = new RandomChanceSkill(null, subSkillType);
rollGraceHalfMaxSkill.setSkillLevel(halfMaxSkillValue * 2); //Double the effective odds
//Chance to roll per level
RandomChanceSkill rollOneSkillLevel = new RandomChanceSkill(null, subSkillType);
rollGraceHalfMaxSkill.setSkillLevel(1); //Level 1 skill
//Chance Stat Calculations
rollChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollHalfMaxSkill);
graceChanceHalfMax = RandomChanceUtil.getRandomChanceExecutionChance(rollGraceHalfMaxSkill);
damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
chancePerLevel = RandomChanceUtil.getRandomChanceExecutionChance(rollOneSkillLevel);
double maxLevel = AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.ACROBATICS_ROLL);
return LocaleLoader.getString("Acrobatics.SubSkill.Roll.Mechanics", rollChanceHalfMax, graceChanceHalfMax, maxLevel, chancePerLevel, damageThreshold, damageThreshold * 2);
}
/**
* Get an array of various stats for a player
*
* @param player target player
* @return stat array for target player for this skill
*/
@Override
public Double[] getStats(Player player)
{
double playerChanceRoll, playerChanceGrace;
RandomChanceSkill roll = new RandomChanceSkill(player, getSubSkillType());
RandomChanceSkill graceful = new RandomChanceSkill(player, getSubSkillType());
graceful.setSkillLevel(graceful.getSkillLevel() * 2); //Double odds
//Calculate
playerChanceRoll = RandomChanceUtil.getRandomChanceExecutionChance(roll);
playerChanceGrace = RandomChanceUtil.getRandomChanceExecutionChance(graceful);
Double[] stats = { playerChanceRoll, playerChanceGrace }; //DEBUG
return stats;
}
public void addFallLocation(Player player)
{
if(fallLocationMap.get(player) == null)
fallLocationMap.put(player, new LimitedSizeList(50));
LimitedSizeList fallLocations = fallLocationMap.get(player);
Location loc = getBlockLocation(player);
fallLocations.add(loc);
}
public Location getBlockLocation(Player player)
{
return player.getLocation().getBlock().getLocation();
}
}

View File

@ -1,14 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.subskills.interfaces;
/**
* This class is used to determine event registrations for SubSkill interactions
*/
public enum InteractType {
ON_BLOCK_BREAK,
ON_BLOCK_DAMAGE,
ON_PROJECTILE_LAUNCH,
ON_BLOCK_PLACE,
ON_ENTITY_DAMAGE,
ON_ENTITY_DAMAGE_BY_ENTITY,
ON_EXPLOSION_PRIME,
}

View File

@ -1,27 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.subskills.interfaces;
import com.gmail.nossr50.mcMMO;
import org.bukkit.event.Event;
import org.bukkit.event.EventPriority;
public interface Interaction {
/**
* The type of interaction this subskill has with Minecraft
* @return the interaction type
*/
InteractType getInteractType();
/**
* Executes the interaction between this subskill and Minecraft
* @param event the vector of interaction
* @param plugin the mcMMO plugin instance
* @return true if interaction wasn't cancelled
*/
boolean doInteraction(Event event, mcMMO plugin);
/**
* The priority for this interaction
* @return the priority for interaction
*/
EventPriority getEventPriority();
}

View File

@ -1,21 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.subskills.interfaces;
public interface Rank {
/**
* Gets the number of ranks for this subskill, 0 for no ranks
* @return the number of ranks for this subskill, 0 for no ranks
*/
int getNumRanks();
/**
* Not all skills have ranks
* @return true if the skill has ranks
*/
boolean hasRanks();
/**
* An sequential collection of rank level requirements
* @return level requirements
*/
//Collection<Integer> getUnlockLevels();
}

View File

@ -1,77 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.subskills.interfaces;
import com.gmail.nossr50.core.datatypes.skills.interfaces.Skill;
import net.md_5.bungee.api.chat.ComponentBuilder;
import org.bukkit.entity.Player;
public interface SubSkill extends Skill {
/**
* Grabs the permission node for this skill
* @return permission node address
*/
String getPermissionNode();
/**
* Returns a collection of strings about how a skill works
* @return
*/
String getMechanics();
/**
* Get an array of various stats for a player
* @param player target player
* @return stat array for target player for this skill
*/
Double[] getStats(Player player);
/**
* Checks if a player has permission to use this skill
* @param player target player
* @return true if player has permission
*/
boolean hasPermission(Player player);
/**
* The name of this subskill
* It's a good idea for this to return the localized name
* @return the subskill name
*/
String getNiceName();
/**
* This is the name that represents our subskill in the config
* @return the config key name
*/
String getConfigKeyName();
/**
* Returns the simple description of this subskill
* @return the simple description of this subskill
*/
String getDescription();
/**
* Grabs tips for the subskill
* @return tips for the subskill
*/
String getTips();
/**
* Adds detailed stats specific to this skill
* @param componentBuilder target component builder
* @param player owner of this skill
*/
void addStats(ComponentBuilder componentBuilder, Player player);
/**
* Whether or not this subskill is enabled
* @return true if enabled
*/
boolean isEnabled();
/**
* Prints detailed info about this subskill to the player
* @param player the target player
*/
void printInfo(Player player);
}

View File

@ -1,9 +0,0 @@
package com.gmail.nossr50.core.datatypes.skills.subskills.interfaces;
public interface SubSkillProperties {
boolean isSuperAbility();
boolean isActiveUse();
boolean isPassive();
}

View File

@ -1,29 +0,0 @@
package com.gmail.nossr50.core.datatypes.treasure;
import org.bukkit.enchantments.Enchantment;
public class EnchantmentTreasure {
private Enchantment enchantment;
private int level;
public EnchantmentTreasure(Enchantment enchantment, int level) {
this.setEnchantment(enchantment);
this.setLevel(level);
}
public Enchantment getEnchantment() {
return enchantment;
}
public void setEnchantment(Enchantment enchantment) {
this.enchantment = enchantment;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
}

View File

@ -1,9 +0,0 @@
package com.gmail.nossr50.core.datatypes.treasure;
import org.bukkit.inventory.ItemStack;
public class ExcavationTreasure extends Treasure {
public ExcavationTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
super(drop, xp, dropChance, dropLevel);
}
}

View File

@ -1,10 +0,0 @@
package com.gmail.nossr50.core.datatypes.treasure;
import org.bukkit.inventory.ItemStack;
public class FishingTreasure extends Treasure {
public FishingTreasure(ItemStack drop, int xp) {
super(drop, xp, 0, 0);
}
}

View File

@ -1,9 +0,0 @@
package com.gmail.nossr50.core.datatypes.treasure;
import org.bukkit.inventory.ItemStack;
public class HylianTreasure extends Treasure {
public HylianTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
super(drop, xp, dropChance, dropLevel);
}
}

View File

@ -1,19 +0,0 @@
package com.gmail.nossr50.core.datatypes.treasure;
public enum Rarity {
RECORD,
LEGENDARY,
EPIC,
RARE,
UNCOMMON,
COMMON;
public static Rarity getRarity(String string) {
try {
return valueOf(string);
}
catch (IllegalArgumentException ex) {
return COMMON;
}
}
}

View File

@ -1,9 +0,0 @@
package com.gmail.nossr50.core.datatypes.treasure;
import org.bukkit.inventory.ItemStack;
public class ShakeTreasure extends Treasure {
public ShakeTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
super(drop, xp, dropChance, dropLevel);
}
}

View File

@ -1,54 +0,0 @@
package com.gmail.nossr50.core.datatypes.treasure;
import com.gmail.nossr50.core.config.skills.Config;
import org.bukkit.inventory.ItemStack;
public abstract class Treasure {
private int xp;
private double dropChance;
private int dropLevel;
private ItemStack drop;
public Treasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
this.drop = drop;
this.xp = xp;
this.dropChance = dropChance;
this.dropLevel = dropLevel;
}
public ItemStack getDrop() {
return drop;
}
public void setDrop(ItemStack drop) {
this.drop = drop;
}
public int getXp() {
return xp;
}
public void setXp(int xp) {
this.xp = xp;
}
public double getDropChance() {
return dropChance;
}
public void setDropChance(Double dropChance) {
this.dropChance = dropChance;
}
public int getDropLevel() {
//If they are in retro mode all requirements are scaled up by 10
if(Config.getInstance().getIsRetroMode())
return dropLevel * 10;
return dropLevel;
}
public void setDropLevel(int dropLevel) {
this.dropLevel = dropLevel;
}
}