1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2026-02-18 09:43:00 +01:00

Compare commits

..

1 Commits

Author SHA1 Message Date
t00thpick1
63ae7e97e1 Ranks config idea 2013-10-04 17:52:47 -04:00
172 changed files with 3262 additions and 3408 deletions

View File

@@ -8,9 +8,6 @@ Key:
- Removal
Version 1.4.07-dev
+ Added XP boost to Acrobatics when wearing Boots of Feather Falling
+ Added SQL Database can now recover from a dropped connection without losing data. (Thanks Riking!)
+ Added more tiers to Fishing, Repair and Smelting!
+ Added Carrot on a Stick and Flint & Steel to repair.vanilla.yml
+ Added horses to the "Shake" ability
+ Added ability to summon horses via "Call of the Wild" using apples
@@ -43,16 +40,12 @@ Version 1.4.07-dev
= Fixed a bug where squid were not awarding XP.
= Fixed a bug where Combat XP was granted within 5 seconds for respawned players
= Fixed a bug where wrong feedback messages were being send when using a command on an offline player
= Fixed a bug where players were able to gain Herbalism XP in mine carts, even though Prevent_AFK_Leveling was enabled
= Fixed a bug where players would get hit by fireworks if they leveled up while in a boat
! Changed Fishing "Treasure Hunter" and "Magic Hunter" drop percentages
! Changed format of mod config files. (blocks.yml, tools.yml, armor.yml and entities.yml) **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
! Changed format of treasures.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
! Changed format of repair.vanilla.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
! Changed default XP multiplier for repairing shears
! Changed "Shake" drops for Witches. They no longer drop water bottles, since they no longer drop them in Vanilla.
! Changed various values to double in advanced.yml for the sake of consistency.
! Nerfed Fishing "Master Angler" (removed skill level based bonus) and also made the modifiers configurable
! Nerfed Archery damage to eliminate constant one-hit kills.
! Changed the way Repair hands out XP, also added config options to control Repair XP
! Changed Swords "Counter Attack" ability from passive to active. Blocking is required to activate.
@@ -60,7 +53,6 @@ Version 1.4.07-dev
! Vampirism can now be enabled without having Skill Death Penalty enabled
! Admin and Party chat prefixes are now customizable
! Changed the color of party leader names in Party chat
! Improved "Tree Feller" algorithm (Thanks Riking!)
! Improved profile saving
! Improved partial name matcher
! Improved update checker
@@ -70,7 +62,6 @@ Version 1.4.07-dev
! Mob healthbars are automatically disabled when the plugin "HealthBar" is found
- The /mmoupdate command has been removed. It is replaced by /mcconvert database
- Removed Abilities.Tools.Durability_Loss_Enabled, set Abilities.Tools.Durability_Loss to 0 to disable instead.
- Removed Skills.Fishing.Shake_UnlockLevel from advanced.yml, now using Skills.Fishing.Rank_Levels.Rank_1 instead.
- Removed SpoutPlugin support
Version 1.4.06

View File

@@ -30,14 +30,6 @@
<include>locale*.properties</include>
</includes>
</resource>
<resource>
<targetPath>mods</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources/mods</directory>
<includes>
<include>*.yml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>

View File

@@ -18,11 +18,11 @@ public final class ChatAPI {
* </br>
* This function is designed for API usage.
*
* @param plugin The plugin sending the message
* @param sender The name of the sender
* @param plugin The plugin sending the message
* @param sender The name of the sender
* @param displayName The display name of the sender
* @param party The name of the party to send to
* @param message The message to send
* @param party The name of the party to send to
* @param message The message to send
*/
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
@@ -33,9 +33,9 @@ public final class ChatAPI {
* </br>
* This function is designed for API usage.
*
* @param plugin The plugin sending the message
* @param sender The name of the sender to display in the chat
* @param party The name of the party to send to
* @param plugin The plugin sending the message
* @param sender The name of the sender to display in the chat
* @param party The name of the party to send to
* @param message The message to send
*/
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
@@ -47,10 +47,10 @@ public final class ChatAPI {
* </br>
* This function is designed for API usage.
*
* @param plugin The plugin sending the message
* @param sender The name of the sender
* @param plugin The plugin sending the message
* @param sender The name of the sender
* @param displayName The display name of the sender
* @param message The message to send
* @param message The message to send
*/
public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, displayName, message);
@@ -61,8 +61,8 @@ public final class ChatAPI {
* </br>
* This function is designed for API usage.
*
* @param plugin The plugin sending the message
* @param sender The name of the sender to display in the chat
* @param plugin The plugin sending the message
* @param sender The name of the sender to display in the chat
* @param message The message to send
*/
public static void sendAdminChat(Plugin plugin, String sender, String message) {
@@ -73,7 +73,6 @@ public final class ChatAPI {
* Check if a player is currently talking in party chat.
*
* @param player The player to check
*
* @return true if the player is using party chat, false otherwise
*/
public static boolean isUsingPartyChat(Player player) {
@@ -84,7 +83,6 @@ public final class ChatAPI {
* Check if a player is currently talking in party chat.
*
* @param playerName The name of the player to check
*
* @return true if the player is using party chat, false otherwise
*/
public static boolean isUsingPartyChat(String playerName) {
@@ -95,7 +93,6 @@ public final class ChatAPI {
* Check if a player is currently talking in admin chat.
*
* @param player The player to check
*
* @return true if the player is using admin chat, false otherwise
*/
public static boolean isUsingAdminChat(Player player) {
@@ -106,7 +103,6 @@ public final class ChatAPI {
* Check if a player is currently talking in admin chat.
*
* @param playerName The name of the player to check
*
* @return true if the player is using admin chat, false otherwise
*/
public static boolean isUsingAdminChat(String playerName) {

View File

@@ -24,7 +24,6 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param skillType A string that may or may not be a skill
*
* @return true if this is a valid mcMMO skill
*/
public static boolean isValidSkillType(String skillType) {
@@ -39,15 +38,12 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param skillType the skill to check
*
* @return true if this is a valid, non-child mcMMO skill
*/
public static boolean isNonChildSkill(String skillType) {
SkillType skill = SkillType.getSkill(skillType);
if (skill == null) {
return false;
}
if (skill == null) return false;
return !skill.isChildSkill();
}
@@ -62,9 +58,9 @@ public final class ExperienceAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to add XP to
* @param player The player to add XP to
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
* @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid
*/
@@ -83,10 +79,10 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The player to add XP to
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
*/
public static void addRawXPOffline(String playerName, String skillType, float XP) {
@@ -98,9 +94,9 @@ public final class ExperienceAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to add XP to
* @param player The player to add XP to
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
* @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid
*/
@@ -114,10 +110,10 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The player to add XP to
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
*/
public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
@@ -129,9 +125,9 @@ public final class ExperienceAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to add XP to
* @param player The player to add XP to
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
* @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid
*/
@@ -147,10 +143,10 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The player to add XP to
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
*/
public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
@@ -165,9 +161,9 @@ public final class ExperienceAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to add XP to
* @param player The player to add XP to
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
* @param XP The amount of XP to add
*
* @throws InvalidSkillException if the given skill is not valid
*/
@@ -180,12 +176,11 @@ public final class ExperienceAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to get XP for
* @param player The player to get XP for
* @param skillType The skill to get XP for
*
* @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidSkillException if the given skill is not valid
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static int getXP(Player player, String skillType) {
@@ -198,12 +193,11 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The player to get XP for
* @param skillType The skill to get XP for
*
* @param skillType The skill to get XP for
* @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static int getOfflineXP(String playerName, String skillType) {
@@ -215,12 +209,11 @@ public final class ExperienceAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to get XP for
* @param player The player to get XP for
* @param skillType The skill to get XP for
*
* @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidSkillException if the given skill is not valid
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static float getXPRaw(Player player, String skillType) {
@@ -233,12 +226,11 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The player to get XP for
* @param skillType The skill to get XP for
*
* @param skillType The skill to get XP for
* @return the amount of XP in a given skill
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static float getOfflineXPRaw(String playerName, String skillType) {
@@ -250,12 +242,11 @@ public final class ExperienceAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to get the XP amount for
* @param player The player to get the XP amount for
* @param skillType The skill to get the XP amount for
*
* @return the total amount of XP needed to reach the next level
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidSkillException if the given skill is not valid
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static int getXPToNextLevel(Player player, String skillType) {
@@ -268,12 +259,11 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The player to get XP for
* @param skillType The skill to get XP for
*
* @param skillType The skill to get XP for
* @return the total amount of XP needed to reach the next level
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static int getOfflineXPToNextLevel(String playerName, String skillType) {
@@ -285,12 +275,11 @@ public final class ExperienceAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to get the XP amount for
* @param player The player to get the XP amount for
* @param skillType The skill to get the XP amount for
*
* @return the amount of XP remaining until the next level
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidSkillException if the given skill is not valid
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static int getXPRemaining(Player player, String skillType) {
@@ -307,12 +296,11 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The player to get XP for
* @param skillType The skill to get XP for
*
* @param skillType The skill to get XP for
* @return the amount of XP needed to reach the next level
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static int getOfflineXPRemaining(String playerName, String skillType) {
@@ -328,9 +316,9 @@ public final class ExperienceAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to add levels to
* @param player The player to add levels to
* @param skillType Type of skill to add levels to
* @param levels Number of levels to add
* @param levels Number of levels to add
*
* @throws InvalidSkillException if the given skill is not valid
*/
@@ -344,10 +332,10 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The player to add levels to
* @param skillType Type of skill to add levels to
* @param levels Number of levels to add
* @param skillType Type of skill to add levels to
* @param levels Number of levels to add
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
*/
public static void addLevelOffline(String playerName, String skillType, int levels) {
@@ -374,9 +362,8 @@ public final class ExperienceAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to get the level for
* @param player The player to get the level for
* @param skillType The skill to get the level for
*
* @return the level of a given skill
*
* @throws InvalidSkillException if the given skill is not valid
@@ -391,11 +378,10 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The player to get the level for
* @param skillType The skill to get the level for
*
* @param skillType The skill to get the level for
* @return the level of a given skill
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
*/
public static int getLevelOffline(String playerName, String skillType) {
@@ -408,7 +394,6 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param player The player to get the power level for
*
* @return the power level of the player
*/
public static int getPowerLevel(Player player) {
@@ -421,7 +406,6 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The player to get the power level for
*
* @return the power level of the player
*
* @throws InvalidPlayerException if the given player does not exist in the database
@@ -430,7 +414,7 @@ public final class ExperienceAPI {
int powerLevel = 0;
PlayerProfile profile = getOfflineProfile(playerName);
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
for (SkillType type : SkillType.nonChildSkills()) {
powerLevel += profile.getSkillLevel(type);
}
@@ -443,7 +427,6 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param skillType The skill to get the level cap for
*
* @return the level cap of a given skill
*
* @throws InvalidSkillException if the given skill is not valid
@@ -469,13 +452,13 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The name of the player to check
* @param skillType The skill to check
* @param skillType The skill to check
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*
* @return the position on the leaderboard
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static int getPlayerRankSkill(String playerName, String skillType) {
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType).toString());
@@ -489,9 +472,9 @@ public final class ExperienceAPI {
*
* @param playerName The name of the player to check
*
* @return the position on the power level leaderboard
*
* @throws InvalidPlayerException if the given player does not exist in the database
*
* @return the position on the power level leaderboard
*/
public static int getPlayerRankOverall(String playerName) {
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get("ALL");
@@ -502,8 +485,8 @@ public final class ExperienceAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to set the level of
* @param skillType The skill to set the level for
* @param player The player to set the level of
* @param skillType The skill to set the level for
* @param skillLevel The value to set the level to
*
* @throws InvalidSkillException if the given skill is not valid
@@ -518,10 +501,10 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The player to set the level of
* @param skillType The skill to set the level for
* @param skillType The skill to set the level for
* @param skillLevel The value to set the level to
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
*/
public static void setLevelOffline(String playerName, String skillType, int skillLevel) {
@@ -533,11 +516,11 @@ public final class ExperienceAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to set the XP of
* @param player The player to set the XP of
* @param skillType The skill to set the XP for
* @param newValue The value to set the XP to
* @param newValue The value to set the XP to
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidSkillException if the given skill is not valid
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static void setXP(Player player, String skillType, int newValue) {
@@ -550,11 +533,11 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The player to set the XP of
* @param skillType The skill to set the XP for
* @param newValue The value to set the XP to
* @param skillType The skill to set the XP for
* @param newValue The value to set the XP to
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static void setXPOffline(String playerName, String skillType, int newValue) {
@@ -566,11 +549,11 @@ public final class ExperienceAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to change the XP of
* @param player The player to change the XP of
* @param skillType The skill to change the XP for
* @param xp The amount of XP to remove
* @param xp The amount of XP to remove
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidSkillException if the given skill is not valid
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static void removeXP(Player player, String skillType, int xp) {
@@ -583,11 +566,11 @@ public final class ExperienceAPI {
* This function is designed for API usage.
*
* @param playerName The player to change the XP of
* @param skillType The skill to change the XP for
* @param xp The amount of XP to remove
* @param skillType The skill to change the XP for
* @param xp The amount of XP to remove
*
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
* @throws UnsupportedOperationException if the given skill is a child skill
*/
public static void removeXPOffline(String playerName, String skillType, int xp) {

View File

@@ -21,7 +21,6 @@ public final class PartyAPI {
* This function is designed for API usage.
*
* @param player The player to check the party name of
*
* @return the name of the player's party, or null if not in a party
*/
public static String getPartyName(Player player) {
@@ -38,7 +37,6 @@ public final class PartyAPI {
* This function is designed for API usage.
*
* @param player The player to check
*
* @return true if the player is in a party, false otherwise
*/
public static boolean inParty(Player player) {
@@ -52,7 +50,6 @@ public final class PartyAPI {
*
* @param playera The first player to check
* @param playerb The second player to check
*
* @return true if the two players are in the same party, false otherwise
*/
public static boolean inSameParty(Player playera, Player playerb) {
@@ -75,7 +72,7 @@ public final class PartyAPI {
* </br>
* This function is designed for API usage.
*
* @param player The player to add to the party
* @param player The player to add to the party
* @param partyName The party to add the player to
*/
public static void addToParty(Player player, String partyName) {
@@ -105,7 +102,6 @@ public final class PartyAPI {
* This function is designed for API usage.
*
* @param partyName The party name
*
* @return the leader of the party
*/
public static String getPartyLeader(String partyName) {
@@ -118,7 +114,7 @@ public final class PartyAPI {
* This function is designed for API usage.
*
* @param partyName The name of the party to set the leader of
* @param player The player to set as leader
* @param player The player to set as leader
*/
public static void setPartyLeader(String partyName, String player) {
PartyManager.setPartyLeader(player, PartyManager.getParty(partyName));
@@ -130,7 +126,6 @@ public final class PartyAPI {
* This function is designed for API usage.
*
* @param player The player to check
*
* @return all the players in the player's party
*/
@Deprecated
@@ -150,7 +145,6 @@ public final class PartyAPI {
* This function is designed for API usage.
*
* @param player The player to check
*
* @return all the player names in the player's party
*/
public static LinkedHashSet<String> getMembers(Player player) {
@@ -163,7 +157,6 @@ public final class PartyAPI {
* This function is designed for API usage.
*
* @param partyName The party to check
*
* @return all online players in this party
*/
public static List<Player> getOnlineMembers(String partyName) {
@@ -176,7 +169,6 @@ public final class PartyAPI {
* This function is designed for API usage.
*
* @param player The player to check
*
* @return all online players in the player's party
*/
public static List<Player> getOnlineMembers(Player player) {

View File

@@ -27,7 +27,7 @@ public class PartyChatManager extends ChatManager {
@Override
protected void sendMessage() {
if (Config.getInstance().getPartyChatColorLeaderName() && senderName.equalsIgnoreCase(party.getLeader())) {
message = message.replaceFirst(displayName, ChatColor.GOLD + displayName + ChatColor.RESET);
message = message.replaceAll(displayName, ChatColor.GOLD + displayName + ChatColor.RESET);
}
for (Player member : party.getOnlineMembers()) {

View File

@@ -24,6 +24,6 @@ public class McabilityCommand extends ToggleCommand {
@Override
protected void sendSuccessMessage(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle"));
sender.sendMessage("Ability use has been toggled for " + player.getName()); // TODO: Localize
}
}

View File

@@ -24,6 +24,6 @@ public class McgodCommand extends ToggleCommand {
@Override
protected void sendSuccessMessage(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Success"));
sender.sendMessage("God mode has been toggled for " + player.getName()); // TODO: Localize
}
}

View File

@@ -12,7 +12,6 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@@ -45,11 +44,11 @@ public class MobhealthCommand implements TabExecutor {
try {
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
playerProfile.setMobHealthbarType(type);
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Changed." + type.name()));
sender.sendMessage("Display type changed to: " + type); //TODO: Localize
return true;
}
catch (IllegalArgumentException ex) {
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Invalid"));
sender.sendMessage("Invalid type!"); //TODO: Localize
return true;
}

View File

@@ -80,10 +80,7 @@ public abstract class ToggleCommand implements TabExecutor {
}
protected abstract boolean hasOtherPermission(CommandSender sender);
protected abstract boolean hasSelfPermission(CommandSender sender);
protected abstract void applyCommandAction();
protected abstract void sendSuccessMessage(CommandSender sender);
}

View File

@@ -22,7 +22,7 @@ public class ConvertDatabaseCommand implements CommandExecutor {
DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) {
if ((newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1])) || previousType == newType) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString()));
return true;
}
@@ -39,12 +39,17 @@ public class ConvertDatabaseCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
}
catch (Exception e) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
try {
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
}
catch (Throwable e) {
e.printStackTrace();
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
catch (Throwable t) {
sender.sendMessage("An error occurred during the conversion process."); // TODO: Localize
return true;
}
}

View File

@@ -45,7 +45,7 @@ public class McconvertCommand implements TabExecutor {
}
// Custom stuff
databaseTypes.remove(DatabaseType.CUSTOM.toString());
databaseTypes.remove(DatabaseType.CUSTOM);
if (mcMMO.getDatabaseManager().getDatabaseType() == DatabaseType.CUSTOM) {
databaseTypes.add(DatabaseManagerFactory.getCustomDatabaseManagerClass().getName());

View File

@@ -2,10 +2,12 @@ package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class AddlevelsCommand extends ExperienceCommand {
@Override
@@ -20,14 +22,11 @@ public class AddlevelsCommand extends ExperienceCommand {
@Override
protected void handleCommand(SkillType skill) {
float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.addLevels(skill, value);
if (player == null) {
return;
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value));
}
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, true);
}
@Override
@@ -37,6 +36,6 @@ public class AddlevelsCommand extends ExperienceCommand {
@Override
protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getSkillName()));
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, SkillUtils.getSkillName(skill)));
}
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class AddxpCommand extends ExperienceCommand {
@Override
@@ -34,6 +35,6 @@ public class AddxpCommand extends ExperienceCommand {
@Override
protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getSkillName()));
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, SkillUtils.getSkillName(skill)));
}
}

View File

@@ -18,6 +18,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
@@ -108,13 +109,9 @@ public abstract class ExperienceCommand implements TabExecutor {
}
protected abstract boolean permissionsCheckSelf(CommandSender sender);
protected abstract boolean permissionsCheckOthers(CommandSender sender);
protected abstract void handleCommand(SkillType skill);
protected abstract void handlePlayerMessageAll();
protected abstract void handlePlayerMessageSkill();
private boolean validateArguments(CommandSender sender, String skillName, String value) {
@@ -152,7 +149,7 @@ public abstract class ExperienceCommand implements TabExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getSkillName(), playerName));
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillUtils.getSkillName(skill), playerName));
}
}

View File

@@ -2,10 +2,13 @@ package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class MmoeditCommand extends ExperienceCommand {
@Override
@@ -20,16 +23,20 @@ public class MmoeditCommand extends ExperienceCommand {
@Override
protected void handleCommand(SkillType skill) {
int skillLevel = profile.getSkillLevel(skill);
float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.modifySkill(skill, value);
if (player == null || value == skillLevel) {
if (player == null) {
return;
}
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, value > skillLevel);
int skillLevel = profile.getSkillLevel(skill);
if (value > skillLevel) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - skillLevel));
}
else if (value < skillLevel) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, skillLevel - value));
}
}
@Override
@@ -39,6 +46,6 @@ public class MmoeditCommand extends ExperienceCommand {
@Override
protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getSkillName(), value));
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillUtils.getSkillName(skill), value));
}
}

View File

@@ -6,12 +6,13 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
public class SkillresetCommand extends ExperienceCommand {
private CommandSender sender;
@@ -102,16 +103,11 @@ public class SkillresetCommand extends ExperienceCommand {
return;
}
int levelsRemoved = profile.getSkillLevel(skill);
float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.modifySkill(skill, 0);
if (player == null) {
return;
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, profile.getSkillLevel(skill)));
}
EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false);
}
@Override
@@ -121,6 +117,6 @@ public class SkillresetCommand extends ExperienceCommand {
@Override
protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getSkillName()));
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", SkillUtils.getSkillName(skill)));
}
}

View File

@@ -50,12 +50,12 @@ public class HardcoreCommand extends HardcoreModeCommand {
private void toggle(boolean enable) {
if (skill.equalsIgnoreCase("ALL")) {
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
skillType.setHardcoreStatLossEnabled(enable);
for (SkillType skillType : SkillType.nonChildSkills()) {
Config.getInstance().setHardcoreStatLossEnabled(skillType, enable);
}
}
else {
SkillType.getSkill(skill).setHardcoreStatLossEnabled(enable);
Config.getInstance().setHardcoreStatLossEnabled(SkillType.getSkill(skill), enable);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), skill));

View File

@@ -129,15 +129,10 @@ public abstract class HardcoreModeCommand implements TabExecutor {
}
protected abstract boolean checkTogglePermissions();
protected abstract boolean checkModifyPermissions();
protected abstract boolean checkEnabled(String skill);
protected abstract void enable(String skill);
protected abstract void disable(String skill);
protected abstract void modify();
private boolean isInvalidPercentage(CommandSender sender, String value) {

View File

@@ -48,16 +48,16 @@ public class VampirismCommand extends HardcoreModeCommand {
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
}
private void toggle(boolean enable) {
private void toggle(boolean enabled) {
if (skill.equalsIgnoreCase("ALL")) {
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
skillType.setHardcoreVampirismEnabled(enable);
for (SkillType skillType : SkillType.nonChildSkills()) {
Config.getInstance().setHardcoreVampirismEnabled(skillType, enabled);
}
}
else {
SkillType.getSkill(skill).setHardcoreVampirismEnabled(enable);
Config.getInstance().setHardcoreVampirismEnabled(SkillType.getSkill(skill), enabled);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), skill));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enabled ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), skill));
}
}

View File

@@ -14,10 +14,10 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
@@ -177,7 +177,25 @@ public class PtpCommand implements TabExecutor {
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
}
else {
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
}
}
public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName());
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
teleportingPlayer.teleport(targetPlayer);
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Player", targetPlayer.getName()));
targetPlayer.sendMessage(LocaleLoader.getString("Party.Teleport.Target", teleportingPlayer.getName()));
mcMMOPlayer.actualizePtpLastUse();
}
}

View File

@@ -52,20 +52,22 @@ public class InspectCommand implements TabExecutor {
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
for (SkillType skill : SkillType.GATHERING_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
CommandUtils.displaySkill(sender, profile, SkillType.EXCAVATION);
CommandUtils.displaySkill(sender, profile, SkillType.FISHING);
CommandUtils.displaySkill(sender, profile, SkillType.HERBALISM);
CommandUtils.displaySkill(sender, profile, SkillType.MINING);
CommandUtils.displaySkill(sender, profile, SkillType.WOODCUTTING);
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
for (SkillType skill : SkillType.COMBAT_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
CommandUtils.displaySkill(sender, profile, SkillType.AXES);
CommandUtils.displaySkill(sender, profile, SkillType.ARCHERY);
CommandUtils.displaySkill(sender, profile, SkillType.SWORDS);
CommandUtils.displaySkill(sender, profile, SkillType.TAMING);
CommandUtils.displaySkill(sender, profile, SkillType.UNARMED);
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
for (SkillType skill : SkillType.MISC_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
CommandUtils.displaySkill(sender, profile, SkillType.ACROBATICS);
CommandUtils.displaySkill(sender, profile, SkillType.REPAIR);
}
else {
Player target = mcMMOPlayer.getPlayer();

View File

@@ -4,32 +4,22 @@ import org.bukkit.block.Biome;
import org.bukkit.entity.EntityType;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.fishing.Fishing;
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
public class FishingCommand extends SkillCommand {
private int lootTier;
private String magicChance;
private String magicChanceLucky;
private String chanceRaining = "";
private String shakeChance;
private String shakeChanceLucky;
private int fishermansDietRank;
private String biteChance;
private String trapTreasure;
private String commonTreasure;
private String uncommonTreasure;
private String rareTreasure;
private String epicTreasure;
private String legendaryTreasure;
private String recordTreasure;
private String magicChance;
private boolean canTreasureHunt;
private boolean canMagicHunt;
private boolean canShake;
@@ -48,24 +38,16 @@ public class FishingCommand extends SkillCommand {
// TREASURE HUNTER
if (canTreasureHunt) {
lootTier = mcMMOPlayer.getFishingManager().getLootTier();
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
// Item drop rates
trapTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.TRAP))[0];
commonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON))[0];
uncommonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON))[0];
rareTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE))[0];
epicTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC))[0];
legendaryTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY))[0];
recordTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD))[0];
if (isStorming) {
chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining");
enchantChance *= 1.1D;
}
// Magic hunter drop rates
double commonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.COMMON);
double uncommonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.UNCOMMON);
double rareEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.RARE);
double epicEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.EPIC);
double legendaryEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.LEGENDARY);
magicChance = calculateAbilityDisplayValues(commonEnchantment + uncommonEnchantment + rareEnchantment + epicEnchantment + legendaryEnchantment)[0];
String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance);
magicChance = treasureHunterStrings[0];
magicChanceLucky = treasureHunterStrings[1];
}
// SHAKE
@@ -82,15 +64,15 @@ public class FishingCommand extends SkillCommand {
// MASTER ANGLER
if (canMasterAngler) {
double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
double rawBiteChance = ((Math.max((skillValue / 200.0), 1.0)) / (isStorming ? 300 : 500));
Biome biome = player.getLocation().getBlock().getBiome();
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
rawBiteChance = rawBiteChance * 2.0;
}
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
rawBiteChance = rawBiteChance * 2.0;
}
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0)[0];
@@ -124,14 +106,6 @@ public class FishingCommand extends SkillCommand {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
}
if (canIceFish) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
}
if (canMasterAngler) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
}
if (canShake) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
}
@@ -139,6 +113,14 @@ public class FishingCommand extends SkillCommand {
if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
}
if (canMasterAngler) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
}
if (canIceFish) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
}
}
@Override
@@ -148,39 +130,20 @@ public class FishingCommand extends SkillCommand {
@Override
protected void statsDisplay() {
if (canMasterAngler) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
}
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier, Tier.EIGHT.toNumerical()));
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.DropRate", trapTreasure, commonTreasure, uncommonTreasure, rareTreasure, epicTreasure, legendaryTreasure, recordTreasure));
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier));
}
if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.MagicRate", magicChance));
}
if (canIceFish) {
int unlockLevel = AdvancedConfig.getInstance().getIceFishingUnlockLevel();
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing"));
}
}
if (canMasterAngler) {
int unlockLevel = AdvancedConfig.getInstance().getMasterAnglerUnlockLevel();
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.2", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
}
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", magicChanceLucky) : ""));
}
if (canShake) {
int unlockLevel = AdvancedConfig.getInstance().getFishingTierLevel(Tier.ONE);
int unlockLevel = AdvancedConfig.getInstance().getShakeUnlockLevel();
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
@@ -193,5 +156,16 @@ public class FishingCommand extends SkillCommand {
if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
}
if (canIceFish) {
int unlockLevel = AdvancedConfig.getInstance().getIceFishingUnlockLevel();
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing"));
}
}
}
}

View File

@@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Permissions;
@@ -115,18 +114,18 @@ public class MiningCommand extends SkillCommand {
}
if (canBlast) {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.ONE);
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank1();
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, Tier.EIGHT.toNumerical(), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
}
}
if (canBiggerBombs) {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.TWO);
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank2();
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
@@ -137,7 +136,7 @@ public class MiningCommand extends SkillCommand {
}
if (canDemoExpert) {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.FOUR);
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank4();
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));

View File

@@ -6,10 +6,9 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.repair.ArcaneForging;
import com.gmail.nossr50.skills.repair.ArcaneForging.Tier;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.util.Permissions;
public class RepairCommand extends SkillCommand {
@@ -146,7 +145,7 @@ public class RepairCommand extends SkillCommand {
if (canArcaneForge) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank(), Tier.EIGHT.toNumerical()));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank()));
if (ArcaneForging.arcaneForgingEnchantLoss) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance())));

View File

@@ -23,6 +23,7 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
@@ -45,7 +46,7 @@ public abstract class SkillCommand implements TabExecutor {
public SkillCommand(SkillType skill) {
this.skill = skill;
skillName = skill.getSkillName();
skillName = SkillUtils.getSkillName(skill);
skillGuideCommand = new SkillGuideCommand(skill);
}
@@ -90,7 +91,7 @@ public abstract class SkillCommand implements TabExecutor {
Set<SkillType> parents = FamilyTree.getParents(skill);
for (SkillType parent : parents) {
player.sendMessage(parent.getSkillName() + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
player.sendMessage(SkillUtils.getSkillName(parent) + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
}
}
@@ -150,7 +151,7 @@ public abstract class SkillCommand implements TabExecutor {
length = Math.min(length, maxLength);
}
return new String[]{String.valueOf(length), String.valueOf(enduranceLength)};
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
}
protected void luckyEffectsDisplay() {

View File

@@ -1,7 +1,6 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.Arrays;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -10,16 +9,17 @@ import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class SkillGuideCommand implements CommandExecutor {
private String header;
private ArrayList<String> guide;
private String[] guide;
private String invalidPage;
public SkillGuideCommand(SkillType skillType) {
header = LocaleLoader.getString("Guides.Header", skillType.getSkillName());
guide = getGuide(skillType);
header = LocaleLoader.getString("Guides.Header", SkillUtils.getSkillName(skillType));
guide = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString())).split("\n");
invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
}
@@ -59,7 +59,7 @@ public class SkillGuideCommand implements CommandExecutor {
}
private int getTotalPageNumber() {
return (int) Math.ceil(guide.size() / 8.0);
return (int) Math.ceil(guide.length / 8.0);
}
private void sendGuide(CommandSender sender, int pageNumber) {
@@ -76,38 +76,15 @@ public class SkillGuideCommand implements CommandExecutor {
// Add targeted strings
while (allStrings.size() < 9) {
if (pageIndexStart + allStrings.size() > guide.size()) {
if (pageIndexStart + allStrings.size() > guide.length) {
allStrings.add("");
}
else {
allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1)));
allStrings.add(guide[pageIndexStart + (allStrings.size() - 1)]);
}
}
allStrings.add("Page " + pagenum + " of " + getTotalPageNumber());
return allStrings;
}
private ArrayList<String> getGuide(SkillType skillType) {
ArrayList<String> guide = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString()) + ".Section." + i).split("\n");
if (section[0].startsWith("!")) {
break;
}
guide.addAll(Arrays.asList(section));
if (section.length < 8) {
for (int blankLine = 8 - section.length; blankLine > 0; blankLine--) {
guide.add("");
}
}
}
return guide;
}
}

View File

@@ -4,7 +4,6 @@ import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.smelting.Smelting;
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
import com.gmail.nossr50.util.Permissions;
public class SmeltingCommand extends SkillCommand {
@@ -95,7 +94,7 @@ public class SmeltingCommand extends SkillCommand {
}
if (canVanillaXPBoost) {
int unlockLevel = AdvancedConfig.getInstance().getSmeltingRankLevel(Tier.ONE);
int unlockLevel = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level();
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel)));

File diff suppressed because it is too large Load Diff

View File

@@ -328,7 +328,7 @@ public class Config extends AutoUpdateConfigLoader {
public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
/* Durability Settings */
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); }
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); }
/* Thresholds */
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }

View File

@@ -1,6 +1,11 @@
package com.gmail.nossr50.config;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import org.bukkit.configuration.file.FileConfiguration;
@@ -11,7 +16,7 @@ import com.gmail.nossr50.mcMMO;
public abstract class ConfigLoader {
protected static final mcMMO plugin = mcMMO.p;
protected String fileName;
private File configFile;
protected File configFile;
protected FileConfiguration config;
public ConfigLoader(String relativePath, String fileName) {
@@ -29,7 +34,7 @@ public abstract class ConfigLoader {
protected void loadFile() {
if (!configFile.exists()) {
plugin.debug("Creating mcMMO " + fileName + " File...");
plugin.saveResource(configFile.getPath(), false);
createFile();
}
else {
plugin.debug("Loading mcMMO " + fileName + " File...");
@@ -40,6 +45,53 @@ public abstract class ConfigLoader {
protected abstract void loadKeys();
protected void createFile() {
configFile.getParentFile().mkdirs();
InputStream inputStream = plugin.getResource(fileName);
if (inputStream == null) {
plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors");
return;
}
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream(configFile);
int read;
byte[] bytes = new byte[1024];
while ((read = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
finally {
if (outputStream != null) {
try {
outputStream.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
try {
inputStream.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
protected boolean validateKeys() {
return true;
}
@@ -66,19 +118,4 @@ public abstract class ConfigLoader {
public File getFile() {
return configFile;
}
public void backup() {
plugin.getLogger().warning("You are using an old version of the " + fileName + " file.");
plugin.getLogger().warning("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
configFile.renameTo(new File(configFile.getPath() + ".old"));
if (plugin.getResource(fileName) != null) {
plugin.saveResource(fileName, true);
}
plugin.getLogger().warning("Reloading " + fileName + " with new values...");
loadFile();
loadKeys();
}
}

View File

@@ -9,7 +9,7 @@ import org.bukkit.entity.EntityType;
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
import com.gmail.nossr50.skills.repair.RepairMaterialType;
import com.gmail.nossr50.util.StringUtils;
public class ExperienceConfig extends AutoUpdateConfigLoader {
@@ -85,18 +85,6 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
reason.add("Experience.Combat.Multiplier.Wither_Skeleton should be at least 0!");
}
if (getDodgeXPModifier() < 0) {
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
}
if (getRollXPModifier() < 0) {
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
}
if (getFallXPModifier() < 0) {
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
}
/* Fishing */
if (getFishingBaseXP() <= 0) {
reason.add("Experience.Fishing.Base should be greater than 0!");
@@ -188,13 +176,6 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
/* Materials */
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
/* Acrobatics */
public int getDodgeXPModifier() { return config.getInt("Experience.Acrobatics.Dodge", 120); }
public int getRollXPModifier() { return config.getInt("Experience.Acrobatics.Roll", 80); }
public int getFallXPModifier() { return config.getInt("Experience.Acrobatics.Fall", 120); }
public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); }
/* Fishing */
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }

View File

@@ -10,16 +10,14 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
import com.gmail.nossr50.skills.repair.RepairItemType;
import com.gmail.nossr50.skills.repair.RepairMaterialType;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableFactory;
public class CustomArmorConfig extends ConfigLoader {
private static CustomArmorConfig instance;
private boolean needsUpdate = false;
private List<Repairable> repairables;
private List<Material> customBoots = new ArrayList<Material>();
@@ -28,7 +26,7 @@ public class CustomArmorConfig extends ConfigLoader {
private List<Material> customLeggings = new ArrayList<Material>();
public CustomArmorConfig() {
super("mods", "armor.yml");
super("ModConfigs", "armor.yml");
loadKeys();
}
@@ -52,17 +50,10 @@ public class CustomArmorConfig extends ConfigLoader {
protected void loadKeys() {
repairables = new ArrayList<Repairable>();
while (!needsUpdate) {
loadArmor("Boots", customBoots);
loadArmor("Chestplates", customChestplates);
loadArmor("Helmets", customHelmets);
loadArmor("Leggings", customLeggings);
}
if (needsUpdate) {
needsUpdate = false;
backup();
}
loadArmor("Boots", customBoots);
loadArmor("Chestplates", customChestplates);
loadArmor("Helmets", customHelmets);
loadArmor("Leggings", customLeggings);
}
private void loadArmor(String armorType, List<Material> materialList) {
@@ -75,11 +66,6 @@ public class CustomArmorConfig extends ConfigLoader {
Set<String> armorConfigSet = armorSection.getKeys(false);
for (String armorName : armorConfigSet) {
if (config.contains(armorType + "." + armorName + "." + ".ID")) {
needsUpdate = true;
return;
}
Material armorMaterial = Material.matchMaterial(armorName);
if (armorMaterial == null) {

View File

@@ -7,6 +7,7 @@ import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.config.ConfigLoader;
@@ -15,8 +16,6 @@ import com.gmail.nossr50.datatypes.mods.CustomBlock;
public class CustomBlockConfig extends ConfigLoader {
private static CustomBlockConfig instance;
private boolean needsUpdate = false;
private List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
private List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
private List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
@@ -29,7 +28,7 @@ public class CustomBlockConfig extends ConfigLoader {
private HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
public CustomBlockConfig() {
super("mods", "blocks.yml");
super("ModConfigs", "blocks.yml");
loadKeys();
}
@@ -43,18 +42,11 @@ public class CustomBlockConfig extends ConfigLoader {
@Override
protected void loadKeys() {
while (!needsUpdate) {
loadBlocks("Excavation", customExcavationBlocks);
loadBlocks("Herbalism", customHerbalismBlocks);
loadBlocks("Mining", customMiningBlocks);
loadBlocks("Woodcutting", customWoodcuttingBlocks);
loadBlocks("Ability_Blocks", customAbilityBlocks);
}
if (needsUpdate) {
needsUpdate = false;
backup();
}
loadBlocks("Excavation", customExcavationBlocks);
loadBlocks("Herbalism", customHerbalismBlocks);
loadBlocks("Mining", customMiningBlocks);
loadBlocks("Woodcutting", customWoodcuttingBlocks);
loadBlocks("Ability_Blocks", customAbilityBlocks);
}
private void loadBlocks(String skillType, List<MaterialData> blockList) {
@@ -67,11 +59,6 @@ public class CustomBlockConfig extends ConfigLoader {
Set<String> skillConfigSet = skillSection.getKeys(false);
for (String blockName : skillConfigSet) {
if (config.contains(skillType + "." + blockName + "." + ".Drop_Item")) {
needsUpdate = true;
return;
}
String[] blockInfo = blockName.split("[|]");
Material blockMaterial = Material.matchMaterial(blockInfo[0]);
@@ -91,6 +78,27 @@ public class CustomBlockConfig extends ConfigLoader {
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
boolean shouldDropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item");
Material dropMaterial = Material.matchMaterial(config.getString(skillType + "." + blockName + ".Drop_Item_Name"));
if (shouldDropItem && dropMaterial == null) {
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself. - " + blockInfo[0]);
shouldDropItem = false;
}
ItemStack itemDrop;
if (shouldDropItem) {
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value");
itemDrop = (new MaterialData(dropMaterial, dropData)).toItemStack(1);
}
else {
itemDrop = blockMaterialData.toItemStack(1);
}
int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1);
int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1);
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
customOres.add(blockMaterialData);
}
@@ -104,7 +112,7 @@ public class CustomBlockConfig extends ConfigLoader {
}
}
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled")));
customBlockMap.put(blockMaterialData, new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, xp));
}
}

View File

@@ -18,7 +18,7 @@ public class CustomEntityConfig extends ConfigLoader {
private HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
public CustomEntityConfig() {
super("mods", "entities.yml");
super("ModConfigs", "entities.yml");
loadKeys();
}
@@ -32,11 +32,6 @@ public class CustomEntityConfig extends ConfigLoader {
@Override
protected void loadKeys() {
if (config.getConfigurationSection("Hostile") != null) {
backup();
return;
}
for (String entityName : config.getKeys(false)) {
Class<?> clazz = null;
String className = config.getString(entityName + ".Class", "");

View File

@@ -12,16 +12,13 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.repairables.RepairItemType;
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
import com.gmail.nossr50.skills.repair.RepairItemType;
import com.gmail.nossr50.skills.repair.RepairMaterialType;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableFactory;
public class CustomToolConfig extends ConfigLoader {
private static CustomToolConfig instance;
private boolean needsUpdate = false;
private List<Repairable> repairables;
private List<Material> customAxes = new ArrayList<Material>();
@@ -34,7 +31,7 @@ public class CustomToolConfig extends ConfigLoader {
private HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
private CustomToolConfig() {
super("mods", "tools.yml");
super("ModConfigs", "tools.yml");
loadKeys();
}
@@ -58,19 +55,12 @@ public class CustomToolConfig extends ConfigLoader {
protected void loadKeys() {
repairables = new ArrayList<Repairable>();
while (!needsUpdate) {
loadTool("Axes", customAxes);
loadTool("Bows", customBows);
loadTool("Hoes", customHoes);
loadTool("Pickaxes", customPickaxes);
loadTool("Shovels", customShovels);
loadTool("Swords", customSwords);
}
if (needsUpdate) {
needsUpdate = false;
backup();
}
loadTool("Axes", customAxes);
loadTool("Bows", customBows);
loadTool("Hoes", customHoes);
loadTool("Pickaxes", customPickaxes);
loadTool("Shovels", customShovels);
loadTool("Swords", customSwords);
}
private void loadTool(String toolType, List<Material> materialList) {
@@ -83,11 +73,6 @@ public class CustomToolConfig extends ConfigLoader {
Set<String> toolConfigSet = toolSection.getKeys(false);
for (String toolName : toolConfigSet) {
if (config.contains(toolType + "." + toolName + "." + ".ID")) {
needsUpdate = true;
return;
}
Material toolMaterial = Material.matchMaterial(toolName);
if (toolMaterial == null) {

View File

@@ -0,0 +1,45 @@
package com.gmail.nossr50.config.tiers;
import org.bukkit.configuration.ConfigurationSection;
public class BlastMiningRank extends Rank {
private double blastDamageDecrease;
private double oreBonus;
private double debrisReduction;
private int dropMultiplier;
private double blastRadiusModifier;
public BlastMiningRank(int level, double blastDamageDecrease, double oreBonus, double debrisReduction, int dropMultiplier, double blastRadiusModifier) {
super(level);
this.blastDamageDecrease = blastDamageDecrease;
this.oreBonus = oreBonus;
this.debrisReduction = debrisReduction;
this.dropMultiplier = dropMultiplier;
this.blastRadiusModifier = blastRadiusModifier;
}
public BlastMiningRank(ConfigurationSection section) {
this(section.getInt("Level"), section.getDouble("BlastDamageDecrease"), section.getDouble("OreBonus"), section.getDouble("DebrisReduction"), section.getInt("DropMultiplier"), section.getDouble("BlastRadiusModifier"));
}
public double getBlastDamageDecrease() {
return blastDamageDecrease;
}
public double getOreBonus() {
return oreBonus;
}
public double getDebrisReduction() {
return debrisReduction;
}
public int getDropMultiplier() {
return dropMultiplier;
}
public double getBlastRadiusModifier() {
return blastRadiusModifier;
}
}

View File

@@ -0,0 +1,27 @@
package com.gmail.nossr50.config.tiers;
import org.bukkit.configuration.ConfigurationSection;
public class FishingRank extends Rank {
private double shakeChance;
private int xpBoost;
private FishingRank(int level, double shakeChance, int xpBoost) {
super(level);
this.shakeChance = shakeChance;
this.xpBoost = xpBoost;
}
public FishingRank(ConfigurationSection section) {
this(section.getInt("Level"), section.getDouble("ShakeChance"), section.getInt("VanillaXPBoost"));
}
public double getShakeChance() {
return shakeChance;
}
public int getXpBoost() {
return xpBoost;
}
}

View File

@@ -0,0 +1,13 @@
package com.gmail.nossr50.config.tiers;
public abstract class Rank {
private int level;
public Rank(int level) {
this.level = level;
}
public int getLevel() {
return level;
}
}

View File

@@ -0,0 +1,117 @@
package com.gmail.nossr50.config.tiers;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import org.bukkit.configuration.ConfigurationSection;
import com.gmail.nossr50.config.ConfigLoader;
public class RankLoader extends ConfigLoader {
private List<FishingRank> fishingRanks;
private List<SmeltingRank> smeltingRanks;
private List<BlastMiningRank> blastMiningRanks;
private List<RepairRank> repairRanks;
private static RankLoader instance;
private RankLoader() {
super("ranks.yml");
fishingRanks = new ArrayList<FishingRank>();
smeltingRanks = new ArrayList<SmeltingRank>();
blastMiningRanks = new ArrayList<BlastMiningRank>();
repairRanks = new ArrayList<RepairRank>();
loadKeys();
}
public static RankLoader getInstance() {
if (instance == null) {
instance = new RankLoader();
}
return instance;
}
@Override
protected void loadKeys() {
ConfigurationSection section = config.getConfigurationSection("Ranks.Fishing");
RankComparator rankComparator = new RankComparator();
for (String rank : section.getKeys(false)) {
fishingRanks.add(new FishingRank(section.getConfigurationSection(rank)));
}
Collections.sort(fishingRanks, rankComparator);
section = config.getConfigurationSection("Ranks.BlastMining");
for (String rank : section.getKeys(false)) {
blastMiningRanks.add(new BlastMiningRank(section.getConfigurationSection(rank)));
}
Collections.sort(blastMiningRanks, rankComparator);
section = config.getConfigurationSection("Ranks.Repair");
for (String rank : section.getKeys(false)) {
repairRanks.add(new RepairRank(section.getConfigurationSection(rank)));
}
Collections.sort(repairRanks, rankComparator);
section = config.getConfigurationSection("Ranks.Smelting");
for (String rank : section.getKeys(false)) {
smeltingRanks.add(new SmeltingRank(section.getConfigurationSection(rank)));
}
Collections.sort(smeltingRanks, rankComparator);
}
public FishingRank getFishingRank(int level) {
Iterator<FishingRank> it = fishingRanks.iterator();
while (it.hasNext()) {
FishingRank rank = it.next();
if (rank.getLevel() > level) {
return rank;
}
}
return null;
}
public RepairRank getRepairRank(int level) {
Iterator<RepairRank> it = repairRanks.iterator();
while (it.hasNext()) {
RepairRank rank = it.next();
if (rank.getLevel() > level) {
return rank;
}
}
return null;
}
public SmeltingRank getSmeltingRank(int level) {
Iterator<SmeltingRank> it = smeltingRanks.iterator();
while (it.hasNext()) {
SmeltingRank rank = it.next();
if (rank.getLevel() > level) {
return rank;
}
}
return null;
}
public BlastMiningRank getBlastMiningRank(int level) {
Iterator<BlastMiningRank> it = blastMiningRanks.iterator();
while (it.hasNext()) {
BlastMiningRank rank = it.next();
if (rank.getLevel() > level) {
return rank;
}
}
return null;
}
private class RankComparator implements Comparator<Rank> {
@Override
public int compare(Rank o1, Rank o2) {
return Integer.valueOf(o1.getLevel()).compareTo(Integer.valueOf(o2.getLevel()));
}
}
}

View File

@@ -0,0 +1,27 @@
package com.gmail.nossr50.config.tiers;
import org.bukkit.configuration.ConfigurationSection;
public class RepairRank extends Rank {
private double downgradeChance;
private double keepEnchantsChance;
public RepairRank(int level, double downgradeChance, double keepEnchantsChance) {
super(level);
this.downgradeChance = downgradeChance;
this.keepEnchantsChance = keepEnchantsChance;
}
public RepairRank(ConfigurationSection section) {
this(section.getInt("Level"), section.getDouble("DowngradeChance"), section.getDouble("KeepEnchantsChance"));
}
public double getDowngradeChance() {
return downgradeChance;
}
public double getKeepEnchantsChance() {
return keepEnchantsChance;
}
}

View File

@@ -0,0 +1,21 @@
package com.gmail.nossr50.config.tiers;
import org.bukkit.configuration.ConfigurationSection;
public class SmeltingRank extends Rank {
private int xpMultiplier;
public SmeltingRank(int level, int xpMultiplier) {
super(level);
this.xpMultiplier = xpMultiplier;
}
public SmeltingRank(ConfigurationSection section) {
this(section.getInt("Level"), section.getInt("VanillaXPMultiplier"));
}
public int getXpMultiplier() {
return xpMultiplier;
}
}

View File

@@ -1,13 +1,11 @@
package com.gmail.nossr50.config.treasure;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@@ -16,13 +14,10 @@ import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionType;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
import com.gmail.nossr50.util.EnchantmentUtils;
public class TreasureConfig extends ConfigLoader {
private static TreasureConfig instance;
@@ -62,8 +57,7 @@ public class TreasureConfig extends ConfigLoader {
public List<ShakeTreasure> shakeFromWitch = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromZombie = new ArrayList<ShakeTreasure>();
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
private TreasureConfig() {
super("treasures.yml");
@@ -81,14 +75,15 @@ public class TreasureConfig extends ConfigLoader {
@Override
protected void loadKeys() {
if (config.getConfigurationSection("Treasures") != null) {
backup();
plugin.getLogger().warning("You are using an old version of the treasures.yml file.");
plugin.getLogger().warning("You should delete your current file and allow a new one to generate.");
plugin.getLogger().warning("Shake, Hylian Luck, Fishing, and Excavation will not work properly until you do.");
return;
}
loadTreaures("Fishing");
loadTreaures("Excavation");
loadTreaures("Hylian_Luck");
loadEnchantments();
for (EntityType entity : EntityType.values()) {
if (entity.isAlive()) {
@@ -109,13 +104,6 @@ public class TreasureConfig extends ConfigLoader {
return;
}
// Initialize fishing HashMap
for (Rarity rarity : Rarity.values()) {
if (!fishingRewards.containsKey(rarity)) {
fishingRewards.put(rarity, (new ArrayList<FishingTreasure>()));
}
}
for (String treasureName : treasureSection.getKeys(false)) {
// Validate all the things!
List<String> reason = new ArrayList<String>();
@@ -142,12 +130,12 @@ public class TreasureConfig extends ConfigLoader {
reason.add("Invalid material: " + treasureName);
}
if (amount <= 0) {
reason.add("Amount of " + treasureName + " must be greater than 0! " + amount);
if (amount < 1) {
reason.add("Invalid amount: " + amount);
}
if (material != null && material.isBlock() && (data > 127 || data < -128)) {
reason.add("Data of " + treasureName + " is invalid! " + data);
reason.add("Invalid data: " + data);
}
/*
@@ -159,27 +147,31 @@ public class TreasureConfig extends ConfigLoader {
int dropLevel = config.getInt(type + "." + treasureName + ".Drop_Level");
if (xp < 0) {
reason.add(treasureName + " has an invalid XP value: " + xp);
reason.add("Invalid xp: " + xp);
}
if (dropChance < 0.0D) {
reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
reason.add("Invalid Drop_Chance: " + dropChance);
}
if (dropLevel < 0) {
reason.add(treasureName + " has an invalid Drop_Level: " + dropLevel);
reason.add("Invalid Drop_Level: " + dropLevel);
}
/*
* Specific Types
*/
Rarity rarity = null;
int maxLevel = 0;
if (isFishing) {
rarity = Rarity.getRarity(config.getString(type + "." + treasureName + ".Rarity"));
maxLevel = config.getInt(type + "." + treasureName + ".Max_Level");
if (rarity == null) {
reason.add("Invalid Rarity for item: " + treasureName);
if (maxLevel < -1) {
reason.add("Invalid Max_Level: " + maxLevel);
}
if (maxLevel != -1 && maxLevel < dropLevel) {
reason.add("Max_Level must be -1 or greater than Drop_Level!");
}
}
@@ -229,7 +221,7 @@ public class TreasureConfig extends ConfigLoader {
if (noErrorsInConfig(reason)) {
if (isFishing) {
fishingRewards.get(rarity).add(new FishingTreasure(item, xp));
fishingRewards.add(new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel));
}
else if (isShake) {
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
@@ -353,37 +345,4 @@ public class TreasureConfig extends ConfigLoader {
}
}
}
private void loadEnchantments() {
for (Rarity rarity : Rarity.values()) {
if (rarity == Rarity.TRAP || rarity == Rarity.RECORD) {
continue;
}
if (!fishingEnchantments.containsKey(rarity)) {
fishingEnchantments.put(rarity, (new ArrayList<EnchantmentTreasure>()));
}
ConfigurationSection enchantmentSection = config.getConfigurationSection("Enchantments_Rarity." + rarity.toString());
if (enchantmentSection == null) {
return;
}
for (String enchantmentName : enchantmentSection.getKeys(false)) {
int level = config.getInt("Enchantments_Rarity." + rarity.toString() + "." + enchantmentName);
Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName);
if (enchantment == null) {
plugin.getLogger().warning("Skipping invalid enchantment in treasures.yml: " + enchantmentName);
continue;
}
fishingEnchantments.get(rarity).add(new EnchantmentTreasure(enchantment, level));
}
}
}
public double getItemDropRate(int tier, Rarity rarity) { return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
public double getEnchantmentDropRate(int tier, Rarity rarity) { return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
}
}

View File

@@ -26,7 +26,6 @@ public interface DatabaseManager {
* Remove a user from the database.
*
* @param playerName The name of the user to remove
*
* @return true if the user was successfully removed, false otherwise
*/
public boolean removeUser(String playerName);
@@ -35,27 +34,23 @@ public interface DatabaseManager {
* Save a user to the database.
*
* @param profile The profile of the player to save
*
* @return true if successful, false on failure
*/
public boolean saveUser(PlayerProfile profile);
public void saveUser(PlayerProfile profile);
/**
* Retrieve leaderboard info.
*
* @param skillName The skill to retrieve info on
* @param pageNumber Which page in the leaderboards to retrieve
* @param statsPerPage The number of stats per page
*
* @return the requested leaderboard information
*/
* Retrieve leaderboard info.
*
* @param skillName The skill to retrieve info on
* @param pageNumber Which page in the leaderboards to retrieve
* @param statsPerPage The number of stats per page
* @return the requested leaderboard information
*/
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage);
/**
* Retrieve rank info.
*
* @param playerName The name of the user to retrieve the rankings for
*
* @return the requested rank information
*/
public Map<String, Integer> readRank(String playerName);
@@ -71,11 +66,10 @@ public interface DatabaseManager {
* Load a player from the database.
*
* @param playerName The name of the player to load from the database
* @param createNew Whether to create a new record if the player is not
* found
*
* @param createNew Whether to create a new record if the player is not
* found
* @return The player's data, or an unloaded PlayerProfile if not found
* and createNew is false
* and createNew is false
*/
public PlayerProfile loadPlayerProfile(String playerName, boolean createNew);

View File

@@ -10,7 +10,7 @@ public class DatabaseManagerFactory {
public static DatabaseManager getDatabaseManager() {
if (customManager != null) {
try {
return createDefaultCustomDatabaseManager();
return createCustomDatabaseManager(customManager);
}
catch (Exception e) {
mcMMO.p.debug("Could not create custom database manager");
@@ -29,18 +29,17 @@ public class DatabaseManagerFactory {
/**
* Sets the custom DatabaseManager class for mcMMO to use. This should be
* called prior to mcMMO enabling.
* <p/>
* <p>
* The provided class must have an empty constructor, which is the one
* that will be used.
* <p/>
* <p>
* This method is intended for API use, but it should not be considered
* stable. This method is subject to change and/or removal in future
* versions.
*
* @param clazz the DatabaseManager class to use
*
* @throws IllegalArgumentException if the provided class does not have
* an empty constructor
* an empty constructor
*/
public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) {
try {
@@ -64,24 +63,13 @@ public class DatabaseManagerFactory {
case SQL:
return new SQLDatabaseManager();
case CUSTOM:
try {
return createDefaultCustomDatabaseManager();
}
catch (Throwable e) {
e.printStackTrace();
}
default:
return null;
}
}
public static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable {
return customManager.getConstructor((Class<?>) null).newInstance((Object[]) null);
}
//TODO: Why is clazz never used here?
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
return clazz.getConstructor((Class<?>) null).newInstance((Object[]) null);
return customManager.getConstructor((Class<?>) clazz).newInstance((Object[]) null);
}
}

View File

@@ -15,6 +15,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import com.gmail.nossr50.mcMMO;
@@ -121,10 +122,9 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
try {
lastPlayed = Long.parseLong(character[37]) * Misc.TIME_CONVERSION_FACTOR;
}
catch (NumberFormatException e) {
}
catch (NumberFormatException e) {}
if (lastPlayed == 0) {
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(name);
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
lastPlayed = player.getLastPlayed();
rewrite = true;
}
@@ -203,7 +203,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
return worked;
}
public boolean saveUser(PlayerProfile profile) {
public void saveUser(PlayerProfile profile) {
String playerName = profile.getPlayerName();
BufferedReader in = null;
@@ -272,11 +272,9 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Write the new file
out = new FileWriter(usersFilePath);
out.write(writer.toString());
return true;
}
catch (Exception e) {
e.printStackTrace();
return false;
}
finally {
tryClose(in);
@@ -298,7 +296,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
Map<String, Integer> skills = new HashMap<String, Integer>();
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
for (SkillType skill : SkillType.nonChildSkills()) {
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
}
@@ -387,14 +385,9 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
}
PlayerProfile p = loadFromLine(character);
in.close();
return p;
}
// Didn't find the player, create a new one
if (create) {
newUser(playerName);
return new PlayerProfile(playerName, true);
}
}
catch (Exception e) {
e.printStackTrace();
@@ -404,7 +397,10 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
}
}
// Return unloaded profile
if (create) {
newUser(playerName);
return new PlayerProfile(playerName, true);
}
return new PlayerProfile(playerName);
}
@@ -438,6 +434,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
}
}
public boolean checkConnected() {
// Not implemented
return true;
}
public List<String> getStoredUsers() {
ArrayList<String> users = new ArrayList<String>();
BufferedReader in = null;
@@ -492,7 +493,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
List<PlayerStat> fishing = new ArrayList<PlayerStat>();
BufferedReader in = null;
String playerName = null;
// Read from the FlatFile database and fill our arrays with information
synchronized (fileWritingLock) {
try {
@@ -501,7 +501,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
while ((line = in.readLine()) != null) {
String[] data = line.split(":");
playerName = data[0];
String playerName = data[0];
int powerLevel = 0;
Map<SkillType, Integer> skills = getSkillMapFromLine(data);
@@ -523,7 +523,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
}
}
catch (Exception e) {
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " during user " + playerName + " (Are you sure you formatted it correctly?) " + e.toString());
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
}
finally {
tryClose(in);

View File

@@ -12,6 +12,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
@@ -22,7 +23,6 @@ import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.runnables.database.SQLDatabaseKeepaliveTask;
import com.gmail.nossr50.runnables.database.SQLReconnectTask;
import com.gmail.nossr50.util.Misc;
@@ -51,8 +51,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
protected SQLDatabaseManager() {
checkStructure();
new SQLDatabaseKeepaliveTask(this).runTaskTimerAsynchronously(mcMMO.p, 10, 60L * 60 * Misc.TICK_CONVERSION_FACTOR);
}
public void purgePowerlessUsers() {
@@ -94,7 +92,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
"WHERE ((" + currentTime + " - lastlogin * " + Misc.TIME_CONVERSION_FACTOR + ") > " + PURGE_TIME + ")");
processPurge(usernames);
mcMMO.p.getLogger().info("Purged " + usernames.size() + " users from the database.");
mcMMO.p.getLogger().info("Purged " + usernames.size() + " users from the database.");;
}
public boolean removeUser(String playerName) {
@@ -115,9 +113,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
return success;
}
public boolean saveUser(PlayerProfile profile) {
public void saveUser(PlayerProfile profile) {
if (!checkConnected()) {
return false;
return;
}
int userId = readId(profile.getPlayerName());
@@ -125,15 +123,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
newUser(profile.getPlayerName());
userId = readId(profile.getPlayerName());
if (userId == -1) {
return false;
mcMMO.p.getLogger().log(Level.WARNING, "Failed to save user " + profile.getPlayerName());
return;
}
}
boolean success = true;
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
success &= saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
success &= saveHuds(userId, (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()));
success &= saveLongs(
saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
saveHuds(userId, (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()));
saveLongs(
"UPDATE " + tablePrefix + "cooldowns SET "
+ " mining = ?, woodcutting = ?, unarmed = ?"
+ ", herbalism = ?, excavation = ?, swords = ?"
@@ -147,7 +145,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
profile.getSkillDATS(AbilityType.SERRATED_STRIKES),
profile.getSkillDATS(AbilityType.SKULL_SPLITTER),
profile.getSkillDATS(AbilityType.BLAST_MINING));
success &= saveIntegers(
saveIntegers(
"UPDATE " + tablePrefix + "skills SET "
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
+ ", unarmed = ?, herbalism = ?, excavation = ?"
@@ -166,7 +164,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
profile.getSkillLevel(SkillType.ACROBATICS),
profile.getSkillLevel(SkillType.FISHING),
userId);
success &= saveIntegers(
saveIntegers(
"UPDATE " + tablePrefix + "experience SET "
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
+ ", unarmed = ?, herbalism = ?, excavation = ?"
@@ -185,7 +183,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
profile.getSkillXpLevel(SkillType.ACROBATICS),
profile.getSkillXpLevel(SkillType.FISHING),
userId);
return success;
}
public List<PlayerStat> readLeaderboard(String skillName, int pageNumber, int statsPerPage) {
@@ -237,7 +234,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
ResultSet resultSet;
try {
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
for (SkillType skillType : SkillType.nonChildSkills()) {
String skillName = skillType.name().toLowerCase();
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
@@ -346,10 +343,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
return loadPlayerProfile(playerName, create, true);
}
private PlayerProfile loadPlayerProfile(String playerName, boolean create, boolean retry) {
if (!checkConnected()) {
return new PlayerProfile(playerName, false); // return fake profile if not connected
}
@@ -379,8 +372,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
result.close();
return ret;
}
catch (SQLException e) {
}
catch (SQLException e) {}
}
result.close();
}
@@ -400,11 +392,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
// Problem, nothing was returned
// Quit if this is second time around
if (!retry) {
return new PlayerProfile(playerName, false);
}
// First, read User Id - this is to check for orphans
int id = readId(playerName);
@@ -413,16 +400,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
// There is no such user
if (create) {
newUser(playerName);
return loadPlayerProfile(playerName, false, false);
}
// Return unloaded profile if can't create
return new PlayerProfile(playerName, false);
return new PlayerProfile(playerName, create);
}
// There is such a user
writeMissingRows(id);
// Retry, and abort on re-failure
return loadPlayerProfile(playerName, create, false);
return loadPlayerProfile(playerName, false);
}
public void convertUsers(DatabaseManager destination) {
@@ -467,30 +452,28 @@ public final class SQLDatabaseManager implements DatabaseManager {
if (statement != null) {
try {
statement.close();
}
catch (SQLException e) {
} catch (SQLException e) {
// Ignore
}
}
}
}
/**
* Check connection status and re-establish if dead or stale.
* <p/>
* If the very first immediate attempt fails, further attempts
* will be made in progressively larger intervals up to MAX_WAIT
* intervals.
* <p/>
* This allows for MySQL to time out idle connections as needed by
* server operator, without affecting McMMO, while still providing
* protection against a database outage taking down Bukkit's tick
* processing loop due to attempting a database connection each
* time McMMO needs the database.
*
* @return the boolean value for whether or not we are connected
*/
* Check connection status and re-establish if dead or stale.
*
* If the very first immediate attempt fails, further attempts
* will be made in progressively larger intervals up to MAX_WAIT
* intervals.
*
* This allows for MySQL to time out idle connections as needed by
* server operator, without affecting McMMO, while still providing
* protection against a database outage taking down Bukkit's tick
* processing loop due to attempting a database connection each
* time McMMO needs the database.
*
* @return the boolean value for whether or not we are connected
*/
public boolean checkConnected() {
boolean isClosed = true;
boolean isValid = false;
@@ -586,8 +569,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
if (stmt != null) {
try {
stmt.close();
}
catch (SQLException e) {
} catch (SQLException e) {
// Ignore
}
}
@@ -846,7 +828,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
* Attempt to write the SQL query.
*
* @param sql Query to write.
*
* @return true if the query was successfully written, false otherwise.
*/
private boolean write(String sql) {
@@ -882,7 +863,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
* Returns the number of rows affected by either a DELETE or UPDATE query
*
* @param sql SQL query to execute
*
* @return the number of rows affected
*/
private int update(String sql) {
@@ -917,7 +897,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
* Read SQL query.
*
* @param sql SQL query to read
*
* @return the rows in this SQL query
*/
private HashMap<Integer, ArrayList<String>> read(String sql) {
@@ -963,7 +942,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
* Get the Integer. Only return first row / first field.
*
* @param statement SQL query to execute
*
* @return the value in the first row / first field
*/
private int readInt(PreparedStatement statement) {
@@ -1042,7 +1020,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
}
private boolean saveIntegers(String sql, int... args) {
private void saveIntegers(String sql, int... args) {
PreparedStatement statement = null;
try {
@@ -1054,11 +1032,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
statement.execute();
return true;
}
catch (SQLException ex) {
printErrors(ex);
return false;
}
finally {
if (statement != null) {
@@ -1072,7 +1048,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
}
private boolean saveLongs(String sql, int id, long... args) {
private void saveLongs(String sql, int id, long... args) {
PreparedStatement statement = null;
try {
@@ -1085,11 +1061,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setInt(i++, id);
statement.execute();
return true;
}
catch (SQLException ex) {
printErrors(ex);
return false;
}
finally {
if (statement != null) {
@@ -1107,7 +1081,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
* Retrieve the database id for a player
*
* @param playerName The name of the user to retrieve the id for
*
* @return the requested id or -1 if not found
*/
private int readId(String playerName) {
@@ -1125,7 +1098,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
return id;
}
private boolean saveLogin(int id, long login) {
private void saveLogin(int id, long login) {
PreparedStatement statement = null;
try {
@@ -1133,11 +1106,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setLong(1, login);
statement.setInt(2, id);
statement.execute();
return true;
}
catch (SQLException ex) {
printErrors(ex);
return false;
}
finally {
if (statement != null) {
@@ -1151,7 +1122,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
}
private boolean saveHuds(int userId, String mobHealthBar) {
private void saveHuds(int userId, String mobHealthBar) {
PreparedStatement statement = null;
try {
@@ -1159,11 +1130,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setString(1, mobHealthBar);
statement.setInt(2, userId);
statement.execute();
return true;
}
catch (SQLException ex) {
printErrors(ex);
return false;
}
finally {
if (statement != null) {

View File

@@ -7,5 +7,6 @@ public enum DatabaseUpdateType {
MOB_HEALTHBARS,
PARTY_NAMES,
KILL_ORPHANS,
DROPPED_SPOUT;
DROPPED_SPOUT
;
}

View File

@@ -1,19 +1,33 @@
package com.gmail.nossr50.datatypes.mods;
import org.bukkit.inventory.ItemStack;
public class CustomBlock {
private int xpGain;
private boolean canDoubleDrop;
private ItemStack itemDrop;
private int minimumDropAmount;
private int maximumDropAmount;
public CustomBlock(int xpGain, boolean canDoubleDrop) {
public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int xpGain) {
this.xpGain = xpGain;
this.canDoubleDrop = canDoubleDrop;
this.itemDrop = itemDrop;
this.minimumDropAmount = minimumDropAmount;
this.maximumDropAmount = maximumDropAmount;
}
public int getXpGain() {
return xpGain;
}
public boolean isDoubleDropEnabled() {
return canDoubleDrop;
public ItemStack getItemDrop() {
return itemDrop;
}
public int getMinimumDropAmount() {
return minimumDropAmount;
}
public int getMaximumDropAmount() {
return maximumDropAmount;
}
}

View File

@@ -7,14 +7,9 @@ import java.util.Set;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.mods.CustomTool;
@@ -22,11 +17,11 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
import com.gmail.nossr50.runnables.skills.ToolLowerTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
import com.gmail.nossr50.skills.archery.ArcheryManager;
@@ -43,12 +38,9 @@ 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.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModUtils;
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.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
@@ -131,69 +123,6 @@ public class McMMOPlayer {
toolMode.put(toolType, false);
toolATS.put(toolType, 0);
}
if (!profile.isLoaded()) {
mcMMO.p.getLogger().warning("Unable to load the PlayerProfile for " + playerName + ". Will retry over the next several seconds.");
new RetryProfileLoadingTask().runTaskTimerAsynchronously(mcMMO.p, 11L, 31L);
}
}
private class RetryProfileLoadingTask extends BukkitRunnable {
private static final int MAX_TRIES = 5;
private final String playerName = McMMOPlayer.this.player.getName();
private int attempt = 0;
// WARNING: ASYNC TASK
// DO NOT MODIFY THE McMMOPLAYER FROM THIS CODE
@Override
public void run() {
// Quit if they logged out
if (!player.isOnline()) {
mcMMO.p.getLogger().info("Aborting profile loading recovery for " + playerName + " - player logged out");
this.cancel();
return;
}
// Send the message that we're doing the recovery
if (attempt == 0) {
player.sendMessage(LocaleLoader.getString("Recovery.Notice"));
}
// Increment attempt counter and try
attempt++;
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, true);
// If successful, schedule the apply
if (profile.isLoaded()) {
new ApplySuccessfulProfile(profile).runTask(mcMMO.p);
player.sendMessage(LocaleLoader.getString("Recovery.Success"));
this.cancel();
return;
}
// If we've failed five times, give up
if (attempt >= MAX_TRIES) {
mcMMO.p.getLogger().severe("Giving up on attempting to load the PlayerProfile for " + playerName);
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Recovery.AdminFailureNotice", playerName), Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
player.sendMessage(LocaleLoader.getString("Recovery.Failure").split("\n"));
this.cancel();
return;
}
}
}
private class ApplySuccessfulProfile extends BukkitRunnable {
private final PlayerProfile profile;
private ApplySuccessfulProfile(PlayerProfile profile) {
this.profile = profile;
}
// Synchronized task
// No database access permitted
@Override
public void run() {
McMMOPlayer.this.profile = profile;
}
}
public AcrobaticsManager getAcrobaticsManager() {
@@ -266,7 +195,6 @@ public class McMMOPlayer {
* Get the mode of an ability.
*
* @param ability The ability to check
*
* @return true if the ability is enabled, false otherwise
*/
public boolean getAbilityMode(AbilityType ability) {
@@ -276,7 +204,7 @@ public class McMMOPlayer {
/**
* Set the mode of an ability.
*
* @param ability The ability to check
* @param ability The ability to check
* @param isActive True if the ability is active, false otherwise
*/
public void setAbilityMode(AbilityType ability, boolean isActive) {
@@ -287,7 +215,6 @@ public class McMMOPlayer {
* Get the informed state of an ability
*
* @param ability The ability to check
*
* @return true if the ability is informed, false otherwise
*/
public boolean getAbilityInformed(AbilityType ability) {
@@ -297,7 +224,7 @@ public class McMMOPlayer {
/**
* Set the informed state of an ability.
*
* @param ability The ability to check
* @param ability The ability to check
* @param isInformed True if the ability is informed, false otherwise
*/
public void setAbilityInformed(AbilityType ability, boolean isInformed) {
@@ -308,7 +235,6 @@ public class McMMOPlayer {
* Get the current prep mode of a tool.
*
* @param tool Tool to get the mode for
*
* @return true if the tool is prepped, false otherwise
*/
public boolean getToolPreparationMode(ToolType tool) {
@@ -339,7 +265,7 @@ public class McMMOPlayer {
/**
* Set the current prep mode of a tool.
*
* @param tool Tool to set the mode for
* @param tool Tool to set the mode for
* @param isPrepared true if the tool should be prepped, false otherwise
*/
public void setToolPreparationMode(ToolType tool, boolean isPrepared) {
@@ -350,7 +276,6 @@ public class McMMOPlayer {
* Get the current prep ATS of a tool.
*
* @param tool Tool to get the ATS for
*
* @return the ATS for the tool
*/
public long getToolPreparationATS(ToolType tool) {
@@ -361,7 +286,7 @@ public class McMMOPlayer {
* Set the current prep ATS of a tool.
*
* @param tool Tool to set the ATS for
* @param ATS the ATS of the tool
* @param ATS the ATS of the tool
*/
public void setToolPreparationATS(ToolType tool, long ATS) {
int startTime = (int) (ATS / Misc.TIME_CONVERSION_FACTOR);
@@ -523,7 +448,7 @@ public class McMMOPlayer {
public int getPowerLevel() {
int powerLevel = 0;
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
for (SkillType type : SkillType.nonChildSkills()) {
if (Permissions.skillEnabled(player, type)) {
powerLevel += profile.getSkillLevel(type);
}
@@ -536,7 +461,7 @@ public class McMMOPlayer {
* Begins an experience gain. The amount will be affected by skill modifiers, global rate, perks, and may be shared with the party
*
* @param skillType Skill being used
* @param xp Experience amount to process
* @param xp Experience amount to process
*/
public void beginXpGain(SkillType skillType, float xp) {
if (xp == 0) {
@@ -567,7 +492,7 @@ public class McMMOPlayer {
* Begins an experience gain. The amount will be affected by skill modifiers, global rate and perks
*
* @param skillType Skill being used
* @param xp Experience amount to process
* @param xp Experience amount to process
*/
public void beginUnsharedXpGain(SkillType skillType, float xp) {
xp = modifyXpGain(skillType, xp);
@@ -579,7 +504,7 @@ public class McMMOPlayer {
* Applies an experience gain
*
* @param skillType Skill being used
* @param xp Experience amount to add
* @param xp Experience amount to add
*/
public void applyXpGain(SkillType skillType, float xp) {
if (!Permissions.skillEnabled(player, skillType)) {
@@ -596,45 +521,17 @@ public class McMMOPlayer {
return;
}
if (!EventUtils.handleXpGainEvent(player, skillType, xp)) {
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
profile.setSkillXpLevel(skillType, profile.getSkillXpLevelRaw(skillType) + event.getRawXpGained());
isUsingUnarmed = (skillType == SkillType.UNARMED);
checkXp(skillType);
}
/**
* Check the XP of a skill.
*
* @param skillType The skill to check
*/
private void checkXp(SkillType skillType) {
int levelsGained = 0;
float xpRemoved = 0;
if (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
while (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
if ((skillType.getMaxLevel() >= profile.getSkillLevel(skillType) + 1) && (Config.getInstance().getPowerLevelCap() >= getPowerLevel() + 1)) {
int xp = profile.getXpToLevel(skillType);
xpRemoved += xp;
profile.removeXp(skillType, xp);
levelsGained++;
profile.skillUp(skillType, 1);
}
else {
profile.addLevels(skillType, 0); // This seems kinda pointless... why do we have this again?
}
}
if (!EventUtils.handleLevelChangeEvent(player, skillType, levelsGained, xpRemoved, true)) {
return;
}
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, profile.getSkillLevel(skillType)));
}
SkillUtils.xpCheckSkill(skillType, player, profile);
}
/*
@@ -785,8 +682,7 @@ public class McMMOPlayer {
* Modifies an experience gain using skill modifiers, global rate and perks
*
* @param skillType Skill being used
* @param xp Experience amount to process
*
* @param xp Experience amount to process
* @return Modified experience
*/
private float modifyXpGain(SkillType skillType, float xp) {
@@ -820,107 +716,4 @@ public class McMMOPlayer {
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
}
}
/**
* Check to see if an ability can be activated.
*
* @param skill The skill the ability is based on
*/
public void checkAbilityActivation(SkillType skill) {
ToolType tool = skill.getTool();
AbilityType ability = skill.getAbility();
setToolPreparationMode(tool, false);
if (getAbilityMode(ability)) {
return;
}
int timeRemaining = SkillUtils.calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
if (timeRemaining > 0) {
/*
* Axes and Woodcutting are odd because they share the same tool.
* We show them the too tired message when they take action.
*/
if (skill == SkillType.WOODCUTTING || skill == SkillType.AXES) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
}
return;
}
if (EventUtils.callPlayerAbilityActivateEvent(player, skill).isCancelled()) {
return;
}
int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxLength());
// Notify people that ability has been activated
ParticleEffectUtils.playAbilityEnabledEffect(player);
if (useChatNotifications()) {
player.sendMessage(ability.getAbilityOn());
}
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player));
// Enable the ability
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
setAbilityMode(ability, true);
if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) {
SkillUtils.handleAbilitySpeedIncrease(player);
}
new AbilityDisableTask(this, ability).runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR);
}
public void processAbilityActivation(SkillType skill) {
if (Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) {
return;
}
ItemStack inHand = player.getItemInHand();
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
return;
}
if (!getAbilityUse()) {
return;
}
for (AbilityType abilityType : AbilityType.values()) {
if (getAbilityMode(abilityType)) {
return;
}
}
AbilityType ability = skill.getAbility();
ToolType tool = skill.getTool();
/*
* Woodcutting & Axes need to be treated differently.
* Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action
*/
if (ability.getPermissions(player) && tool.inHand(inHand) && !getToolPreparationMode(tool)) {
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
int timeRemaining = SkillUtils.calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
if (!getAbilityMode(ability) && timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
return;
}
}
if (Config.getInstance().getAbilityMessagesEnabled()) {
player.sendMessage(tool.getRaiseTool());
}
setToolPreparationATS(tool, System.currentTimeMillis());
setToolPreparationMode(tool, true);
new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
}
}
}

View File

@@ -39,7 +39,7 @@ public class PlayerProfile {
skillsDATS.put(abilityType, 0);
}
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
for (SkillType skillType : SkillType.nonChildSkills()) {
skills.put(skillType, 0);
skillsXp.put(skillType, 0F);
}
@@ -54,7 +54,7 @@ public class PlayerProfile {
* Calling this constructor is considered loading the profile.
*/
public PlayerProfile(String playerName, Map<SkillType, Integer> argSkills, Map<SkillType, Float> argSkillsXp, Map<AbilityType, Integer> argSkillsDats, MobHealthbarType mobHealthbarType) {
this(playerName);
this(playerName, true);
this.mobHealthbarType = mobHealthbarType;
@@ -66,14 +66,12 @@ public class PlayerProfile {
}
public void save() {
if (!changed || !loaded) {
if (!changed) {
return;
}
changed = !mcMMO.getDatabaseManager().saveUser(this);
if (changed) {
mcMMO.p.getLogger().warning("PlayerProfile for " + playerName + " failed to save");
}
mcMMO.getDatabaseManager().saveUser(this);
changed = false;
}
public String getPlayerName() {
@@ -116,7 +114,6 @@ public class PlayerProfile {
* Get the current DATS of a skill.
*
* @param abilityType Ability to get the DATS for
*
* @return the DATS for the ability
*/
public long getSkillDATS(AbilityType abilityType) {
@@ -126,8 +123,8 @@ public class PlayerProfile {
/**
* Set the current DATS of a skill.
*
* @param abilityType Ability to set the DATS for
* @param DATS the DATS of the ability
* @param abilityType Ability to set the DATS for
* @param DATS the DATS of the ability
*/
public void setSkillDATS(AbilityType abilityType, long DATS) {
int wearsOff = (int) (DATS * .001D);
@@ -153,7 +150,11 @@ public class PlayerProfile {
*/
public int getSkillLevel(SkillType skillType) {
return skillType.isChildSkill() ? getChildSkillLevel(skillType) : skills.get(skillType);
if (skillType.isChildSkill()) {
return getChildSkillLevel(skillType);
}
return skills.get(skillType);
}
public float getSkillXpLevelRaw(SkillType skillType) {
@@ -182,7 +183,7 @@ public class PlayerProfile {
* Remove Xp from a skill.
*
* @param skillType Type of skill to modify
* @param xp Amount of xp to remove
* @param xp Amount of xp to remove
*/
public void removeXp(SkillType skillType, int xp) {
if (skillType.isChildSkill()) {
@@ -198,7 +199,7 @@ public class PlayerProfile {
* Modify a skill level.
*
* @param skillType Type of skill to modify
* @param newValue New level value for the skill
* @param newValue New level value for the skill
*/
public void modifySkill(SkillType skillType, int newValue) {
if (skillType.isChildSkill()) {
@@ -215,7 +216,7 @@ public class PlayerProfile {
* Add levels to a skill.
*
* @param skillType Type of skill to add levels to
* @param levels Number of levels to add
* @param levels Number of levels to add
*/
public void addLevels(SkillType skillType, int levels) {
if (skillType.isChildSkill()) {
@@ -231,7 +232,7 @@ public class PlayerProfile {
/**
* Add Experience to a skill.
*
* @param skillType Type of skill to add experience to
* @param skillType Type of skill to add experience to
* @param experience Number of experience to add
*/
public void addExperience(SkillType skillType, int experience) {
@@ -248,7 +249,6 @@ public class PlayerProfile {
* Get the total amount of Xp before the next level.
*
* @param skillType Type of skill to check
*
* @return the total amount of Xp until next level
*/
public int getXpToLevel(SkillType skillType) {

View File

@@ -1,14 +1,12 @@
package com.gmail.nossr50.datatypes.skills;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
@@ -150,7 +148,6 @@ public enum AbilityType {
* 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) {
@@ -194,7 +191,6 @@ public enum AbilityType {
* 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) {
@@ -224,24 +220,4 @@ public enum AbilityType {
return false;
}
}
/**
* Check to see if ability should be triggered.
*
* @param player The player using the ability
* @param block The block modified by the ability
*
* @return true if the ability should activate, false otherwise
*/
public boolean triggerCheck(Player player, Block block) {
switch (this) {
case BERSERK:
case BLOCK_CRACKER:
case LEAF_BLOWER:
return blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true);
default:
return false;
}
}
}

View File

@@ -25,6 +25,7 @@ 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.StringUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
@@ -50,34 +51,15 @@ public enum SkillType {
public static final List<String> SKILL_NAMES;
public static final List<SkillType> CHILD_SKILLS;
public static final List<SkillType> NON_CHILD_SKILLS;
public static final List<SkillType> COMBAT_SKILLS = ImmutableList.of(ARCHERY, AXES, SWORDS, TAMING, UNARMED);
public static final List<SkillType> GATHERING_SKILLS = ImmutableList.of(EXCAVATION, FISHING, HERBALISM, MINING, WOODCUTTING);
public static final List<SkillType> MISC_SKILLS = ImmutableList.of(ACROBATICS, REPAIR, SMELTING);
static {
List<SkillType> childSkills = new ArrayList<SkillType>();
List<SkillType> nonChildSkills = new ArrayList<SkillType>();
ArrayList<String> names = new ArrayList<String>();
for (SkillType skill : values()) {
if (skill.isChildSkill()) {
childSkills.add(skill);
}
else {
nonChildSkills.add(skill);
}
names.add(skill.getSkillName());
names.add(SkillUtils.getSkillName(skill));
}
Collections.sort(names);
SKILL_NAMES = ImmutableList.copyOf(names);
CHILD_SKILLS = ImmutableList.copyOf(childSkills);
NON_CHILD_SKILLS = ImmutableList.copyOf(nonChildSkills);
}
private SkillType(Class<? extends SkillManager> managerClass, Color runescapeColor) {
@@ -127,18 +109,10 @@ public enum SkillType {
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;
}
@@ -169,14 +143,33 @@ public enum SkillType {
// 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 SMELTING:
return true;
case SMELTING:
return true;
default:
return false;
default:
return false;
}
}
public static SkillType[] nonChildSkills() {
return new SkillType[] {SkillType.ACROBATICS,
SkillType.ARCHERY,
SkillType.AXES,
SkillType.EXCAVATION,
SkillType.FISHING,
SkillType.HERBALISM,
SkillType.MINING,
SkillType.REPAIR,
SkillType.SWORDS,
SkillType.TAMING,
SkillType.UNARMED,
SkillType.WOODCUTTING };
}
public static SkillType[] childSkills() {
return new SkillType[] { SkillType.SMELTING };
}
public Color getRunescapeModeColor() {
return runescapeColor;
}
@@ -190,8 +183,4 @@ public enum SkillType {
return null;
}
public String getSkillName() {
return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName"));
}
}

View File

@@ -34,7 +34,6 @@ public enum ToolType {
* 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) {

View File

@@ -1,29 +0,0 @@
package com.gmail.nossr50.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

@@ -3,8 +3,18 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack;
public class FishingTreasure extends Treasure {
private int maxLevel;
public FishingTreasure(ItemStack drop, int xp) {
super(drop, xp, 0, 0);
public FishingTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel, int maxLevel) {
super(drop, xp, dropChance, dropLevel);
this.setMaxLevel(maxLevel);
}
public int getMaxLevel() {
return maxLevel;
}
public void setMaxLevel(int maxLevel) {
this.maxLevel = maxLevel;
}
}

View File

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

View File

@@ -3,16 +3,28 @@ package com.gmail.nossr50.events.skills.abilities;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerAbilityEvent implements Cancellable {
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerSkillEvent implements Cancellable {
private AbilityType abilityType;
private boolean cancelled;
public McMMOPlayerAbilityActivateEvent(Player player, SkillType skill) {
super(player, skill);
abilityType = skill.getAbility();
cancelled = false;
}
/**
* @return The ability type involved in this event
*/
public AbilityType getAbilityType() {
return abilityType;
}
public boolean isCancelled() {
return cancelled;
}

View File

@@ -2,10 +2,21 @@ package com.gmail.nossr50.events.skills.abilities;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerSkillEvent {
private AbilityType ability;
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerAbilityEvent {
public McMMOPlayerAbilityDeactivateEvent(Player player, SkillType skill) {
super(player, skill);
this.ability = skill.getAbility();
}
public AbilityType getAbility() {
return ability;
}
}

View File

@@ -1,20 +0,0 @@
package com.gmail.nossr50.events.skills.abilities;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerAbilityEvent extends McMMOPlayerSkillEvent {
private AbilityType ability;
protected McMMOPlayerAbilityEvent(Player player, SkillType skill) {
super(player, skill);
ability = skill.getAbility();
}
public AbilityType getAbility() {
return ability;
}
}

View File

@@ -1,24 +0,0 @@
package com.gmail.nossr50.events.skills.fishing;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerFishingEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
protected McMMOPlayerFishingEvent(Player player) {
super(player, SkillType.FISHING);
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
}

View File

@@ -1,14 +1,20 @@
package com.gmail.nossr50.events.skills.fishing;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerFishingEvent {
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled = false;
private ItemStack treasure;
private int xp;
public McMMOPlayerFishingTreasureEvent(Player player, ItemStack treasure, int xp) {
super(player);
super(player, SkillType.FISHING);
this.treasure = treasure;
this.xp = xp;
}
@@ -21,6 +27,14 @@ public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerFishingEvent {
this.treasure = item;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
public int getXp() {
return xp;
}

View File

@@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class McMMOPlayerMagicHunterEvent extends McMMOPlayerFishingTreasureEvent {
private Map<Enchantment, Integer> enchants;
public McMMOPlayerMagicHunterEvent(Player player, ItemStack treasure, int xp, Map<Enchantment, Integer> enchants) {

View File

@@ -1,16 +1,30 @@
package com.gmail.nossr50.events.skills.fishing;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
public class McMMOPlayerShakeEvent extends McMMOPlayerFishingEvent {
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerShakeEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled = false;
private ItemStack drop;
public McMMOPlayerShakeEvent(Player player, ItemStack drop) {
super(player);
super(player, SkillType.FISHING);
this.drop = drop;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
public ItemStack getDrop() {
return drop;
}
@@ -18,4 +32,5 @@ public class McMMOPlayerShakeEvent extends McMMOPlayerFishingEvent {
public void setDrop(ItemStack drop) {
this.drop = drop;
}
}

View File

@@ -54,7 +54,7 @@ public class BlockListener implements Listener {
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
List<Block> blocks = event.getBlocks();
BlockFace direction = event.getDirection();
@@ -84,7 +84,7 @@ public class BlockListener implements Listener {
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
if (event.isSticky()) {
// Needed only because under some circumstances Minecraft doesn't move the block
@@ -149,7 +149,7 @@ public class BlockListener implements Listener {
/* Green Terra */
if (herbalismManager.canActivateAbility()) {
mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM);
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
}
/*
@@ -280,19 +280,19 @@ public class BlockListener implements Listener {
}
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM);
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
}
else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
mcMMOPlayer.checkAbilityActivation(SkillType.WOODCUTTING);
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.WOODCUTTING);
}
else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
mcMMOPlayer.checkAbilityActivation(SkillType.MINING);
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.MINING);
}
else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
mcMMOPlayer.checkAbilityActivation(SkillType.EXCAVATION);
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.EXCAVATION);
}
else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
mcMMOPlayer.checkAbilityActivation(SkillType.UNARMED);
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED);
}
}
@@ -339,17 +339,17 @@ public class BlockListener implements Listener {
}
}
else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
if (AbilityType.BERSERK.triggerCheck(player, block)) {
if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) {
event.setInstaBreak(true);
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}
else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && AbilityType.BLOCK_CRACKER.triggerCheck(player, block)) {
else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && SkillUtils.triggerCheck(player, block, AbilityType.BLOCK_CRACKER)) {
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
blockState.update();
}
}
}
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && AbilityType.LEAF_BLOWER.triggerCheck(player, block)) {
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
event.setInstaBreak(true);
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}

View File

@@ -459,22 +459,6 @@ public class EntityListener implements Listener {
}
}
/**
* Handle EntityExplode events that involve modifying the event.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityExplodeMonitor(EntityExplodeEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntsafeMetadataKey)) {
return;
}
event.blockList().clear();
}
/**
* Handle FoodLevelChange events that involve modifying the event.
*

View File

@@ -49,7 +49,6 @@ import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.Unarmed;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.HardcoreManager;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
@@ -69,7 +68,7 @@ public class PlayerListener implements Listener {
/**
* Monitor PlayerTeleportEvents.
* <p/>
* <p>
* These events are monitored for the purpose of setting the
* player's last teleportation timestamp, in order to prevent
* possible Acrobatics exploitation.
@@ -89,7 +88,7 @@ public class PlayerListener implements Listener {
/**
* Handle PlayerDeathEvents at the lowest priority.
* <p/>
* <p>
* These events are used to modify the death message of a player when
* needed to correct issues potentially caused by the custom naming used
* for mob healthbars.
@@ -115,7 +114,7 @@ public class PlayerListener implements Listener {
/**
* Monitor PlayerDeathEvents.
* <p/>
* <p>
* These events are monitored for the purpose of dealing the penalties
* associated with hardcore and vampirism modes. If neither of these
* modes are enabled, or if the player who died has hardcore bypass
@@ -151,7 +150,7 @@ public class PlayerListener implements Listener {
/**
* Monitor PlayerChangedWorldEvents.
* <p/>
* <p>
* These events are monitored for the purpose of removing god mode or
* player parties if they are not allowed on the world the player has
* changed to.
@@ -174,7 +173,7 @@ public class PlayerListener implements Listener {
/**
* Monitor PlayerDropItemEvents.
* <p/>
* <p>
* These events are monitored for the purpose of flagging sharable
* dropped items, as well as removing ability buffs from pickaxes
* and shovels.
@@ -195,7 +194,7 @@ public class PlayerListener implements Listener {
/**
* Handle PlayerFishEvents at the highest priority.
* <p/>
* <p>
* These events are used for the purpose of handling our anti-exploit
* code, as well as dealing with ice fishing.
*
@@ -240,7 +239,7 @@ public class PlayerListener implements Listener {
/**
* Monitor PlayerFishEvents.
* <p/>
* <p>
* These events are monitored for the purpose of handling the various
* Fishing skills and abilities.
*
@@ -281,7 +280,7 @@ public class PlayerListener implements Listener {
/**
* Handle PlayerPickupItemEvents at the highest priority.
* <p/>
* <p>
* These events are used to handle item sharing between party members and
* are also used to handle item pickup for the Unarmed skill.
*
@@ -322,7 +321,7 @@ public class PlayerListener implements Listener {
/**
* Monitor PlayerQuitEvents.
* <p/>
* <p>
* These events are monitored for the purpose of resetting player
* variables and other garbage collection tasks that must take place when
* a player exits the server.
@@ -347,7 +346,7 @@ public class PlayerListener implements Listener {
/**
* Monitor PlayerJoinEvents.
* <p/>
* <p>
* These events are monitored for the purpose of initializing player
* variables, as well as handling the MOTD display and other important
* join messages.
@@ -381,7 +380,7 @@ public class PlayerListener implements Listener {
/**
* Monitor PlayerRespawnEvents.
* <p/>
* <p>
* These events are monitored for the purpose of setting the
* player's last respawn timestamp, in order to prevent
* possible exploitation.
@@ -515,15 +514,15 @@ public class PlayerListener implements Listener {
if (BlockUtils.canActivateAbilities(blockState)) {
if (Config.getInstance().getAbilitiesEnabled()) {
if (BlockUtils.canActivateHerbalism(blockState)) {
mcMMOPlayer.processAbilityActivation(SkillType.HERBALISM);
SkillUtils.activationCheck(player, SkillType.HERBALISM);
}
mcMMOPlayer.processAbilityActivation(SkillType.AXES);
mcMMOPlayer.processAbilityActivation(SkillType.EXCAVATION);
mcMMOPlayer.processAbilityActivation(SkillType.MINING);
mcMMOPlayer.processAbilityActivation(SkillType.SWORDS);
mcMMOPlayer.processAbilityActivation(SkillType.UNARMED);
mcMMOPlayer.processAbilityActivation(SkillType.WOODCUTTING);
SkillUtils.activationCheck(player, SkillType.AXES);
SkillUtils.activationCheck(player, SkillType.EXCAVATION);
SkillUtils.activationCheck(player, SkillType.MINING);
SkillUtils.activationCheck(player, SkillType.SWORDS);
SkillUtils.activationCheck(player, SkillType.UNARMED);
SkillUtils.activationCheck(player, SkillType.WOODCUTTING);
}
ChimaeraWing.activationCheck(player);
@@ -535,14 +534,14 @@ public class PlayerListener implements Listener {
if (herbalismManager.canGreenThumbBlock(blockState)) {
player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1));
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
if (herbalismManager.processGreenThumbBlocks(blockState) && SkillUtils.blockBreakSimulate(block, player, false)) {
blockState.update(true);
}
}
/* SHROOM THUMB CHECK */
else if (herbalismManager.canUseShroomThumb(blockState)) {
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
if (herbalismManager.processShroomThumb(blockState) && SkillUtils.blockBreakSimulate(block, player, false)) {
blockState.update(true);
}
}
@@ -552,13 +551,13 @@ public class PlayerListener implements Listener {
/* ACTIVATION CHECKS */
if (Config.getInstance().getAbilitiesEnabled()) {
mcMMOPlayer.processAbilityActivation(SkillType.AXES);
mcMMOPlayer.processAbilityActivation(SkillType.EXCAVATION);
mcMMOPlayer.processAbilityActivation(SkillType.HERBALISM);
mcMMOPlayer.processAbilityActivation(SkillType.MINING);
mcMMOPlayer.processAbilityActivation(SkillType.SWORDS);
mcMMOPlayer.processAbilityActivation(SkillType.UNARMED);
mcMMOPlayer.processAbilityActivation(SkillType.WOODCUTTING);
SkillUtils.activationCheck(player, SkillType.AXES);
SkillUtils.activationCheck(player, SkillType.EXCAVATION);
SkillUtils.activationCheck(player, SkillType.HERBALISM);
SkillUtils.activationCheck(player, SkillType.MINING);
SkillUtils.activationCheck(player, SkillType.SWORDS);
SkillUtils.activationCheck(player, SkillType.UNARMED);
SkillUtils.activationCheck(player, SkillType.WOODCUTTING);
}
/* ITEM CHECKS */
@@ -660,7 +659,7 @@ public class PlayerListener implements Listener {
// Do these ACTUALLY have to be lower case to work properly?
for (SkillType skill : SkillType.values()) {
String skillName = skill.toString().toLowerCase();
String localizedName = skill.getSkillName().toLowerCase();
String localizedName = SkillUtils.getSkillName(skill).toLowerCase();
if (lowerCaseCommand.equals(localizedName)) {
event.setMessage(message.replace(command, skillName));

View File

@@ -14,7 +14,7 @@ public final class LocaleLoader {
private static ResourceBundle bundle = null;
private static ResourceBundle enBundle = null;
private LocaleLoader() {}
private LocaleLoader() {};
public static String getString(String key) {
return getString(key, (Object[]) null);
@@ -23,9 +23,8 @@ public final class LocaleLoader {
/**
* Gets the appropriate string from the Locale files.
*
* @param key The key to look up the string with
* @param key The key to look up the string with
* @param messageArguments Any arguments to be added to the string
*
* @return The properly formatted locale string
*/
public static String getString(String key, Object... messageArguments) {
@@ -47,7 +46,7 @@ public final class LocaleLoader {
}
private static String getString(String key, ResourceBundle bundle, Object... messageArguments) throws MissingResourceException {
return formatString(bundle.getString(key), messageArguments);
return formatString(bundle.getString(key).replace("\'", "''"), messageArguments);
}
public static String formatString(String string, Object... messageArguments) {
@@ -57,7 +56,6 @@ public final class LocaleLoader {
string = formatter.format(messageArguments);
}
string.replaceAll("\'", "''");
string = addColors(string);
return string;

View File

@@ -35,10 +35,10 @@ import com.gmail.nossr50.runnables.database.UserPurgeTask;
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.skills.child.ChildConfig;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableManager;
import com.gmail.nossr50.skills.repair.RepairableManagerFactory;
import com.gmail.nossr50.skills.repair.config.RepairConfigManager;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.skills.repair.repairables.RepairableManager;
import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager;
import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.LogFilter;
import com.gmail.nossr50.util.Misc;
@@ -91,7 +91,6 @@ public class mcMMO extends JavaPlugin {
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace";
public final static String tntMetadataKey = "mcMMO: Tracked TNT";
public final static String tntsafeMetadataKey = "mcMMO: Safe TNT";
public final static String customNameKey = "mcMMO: Custom Name";
public final static String customVisibleKey = "mcMMO: Name Visibility";
public final static String droppedItemKey = "mcMMO: Tracked Item";
@@ -186,8 +185,7 @@ public class mcMMO extends JavaPlugin {
placeStore.saveAll(); // Save our metadata
placeStore.cleanUp(); // Cleanup empty metadata stores
}
catch (NullPointerException e) {
}
catch (NullPointerException e) {}
getServer().getScheduler().cancelTasks(this); // This removes our tasks
HandlerList.unregisterAll(this); // Cancel event registrations
@@ -289,23 +287,9 @@ public class mcMMO extends JavaPlugin {
private void setupFilePaths() {
mcmmo = getFile();
mainDirectory = getDataFolder().getPath() + File.separator;
flatFileDirectory = mainDirectory + "flatfile" + File.separator;
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
usersFile = flatFileDirectory + "mcmmo.users";
modDirectory = mainDirectory + "mods" + File.separator;
fixFilePaths();
}
private void fixFilePaths() {
File oldFlatfilePath = new File(mainDirectory + "FlatFileStuff" + File.separator);
File oldModPath = new File(mainDirectory + "ModConfigs" + File.separator);
if (oldFlatfilePath.exists()) {
oldFlatfilePath.renameTo(new File(flatFileDirectory));
}
if (oldModPath.exists()) {
oldModPath.renameTo(new File(modDirectory));
}
modDirectory = mainDirectory + "ModConfigs" + File.separator;
}
private void checkForUpdates() {
@@ -358,7 +342,7 @@ public class mcMMO extends JavaPlugin {
// Load repair configs, make manager, and register them at this time
RepairConfigManager rManager = new RepairConfigManager(this);
repairables.addAll(rManager.getLoadedRepairables());
repairableManager = new SimpleRepairableManager(repairables.size());
repairableManager = RepairableManagerFactory.getRepairManager(repairables.size());
repairableManager.registerRepairables(repairables);
}

View File

@@ -31,9 +31,8 @@ public final class PartyManager {
/**
* Check if a party with a given name already exists.
*
* @param player The player to notify
* @param player The player to notify
* @param partyName The name of the party to check
*
* @return true if a party with that name exists, false otherwise
*/
public static boolean checkPartyExistence(Player player, String partyName) {
@@ -48,9 +47,8 @@ public final class PartyManager {
/**
* Attempt to change parties or join a new party.
*
* @param mcMMOPlayer The player changing or joining parties
* @param mcMMOPlayer The player changing or joining parties
* @param newPartyName The name of the party being joined
*
* @return true if the party was joined successfully, false otherwise
*/
public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, String newPartyName) {
@@ -75,9 +73,8 @@ public final class PartyManager {
/**
* Check if two online players are in the same party.
*
* @param firstPlayer The first player
* @param firstPlayer The first player
* @param secondPlayer The second player
*
* @return true if they are in the same party, false otherwise
*/
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) {
@@ -95,7 +92,6 @@ public final class PartyManager {
* Get the near party members.
*
* @param mcMMOPlayer The player to check
*
* @return the near party members
*/
public static List<Player> getNearMembers(McMMOPlayer mcMMOPlayer) {
@@ -120,7 +116,6 @@ public final class PartyManager {
* Get a list of all players in this player's party.
*
* @param player The player to check
*
* @return all the players in the player's party
*/
public static LinkedHashSet<String> getAllMembers(Player player) {
@@ -133,7 +128,6 @@ public final class PartyManager {
* Get a list of all online players in this party.
*
* @param partyName The party to check
*
* @return all online players in this party
*/
public static List<Player> getOnlineMembers(String partyName) {
@@ -144,7 +138,6 @@ public final class PartyManager {
* Get a list of all online players in this party.
*
* @param player The player to check
*
* @return all online players in this party
*/
public static List<Player> getOnlineMembers(Player player) {
@@ -159,7 +152,6 @@ public final class PartyManager {
* Retrieve a party by its name
*
* @param partyName The party name
*
* @return the existing party, null otherwise
*/
public static Party getParty(String partyName) {
@@ -176,7 +168,6 @@ public final class PartyManager {
* Retrieve a party by a members name
*
* @param playerName The members name
*
* @return the existing party, null otherwise
*/
public static Party getPlayerParty(String playerName) {
@@ -193,13 +184,16 @@ public final class PartyManager {
* Retrieve a party by member
*
* @param player The member
*
* @return the existing party, null otherwise
*/
public static Party getParty(Player player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
return mcMMOPlayer.getParty();
if (mcMMOPlayer != null) {
return mcMMOPlayer.getParty();
}
return getPlayerParty(player.getName());
}
/**
@@ -215,7 +209,7 @@ public final class PartyManager {
* Remove a player from a party.
*
* @param player The player to remove
* @param party The party
* @param party The party
*/
public static void removeFromParty(OfflinePlayer player, Party party) {
LinkedHashSet<String> members = party.getMembers();
@@ -263,8 +257,8 @@ public final class PartyManager {
* Create a new party
*
* @param mcMMOPlayer The player to add to the party
* @param partyName The party to add the player to
* @param password The password for this party, null if there was no password
* @param partyName The party to add the player to
* @param password The password for this party, null if there was no password
*/
public static void createParty(McMMOPlayer mcMMOPlayer, String partyName, String password) {
Player player = mcMMOPlayer.getPlayer();
@@ -285,10 +279,9 @@ public final class PartyManager {
/**
* Check if a player can join a party
*
* @param player The player trying to join a party
* @param party The party
* @param player The player trying to join a party
* @param party The party
* @param password The password provided by the player
*
* @return true if the player can join the party
*/
public static boolean checkPartyPassword(Player player, Party party, String password) {
@@ -337,7 +330,7 @@ public final class PartyManager {
* Add a player to a party
*
* @param mcMMOPlayer The player to add to the party
* @param party The party
* @param party The party
*/
public static void addToParty(McMMOPlayer mcMMOPlayer, Party party) {
String playerName = mcMMOPlayer.getPlayer().getName();
@@ -351,7 +344,6 @@ public final class PartyManager {
* Get the leader of a party.
*
* @param partyName The party name
*
* @return the leader of the party
*/
public static String getPartyLeader(String partyName) {
@@ -364,7 +356,7 @@ public final class PartyManager {
* Set the leader of a party.
*
* @param playerName The name of the player to set as leader
* @param party The party
* @param party The party
*/
public static void setPartyLeader(String playerName, Party party) {
String leaderName = party.getLeader();
@@ -401,7 +393,6 @@ public final class PartyManager {
* Check if a string is a valid party name.
*
* @param partyName The party name to check
*
* @return true if this is a valid party, false otherwise
*/
public static boolean isParty(String partyName) {
@@ -487,11 +478,10 @@ public final class PartyManager {
/**
* Handle party change event.
*
* @param player The player changing parties
* @param player The player changing parties
* @param oldPartyName The name of the old party
* @param newPartyName The name of the new party
* @param reason The reason for changing parties
*
* @param reason The reason for changing parties
* @return true if the change event was successful, false otherwise
*/
public static boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
@@ -515,7 +505,7 @@ public final class PartyManager {
/**
* Notify party members when a player joins.
*
* @param party The concerned party
* @param party The concerned party
* @param playerName The name of the player that joined
*/
private static void informPartyMembersJoin(Party party, String playerName) {
@@ -527,7 +517,7 @@ public final class PartyManager {
/**
* Notify party members when a party member quits.
*
* @param party The concerned party
* @param party The concerned party
* @param playerName The name of the player that left
*/
private static void informPartyMembersQuit(Party party, String playerName) {

View File

@@ -22,10 +22,9 @@ public final class ShareHandler {
/**
* Distribute Xp amongst party members.
*
* @param xp Xp without party sharing
* @param xp Xp without party sharing
* @param mcMMOPlayer Player initiating the Xp gain
* @param skillType Skill being used
*
* @param skillType Skill being used
* @return True is the xp has been shared
*/
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
@@ -57,9 +56,8 @@ public final class ShareHandler {
/**
* Distribute Items amongst party members.
*
* @param drop Item that will get shared
* @param drop Item that will get shared
* @param mcMMOPlayer Player who picked up the item
*
* @return True if the item has been shared
*/
public static boolean handleItemShare(Item drop, McMMOPlayer mcMMOPlayer) {

View File

@@ -10,6 +10,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class McrankCommandDisplayTask extends BukkitRunnable {
private final Map<String, Integer> skills;
@@ -30,13 +31,13 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (player != null && !Permissions.skillEnabled(player, skill)) {
continue;
}
rank = skills.get(skill.name());
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", skill.getSkillName(), (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank)));
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillUtils.getSkillName(skill), (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank)));
}
rank = skills.get("ALL");

View File

@@ -28,5 +28,5 @@ public class DatabaseConversionTask extends BukkitRunnable {
sender.sendMessage(message);
}
});
}
}
}

View File

@@ -52,7 +52,7 @@ public class FormulaConversionTask extends BukkitRunnable {
private void editValues(PlayerProfile profile) {
mcMMO.p.debug("========================================================================");
mcMMO.p.debug("Conversion report for " + profile.getPlayerName() + ":");
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
for (SkillType skillType : SkillType.nonChildSkills()) {
int oldLevel = profile.getSkillLevel(skillType);
int oldXPLevel = profile.getSkillXpLevel(skillType);
int totalOldXP = mcMMO.getFormulaManager().calculateTotalExperience(oldLevel, oldXPLevel);

View File

@@ -1,39 +0,0 @@
package com.gmail.nossr50.runnables.database;
import java.lang.ref.WeakReference;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.database.SQLDatabaseManager;
/**
* This task is in charge of sending a MySQL ping over the MySQL connection
* every hour to prevent the connection from timing out and losing players'
* data when they join.
* <p/>
* A WeakReference is used to keep the database instance, because
* {@link com.gmail.nossr50.commands.database.ConvertDatabaseCommand database
* conversion} may create a SQLDatabaseManager that will be thrown out. If a
* normal reference was used, the conversion would cause a combined data and
* resource leak through this task.
*/
public class SQLDatabaseKeepaliveTask extends BukkitRunnable {
WeakReference<SQLDatabaseManager> databaseInstance;
public SQLDatabaseKeepaliveTask(SQLDatabaseManager dbman) {
databaseInstance = new WeakReference<SQLDatabaseManager>(dbman);
}
public void run() {
SQLDatabaseManager dbman = databaseInstance.get();
if (dbman != null) {
dbman.checkConnected();
}
else {
// This happens when the database was started for a conversion,
// or discarded by its creator for any other reason. If this code
// was not present, we would leak the connection resources.
this.cancel();
}
}
}

View File

@@ -4,11 +4,11 @@ import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.SkillUtils;
@@ -58,6 +58,6 @@ public class TeleportationWarmup extends BukkitRunnable {
}
}
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
PtpCommand.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
}
}

View File

@@ -7,7 +7,8 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.PerksUtils;
@@ -46,7 +47,8 @@ public class AbilityDisableTask extends BukkitRunnable {
break;
}
EventUtils.callAbilityDeactivateEvent(player, ability);
McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, SkillType.byAbility(ability));
mcMMO.p.getServer().getPluginManager().callEvent(event);
mcMMOPlayer.setAbilityMode(ability, false);
mcMMOPlayer.setAbilityInformed(ability, false);

View File

@@ -94,7 +94,7 @@ public class BleedTimerTask extends BukkitRunnable {
* Add a LivingEntity to the bleedList if it is not in it.
*
* @param entity LivingEntity to add
* @param ticks Number of bleeding ticks
* @param ticks Number of bleeding ticks
*/
public static void add(LivingEntity entity, int ticks) {
int newTicks = ticks;

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.acrobatics;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
public final class Acrobatics {
public static int dodgeMaxBonusLevel = AdvancedConfig.getInstance().getDodgeMaxBonusLevel();
@@ -17,16 +16,14 @@ public final class Acrobatics {
public static double gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold();
public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax();
public static int dodgeXpModifier = ExperienceConfig.getInstance().getDodgeXPModifier();
public static int rollXpModifier = ExperienceConfig.getInstance().getRollXPModifier();
public static int fallXpModifier = ExperienceConfig.getInstance().getFallXPModifier();
public static double featherFallXPModifier = ExperienceConfig.getInstance().getFeatherFallXPModifier();
public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier();
public static int rollXpModifier = AdvancedConfig.getInstance().getRollXPModifier();
public static int fallXpModifier = AdvancedConfig.getInstance().getFallXPModifier();
public static boolean afkLevelingDisabled = Config.getInstance().getAcrobaticsAFKDisabled();
public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled();
private Acrobatics() {}
private Acrobatics() {};
protected static double calculateModifiedDodgeDamage(double damage, double damageModifier) {
return Math.max(damage / damageModifier, 1.0);

View File

@@ -1,11 +1,9 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -44,7 +42,6 @@ public class AcrobaticsManager extends SkillManager {
* Handle the damage reduction and XP gain from the Dodge 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
*/
public double dodgeCheck(double damage) {
@@ -73,7 +70,6 @@ public class AcrobaticsManager extends SkillManager {
* 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
*/
public double rollCheck(double damage) {
@@ -87,12 +83,12 @@ public class AcrobaticsManager extends SkillManager {
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel)) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
applyXpGain(calculateRollXP(damage, true));
applyXpGain((float) (damage * Acrobatics.rollXpModifier));
return modifiedDamage;
}
else if (!isFatal(damage)) {
applyXpGain(calculateRollXP(damage, false));
applyXpGain((float) (damage * Acrobatics.fallXpModifier));
}
return damage;
@@ -102,7 +98,6 @@ public class AcrobaticsManager extends SkillManager {
* 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(double damage) {
@@ -110,12 +105,12 @@ public class AcrobaticsManager extends SkillManager {
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel)) {
getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
applyXpGain(calculateRollXP(damage, true));
applyXpGain((float) (damage * Acrobatics.rollXpModifier));
return modifiedDamage;
}
else if (!isFatal(damage)) {
applyXpGain(calculateRollXP(damage, false));
applyXpGain((float) (damage * Acrobatics.fallXpModifier));
}
return damage;
@@ -128,15 +123,4 @@ public class AcrobaticsManager extends SkillManager {
private boolean isFatal(double damage) {
return getPlayer().getHealth() - damage < 1;
}
private float calculateRollXP(double damage, boolean isRoll) {
ItemStack boots = getPlayer().getInventory().getBoots();
float xp = (float) (damage * (isRoll ? Acrobatics.rollXpModifier : Acrobatics.fallXpModifier));
if (boots != null && boots.containsEnchantment(Enchantment.PROTECTION_FALL)) {
xp *= Acrobatics.featherFallXPModifier;
}
return xp;
}
}

View File

@@ -40,7 +40,7 @@ public class ArcheryManager extends SkillManager {
/**
* Calculate bonus XP awarded for Archery when hitting a far-away target.
*
* @param target The {@link LivingEntity} damaged by the arrow
* @param target The {@link LivingEntity} damaged by the arrow
* @param damager The {@link Entity} who shot the arrow
*/
public void distanceXpBonus(LivingEntity target, Entity damager) {
@@ -69,7 +69,7 @@ public class ArcheryManager extends SkillManager {
* Handle the effects of the Daze ability
*
* @param defender The {@link Player} being affected by the ability
* @param arrow The {@link Arrow} that was fired
* @param arrow The {@link Arrow} that was fired
*/
public double daze(Player defender, Arrow arrow) {
if (!SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
@@ -98,7 +98,7 @@ public class ArcheryManager extends SkillManager {
*
* @param target The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
* @param arrow The {@link Arrow} that was fired
* @param arrow The {@link Arrow} that was fired
*/
public double skillShot(LivingEntity target, double damage, Arrow arrow) {
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);

View File

@@ -20,7 +20,7 @@ public class ChildConfig extends AutoUpdateConfigLoader {
FamilyTree.clearRegistrations(); // when reloading, need to clear statics
for (SkillType skill : SkillType.CHILD_SKILLS) {
for (SkillType skill : SkillType.childSkills()) {
plugin.debug("Finding parents of " + skill.name());
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);

View File

@@ -16,7 +16,6 @@ public class Excavation {
* Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block.
*
* @param blockState The {@link BlockState} of the block to check.
*
* @return the list of treasures that could be found
*/
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {

View File

@@ -15,15 +15,27 @@ import com.gmail.nossr50.util.Misc;
public final class Fishing {
// The order of the values is extremely important, a few methods depend on it to work properly
public enum Tier {
EIGHT(8),
SEVEN(7),
SIX(6),
FIVE(5),
FOUR(4),
THREE(3),
TWO(2),
ONE(1);
protected enum Tier {
FIVE(5) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier5(); }
@Override public double getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank5(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank5(); }},
FOUR(4) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier4(); }
@Override public double getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank4(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank4(); }},
THREE(3) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier3(); }
@Override public double getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank3(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank3(); }},
TWO(2) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier2(); }
@Override public double getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank2(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank2(); }},
ONE(1) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier1(); }
@Override public double getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank1(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank1(); }};
int numerical;
@@ -35,17 +47,9 @@ public final class Fishing {
return numerical;
}
protected int getLevel() {
return AdvancedConfig.getInstance().getFishingTierLevel(this);
}
protected double getShakeChance() {
return AdvancedConfig.getInstance().getShakeChance(this);
}
protected int getVanillaXPBoostModifier() {
return AdvancedConfig.getInstance().getFishingVanillaXPModifier(this);
}
abstract protected int getLevel();
abstract protected double getShakeChance();
abstract protected int getVanillaXPBoostModifier();
}
protected static final HashMap<Material, List<Enchantment>> ENCHANTABLE_CACHE = new HashMap<Material, List<Enchantment>>();
@@ -62,7 +66,6 @@ public final class Fishing {
* Finds the possible drops of an entity
*
* @param target Targeted entity
*
* @return possibleDrops List of ItemStack that can be dropped
*/
protected static List<ShakeTreasure> findPossibleDrops(LivingEntity target) {
@@ -136,7 +139,6 @@ public final class Fishing {
* Randomly chooses a drop among the list
*
* @param possibleDrops List of ItemStack that can be dropped
*
* @return Chosen ItemStack
*/
protected static ItemStack chooseDrop(List<ShakeTreasure> possibleDrops) {

View File

@@ -26,14 +26,10 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Wool;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionType;
import org.bukkit.util.Vector;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
@@ -42,18 +38,18 @@ import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakePlayerFishEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.skills.KrakenAttackTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@@ -66,18 +62,17 @@ public class FishingManager extends SkillManager {
private int fishingTries = 0;
private long fishingTimestamp = 0L;
private Location fishingTarget;
private Item fishingCatch;
public FishingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.FISHING);
}
public boolean canShake(Entity target) {
return target instanceof LivingEntity && getSkillLevel() >= Tier.ONE.getLevel() && Permissions.shake(getPlayer());
return target instanceof LivingEntity && getSkillLevel() >= AdvancedConfig.getInstance().getShakeUnlockLevel() && Permissions.shake(getPlayer());
}
public boolean canMasterAngler() {
return getSkillLevel() >= AdvancedConfig.getInstance().getMasterAnglerUnlockLevel() && Permissions.masterAngler(getPlayer());
return Permissions.masterAngler(getPlayer());
}
public boolean unleashTheKraken() {
@@ -208,7 +203,10 @@ public class FishingManager extends SkillManager {
return false;
}
return EventUtils.simulateBlockBreak(block, player, false);
FakeBlockBreakEvent blockBreakEvent = new FakeBlockBreakEvent(block, player);
mcMMO.p.getServer().getPluginManager().callEvent(blockBreakEvent);
return !blockBreakEvent.isCancelled();
}
/**
@@ -248,9 +246,8 @@ public class FishingManager extends SkillManager {
/**
* Handle the Fisherman's Diet ability
*
* @param rankChange The # of levels to change rank for the food
* @param rankChange The # of levels to change rank for the food
* @param eventFoodLevel The initial change in hunger from the event
*
* @return the modified change in hunger for the event
*/
public int handleFishermanDiet(int rankChange, int eventFoodLevel) {
@@ -272,20 +269,20 @@ public class FishingManager extends SkillManager {
}
// Recast in the new spot
EventUtils.callFakeFishEvent(getPlayer(), hook);
mcMMO.p.getServer().getPluginManager().callEvent(new FakePlayerFishEvent(getPlayer(), null, hook, PlayerFishEvent.State.FISHING));
}
public void masterAngler(Fish hook) {
Player player = getPlayer();
Biome biome = player.getLocation().getBlock().getBiome();
double biteChance = hook.getBiteChance();
double biteChance = Math.min(hook.getBiteChance() * Math.max((getSkillLevel() / 200.0), 1.0), 1.0);
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
biteChance = biteChance * 2.0;
}
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
biteChance = biteChance * 2.0;
}
hook.setBiteChance(biteChance);
@@ -297,33 +294,37 @@ public class FishingManager extends SkillManager {
* @param fishingCatch The {@link Item} initially caught
*/
public void handleFishing(Item fishingCatch) {
this.fishingCatch = fishingCatch;
int treasureXp = 0;
Player player = getPlayer();
FishingTreasure treasure = null;
if (Config.getInstance().getFishingDropsEnabled() && Permissions.fishingTreasureHunter(player)) {
treasure = getFishingTreasure();
this.fishingCatch = null;
}
if (treasure != null) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.ItemFound"));
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
treasureXp = treasure.getXp();
ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
McMMOPlayerFishingTreasureEvent event;
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
if (Permissions.magicHunter(player) && ItemUtils.isEnchantable(treasureDrop)) {
enchants = handleMagicHunter(treasureDrop);
}
McMMOPlayerFishingTreasureEvent event = EventUtils.callFishingTreasureEvent(player, treasureDrop, treasure.getXp(), enchants);
if (!event.isCancelled()) {
treasureDrop = event.getTreasure();
treasureXp = event.getXp();
event = new McMMOPlayerMagicHunterEvent(player, treasureDrop, treasureXp, enchants);
}
else {
event = new McMMOPlayerFishingTreasureEvent(player, treasureDrop, treasureXp);
}
mcMMO.p.getServer().getPluginManager().callEvent(event);
treasureDrop = event.getTreasure();
treasureXp = event.getXp();
if (event.isCancelled()) {
treasureDrop = null;
treasureXp = 0;
}
@@ -338,9 +339,10 @@ public class FishingManager extends SkillManager {
}
if (enchanted) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.MagicFound"));
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
}
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
fishingCatch.setItemStack(treasureDrop);
}
}
@@ -352,7 +354,6 @@ public class FishingManager extends SkillManager {
* Handle the vanilla XP boost for Fishing
*
* @param experience The amount of experience initially awarded by the event
*
* @return the modified event damage
*/
public int handleVanillaXpBoost(int experience) {
@@ -438,32 +439,28 @@ public class FishingManager extends SkillManager {
* @return The {@link FishingTreasure} found, or null if no treasure was found.
*/
private FishingTreasure getFishingTreasure() {
double diceRoll = Misc.getRandom().nextDouble() * 100;
FishingTreasure treasure = null;
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
int skillLevel = getSkillLevel();
for (Rarity rarity : Rarity.values()) {
double dropRate = TreasureConfig.getInstance().getItemDropRate(getLootTier(), rarity);
for (FishingTreasure treasure : TreasureConfig.getInstance().fishingRewards) {
int maxLevel = treasure.getMaxLevel();
if (diceRoll <= dropRate) {
if (rarity == Rarity.TRAP) {
handleTraps();
break;
}
List<FishingTreasure> fishingTreasures = TreasureConfig.getInstance().fishingRewards.get(rarity);
treasure = fishingTreasures.get(Misc.getRandom().nextInt(fishingTreasures.size()));
break;
if (treasure.getDropLevel() <= skillLevel && (maxLevel >= skillLevel || maxLevel <= 0)) {
rewards.add(treasure);
}
diceRoll -= dropRate;
}
if (treasure == null) {
if (rewards.isEmpty()) {
return null;
}
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
ItemStack treasureDrop = treasure.getDrop();
if (!SkillUtils.treasureDropSuccessful(treasure.getDropChance(), activationChance)) {
return null;
}
short maxDurability = treasureDrop.getType().getMaxDurability();
if (maxDurability > 0) {
@@ -473,92 +470,41 @@ public class FishingManager extends SkillManager {
return treasure;
}
private void handleTraps() {
Player player = getPlayer();
if (Misc.getRandom().nextBoolean()) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.Boom"));
TNTPrimed tnt = (TNTPrimed) player.getWorld().spawnEntity(fishingCatch.getLocation(), EntityType.PRIMED_TNT);
fishingCatch.setPassenger(tnt);
Vector velocity = fishingCatch.getVelocity();
double magnitude = velocity.length();
fishingCatch.setVelocity(velocity.multiply((magnitude + 1) / magnitude));
tnt.setMetadata(mcMMO.tntsafeMetadataKey, mcMMO.metadataValue);
tnt.setFuseTicks(3 * Misc.TICK_CONVERSION_FACTOR);
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.Poison"));
ThrownPotion thrownPotion = player.getWorld().spawn(fishingCatch.getLocation(), ThrownPotion.class);
thrownPotion.setItem(new Potion(PotionType.POISON).splash().toItemStack(1));
fishingCatch.setPassenger(thrownPotion);
}
}
/**
* Process the Magic Hunter ability
*
* @param treasureDrop The {@link ItemStack} to enchant
*
* @return true if the item has been enchanted
*/
private Map<Enchantment, Integer> handleMagicHunter(ItemStack treasureDrop) {
Player player = getPlayer();
int activationChance = this.activationChance;
if (player.getWorld().hasStorm()) {
activationChance *= Fishing.STORM_MODIFIER;
}
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
List<EnchantmentTreasure> fishingEnchantments = null;
double diceRoll = Misc.getRandom().nextDouble() * 100;
for (Rarity rarity : Rarity.values()) {
if (rarity == Rarity.TRAP || rarity == Rarity.RECORD) {
continue;
}
double dropRate = TreasureConfig.getInstance().getEnchantmentDropRate(getLootTier(), rarity);
if (diceRoll <= dropRate) {
fishingEnchantments = TreasureConfig.getInstance().fishingEnchantments.get(rarity);
break;
}
diceRoll -= dropRate;
}
if (fishingEnchantments == null) {
if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) {
return enchants;
}
List<Enchantment> validEnchantments = getPossibleEnchantments(treasureDrop);
List<EnchantmentTreasure> possibleEnchants = new ArrayList<EnchantmentTreasure>();
for (EnchantmentTreasure enchantmentTreasure : fishingEnchantments) {
if (validEnchantments.contains(enchantmentTreasure.getEnchantment())) {
possibleEnchants.add(enchantmentTreasure);
}
}
if (possibleEnchants.isEmpty()) {
return enchants;
}
List<Enchantment> possibleEnchantments = getPossibleEnchantments(treasureDrop);
// This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant
Collections.shuffle(possibleEnchants, Misc.getRandom());
Collections.shuffle(possibleEnchantments, Misc.getRandom());
int specificChance = 1;
for (EnchantmentTreasure enchantmentTreasure : possibleEnchants) {
Enchantment possibleEnchantment = enchantmentTreasure.getEnchantment();
for (Enchantment possibleEnchantment : possibleEnchantments) {
if (treasureDrop.getItemMeta().hasConflictingEnchant(possibleEnchantment) || Misc.getRandom().nextInt(specificChance) != 0) {
continue;
}
enchants.put(possibleEnchantment, enchantmentTreasure.getLevel());
enchants.put(possibleEnchantment, Math.max(Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1, possibleEnchantment.getStartLevel()));
specificChance *= 2;
specificChance++;
}
return enchants;

View File

@@ -33,7 +33,6 @@ public class Herbalism {
* Convert blocks affected by the Green Thumb & Green Terra abilities.
*
* @param blockState The {@link BlockState} to check ability activation for
*
* @return true if the ability was successful, false otherwise
*/
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
@@ -63,7 +62,6 @@ public class Herbalism {
* Calculate the drop amounts for cacti & sugar cane based on the blocks above them.
*
* @param blockState The {@link BlockState} of the bottom block of the plant
*
* @return the number of bonus drops to award from the blocks in this plant
*/
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
@@ -94,7 +92,6 @@ public class Herbalism {
* Convert blocks affected by the Green Thumb & Green Terra abilities.
*
* @param blockState The {@link BlockState} to check ability activation for
*
* @return true if the ability was successful, false otherwise
*/
protected static boolean convertShroomThumb(BlockState blockState) {

View File

@@ -0,0 +1,77 @@
package com.gmail.nossr50.skills.herbalism;
import java.util.Map;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.google.common.collect.Maps;
public enum HerbalismBlock {
BROWN_MUSHROOM(Material.BROWN_MUSHROOM),
CACTUS(Material.CACTUS),
CARROT(Material.CARROT, Material.CARROT_ITEM),
COCOA(Material.COCOA, new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData())),
CROPS(Material.CROPS, Material.WHEAT),
MELON_BLOCK(Material.MELON_BLOCK, Material.MELON),
NETHER_WARTS(Material.NETHER_WARTS, Material.NETHER_STALK),
POTATO(Material.POTATO, Material.POTATO_ITEM),
PUMPKIN(Material.PUMPKIN),
RED_MUSHROOM(Material.RED_MUSHROOM),
RED_ROSE(Material.RED_ROSE),
SUGAR_CANE_BLOCK(Material.SUGAR_CANE_BLOCK, Material.SUGAR_CANE),
VINE(Material.VINE),
WATER_LILY(Material.WATER_LILY),
YELLOW_FLOWER(Material.YELLOW_FLOWER);
private Material blockType;
private ItemStack dropItem;
private final static Map<Material, HerbalismBlock> BY_MATERIAL = Maps.newHashMap();
private HerbalismBlock(Material blockType) {
this(blockType, new ItemStack(blockType));
}
private HerbalismBlock(Material blockType, Material dropType) {
this(blockType, new ItemStack(dropType));
}
private HerbalismBlock(Material blockType, ItemStack dropItem) {
this.blockType = blockType;
this.dropItem = dropItem;
}
static {
for (HerbalismBlock herbalismBlock : values()) {
BY_MATERIAL.put(herbalismBlock.blockType, herbalismBlock);
}
}
public ItemStack getDropItem() {
return dropItem;
}
public int getXpGain() {
return ExperienceConfig.getInstance().getXp(SkillType.HERBALISM, blockType);
}
public boolean canDoubleDrop() {
return Config.getInstance().getDoubleDropsEnabled(SkillType.HERBALISM, blockType);
}
public boolean hasGreenThumbPermission(Player player) {
return Permissions.greenThumbPlant(player, blockType);
}
public static HerbalismBlock getHerbalismBlock(Material blockType) {
return BY_MATERIAL.get(blockType);
}
}

View File

@@ -1,7 +1,6 @@
package com.gmail.nossr50.skills.herbalism;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.bukkit.CropState;
@@ -18,7 +17,6 @@ import org.bukkit.material.NetherWarts;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@@ -30,7 +28,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModUtils;
import com.gmail.nossr50.util.Permissions;
@@ -78,9 +75,8 @@ public class HerbalismManager extends SkillManager {
/**
* Handle the Farmer's Diet ability
*
* @param rankChange The # of levels to change rank for the food
* @param rankChange The # of levels to change rank for the food
* @param eventFoodLevel The initial change in hunger from the event
*
* @return the modified change in hunger for the event
*/
public int farmersDiet(int rankChange, int eventFoodLevel) {
@@ -91,7 +87,6 @@ public class HerbalismManager extends SkillManager {
* Process the Green Terra ability.
*
* @param blockState The {@link BlockState} to check ability activation for
*
* @return true if the ability was successful, false otherwise
*/
public boolean processGreenTerra(BlockState blockState) {
@@ -116,10 +111,11 @@ public class HerbalismManager extends SkillManager {
}
/**
*
*
* @param blockState The {@link BlockState} to check ability activation for
*/
public void herbalismBlockCheck(BlockState blockState) {
Player player = getPlayer();
Material material = blockState.getType();
boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK);
@@ -127,32 +123,21 @@ public class HerbalismManager extends SkillManager {
return;
}
if (!canBlockCheck()) {
return;
}
Collection<ItemStack> drops = null;
HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(material);
ItemStack drop = null;
int amount = 1;
int xp = 0;
boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility());
if (ModUtils.isCustomHerbalismBlock(blockState)) {
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
xp = customBlock.getXpGain();
if (Permissions.doubleDrops(player, skill) && customBlock.isDoubleDropEnabled()) {
drops = blockState.getBlock().getDrops();
}
}
else {
if (Permissions.greenThumbPlant(player, material)) {
if (herbalismBlock != null) {
if (herbalismBlock.hasGreenThumbPermission(getPlayer())) {
processGreenThumbPlants(blockState, greenTerra);
}
xp = ExperienceConfig.getInstance().getXp(skill, material);
xp = herbalismBlock.getXpGain();
if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.doubleDrops(player, skill)) {
drops = blockState.getBlock().getDrops();
if (herbalismBlock.canDoubleDrop() && Permissions.doubleDrops(getPlayer(), skill)) {
drop = herbalismBlock.getDropItem();
}
if (!oneBlockPlant) {
@@ -160,18 +145,27 @@ public class HerbalismManager extends SkillManager {
xp *= amount;
}
}
else {
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
xp = customBlock.getXpGain();
if (Permissions.doubleDrops(getPlayer(), skill)) {
int minimumDropAmount = customBlock.getMinimumDropAmount();
int maximumDropAmount = customBlock.getMaximumDropAmount();
drop = customBlock.getItemDrop();
amount = Misc.getRandom().nextInt(maximumDropAmount - minimumDropAmount + 1) + minimumDropAmount;
}
}
applyXpGain(xp);
if (drops == null) {
if (drop == null) {
return;
}
for (int i = greenTerra ? 2 : 1; i != 0; i--) {
if (SkillUtils.activationSuccessful(getSkillLevel(), getActivationChance(), Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) {
for (ItemStack item : drops) {
Misc.dropItems(blockState.getLocation(), item, amount);
}
Misc.dropItems(blockState.getLocation(), drop, amount);
}
}
}
@@ -180,7 +174,6 @@ public class HerbalismManager extends SkillManager {
* Process the Green Thumb ability for blocks.
*
* @param blockState The {@link BlockState} to check ability activation for
*
* @return true if the ability was successful, false otherwise
*/
public boolean processGreenThumbBlocks(BlockState blockState) {
@@ -196,7 +189,6 @@ public class HerbalismManager extends SkillManager {
* Process the Hylian Luck ability.
*
* @param blockState The {@link BlockState} to check ability activation for
*
* @return true if the ability was successful, false otherwise
*/
public boolean processHylianLuck(BlockState blockState) {
@@ -231,16 +223,14 @@ public class HerbalismManager extends SkillManager {
return false;
}
Player player = getPlayer();
if (treasures.isEmpty() || EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) {
if (treasures.isEmpty()) {
return false;
}
blockState.setType(Material.AIR);
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
getPlayer().sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
return true;
}
@@ -248,7 +238,6 @@ public class HerbalismManager extends SkillManager {
* Process the Shroom Thumb ability.
*
* @param blockState The {@link BlockState} to check ability activation for
*
* @return true if the ability was successful, false otherwise
*/
public boolean processShroomThumb(BlockState blockState) {
@@ -286,28 +275,7 @@ public class HerbalismManager extends SkillManager {
private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) {
Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory();
ItemStack seed = null;
switch (blockState.getType()) {
case CARROT:
seed = new ItemStack(Material.CARROT_ITEM);
break;
case CROPS:
seed = new ItemStack(Material.SEEDS);
break;
case NETHER_WARTS:
seed = new ItemStack(Material.NETHER_STALK);
break;
case POTATO:
seed = new ItemStack(Material.POTATO_ITEM);
break;
default:
break;
}
ItemStack seed = (blockState.getType() == Material.CROPS) ? new ItemStack(Material.SEEDS) : HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem();
if (!playerInventory.containsAtLeast(seed, 1)) {
return;

View File

@@ -7,15 +7,63 @@ import com.gmail.nossr50.config.Config;
public class BlastMining {
// The order of the values is extremely important, a few methods depend on it to work properly
public enum Tier {
EIGHT(8),
SEVEN(7),
SIX(6),
FIVE(5),
FOUR(4),
THREE(3),
TWO(2),
ONE(1);
protected enum Tier {
EIGHT(8) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank8(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank8(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank8(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank8(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank8(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank8(); }},
SEVEN(7) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank7(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank7(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank7(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank7(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank7(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank7(); }},
SIX(6) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank6(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank6(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank6(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank6(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank6(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank6(); }},
FIVE(5) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank5(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank5(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank5(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank5(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank5(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank5(); }},
FOUR(4) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank4(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank4(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank4(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank4(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank4(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank4(); }},
THREE(3) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank3(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank3(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank3(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank3(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank3(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank3(); }},
TWO(2) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank2(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank2(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank2(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank2(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank2(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank2(); }},
ONE(1) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank1(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank1(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank1(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank1(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank1(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank1(); }};
int numerical;
@@ -27,29 +75,12 @@ public class BlastMining {
return numerical;
}
protected int getLevel() {
return AdvancedConfig.getInstance().getBlastMiningRankLevel(this);
}
protected double getBlastRadiusModifier() {
return AdvancedConfig.getInstance().getBlastRadiusModifier(this);
}
protected double getOreBonus() {
return AdvancedConfig.getInstance().getOreBonus(this);
}
protected double getDebrisReduction() {
return AdvancedConfig.getInstance().getDebrisReduction(this);
}
protected double getBlastDamageDecrease() {
return AdvancedConfig.getInstance().getBlastDamageDecrease(this);
}
protected int getDropMultiplier() {
return AdvancedConfig.getInstance().getDropMultiplier(this);
}
abstract protected int getLevel();
abstract protected double getBlastRadiusModifier();
abstract protected double getOreBonus();
abstract protected double getDebrisReduction();
abstract protected double getBlastDamageDecrease();
abstract protected int getDropMultiplier();
}
public static Material detonator = Config.getInstance().getDetonatorItem();

View File

@@ -1,5 +1,6 @@
package com.gmail.nossr50.skills.mining;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.inventory.ItemStack;
@@ -7,6 +8,7 @@ import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModUtils;
@@ -24,13 +26,11 @@ public class Mining {
Material blockType = blockState.getType();
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType);
if (xp == 0) {
if (blockType == Material.GLOWING_REDSTONE_ORE) {
xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, Material.REDSTONE_ORE);
}
else if (ModUtils.isCustomMiningBlock(blockState)) {
xp = ModUtils.getCustomBlock(blockState).getXpGain();
}
if (blockType == Material.GLOWING_REDSTONE_ORE) {
xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, Material.REDSTONE_ORE);
}
else if (xp == 0 && ModUtils.isCustomMiningBlock(blockState)) {
xp = ModUtils.getCustomBlock(blockState).getXpGain();
}
return xp;
@@ -86,7 +86,10 @@ public class Mining {
* @param blockState The {@link BlockState} to check ability activation for
*/
protected static void handleMiningDrops(BlockState blockState) {
switch (blockState.getType()) {
Material blockType = blockState.getType();
Location location = blockState.getLocation();
switch (blockType) {
case COAL_ORE:
case DIAMOND_ORE:
case EMERALD_ORE:
@@ -99,21 +102,36 @@ public class Mining {
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case REDSTONE_ORE:
case SANDSTONE:
case QUARTZ_ORE:
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
return;
case GLOWING_REDSTONE_ORE:
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
for (ItemStack drop : blockState.getBlock().getDrops()) {
Misc.dropItem(location, drop);
}
return;
case GLOWING_REDSTONE_ORE:
case REDSTONE_ORE:
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
for (ItemStack drop : blockState.getBlock().getDrops()) {
Misc.dropItem(location, drop);
}
}
return;
default:
if (ModUtils.isCustomMiningBlock(blockState)) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
int minimumDropAmount = customBlock.getMinimumDropAmount();
int maximumDropAmount = customBlock.getMaximumDropAmount();
ItemStack dropItem = customBlock.getItemDrop();
if (minimumDropAmount != maximumDropAmount) {
Misc.dropItems(location, dropItem, minimumDropAmount);
Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount);
}
else {
Misc.dropItems(location, dropItem, minimumDropAmount);
}
}
return;
}

View File

@@ -22,9 +22,7 @@ import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
@@ -71,7 +69,7 @@ public class MiningManager extends SkillManager {
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
}
if ((ModUtils.isCustomMiningBlock(blockState) && !ModUtils.getCustomBlock(blockState).isDoubleDropEnabled()) || material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
if (material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
return;
}
@@ -96,7 +94,7 @@ public class MiningManager extends SkillManager {
Player player = getPlayer();
Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
if (targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player, true) || !blastMiningCooldownOver()) {
if (targetBlock.getType() != Material.TNT || !SkillUtils.blockBreakSimulate(targetBlock, player, true) || !blastMiningCooldownOver()) {
return;
}
@@ -173,7 +171,6 @@ public class MiningManager extends SkillManager {
* Increases the blast radius of the explosion.
*
* @param radius to modify
*
* @return modified radius
*/
public float biggerBombs(float radius) {

View File

@@ -4,15 +4,23 @@ import com.gmail.nossr50.config.AdvancedConfig;
public class ArcaneForging {
// The order of the values is extremely important, a few methods depend on it to work properly
public enum Tier {
EIGHT(8),
SEVEN(7),
SIX(6),
FIVE(5),
FOUR(4),
THREE(3),
TWO(2),
ONE(1);
protected enum Tier {
FOUR(4) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels4(); }
@Override public double getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4(); }
@Override public double getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }},
THREE(3) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels3(); }
@Override public double getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3(); }
@Override public double getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank3(); }},
TWO(2) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels2(); }
@Override public double getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2(); }
@Override public double getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank2(); }},
ONE(1) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels1(); }
@Override public double getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1(); }
@Override public double getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank1(); }};
int numerical;
@@ -24,17 +32,9 @@ public class ArcaneForging {
return numerical;
}
protected int getLevel() {
return AdvancedConfig.getInstance().getArcaneForgingRankLevel(this);
}
protected double getKeepEnchantChance() {
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChance(this);
}
protected double getDowngradeEnchantChance() {
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChance(this);
}
abstract protected int getLevel();
abstract protected double getKeepEnchantChance();
abstract protected double getDowngradeEnchantChance();
}
public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled();

View File

@@ -127,14 +127,14 @@ public class Repair {
if (recipe instanceof ShapelessRecipe) {
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData() == repairData)) {
quantity += ingredient.getAmount();
}
}
}
else if (recipe instanceof ShapedRecipe) {
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData().equals(repairData))) {
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getData() == repairData)) {
quantity += ingredient.getAmount();
}
}

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.skills.repair.repairables;
package com.gmail.nossr50.skills.repair;
import org.bukkit.entity.Player;
@@ -13,7 +13,6 @@ public enum RepairItemType {
* Get the base permissions associated with this RepairItemType.
*
* @param player The player to check the permissions for
*
* @return true if the player has permissions, false otherwise
*/
public boolean getPermissions(Player player) {

View File

@@ -17,11 +17,10 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.repair.ArcaneForging.Tier;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
@@ -116,7 +115,10 @@ public class RepairManager extends SkillManager {
short newDurability = repairCalculate(startDurability, baseRepairAmount); // When I asked for sons?
// Call event
if (EventUtils.callRepairCheckEvent(player, (short) (startDurability - newDurability), toRemove, item).isCancelled()) {
McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (startDurability - newDurability), toRemove, item);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
@@ -253,9 +255,8 @@ public class RepairManager extends SkillManager {
/**
* Computes repair bonuses.
*
* @param durability The durability of the item being repaired
* @param durability The durability of the item being repaired
* @param repairAmount The base amount of durability repaired to the item
*
* @return The final amount of durability repaired to the item
*/
private short repairCalculate(short durability, int repairAmount) {

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.skills.repair.repairables;
package com.gmail.nossr50.skills.repair;
import org.bukkit.Material;
import org.bukkit.entity.Player;

View File

@@ -1,8 +1,7 @@
package com.gmail.nossr50.skills.repair.repairables;
package com.gmail.nossr50.skills.repair;
import org.bukkit.Material;
public interface Repairable {
/**
* Gets the type of this repairable item
@@ -41,7 +40,7 @@ public interface Repairable {
/**
* Gets the minimum quantity of repair materials ignoring all other repair bonuses
* <p/>
*
* This is typically set to the number of items needed to create that item, for example 5 for helmets or 2 for swords
*
* @return the minimum number of items
@@ -57,7 +56,7 @@ public interface Repairable {
/**
* Gets the base repair durability on which to calculate bonuses.
* <p/>
*
* This is actually the maximum durability divided by the minimum quantity
*
* @return the base repair durability

View File

@@ -1,8 +1,7 @@
package com.gmail.nossr50.skills.repair.repairables;
package com.gmail.nossr50.skills.repair;
import org.bukkit.Material;
public class RepairableFactory {
public static Repairable getRepairable(Material itemMaterial, Material repairMaterial, byte repairMetadata, int minimumQuantity, short maximumDurability) {
return getRepairable(itemMaterial, repairMaterial, repairMetadata, 0, minimumQuantity, maximumDurability, RepairItemType.OTHER, RepairMaterialType.OTHER, 1);

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.skills.repair.repairables;
package com.gmail.nossr50.skills.repair;
import java.util.List;

View File

@@ -0,0 +1,13 @@
package com.gmail.nossr50.skills.repair;
public class RepairableManagerFactory {
public static RepairableManager getRepairManager() {
// TODO: Add in loading from config what type of manager we want.
return new SimpleRepairableManager();
}
public static RepairableManager getRepairManager(int repairablesSize) {
// TODO: Add in loading from config what type of manager we want.
return new SimpleRepairableManager(repairablesSize);
}
}

Some files were not shown because too many files have changed in this diff Show More