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

Compare commits

..

80 Commits

Author SHA1 Message Date
GJ
fcdb5abaea Reimplement Impact event 2013-11-12 12:25:09 -05:00
TfT_02
b1095ce1a6 Fix things after rebase 2013-11-12 17:05:25 +01:00
TfT_02
2497c62ada Move changelog entries to 1.4.08 2013-11-12 17:05:25 +01:00
GJ
997685b5ec More event work. 2013-11-12 17:05:24 +01:00
GJ
a65bcb9e5d More event work. 2013-11-12 17:05:24 +01:00
GJ
26d5db07ef Axe events. 2013-11-12 17:05:24 +01:00
GJ
d6fbf1be34 Move standard activation checks into activation function, Archery refactoring, Unarmed cleanup, start work on Axe events. 2013-11-12 17:05:24 +01:00
GJ
965035fa72 Archery events & bugfixes
- Added custom events for Skill Shot and Daze.
- Archery metadata is now stored directly as a location, rather than a
string.
- Fixed bug where arrows weren't properly tracked.
- Use HashMap instead of ArrayList for entity tracking.
2013-11-12 17:05:24 +01:00
GJ
a99293aa48 We should ALWAYS inform other plugins of what we're doing. 2013-11-12 17:05:24 +01:00
GJ
20967bea92 Add roll event, remove particle flag from the dodge event. 2013-11-12 17:05:24 +01:00
GJ
e10b70c422 Add event for Dodge 2013-11-12 17:05:24 +01:00
GJ
071c568353 Add boolean for particle effects to ability events. 2013-11-12 17:05:24 +01:00
GJ
d5fb19a7db Make ability events separate from skill events 2013-11-12 17:05:23 +01:00
GJ
badabeb8e4 Refactor experience events into separate packages.
Level events are now in one package, and XP events are now in a second
package.
2013-11-12 17:05:23 +01:00
GJ
d0a1d44fa2 Add new McMMOPlayerXpLossEvent 2013-11-12 17:05:23 +01:00
GJ
fdaa42edd3 Fire appropriate level change events for Hardcore mode. 2013-11-12 17:05:23 +01:00
GJ
e904e34556 Update Korean translation
Closes PR #1613 from @wolfdate25
2013-11-12 08:15:58 -05:00
TfT_02
445f805bb8 Set the treasure drop after using .clone()
Fixes #1603
2013-11-12 12:49:16 +01:00
t00thpick1
df77b9d0ed Parenthesis 2013-11-10 13:56:15 -05:00
t00thpick1
29f2525b58 Tend toward the smaller values, and configurable maximum for horse jump strength 2013-11-10 13:54:45 -05:00
TfT_02
5a68c7a335 Fixed bug which prevented gaining Acrobatics XP 2013-11-10 00:52:30 +01:00
GJ
69ef7f40d8 Command cleanup. 2013-11-08 23:14:11 +01:00
GJ
d1d6b80676 Allow repair of items without a recipe. 2013-11-08 10:52:43 -05:00
GJ
dfe83ff497 Fix divide by zero bug
Minimum Level & Minimum Quantity were accidentally flipped.
2013-11-07 09:13:56 -05:00
riking
e5acf6d936 Also clone fishing treasures, use alternate Wool method
The alternate wool method is testing, the treasure clone is there to stay ;)
2013-11-06 21:34:16 -08:00
riking
bca0ca6766 Fix Shake poisoning the treasure cache with Wither skeletons
The returned ItemStack is modified for both Sheep and Skeletons, so a copy should be returned.
2013-11-06 21:03:13 -08:00
GJ
f17b5faaf6 Parenthesis are good. 2013-11-06 14:52:19 -05:00
GJ
f20fa571f1 Update changelog. 2013-11-06 11:56:50 -05:00
GJ
b90d1c31c7 Updated localization files
Includes new Portuguese (Brazil) translation provided by @FabioZumbi12
in #1585

Includes new Korean translation provided by @wolfwork in #1258
2013-11-06 09:48:05 -05:00
GJ
cf56ca35eb Tweaked durability handling slightly.
Now routes everything through one function to handle enchants and max
durability. Use max durability from RepairableManager by default to
account for mod tools.
2013-11-06 08:45:20 -05:00
TfT_02
c31f5b5782 Account for Unbreaking enchantment when using abilities 2013-11-05 14:51:54 +01:00
GJ
af98c8eb59 Best way to handle minimum quantities.
Check repair function first, assuming the item isn't null, otherwise
check the config. If not found, check config.
2013-11-04 11:01:14 -05:00
TfT_02
3a10b2d83c Make sure we're not setting a bite chance > 1.0
Fixes #1592
2013-11-04 10:32:05 +01:00
TfT_02
32e7c48fd8 Change this message to something that makes sense
The old message was confusing see #1593
2013-11-03 22:49:39 +01:00
Glitchfinder
af578870c7 Defaulted quantities should be defaulted everywhere.
Fixes #1581
2013-11-03 09:40:04 -08:00
TfT_02
cd470d5497 Fix a NPE which occured when there was no backups folder 2013-11-03 14:09:41 +01:00
TfT_02
a9c5e2a04f Don't send a message to the console if no backups were deleted 2013-11-02 21:50:49 +01:00
TfT_02
0196fd8447 Fix the update checker 2013-11-02 21:49:20 +01:00
TfT_02
b1458840e7 Permissions should be lowercase 2013-11-02 19:29:36 +01:00
TfT_02
1fea786669 Added bypass permission for finding Fishing traps 2013-11-02 19:25:02 +01:00
TfT_02
6f9a57751e We can't schedule tasks in onDisable() 2013-11-01 17:39:03 +01:00
GJ
2e1c585005 Fix issue with updating players that are offline. 2013-11-01 12:38:40 -04:00
GJ
811626e67b Cleanup. 2013-11-01 11:54:51 -04:00
TfT_02
cdfd81a67a Cleanup ZipLibrary class 2013-11-01 16:44:03 +01:00
TfT_02
408b8b2107 Added automatic cleanup of backups folder
By default mcMMO keeps the following files:
 * All files from the last 24 hours
 * Daily backups of the past week
 * Weekly backups of the past months

Adds #1574
2013-11-01 16:43:56 +01:00
GJ
6d5f3a52f4 Don't process chat if the mcMMOPlayer is null.
The player should ALWAYS be online when chatting, but depending on
external plugins and applications, this is not always properly
implemented. Fixes #1578
2013-11-01 09:30:10 -04:00
GJ
2cdf08de9f Allow offline players for chat events.
This fixes issues with plugins or applications that rely on JSONAPI to
chat. Fixes #1578
2013-11-01 09:12:06 -04:00
GJ
71141a0f8d Minimum quantity should default to 2.
Fixes #1581
2013-11-01 08:22:14 -04:00
TfT_02
bded936af5 Cleanup our imports 2013-10-31 22:30:05 +01:00
GJ
caaac232d7 Cleanup CombatUtils.
Opting to stick with the if-else rather than the switch statement,
because I think it's slightly easier to read.
2013-10-31 15:03:06 -04:00
GJ
a9d51dad34 Clean up Smelting checks.
Now uses recipes to check if an item is the result of smelting.
2013-10-31 14:29:06 -04:00
GJ
88296da0af Removed MCPC+ workaround.
This has been fixed by MCPC+ starting with build 112.

Addresses #1549
2013-10-31 13:28:54 -04:00
GJ
de3c4f8fd7 Smelting now works with custom ores.
Also fixed exploit where smelting XP could be awarded for some
non-smeltable materials.
2013-10-31 13:25:06 -04:00
GJ
1785bab504 Fix bug with Salvage config value.
After our renames and updates, Salvage was not reading the config value
for the anvil material properly.
2013-10-31 09:09:52 -04:00
GJ
41da32cd1b Added options to disable various sound effects.
Fixes #1577
2013-10-31 09:03:29 -04:00
GJ
93d586592e Move these checks up.
These checks need to happen sooner because they may impact config
loading, specifically the MCPC+ check.

Fixes #1549
2013-10-31 08:15:30 -04:00
Glitchfinder
d6c6c75157 Experience is occasionally zero or cast to zero.
Fixes #1575 and fixes #1576
2013-10-30 15:49:47 -07:00
GJ
4889769522 Workaround MCPC+ shortcomings for now.
Fixes #1549
2013-10-30 15:33:37 -04:00
TfT_02
6c70de6a58 Also backup experience.yml 2013-10-30 12:33:34 +01:00
GJ
fd9154e009 Fixed bug with toggle commands not properly displaying the success message. 2013-10-29 11:45:27 -04:00
GJ
97b9214d6e Wrap these inside McMMOPlayer for easier access. 2013-10-29 11:02:57 -04:00
GJ
a8d1376533 More minor cleanup. 2013-10-29 10:01:30 -04:00
GJ
3be443c63c Cleanup some XP functions, remove unused scoreboard values, minor refactoring. 2013-10-29 09:49:41 -04:00
GJ
cc2c9eb21d Move this to the skill itself. 2013-10-28 16:32:40 -04:00
GJ
9b3ae5c729 These belong in their managers, not in McMMOPlayer 2013-10-28 16:14:52 -04:00
GJ
ccb7fc5886 Remove, don't just comment out. 2013-10-28 16:04:55 -04:00
GJ
60d69e3cc4 Create wrapper to handle all PTP data. 2013-10-28 15:49:48 -04:00
riking
f64f62492f Reinstate static color list, clarify intent 2013-10-28 12:47:25 -07:00
GJ
3fe936306b Oops. 2013-10-28 15:19:47 -04:00
GJ
c79f8043ad Use proper functions where they exist, and move functions to better locations. 2013-10-28 15:12:24 -04:00
GJ
8369ae4616 Don't use a class variable here. 2013-10-28 14:14:20 -04:00
GJ
4715688fe8 Update changelog. 2013-10-28 14:07:41 -04:00
GJ
62e03a4ef5 Black is hard to read. 2013-10-28 13:58:34 -04:00
GJ
9ef3c721df Formatting cleanup from the scoreboard update. Also handle skill permissions differently. 2013-10-28 13:04:46 -04:00
TfT_02
f55039ac6b Earn XP when using Shake
Adds #1564
2013-10-28 17:38:03 +01:00
TfT_02
be792a1052 Fix exploitPrevention() and add Javadocs 2013-10-28 15:39:47 +01:00
GJ
c612036db3 Don't try to find a treasure if there aren't any.
Fixes #1572
2013-10-28 08:52:55 -04:00
GJ
ad4ee6f402 Cleanup exploit prevention method. 2013-10-28 08:17:06 -04:00
TfT_02
49a5bd2ba6 We can move this check to exploitPrevention() 2013-10-26 00:50:31 +02:00
GJ
8aac6a992b Back to active development. 2013-10-25 17:11:54 -04:00
189 changed files with 4198 additions and 3395 deletions

View File

@@ -7,6 +7,22 @@ Key:
! Change ! Change
- Removal - Removal
Version 1.4.08-dev
+ Added the possibility to gain experience when using Fishing "Shake"
+ Added config options to disable various sound effects
+ Smelting now works with custom ores - add smelting XP value to blocks.yml, or it will default to 1/10th of normal XP.
+ Added automatic cleanup of backups folder.
+ Added bypass permission for finding Fishing traps
= Fixed bug with toggle commands not properly displaying the success message.
= Fixed IllegalArgumentException caused by an empty Fishing treasure category
= Fixed bug with Salvage not reading the config value for the anvil material.
= Fixed exploit where you could receive smelting XP for improper items
= Fixed bug where the Unbreaking enchantment was ignored when using "Super Breaker" or "Giga Drill Breaker"
= Fixed bug which prevented players from gaining Acrobatics XP when the setting 'Prevent_XP_After_Teleport' was set to false
= Fixed McMMOPlayerDisarmEvent reporting the skill level of the defending player, not the attacking player.
= Fixed bug where arrow retrieval was not properly detecting entities that already existed in the tracker
! Updated localization files
Version 1.4.07 Version 1.4.07
+ Added XP boost to Acrobatics when wearing Boots of Feather Falling + 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 SQL Database can now recover from a dropped connection without losing data. (Thanks Riking!)

View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId> <groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId> <artifactId>mcMMO</artifactId>
<version>1.4.07</version> <version>1.4.08-dev1</version>
<name>mcMMO</name> <name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url> <url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement> <issueManagement>

View File

@@ -50,34 +50,34 @@ public final class AbilityAPI {
} }
public static void resetCooldowns(Player player) { public static void resetCooldowns(Player player) {
UserManager.getPlayer(player).getProfile().resetCooldowns(); UserManager.getPlayer(player).resetCooldowns();
} }
public static void setBerserkCooldown(Player player, long cooldown) { public static void setBerserkCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.BERSERK, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.BERSERK, cooldown);
} }
public static void setGigaDrillBreakerCooldown(Player player, long cooldown) { public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.GIGA_DRILL_BREAKER, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.GIGA_DRILL_BREAKER, cooldown);
} }
public static void setGreenTerraCooldown(Player player, long cooldown) { public static void setGreenTerraCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.GREEN_TERRA, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.GREEN_TERRA, cooldown);
} }
public static void setSerratedStrikesCooldown(Player player, long cooldown) { public static void setSerratedStrikesCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.SERRATED_STRIKES, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.SERRATED_STRIKES, cooldown);
} }
public static void setSkullSplitterCooldown(Player player, long cooldown) { public static void setSkullSplitterCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.SKULL_SPLITTER, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.SKULL_SPLITTER, cooldown);
} }
public static void setSuperBreakerCooldown(Player player, long cooldown) { public static void setSuperBreakerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.SUPER_BREAKER, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.SUPER_BREAKER, cooldown);
} }
public static void setTreeFellerCooldown(Player player, long cooldown) { public static void setTreeFellerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).getProfile().setSkillDATS(AbilityType.TREE_FELLER, cooldown); UserManager.getPlayer(player).setAbilityDATS(AbilityType.TREE_FELLER, cooldown);
} }
} }

View File

@@ -76,7 +76,7 @@ public final class ChatAPI {
* @return true if the player is using party chat, false otherwise * @return true if the player is using party chat, false otherwise
*/ */
public static boolean isUsingPartyChat(Player player) { public static boolean isUsingPartyChat(Player player) {
return UserManager.getPlayer(player).getPartyChatMode(); return UserManager.getPlayer(player).isChatEnabled(ChatMode.PARTY);
} }
/** /**
@@ -86,7 +86,7 @@ public final class ChatAPI {
* @return true if the player is using party chat, false otherwise * @return true if the player is using party chat, false otherwise
*/ */
public static boolean isUsingPartyChat(String playerName) { public static boolean isUsingPartyChat(String playerName) {
return UserManager.getPlayer(playerName).getPartyChatMode(); return UserManager.getPlayer(playerName).isChatEnabled(ChatMode.PARTY);
} }
/** /**
@@ -96,7 +96,7 @@ public final class ChatAPI {
* @return true if the player is using admin chat, false otherwise * @return true if the player is using admin chat, false otherwise
*/ */
public static boolean isUsingAdminChat(Player player) { public static boolean isUsingAdminChat(Player player) {
return UserManager.getPlayer(player).getAdminChatMode(); return UserManager.getPlayer(player).isChatEnabled(ChatMode.ADMIN);
} }
/** /**
@@ -106,7 +106,7 @@ public final class ChatAPI {
* @return true if the player is using admin chat, false otherwise * @return true if the player is using admin chat, false otherwise
*/ */
public static boolean isUsingAdminChat(String playerName) { public static boolean isUsingAdminChat(String playerName) {
return UserManager.getPlayer(playerName).getAdminChatMode(); return UserManager.getPlayer(playerName).isChatEnabled(ChatMode.ADMIN);
} }
/** /**
@@ -115,7 +115,7 @@ public final class ChatAPI {
* @param player The player to toggle party chat on. * @param player The player to toggle party chat on.
*/ */
public static void togglePartyChat(Player player) { public static void togglePartyChat(Player player) {
UserManager.getPlayer(player).togglePartyChat(); UserManager.getPlayer(player).toggleChat(ChatMode.PARTY);
} }
/** /**
@@ -124,7 +124,7 @@ public final class ChatAPI {
* @param playerName The name of the player to toggle party chat on. * @param playerName The name of the player to toggle party chat on.
*/ */
public static void togglePartyChat(String playerName) { public static void togglePartyChat(String playerName) {
UserManager.getPlayer(playerName).togglePartyChat(); UserManager.getPlayer(playerName).toggleChat(ChatMode.PARTY);
} }
/** /**
@@ -133,7 +133,7 @@ public final class ChatAPI {
* @param player The player to toggle admin chat on. * @param player The player to toggle admin chat on.
*/ */
public static void toggleAdminChat(Player player) { public static void toggleAdminChat(Player player) {
UserManager.getPlayer(player).toggleAdminChat(); UserManager.getPlayer(player).toggleChat(ChatMode.ADMIN);
} }
/** /**
@@ -142,7 +142,7 @@ public final class ChatAPI {
* @param playerName The name of the player to toggle party chat on. * @param playerName The name of the player to toggle party chat on.
*/ */
public static void toggleAdminChat(String playerName) { public static void toggleAdminChat(String playerName) {
UserManager.getPlayer(playerName).toggleAdminChat(); UserManager.getPlayer(playerName).toggleChat(ChatMode.ADMIN);
} }
private static ChatManager getPartyChatManager(Plugin plugin, String party) { private static ChatManager getPartyChatManager(Plugin plugin, String party) {

View File

@@ -184,7 +184,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static int getXP(Player player, String skillType) { public static int getXP(Player player, String skillType) {
return UserManager.getPlayer(player).getProfile().getSkillXpLevel(getNonChildSkillType(skillType)); return UserManager.getPlayer(player).getSkillXpLevel(getNonChildSkillType(skillType));
} }
/** /**
@@ -217,7 +217,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static float getXPRaw(Player player, String skillType) { public static float getXPRaw(Player player, String skillType) {
return UserManager.getPlayer(player).getProfile().getSkillXpLevelRaw(getNonChildSkillType(skillType)); return UserManager.getPlayer(player).getSkillXpLevelRaw(getNonChildSkillType(skillType));
} }
/** /**
@@ -250,7 +250,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static int getXPToNextLevel(Player player, String skillType) { public static int getXPToNextLevel(Player player, String skillType) {
return UserManager.getPlayer(player).getProfile().getXpToLevel(getNonChildSkillType(skillType)); return UserManager.getPlayer(player).getXpToLevel(getNonChildSkillType(skillType));
} }
/** /**
@@ -323,7 +323,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static void addLevel(Player player, String skillType, int levels) { public static void addLevel(Player player, String skillType, int levels) {
UserManager.getPlayer(player).getProfile().addLevels(getSkillType(skillType), levels); UserManager.getPlayer(player).addLevels(getSkillType(skillType), levels);
} }
/** /**
@@ -369,7 +369,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static int getLevel(Player player, String skillType) { public static int getLevel(Player player, String skillType) {
return UserManager.getPlayer(player).getProfile().getSkillLevel(getSkillType(skillType)); return UserManager.getPlayer(player).getSkillLevel(getSkillType(skillType));
} }
/** /**
@@ -492,7 +492,7 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid * @throws InvalidSkillException if the given skill is not valid
*/ */
public static void setLevel(Player player, String skillType, int skillLevel) { public static void setLevel(Player player, String skillType, int skillLevel) {
UserManager.getPlayer(player).getProfile().modifySkill(getSkillType(skillType), skillLevel); UserManager.getPlayer(player).modifySkill(getSkillType(skillType), skillLevel);
} }
/** /**
@@ -524,7 +524,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static void setXP(Player player, String skillType, int newValue) { public static void setXP(Player player, String skillType, int newValue) {
UserManager.getPlayer(player).getProfile().setSkillXpLevel(getNonChildSkillType(skillType), newValue); UserManager.getPlayer(player).setSkillXpLevel(getNonChildSkillType(skillType), newValue);
} }
/** /**
@@ -557,7 +557,7 @@ public final class ExperienceAPI {
* @throws UnsupportedOperationException if the given skill is a child skill * @throws UnsupportedOperationException if the given skill is a child skill
*/ */
public static void removeXP(Player player, String skillType, int xp) { public static void removeXP(Player player, String skillType, int xp) {
UserManager.getPlayer(player).getProfile().removeXp(getNonChildSkillType(skillType), xp); UserManager.getPlayer(player).removeXp(getNonChildSkillType(skillType), xp);
} }
/** /**
@@ -582,18 +582,7 @@ public final class ExperienceAPI {
private static void addOfflineXP(String playerName, SkillType skill, int XP) { private static void addOfflineXP(String playerName, SkillType skill, int XP) {
PlayerProfile profile = getOfflineProfile(playerName); PlayerProfile profile = getOfflineProfile(playerName);
if (skill.isChildSkill()) { profile.addXp(skill, XP);
Set<SkillType> parentSkills = FamilyTree.getParents(skill);
for (SkillType parentSkill : parentSkills) {
profile.setSkillXpLevel(parentSkill, profile.getSkillLevel(parentSkill) + (XP / parentSkills.size()));
}
profile.save();
return;
}
profile.setSkillXpLevel(skill, profile.getSkillXpLevel(skill) + XP);
profile.save(); profile.save();
} }

View File

@@ -7,7 +7,6 @@ import java.util.Set;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@@ -32,7 +31,7 @@ public class KrakenCommand implements TabExecutor {
return true; return true;
} }
UserManager.getPlayer((Player) sender).getFishingManager().unleashTheKraken(); UserManager.getPlayer(sender.getName()).getFishingManager().unleashTheKraken();
return true; return true;
case 1: case 1:

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.commands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@@ -17,13 +18,13 @@ public class McabilityCommand extends ToggleCommand {
} }
@Override @Override
protected void applyCommandAction() { protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
player.sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On"))); mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability." + (mcMMOPlayer.getAbilityUse() ? "Off" : "On")));
mcMMOPlayer.toggleAbilityUse(); mcMMOPlayer.toggleAbilityUse();
} }
@Override @Override
protected void sendSuccessMessage(CommandSender sender) { protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle")); sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle", playerName));
} }
} }

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.commands.database; package com.gmail.nossr50.commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -11,6 +11,7 @@ import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.database.ConvertDatabaseCommand;
import com.gmail.nossr50.commands.experience.ConvertExperienceCommand; import com.gmail.nossr50.commands.experience.ConvertExperienceCommand;
import com.gmail.nossr50.database.DatabaseManagerFactory; import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.database.DatabaseType; import com.gmail.nossr50.datatypes.database.DatabaseType;
@@ -23,23 +24,17 @@ public class McconvertCommand implements TabExecutor {
private static final List<String> DATABASE_TYPES; private static final List<String> DATABASE_TYPES;
private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience"); private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience");
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand(); private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand(); private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
static { static {
ArrayList<String> formulaTypes = new ArrayList<String>(); ArrayList<String> formulaTypes = new ArrayList<String>();
ArrayList<String> databaseTypes = new ArrayList<String>();
for (FormulaType type : FormulaType.values()) { for (FormulaType type : FormulaType.values()) {
formulaTypes.add(type.toString()); formulaTypes.add(type.toString());
} }
Collections.sort(formulaTypes);
FORMULA_TYPES = ImmutableList.copyOf(formulaTypes);
}
static {
ArrayList<String> databaseTypes = new ArrayList<String>();
for (DatabaseType type : DatabaseType.values()) { for (DatabaseType type : DatabaseType.values()) {
databaseTypes.add(type.toString()); databaseTypes.add(type.toString());
} }
@@ -51,8 +46,12 @@ public class McconvertCommand implements TabExecutor {
databaseTypes.add(DatabaseManagerFactory.getCustomDatabaseManagerClass().getName()); databaseTypes.add(DatabaseManagerFactory.getCustomDatabaseManagerClass().getName());
} }
Collections.sort(formulaTypes);
Collections.sort(databaseTypes); Collections.sort(databaseTypes);
FORMULA_TYPES = ImmutableList.copyOf(formulaTypes);
DATABASE_TYPES = ImmutableList.copyOf(databaseTypes); DATABASE_TYPES = ImmutableList.copyOf(databaseTypes);
} }
@Override @Override

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.commands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@@ -17,13 +18,13 @@ public class McgodCommand extends ToggleCommand {
} }
@Override @Override
protected void applyCommandAction() { protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
player.sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled"))); mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.GodMode." + (mcMMOPlayer.getGodMode() ? "Disabled" : "Enabled")));
mcMMOPlayer.toggleGodMode(); mcMMOPlayer.toggleGodMode();
} }
@Override @Override
protected void sendSuccessMessage(CommandSender sender) { protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Success")); sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Toggle", playerName));
} }
} }

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.commands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@@ -17,17 +18,17 @@ public class McrefreshCommand extends ToggleCommand {
} }
@Override @Override
protected void applyCommandAction() { protected void applyCommandAction(McMMOPlayer mcMMOPlayer) {
mcMMOPlayer.setRecentlyHurt(0); mcMMOPlayer.setRecentlyHurt(0);
mcMMOPlayer.getProfile().resetCooldowns(); mcMMOPlayer.resetCooldowns();
mcMMOPlayer.resetToolPrepMode(); mcMMOPlayer.resetToolPrepMode();
mcMMOPlayer.resetAbilityMode(); mcMMOPlayer.resetAbilityMode();
player.sendMessage(LocaleLoader.getString("Ability.Generic.Refresh")); mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
} }
@Override @Override
protected void sendSuccessMessage(CommandSender sender) { protected void sendSuccessMessage(CommandSender sender, String playerName) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", player.getName())); sender.sendMessage(LocaleLoader.getString("Commands.mcrefresh.Success", playerName));
} }
} }

View File

@@ -2,6 +2,7 @@ package com.gmail.nossr50.commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
@@ -11,60 +12,62 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class McscoreboardCommand implements TabExecutor { public class McscoreboardCommand implements TabExecutor {
private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear", "reset"); private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear");
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
return true; return true;
} }
if (args.length == 0) {
help(sender);
return true;
}
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) { switch (args.length) {
ScoreboardManager.clearBoard(sender.getName()); case 1:
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear")); if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
} ScoreboardManager.clearBoard(sender.getName());
else if (args[0].equalsIgnoreCase("keep")) { sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear"));
if (!Config.getInstance().getAllowKeepBoard()) { return true;
sender.sendMessage(LocaleLoader.getString("Commands.Disabled")); }
return true;
}
if (!ScoreboardManager.isBoardShown(sender.getName())) {
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.NoBoard"));
return true;
}
ScoreboardManager.keepBoard(sender.getName());
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep"));
}
else if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) {
if (args.length == 1) {
help(sender);
return true;
}
if (CommandUtils.isInvalidInteger(sender, args[1])) {
return true;
}
int time = Math.abs(Integer.parseInt(args[1]));
ScoreboardManager.setRevertTimer(sender.getName(), time);
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", time));
}
else {
help(sender);
}
return true;
}
private void help(CommandSender sender) { if (args[0].equalsIgnoreCase("keep")) {
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.0")); if (!Config.getInstance().getAllowKeepBoard()) {
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.1")); sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.2")); return true;
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.3")); }
if (!ScoreboardManager.isBoardShown(sender.getName())) {
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.NoBoard"));
return true;
}
ScoreboardManager.keepBoard(sender.getName());
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep"));
return true;
}
return help(sender);
case 2:
if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) {
if (CommandUtils.isInvalidInteger(sender, args[1])) {
return true;
}
int time = Math.abs(Integer.parseInt(args[1]));
ScoreboardManager.setRevertTimer(sender.getName(), time);
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", time));
return true;
}
return help(sender);
default:
return help(sender);
}
} }
@Override @Override
@@ -73,8 +76,15 @@ public class McscoreboardCommand implements TabExecutor {
case 1: case 1:
return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<String>(FIRST_ARGS.size())); return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<String>(FIRST_ARGS.size()));
default: default:
break; return ImmutableList.of();
} }
return ImmutableList.of(); }
private boolean help(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.0"));
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.1"));
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.2"));
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.3"));
return true;
} }
} }

View File

@@ -11,10 +11,10 @@ import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.MobHealthbarType; import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class MobhealthCommand implements TabExecutor { public class MobhealthCommand implements TabExecutor {
@@ -39,11 +39,9 @@ public class MobhealthCommand implements TabExecutor {
switch (args.length) { switch (args.length) {
case 1: case 1:
PlayerProfile playerProfile = UserManager.getPlayer((Player) sender).getProfile();
try { try {
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim()); MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
playerProfile.setMobHealthbarType(type); UserManager.getPlayer((Player) sender).getProfile().setMobHealthbarType(type);
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Changed." + type.name())); sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Changed." + type.name()));
return true; return true;
} }

View File

@@ -7,7 +7,6 @@ import java.util.Set;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil; import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@@ -18,9 +17,6 @@ import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public abstract class ToggleCommand implements TabExecutor { public abstract class ToggleCommand implements TabExecutor {
protected McMMOPlayer mcMMOPlayer;
protected Player player;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
@@ -34,10 +30,7 @@ public abstract class ToggleCommand implements TabExecutor {
return true; return true;
} }
player = (Player) sender; applyCommandAction(UserManager.getPlayer(sender.getName()));
mcMMOPlayer = UserManager.getPlayer(player);
applyCommandAction();
return true; return true;
case 1: case 1:
@@ -47,20 +40,18 @@ public abstract class ToggleCommand implements TabExecutor {
} }
String playerName = Misc.getMatchedPlayerName(args[0]); String playerName = Misc.getMatchedPlayerName(args[0]);
mcMMOPlayer = UserManager.getPlayer(playerName); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) { if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
return true; return true;
} }
player = mcMMOPlayer.getPlayer(); if (CommandUtils.isOffline(sender, mcMMOPlayer.getPlayer())) {
if (CommandUtils.isOffline(sender, player)) {
return true; return true;
} }
applyCommandAction(); applyCommandAction(mcMMOPlayer);
sendSuccessMessage(sender); sendSuccessMessage(sender, playerName);
return true; return true;
default: default:
@@ -81,6 +72,6 @@ public abstract class ToggleCommand implements TabExecutor {
protected abstract boolean hasOtherPermission(CommandSender sender); protected abstract boolean hasOtherPermission(CommandSender sender);
protected abstract boolean hasSelfPermission(CommandSender sender); protected abstract boolean hasSelfPermission(CommandSender sender);
protected abstract void applyCommandAction(); protected abstract void applyCommandAction(McMMOPlayer mcMMOPlayer);
protected abstract void sendSuccessMessage(CommandSender sender); protected abstract void sendSuccessMessage(CommandSender sender, String playerName);
} }

View File

@@ -18,11 +18,7 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class XprateCommand implements TabExecutor { public class XprateCommand implements TabExecutor {
private double originalRate; private final double ORIGINAL_XP_RATE = ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier();
public XprateCommand() {
originalRate = ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier();
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@@ -42,7 +38,7 @@ public class XprateCommand implements TabExecutor {
mcMMO.p.toggleXpEventEnabled(); mcMMO.p.toggleXpEventEnabled();
} }
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(originalRate); ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(ORIGINAL_XP_RATE);
return true; return true;
case 2: case 2:

View File

@@ -21,9 +21,8 @@ import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public abstract class ChatCommand implements TabExecutor { public abstract class ChatCommand implements TabExecutor {
protected ChatMode chatMode; private ChatMode chatMode;
protected ChatManager chatManager; protected ChatManager chatManager;
private McMMOPlayer mcMMOPlayer;
public ChatCommand(ChatMode chatMode) { public ChatCommand(ChatMode chatMode) {
this.chatMode = chatMode; this.chatMode = chatMode;
@@ -32,19 +31,21 @@ public abstract class ChatCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
McMMOPlayer mcMMOPlayer;
switch (args.length) { switch (args.length) {
case 0: case 0:
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
return true; return true;
} }
mcMMOPlayer = UserManager.getPlayer((Player) sender); mcMMOPlayer = UserManager.getPlayer(sender.getName());
if (chatMode.isEnabled(mcMMOPlayer)) { if (mcMMOPlayer.isChatEnabled(chatMode)) {
disableChatMode(sender); disableChatMode(mcMMOPlayer, sender);
} }
else { else {
enableChatMode(sender); enableChatMode(mcMMOPlayer, sender);
} }
return true; return true;
@@ -55,9 +56,7 @@ public abstract class ChatCommand implements TabExecutor {
return true; return true;
} }
mcMMOPlayer = UserManager.getPlayer((Player) sender); enableChatMode(UserManager.getPlayer(sender.getName()), sender);
enableChatMode(sender);
return true; return true;
} }
@@ -66,9 +65,7 @@ public abstract class ChatCommand implements TabExecutor {
return true; return true;
} }
mcMMOPlayer = UserManager.getPlayer((Player) sender); disableChatMode(UserManager.getPlayer(sender.getName()), sender);
disableChatMode(sender);
return true; return true;
} }
@@ -108,23 +105,23 @@ public abstract class ChatCommand implements TabExecutor {
protected abstract void handleChatSending(CommandSender sender, String[] args); protected abstract void handleChatSending(CommandSender sender, String[] args);
private void enableChatMode(CommandSender sender) { private void enableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) { if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return; return;
} }
chatMode.enable(mcMMOPlayer); mcMMOPlayer.enableChat(chatMode);
sender.sendMessage(chatMode.getEnabledMessage()); sender.sendMessage(chatMode.getEnabledMessage());
} }
private void disableChatMode(CommandSender sender) { private void disableChatMode(McMMOPlayer mcMMOPlayer, CommandSender sender) {
if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) { if (chatMode == ChatMode.PARTY && mcMMOPlayer.getParty() == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return; return;
} }
chatMode.disable(mcMMOPlayer); mcMMOPlayer.disableChat(chatMode);
sender.sendMessage(chatMode.getDisabledMessage()); sender.sendMessage(chatMode.getDisabledMessage());
} }
} }

View File

@@ -15,19 +15,21 @@ import com.google.common.collect.ImmutableList;
public class MmoshowdbCommand implements TabExecutor { public class MmoshowdbCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 0) { switch (args.length) {
return false; case 0:
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
if (clazz != null) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName()));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile")));
return true;
default:
return false;
} }
Class<?> clazz = DatabaseManagerFactory.getCustomDatabaseManagerClass();
if (clazz != null) {
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", clazz.getName()));
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile")));
return true;
} }
@Override @Override

View File

@@ -1,7 +1,9 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.EventUtils;
@@ -19,11 +21,12 @@ public class AddlevelsCommand extends ExperienceCommand {
} }
@Override @Override
protected void handleCommand(SkillType skill) { protected void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value) {
float xpRemoved = profile.getSkillXpLevelRaw(skill); float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.addLevels(skill, value); profile.addLevels(skill, value);
if (player == null) { if (player == null) {
profile.save();
return; return;
} }
@@ -31,12 +34,12 @@ public class AddlevelsCommand extends ExperienceCommand {
} }
@Override @Override
protected void handlePlayerMessageAll() { protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value)); player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value));
} }
@Override @Override
protected void handlePlayerMessageSkill() { protected void handlePlayerMessageSkill(Player player, int value, SkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getSkillName())); player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getName()));
} }
} }

View File

@@ -1,10 +1,13 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
public class AddxpCommand extends ExperienceCommand { public class AddxpCommand extends ExperienceCommand {
@Override @Override
@@ -18,22 +21,23 @@ public class AddxpCommand extends ExperienceCommand {
} }
@Override @Override
protected void handleCommand(SkillType skill) { protected void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value) {
if (player != null) { if (player != null) {
mcMMOPlayer.applyXpGain(skill, value); UserManager.getPlayer(player).applyXpGain(skill, value);
} }
else { else {
profile.addExperience(skill, value); profile.addXp(skill, value);
profile.save();
} }
} }
@Override @Override
protected void handlePlayerMessageAll() { protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value)); player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value));
} }
@Override @Override
protected void handlePlayerMessageSkill() { protected void handlePlayerMessageSkill(Player player, int value, SkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getSkillName())); player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName()));
} }
} }

View File

@@ -22,14 +22,6 @@ import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public abstract class ExperienceCommand implements TabExecutor { public abstract class ExperienceCommand implements TabExecutor {
protected McMMOPlayer mcMMOPlayer;
protected Player player;
protected PlayerProfile profile;
protected boolean allSkills;
protected SkillType skill;
protected int value;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
@@ -47,12 +39,7 @@ public abstract class ExperienceCommand implements TabExecutor {
return true; return true;
} }
player = (Player) sender; editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), SkillType.getSkill(args[0]), Integer.parseInt(args[1]));
mcMMOPlayer = UserManager.getPlayer(player);
profile = mcMMOPlayer.getProfile();
editValues();
cleanUp();
return true; return true;
case 3: case 3:
@@ -65,28 +52,27 @@ public abstract class ExperienceCommand implements TabExecutor {
return true; return true;
} }
SkillType skill = SkillType.getSkill(args[1]);
int value = Integer.parseInt(args[2]);
String playerName = Misc.getMatchedPlayerName(args[0]); String playerName = Misc.getMatchedPlayerName(args[0]);
mcMMOPlayer = UserManager.getPlayer(playerName, true); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) { if (mcMMOPlayer == null) {
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
if (CommandUtils.unloadedProfile(sender, profile)) { if (CommandUtils.unloadedProfile(sender, profile)) {
return true; return true;
} }
editValues(); editValues(null, profile, skill, value);
profile.save(); // Since this is a temporary profile, we save it here.
} }
else { else {
profile = mcMMOPlayer.getProfile(); editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value);
player = mcMMOPlayer.getPlayer();
editValues();
} }
handleSenderMessage(sender, playerName); handleSenderMessage(sender, playerName, skill);
cleanUp();
return true; return true;
default: default:
@@ -109,70 +95,43 @@ public abstract class ExperienceCommand implements TabExecutor {
protected abstract boolean permissionsCheckSelf(CommandSender sender); protected abstract boolean permissionsCheckSelf(CommandSender sender);
protected abstract boolean permissionsCheckOthers(CommandSender sender); protected abstract boolean permissionsCheckOthers(CommandSender sender);
protected abstract void handleCommand(SkillType skill); protected abstract void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value);
protected abstract void handlePlayerMessageAll(); protected abstract void handlePlayerMessageAll(Player player, int value);
protected abstract void handlePlayerMessageSkill(); protected abstract void handlePlayerMessageSkill(Player player, int value, SkillType skill);
private boolean validateArguments(CommandSender sender, String skillName, String value) { private boolean validateArguments(CommandSender sender, String skillName, String value) {
if (isInvalidInteger(sender, value) || isInvalidSkill(sender, skillName)) { if (CommandUtils.isInvalidInteger(sender, value) || CommandUtils.isInvalidSkill(sender, skillName)) {
return false; return false;
} }
return true; return true;
} }
private boolean isInvalidInteger(CommandSender sender, String value) { protected static void handleSenderMessage(CommandSender sender, String playerName, SkillType skill) {
if (CommandUtils.isInvalidInteger(sender, value)) { if (skill == null) {
return true;
}
this.value = Integer.parseInt(value);
return false;
}
protected boolean isInvalidSkill(CommandSender sender, String skillName) {
if (skillName.equalsIgnoreCase("all")) {
allSkills = true;
return false;
}
else if (CommandUtils.isInvalidSkill(sender, skillName)) {
return true;
}
skill = SkillType.getSkill(skillName);
return false;
}
protected void handleSenderMessage(CommandSender sender, String playerName) {
if (allSkills) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName)); sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
} }
else { else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getSkillName(), playerName)); sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
} }
} }
protected void editValues() { protected void editValues(Player player, PlayerProfile profile, SkillType skill, int value) {
if (allSkills) { if (skill == null) {
for (SkillType skillType : SkillType.values()) { for (SkillType skillType : SkillType.values()) {
handleCommand(skillType); handleCommand(player, profile, skillType, value);
} }
if (player != null) { if (player != null) {
handlePlayerMessageAll(); handlePlayerMessageAll(player, value);
} }
} }
else { else {
handleCommand(skill); handleCommand(player, profile, skill, value);
if (player != null) { if (player != null) {
handlePlayerMessageSkill(); handlePlayerMessageSkill(player, value, skill);
} }
} }
} }
private void cleanUp() {
allSkills = false;
player = null;
}
} }

View File

@@ -1,7 +1,9 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.EventUtils;
@@ -19,13 +21,18 @@ public class MmoeditCommand extends ExperienceCommand {
} }
@Override @Override
protected void handleCommand(SkillType skill) { protected void handleCommand(Player player, PlayerProfile profile, SkillType skill, int value) {
int skillLevel = profile.getSkillLevel(skill); int skillLevel = profile.getSkillLevel(skill);
float xpRemoved = profile.getSkillXpLevelRaw(skill); float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.modifySkill(skill, value); profile.modifySkill(skill, value);
if (player == null || value == skillLevel) { if (player == null) {
profile.save();
return;
}
if (value == skillLevel) {
return; return;
} }
@@ -33,12 +40,12 @@ public class MmoeditCommand extends ExperienceCommand {
} }
@Override @Override
protected void handlePlayerMessageAll() { protected void handlePlayerMessageAll(Player player, int value) {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value)); player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value));
} }
@Override @Override
protected void handlePlayerMessageSkill() { protected void handlePlayerMessageSkill(Player player, int value, SkillType skill) {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getSkillName(), value)); player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getName(), value));
} }
} }

View File

@@ -1,10 +1,18 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.EventUtils;
@@ -12,18 +20,11 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
public class SkillresetCommand extends ExperienceCommand { public class SkillresetCommand implements TabExecutor {
private CommandSender sender;
private Command command;
private int argsLength;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
this.command = command;
this.sender = sender;
argsLength = args.length;
switch (args.length) { switch (args.length) {
case 1: case 1:
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
@@ -35,15 +36,11 @@ public class SkillresetCommand extends ExperienceCommand {
return true; return true;
} }
if (isInvalidSkill(sender, args[0])) { if (CommandUtils.isInvalidSkill(sender, args[0])) {
return true; return true;
} }
player = (Player) sender; editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), SkillType.getSkill(args[0]), args.length, sender, command);
mcMMOPlayer = UserManager.getPlayer(player);
profile = mcMMOPlayer.getProfile();
editValues();
return true; return true;
case 2: case 2:
@@ -52,32 +49,30 @@ public class SkillresetCommand extends ExperienceCommand {
return true; return true;
} }
if (isInvalidSkill(sender, args[1])) { if (CommandUtils.isInvalidSkill(sender, args[1])) {
return true; return true;
} }
SkillType skill = SkillType.getSkill(args[1]);
String playerName = Misc.getMatchedPlayerName(args[0]); String playerName = Misc.getMatchedPlayerName(args[0]);
mcMMOPlayer = UserManager.getPlayer(playerName, true); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process. // If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) { if (mcMMOPlayer == null) {
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
if (CommandUtils.unloadedProfile(sender, profile)) { if (CommandUtils.unloadedProfile(sender, profile)) {
return true; return true;
} }
editValues(); editValues(null, profile, skill, args.length, sender, command);
profile.save(); // Since this is a temporary profile, we save it here.
} }
else { else {
profile = mcMMOPlayer.getProfile(); editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, args.length, sender, command);
player = mcMMOPlayer.getPlayer();
editValues();
} }
handleSenderMessage(sender, playerName); ExperienceCommand.handleSenderMessage(sender, playerName, skill);
return true; return true;
default: default:
@@ -86,17 +81,38 @@ public class SkillresetCommand extends ExperienceCommand {
} }
@Override @Override
protected boolean permissionsCheckSelf(CommandSender sender) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return false; switch (args.length) {
case 1:
Set<String> playerNames = UserManager.getPlayerNames();
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
case 2:
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
default:
return ImmutableList.of();
}
} }
@Override private void editValues(Player player, PlayerProfile profile, SkillType skill, int argsLength, CommandSender sender, Command command) {
protected boolean permissionsCheckOthers(CommandSender sender) { if (skill == null) {
return false; for (SkillType skillType : SkillType.values()) {
handleCommand(player, profile, skillType, argsLength, sender, command);
}
if (player != null) {
player.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
}
}
else {
handleCommand(player, profile, skill, argsLength, sender, command);
if (player != null) {
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getName()));
}
}
} }
@Override private void handleCommand(Player player, PlayerProfile profile, SkillType skill, int argsLength, CommandSender sender, Command command) {
protected void handleCommand(SkillType skill) {
if (argsLength == 1 && !Permissions.skillreset(sender, skill) || (argsLength == 2 && !Permissions.skillresetOthers(sender, skill))) { if (argsLength == 1 && !Permissions.skillreset(sender, skill) || (argsLength == 2 && !Permissions.skillresetOthers(sender, skill))) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return; return;
@@ -108,19 +124,10 @@ public class SkillresetCommand extends ExperienceCommand {
profile.modifySkill(skill, 0); profile.modifySkill(skill, 0);
if (player == null) { if (player == null) {
profile.save();
return; return;
} }
EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false); EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false);
} }
@Override
protected void handlePlayerMessageAll() {
player.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
}
@Override
protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getSkillName()));
}
} }

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.commands.hardcore; package com.gmail.nossr50.commands.hardcore;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -8,18 +10,18 @@ import com.gmail.nossr50.util.Permissions;
public class HardcoreCommand extends HardcoreModeCommand { public class HardcoreCommand extends HardcoreModeCommand {
@Override @Override
protected boolean checkTogglePermissions() { protected boolean checkTogglePermissions(CommandSender sender) {
return Permissions.hardcoreToggle(sender); return Permissions.hardcoreToggle(sender);
} }
@Override @Override
protected boolean checkModifyPermissions() { protected boolean checkModifyPermissions(CommandSender sender) {
return Permissions.hardcoreModify(sender); return Permissions.hardcoreModify(sender);
} }
@Override @Override
protected boolean checkEnabled(String skill) { protected boolean checkEnabled(SkillType skill) {
if (skill.equalsIgnoreCase("ALL")) { if (skill == null) {
for (SkillType skillType : SkillType.values()) { for (SkillType skillType : SkillType.values()) {
if (!skillType.getHardcoreStatLossEnabled()) { if (!skillType.getHardcoreStatLossEnabled()) {
return false; return false;
@@ -29,35 +31,35 @@ public class HardcoreCommand extends HardcoreModeCommand {
return true; return true;
} }
return SkillType.getSkill(skill).getHardcoreStatLossEnabled(); return skill.getHardcoreStatLossEnabled();
} }
@Override @Override
protected void enable(String skill) { protected void enable(SkillType skill) {
toggle(true); toggle(true, skill);
} }
@Override @Override
protected void disable(String skill) { protected void disable(SkillType skill) {
toggle(false); toggle(false, skill);
} }
@Override @Override
protected void modify() { protected void modify(CommandSender sender, double newPercentage) {
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent); Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercent / 100D))); sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercentage / 100.0D)));
} }
private void toggle(boolean enable) { private void toggle(boolean enable, SkillType skill) {
if (skill.equalsIgnoreCase("ALL")) { if (skill == null) {
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) { for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
skillType.setHardcoreStatLossEnabled(enable); skillType.setHardcoreStatLossEnabled(enable);
} }
} }
else { else {
SkillType.getSkill(skill).setHardcoreStatLossEnabled(enable); skill.setHardcoreStatLossEnabled(enable);
} }
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), skill)); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), (skill == null ? "all skills" : skill.getName())));
} }
} }

View File

@@ -17,31 +17,22 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public abstract class HardcoreModeCommand implements TabExecutor { public abstract class HardcoreModeCommand implements TabExecutor {
protected CommandSender sender; protected final DecimalFormat percent = new DecimalFormat("##0.00%");
protected double newPercent;
protected DecimalFormat percent;
protected String skill;
public HardcoreModeCommand() {
percent = new DecimalFormat("##0.00%");
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 0: case 0:
this.sender = sender; if (!checkTogglePermissions(sender)) {
if (!checkTogglePermissions()) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }
if (checkEnabled("ALL")) { if (checkEnabled(null)) {
disable("ALL"); disable(null);
} }
else { else {
enable("ALL"); enable(null);
} }
return true; return true;
@@ -53,7 +44,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true; return true;
} }
enable("ALL"); enable(null);
return true; return true;
} }
@@ -63,11 +54,11 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true; return true;
} }
disable("ALL"); disable(null);
return true; return true;
} }
if (isInvalidPercentage(sender, args[0])) { if (CommandUtils.isInvalidDouble(sender, args[0])) {
return true; return true;
} }
@@ -76,16 +67,20 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true; return true;
} }
modify(); modify(sender, Double.parseDouble(args[0]));
return true; return true;
case 2: case 2:
if (!args[0].equalsIgnoreCase("ALL") && CommandUtils.isChildSkill(sender, SkillType.getSkill(args[0]))) { if (CommandUtils.isInvalidSkill(sender, args[0])) {
return true; return true;
} }
skill = args[0]; SkillType skill = SkillType.getSkill(args[0]);
if (!CommandUtils.isChildSkill(sender, skill)) {
return true;
}
if (CommandUtils.shouldEnableToggle(args[1])) { if (CommandUtils.shouldEnableToggle(args[1])) {
if (!Permissions.hardcoreToggle(sender)) { if (!Permissions.hardcoreToggle(sender)) {
@@ -103,7 +98,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true; return true;
} }
disable(skill); enable(skill);
return true; return true;
} }
@@ -128,19 +123,10 @@ public abstract class HardcoreModeCommand implements TabExecutor {
} }
} }
protected abstract boolean checkTogglePermissions(); protected abstract boolean checkTogglePermissions(CommandSender sender);
protected abstract boolean checkModifyPermissions(); protected abstract boolean checkModifyPermissions(CommandSender sender);
protected abstract boolean checkEnabled(String skill); protected abstract boolean checkEnabled(SkillType skill);
protected abstract void enable(String skill); protected abstract void enable(SkillType skill);
protected abstract void disable(String skill); protected abstract void disable(SkillType skill);
protected abstract void modify(); protected abstract void modify(CommandSender sender, double newPercentage);
private boolean isInvalidPercentage(CommandSender sender, String value) {
if (CommandUtils.isInvalidDouble(sender, value)) {
return true;
}
newPercent = Double.parseDouble(value);
return false;
}
} }

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.commands.hardcore; package com.gmail.nossr50.commands.hardcore;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -8,18 +10,18 @@ import com.gmail.nossr50.util.Permissions;
public class VampirismCommand extends HardcoreModeCommand { public class VampirismCommand extends HardcoreModeCommand {
@Override @Override
protected boolean checkTogglePermissions() { protected boolean checkTogglePermissions(CommandSender sender) {
return Permissions.vampirismToggle(sender); return Permissions.vampirismToggle(sender);
} }
@Override @Override
protected boolean checkModifyPermissions() { protected boolean checkModifyPermissions(CommandSender sender) {
return Permissions.vampirismModify(sender); return Permissions.vampirismModify(sender);
} }
@Override @Override
protected boolean checkEnabled(String skill) { protected boolean checkEnabled(SkillType skill) {
if (skill.equalsIgnoreCase("ALL")) { if (skill == null) {
for (SkillType skillType : SkillType.values()) { for (SkillType skillType : SkillType.values()) {
if (!skillType.getHardcoreVampirismEnabled()) { if (!skillType.getHardcoreVampirismEnabled()) {
return false; return false;
@@ -29,35 +31,35 @@ public class VampirismCommand extends HardcoreModeCommand {
return true; return true;
} }
return SkillType.getSkill(skill).getHardcoreVampirismEnabled(); return skill.getHardcoreVampirismEnabled();
} }
@Override @Override
protected void enable(String skill) { protected void enable(SkillType skill) {
toggle(true); toggle(true, skill);
} }
@Override @Override
protected void disable(String skill) { protected void disable(SkillType skill) {
toggle(false); toggle(false, skill);
} }
@Override @Override
protected void modify() { protected void modify(CommandSender sender, double newPercentage) {
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent); Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercent / 100D))); sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercentage / 100.0D)));
} }
private void toggle(boolean enable) { private void toggle(boolean enable, SkillType skill) {
if (skill.equalsIgnoreCase("ALL")) { if (skill == null) {
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) { for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
skillType.setHardcoreVampirismEnabled(enable); skillType.setHardcoreVampirismEnabled(enable);
} }
} }
else { else {
SkillType.getSkill(skill).setHardcoreVampirismEnabled(enable); skill.setHardcoreVampirismEnabled(enable);
} }
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." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), (skill == null ? "all skills" : skill)));
} }
} }

View File

@@ -10,24 +10,22 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class PartyChangePasswordCommand implements CommandExecutor { public class PartyChangePasswordCommand implements CommandExecutor {
private Party playerParty;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
playerParty = UserManager.getPlayer((Player) sender).getParty(); Party party = UserManager.getPlayer((Player) sender).getParty();
switch (args.length) { switch (args.length) {
case 1: case 1:
unprotectParty(sender); unprotectParty(party, sender);
return true; return true;
case 2: case 2:
if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) { if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) {
unprotectParty(sender); unprotectParty(party, sender);
return true; return true;
} }
protectParty(sender, args[1]); protectParty(party, sender, args[1]);
return true; return true;
default: default:
@@ -37,15 +35,15 @@ public class PartyChangePasswordCommand implements CommandExecutor {
} }
} }
private void unprotectParty(CommandSender sender) { private void unprotectParty(Party party, CommandSender sender) {
playerParty.setLocked(true); party.setLocked(true);
playerParty.setPassword(null); party.setPassword(null);
sender.sendMessage(LocaleLoader.getString("Party.Password.Removed")); sender.sendMessage(LocaleLoader.getString("Party.Password.Removed"));
} }
private void protectParty(CommandSender sender, String password) { private void protectParty(Party party, CommandSender sender, String password) {
playerParty.setLocked(true); party.setLocked(true);
playerParty.setPassword(password); party.setPassword(password);
sender.sendMessage(LocaleLoader.getString("Party.Password.Set", password)); sender.sendMessage(LocaleLoader.getString("Party.Password.Set", password));
} }
} }

View File

@@ -24,9 +24,6 @@ import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class PartyCommand implements TabExecutor { public class PartyCommand implements TabExecutor {
private McMMOPlayer mcMMOPlayer;
private Player player;
private static final List<String> PARTY_SUBCOMMANDS; private static final List<String> PARTY_SUBCOMMANDS;
private static final List<String> EXPSHARE_COMPLETIONS = ImmutableList.of("none", "equal"); private static final List<String> EXPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc"); private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
@@ -71,13 +68,13 @@ public class PartyCommand implements TabExecutor {
return true; return true;
} }
player = (Player) sender; Player player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (args.length < 1) { if (args.length < 1) {
if (!mcMMOPlayer.inParty()) { if (!mcMMOPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage(); return printUsage(player);
} }
return partyInfoCommand.onCommand(sender, command, label, args); return partyInfoCommand.onCommand(sender, command, label, args);
@@ -86,7 +83,7 @@ public class PartyCommand implements TabExecutor {
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]); PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
if (subcommand == null) { if (subcommand == null) {
return printUsage(); return printUsage(player);
} }
// Can't use this for lock/unlock since they're handled by the same command // Can't use this for lock/unlock since they're handled by the same command
@@ -111,7 +108,7 @@ public class PartyCommand implements TabExecutor {
// Party member commands // Party member commands
if (!mcMMOPlayer.inParty()) { if (!mcMMOPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage(); return printUsage(player);
} }
switch (subcommand) { switch (subcommand) {
@@ -211,7 +208,7 @@ public class PartyCommand implements TabExecutor {
} }
} }
private boolean printUsage() { private boolean printUsage(Player player) {
player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join")); player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join"));
player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?")); player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?"));

View File

@@ -14,8 +14,6 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class PartyExpShareCommand implements CommandExecutor { public class PartyExpShareCommand implements CommandExecutor {
private Party playerParty;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Config.getInstance().getExpShareEnabled()) { if (!Config.getInstance().getExpShareEnabled()) {
@@ -25,13 +23,13 @@ public class PartyExpShareCommand implements CommandExecutor {
switch (args.length) { switch (args.length) {
case 2: case 2:
playerParty = UserManager.getPlayer((Player) sender).getParty(); Party party = UserManager.getPlayer((Player) sender).getParty();
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) { if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
handleChangingShareMode(ShareMode.NONE); handleChangingShareMode(party, ShareMode.NONE);
} }
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) { else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) {
handleChangingShareMode(ShareMode.EQUAL); handleChangingShareMode(party, ShareMode.EQUAL);
} }
else { else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "<NONE | EQUAL>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "<NONE | EQUAL>"));
@@ -45,12 +43,12 @@ public class PartyExpShareCommand implements CommandExecutor {
} }
} }
private void handleChangingShareMode(ShareMode mode) { private void handleChangingShareMode(Party party, ShareMode mode) {
playerParty.setXpShareMode(mode); party.setXpShareMode(mode);
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))); String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
for (Player member : playerParty.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
member.sendMessage(changeModeMessage); member.sendMessage(changeModeMessage);
} }
} }

View File

@@ -16,36 +16,33 @@ import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class PartyInfoCommand implements CommandExecutor { public class PartyInfoCommand implements CommandExecutor {
private McMMOPlayer mcMMOPlayer;
private Player player;
private Party playerParty;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 0: case 0:
case 1: case 1:
player = (Player) sender; Player player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
playerParty = mcMMOPlayer.getParty(); Party party = mcMMOPlayer.getParty();
displayPartyHeader(); displayPartyHeader(player, party);
displayShareModeInfo(); displayShareModeInfo(party, player);
displayMemberInfo(); displayMemberInfo(player, mcMMOPlayer, party);
return true; return true;
default: default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "info")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "info"));
return true; return true;
} }
} }
private String createMembersList() { private String createMembersList(Party party) {
StringBuilder memberList = new StringBuilder(); StringBuilder memberList = new StringBuilder();
for (String memberName : playerParty.getMembers()) { for (String memberName : party.getMembers()) {
Player member = mcMMO.p.getServer().getPlayerExact(memberName); Player member = mcMMO.p.getServer().getPlayerExact(memberName);
if (playerParty.getLeader().equalsIgnoreCase(memberName)) { if (party.getLeader().equalsIgnoreCase(memberName)) {
memberList.append(ChatColor.GOLD); memberList.append(ChatColor.GOLD);
} }
else if (member != null) { else if (member != null) {
@@ -61,10 +58,10 @@ public class PartyInfoCommand implements CommandExecutor {
return memberList.toString(); return memberList.toString();
} }
private void displayShareModeInfo() { private void displayShareModeInfo(Party party, Player player) {
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled(); boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled(); boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
boolean itemSharingActive = (playerParty.getItemShareMode() != ShareMode.NONE); boolean itemSharingActive = (party.getItemShareMode() != ShareMode.NONE);
if (!xpShareEnabled && !itemShareEnabled) { if (!xpShareEnabled && !itemShareEnabled) {
return; return;
@@ -75,11 +72,11 @@ public class PartyInfoCommand implements CommandExecutor {
String separator = ""; String separator = "";
if (xpShareEnabled) { if (xpShareEnabled) {
expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", playerParty.getXpShareMode().toString()); expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", party.getXpShareMode().toString());
} }
if (itemShareEnabled) { if (itemShareEnabled) {
itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", playerParty.getItemShareMode().toString()); itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", party.getItemShareMode().toString());
} }
if (xpShareEnabled && itemShareEnabled) { if (xpShareEnabled && itemShareEnabled) {
@@ -87,28 +84,23 @@ public class PartyInfoCommand implements CommandExecutor {
} }
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo); player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo);
if (itemSharingActive) { if (itemSharingActive) {
player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", playerParty.getItemShareCategories())); player.sendMessage(LocaleLoader.getString("Commands.Party.ItemShareCategories", party.getItemShareCategories()));
} }
} }
private void displayPartyHeader() { private void displayPartyHeader(Player player, Party party) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", party.getName(), LocaleLoader.getString("Party.Status." + (party.isLocked() ? "Locked" : "Unlocked"))));
if (playerParty.isLocked()) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Locked")));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Unlocked")));
}
} }
private void displayMemberInfo() { private void displayMemberInfo(Player player, McMMOPlayer mcMMOPlayer, Party party) {
int membersNear = PartyManager.getNearMembers(mcMMOPlayer).size(); int membersNear = PartyManager.getNearMembers(mcMMOPlayer).size();
int membersOnline = playerParty.getOnlineMembers().size() - 1; int membersOnline = party.getOnlineMembers().size() - 1;
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline)); player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline));
player.sendMessage(createMembersList()); player.sendMessage(createMembersList(party));
} }
} }

View File

@@ -15,8 +15,6 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class PartyItemShareCommand implements CommandExecutor { public class PartyItemShareCommand implements CommandExecutor {
private Party playerParty;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Config.getInstance().getItemShareEnabled()) { if (!Config.getInstance().getItemShareEnabled()) {
@@ -24,9 +22,10 @@ public class PartyItemShareCommand implements CommandExecutor {
return true; return true;
} }
Party party = UserManager.getPlayer((Player) sender).getParty();
switch (args.length) { switch (args.length) {
case 2: case 2:
playerParty = UserManager.getPlayer((Player) sender).getParty();
ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase()); ShareMode mode = ShareMode.getShareMode(args[1].toUpperCase());
if (mode == null) { if (mode == null) {
@@ -34,11 +33,10 @@ public class PartyItemShareCommand implements CommandExecutor {
return true; return true;
} }
handleChangingShareMode(mode); handleChangingShareMode(party, mode);
return true; return true;
case 3: case 3:
playerParty = UserManager.getPlayer((Player) sender).getParty();
boolean toggle = false; boolean toggle = false;
if (CommandUtils.shouldEnableToggle(args[2])) { if (CommandUtils.shouldEnableToggle(args[2])) {
@@ -53,7 +51,7 @@ public class PartyItemShareCommand implements CommandExecutor {
} }
try { try {
handleToggleItemShareCategory(ItemShareType.valueOf(args[1].toUpperCase()), toggle); handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase()), toggle);
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
@@ -68,22 +66,22 @@ public class PartyItemShareCommand implements CommandExecutor {
} }
} }
private void handleChangingShareMode(ShareMode mode) { private void handleChangingShareMode(Party party, ShareMode mode) {
playerParty.setItemShareMode(mode); party.setItemShareMode(mode);
String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))); String changeModeMessage = LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString())));
for (Player member : playerParty.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
member.sendMessage(changeModeMessage); member.sendMessage(changeModeMessage);
} }
} }
private void handleToggleItemShareCategory(ItemShareType type, boolean toggle) { private void handleToggleItemShareCategory(Party party, ItemShareType type, boolean toggle) {
playerParty.setSharingDrops(type, toggle); party.setSharingDrops(type, toggle);
String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled"); String toggleMessage = LocaleLoader.getString("Commands.Party.ToggleShareCategory", StringUtils.getCapitalized(type.toString()), toggle ? "enabled" : "disabled");
for (Player member : playerParty.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
member.sendMessage(toggleMessage); member.sendMessage(toggleMessage);
} }
} }

View File

@@ -14,25 +14,33 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class PartyJoinCommand implements CommandExecutor { public class PartyJoinCommand implements CommandExecutor {
private McMMOPlayer mcMMOTarget;
private Player target;
private Party targetParty;
private McMMOPlayer mcMMOPlayer;
private Player player;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 2: case 2:
case 3: case 3:
// Verify target exists and is in a different party than the player String targetName = Misc.getMatchedPlayerName(args[1]);
if (!canJoinParty(sender, args[1])) { McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return true; return true;
} }
mcMMOPlayer = UserManager.getPlayer((Player) sender); Player target = mcMMOTarget.getPlayer();
player = mcMMOPlayer.getPlayer();
if (!mcMMOTarget.inParty()) {
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
return true;
}
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Party targetParty = mcMMOTarget.getParty();
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) {
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
return true;
}
String password = getPassword(args); String password = getPassword(args);
@@ -65,31 +73,4 @@ public class PartyJoinCommand implements CommandExecutor {
return null; return null;
} }
private boolean canJoinParty(CommandSender sender, String targetName) {
targetName = Misc.getMatchedPlayerName(targetName);
mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
target = mcMMOTarget.getPlayer();
if (!mcMMOTarget.inParty()) {
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
return false;
}
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
targetParty = mcMMOTarget.getParty();
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) {
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
return false;
}
return true;
}
} }

View File

@@ -12,19 +12,15 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
public class PartyLockCommand implements CommandExecutor { public class PartyLockCommand implements CommandExecutor {
private Party playerParty;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
playerParty = UserManager.getPlayer((Player) sender).getParty();
switch (args.length) { switch (args.length) {
case 1: case 1:
if (args[0].equalsIgnoreCase("lock")) { if (args[0].equalsIgnoreCase("lock")) {
lockParty(sender, command.getPermissionMessage()); togglePartyLock(sender, true);
} }
else if (args[0].equalsIgnoreCase("unlock")) { else if (args[0].equalsIgnoreCase("unlock")) {
unlockParty(sender, command.getPermissionMessage()); togglePartyLock(sender, false);
} }
return true; return true;
@@ -36,10 +32,10 @@ public class PartyLockCommand implements CommandExecutor {
} }
if (CommandUtils.shouldEnableToggle(args[1])) { if (CommandUtils.shouldEnableToggle(args[1])) {
lockParty(sender, command.getPermissionMessage()); togglePartyLock(sender, true);
} }
else if (CommandUtils.shouldDisableToggle(args[1])) { else if (CommandUtils.shouldDisableToggle(args[1])) {
unlockParty(sender, command.getPermissionMessage()); togglePartyLock(sender, false);
} }
else { else {
sendUsageStrings(sender); sendUsageStrings(sender);
@@ -53,44 +49,25 @@ public class PartyLockCommand implements CommandExecutor {
} }
} }
/**
* Handle locking a party.
*/
private void lockParty(CommandSender sender, String permissionMessage) {
if (!Permissions.partySubcommand(sender, PartySubcommandType.LOCK)) {
sender.sendMessage(permissionMessage);
return;
}
if (playerParty.isLocked()) {
sender.sendMessage(LocaleLoader.getString("Party.IsLocked"));
return;
}
playerParty.setLocked(true);
sender.sendMessage(LocaleLoader.getString("Party.Locked"));
}
/**
* Handle unlocking a party.
*/
private void unlockParty(CommandSender sender, String permissionMessage) {
if (!Permissions.partySubcommand(sender, PartySubcommandType.UNLOCK)) {
sender.sendMessage(permissionMessage);
return;
}
if (!playerParty.isLocked()) {
sender.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
return;
}
playerParty.setLocked(false);
sender.sendMessage(LocaleLoader.getString("Party.Unlocked"));
}
private void sendUsageStrings(CommandSender sender) { private void sendUsageStrings(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]"));
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock"));
} }
private void togglePartyLock(CommandSender sender, boolean lock) {
Party party = UserManager.getPlayer((Player) sender).getParty();
if (!Permissions.partySubcommand(sender, lock ? PartySubcommandType.LOCK : PartySubcommandType.UNLOCK)) {
sender.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
return;
}
if (lock ? party.isLocked() : !party.isLocked()) {
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "IsLocked" : "IsntLocked")));
return;
}
party.setLocked(lock);
sender.sendMessage(LocaleLoader.getString("Party." + (lock ? "Locked" : "Unlocked")));
}
} }

View File

@@ -3,9 +3,8 @@ package com.gmail.nossr50.commands.party.teleport;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@@ -18,17 +17,16 @@ public class PtpAcceptAnyCommand implements CommandExecutor {
return true; return true;
} }
Player player = (Player) sender; PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer.getPtpConfirmRequired()) { if (ptpRecord.isConfirmRequired()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled"));
} }
mcMMOPlayer.togglePtpConfirmRequired(); ptpRecord.toggleConfirmRequired();
return true; return true;
} }
} }

View File

@@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@@ -22,21 +22,21 @@ public class PtpAcceptCommand implements CommandExecutor {
} }
Player player = (Player) sender; Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); PartyTeleportRecord ptpRecord = UserManager.getPlayer(player).getPartyTeleportRecord();
if (!mcMMOPlayer.hasPtpRequest()) { if (!ptpRecord.hasRequest()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests")); player.sendMessage(LocaleLoader.getString("Commands.ptp.NoRequests"));
return true; return true;
} }
if ((mcMMOPlayer.getPtpTimeout() + Config.getInstance().getPTPCommandTimeout()) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) { if ((ptpRecord.getTimeout() + Config.getInstance().getPTPCommandTimeout()) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) {
mcMMOPlayer.removePtpRequest(); ptpRecord.removeRequest();
player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired")); player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired"));
return true; return true;
} }
Player target = mcMMOPlayer.getPtpRequest(); Player target = ptpRecord.getRequestor();
mcMMOPlayer.removePtpRequest(); ptpRecord.removeRequest();
if (!PtpCommand.canTeleport(sender, player, target.getName())) { if (!PtpCommand.canTeleport(sender, player, target.getName())) {
return true; return true;

View File

@@ -13,6 +13,7 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.PartyManager;
@@ -27,9 +28,6 @@ import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class PtpCommand implements TabExecutor { public class PtpCommand implements TabExecutor {
private static Player target;
private static McMMOPlayer mcMMOTarget;
public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall"); public static final List<String> TELEPORT_SUBCOMMANDS = ImmutableList.of("toggle", "accept", "acceptany", "acceptall");
private CommandExecutor ptpToggleCommand = new PtpToggleCommand(); private CommandExecutor ptpToggleCommand = new PtpToggleCommand();
@@ -77,7 +75,7 @@ public class PtpCommand implements TabExecutor {
} }
int ptpCooldown = Config.getInstance().getPTPCommandCooldown(); int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
long ptpLastUse = mcMMOPlayer.getPtpLastUse(); long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse();
if (ptpCooldown > 0) { if (ptpCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player); int timeRemaining = SkillUtils.calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player);
@@ -118,13 +116,18 @@ public class PtpCommand implements TabExecutor {
return; return;
} }
if (!mcMMOTarget.getPtpConfirmRequired()) { McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
Player target = mcMMOTarget.getPlayer();
PartyTeleportRecord ptpRecord = mcMMOTarget.getPartyTeleportRecord();
if (!ptpRecord.isConfirmRequired()) {
handleTeleportWarmup(player, target); handleTeleportWarmup(player, target);
return; return;
} }
mcMMOTarget.setPtpRequest(player); ptpRecord.setRequestor(player);
mcMMOTarget.actualizePtpTimeout(); ptpRecord.actualizeTimeout();
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
@@ -133,13 +136,13 @@ public class PtpCommand implements TabExecutor {
} }
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) { protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
mcMMOTarget = UserManager.getPlayer(targetName); McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) { if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false; return false;
} }
target = mcMMOTarget.getPlayer(); Player target = mcMMOTarget.getPlayer();
if (player.equals(target)) { if (player.equals(target)) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self")); player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
@@ -151,7 +154,7 @@ public class PtpCommand implements TabExecutor {
return false; return false;
} }
if (!mcMMOTarget.getPtpEnabled()) { if (!mcMMOTarget.getPartyTeleportRecord().isEnabled()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", targetName)); player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", targetName));
return false; return false;
} }
@@ -166,7 +169,7 @@ public class PtpCommand implements TabExecutor {
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) { protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
mcMMOTarget = UserManager.getPlayer(targetPlayer); McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer);
long warmup = Config.getInstance().getPTPCommandWarmup(); long warmup = Config.getInstance().getPTPCommandWarmup();

View File

@@ -3,9 +3,8 @@ package com.gmail.nossr50.commands.party.teleport;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@@ -18,17 +17,16 @@ public class PtpToggleCommand implements CommandExecutor {
return true; return true;
} }
Player player = (Player) sender; PartyTeleportRecord ptpRecord = UserManager.getPlayer(sender.getName()).getPartyTeleportRecord();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (mcMMOPlayer.getPtpEnabled()) { if (ptpRecord.isEnabled()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled"));
} }
mcMMOPlayer.togglePtpUse(); ptpRecord.toggleEnabled();
return true; return true;
} }
} }

View File

@@ -42,7 +42,10 @@ public class InspectCommand implements TabExecutor {
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) { if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile); ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
if (!Config.getInstance().getInspectUseChat()) return true;
if (!Config.getInstance().getInspectUseChat()) {
return true;
}
} }
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName)); sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
@@ -78,7 +81,10 @@ public class InspectCommand implements TabExecutor {
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) { if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile()); ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
if (!Config.getInstance().getInspectUseChat()) return true;
if (!Config.getInstance().getInspectUseChat()) {
return true;
}
} }
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName())); sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));

View File

@@ -6,18 +6,15 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class MccooldownCommand implements TabExecutor { public class MccooldownCommand implements TabExecutor {
@@ -33,26 +30,29 @@ public class MccooldownCommand implements TabExecutor {
if (Config.getInstance().getCooldownUseBoard()) { if (Config.getInstance().getCooldownUseBoard()) {
ScoreboardManager.enablePlayerCooldownScoreboard(player); ScoreboardManager.enablePlayerCooldownScoreboard(player);
if (!Config.getInstance().getCooldownUseChat()) return true;
if (!Config.getInstance().getCooldownUseChat()) {
return true;
}
} }
PlayerProfile profile = UserManager.getPlayer(player).getProfile(); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header")); player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
for (AbilityType ability : AbilityType.NORMAL_ABILITIES) { for (AbilityType ability : AbilityType.NORMAL_ABILITIES) {
if (!hasPermission(player, ability)) { if (!ability.getPermissions(player)) {
continue; continue;
} }
int seconds = SkillUtils.calculateTimeLeft(ability, profile, player); int seconds = mcMMOPlayer.calculateTimeRemaining(ability);
if (seconds <= 0) { if (seconds <= 0) {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getAbilityName())); player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getAbilityName(), Integer.toString(seconds))); player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
} }
} }
@@ -63,34 +63,6 @@ public class MccooldownCommand implements TabExecutor {
} }
} }
private boolean hasPermission(Permissible permissible, AbilityType ability) {
switch (ability) {
case BERSERK:
return Permissions.berserk(permissible);
case BLAST_MINING:
return Permissions.remoteDetonation(permissible);
case BLOCK_CRACKER:
return Permissions.blockCracker(permissible);
case GIGA_DRILL_BREAKER:
return Permissions.gigaDrillBreaker(permissible);
case GREEN_TERRA:
return Permissions.greenTerra(permissible);
case LEAF_BLOWER:
return Permissions.leafBlower(permissible);
case SERRATED_STRIKES:
return Permissions.serratedStrikes(permissible);
case SKULL_SPLITTER:
return Permissions.skullSplitter(permissible);
case SUPER_BREAKER:
return Permissions.superBreaker(permissible);
case TREE_FELLER:
return Permissions.treeFeller(permissible);
default:
mcMMO.p.getLogger().warning("MccooldownCommand - couldn't check permission for AbilityType." + ability.name());
return false;
}
}
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of(); return ImmutableList.of();

View File

@@ -19,6 +19,7 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class McrankCommand implements TabExecutor { public class McrankCommand implements TabExecutor {
@@ -49,9 +50,10 @@ public class McrankCommand implements TabExecutor {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
if (mcMMOPlayer != null) { if (mcMMOPlayer != null) {
playerName = mcMMOPlayer.getPlayer().getName(); Player player = mcMMOPlayer.getPlayer();
playerName = player.getName();
if (CommandUtils.tooFar(sender, mcMMOPlayer.getPlayer(), Permissions.mcrankFar(sender))) { if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) {
return true; return true;
} }
} }
@@ -80,16 +82,19 @@ public class McrankCommand implements TabExecutor {
private void display(CommandSender sender, String playerName) { private void display(CommandSender sender, String playerName) {
if (sender instanceof Player) { if (sender instanceof Player) {
McMMOPlayer mcpl = UserManager.getPlayer(sender.getName()); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
if (mcpl.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown")); sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
return; return;
} }
mcpl.actualizeDatabaseATS();
mcMMOPlayer.actualizeDatabaseATS();
} }
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getRankUseBoard()); boolean useBoard = (sender instanceof Player) && (Config.getInstance().getRankUseBoard());
boolean useChat = useBoard ? Config.getInstance().getRankUseChat() : true; boolean useChat = useBoard ? Config.getInstance().getRankUseChat() : true;
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p); new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
} }
} }

View File

@@ -28,8 +28,12 @@ public class McstatsCommand implements TabExecutor {
if (Config.getInstance().getStatsUseBoard()) { if (Config.getInstance().getStatsUseBoard()) {
ScoreboardManager.enablePlayerStatsScoreboard(player); ScoreboardManager.enablePlayerStatsScoreboard(player);
if (!Config.getInstance().getStatsUseChat()) return true;
if (!Config.getInstance().getStatsUseChat()) {
return true;
}
} }
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats")); player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));

View File

@@ -20,26 +20,28 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class MctopCommand implements TabExecutor { public class MctopCommand implements TabExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
SkillType skill; SkillType skill = null;
switch (args.length) { switch (args.length) {
case 0: case 0:
display(1, null, sender, command); display(1, skill, sender, command);
return true; return true;
case 1: case 1:
if (StringUtils.isInt(args[0])) { if (StringUtils.isInt(args[0])) {
display(Math.abs(Integer.parseInt(args[0])), null, sender, command); display(Math.abs(Integer.parseInt(args[0])), skill, sender, command);
return true; return true;
} }
if ((skill = extractSkill(sender, args[0])) == null) { skill = extractSkill(sender, args[0]);
if (skill == null) {
return true; return true;
} }
@@ -51,7 +53,9 @@ public class MctopCommand implements TabExecutor {
return true; return true;
} }
if ((skill = extractSkill(sender, args[0])) == null) { skill = extractSkill(sender, args[0]);
if (skill == null) {
return true; return true;
} }
@@ -80,12 +84,14 @@ public class MctopCommand implements TabExecutor {
} }
if (sender instanceof Player) { if (sender instanceof Player) {
McMMOPlayer mcpl = UserManager.getPlayer(sender.getName()); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
if (mcpl.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown")); sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
return; return;
} }
mcpl.actualizeDatabaseATS();
mcMMOPlayer.actualizeDatabaseATS();
} }
display(page, skill, sender); display(page, skill, sender);
@@ -102,9 +108,10 @@ public class MctopCommand implements TabExecutor {
if (CommandUtils.isInvalidSkill(sender, skillName)) { if (CommandUtils.isInvalidSkill(sender, skillName)) {
return null; return null;
} }
SkillType skill = SkillType.getSkill(skillName); SkillType skill = SkillType.getSkill(skillName);
if (skill != null && CommandUtils.isChildSkill(sender, skill)) { if (CommandUtils.isChildSkill(sender, skill)) {
return null; return null;
} }

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.acrobatics.Acrobatics; import com.gmail.nossr50.skills.acrobatics.Acrobatics;
@@ -22,75 +27,71 @@ public class AcrobaticsCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// DODGE // DODGE
if (canDodge) { if (canDodge) {
String[] dodgeStrings = calculateAbilityDisplayValues(Acrobatics.dodgeMaxBonusLevel, Acrobatics.dodgeMaxChance); String[] dodgeStrings = calculateAbilityDisplayValues(skillValue, Acrobatics.dodgeMaxBonusLevel, Acrobatics.dodgeMaxChance, isLucky);
dodgeChance = dodgeStrings[0]; dodgeChance = dodgeStrings[0];
dodgeChanceLucky = dodgeStrings[1]; dodgeChanceLucky = dodgeStrings[1];
} }
// ROLL // ROLL
if (canRoll) { if (canRoll) {
String[] rollStrings = calculateAbilityDisplayValues(Acrobatics.rollMaxBonusLevel, Acrobatics.rollMaxChance); String[] rollStrings = calculateAbilityDisplayValues(skillValue, Acrobatics.rollMaxBonusLevel, Acrobatics.rollMaxChance, isLucky);
rollChance = rollStrings[0]; rollChance = rollStrings[0];
rollChanceLucky = rollStrings[1]; rollChanceLucky = rollStrings[1];
} }
// GRACEFUL ROLL // GRACEFUL ROLL
if (canGracefulRoll) { if (canGracefulRoll) {
String[] gracefulRollStrings = calculateAbilityDisplayValues(Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollMaxChance); String[] gracefulRollStrings = calculateAbilityDisplayValues(skillValue, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollMaxChance, isLucky);
gracefulRollChance = gracefulRollStrings[0]; gracefulRollChance = gracefulRollStrings[0];
gracefulRollChanceLucky = gracefulRollStrings[1]; gracefulRollChanceLucky = gracefulRollStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canDodge = Permissions.dodge(player); canDodge = Permissions.dodge(player);
canRoll = Permissions.roll(player); canRoll = Permissions.roll(player);
canGracefulRoll = Permissions.gracefulRoll(player); canGracefulRoll = Permissions.gracefulRoll(player);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canDodge || canGracefulRoll || canRoll; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canRoll) { if (canRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1")));
} }
if (canGracefulRoll) { if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3")));
} }
if (canDodge) { if (canDodge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canDodge || canGracefulRoll || canRoll; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canRoll) { if (canRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : "")); messages.add(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : ""));
} }
if (canGracefulRoll) { if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : "")); messages.add(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : ""));
} }
if (canDodge) { if (canDodge) {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dodgeChanceLucky) : "")); messages.add(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dodgeChanceLucky) : ""));
} }
return messages;
} }
} }

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.archery.Archery; import com.gmail.nossr50.skills.archery.Archery;
@@ -21,7 +26,7 @@ public class ArcheryCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// SKILL SHOT // SKILL SHOT
if (canSkillShot) { if (canSkillShot) {
double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage; double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage;
@@ -30,65 +35,61 @@ public class ArcheryCommand extends SkillCommand {
// DAZE // DAZE
if (canDaze) { if (canDaze) {
String[] dazeStrings = calculateAbilityDisplayValues(Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus); String[] dazeStrings = calculateAbilityDisplayValues(skillValue, Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus, isLucky);
dazeChance = dazeStrings[0]; dazeChance = dazeStrings[0];
dazeChanceLucky = dazeStrings[1]; dazeChanceLucky = dazeStrings[1];
} }
// RETRIEVE // RETRIEVE
if (canRetrieve) { if (canRetrieve) {
String[] retrieveStrings = calculateAbilityDisplayValues(Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance); String[] retrieveStrings = calculateAbilityDisplayValues(skillValue, Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance, isLucky);
retrieveChance = retrieveStrings[0]; retrieveChance = retrieveStrings[0];
retrieveChanceLucky = retrieveStrings[1]; retrieveChanceLucky = retrieveStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canSkillShot = Permissions.bonusDamage(player, skill); canSkillShot = Permissions.bonusDamage(player, skill);
canDaze = Permissions.daze(player); canDaze = Permissions.daze(player);
canRetrieve = Permissions.arrowRetrieval(player); canRetrieve = Permissions.arrowRetrieval(player);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canSkillShot || canDaze || canRetrieve; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canSkillShot) { if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1")));
} }
if (canDaze) { if (canDaze) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier)));
} }
if (canRetrieve) { if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canSkillShot || canDaze || canRetrieve; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canSkillShot) { if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", skillShotBonus)); messages.add(LocaleLoader.getString("Archery.Combat.SkillshotBonus", skillShotBonus));
} }
if (canDaze) { if (canDaze) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dazeChanceLucky) : "")); messages.add(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dazeChanceLucky) : ""));
} }
if (canRetrieve) { if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", retrieveChanceLucky) : "")); messages.add(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", retrieveChanceLucky) : ""));
} }
return messages;
} }
} }

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.axes.Axes; import com.gmail.nossr50.skills.axes.Axes;
@@ -24,7 +29,7 @@ public class AxesCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// IMPACT // IMPACT
if (canImpact) { if (canImpact) {
impactDamage = 1 + (skillValue / Axes.impactIncreaseLevel); impactDamage = 1 + (skillValue / Axes.impactIncreaseLevel);
@@ -32,14 +37,14 @@ public class AxesCommand extends SkillCommand {
// SKULL SPLITTER // SKULL SPLITTER
if (canSkullSplitter) { if (canSkullSplitter) {
String[] skullSplitterStrings = calculateLengthDisplayValues(); String[] skullSplitterStrings = calculateLengthDisplayValues(player, skillValue);
skullSplitterLength = skullSplitterStrings[0]; skullSplitterLength = skullSplitterStrings[0];
skullSplitterLengthEndurance = skullSplitterStrings[1]; skullSplitterLengthEndurance = skullSplitterStrings[1];
} }
// CRITICAL STRIKES // CRITICAL STRIKES
if (canCritical) { if (canCritical) {
String[] criticalStrikeStrings = calculateAbilityDisplayValues(Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance); String[] criticalStrikeStrings = calculateAbilityDisplayValues(skillValue, Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance, isLucky);
critChance = criticalStrikeStrings[0]; critChance = criticalStrikeStrings[0];
critChanceLucky = criticalStrikeStrings[1]; critChanceLucky = criticalStrikeStrings[1];
} }
@@ -51,7 +56,7 @@ public class AxesCommand extends SkillCommand {
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canSkullSplitter = Permissions.skullSplitter(player); canSkullSplitter = Permissions.skullSplitter(player);
canCritical = Permissions.criticalStrikes(player); canCritical = Permissions.criticalStrikes(player);
canBonusDamage = Permissions.bonusDamage(player, skill); canBonusDamage = Permissions.bonusDamage(player, skill);
@@ -60,60 +65,56 @@ public class AxesCommand extends SkillCommand {
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canSkullSplitter) { if (canSkullSplitter) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1")));
} }
if (canCritical) { if (canCritical) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3")));
} }
if (canBonusDamage) { if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5")));
} }
if (canImpact) { if (canImpact) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7")));
} }
if (canGreaterImpact) { if (canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canBonusDamage) { if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", bonusDamage))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", bonusDamage)));
} }
if (canImpact) { if (canImpact) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage)));
} }
if (canGreaterImpact) { if (canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", Axes.greaterImpactBonusDamage))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", Axes.greaterImpactBonusDamage)));
} }
if (canCritical) { if (canCritical) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", critChanceLucky) : "")); messages.add(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", critChanceLucky) : ""));
} }
if (canSkullSplitter) { if (canSkullSplitter) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : "")); messages.add(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : ""));
} }
return messages;
} }
} }

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
@@ -16,48 +21,44 @@ public class ExcavationCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// GIGA DRILL BREAKER // GIGA DRILL BREAKER
if (canGigaDrill) { if (canGigaDrill) {
String gigaDrillStrings[] = calculateLengthDisplayValues(); String gigaDrillStrings[] = calculateLengthDisplayValues(player, skillValue);
gigaDrillBreakerLength = gigaDrillStrings[0]; gigaDrillBreakerLength = gigaDrillStrings[0];
gigaDrillBreakerLengthEndurance = gigaDrillStrings[1]; gigaDrillBreakerLengthEndurance = gigaDrillStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canGigaDrill = Permissions.gigaDrillBreaker(player); canGigaDrill = Permissions.gigaDrillBreaker(player);
canTreasureHunt = Permissions.excavationTreasureHunter(player); canTreasureHunt = Permissions.excavationTreasureHunter(player);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canGigaDrill || canTreasureHunt; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canGigaDrill) { if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1")));
} }
if (canTreasureHunt) { if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canGigaDrill; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canGigaDrill) { if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : "")); messages.add(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
} }
return messages;
} }
} }

View File

@@ -1,8 +1,12 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig; import com.gmail.nossr50.config.treasure.TreasureConfig;
@@ -11,6 +15,7 @@ import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.fishing.Fishing; import com.gmail.nossr50.skills.fishing.Fishing;
import com.gmail.nossr50.skills.fishing.Fishing.Tier; import com.gmail.nossr50.skills.fishing.Fishing.Tier;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
@@ -43,48 +48,55 @@ public class FishingCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
boolean isStorming = player.getWorld().hasStorm(); boolean isStorming = player.getWorld().hasStorm();
// TREASURE HUNTER // TREASURE HUNTER
if (canTreasureHunt) { if (canTreasureHunt) {
lootTier = mcMMOPlayer.getFishingManager().getLootTier(); lootTier = fishingManager.getLootTier();
// Item drop rates // Item drop rates
trapTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.TRAP))[0]; trapTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.TRAP) / 100.0);
commonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON))[0]; commonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0);
uncommonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON))[0]; uncommonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0);
rareTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE))[0]; rareTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0);
epicTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC))[0]; epicTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC) / 100.0);
legendaryTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY))[0]; legendaryTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY) / 100.0);
recordTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD))[0]; recordTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD) / 100.0);
// Magic hunter drop rates // Magic hunter drop rates
double commonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.COMMON); double totalEnchantChance = 0;
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]; for (Rarity rarity : Rarity.values()) {
if (rarity != Rarity.TRAP || rarity != Rarity.RECORD) {
totalEnchantChance += TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, rarity);
}
}
magicChance = percent.format(totalEnchantChance / 100.0);
} }
// SHAKE // SHAKE
if (canShake) { if (canShake) {
String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability()); String[] shakeStrings = calculateAbilityDisplayValues(UserManager.getPlayer(player).getFishingManager().getShakeProbability(), isLucky);
shakeChance = shakeStrings[0]; shakeChance = shakeStrings[0];
shakeChanceLucky = shakeStrings[1]; shakeChanceLucky = shakeStrings[1];
} }
// FISHERMAN'S DIET // FISHERMAN'S DIET
if (canFishermansDiet) { if (canFishermansDiet) {
fishermansDietRank = calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1); fishermansDietRank = calculateRank(skillValue, Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
} }
// MASTER ANGLER // MASTER ANGLER
if (canMasterAngler) { if (canMasterAngler) {
double rawBiteChance = 1.0 / (isStorming ? 300 : 500); double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
Location location = (mcMMOPlayer.getHookLocation() != null) ? mcMMOPlayer.getHookLocation() : player.getLocation(); Location location = fishingManager.getHookLocation();
if (location == null) {
location = player.getLocation();
}
Biome biome = location.getBlock().getBiome(); Biome biome = location.getBlock().getBiome();
@@ -96,12 +108,12 @@ public class FishingCommand extends SkillCommand {
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier(); rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
} }
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0)[0]; biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0, isLucky)[0];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canTreasureHunt = Permissions.fishingTreasureHunter(player); canTreasureHunt = Permissions.fishingTreasureHunter(player);
canMagicHunt = Permissions.magicHunter(player); canMagicHunt = Permissions.magicHunter(player);
canShake = Permissions.shake(player); canShake = Permissions.shake(player);
@@ -111,63 +123,57 @@ public class FishingCommand extends SkillCommand {
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canTreasureHunt) { if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1")));
} }
if (canMagicHunt) { if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
} }
if (canIceFish) { if (canIceFish) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
} }
if (canMasterAngler) { if (canMasterAngler) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
} }
if (canShake) { if (canShake) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
} }
if (canFishermansDiet) { if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canTreasureHunt) { if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier, Tier.EIGHT.toNumerical())); messages.add(LocaleLoader.getString("Fishing.Ability.Rank", lootTier, Tier.EIGHT.toNumerical()));
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.DropRate", trapTreasure, commonTreasure, uncommonTreasure, rareTreasure, epicTreasure, legendaryTreasure, recordTreasure)); messages.add(LocaleLoader.getString("Fishing.Ability.TH.DropRate", trapTreasure, commonTreasure, uncommonTreasure, rareTreasure, epicTreasure, legendaryTreasure, recordTreasure));
} }
if (canMagicHunt) { if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.MagicRate", magicChance)); messages.add(LocaleLoader.getString("Fishing.Ability.TH.MagicRate", magicChance));
} }
if (canIceFish) { if (canIceFish) {
int unlockLevel = AdvancedConfig.getInstance().getIceFishingUnlockLevel(); int unlockLevel = AdvancedConfig.getInstance().getIceFishingUnlockLevel();
if (skillValue < unlockLevel) { if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing")); messages.add(LocaleLoader.getString("Fishing.Ability.IceFishing"));
} }
} }
@@ -175,10 +181,10 @@ public class FishingCommand extends SkillCommand {
int unlockLevel = AdvancedConfig.getInstance().getMasterAnglerUnlockLevel(); int unlockLevel = AdvancedConfig.getInstance().getMasterAnglerUnlockLevel();
if (skillValue < unlockLevel) { if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.2", unlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.2", unlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance)); messages.add(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
} }
} }
@@ -186,15 +192,17 @@ public class FishingCommand extends SkillCommand {
int unlockLevel = AdvancedConfig.getInstance().getFishingTierLevel(Tier.ONE); int unlockLevel = AdvancedConfig.getInstance().getFishingTierLevel(Tier.ONE);
if (skillValue < unlockLevel) { if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", unlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : "")); messages.add(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
} }
} }
if (canFishermansDiet) { if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank)); messages.add(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
} }
return messages;
} }
} }

View File

@@ -1,6 +1,10 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
@@ -34,52 +38,52 @@ public class HerbalismCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// GREEN TERRA // GREEN TERRA
if (canGreenTerra) { if (canGreenTerra) {
String[] greenTerraStrings = calculateLengthDisplayValues(); String[] greenTerraStrings = calculateLengthDisplayValues(player, skillValue);
greenTerraLength = greenTerraStrings[0]; greenTerraLength = greenTerraStrings[0];
greenTerraLengthEndurance = greenTerraStrings[1]; greenTerraLengthEndurance = greenTerraStrings[1];
} }
// FARMERS DIET // FARMERS DIET
if (canFarmersDiet) { if (canFarmersDiet) {
farmersDietRank = calculateRank(Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1); farmersDietRank = calculateRank(skillValue, Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1);
} }
// GREEN THUMB // GREEN THUMB
if (canGreenThumbBlocks || canGreenThumbPlants) { if (canGreenThumbBlocks || canGreenThumbPlants) {
greenThumbStage = calculateRank(Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel); greenThumbStage = calculateRank(skillValue, Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel);
String[] greenThumbStrings = calculateAbilityDisplayValues(Herbalism.greenThumbMaxLevel, Herbalism.greenThumbMaxChance); String[] greenThumbStrings = calculateAbilityDisplayValues(skillValue, Herbalism.greenThumbMaxLevel, Herbalism.greenThumbMaxChance, isLucky);
greenThumbChance = greenThumbStrings[0]; greenThumbChance = greenThumbStrings[0];
greenThumbChanceLucky = greenThumbStrings[1]; greenThumbChanceLucky = greenThumbStrings[1];
} }
// DOUBLE DROPS // DOUBLE DROPS
if (canDoubleDrop) { if (canDoubleDrop) {
String[] doubleDropStrings = calculateAbilityDisplayValues(Herbalism.doubleDropsMaxLevel, Herbalism.doubleDropsMaxChance); String[] doubleDropStrings = calculateAbilityDisplayValues(skillValue, Herbalism.doubleDropsMaxLevel, Herbalism.doubleDropsMaxChance, isLucky);
doubleDropChance = doubleDropStrings[0]; doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1]; doubleDropChanceLucky = doubleDropStrings[1];
} }
// HYLIAN LUCK // HYLIAN LUCK
if (hasHylianLuck) { if (hasHylianLuck) {
String[] hylianLuckStrings = calculateAbilityDisplayValues(Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance); String[] hylianLuckStrings = calculateAbilityDisplayValues(skillValue, Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance, isLucky);
hylianLuckChance = hylianLuckStrings[0]; hylianLuckChance = hylianLuckStrings[0];
hylianLuckChanceLucky = hylianLuckStrings[1]; hylianLuckChanceLucky = hylianLuckStrings[1];
} }
// SHROOM THUMB // SHROOM THUMB
if (canShroomThumb) { if (canShroomThumb) {
String[] shroomThumbStrings = calculateAbilityDisplayValues(Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance); String[] shroomThumbStrings = calculateAbilityDisplayValues(skillValue, Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance, isLucky);
shroomThumbChance = shroomThumbStrings[0]; shroomThumbChance = shroomThumbStrings[0];
shroomThumbChanceLucky = shroomThumbStrings[1]; shroomThumbChanceLucky = shroomThumbStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
hasHylianLuck = Permissions.hylianLuck(player); hasHylianLuck = Permissions.hylianLuck(player);
canGreenTerra = Permissions.greenTerra(player); canGreenTerra = Permissions.greenTerra(player);
canGreenThumbPlants = Permissions.greenThumbPlant(player, Material.CROPS) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.NETHER_WARTS) || Permissions.greenThumbPlant(player, Material.COCOA); canGreenThumbPlants = Permissions.greenThumbPlant(player, Material.CROPS) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.NETHER_WARTS) || Permissions.greenThumbPlant(player, Material.COCOA);
@@ -90,76 +94,72 @@ public class HerbalismCommand extends SkillCommand {
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canGreenTerra || canDoubleDrop || canFarmersDiet || canGreenThumbBlocks || canGreenThumbPlants || canShroomThumb; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canGreenTerra) { if (canGreenTerra) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1")));
} }
if (canGreenThumbPlants) { if (canGreenThumbPlants) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3")));
} }
if (canGreenThumbBlocks) { if (canGreenThumbBlocks) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5")));
} }
if (canFarmersDiet) { if (canFarmersDiet) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7")));
} }
if (hasHylianLuck) { if (hasHylianLuck) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11")));
} }
if (canShroomThumb) { if (canShroomThumb) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13")));
} }
if (canDoubleDrop) { if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canGreenTerra || canDoubleDrop || canFarmersDiet || canGreenThumbBlocks || canGreenThumbPlants || canShroomThumb; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canGreenTerra) { if (canGreenTerra) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : "")); messages.add(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));
} }
if (canGreenThumbBlocks || canGreenThumbPlants) { if (canGreenThumbBlocks || canGreenThumbPlants) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : "")); messages.add(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : ""));
} }
if (canGreenThumbPlants) { if (canGreenThumbPlants) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", greenThumbStage)); messages.add(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", greenThumbStage));
} }
if (canFarmersDiet) { if (canFarmersDiet) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", farmersDietRank)); messages.add(LocaleLoader.getString("Herbalism.Ability.FD", farmersDietRank));
} }
if (hasHylianLuck) { if (hasHylianLuck) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", hylianLuckChanceLucky) : "")); messages.add(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", hylianLuckChanceLucky) : ""));
} }
if (canShroomThumb) { if (canShroomThumb) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shroomThumbChanceLucky) : "")); messages.add(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shroomThumbChanceLucky) : ""));
} }
if (canDoubleDrop) { if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : "")); messages.add(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
} }
return messages;
} }
} }

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
@@ -7,6 +12,7 @@ import com.gmail.nossr50.skills.mining.BlastMining.Tier;
import com.gmail.nossr50.skills.mining.Mining; import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
public class MiningCommand extends SkillCommand { public class MiningCommand extends SkillCommand {
private String doubleDropChance; private String doubleDropChance;
@@ -32,24 +38,24 @@ public class MiningCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// SUPER BREAKER // SUPER BREAKER
if (canSuperBreaker) { if (canSuperBreaker) {
String[] superBreakerStrings = calculateLengthDisplayValues(); String[] superBreakerStrings = calculateLengthDisplayValues(player, skillValue);
superBreakerLength = superBreakerStrings[0]; superBreakerLength = superBreakerStrings[0];
superBreakerLengthEndurance = superBreakerStrings[1]; superBreakerLengthEndurance = superBreakerStrings[1];
} }
// DOUBLE DROPS // DOUBLE DROPS
if (canDoubleDrop) { if (canDoubleDrop) {
String[] doubleDropStrings = calculateAbilityDisplayValues(Mining.doubleDropsMaxLevel, Mining.doubleDropsMaxChance); String[] doubleDropStrings = calculateAbilityDisplayValues(skillValue, Mining.doubleDropsMaxLevel, Mining.doubleDropsMaxChance, isLucky);
doubleDropChance = doubleDropStrings[0]; doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1]; doubleDropChanceLucky = doubleDropStrings[1];
} }
// BLAST MINING // BLAST MINING
if (canBlast || canDemoExpert || canBiggerBombs) { if (canBlast || canDemoExpert || canBiggerBombs) {
MiningManager miningManager = mcMMOPlayer.getMiningManager(); MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
blastMiningRank = miningManager.getBlastMiningTier(); blastMiningRank = miningManager.getBlastMiningTier();
bonusTNTDrops = miningManager.getDropMultiplier(); bonusTNTDrops = miningManager.getDropMultiplier();
@@ -61,7 +67,7 @@ public class MiningCommand extends SkillCommand {
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canBiggerBombs = Permissions.biggerBombs(player); canBiggerBombs = Permissions.biggerBombs(player);
canBlast = Permissions.remoteDetonation(player); canBlast = Permissions.remoteDetonation(player);
canDemoExpert = Permissions.demolitionsExpertise(player); canDemoExpert = Permissions.demolitionsExpertise(player);
@@ -70,58 +76,52 @@ public class MiningCommand extends SkillCommand {
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canBiggerBombs || canBlast || canDemoExpert || canDoubleDrop || canSuperBreaker; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canSuperBreaker) { if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1")));
} }
if (canDoubleDrop) { if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3")));
} }
if (canBlast) { if (canBlast) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5")));
} }
if (canBiggerBombs) { if (canBiggerBombs) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7")));
} }
if (canDemoExpert) { if (canDemoExpert) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canBiggerBombs || canBlast || canDemoExpert || canDoubleDrop || canSuperBreaker; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canDoubleDrop) { if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : "")); messages.add(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
} }
if (canSuperBreaker) { if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : "")); messages.add(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));
} }
if (canBlast) { if (canBlast) {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.ONE); int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.ONE);
if (skillValue < unlockLevel) { if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, Tier.EIGHT.toNumerical(), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops))); messages.add(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, Tier.EIGHT.toNumerical(), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
} }
} }
@@ -129,10 +129,10 @@ public class MiningCommand extends SkillCommand {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.TWO); int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.TWO);
if (skillValue < unlockLevel) { if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease)); messages.add(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease));
} }
} }
@@ -140,11 +140,13 @@ public class MiningCommand extends SkillCommand {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.FOUR); int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.FOUR);
if (skillValue < unlockLevel) { if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease)); messages.add(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease));
} }
} }
return messages;
} }
} }

View File

@@ -1,6 +1,10 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -11,6 +15,7 @@ import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.repairables.Repairable; import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
public class RepairCommand extends SkillCommand { public class RepairCommand extends SkillCommand {
private String repairMasteryBonus; private String repairMasteryBonus;
@@ -40,7 +45,7 @@ public class RepairCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// We're using pickaxes here, not the best but it works // We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE); Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE); Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE);
@@ -60,14 +65,14 @@ public class RepairCommand extends SkillCommand {
// SUPER REPAIR // SUPER REPAIR
if (canSuperRepair) { if (canSuperRepair) {
String[] superRepairStrings = calculateAbilityDisplayValues(Repair.superRepairMaxBonusLevel, Repair.superRepairMaxChance); String[] superRepairStrings = calculateAbilityDisplayValues(skillValue, Repair.superRepairMaxBonusLevel, Repair.superRepairMaxChance, isLucky);
superRepairChance = superRepairStrings[0]; superRepairChance = superRepairStrings[0];
superRepairChanceLucky = superRepairStrings[1]; superRepairChanceLucky = superRepairStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canSuperRepair = Permissions.superRepair(player); canSuperRepair = Permissions.superRepair(player);
canMasterRepair = Permissions.repairMastery(player); canMasterRepair = Permissions.repairMastery(player);
canArcaneForge = Permissions.arcaneForging(player); canArcaneForge = Permissions.arcaneForging(player);
@@ -83,78 +88,76 @@ public class RepairCommand extends SkillCommand {
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canArcaneForge || canSalvage || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather; List<String> messages = new ArrayList<String>();
}
@Override if (canRepairLeather || canRepairString || canRepairWood || canRepairStone || canRepairIron || canRepairGold || canRepairDiamond) {
protected void effectsDisplay() { messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1")));
luckyEffectsDisplay(); }
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1")));
if (canMasterRepair) { if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3")));
} }
if (canSuperRepair) { if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5")));
} }
/* Repair Level Requirements */ /* Repair Level Requirements */
if (canRepairStone && stoneLevel > 0) { if (canRepairStone && stoneLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15")));
} }
if (canRepairIron && ironLevel > 0) { if (canRepairIron && ironLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13")));
} }
if (canRepairGold && goldLevel > 0) { if (canRepairGold && goldLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11")));
} }
if (canRepairDiamond && diamondLevel > 0) { if (canRepairDiamond && diamondLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
} }
if (canSalvage && Repair.salvageUnlockLevel > 0) { if (canSalvage && Repair.salvageUnlockLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Repair.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Repair.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
} }
if (canArcaneForge) { if (canArcaneForge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canArcaneForge || canMasterRepair || canSuperRepair; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canMasterRepair) { if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus)); messages.add(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus));
} }
if (canSuperRepair) { if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", superRepairChanceLucky) : "")); messages.add(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", superRepairChanceLucky) : ""));
} }
if (canArcaneForge) { if (canArcaneForge) {
RepairManager repairManager = mcMMOPlayer.getRepairManager(); RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank(), Tier.EIGHT.toNumerical())); messages.add(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank(), Tier.EIGHT.toNumerical()));
if (ArcaneForging.arcaneForgingEnchantLoss) { if (ArcaneForging.arcaneForgingEnchantLoss) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance()))); messages.add(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance())));
} }
if (ArcaneForging.arcaneForgingDowngrades) { if (ArcaneForging.arcaneForgingDowngrades) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance()))); messages.add(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance())));
} }
} }
return messages;
} }
} }

View File

@@ -13,7 +13,6 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.child.FamilyTree;
@@ -28,15 +27,7 @@ import com.google.common.collect.ImmutableList;
public abstract class SkillCommand implements TabExecutor { public abstract class SkillCommand implements TabExecutor {
protected SkillType skill; protected SkillType skill;
protected String skillName; private String skillName;
protected Player player;
protected PlayerProfile profile;
protected McMMOPlayer mcMMOPlayer;
protected float skillValue;
protected boolean isLucky;
protected boolean hasEndurance;
protected DecimalFormat percent = new DecimalFormat("##0.00%"); protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00"); protected DecimalFormat decimal = new DecimalFormat("##0.00");
@@ -45,7 +36,7 @@ public abstract class SkillCommand implements TabExecutor {
public SkillCommand(SkillType skill) { public SkillCommand(SkillType skill) {
this.skill = skill; this.skill = skill;
skillName = skill.getSkillName(); skillName = skill.getName();
skillGuideCommand = new SkillGuideCommand(skill); skillGuideCommand = new SkillGuideCommand(skill);
} }
@@ -55,19 +46,17 @@ public abstract class SkillCommand implements TabExecutor {
return true; return true;
} }
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
switch (args.length) { switch (args.length) {
case 0: case 0:
profile = mcMMOPlayer.getProfile(); Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
skillValue = profile.getSkillLevel(skill); boolean isLucky = Permissions.lucky(player, skill);
isLucky = Permissions.lucky(sender, skill); boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0); float skillValue = mcMMOPlayer.getSkillLevel(skill);
permissionsCheck(); permissionsCheck(player);
dataCalculations(); dataCalculations(player, skillValue, isLucky);
if (Config.getInstance().getSkillUseBoard()) { if (Config.getInstance().getSkillUseBoard()) {
ScoreboardManager.enablePlayerSkillScoreboard(player, skill); ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
@@ -76,8 +65,7 @@ public abstract class SkillCommand implements TabExecutor {
if (!skill.isChildSkill()) { if (!skill.isChildSkill()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName)); player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString())))); player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill))); player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, mcMMOPlayer.getSkillXpLevel(skill), mcMMOPlayer.getXpToLevel(skill)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child"))); player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
@@ -88,21 +76,34 @@ public abstract class SkillCommand implements TabExecutor {
Set<SkillType> parents = FamilyTree.getParents(skill); Set<SkillType> parents = FamilyTree.getParents(skill);
for (SkillType parent : parents) { for (SkillType parent : parents) {
player.sendMessage(parent.getSkillName() + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent))); player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)));
} }
} }
if (effectsHeaderPermissions()) { List<String> effectMessages = effectsDisplay();
if (!effectMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects"))); player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
if (isLucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.Lucky.Name"), LocaleLoader.getString("Perks.Lucky.Desc", skillName)));
}
for (String message : effectMessages) {
player.sendMessage(message);
}
} }
effectsDisplay(); List<String> statsMessages = statsDisplay(player, skillValue, hasEndurance, isLucky);
if (statsHeaderPermissions()) { if (!statsMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self"))); player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));
}
statsDisplay(); for (String message : statsMessages) {
player.sendMessage(message);
}
}
player.sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase())); player.sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase()));
return true; return true;
@@ -122,11 +123,11 @@ public abstract class SkillCommand implements TabExecutor {
} }
} }
protected int calculateRank(int maxLevel, int rankChangeLevel) { protected int calculateRank(float skillValue, int maxLevel, int rankChangeLevel) {
return Math.min((int) skillValue, maxLevel) / rankChangeLevel; return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
} }
protected String[] calculateAbilityDisplayValues(double chance) { protected String[] calculateAbilityDisplayValues(double chance, boolean isLucky) {
String[] displayValues = new String[2]; String[] displayValues = new String[2];
displayValues[0] = percent.format(Math.min(chance, 100.0D) / 100.0D); displayValues[0] = percent.format(Math.min(chance, 100.0D) / 100.0D);
@@ -135,11 +136,11 @@ public abstract class SkillCommand implements TabExecutor {
return displayValues; return displayValues;
} }
protected String[] calculateAbilityDisplayValues(int maxBonusLevel, double maxChance) { protected String[] calculateAbilityDisplayValues(float skillValue, int maxBonusLevel, double maxChance, boolean isLucky) {
return calculateAbilityDisplayValues((maxChance / maxBonusLevel) * Math.min(skillValue, maxBonusLevel)); return calculateAbilityDisplayValues((maxChance / maxBonusLevel) * Math.min(skillValue, maxBonusLevel), isLucky);
} }
protected String[] calculateLengthDisplayValues() { protected String[] calculateLengthDisplayValues(Player player, float skillValue) {
int maxLength = skill.getAbility().getMaxLength(); int maxLength = skill.getAbility().getMaxLength();
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength()); int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength); int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
@@ -151,22 +152,11 @@ public abstract class SkillCommand implements TabExecutor {
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) }; return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
} }
protected void luckyEffectsDisplay() { protected abstract void dataCalculations(Player player, float skillValue, boolean isLucky);
if (isLucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.Lucky.Name"), LocaleLoader.getString("Perks.Lucky.Desc", skillName)));
}
}
protected abstract void dataCalculations(); protected abstract void permissionsCheck(Player player);
protected abstract void permissionsCheck(); protected abstract List<String> effectsDisplay();
protected abstract boolean effectsHeaderPermissions(); protected abstract List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky);
protected abstract void effectsDisplay();
protected abstract boolean statsHeaderPermissions();
protected abstract void statsDisplay();
} }

View File

@@ -15,13 +15,11 @@ public class SkillGuideCommand implements CommandExecutor {
private String header; private String header;
private ArrayList<String> guide; private ArrayList<String> guide;
private String invalidPage; private String invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
public SkillGuideCommand(SkillType skillType) { public SkillGuideCommand(SkillType skill) {
header = LocaleLoader.getString("Guides.Header", skillType.getSkillName()); header = LocaleLoader.getString("Guides.Header", skill.getName());
guide = getGuide(skillType); guide = getGuide(skill);
invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
} }
@Override @Override
@@ -68,8 +66,8 @@ public class SkillGuideCommand implements CommandExecutor {
} }
} }
private ArrayList<String> grabPageContents(int pagenum) { private ArrayList<String> grabPageContents(int page) {
int pageIndexStart = 8 * (pagenum - 1); // Determine what string to start at int pageIndexStart = 8 * (page - 1); // Determine what string to start at
ArrayList<String> allStrings = new ArrayList<String>(); ArrayList<String> allStrings = new ArrayList<String>();
allStrings.add(header); allStrings.add(header);
@@ -84,15 +82,15 @@ public class SkillGuideCommand implements CommandExecutor {
} }
} }
allStrings.add("Page " + pagenum + " of " + getTotalPageNumber()); allStrings.add("Page " + page + " of " + getTotalPageNumber());
return allStrings; return allStrings;
} }
private ArrayList<String> getGuide(SkillType skillType) { private ArrayList<String> getGuide(SkillType skill) {
ArrayList<String> guide = new ArrayList<String>(); ArrayList<String> guide = new ArrayList<String>();
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString()) + ".Section." + i).split("\n"); String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skill.toString()) + ".Section." + i).split("\n");
if (section[0].startsWith("!")) { if (section[0].startsWith("!")) {
break; break;

View File

@@ -1,11 +1,17 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.smelting.Smelting; import com.gmail.nossr50.skills.smelting.Smelting;
import com.gmail.nossr50.skills.smelting.Smelting.Tier; import com.gmail.nossr50.skills.smelting.Smelting.Tier;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
public class SmeltingCommand extends SkillCommand { public class SmeltingCommand extends SkillCommand {
private String burnTimeModifier; private String burnTimeModifier;
@@ -24,7 +30,7 @@ public class SmeltingCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// FUEL EFFICIENCY // FUEL EFFICIENCY
if (canFuelEfficiency) { if (canFuelEfficiency) {
burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier)); burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier));
@@ -32,21 +38,21 @@ public class SmeltingCommand extends SkillCommand {
// SECOND SMELT // SECOND SMELT
if (canSecondSmelt) { if (canSecondSmelt) {
String[] secondSmeltStrings = calculateAbilityDisplayValues(Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance); String[] secondSmeltStrings = calculateAbilityDisplayValues(skillValue, Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance, isLucky);
secondSmeltChance = secondSmeltStrings[0]; secondSmeltChance = secondSmeltStrings[0];
secondSmeltChanceLucky = secondSmeltStrings[1]; secondSmeltChanceLucky = secondSmeltStrings[1];
} }
// FLUX MINING // FLUX MINING
if (canFluxMine) { if (canFluxMine) {
String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance); String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance, isLucky);
fluxMiningChance = fluxMiningStrings[0]; fluxMiningChance = fluxMiningStrings[0];
fluxMiningChanceLucky = fluxMiningStrings[1]; fluxMiningChanceLucky = fluxMiningStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canFuelEfficiency = Permissions.fuelEfficiency(player); canFuelEfficiency = Permissions.fuelEfficiency(player);
canSecondSmelt = Permissions.doubleDrops(player, skill); canSecondSmelt = Permissions.doubleDrops(player, skill);
canFluxMine = Permissions.fluxMining(player); canFluxMine = Permissions.fluxMining(player);
@@ -54,64 +60,60 @@ public class SmeltingCommand extends SkillCommand {
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canFuelEfficiency) { if (canFuelEfficiency) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.0"), LocaleLoader.getString("Smelting.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.0"), LocaleLoader.getString("Smelting.Effect.1")));
} }
if (canSecondSmelt) { if (canSecondSmelt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.2"), LocaleLoader.getString("Smelting.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.2"), LocaleLoader.getString("Smelting.Effect.3")));
} }
if (canVanillaXPBoost) { if (canVanillaXPBoost) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.4"), LocaleLoader.getString("Smelting.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.4"), LocaleLoader.getString("Smelting.Effect.5")));
} }
if (canFluxMine) { if (canFluxMine) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.6"), LocaleLoader.getString("Smelting.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.6"), LocaleLoader.getString("Smelting.Effect.7")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canFuelEfficiency) { if (canFuelEfficiency) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FuelEfficiency", burnTimeModifier)); messages.add(LocaleLoader.getString("Smelting.Ability.FuelEfficiency", burnTimeModifier));
} }
if (canSecondSmelt) { if (canSecondSmelt) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", secondSmeltChanceLucky) : "")); messages.add(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", secondSmeltChanceLucky) : ""));
} }
if (canVanillaXPBoost) { if (canVanillaXPBoost) {
int unlockLevel = AdvancedConfig.getInstance().getSmeltingRankLevel(Tier.ONE); int unlockLevel = AdvancedConfig.getInstance().getSmeltingRankLevel(Tier.ONE);
if (skillValue < unlockLevel) { if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", mcMMOPlayer.getSmeltingManager().getVanillaXpMultiplier())); messages.add(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", UserManager.getPlayer(player).getSmeltingManager().getVanillaXpMultiplier()));
} }
} }
if (canFluxMine) { if (canFluxMine) {
if (skillValue < Smelting.fluxMiningUnlockLevel) { if (skillValue < Smelting.fluxMiningUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", fluxMiningChanceLucky) : "")); messages.add(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", fluxMiningChanceLucky) : ""));
} }
} }
return messages;
} }
} }

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.swords.Swords; import com.gmail.nossr50.skills.swords.Swords;
@@ -23,10 +28,10 @@ public class SwordsCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// SERRATED STRIKES // SERRATED STRIKES
if (canSerratedStrike) { if (canSerratedStrike) {
String[] serratedStrikesStrings = calculateLengthDisplayValues(); String[] serratedStrikesStrings = calculateLengthDisplayValues(player, skillValue);
serratedStrikesLength = serratedStrikesStrings[0]; serratedStrikesLength = serratedStrikesStrings[0];
serratedStrikesLengthEndurance = serratedStrikesStrings[1]; serratedStrikesLengthEndurance = serratedStrikesStrings[1];
} }
@@ -35,68 +40,64 @@ public class SwordsCommand extends SkillCommand {
if (canBleed) { if (canBleed) {
bleedLength = (skillValue >= Swords.bleedMaxBonusLevel) ? Swords.bleedMaxTicks : Swords.bleedBaseTicks; bleedLength = (skillValue >= Swords.bleedMaxBonusLevel) ? Swords.bleedMaxTicks : Swords.bleedBaseTicks;
String[] bleedStrings = calculateAbilityDisplayValues(Swords.bleedMaxBonusLevel, Swords.bleedMaxChance); String[] bleedStrings = calculateAbilityDisplayValues(skillValue, Swords.bleedMaxBonusLevel, Swords.bleedMaxChance, isLucky);
bleedChance = bleedStrings[0]; bleedChance = bleedStrings[0];
bleedChanceLucky = bleedStrings[1]; bleedChanceLucky = bleedStrings[1];
} }
// COUNTER ATTACK // COUNTER ATTACK
if (canCounter) { if (canCounter) {
String[] counterAttackStrings = calculateAbilityDisplayValues(Swords.counterAttackMaxBonusLevel, Swords.counterAttackMaxChance); String[] counterAttackStrings = calculateAbilityDisplayValues(skillValue, Swords.counterAttackMaxBonusLevel, Swords.counterAttackMaxChance, isLucky);
counterAttackChance = counterAttackStrings[0]; counterAttackChance = counterAttackStrings[0];
counterAttackChanceLucky = counterAttackStrings[1]; counterAttackChanceLucky = counterAttackStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canBleed = Permissions.bleed(player); canBleed = Permissions.bleed(player);
canCounter = Permissions.counterAttack(player); canCounter = Permissions.counterAttack(player);
canSerratedStrike = Permissions.serratedStrikes(player); canSerratedStrike = Permissions.serratedStrikes(player);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canBleed || canCounter || canSerratedStrike; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canCounter) { if (canCounter) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1", percent.format(1.0D / Swords.counterAttackModifier)))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1", percent.format(1.0D / Swords.counterAttackModifier))));
} }
if (canSerratedStrike) { if (canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3", percent.format(1.0D / Swords.serratedStrikesModifier)))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3", percent.format(1.0D / Swords.serratedStrikesModifier))));
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5", Swords.serratedStrikesBleedTicks))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5", Swords.serratedStrikesBleedTicks)));
} }
if (canBleed) { if (canBleed) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canBleed || canCounter || canSerratedStrike; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canCounter) { if (canCounter) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", counterAttackChanceLucky) : "")); messages.add(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", counterAttackChanceLucky) : ""));
} }
if (canBleed) { if (canBleed) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength)); messages.add(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note")); messages.add(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", bleedChanceLucky) : "")); messages.add(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", bleedChanceLucky) : ""));
} }
if (canSerratedStrike) { if (canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : "")); messages.add(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
} }
return messages;
} }
} }

View File

@@ -1,6 +1,10 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -27,16 +31,16 @@ public class TamingCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
if (canGore) { if (canGore) {
String[] goreStrings = calculateAbilityDisplayValues(Taming.goreMaxBonusLevel, Taming.goreMaxChance); String[] goreStrings = calculateAbilityDisplayValues(skillValue, Taming.goreMaxBonusLevel, Taming.goreMaxChance, isLucky);
goreChance = goreStrings[0]; goreChance = goreStrings[0];
goreChanceLucky = goreStrings[1]; goreChanceLucky = goreStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canBeastLore = Permissions.beastLore(player); canBeastLore = Permissions.beastLore(player);
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT); canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
canEnvironmentallyAware = Permissions.environmentallyAware(player); canEnvironmentallyAware = Permissions.environmentallyAware(player);
@@ -49,117 +53,113 @@ public class TamingCommand extends SkillCommand {
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canBeastLore) { if (canBeastLore) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1")));
} }
if (canGore) { if (canGore) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3")));
} }
if (canSharpenedClaws) { if (canSharpenedClaws) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5")));
} }
if (canEnvironmentallyAware) { if (canEnvironmentallyAware) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7")));
} }
if (canThickFur) { if (canThickFur) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9")));
} }
if (canShockProof) { if (canShockProof) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11")));
} }
if (canFastFood) { if (canFastFood) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17")));
} }
if (canHolyHound) { if (canHolyHound) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.18"), LocaleLoader.getString("Taming.Effect.19"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.18"), LocaleLoader.getString("Taming.Effect.19")));
} }
if (canCallWild) { if (canCallWild) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost())); messages.add(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost())); messages.add(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
player.sendMessage(LocaleLoader.getString("Taming.Effect.20", Config.getInstance().getTamingCOTWHorseCost())); messages.add(LocaleLoader.getString("Taming.Effect.20", Config.getInstance().getTamingCOTWHorseCost()));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canFastFood) { if (canFastFood) {
if (skillValue < Taming.fastFoodServiceUnlockLevel) { if (skillValue < Taming.fastFoodServiceUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.4", Taming.fastFoodServiceUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.4", Taming.fastFoodServiceUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", percent.format(Taming.fastFoodServiceActivationChance / 100D)))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", percent.format(Taming.fastFoodServiceActivationChance / 100D))));
} }
} }
if (canEnvironmentallyAware) { if (canEnvironmentallyAware) {
if (skillValue < Taming.environmentallyAwareUnlockLevel) { if (skillValue < Taming.environmentallyAwareUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.0", Taming.environmentallyAwareUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.0", Taming.environmentallyAwareUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1"))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1")));
} }
} }
if (canThickFur) { if (canThickFur) {
if (skillValue < Taming.thickFurUnlockLevel) { if (skillValue < Taming.thickFurUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.1", Taming.thickFurUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.1", Taming.thickFurUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3", Taming.thickFurModifier))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3", Taming.thickFurModifier)));
} }
} }
if (canHolyHound) { if (canHolyHound) {
if (skillValue < Taming.holyHoundUnlockLevel) { if (skillValue < Taming.holyHoundUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.5", Taming.holyHoundUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.5", Taming.holyHoundUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.10"), LocaleLoader.getString("Taming.Ability.Bonus.11"))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.10"), LocaleLoader.getString("Taming.Ability.Bonus.11")));
} }
} }
if (canShockProof) { if (canShockProof) {
if (skillValue < Taming.shockProofUnlockLevel) { if (skillValue < Taming.shockProofUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5", Taming.shockProofModifier))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5", Taming.shockProofModifier)));
} }
} }
if (canSharpenedClaws) { if (canSharpenedClaws) {
if (skillValue < Taming.sharpenedClawsUnlockLevel) { if (skillValue < Taming.sharpenedClawsUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.3", Taming.sharpenedClawsUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.3", Taming.sharpenedClawsUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7", Taming.sharpenedClawsBonusDamage))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7", Taming.sharpenedClawsBonusDamage)));
} }
} }
if (canGore) { if (canGore) {
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", goreChanceLucky) : "")); messages.add(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", goreChanceLucky) : ""));
} }
return messages;
} }
} }

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.unarmed.Unarmed; import com.gmail.nossr50.skills.unarmed.Unarmed;
@@ -27,24 +32,24 @@ public class UnarmedCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// BERSERK // BERSERK
if (canBerserk) { if (canBerserk) {
String[] berserkStrings = calculateLengthDisplayValues(); String[] berserkStrings = calculateLengthDisplayValues(player, skillValue);
berserkLength = berserkStrings[0]; berserkLength = berserkStrings[0];
berserkLengthEndurance = berserkStrings[1]; berserkLengthEndurance = berserkStrings[1];
} }
// DISARM // DISARM
if (canDisarm) { if (canDisarm) {
String[] disarmStrings = calculateAbilityDisplayValues(Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance); String[] disarmStrings = calculateAbilityDisplayValues(skillValue, Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance, isLucky);
disarmChance = disarmStrings[0]; disarmChance = disarmStrings[0];
disarmChanceLucky = disarmStrings[1]; disarmChanceLucky = disarmStrings[1];
} }
// DEFLECT // DEFLECT
if (canDeflect) { if (canDeflect) {
String[] deflectStrings = calculateAbilityDisplayValues(Unarmed.deflectMaxBonusLevel, Unarmed.deflectMaxChance); String[] deflectStrings = calculateAbilityDisplayValues(skillValue, Unarmed.deflectMaxBonusLevel, Unarmed.deflectMaxChance, isLucky);
deflectChance = deflectStrings[0]; deflectChance = deflectStrings[0];
deflectChanceLucky = deflectStrings[1]; deflectChanceLucky = deflectStrings[1];
} }
@@ -56,14 +61,14 @@ public class UnarmedCommand extends SkillCommand {
// IRON GRIP // IRON GRIP
if (canIronGrip) { if (canIronGrip) {
String[] ironGripStrings = calculateAbilityDisplayValues(Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance); String[] ironGripStrings = calculateAbilityDisplayValues(skillValue, Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance, isLucky);
ironGripChance = ironGripStrings[0]; ironGripChance = ironGripStrings[0];
ironGripChanceLucky = ironGripStrings[1]; ironGripChanceLucky = ironGripStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canBerserk = Permissions.berserk(player); canBerserk = Permissions.berserk(player);
canBonusDamage = Permissions.bonusDamage(player, skill); canBonusDamage = Permissions.bonusDamage(player, skill);
canDeflect = Permissions.arrowDeflect(player); canDeflect = Permissions.arrowDeflect(player);
@@ -72,60 +77,56 @@ public class UnarmedCommand extends SkillCommand {
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canBerserk) { if (canBerserk) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1")));
} }
if (canDisarm) { if (canDisarm) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3")));
} }
if (canBonusDamage) { if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5")));
} }
if (canDeflect) { if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7")));
} }
if (canIronGrip) { if (canIronGrip) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.8"), LocaleLoader.getString("Unarmed.Effect.9"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.8"), LocaleLoader.getString("Unarmed.Effect.9")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canBonusDamage) { if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", ironArmBonus))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", ironArmBonus)));
} }
if (canDeflect) { if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", deflectChanceLucky) : "")); messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", deflectChanceLucky) : ""));
} }
if (canDisarm) { if (canDisarm) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", disarmChanceLucky) : "")); messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", disarmChanceLucky) : ""));
} }
if (canIronGrip) { if (canIronGrip) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : "")); messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
} }
if (canBerserk) { if (canBerserk) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : "")); messages.add(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : ""));
} }
return messages;
} }
} }

View File

@@ -1,5 +1,10 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
@@ -21,75 +26,71 @@ public class WoodcuttingCommand extends SkillCommand {
} }
@Override @Override
protected void dataCalculations() { protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// TREE FELLER // TREE FELLER
if (canTreeFell) { if (canTreeFell) {
String[] treeFellerStrings = calculateLengthDisplayValues(); String[] treeFellerStrings = calculateLengthDisplayValues(player, skillValue);
treeFellerLength = treeFellerStrings[0]; treeFellerLength = treeFellerStrings[0];
treeFellerLengthEndurance = treeFellerStrings[1]; treeFellerLengthEndurance = treeFellerStrings[1];
} }
// DOUBLE DROPS // DOUBLE DROPS
if (canDoubleDrop) { if (canDoubleDrop) {
String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance); String[] doubleDropStrings = calculateAbilityDisplayValues(skillValue, Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance, isLucky);
doubleDropChance = doubleDropStrings[0]; doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1]; doubleDropChanceLucky = doubleDropStrings[1];
} }
} }
@Override @Override
protected void permissionsCheck() { protected void permissionsCheck(Player player) {
canTreeFell = Permissions.treeFeller(player); canTreeFell = Permissions.treeFeller(player);
canDoubleDrop = Permissions.doubleDrops(player, skill) && !skill.getDoubleDropsDisabled(); canDoubleDrop = Permissions.doubleDrops(player, skill) && !skill.getDoubleDropsDisabled();
canLeafBlow = Permissions.leafBlower(player); canLeafBlow = Permissions.leafBlower(player);
} }
@Override @Override
protected boolean effectsHeaderPermissions() { protected List<String> effectsDisplay() {
return canDoubleDrop || canLeafBlow || canTreeFell; List<String> messages = new ArrayList<String>();
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canTreeFell) { if (canTreeFell) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1")));
} }
if (canLeafBlow) { if (canLeafBlow) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3")));
} }
if (canDoubleDrop) { if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5"))); messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5")));
} }
return messages;
} }
@Override @Override
protected boolean statsHeaderPermissions() { protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
return canDoubleDrop || canLeafBlow || canTreeFell; List<String> messages = new ArrayList<String>();
}
@Override
protected void statsDisplay() {
if (canLeafBlow) { if (canLeafBlow) {
int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel(); int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
if (skillValue < leafBlowerUnlockLevel) { if (skillValue < leafBlowerUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Woodcutting.Ability.Locked.0", leafBlowerUnlockLevel))); messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Woodcutting.Ability.Locked.0", leafBlowerUnlockLevel)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1"))); messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1")));
} }
} }
if (canDoubleDrop) { if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : "")); messages.add(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
} }
if (canTreeFell) { if (canTreeFell) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", treeFellerLengthEndurance) : "")); messages.add(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", treeFellerLengthEndurance) : ""));
} }
return messages;
} }
} }

View File

@@ -526,6 +526,9 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
reason.add("Skills.Taming.SharpenedClaws.Bonus should be at least 1!"); reason.add("Skills.Taming.SharpenedClaws.Bonus should be at least 1!");
} }
if (getMaxHorseJumpStrength() < 0 || getMaxHorseJumpStrength() > 2) {
reason.add("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength should be between 0 and 2!");
}
/* UNARMED */ /* UNARMED */
if (getDisarmChanceMax() < 1) { if (getDisarmChanceMax() < 1) {
@@ -764,6 +767,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public int getSharpenedClawsUnlock() { return config.getInt("Skills.Taming.SharpenedClaws.UnlockLevel", 750); } public int getSharpenedClawsUnlock() { return config.getInt("Skills.Taming.SharpenedClaws.UnlockLevel", 750); }
public double getSharpenedClawsBonus() { return config.getDouble("Skills.Taming.SharpenedClaws.Bonus", 2.0D); } public double getSharpenedClawsBonus() { return config.getDouble("Skills.Taming.SharpenedClaws.Bonus", 2.0D); }
public double getMaxHorseJumpStrength() { return config.getDouble("Skills.Taming.CallOfTheWild.MaxHorseJumpStrength", 2.0D); }
/* UNARMED */ /* UNARMED */
public double getDisarmChanceMax() { return config.getDouble("Skills.Unarmed.Disarm.ChanceMax", 33.0D); } public double getDisarmChanceMax() { return config.getDouble("Skills.Unarmed.Disarm.ChanceMax", 33.0D); }
public int getDisarmMaxBonusLevel() { return config.getInt("Skills.Unarmed.Disarm.MaxBonusLevel", 1000); } public int getDisarmMaxBonusLevel() { return config.getInt("Skills.Unarmed.Disarm.MaxBonusLevel", 1000); }

View File

@@ -85,12 +85,6 @@ public class Config extends AutoUpdateConfigLoader {
reason.add("Either Board or Print in Scoreboard.Types.Inspect must be true!"); reason.add("Either Board or Print in Scoreboard.Types.Inspect must be true!");
} }
/* Skill.Print setting removed, as I can't think of a good use for it
if (!(getSkillUseChat() || getSkillUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Commands.Skill must be true!");
}
// */
/* Database Purging */ /* Database Purging */
if (getPurgeInterval() < -1) { if (getPurgeInterval() < -1) {
reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!"); reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
@@ -211,8 +205,6 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); } public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); } public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); } public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
public boolean getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", true); }
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); } public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); } public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
@@ -225,6 +217,8 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); } public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
public boolean getLevelUpSoundsEnabled() { return config.getBoolean("General.LevelUp_Sounds", true); }
/* Mob Healthbar */ /* Mob Healthbar */
public MobHealthbarType getMobHealthbarDefault() { public MobHealthbarType getMobHealthbarDefault() {
try { try {
@@ -258,7 +252,6 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getCooldownUseBoard() { return config.getBoolean("Scoreboard.Types.Cooldown.Board", true); } public boolean getCooldownUseBoard() { return config.getBoolean("Scoreboard.Types.Cooldown.Board", true); }
public int getCooldownScoreboardTime() { return config.getInt("Scoreboard.Types.Cooldown.Display_Time", 41); } public int getCooldownScoreboardTime() { return config.getInt("Scoreboard.Types.Cooldown.Display_Time", 41); }
// public boolean getSkillUseChat() { return config.getBoolean("Scoreboard.Types.Skill.Print", false); }
public boolean getSkillUseBoard() { return config.getBoolean("Scoreboard.Types.Skill.Board", true); } public boolean getSkillUseBoard() { return config.getBoolean("Scoreboard.Types.Skill.Board", true); }
public int getSkillScoreboardTime() { return config.getInt("Scoreboard.Types.Skill.Display_Time", 30); } public int getSkillScoreboardTime() { return config.getInt("Scoreboard.Types.Skill.Display_Time", 30); }
public boolean getSkillLevelUpBoard() { return config.getBoolean("Scoreboard.Types.Skill.LevelUp_Board", true); } public boolean getSkillLevelUpBoard() { return config.getBoolean("Scoreboard.Types.Skill.LevelUp_Board", true); }
@@ -273,6 +266,12 @@ public class Config extends AutoUpdateConfigLoader {
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); } public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); } public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); }
/* Backups */
public boolean getBackupsEnabled() { return config.getBoolean("Backups.Enabled", true); }
public boolean getKeepLast24Hours() { return config.getBoolean("Backups.Keep.Last_24_Hours", true); }
public boolean getKeepDailyLastWeek() { return config.getBoolean("Backups.Keep.Daily_Last_Week", true); }
public boolean getKeepWeeklyPastMonth() { return config.getBoolean("Backups.Keep.Weekly_Past_Months", true); }
/* mySQL */ /* mySQL */
public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); } public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); }
public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); } public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); }
@@ -323,6 +322,7 @@ public class Config extends AutoUpdateConfigLoader {
public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); } public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); }
public int getChimaeraWarmup() { return config.getInt("Items.Chimaera_Wing.Warmup", 5); } public int getChimaeraWarmup() { return config.getInt("Items.Chimaera_Wing.Warmup", 5); }
public int getChimaeraRecentlyHurtCooldown() { return config.getInt("Items.Chimaera_Wing.RecentlyHurt_Cooldown", 60); } public int getChimaeraRecentlyHurtCooldown() { return config.getInt("Items.Chimaera_Wing.RecentlyHurt_Cooldown", 60); }
public boolean getChimaeraSoundEnabled() { return config.getBoolean("Items.Chimaera_Wing.Sound_Enabled", true); }
/* Particles */ /* Particles */
public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); } public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); }
@@ -364,8 +364,8 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", true); } public boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", true); }
public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); } public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.getConfigString()); } public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.getConfigString()); } public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
/* Durability Settings */ /* Durability Settings */
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); } public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); }
@@ -406,8 +406,10 @@ public class Config extends AutoUpdateConfigLoader {
/* Repair */ /* Repair */
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); } public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
public boolean getRepairAnvilPlaceSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Placed_Sounds", true); }
public boolean getRepairAnvilUseSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Use_Sounds", true); }
public Material getRepairAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Anvil_Material", "IRON_BLOCK")); } public Material getRepairAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Anvil_Material", "IRON_BLOCK")); }
public Material getSalvageAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Salvage_Anvil_ID", "GOLD_BLOCK")); } public Material getSalvageAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Salvage_Anvil_Material", "GOLD_BLOCK")); }
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); } public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); } public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); } public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); }
@@ -427,11 +429,12 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); } public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); } public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); } public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
/* AFK Leveling */ /* AFK Leveling */
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); } public boolean getAcrobaticsPreventAFK() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
public int getAcrobaticsAFKMaxTries() { return config.getInt("Skills.Acrobatics.Max_Tries_At_Same_Location", 3); } public int getAcrobaticsAFKMaxTries() { return config.getInt("Skills.Acrobatics.Max_Tries_At_Same_Location", 3); }
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); } public boolean getHerbalismPreventAFK() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
/* Level Caps */ /* Level Caps */
public int getPowerLevelCap() { public int getPowerLevelCap() {

View File

@@ -102,6 +102,10 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
reason.add("Experience.Fishing.Base should be greater than 0!"); reason.add("Experience.Fishing.Base should be greater than 0!");
} }
if (getFishingShakeXP() <= 0) {
reason.add("Experience.Fishing.Shake should be greater than 0!");
}
/* Repair */ /* Repair */
if (getRepairXPBase() <= 0) { if (getRepairXPBase() <= 0) {
reason.add("Experience.Repair.Base should be greater than 0!"); reason.add("Experience.Repair.Base should be greater than 0!");
@@ -197,6 +201,7 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
/* Fishing */ /* Fishing */
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); } public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); }
/* Repair */ /* Repair */
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); } public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }

View File

@@ -111,7 +111,7 @@ public class CustomArmorConfig extends ConfigLoader {
durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70); durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
} }
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, repairQuantity, 0, durability, RepairItemType.ARMOR, RepairMaterialType.OTHER, 1.0)); repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, 0, repairQuantity, durability, RepairItemType.ARMOR, RepairMaterialType.OTHER, 1.0));
} }
materialList.add(armorMaterial); materialList.add(armorMaterial);

View File

@@ -92,9 +92,11 @@ public class CustomBlockConfig extends ConfigLoader {
} }
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain"); int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
int smeltingXp = 0;
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) { if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
customOres.add(blockMaterialData); customOres.add(blockMaterialData);
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
} }
else if (skillType.equals("Woodcutting")) { else if (skillType.equals("Woodcutting")) {
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) { if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
@@ -106,7 +108,7 @@ public class CustomBlockConfig extends ConfigLoader {
} }
} }
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"))); customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
} }
} }

View File

@@ -68,6 +68,7 @@ public class TreasureConfig extends ConfigLoader {
private TreasureConfig() { private TreasureConfig() {
super("treasures.yml"); super("treasures.yml");
loadKeys(); loadKeys();
validate();
} }
public static TreasureConfig getInstance() { public static TreasureConfig getInstance() {
@@ -78,6 +79,43 @@ public class TreasureConfig extends ConfigLoader {
return instance; return instance;
} }
@Override
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<String>();
for (String tier : config.getConfigurationSection("Enchantment_Drop_Rates").getKeys(false)) {
double totalEnchantDropRate = 0;
double totalItemDropRate = 0;
for (Rarity rarity : Rarity.values()) {
double enchantDropRate = config.getDouble("Enchantment_Drop_Rates." + tier + "." + rarity.toString());
double itemDropRate = config.getDouble("Item_Drop_Rates." + tier + "." + rarity.toString());
if ((enchantDropRate < 0.0 || enchantDropRate > 100.0) && rarity != Rarity.TRAP && rarity != Rarity.RECORD) {
reason.add("The enchant drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
}
if (itemDropRate < 0.0 || itemDropRate > 100.0) {
reason.add("The item drop rate for " + tier + " items that are " + rarity.toString() + "should be between 0.0 and 100.0!");
}
totalEnchantDropRate += enchantDropRate;
totalItemDropRate += itemDropRate;
}
if (totalEnchantDropRate < 0 || totalEnchantDropRate > 100.0) {
reason.add("The total enchant drop rate for " + tier + " should be between 0.0 and 100.0!");
}
if (totalItemDropRate < 0 || totalItemDropRate > 100.0) {
reason.add("The total item drop rate for " + tier + " should be between 0.0 and 100.0!");
}
}
return noErrorsInConfig(reason);
}
@Override @Override
protected void loadKeys() { protected void loadKeys() {
if (config.getConfigurationSection("Treasures") != null) { if (config.getConfigurationSection("Treasures") != null) {

View File

@@ -251,17 +251,17 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
writer.append(":"); writer.append(":");
writer.append(profile.getSkillLevel(SkillType.TAMING)).append(":"); writer.append(profile.getSkillLevel(SkillType.TAMING)).append(":");
writer.append(profile.getSkillXpLevel(SkillType.TAMING)).append(":"); writer.append(profile.getSkillXpLevel(SkillType.TAMING)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.BERSERK)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.BERSERK)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.GIGA_DRILL_BREAKER)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.TREE_FELLER)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.TREE_FELLER)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.GREEN_TERRA)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.GREEN_TERRA)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.SERRATED_STRIKES)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.SERRATED_STRIKES)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.SKULL_SPLITTER)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.SKULL_SPLITTER)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.SUPER_BREAKER)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.SUPER_BREAKER)).append(":");
writer.append(":"); writer.append(":");
writer.append(profile.getSkillLevel(SkillType.FISHING)).append(":"); writer.append(profile.getSkillLevel(SkillType.FISHING)).append(":");
writer.append(profile.getSkillXpLevel(SkillType.FISHING)).append(":"); writer.append(profile.getSkillXpLevel(SkillType.FISHING)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.BLAST_MINING)).append(":"); writer.append((int) profile.getAbilityDATS(AbilityType.BLAST_MINING)).append(":");
writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":"); writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":");
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType(); MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":"); writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":");

View File

@@ -139,14 +139,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ ", herbalism = ?, excavation = ?, swords = ?" + ", herbalism = ?, excavation = ?, swords = ?"
+ ", axes = ?, blast_mining = ? WHERE user_id = ?", + ", axes = ?, blast_mining = ? WHERE user_id = ?",
userId, userId,
profile.getSkillDATS(AbilityType.SUPER_BREAKER), profile.getAbilityDATS(AbilityType.SUPER_BREAKER),
profile.getSkillDATS(AbilityType.TREE_FELLER), profile.getAbilityDATS(AbilityType.TREE_FELLER),
profile.getSkillDATS(AbilityType.BERSERK), profile.getAbilityDATS(AbilityType.BERSERK),
profile.getSkillDATS(AbilityType.GREEN_TERRA), profile.getAbilityDATS(AbilityType.GREEN_TERRA),
profile.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER), profile.getAbilityDATS(AbilityType.GIGA_DRILL_BREAKER),
profile.getSkillDATS(AbilityType.SERRATED_STRIKES), profile.getAbilityDATS(AbilityType.SERRATED_STRIKES),
profile.getSkillDATS(AbilityType.SKULL_SPLITTER), profile.getAbilityDATS(AbilityType.SKULL_SPLITTER),
profile.getSkillDATS(AbilityType.BLAST_MINING)); profile.getAbilityDATS(AbilityType.BLAST_MINING));
success &= saveIntegers( success &= saveIntegers(
"UPDATE " + tablePrefix + "skills SET " "UPDATE " + tablePrefix + "skills SET "
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?" + " taming = ?, mining = ?, repair = ?, woodcutting = ?"

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes.chat; package com.gmail.nossr50.datatypes.chat;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
public enum ChatMode { public enum ChatMode {
@@ -15,51 +14,6 @@ public enum ChatMode {
this.disabledMessage = disabledMessage; this.disabledMessage = disabledMessage;
} }
public boolean isEnabled(McMMOPlayer mcMMOPlayer) {
switch (this) {
case ADMIN:
return mcMMOPlayer.getAdminChatMode();
case PARTY:
return mcMMOPlayer.getPartyChatMode();
default:
return false;
}
}
public void disable(McMMOPlayer mcMMOPlayer) {
switch (this) {
case ADMIN:
mcMMOPlayer.setAdminChat(false);
return;
case PARTY:
mcMMOPlayer.setPartyChat(false);
return;
default:
return;
}
}
public void enable(McMMOPlayer mcMMOPlayer) {
switch (this) {
case ADMIN:
mcMMOPlayer.setAdminChat(true);
mcMMOPlayer.setPartyChat(false);
return;
case PARTY:
mcMMOPlayer.setPartyChat(true);
mcMMOPlayer.setAdminChat(false);
return;
default:
return;
}
}
public String getEnabledMessage() { public String getEnabledMessage() {
return enabledMessage; return enabledMessage;
} }

View File

@@ -3,10 +3,12 @@ package com.gmail.nossr50.datatypes.mods;
public class CustomBlock { public class CustomBlock {
private int xpGain; private int xpGain;
private boolean canDoubleDrop; private boolean canDoubleDrop;
private int smeltingXpGain;
public CustomBlock(int xpGain, boolean canDoubleDrop) { public CustomBlock(int xpGain, boolean canDoubleDrop, int smeltingXpGain) {
this.xpGain = xpGain; this.xpGain = xpGain;
this.canDoubleDrop = canDoubleDrop; this.canDoubleDrop = canDoubleDrop;
this.smeltingXpGain = smeltingXpGain;
} }
public int getXpGain() { public int getXpGain() {
@@ -16,4 +18,8 @@ public class CustomBlock {
public boolean isDoubleDropEnabled() { public boolean isDoubleDropEnabled() {
return canDoubleDrop; return canDoubleDrop;
} }
public int getSmeltingXpGain() {
return smeltingXpGain;
}
} }

View File

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

View File

@@ -6,7 +6,6 @@ import java.util.Set;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -17,8 +16,10 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.mods.CustomTool; import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.datatypes.skills.ToolType;
@@ -36,7 +37,6 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.swords.SwordsManager;
@@ -52,42 +52,27 @@ import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
import org.apache.commons.lang.Validate;
public class McMMOPlayer { public class McMMOPlayer {
private Player player; private Player player;
private PlayerProfile profile; private PlayerProfile profile;
/*
* Since SkillManager isn't a "polymorphic type" we may prefer to have one field for each of our
* class inheriting from SkillManager. This would also prevent the need for casting.
* However, by using the map and the loop in the constructor
* we make sure that all class inheriting from SkillManager are instanced.
* Which solution is better, I let you decide. - bm01
*/
private final Map<SkillType, SkillManager> skillManagers = new HashMap<SkillType, SkillManager>(); private final Map<SkillType, SkillManager> skillManagers = new HashMap<SkillType, SkillManager>();
private Party party; private Party party;
private Party invite; private Party invite;
private int itemShareModifier; private int itemShareModifier;
private Player ptpRequest; private PartyTeleportRecord ptpRecord;
private boolean ptpEnabled = true;
private boolean ptpConfirmRequired = Config.getInstance().getPTPCommandConfirmRequired();
private long ptpTimeout;
private int ptpLastUse;
private boolean partyChatMode; private boolean partyChatMode;
private boolean adminChatMode; private boolean adminChatMode;
private boolean displaySkillNotifications = true; private boolean displaySkillNotifications = true;
private boolean abilityUse = true; private boolean abilityUse = true;
private boolean placedRepairAnvil;
private int lastRepairClick;
private boolean placedSalvageAnvil;
private int lastSalvageClick;
private boolean godMode; private boolean godMode;
private Location hookLocation;
private final Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>(); private final Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>(); private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
@@ -109,6 +94,7 @@ public class McMMOPlayer {
this.player = player; this.player = player;
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, true); profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, true);
party = PartyManager.getPlayerParty(playerName); party = PartyManager.getPlayerParty(playerName);
ptpRecord = new PartyTeleportRecord();
/* /*
* I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually), * I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually),
@@ -436,68 +422,6 @@ public class McMMOPlayer {
databaseATS = System.currentTimeMillis(); databaseATS = System.currentTimeMillis();
} }
/*
* Repair Anvil Placement
*/
public boolean getPlacedAnvil(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
return placedRepairAnvil;
}
if (anvilType == Repair.salvageAnvilMaterial) {
return placedSalvageAnvil;
}
return true;
}
public void togglePlacedAnvil(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
placedRepairAnvil = !placedRepairAnvil;
}
if (anvilType == Repair.salvageAnvilMaterial) {
placedSalvageAnvil = !placedSalvageAnvil;
}
}
/*
* Repair Anvil Usage
*/
public int getLastAnvilUse(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
return lastRepairClick;
}
if (anvilType == Repair.salvageAnvilMaterial) {
return lastSalvageClick;
}
return 0;
}
public void setLastAnvilUse(Material anvilType, int value) {
if (anvilType == Repair.repairAnvilMaterial) {
lastRepairClick = value;
}
if (anvilType == Repair.salvageAnvilMaterial) {
lastSalvageClick = value;
}
}
public void actualizeLastAnvilUse(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
lastRepairClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
if (anvilType == Repair.salvageAnvilMaterial) {
lastSalvageClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
}
/* /*
* God Mode * God Mode
*/ */
@@ -510,18 +434,6 @@ public class McMMOPlayer {
godMode = !godMode; godMode = !godMode;
} }
/*
* Fishing: Master Angler
*/
public Location getHookLocation() {
return hookLocation;
}
public void setHookLocation(Location hookLocation) {
this.hookLocation = hookLocation;
}
/* /*
* Skill notifications * Skill notifications
*/ */
@@ -543,8 +455,8 @@ public class McMMOPlayer {
int powerLevel = 0; int powerLevel = 0;
for (SkillType type : SkillType.NON_CHILD_SKILLS) { for (SkillType type : SkillType.NON_CHILD_SKILLS) {
if (Permissions.skillEnabled(player, type)) { if (type.getPermissions(player)) {
powerLevel += profile.getSkillLevel(type); powerLevel += getSkillLevel(type);
} }
} }
@@ -554,20 +466,23 @@ 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 * 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 skill Skill being used
* @param xp Experience amount to process * @param xp Experience amount to process
*/ */
public void beginXpGain(SkillType skillType, float xp) { public void beginXpGain(SkillType skill, float xp) {
if (xp == 0) { Validate.isTrue(xp >= 0.0, "XP gained should be greater than or equal to zero.");
if (xp <= 0.0) {
return; return;
} }
if (skillType.isChildSkill()) { if (skill.isChildSkill()) {
Set<SkillType> parentSkills = FamilyTree.getParents(skillType); Set<SkillType> parentSkills = FamilyTree.getParents(skill);
float splitXp = xp / parentSkills.size();
for (SkillType parentSkill : parentSkills) { for (SkillType parentSkill : parentSkills) {
if (Permissions.skillEnabled(player, parentSkill)) { if (parentSkill.getPermissions(player)) {
beginXpGain(parentSkill, xp / parentSkills.size()); beginXpGain(parentSkill, splitXp);
} }
} }
@@ -575,23 +490,21 @@ public class McMMOPlayer {
} }
// Return if the experience has been shared // Return if the experience has been shared
if (party != null && ShareHandler.handleXpShare(xp, this, skillType)) { if (party != null && ShareHandler.handleXpShare(xp, this, skill)) {
return; return;
} }
beginUnsharedXpGain(skillType, xp); beginUnsharedXpGain(skill, xp);
} }
/** /**
* Begins an experience gain. The amount will be affected by skill modifiers, global rate and perks * Begins an experience gain. The amount will be affected by skill modifiers, global rate and perks
* *
* @param skillType Skill being used * @param skill Skill being used
* @param xp Experience amount to process * @param xp Experience amount to process
*/ */
public void beginUnsharedXpGain(SkillType skillType, float xp) { public void beginUnsharedXpGain(SkillType skill, float xp) {
xp = modifyXpGain(skillType, xp); applyXpGain(skill, modifyXpGain(skill, xp));
applyXpGain(skillType, xp);
} }
/** /**
@@ -601,7 +514,7 @@ public class McMMOPlayer {
* @param xp Experience amount to add * @param xp Experience amount to add
*/ */
public void applyXpGain(SkillType skillType, float xp) { public void applyXpGain(SkillType skillType, float xp) {
if (!Permissions.skillEnabled(player, skillType)) { if (!skillType.getPermissions(player)) {
return; return;
} }
@@ -615,7 +528,7 @@ public class McMMOPlayer {
return; return;
} }
if (!EventUtils.handleXpGainEvent(player, skillType, xp)) { if (!EventUtils.handleXpChangeEvent(player, skillType, xp, true)) {
return; return;
} }
@@ -629,31 +542,32 @@ public class McMMOPlayer {
* @param skillType The skill to check * @param skillType The skill to check
*/ */
private void checkXp(SkillType skillType) { private void checkXp(SkillType skillType) {
if (getSkillXpLevelRaw(skillType) < getXpToLevel(skillType)) {
return;
}
int levelsGained = 0; int levelsGained = 0;
float xpRemoved = 0; float xpRemoved = 0;
if (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) { while (getSkillXpLevelRaw(skillType) >= getXpToLevel(skillType)) {
while (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) { if (hasReachedLevelCap(skillType)) {
if ((skillType.getMaxLevel() >= profile.getSkillLevel(skillType) + 1) && (Config.getInstance().getPowerLevelCap() >= getPowerLevel() + 1)) { setSkillXpLevel(skillType, 0);
int xp = profile.getXpToLevel(skillType); break;
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)) { xpRemoved += profile.levelUp(skillType);
return; levelsGained++;
}
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)));
} }
if (!EventUtils.handleLevelChangeEvent(player, skillType, levelsGained, xpRemoved, true)) {
return;
}
if (Config.getInstance().getLevelUpSoundsEnabled()) {
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
}
player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, getSkillLevel(skillType)));
} }
/* /*
@@ -708,52 +622,8 @@ public class McMMOPlayer {
invite = null; invite = null;
} }
public boolean getPtpEnabled() { public PartyTeleportRecord getPartyTeleportRecord() {
return ptpEnabled; return ptpRecord;
}
public void togglePtpUse() {
ptpEnabled = !ptpEnabled;
}
public Player getPtpRequest() {
return ptpRequest;
}
public void setPtpRequest(Player ptpRequest) {
this.ptpRequest = ptpRequest;
}
public boolean hasPtpRequest() {
return (ptpRequest != null);
}
public void removePtpRequest() {
ptpRequest = null;
}
public boolean getPtpConfirmRequired() {
return ptpConfirmRequired;
}
public void togglePtpConfirmRequired() {
ptpConfirmRequired = !ptpConfirmRequired;
}
public int getPtpLastUse() {
return ptpLastUse;
}
public void actualizePtpLastUse() {
ptpLastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
public long getPtpTimeout() {
return ptpTimeout;
}
public void actualizePtpTimeout() {
ptpTimeout = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
} }
public int getItemShareModifier() { public int getItemShareModifier() {
@@ -772,28 +642,67 @@ public class McMMOPlayer {
* Chat modes * Chat modes
*/ */
public boolean getAdminChatMode() { public boolean isChatEnabled(ChatMode mode) {
return adminChatMode; switch (mode) {
case ADMIN:
return adminChatMode;
case PARTY:
return partyChatMode;
default:
return false;
}
} }
public void setAdminChat(boolean enabled) { public void disableChat(ChatMode mode) {
adminChatMode = enabled; switch (mode) {
case ADMIN:
adminChatMode = false;
return;
case PARTY:
partyChatMode = false;
return;
default:
return;
}
} }
public void toggleAdminChat() { public void enableChat(ChatMode mode) {
adminChatMode = !adminChatMode; switch (mode) {
case ADMIN:
adminChatMode = true;
partyChatMode = false;
return;
case PARTY:
partyChatMode = true;
adminChatMode = false;
return;
default:
return;
}
} }
public boolean getPartyChatMode() { public void toggleChat(ChatMode mode) {
return partyChatMode; switch (mode) {
} case ADMIN:
adminChatMode = !adminChatMode;
partyChatMode = adminChatMode ? false : partyChatMode;
return;
public void setPartyChat(boolean enabled) { case PARTY:
partyChatMode = enabled; partyChatMode = !partyChatMode;
} adminChatMode = partyChatMode ? false : adminChatMode;
return;
public void togglePartyChat() { default:
partyChatMode = !partyChatMode; return;
}
} }
public boolean isUsingUnarmed() { public boolean isUsingUnarmed() {
@@ -808,7 +717,7 @@ public class McMMOPlayer {
* @return Modified experience * @return Modified experience
*/ */
private float modifyXpGain(SkillType skillType, float xp) { private float modifyXpGain(SkillType skillType, float xp) {
if (player.getGameMode() == GameMode.CREATIVE || (skillType.getMaxLevel() <= profile.getSkillLevel(skillType)) || (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) { if (player.getGameMode() == GameMode.CREATIVE || (skillType.getMaxLevel() <= getSkillLevel(skillType)) || (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) {
return 0; return 0;
} }
@@ -848,13 +757,17 @@ public class McMMOPlayer {
ToolType tool = skill.getTool(); ToolType tool = skill.getTool();
AbilityType ability = skill.getAbility(); AbilityType ability = skill.getAbility();
if (!getToolPreparationMode(tool) || !ability.getPermissions(player)) {
return;
}
setToolPreparationMode(tool, false); setToolPreparationMode(tool, false);
if (getAbilityMode(ability)) { if (getAbilityMode(ability)) {
return; return;
} }
int timeRemaining = SkillUtils.calculateTimeLeft(ability, profile, player); int timeRemaining = calculateTimeRemaining(ability);
if (timeRemaining > 0) { if (timeRemaining > 0) {
/* /*
@@ -868,11 +781,11 @@ public class McMMOPlayer {
return; return;
} }
if (EventUtils.callPlayerAbilityActivateEvent(player, skill).isCancelled()) { if (!EventUtils.handlePlayerAbilityActivateEvent(player, ability)) {
return; return;
} }
int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxLength()); int ticks = PerksUtils.handleActivationPerks(player, 2 + (getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxLength());
// Notify people that ability has been activated // Notify people that ability has been activated
ParticleEffectUtils.playAbilityEnabledEffect(player); ParticleEffectUtils.playAbilityEnabledEffect(player);
@@ -884,7 +797,7 @@ public class McMMOPlayer {
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player)); SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player));
// Enable the ability // Enable the ability
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR)); profile.setAbilityDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
setAbilityMode(ability, true); setAbilityMode(ability, true);
if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) { if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) {
@@ -924,7 +837,7 @@ public class McMMOPlayer {
*/ */
if (ability.getPermissions(player) && tool.inHand(inHand) && !getToolPreparationMode(tool)) { if (ability.getPermissions(player) && tool.inHand(inHand) && !getToolPreparationMode(tool)) {
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) { if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
int timeRemaining = SkillUtils.calculateTimeLeft(ability, profile, player); int timeRemaining = calculateTimeRemaining(ability);
if (!getAbilityMode(ability) && timeRemaining > 0) { if (!getAbilityMode(ability) && timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining)); player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
@@ -941,4 +854,67 @@ public class McMMOPlayer {
new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR); new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
} }
} }
/**
* Calculate the time remaining until the ability's cooldown expires.
*
* @param ability AbilityType whose cooldown to check
*
* @return the number of seconds remaining before the cooldown expires
*/
public int calculateTimeRemaining(AbilityType ability) {
long deactivatedTimestamp = profile.getAbilityDATS(ability) * Misc.TIME_CONVERSION_FACTOR;
return (int) (((deactivatedTimestamp + (PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
}
private boolean hasReachedLevelCap(SkillType skill) {
return (skill.getMaxLevel() < getSkillLevel(skill) + 1) || (Config.getInstance().getPowerLevelCap() < getPowerLevel() + 1);
}
/*
* These functions are wrapped from PlayerProfile so that we don't always have to store it alongside the McMMOPlayer object.
*/
public int getSkillLevel(SkillType skill) {
return profile.getSkillLevel(skill);
}
public float getSkillXpLevelRaw(SkillType skill) {
return profile.getSkillXpLevelRaw(skill);
}
public int getSkillXpLevel(SkillType skill) {
return profile.getSkillXpLevel(skill);
}
public void setSkillXpLevel(SkillType skill, float xpLevel) {
profile.setSkillXpLevel(skill, xpLevel);
}
public int getXpToLevel(SkillType skill) {
return profile.getXpToLevel(skill);
}
public void removeXp(SkillType skill, int xp) {
profile.removeXp(skill, xp);
}
public void modifySkill(SkillType skill, int level) {
profile.modifySkill(skill, level);
}
public void addLevels(SkillType skill, int levels) {
profile.addLevels(skill, levels);
}
public void addXp(SkillType skill, float xp) {
profile.addXp(skill, xp);
}
public void setAbilityDATS(AbilityType ability, long DATS) {
profile.setAbilityDATS(ability, DATS);
}
public void resetCooldowns() {
profile.resetCooldowns();
}
} }

View File

@@ -4,8 +4,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.bukkit.scoreboard.Scoreboard;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
@@ -23,20 +21,19 @@ public class PlayerProfile {
/* HUDs */ /* HUDs */
private MobHealthbarType mobHealthbarType; private MobHealthbarType mobHealthbarType;
private Scoreboard playerStatsScoreboard;
/* Skill Data */ /* Skill Data */
private final Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level private final Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
private final Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP private final Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
private final Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown private final Map<AbilityType, Integer> abilityDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
public PlayerProfile(String playerName) { public PlayerProfile(String playerName) {
this.playerName = playerName; this.playerName = playerName;
mobHealthbarType = Config.getInstance().getMobHealthbarDefault(); mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
for (AbilityType abilityType : AbilityType.values()) { for (AbilityType abilityType : AbilityType.NORMAL_ABILITIES) {
skillsDATS.put(abilityType, 0); abilityDATS.put(abilityType, 0);
} }
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) { for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
@@ -50,17 +47,13 @@ public class PlayerProfile {
this.loaded = isLoaded; this.loaded = isLoaded;
} }
/** public PlayerProfile(String playerName, Map<SkillType, Integer> levelData, Map<SkillType, Float> xpData, Map<AbilityType, Integer> cooldownData, MobHealthbarType mobHealthbarType) {
* Calling this constructor is considered loading the profile. this.playerName = playerName;
*/
public PlayerProfile(String playerName, Map<SkillType, Integer> argSkills, Map<SkillType, Float> argSkillsXp, Map<AbilityType, Integer> argSkillsDats, MobHealthbarType mobHealthbarType) {
this(playerName);
this.mobHealthbarType = mobHealthbarType; this.mobHealthbarType = mobHealthbarType;
this.skills.putAll(argSkills); skills.putAll(levelData);
this.skillsXp.putAll(argSkillsXp); skillsXp.putAll(xpData);
this.skillsDATS.putAll(argSkillsDats); abilityDATS.putAll(cooldownData);
loaded = true; loaded = true;
} }
@@ -71,6 +64,7 @@ public class PlayerProfile {
} }
changed = !mcMMO.getDatabaseManager().saveUser(this); changed = !mcMMO.getDatabaseManager().saveUser(this);
if (changed) { if (changed) {
mcMMO.p.getLogger().warning("PlayerProfile for " + playerName + " failed to save"); mcMMO.p.getLogger().warning("PlayerProfile for " + playerName + " failed to save");
} }
@@ -96,54 +90,40 @@ public class PlayerProfile {
this.mobHealthbarType = mobHealthbarType; this.mobHealthbarType = mobHealthbarType;
} }
/*
* Scoreboards
*/
public Scoreboard getPlayerStatsScoreboard() {
return playerStatsScoreboard;
}
public void setPlayerStatsScoreboard(Scoreboard statsScoreboard) {
this.playerStatsScoreboard = statsScoreboard;
}
/* /*
* Cooldowns * Cooldowns
*/ */
/** /**
* Get the current DATS of a skill. * Get the current deactivation timestamp of an ability.
* *
* @param abilityType Ability to get the DATS for * @param ability The {@link AbilityType} to get the DATS for
* @return the DATS for the ability * @return the deactivation timestamp for the ability
*/ */
public long getSkillDATS(AbilityType abilityType) { public long getAbilityDATS(AbilityType ability) {
return skillsDATS.get(abilityType); return abilityDATS.get(ability);
} }
/** /**
* Set the current DATS of a skill. * Set the current deactivation timestamp of an ability.
* *
* @param abilityType Ability to set the DATS for * @param ability The {@link AbilityType} to set the DATS for
* @param DATS the DATS of the ability * @param DATS the DATS of the ability
*/ */
public void setSkillDATS(AbilityType abilityType, long DATS) { protected void setAbilityDATS(AbilityType ability, long DATS) {
int wearsOff = (int) (DATS * .001D);
changed = true; changed = true;
skillsDATS.put(abilityType, wearsOff); abilityDATS.put(ability, (int) (DATS * .001D));
} }
/** /**
* Reset all skill cooldowns. * Reset all ability cooldowns.
*/ */
public void resetCooldowns() { protected void resetCooldowns() {
changed = true; changed = true;
for (AbilityType ability : skillsDATS.keySet()) { for (AbilityType ability : abilityDATS.keySet()) {
skillsDATS.put(ability, 0); abilityDATS.put(ability, 0);
} }
} }
@@ -151,96 +131,102 @@ public class PlayerProfile {
* Xp Functions * Xp Functions
*/ */
public int getSkillLevel(SkillType skillType) { public int getSkillLevel(SkillType skill) {
return skillType.isChildSkill() ? getChildSkillLevel(skillType) : skills.get(skillType); return skill.isChildSkill() ? getChildSkillLevel(skill) : skills.get(skill);
} }
public float getSkillXpLevelRaw(SkillType skillType) { public float getSkillXpLevelRaw(SkillType skill) {
return skillsXp.get(skillType); return skillsXp.get(skill);
} }
public int getSkillXpLevel(SkillType skillType) { public int getSkillXpLevel(SkillType skill) {
return (int) Math.floor(getSkillXpLevelRaw(skillType)); return (int) Math.floor(getSkillXpLevelRaw(skill));
} }
public void setSkillXpLevel(SkillType skillType, float newValue) { public void setSkillXpLevel(SkillType skill, float xpLevel) {
if (skillType.isChildSkill()) { if (skill.isChildSkill()) {
return; return;
} }
changed = true; changed = true;
skillsXp.put(skillType, newValue); skillsXp.put(skill, xpLevel);
} }
public void skillUp(SkillType skillType, int newValue) { protected float levelUp(SkillType skill) {
skills.put(skillType, skills.get(skillType) + newValue); float xpRemoved = getXpToLevel(skill);
changed = true;
skills.put(skill, skills.get(skill) + 1);
skillsXp.put(skill, skillsXp.get(skill) - xpRemoved);
return xpRemoved;
} }
/** /**
* Remove Xp from a skill. * Remove Xp from a skill.
* *
* @param skillType Type of skill to modify * @param skill 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) { public void removeXp(SkillType skill, int xp) {
if (skillType.isChildSkill()) { if (skill.isChildSkill()) {
return; return;
} }
changed = true; changed = true;
skillsXp.put(skillType, skillsXp.get(skillType) - xp); skillsXp.put(skill, skillsXp.get(skill) - xp);
} }
/** /**
* Modify a skill level. * Modify a skill level.
* *
* @param skillType Type of skill to modify * @param skill Type of skill to modify
* @param newValue New level value for the skill * @param level New level value for the skill
*/ */
public void modifySkill(SkillType skillType, int newValue) { public void modifySkill(SkillType skill, int level) {
if (skillType.isChildSkill()) { if (skill.isChildSkill()) {
return; return;
} }
changed = true; changed = true;
skills.put(skillType, newValue); skills.put(skill, level);
skillsXp.put(skillType, 0F); skillsXp.put(skill, 0F);
} }
/** /**
* Add levels to a skill. * Add levels to a skill.
* *
* @param skillType Type of skill to add levels to * @param skill 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) { public void addLevels(SkillType skill, int levels) {
if (skillType.isChildSkill()) { modifySkill(skill, skills.get(skill) + levels);
return;
}
changed = true;
skills.put(skillType, skills.get(skillType) + levels);
skillsXp.put(skillType, 0F);
} }
/** /**
* Add Experience to a skill. * Add Experience to a skill.
* *
* @param skillType Type of skill to add experience to * @param skill Type of skill to add experience to
* @param experience Number of experience to add * @param xp Number of experience to add
*/ */
public void addExperience(SkillType skillType, int experience) { public void addXp(SkillType skill, float xp) {
if (skillType.isChildSkill()) {
return;
}
changed = true; changed = true;
skillsXp.put(skillType, skillsXp.get(skillType) + experience); if (skill.isChildSkill()) {
Set<SkillType> parentSkills = FamilyTree.getParents(skill);
float dividedXP = (xp / parentSkills.size());
for (SkillType parentSkill : parentSkills) {
skillsXp.put(parentSkill, skillsXp.get(parentSkill) + dividedXP);
}
}
else {
skillsXp.put(skill, skillsXp.get(skill) + xp);
}
} }
/** /**

View File

@@ -13,11 +13,11 @@ import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils; import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public enum AbilityType { public enum AbilityType {
BERSERK( BERSERK(
"Unarmed.Skills.Berserk.Name",
"Unarmed.Skills.Berserk.On", "Unarmed.Skills.Berserk.On",
"Unarmed.Skills.Berserk.Off", "Unarmed.Skills.Berserk.Off",
"Unarmed.Skills.Berserk.Other.On", "Unarmed.Skills.Berserk.Other.On",
@@ -25,7 +25,6 @@ public enum AbilityType {
"Unarmed.Skills.Berserk.Other.Off"), "Unarmed.Skills.Berserk.Other.Off"),
SUPER_BREAKER( SUPER_BREAKER(
"Mining.Skills.SuperBreaker.Name",
"Mining.Skills.SuperBreaker.On", "Mining.Skills.SuperBreaker.On",
"Mining.Skills.SuperBreaker.Off", "Mining.Skills.SuperBreaker.Off",
"Mining.Skills.SuperBreaker.Other.On", "Mining.Skills.SuperBreaker.Other.On",
@@ -33,7 +32,6 @@ public enum AbilityType {
"Mining.Skills.SuperBreaker.Other.Off"), "Mining.Skills.SuperBreaker.Other.Off"),
GIGA_DRILL_BREAKER( GIGA_DRILL_BREAKER(
"Excavation.Skills.GigaDrillBreaker.Name",
"Excavation.Skills.GigaDrillBreaker.On", "Excavation.Skills.GigaDrillBreaker.On",
"Excavation.Skills.GigaDrillBreaker.Off", "Excavation.Skills.GigaDrillBreaker.Off",
"Excavation.Skills.GigaDrillBreaker.Other.On", "Excavation.Skills.GigaDrillBreaker.Other.On",
@@ -41,7 +39,6 @@ public enum AbilityType {
"Excavation.Skills.GigaDrillBreaker.Other.Off"), "Excavation.Skills.GigaDrillBreaker.Other.Off"),
GREEN_TERRA( GREEN_TERRA(
"Herbalism.Skills.GTe.Name",
"Herbalism.Skills.GTe.On", "Herbalism.Skills.GTe.On",
"Herbalism.Skills.GTe.Off", "Herbalism.Skills.GTe.Off",
"Herbalism.Skills.GTe.Other.On", "Herbalism.Skills.GTe.Other.On",
@@ -49,7 +46,6 @@ public enum AbilityType {
"Herbalism.Skills.GTe.Other.Off"), "Herbalism.Skills.GTe.Other.Off"),
SKULL_SPLITTER( SKULL_SPLITTER(
"Axes.Skills.SS.Name",
"Axes.Skills.SS.On", "Axes.Skills.SS.On",
"Axes.Skills.SS.Off", "Axes.Skills.SS.Off",
"Axes.Skills.SS.Other.On", "Axes.Skills.SS.Other.On",
@@ -57,7 +53,6 @@ public enum AbilityType {
"Axes.Skills.SS.Other.Off"), "Axes.Skills.SS.Other.Off"),
TREE_FELLER( TREE_FELLER(
"Woodcutting.Skills.TreeFeller.Name",
"Woodcutting.Skills.TreeFeller.On", "Woodcutting.Skills.TreeFeller.On",
"Woodcutting.Skills.TreeFeller.Off", "Woodcutting.Skills.TreeFeller.Off",
"Woodcutting.Skills.TreeFeller.Other.On", "Woodcutting.Skills.TreeFeller.Other.On",
@@ -65,7 +60,6 @@ public enum AbilityType {
"Woodcutting.Skills.TreeFeller.Other.Off"), "Woodcutting.Skills.TreeFeller.Other.Off"),
SERRATED_STRIKES( SERRATED_STRIKES(
"Swords.Skills.SS.Name",
"Swords.Skills.SS.On", "Swords.Skills.SS.On",
"Swords.Skills.SS.Off", "Swords.Skills.SS.Off",
"Swords.Skills.SS.Other.On", "Swords.Skills.SS.Other.On",
@@ -76,7 +70,6 @@ public enum AbilityType {
* Has cooldown - but has to share a skill with Super Breaker, so needs special treatment * Has cooldown - but has to share a skill with Super Breaker, so needs special treatment
*/ */
BLAST_MINING( BLAST_MINING(
"Mining.Blast.Name",
null, null,
null, null,
"Mining.Blast.Other.On", "Mining.Blast.Other.On",
@@ -86,26 +79,13 @@ public enum AbilityType {
/** /**
* No cooldown - always active * No cooldown - always active
*/ */
LEAF_BLOWER( LEAF_BLOWER,
null,
null,
null,
null,
null,
null),
/** /**
* Not a first-class Ability - part of Berserk * Not a first-class Ability - part of Berserk
*/ */
BLOCK_CRACKER( BLOCK_CRACKER;
null,
null,
null,
null,
null,
null);
private String abilityName;
private String abilityOn; private String abilityOn;
private String abilityOff; private String abilityOff;
private String abilityPlayer; private String abilityPlayer;
@@ -115,31 +95,18 @@ public enum AbilityType {
/** /**
* Those abilities that have a cooldown saved to the database. * Those abilities that have a cooldown saved to the database.
*/ */
public static final List<AbilityType> NORMAL_ABILITIES; public static final List<AbilityType> NORMAL_ABILITIES = ImmutableList.of(BERSERK, BLAST_MINING, GIGA_DRILL_BREAKER, GREEN_TERRA, SERRATED_STRIKES, SKULL_SPLITTER, SUPER_BREAKER, TREE_FELLER);
/** /**
* Those abilities that do not have a cooldown saved to the database. * Those abilities that do not have a cooldown saved to the database.
*/ */
public static final List<AbilityType> NON_NORMAL_ABILITIES; public static final List<AbilityType> NON_NORMAL_ABILITIES = ImmutableList.of(BLOCK_CRACKER, LEAF_BLOWER);
static { private AbilityType() {
NORMAL_ABILITIES = ImmutableList.of( this(null, null, null, null, null);
BERSERK,
SUPER_BREAKER,
GIGA_DRILL_BREAKER,
GREEN_TERRA,
SKULL_SPLITTER,
TREE_FELLER,
SERRATED_STRIKES,
BLAST_MINING
);
NON_NORMAL_ABILITIES = ImmutableList.of(
LEAF_BLOWER,
BLOCK_CRACKER
);
} }
private AbilityType(String abilityName, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) { private AbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
this.abilityName = abilityName;
this.abilityOn = abilityOn; this.abilityOn = abilityOn;
this.abilityOff = abilityOff; this.abilityOff = abilityOff;
this.abilityPlayer = abilityPlayer; this.abilityPlayer = abilityPlayer;
@@ -155,17 +122,6 @@ public enum AbilityType {
return Config.getInstance().getMaxLength(this); return Config.getInstance().getMaxLength(this);
} }
/**
* May return null
* @return ability name, or null if unavailable
*/
public String getAbilityName() {
if (this.abilityName == null) {
return null;
}
return LocaleLoader.getString(this.abilityName);
}
public String getAbilityOn() { public String getAbilityOn() {
return LocaleLoader.getString(this.abilityOn); return LocaleLoader.getString(this.abilityOn);
} }
@@ -186,9 +142,8 @@ public enum AbilityType {
return LocaleLoader.getString(this.abilityRefresh); return LocaleLoader.getString(this.abilityRefresh);
} }
public String getConfigString() { public String getName() {
// If toString() changes, place old code here to not break config.yml return StringUtils.getPrettyAbilityString(this);
return this.toString();
} }
@Override @Override

View File

@@ -5,6 +5,9 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
@@ -24,7 +27,9 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@@ -70,7 +75,7 @@ public enum SkillType {
nonChildSkills.add(skill); nonChildSkills.add(skill);
} }
names.add(skill.getSkillName()); names.add(skill.getName());
} }
Collections.sort(names); Collections.sort(names);
@@ -162,7 +167,10 @@ public enum SkillType {
} }
} }
mcMMO.p.getLogger().warning("[Debug] Invalid mcMMO skill (" + skillName + ")"); if (!skillName.equalsIgnoreCase("all")) {
mcMMO.p.getLogger().warning("Invalid mcMMO skill (" + skillName + ")"); //TODO: Localize
}
return null; return null;
} }
@@ -177,10 +185,6 @@ public enum SkillType {
} }
} }
public Color getRunescapeModeColor() {
return runescapeColor;
}
public static SkillType byAbility(AbilityType ability) { public static SkillType byAbility(AbilityType ability) {
for (SkillType type : values()) { for (SkillType type : values()) {
if (type.getAbility() == ability) { if (type.getAbility() == ability) {
@@ -191,7 +195,19 @@ public enum SkillType {
return null; return null;
} }
public String getSkillName() { public String getName() {
return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName")); return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName"));
} }
public boolean getPermissions(Player player) {
return Permissions.skillEnabled(player, this);
}
public void celebrateLevelUp(Player player) {
ParticleEffectUtils.fireworkParticleShower(player, runescapeColor);
}
public boolean shouldProcess(Entity target) {
return (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) ? getPVPEnabled() : getPVEEnabled();
}
} }

View File

@@ -1,18 +1,25 @@
package com.gmail.nossr50.events.skills.abilities; package com.gmail.nossr50.events.abilities;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerAbilityEvent implements Cancellable { public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerAbilityEvent implements Cancellable {
private boolean cancelled; private boolean cancelled;
@Deprecated
public McMMOPlayerAbilityActivateEvent(Player player, SkillType skill) { public McMMOPlayerAbilityActivateEvent(Player player, SkillType skill) {
super(player, skill); super(player, skill);
cancelled = false; cancelled = false;
} }
public McMMOPlayerAbilityActivateEvent(Player player, AbilityType ability) {
super(player, ability);
cancelled = false;
}
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;
} }

View File

@@ -1,11 +1,17 @@
package com.gmail.nossr50.events.skills.abilities; package com.gmail.nossr50.events.abilities;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerAbilityEvent { public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerAbilityEvent {
@Deprecated
public McMMOPlayerAbilityDeactivateEvent(Player player, SkillType skill) { public McMMOPlayerAbilityDeactivateEvent(Player player, SkillType skill) {
super(player, skill); super(player, skill);
} }
public McMMOPlayerAbilityDeactivateEvent(Player player, AbilityType ability) {
super(player, ability);
}
} }

View File

@@ -0,0 +1,62 @@
package com.gmail.nossr50.events.abilities;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
public abstract class McMMOPlayerAbilityEvent extends PlayerEvent {
private SkillType skill;
private AbilityType ability;
private boolean useParticleEffects;
@Deprecated
protected McMMOPlayerAbilityEvent(Player player, SkillType skill) {
super(player);
ability = skill.getAbility();
useParticleEffects = true;
}
protected McMMOPlayerAbilityEvent(Player player, AbilityType ability) {
super(player);
this.ability = ability;
this.useParticleEffects = true;
}
protected McMMOPlayerAbilityEvent(Player player, AbilityType ability, boolean useParticleEffects) {
super(player);
this.ability = ability;
this.useParticleEffects = useParticleEffects;
}
@Deprecated
public SkillType getSkill() {
return skill;
}
public AbilityType getAbility() {
return ability;
}
public boolean useParticleEffects() {
return useParticleEffects;
}
public void shouldUseParticleEffects(boolean useParticleEffects) {
this.useParticleEffects = useParticleEffects;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -19,7 +19,7 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
protected McMMOPlayerExperienceEvent(Player player, SkillType skill) { protected McMMOPlayerExperienceEvent(Player player, SkillType skill) {
super(player); super(player);
this.skill = skill; this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill); this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
} }
/** /**

View File

@@ -1,8 +1,9 @@
package com.gmail.nossr50.events.experience; package com.gmail.nossr50.events.experience.levels;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerExperienceEvent;
/** /**
* Called when a user levels change * Called when a user levels change

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.events.experience; package com.gmail.nossr50.events.experience.levels;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.events.experience; package com.gmail.nossr50.events.experience.levels;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@@ -0,0 +1,12 @@
package com.gmail.nossr50.events.experience.xp;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerExperienceEvent;
public abstract class McMMOPlayerXpChangeEvent extends McMMOPlayerExperienceEvent {
public McMMOPlayerXpChangeEvent(Player player, SkillType skill) {
super(player, skill);
}
}

View File

@@ -1,4 +1,4 @@
package com.gmail.nossr50.events.experience; package com.gmail.nossr50.events.experience.xp;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -7,7 +7,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
/** /**
* Called when a player gains XP in a skill * Called when a player gains XP in a skill
*/ */
public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent { public class McMMOPlayerXpGainEvent extends McMMOPlayerXpChangeEvent {
private float xpGained; private float xpGained;
public McMMOPlayerXpGainEvent(Player player, SkillType skill, float xpGained) { public McMMOPlayerXpGainEvent(Player player, SkillType skill, float xpGained) {
@@ -31,7 +31,7 @@ public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
} }
/** /**
* @param xpGained int amount of experience gained in this event * @param xpGained float amount of experience gained in this event
*/ */
public void setRawXpGained(float xpGained) { public void setRawXpGained(float xpGained) {
this.xpGained = xpGained; this.xpGained = xpGained;

View File

@@ -0,0 +1,28 @@
package com.gmail.nossr50.events.experience.xp;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
public class McMMOPlayerXpLossEvent extends McMMOPlayerXpChangeEvent {
private float xpLost;
public McMMOPlayerXpLossEvent(Player player, SkillType skill, float xpLost) {
super(player, skill);
this.xpLost = xpLost;
}
/**
* @return The amount of experience lost in this event
*/
public float getRawXpLost() {
return xpLost;
}
/**
* @param xpLost amount of experience lost in this event
*/
public void setRawXpLost(float xpLost) {
this.xpLost = xpLost;
}
}

View File

@@ -0,0 +1,40 @@
package com.gmail.nossr50.events.skills;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.util.player.UserManager;
public abstract class McMMOPlayerCombatEvent extends FakeEntityDamageByEntityEvent {
private Player player;
private SkillType skill;
private int skillLevel;
protected McMMOPlayerCombatEvent(Player player, Entity damager, Entity damagee, DamageCause cause, double damage, SkillType skill) {
super(damager, damagee, cause, damage);
this.player = player;
this.skill = skill;
skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
}
protected McMMOPlayerCombatEvent(Player player, Entity damagee, DamageCause cause, double damage, SkillType skill) {
super(player, damagee, cause, damage);
this.player = player;
this.skill = skill;
skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
}
public Player getPlayer() {
return player;
}
public SkillType getSkill() {
return skill;
}
public int getSkillLevel() {
return skillLevel;
}
}

View File

@@ -17,7 +17,7 @@ public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
protected McMMOPlayerSkillEvent(Player player, SkillType skill) { protected McMMOPlayerSkillEvent(Player player, SkillType skill) {
super(player); super(player);
this.skill = skill; this.skill = skill;
this.skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill); this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
} }
/** /**

View File

@@ -0,0 +1,44 @@
package com.gmail.nossr50.events.skills;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.skills.SkillType;
public abstract class McMMOPlayerTreasureEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
private ItemStack treasure;
private int xpGained;
protected McMMOPlayerTreasureEvent(Player player, SkillType skill, ItemStack treasure, int xpGained) {
super(player, skill);
this.treasure = treasure;
this.xpGained = xpGained;
this.cancelled = false;
}
public ItemStack getTreasure() {
return treasure;
}
public void setTreasure(ItemStack item) {
this.treasure = item;
}
public int getXpGained() {
return xpGained;
}
public void setXpGained(int xpGained) {
this.xpGained = xpGained;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
}

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

@@ -0,0 +1,24 @@
package com.gmail.nossr50.events.skills.acrobatics;
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 abstract class McMMOPlayerAcrobaticsEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
protected McMMOPlayerAcrobaticsEvent(Player player) {
super(player, SkillType.ACROBATICS);
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@@ -0,0 +1,30 @@
package com.gmail.nossr50.events.skills.acrobatics;
import org.bukkit.entity.Player;
public class McMMOPlayerDodgeEvent extends McMMOPlayerAcrobaticsEvent {
private double damageTaken;
private float xpGained;
public McMMOPlayerDodgeEvent(Player player, double damageTaken, float xpGained) {
super(player);
this.damageTaken = damageTaken;
this.xpGained = xpGained;
}
public double getDamageTaken() {
return damageTaken;
}
public void setDamageTaken(double damageTaken) {
this.damageTaken = damageTaken;
}
public float getXpGained() {
return xpGained;
}
public void setXpGained(float xpGained) {
this.xpGained = xpGained;
}
}

View File

@@ -0,0 +1,36 @@
package com.gmail.nossr50.events.skills.acrobatics;
import org.bukkit.entity.Player;
public class McMMOPlayerRollEvent extends McMMOPlayerAcrobaticsEvent {
private double damageTaken;
private float xpGained;
private boolean graceful;
public McMMOPlayerRollEvent(Player player, double damageTaken, float xpGained, boolean graceful) {
super(player);
this.damageTaken = damageTaken;
this.xpGained = xpGained;
this.graceful = graceful;
}
public double getDamageTaken() {
return damageTaken;
}
public void setDamageTaken(double damageTaken) {
this.damageTaken = damageTaken;
}
public float getXpGained() {
return xpGained;
}
public void setXpGained(float xpGained) {
this.xpGained = xpGained;
}
public boolean isGraceful() {
return graceful;
}
}

View File

@@ -0,0 +1,13 @@
package com.gmail.nossr50.events.skills.archery;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerCombatEvent;
public class McMMOPlayerArcheryCombatEvent extends McMMOPlayerCombatEvent {
public McMMOPlayerArcheryCombatEvent(Player player, Entity damager, Entity damagee, DamageCause cause, double damage) {
super(player, damager, damagee, cause, damage, SkillType.ARCHERY);
}
}

View File

@@ -0,0 +1,24 @@
package com.gmail.nossr50.events.skills.archery;
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 abstract class McMMOPlayerArcheryEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
protected McMMOPlayerArcheryEvent(Player player) {
super(player, SkillType.ARCHERY);
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@@ -0,0 +1,12 @@
package com.gmail.nossr50.events.skills.archery;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.skills.archery.Archery;
public class McMMOPlayerDazeEvent extends McMMOPlayerArcheryCombatEvent {
public McMMOPlayerDazeEvent(Player player, Entity damager, Entity damagee) {
super(player, damager, damagee, DamageCause.PROJECTILE, Archery.dazeModifier);
}
}

View File

@@ -0,0 +1,10 @@
package com.gmail.nossr50.events.skills.archery;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class McMMOPlayerSkillShotEvent extends McMMOPlayerArcheryCombatEvent {
public McMMOPlayerSkillShotEvent(Player player, Entity damager, Entity damagee, double damage) {
super(player, damager, damagee, DamageCause.PROJECTILE, damage);
}
}

View File

@@ -0,0 +1,13 @@
package com.gmail.nossr50.events.skills.axes;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerCombatEvent;
public class McMMOPlayerAxeCombatEvent extends McMMOPlayerCombatEvent {
public McMMOPlayerAxeCombatEvent(Player player, Entity damagee, DamageCause cause, double damage) {
super(player, damagee, cause, damage, SkillType.AXES);
}
}

View File

@@ -0,0 +1,24 @@
package com.gmail.nossr50.events.skills.axes;
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 abstract class McMMOPlayerAxeEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
protected McMMOPlayerAxeEvent(Player player) {
super(player, SkillType.AXES);
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@@ -0,0 +1,12 @@
package com.gmail.nossr50.events.skills.axes;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class McMMOPlayerAxeMasteryEvent extends McMMOPlayerAxeCombatEvent {
public McMMOPlayerAxeMasteryEvent(Player player, Entity damagee, double damage) {
super(player, damagee, DamageCause.ENTITY_ATTACK, damage);
// TODO Auto-generated constructor stub
}
}

View File

@@ -0,0 +1,10 @@
package com.gmail.nossr50.events.skills.axes;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class McMMOPlayerCriticalHitEvent extends McMMOPlayerAxeCombatEvent {
public McMMOPlayerCriticalHitEvent(Player player, Entity damagee, double damage) {
super(player, damagee, DamageCause.ENTITY_ATTACK, damage);
}
}

View File

@@ -0,0 +1,22 @@
package com.gmail.nossr50.events.skills.axes;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class McMMOPlayerGreaterImpactEvent extends McMMOPlayerAxeCombatEvent {
private Vector knockbackVelocity;
public McMMOPlayerGreaterImpactEvent(Player player, Entity damagee, double damage, Vector knockbackVelocity) {
super(player, damagee, DamageCause.ENTITY_ATTACK, damage);
this.knockbackVelocity = knockbackVelocity;
}
public Vector getKnockbackVelocity() {
return knockbackVelocity;
}
public void setKnockbackVelocity(Vector knockbackVelocity) {
this.knockbackVelocity = knockbackVelocity;
}
}

View File

@@ -0,0 +1,17 @@
package com.gmail.nossr50.events.skills.axes;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class McMMOPlayerImpactEvent extends McMMOPlayerAxeEvent {
private ItemStack armor;
public McMMOPlayerImpactEvent(Player player, ItemStack armor) {
super(player);
this.armor = armor;
}
public ItemStack getArmor() {
return armor;
}
}

View File

@@ -0,0 +1,21 @@
package com.gmail.nossr50.events.skills.excavation;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerTreasureEvent;
public class McMMOPlayerExcavationTreasureEvent extends McMMOPlayerTreasureEvent {
private Block block;
public McMMOPlayerExcavationTreasureEvent(Player player, ItemStack treasure, int xpGained, Block block) {
super(player, SkillType.EXCAVATION, treasure, xpGained);
this.block = block;
}
public Block getBlock() {
return block;
}
}

View File

@@ -0,0 +1,13 @@
package com.gmail.nossr50.events.skills.fishing;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerCombatEvent;
public abstract class McMMOPlayerFishingCombatEvent extends McMMOPlayerCombatEvent {
public McMMOPlayerFishingCombatEvent(Player player, Entity damager, Entity damagee, DamageCause cause, double damage) {
super(player, damager, damagee, cause, damage, SkillType.FISHING);
}
}

View File

@@ -3,29 +3,11 @@ package com.gmail.nossr50.events.skills.fishing;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerFishingEvent { import com.gmail.nossr50.datatypes.skills.SkillType;
private ItemStack treasure; import com.gmail.nossr50.events.skills.McMMOPlayerTreasureEvent;
private int xp;
public McMMOPlayerFishingTreasureEvent(Player player, ItemStack treasure, int xp) { public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerTreasureEvent {
super(player); public McMMOPlayerFishingTreasureEvent(Player player, ItemStack treasure, int xpGained) {
this.treasure = treasure; super(player, SkillType.FISHING, treasure, xpGained);
this.xp = xp;
}
public ItemStack getTreasure() {
return treasure;
}
public void setTreasure(ItemStack item) {
this.treasure = item;
}
public int getXp() {
return xp;
}
public void setXp(int xp) {
this.xp = xp;
} }
} }

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