mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-20 10:43:12 +01:00
Compare commits
149 Commits
1.4.06-bet
...
dev-partym
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
663d54d31f | ||
|
|
9a5f4b638f | ||
|
|
9aa49a09da | ||
|
|
bf8945ac59 | ||
|
|
d9926bab4e | ||
|
|
38ba2c21e5 | ||
|
|
a48fb30edf | ||
|
|
92ec04bd46 | ||
|
|
0b6372a6ea | ||
|
|
4f8b66f94d | ||
|
|
0c52b3016c | ||
|
|
a2f80569e3 | ||
|
|
87df536a1f | ||
|
|
12e70490d8 | ||
|
|
23b1518dc0 | ||
|
|
6dbf2e0d95 | ||
|
|
60304e9643 | ||
|
|
614557e2fa | ||
|
|
e312e95aed | ||
|
|
2ee919b51f | ||
|
|
22f6ae858b | ||
|
|
3c3b4af2c4 | ||
|
|
feb0d1fe5d | ||
|
|
2d66b8ed12 | ||
|
|
483f348403 | ||
|
|
a8a5100f58 | ||
|
|
1f9dc70bb1 | ||
|
|
7f1ef61657 | ||
|
|
2e74c079b0 | ||
|
|
ce4295289a | ||
|
|
7fde04851d | ||
|
|
71d030e5ad | ||
|
|
b08649d0a4 | ||
|
|
0a11a9a2c8 | ||
|
|
068f47b523 | ||
|
|
79aab57abc | ||
|
|
2cf58f1b5b | ||
|
|
9678875b4b | ||
|
|
d1a7ce827a | ||
|
|
9b2f4b7bde | ||
|
|
24e5147a2a | ||
|
|
0423a7831d | ||
|
|
feea22b3a4 | ||
|
|
7f40a9f284 | ||
|
|
bc706109e0 | ||
|
|
a25bddba5e | ||
|
|
ab897724d3 | ||
|
|
a7861fc54b | ||
|
|
936bec8ff5 | ||
|
|
01d10971a1 | ||
|
|
12e388a392 | ||
|
|
fb450671d6 | ||
|
|
fca5f9ec98 | ||
|
|
c9ae6436bd | ||
|
|
b6c4d2b4ad | ||
|
|
27ab2f5b12 | ||
|
|
9b08062a58 | ||
|
|
401bdfa9ac | ||
|
|
68d8d6dd30 | ||
|
|
2a57d7007d | ||
|
|
fd675ac291 | ||
|
|
41f020bbb7 | ||
|
|
00dee500e0 | ||
|
|
36bdb8a63e | ||
|
|
aa9eb0868c | ||
|
|
48aafa9834 | ||
|
|
78f53f294a | ||
|
|
3158c7e3eb | ||
|
|
47d27ebf31 | ||
|
|
bc3773ae75 | ||
|
|
d8ddd27d71 | ||
|
|
8d5696507a | ||
|
|
9ec376a228 | ||
|
|
a05a0da9fb | ||
|
|
5029ad9d93 | ||
|
|
1444be665c | ||
|
|
3dedb94bdc | ||
|
|
c0f6c15a80 | ||
|
|
00626a4893 | ||
|
|
b416a59bb7 | ||
|
|
bf96fb2214 | ||
|
|
2e79c8d770 | ||
|
|
6c9d1c4953 | ||
|
|
df8df192d3 | ||
|
|
e5f43462c8 | ||
|
|
1867a3e040 | ||
|
|
6818f98de3 | ||
|
|
f910c76248 | ||
|
|
975cbf0bf8 | ||
|
|
f10b3cef01 | ||
|
|
ad39c94773 | ||
|
|
f189ab30e5 | ||
|
|
0ad18ee971 | ||
|
|
501f5de55a | ||
|
|
0b18ae8ff2 | ||
|
|
de12970486 | ||
|
|
7550b99aaa | ||
|
|
ed5a43966d | ||
|
|
95ea6703f1 | ||
|
|
55f9092aa6 | ||
|
|
5f50a46603 | ||
|
|
c5e6704530 | ||
|
|
8552192894 | ||
|
|
0261d16140 | ||
|
|
2b414526e5 | ||
|
|
c0b7eb526a | ||
|
|
7b7196a8c4 | ||
|
|
f648289035 | ||
|
|
8a0b1d548d | ||
|
|
1f17d5d11e | ||
|
|
18efd09421 | ||
|
|
18d3b30647 | ||
|
|
7f0243b2df | ||
|
|
33610c8997 | ||
|
|
8e0a1f4f70 | ||
|
|
b07cf6bdde | ||
|
|
7ed218ee7f | ||
|
|
3aedeea220 | ||
|
|
4f9b7b2609 | ||
|
|
09abab1b5d | ||
|
|
499713c8e7 | ||
|
|
cb953a1619 | ||
|
|
3ab4938f3d | ||
|
|
f6e9fd9f3a | ||
|
|
8dab75f3cb | ||
|
|
b36096e54d | ||
|
|
0574de4a29 | ||
|
|
6d6bc3de76 | ||
|
|
5c4c3cf59c | ||
|
|
0033c8864e | ||
|
|
e7c749ee3a | ||
|
|
5c026be0cd | ||
|
|
c465546871 | ||
|
|
3322677d32 | ||
|
|
76cf0ebb01 | ||
|
|
d34a0cca30 | ||
|
|
a77a916fcc | ||
|
|
e1ebb96545 | ||
|
|
d85a6bec43 | ||
|
|
78eb7787e9 | ||
|
|
b55ce30b2d | ||
|
|
14050cf096 | ||
|
|
5930128b7f | ||
|
|
08be78fa35 | ||
|
|
88f43d9a91 | ||
|
|
6cbf960dea | ||
|
|
374d34f76d | ||
|
|
cc486c2dc7 | ||
|
|
724dce07a9 |
@@ -6,8 +6,9 @@ Key:
|
|||||||
= Fix
|
= Fix
|
||||||
! Change
|
! Change
|
||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
Version 1.4.06-dev
|
Version 1.4.06-dev
|
||||||
|
+ Added "Ice Fishing" ability to Fishing
|
||||||
+ Added global scoreboards to track skill rankings (display using /mctop)
|
+ Added global scoreboards to track skill rankings (display using /mctop)
|
||||||
+ Added per-player scoreboard displays for the /inspect, /mcrank, /mcstats, and /<skillname> commands
|
+ Added per-player scoreboard displays for the /inspect, /mcrank, /mcstats, and /<skillname> commands
|
||||||
+ Added tab-complete support for all commands
|
+ Added tab-complete support for all commands
|
||||||
@@ -18,6 +19,17 @@ Version 1.4.06-dev
|
|||||||
+ Added new permission node for /ptp; mcmmo.commands.ptp.send (enabled by default)
|
+ Added new permission node for /ptp; mcmmo.commands.ptp.send (enabled by default)
|
||||||
+ Added configurable cooldown and warmup times when using /ptp
|
+ Added configurable cooldown and warmup times when using /ptp
|
||||||
+ Added a new Party item share category "Misc" which contains a list of configurable items. (By default all tools and armor)
|
+ Added a new Party item share category "Misc" which contains a list of configurable items. (By default all tools and armor)
|
||||||
|
+ Added fishing exploit prevention
|
||||||
|
+ Added permission node to bypass the fishing exploit prevention
|
||||||
|
+ Added boosts to Fishing chance depending on conditions
|
||||||
|
+ Added McMMOAbilityActivateEvent and McMMOAbilityDeactivateEvent
|
||||||
|
+ Added config option to toggle the size of fireworks
|
||||||
|
+ Added config option to multiply xp gains from mob spawner mobs
|
||||||
|
+ Added multiplier to Archery XP based on bow force
|
||||||
|
+ Added information about /party itemshare and /party expshare to the party help page
|
||||||
|
+ Added option to use scoreboards for power level display instead of Spout.
|
||||||
|
= Fixed bug where custom Spout titles were overwritten by mcMMO.
|
||||||
|
= Fixed bug where Nether Quartz wasn't included in Smelting or item sharing
|
||||||
= Fixed bug where players were able to join the same party multiple times
|
= Fixed bug where players were able to join the same party multiple times
|
||||||
= Fixed displaying partial names when trying to use /ptp
|
= Fixed displaying partial names when trying to use /ptp
|
||||||
= Fixed wolves from Call of the Wild only having 8 health
|
= Fixed wolves from Call of the Wild only having 8 health
|
||||||
@@ -28,6 +40,15 @@ Version 1.4.06-dev
|
|||||||
= Fixed Fishing treasures always having the same enchants
|
= Fixed Fishing treasures always having the same enchants
|
||||||
= Fixed Smelting returning ink sacs instead of Lapis when double-dropping
|
= Fixed Smelting returning ink sacs instead of Lapis when double-dropping
|
||||||
= Fixed bug where players could remain in party chat after leaving or being kicked from a party.
|
= Fixed bug where players could remain in party chat after leaving or being kicked from a party.
|
||||||
|
= Fixed bug where non-player arrows couldn't be deflected.
|
||||||
|
= Fixed experience being applied even when the permission for a skill was denied
|
||||||
|
= Fixed possible item duplication bug with infinity bows
|
||||||
|
= Fixed bug with removing players from mySQL database
|
||||||
|
= Fixed bug with empty metadata lists and Smelting
|
||||||
|
= Fixed bug where Blast Mining would drop wrong items
|
||||||
|
= Fixed bug with Blast Mining where the Ability refreshed message was being send too early
|
||||||
|
= Fixed bug where the chance of a successful Gracefull Roll was twice as high as displayed
|
||||||
|
! Changed Spout notification tiers to be stored in SpoutConfig instead of AdvancedConfig
|
||||||
! Changed Berserk to add items to inventory rather than denying pickup
|
! Changed Berserk to add items to inventory rather than denying pickup
|
||||||
! Changed Call of the Wild, newly summoned pet's will have a custom name. (added permission node to disable this)
|
! Changed Call of the Wild, newly summoned pet's will have a custom name. (added permission node to disable this)
|
||||||
! Changed Chimaera Wing's recipe result to use the ingredient Material
|
! Changed Chimaera Wing's recipe result to use the ingredient Material
|
||||||
@@ -38,6 +59,7 @@ Version 1.4.06-dev
|
|||||||
! Changed the amount of info messages in the console when enabling/disabling, enable Verbose_Logging to enable them again
|
! Changed the amount of info messages in the console when enabling/disabling, enable Verbose_Logging to enable them again
|
||||||
! Items dropped by players are now being tracked and are not being shared with party members
|
! Items dropped by players are now being tracked and are not being shared with party members
|
||||||
! Optimized tracking of tool & ability cooldowns.
|
! Optimized tracking of tool & ability cooldowns.
|
||||||
|
! Updated the localization files
|
||||||
|
|
||||||
Version 1.4.05
|
Version 1.4.05
|
||||||
+ Added option to allow refreshing of chunks after block-breaking abilities. (Disabled by default)
|
+ Added option to allow refreshing of chunks after block-breaking abilities. (Disabled by default)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ mcMMO is currently developed by a team of individuals from all over the world.
|
|||||||
(https://github.com/shatteredbeam)
|
(https://github.com/shatteredbeam)
|
||||||
[]
|
[]
|
||||||
(https://github.com/TfT-02)
|
(https://github.com/TfT-02)
|
||||||
[]
|
[]
|
||||||
(https://github.com/t00thpick1)
|
(https://github.com/t00thpick1)
|
||||||
|
|
||||||
## Compiling
|
## Compiling
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -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.06-beta2</version>
|
<version>1.4.06-dev6</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>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.api;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.chat.ChatManager;
|
import com.gmail.nossr50.chat.ChatManager;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@@ -22,7 +23,7 @@ public final class ChatAPI {
|
|||||||
* @param message The message to send
|
* @param message The message to send
|
||||||
*/
|
*/
|
||||||
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
||||||
ChatManager.handlePartyChat(plugin, PartyManager.getParty(party), sender, displayName, message);
|
ChatManager.handlePartyChat(plugin, mcMMO.getPartyManager().getParty(party), sender, displayName, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,7 +37,7 @@ public final class ChatAPI {
|
|||||||
* @param message The message to send
|
* @param message The message to send
|
||||||
*/
|
*/
|
||||||
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
||||||
ChatManager.handlePartyChat(plugin, PartyManager.getParty(party), sender, sender, message);
|
ChatManager.handlePartyChat(plugin, mcMMO.getPartyManager().getParty(party), sender, sender, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,7 +139,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).setAdminChat(!isUsingAdminChat(playerName));
|
UserManager.getPlayer(playerName).setAdminChat(!isUsingAdminChat(playerName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public final class ExperienceAPI {
|
|||||||
throw new InvalidSkillException();
|
throw new InvalidSkillException();
|
||||||
}
|
}
|
||||||
|
|
||||||
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
UserManager.getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * Config.getInstance().getExperienceGainsGlobalMultiplier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -175,6 +175,7 @@ public final class ExperienceAPI {
|
|||||||
* @return the amount of XP in a given skill
|
* @return the amount of XP in a given skill
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static int getXP(Player player, String skillType) {
|
public static int getXP(Player player, String skillType) {
|
||||||
SkillType skill = SkillType.getSkill(skillType);
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
@@ -183,6 +184,10 @@ public final class ExperienceAPI {
|
|||||||
throw new InvalidSkillException();
|
throw new InvalidSkillException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||||
|
}
|
||||||
|
|
||||||
return UserManager.getPlayer(player).getProfile().getSkillXpLevel(skill);
|
return UserManager.getPlayer(player).getProfile().getSkillXpLevel(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,6 +202,7 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static int getOfflineXP(String playerName, String skillType) {
|
public static int getOfflineXP(String playerName, String skillType) {
|
||||||
SkillType skill = SkillType.getSkill(skillType);
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
@@ -205,6 +211,10 @@ public final class ExperienceAPI {
|
|||||||
throw new InvalidSkillException();
|
throw new InvalidSkillException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||||
|
}
|
||||||
|
|
||||||
return getOfflineProfile(playerName).getSkillXpLevel(skill);
|
return getOfflineProfile(playerName).getSkillXpLevel(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,6 +228,7 @@ public final class ExperienceAPI {
|
|||||||
* @return the amount of XP in a given skill
|
* @return the amount of XP in a given skill
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static float getXPRaw(Player player, String skillType) {
|
public static float getXPRaw(Player player, String skillType) {
|
||||||
SkillType skill = SkillType.getSkill(skillType);
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
@@ -226,6 +237,10 @@ public final class ExperienceAPI {
|
|||||||
throw new InvalidSkillException();
|
throw new InvalidSkillException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||||
|
}
|
||||||
|
|
||||||
return UserManager.getPlayer(player).getProfile().getSkillXpLevelRaw(skill);
|
return UserManager.getPlayer(player).getProfile().getSkillXpLevelRaw(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,6 +255,7 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static float getOfflineXPRaw(String playerName, String skillType) {
|
public static float getOfflineXPRaw(String playerName, String skillType) {
|
||||||
SkillType skill = SkillType.getSkill(skillType);
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
@@ -248,19 +264,24 @@ public final class ExperienceAPI {
|
|||||||
throw new InvalidSkillException();
|
throw new InvalidSkillException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||||
|
}
|
||||||
|
|
||||||
return getOfflineProfile(playerName).getSkillXpLevelRaw(skill);
|
return getOfflineProfile(playerName).getSkillXpLevelRaw(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of XP left before leveling up.
|
* Get the total amount of XP needed to reach the next level.
|
||||||
* </br>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* This function is designed for API usage.
|
||||||
*
|
*
|
||||||
* @param player The player to get the XP amount for
|
* @param player The player to get the XP amount for
|
||||||
* @param skillType The skill to get the XP amount for
|
* @param skillType The skill to get the XP amount for
|
||||||
* @return the amount of XP left before leveling up a specifc skill
|
* @return the total amount of XP needed to reach the next level
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static int getXPToNextLevel(Player player, String skillType) {
|
public static int getXPToNextLevel(Player player, String skillType) {
|
||||||
SkillType skill = SkillType.getSkill(skillType);
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
@@ -269,9 +290,68 @@ public final class ExperienceAPI {
|
|||||||
throw new InvalidSkillException();
|
throw new InvalidSkillException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||||
|
}
|
||||||
|
|
||||||
return UserManager.getPlayer(player).getProfile().getXpToLevel(skill);
|
return UserManager.getPlayer(player).getProfile().getXpToLevel(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the total amount of XP an offline player needs to reach the next level.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param playerName The player to get XP for
|
||||||
|
* @param skillType The skill to get XP for
|
||||||
|
* @return the total amount of XP needed to reach the next level
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
|
*/
|
||||||
|
public static int getOfflineXPToNextLevel(String playerName, String skillType) {
|
||||||
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
|
|
||||||
|
if (skill == null) {
|
||||||
|
throw new InvalidSkillException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||||
|
}
|
||||||
|
|
||||||
|
return getOfflineProfile(playerName).getXpToLevel(skill);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the amount of XP remaining until the next level.
|
||||||
|
* </br>
|
||||||
|
* This function is designed for API usage.
|
||||||
|
*
|
||||||
|
* @param player The player to get the XP amount for
|
||||||
|
* @param skillType The skill to get the XP amount for
|
||||||
|
* @return the amount of XP remaining until the next level
|
||||||
|
*
|
||||||
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
|
*/
|
||||||
|
public static int getXPRemaining(Player player, String skillType) {
|
||||||
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
|
|
||||||
|
if (skill == null) {
|
||||||
|
throw new InvalidSkillException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||||
|
|
||||||
|
return profile.getXpToLevel(skill) - profile.getSkillXpLevel(skill);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of XP an offline player has left before leveling up.
|
* Get the amount of XP an offline player has left before leveling up.
|
||||||
* </br>
|
* </br>
|
||||||
@@ -279,19 +359,26 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @param playerName The player to get XP for
|
* @param playerName The player to get XP for
|
||||||
* @param skillType The skill to get XP for
|
* @param skillType The skill to get XP for
|
||||||
* @return the amount of XP in a given skill
|
* @return the amount of XP needed to reach the next level
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static int getOfflineXPToNextLevel(String playerName, String skillType) {
|
public static int getOfflineXPRemaining(String playerName, String skillType) {
|
||||||
SkillType skill = SkillType.getSkill(skillType);
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
|
|
||||||
if (skill == null) {
|
if (skill == null) {
|
||||||
throw new InvalidSkillException();
|
throw new InvalidSkillException();
|
||||||
}
|
}
|
||||||
|
|
||||||
return getOfflineProfile(playerName).getXpToLevel(skill);
|
if (skill.isChildSkill()) {
|
||||||
|
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerProfile profile = getOfflineProfile(playerName);
|
||||||
|
|
||||||
|
return profile.getXpToLevel(skill) - profile.getSkillXpLevel(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -419,11 +506,7 @@ public final class ExperienceAPI {
|
|||||||
int powerLevel = 0;
|
int powerLevel = 0;
|
||||||
PlayerProfile profile = getOfflineProfile(playerName);
|
PlayerProfile profile = getOfflineProfile(playerName);
|
||||||
|
|
||||||
for (SkillType type : SkillType.values()) {
|
for (SkillType type : SkillType.nonChildSkills()) {
|
||||||
if (type.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
powerLevel += profile.getSkillLevel(type);
|
powerLevel += profile.getSkillLevel(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,6 +597,7 @@ public final class ExperienceAPI {
|
|||||||
* @param newValue The value to set the XP to
|
* @param newValue The value to set the XP to
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static void setXP(Player player, String skillType, int newValue) {
|
public static void setXP(Player player, String skillType, int newValue) {
|
||||||
SkillType skill = SkillType.getSkill(skillType);
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
@@ -522,6 +606,10 @@ public final class ExperienceAPI {
|
|||||||
throw new InvalidSkillException();
|
throw new InvalidSkillException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||||
|
}
|
||||||
|
|
||||||
UserManager.getPlayer(player).getProfile().setSkillXpLevel(skill, newValue);
|
UserManager.getPlayer(player).getProfile().setSkillXpLevel(skill, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,6 +624,7 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static void setXPOffline(String playerName, String skillType, int newValue) {
|
public static void setXPOffline(String playerName, String skillType, int newValue) {
|
||||||
SkillType skill = SkillType.getSkill(skillType);
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
@@ -544,6 +633,10 @@ public final class ExperienceAPI {
|
|||||||
throw new InvalidSkillException();
|
throw new InvalidSkillException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||||
|
}
|
||||||
|
|
||||||
getOfflineProfile(playerName).setSkillXpLevel(skill, newValue);
|
getOfflineProfile(playerName).setSkillXpLevel(skill, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,6 +650,7 @@ public final class ExperienceAPI {
|
|||||||
* @param xp The amount of XP to remove
|
* @param xp The amount of XP to remove
|
||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static void removeXP(Player player, String skillType, int xp) {
|
public static void removeXP(Player player, String skillType, int xp) {
|
||||||
SkillType skill = SkillType.getSkill(skillType);
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
@@ -565,6 +659,10 @@ public final class ExperienceAPI {
|
|||||||
throw new InvalidSkillException();
|
throw new InvalidSkillException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||||
|
}
|
||||||
|
|
||||||
UserManager.getPlayer(player).getProfile().removeXp(skill, xp);
|
UserManager.getPlayer(player).getProfile().removeXp(skill, xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,6 +677,7 @@ public final class ExperienceAPI {
|
|||||||
*
|
*
|
||||||
* @throws InvalidSkillException if the given skill is not valid
|
* @throws InvalidSkillException if the given skill is not valid
|
||||||
* @throws InvalidPlayerException if the given player does not exist in the database
|
* @throws InvalidPlayerException if the given player does not exist in the database
|
||||||
|
* @throws UnsupportedOperationException if the given skill is a child skill
|
||||||
*/
|
*/
|
||||||
public static void removeXPOffline(String playerName, String skillType, int xp) {
|
public static void removeXPOffline(String playerName, String skillType, int xp) {
|
||||||
SkillType skill = SkillType.getSkill(skillType);
|
SkillType skill = SkillType.getSkill(skillType);
|
||||||
@@ -587,6 +686,10 @@ public final class ExperienceAPI {
|
|||||||
throw new InvalidSkillException();
|
throw new InvalidSkillException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (skill.isChildSkill()) {
|
||||||
|
throw new UnsupportedOperationException("Child skills do not have XP");
|
||||||
|
}
|
||||||
|
|
||||||
getOfflineProfile(playerName).removeXp(skill, xp);
|
getOfflineProfile(playerName).removeXp(skill, xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public final class PartyAPI {
|
|||||||
* @return true if the two players are in the same party, false otherwise
|
* @return true if the two players are in the same party, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean inSameParty(Player playera, Player playerb) {
|
public static boolean inSameParty(Player playera, Player playerb) {
|
||||||
return PartyManager.inSameParty(playera, playerb);
|
return mcMMO.getPartyManager().inSameParty(playera, playerb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,7 +64,7 @@ public final class PartyAPI {
|
|||||||
* @return the list of parties.
|
* @return the list of parties.
|
||||||
*/
|
*/
|
||||||
public static List<Party> getParties() {
|
public static List<Party> getParties() {
|
||||||
return PartyManager.getParties();
|
return mcMMO.getPartyManager().getParties();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +76,7 @@ public final class PartyAPI {
|
|||||||
* @param partyName The party to add the player to
|
* @param partyName The party to add the player to
|
||||||
*/
|
*/
|
||||||
public static void addToParty(Player player, String partyName) {
|
public static void addToParty(Player player, String partyName) {
|
||||||
Party party = PartyManager.getParty(partyName);
|
Party party = mcMMO.getPartyManager().getParty(partyName);
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
party = new Party();
|
party = new Party();
|
||||||
@@ -84,7 +84,7 @@ public final class PartyAPI {
|
|||||||
party.setLeader(player.getName());
|
party.setLeader(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.addToParty(player, UserManager.getPlayer(player), party);
|
mcMMO.getPartyManager().addToParty(player, party);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,7 +95,7 @@ public final class PartyAPI {
|
|||||||
* @param player The player to remove
|
* @param player The player to remove
|
||||||
*/
|
*/
|
||||||
public static void removeFromParty(Player player) {
|
public static void removeFromParty(Player player) {
|
||||||
PartyManager.removeFromParty(player, UserManager.getPlayer(player).getParty());
|
mcMMO.getPartyManager().removeFromParty(player, UserManager.getPlayer(player).getParty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +107,7 @@ public final class PartyAPI {
|
|||||||
* @return the leader of the party
|
* @return the leader of the party
|
||||||
*/
|
*/
|
||||||
public static String getPartyLeader(String partyName) {
|
public static String getPartyLeader(String partyName) {
|
||||||
return PartyManager.getPartyLeader(partyName);
|
return mcMMO.getPartyManager().getPartyLeader(partyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,7 +119,7 @@ public final class PartyAPI {
|
|||||||
* @param player The player to set as leader
|
* @param player The player to set as leader
|
||||||
*/
|
*/
|
||||||
public static void setPartyLeader(String partyName, String player) {
|
public static void setPartyLeader(String partyName, String player) {
|
||||||
PartyManager.setPartyLeader(player, PartyManager.getParty(partyName));
|
mcMMO.getPartyManager().setPartyLeader(player, mcMMO.getPartyManager().getParty(partyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +134,7 @@ public final class PartyAPI {
|
|||||||
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
|
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
|
||||||
List<OfflinePlayer> members = new ArrayList<OfflinePlayer>();
|
List<OfflinePlayer> members = new ArrayList<OfflinePlayer>();
|
||||||
|
|
||||||
for (String memberName : PartyManager.getAllMembers(player)) {
|
for (String memberName : mcMMO.getPartyManager().getAllMembers(UserManager.getPlayer(player).getParty())) {
|
||||||
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberName);
|
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberName);
|
||||||
members.add(member);
|
members.add(member);
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ public final class PartyAPI {
|
|||||||
* @return all the player names in the player's party
|
* @return all the player names in the player's party
|
||||||
*/
|
*/
|
||||||
public static LinkedHashSet<String> getMembers(Player player) {
|
public static LinkedHashSet<String> getMembers(Player player) {
|
||||||
return PartyManager.getAllMembers(player);
|
return mcMMO.getPartyManager().getAllMembers(UserManager.getPlayer(player).getParty());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -162,7 +162,7 @@ public final class PartyAPI {
|
|||||||
* @return all online players in this party
|
* @return all online players in this party
|
||||||
*/
|
*/
|
||||||
public static List<Player> getOnlineMembers(String partyName) {
|
public static List<Player> getOnlineMembers(String partyName) {
|
||||||
return PartyManager.getOnlineMembers(partyName);
|
return mcMMO.getPartyManager().getOnlineMembers(partyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -174,6 +174,6 @@ public final class PartyAPI {
|
|||||||
* @return all online players in the player's party
|
* @return all online players in the player's party
|
||||||
*/
|
*/
|
||||||
public static List<Player> getOnlineMembers(Player player) {
|
public static List<Player> getOnlineMembers(Player player) {
|
||||||
return PartyManager.getOnlineMembers(player);
|
return mcMMO.getPartyManager().getOnlineMembers(UserManager.getPlayer(player).getParty().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
|
||||||
public final class ChatManager {
|
public final class ChatManager {
|
||||||
public ChatManager () {}
|
public ChatManager() {}
|
||||||
|
|
||||||
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) {
|
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) {
|
||||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync);
|
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync);
|
||||||
|
|||||||
65
src/main/java/com/gmail/nossr50/commands/KrakenCommand.java
Normal file
65
src/main/java/com/gmail/nossr50/commands/KrakenCommand.java
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabExecutor;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
public class KrakenCommand implements TabExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Permissions.kraken(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserManager.getPlayer(sender.getName()).getFishingManager().unleashTheKraken();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (!Permissions.krakenOthers(sender)) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (!CommandUtils.checkPlayerExistence(sender, args[0], mcMMOPlayer)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.getFishingManager().unleashTheKraken();
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 1:
|
||||||
|
Set<String> playerNames = UserManager.getPlayers().keySet();
|
||||||
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
||||||
|
default:
|
||||||
|
return ImmutableList.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
package com.gmail.nossr50.commands;
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
|
||||||
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.getspout.spoutapi.player.SpoutPlayer;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
import com.gmail.nossr50.commands.party.PartySubcommandType;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
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.spout.SpoutUtils;
|
||||||
|
|
||||||
public class McmmoCommand implements CommandExecutor {
|
public class McmmoCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
@@ -28,13 +28,13 @@ public class McmmoCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(mcSplit);
|
sender.sendMessage(mcSplit);
|
||||||
|
|
||||||
if (Config.getInstance().getDonateMessageEnabled()) {
|
if (Config.getInstance().getDonateMessageEnabled()) {
|
||||||
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
|
if (mcMMO.isSpoutEnabled() && sender instanceof Player) {
|
||||||
SpoutPlayer spoutPlayer = (SpoutPlayer) sender;
|
SpoutUtils.sendDonationNotification((Player) sender);
|
||||||
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND);
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||||
|
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
|
||||||
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
|
||||||
@@ -62,52 +62,52 @@ public class McmmoCommand implements CommandExecutor {
|
|||||||
private void displayPartyCommands(CommandSender sender) {
|
private void displayPartyCommands(CommandSender sender) {
|
||||||
if (Permissions.party(sender)) {
|
if (Permissions.party(sender)) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
|
||||||
sender.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
|
sender.sendMessage(" /party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
|
||||||
sender.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
|
sender.sendMessage(" /party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
|
||||||
sender.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit"));
|
sender.sendMessage(" /party quit " + LocaleLoader.getString("Commands.Party.Quit"));
|
||||||
|
|
||||||
if (Permissions.partyChat(sender)) {
|
if (Permissions.partyChat(sender)) {
|
||||||
sender.sendMessage("/party chat " + LocaleLoader.getString("Commands.Party.Toggle"));
|
sender.sendMessage(" /party chat " + LocaleLoader.getString("Commands.Party.Toggle"));
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
|
sender.sendMessage(" /party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
|
||||||
sender.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept"));
|
sender.sendMessage(" /party accept " + LocaleLoader.getString("Commands.Party.Accept"));
|
||||||
|
|
||||||
if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) {
|
if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) {
|
||||||
sender.sendMessage("/party teleport " + LocaleLoader.getString("Commands.Party.Teleport"));
|
sender.sendMessage(" /party teleport " + LocaleLoader.getString("Commands.Party.Teleport"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayOtherCommands(CommandSender sender) {
|
private void displayOtherCommands(CommandSender sender) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Other"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Other"));
|
||||||
sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
sender.sendMessage(" /mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||||
sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
sender.sendMessage(" /mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||||
|
|
||||||
if (Permissions.skillreset(sender)) {
|
if (Permissions.skillreset(sender)) {
|
||||||
sender.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
sender.sendMessage(" /skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.mcability(sender)) {
|
if (Permissions.mcability(sender)) {
|
||||||
sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
sender.sendMessage(" /mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.adminChat(sender)) {
|
if (Permissions.adminChat(sender)) {
|
||||||
sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
|
sender.sendMessage(" /adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.inspect(sender)) {
|
if (Permissions.inspect(sender)) {
|
||||||
sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
|
sender.sendMessage(" /inspect " + LocaleLoader.getString("Commands.Inspect"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.mmoedit(sender)) {
|
if (Permissions.mmoedit(sender)) {
|
||||||
sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
|
sender.sendMessage(" /mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.mcgod(sender)) {
|
if (Permissions.mcgod(sender)) {
|
||||||
sender.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod"));
|
sender.sendMessage(" /mcgod " + LocaleLoader.getString("Commands.mcgod"));
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.SkillInfo"));
|
sender.sendMessage(" /<skill>" + LocaleLoader.getString("Commands.SkillInfo"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabExecutor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
public class McscoreboardCommand implements TabExecutor {
|
||||||
|
private static final List<String> SCOREBOARD_TYPES = ImmutableList.of("clear", "rank", "stats", "top");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
clearScoreboard(player);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
if (args[0].equalsIgnoreCase("clear")) {
|
||||||
|
clearScoreboard(player);
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("rank")) {
|
||||||
|
if (!Config.getInstance().getMcrankScoreboardEnabled()) {
|
||||||
|
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||||
|
ScoreboardManager.enablePlayerRankScoreboard(player);
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("stats")) {
|
||||||
|
if (!Config.getInstance().getMcstatsScoreboardsEnabled()) {
|
||||||
|
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScoreboardManager.setupPlayerScoreboard(player.getName());
|
||||||
|
ScoreboardManager.enablePlayerStatsScoreboard(UserManager.getPlayer(player));
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("top")) {
|
||||||
|
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
||||||
|
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScoreboardManager.enableGlobalStatsScoreboard(player, "all", 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
if (!args[0].equalsIgnoreCase("top")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
||||||
|
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isInt(args[1])) {
|
||||||
|
ScoreboardManager.enableGlobalStatsScoreboard(player, "all", Math.abs(Integer.parseInt(args[1])));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CommandUtils.isInvalidSkill(sender, args[1])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScoreboardManager.enableGlobalStatsScoreboard(player, args[1], 1);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
if (!args[0].equalsIgnoreCase("top")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Config.getInstance().getMctopScoreboardEnabled()) {
|
||||||
|
sender.sendMessage("This scoreboard is not enabled."); //TODO: Localize
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CommandUtils.isInvalidSkill(sender, args[1])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CommandUtils.isInvalidInteger(sender, args[2])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ScoreboardManager.enableGlobalStatsScoreboard(player, args[1], Math.abs(Integer.parseInt(args[2])));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
switch (args.length) {
|
||||||
|
case 1:
|
||||||
|
return StringUtil.copyPartialMatches(args[0], SCOREBOARD_TYPES, new ArrayList<String>(SCOREBOARD_TYPES.size()));
|
||||||
|
case 2:
|
||||||
|
if (args[0].equalsIgnoreCase("top")) {
|
||||||
|
return StringUtil.copyPartialMatches(args[1], SkillType.SKILL_NAMES, new ArrayList<String>(SkillType.SKILL_NAMES.size()));
|
||||||
|
}
|
||||||
|
// Fallthrough
|
||||||
|
|
||||||
|
default:
|
||||||
|
return ImmutableList.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearScoreboard(Player player) {
|
||||||
|
player.setScoreboard(mcMMO.p.getServer().getScoreboardManager().getMainScoreboard());
|
||||||
|
player.sendMessage("Your scoreboard has been cleared!"); //TODO: Locale
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,7 +35,7 @@ public class PartyChatCommand extends ChatCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Party party = PartyManager.getParty(args[0]);
|
Party party = mcMMO.getPartyManager().getParty(args[0]);
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
||||||
|
|||||||
@@ -9,18 +9,12 @@ import org.bukkit.command.TabExecutor;
|
|||||||
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.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public class McpurgeCommand implements TabExecutor {
|
public class McpurgeCommand 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 (!Permissions.mcpurge(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
mcMMO.getDatabaseManager().purgePowerlessUsers();
|
mcMMO.getDatabaseManager().purgePowerlessUsers();
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import org.bukkit.util.StringUtil;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
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;
|
||||||
|
|
||||||
@@ -21,11 +20,6 @@ import com.google.common.collect.ImmutableList;
|
|||||||
public class McremoveCommand implements TabExecutor {
|
public class McremoveCommand 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 (!Permissions.mcremove(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
if (UserManager.getPlayer(args[0]) == null && CommandUtils.unloadedProfile(sender, new PlayerProfile(args[0], false))) {
|
if (UserManager.getPlayer(args[0]) == null && CommandUtils.unloadedProfile(sender, new PlayerProfile(args[0], false))) {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.database.SQLConversionTask;
|
import com.gmail.nossr50.runnables.database.SQLConversionTask;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
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;
|
||||||
@@ -19,11 +18,6 @@ import com.google.common.collect.ImmutableList;
|
|||||||
public class MmoupdateCommand implements TabExecutor {
|
public class MmoupdateCommand 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 (!Permissions.mmoupdate(sender)) {
|
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Config.getInstance().getUseMySQL()) {
|
if (!Config.getInstance().getUseMySQL()) {
|
||||||
sender.sendMessage("SQL Mode is not enabled."); // TODO: Localize
|
sender.sendMessage("SQL Mode is not enabled."); // TODO: Localize
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
|
|||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||||
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.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
@@ -21,6 +23,10 @@ public class AddlevelsCommand extends ExperienceCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void handleCommand(SkillType skill) {
|
protected void handleCommand(SkillType skill) {
|
||||||
profile.addLevels(skill, value);
|
profile.addLevels(skill, value);
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
|
|||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
||||||
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.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
@@ -21,6 +23,10 @@ public class MmoeditCommand extends ExperienceCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void handleCommand(SkillType skill) {
|
protected void handleCommand(SkillType skill) {
|
||||||
profile.modifySkill(skill, value);
|
profile.modifySkill(skill, value);
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - profile.getSkillLevel(skill)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package com.gmail.nossr50.commands.experience;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
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.events.experience.McMMOPlayerLevelUpEvent;
|
||||||
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.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
@@ -84,13 +86,11 @@ public class SkillresetCommand extends ExperienceCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean permissionsCheckSelf(CommandSender sender) {
|
protected boolean permissionsCheckSelf(CommandSender sender) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean permissionsCheckOthers(CommandSender sender) {
|
protected boolean permissionsCheckOthers(CommandSender sender) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +102,10 @@ public class SkillresetCommand extends ExperienceCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
profile.modifySkill(skill, 0);
|
profile.modifySkill(skill, 0);
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, 0 - profile.getSkillLevel(skill)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
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;
|
||||||
@@ -24,11 +25,11 @@ public class PartyAcceptCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Changing parties
|
// Changing parties
|
||||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), mcMMOPlayer.getPartyInvite().getName())) {
|
if (!mcMMO.getPartyManager().changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.joinInvitedParty(player, mcMMOPlayer);
|
mcMMO.getPartyManager().joinInvitedParty(player);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ 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 com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
@@ -21,7 +22,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.setPartyLeader(args[1], playerParty);
|
mcMMO.getPartyManager().setPartyLeader(args[1], playerParty);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.mcMMO;
|
||||||
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;
|
||||||
@@ -17,22 +17,20 @@ public class PartyCreateCommand implements CommandExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
Party newParty = PartyManager.getParty(args[1]);
|
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
// Check to see if the party exists, and if it does cancel creating a new party
|
// Check to see if the party exists, and if it does cancel creating a new party
|
||||||
if (PartyManager.checkPartyExistence(player, newParty, args[1])) {
|
if (mcMMO.getPartyManager().checkPartyExistence(player, args[1])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changing parties
|
// Changing parties
|
||||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) {
|
if (!mcMMO.getPartyManager().changeOrJoinParty(mcMMOPlayer, args[1])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.createParty(player, mcMMOPlayer, args[1], getPassword(args));
|
mcMMO.getPartyManager().createParty(player, args[1], getPassword(args));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@@ -20,14 +21,14 @@ public class PartyDisbandCommand implements CommandExecutor {
|
|||||||
String partyName = playerParty.getName();
|
String partyName = playerParty.getName();
|
||||||
|
|
||||||
for (Player member : playerParty.getOnlineMembers()) {
|
for (Player member : playerParty.getOnlineMembers()) {
|
||||||
if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
if (!mcMMO.getPartyManager().handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
member.sendMessage(LocaleLoader.getString("Party.Disband"));
|
member.sendMessage(LocaleLoader.getString("Party.Disband"));
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.disbandParty(playerParty);
|
mcMMO.getPartyManager().disbandParty(playerParty);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public class PartyHelpCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick"));
|
sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick"));
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader"));
|
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader"));
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband"));
|
sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Help.9", "/party itemshare"));
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.Help.10", "/party expshare"));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void displayMemberInfo() {
|
private void displayMemberInfo() {
|
||||||
int membersNear = PartyManager.getNearMembers(player, playerParty, Config.getInstance().getPartyShareRange()).size();
|
int membersNear = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange()).size();
|
||||||
int membersOnline = playerParty.getOnlineMembers().size() - 1;
|
int membersOnline = playerParty.getOnlineMembers().size() - 1;
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
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;
|
||||||
@@ -32,14 +33,14 @@ public class PartyInviteCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PartyManager.inSameParty(player, target)) {
|
if (mcMMO.getPartyManager().inSameParty(player, target)) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
|
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Party playerParty = mcMMOPlayer.getParty();
|
Party playerParty = mcMMOPlayer.getParty();
|
||||||
|
|
||||||
if (!PartyManager.canInvite(player, playerParty)) {
|
if (!mcMMO.getPartyManager().canInvite(player)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
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;
|
||||||
@@ -37,16 +38,16 @@ public class PartyJoinCommand implements CommandExecutor {
|
|||||||
String password = getPassword(args);
|
String password = getPassword(args);
|
||||||
|
|
||||||
// Make sure party passwords match
|
// Make sure party passwords match
|
||||||
if (!PartyManager.checkPartyPassword(player, targetParty, password)) {
|
if (!mcMMO.getPartyManager().checkPartyPassword(player, targetParty, password)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Changing parties
|
// Changing parties
|
||||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, playerParty, targetParty.getName())) {
|
if (!mcMMO.getPartyManager().changeOrJoinParty(mcMMOPlayer, targetParty.getName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.joinParty(player, mcMMOPlayer, targetParty, password);
|
mcMMO.getPartyManager().joinParty(player, targetParty, password);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -30,14 +30,14 @@ public class PartyKickCommand implements CommandExecutor {
|
|||||||
Player onlineTarget = target.getPlayer();
|
Player onlineTarget = target.getPlayer();
|
||||||
String partyName = playerParty.getName();
|
String partyName = playerParty.getName();
|
||||||
|
|
||||||
if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
if (!mcMMO.getPartyManager().handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.removeFromParty(target, playerParty);
|
mcMMO.getPartyManager().removeFromParty(target, playerParty);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
@@ -19,11 +20,11 @@ public class PartyQuitCommand implements CommandExecutor {
|
|||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
Party playerParty = UserManager.getPlayer(player).getParty();
|
Party playerParty = UserManager.getPlayer(player).getParty();
|
||||||
|
|
||||||
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
|
if (!mcMMO.getPartyManager().handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.removeFromParty(player, playerParty);
|
mcMMO.getPartyManager().removeFromParty(player, playerParty);
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||||
@@ -30,17 +31,16 @@ public class PartyRenameCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
Party newParty = PartyManager.getParty(newPartyName);
|
|
||||||
|
|
||||||
// Check to see if the party exists, and if it does cancel renaming the party
|
// Check to see if the party exists, and if it does cancel renaming the party
|
||||||
if (PartyManager.checkPartyExistence(player, newParty, newPartyName)) {
|
if (mcMMO.getPartyManager().checkPartyExistence(player, newPartyName)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String leaderName = playerParty.getLeader();
|
String leaderName = playerParty.getLeader();
|
||||||
|
|
||||||
for (Player member : playerParty.getOnlineMembers()) {
|
for (Player member : playerParty.getOnlineMembers()) {
|
||||||
if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
|
if (!mcMMO.getPartyManager().handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
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;
|
||||||
@@ -56,11 +55,15 @@ public class PtpCommand implements TabExecutor {
|
|||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
|
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
|
||||||
int recentlyhurt_cooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
|
int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
|
||||||
|
|
||||||
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)) {
|
if (hurtCooldown > 0) {
|
||||||
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)));
|
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
|
||||||
return true;
|
|
||||||
|
if (timeRemaining > 0) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("accept")) {
|
if (args[0].equalsIgnoreCase("accept")) {
|
||||||
@@ -75,9 +78,13 @@ public class PtpCommand implements TabExecutor {
|
|||||||
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
|
||||||
long lastTeleport = mcMMOPlayer.getLastTeleport();
|
long lastTeleport = mcMMOPlayer.getLastTeleport();
|
||||||
|
|
||||||
if (!SkillUtils.cooldownOver(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player)) {
|
if (ptpCooldown > 0) {
|
||||||
player.sendMessage(ChatColor.RED + "You need to wait before you can use this again! " + ChatColor.YELLOW + "(" + SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player) + ")"); //TODO Locale!
|
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player);
|
||||||
return true;
|
|
||||||
|
if (timeRemaining > 0) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendTeleportRequest(sender, player, args[0]);
|
sendTeleportRequest(sender, player, args[0]);
|
||||||
@@ -139,7 +146,7 @@ public class PtpCommand implements TabExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PartyManager.inSameParty(player, target)) {
|
if (!mcMMO.getPartyManager().inSameParty(player, target)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -166,7 +173,7 @@ public class PtpCommand implements TabExecutor {
|
|||||||
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
|
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
|
||||||
|
|
||||||
if (warmup > 0) {
|
if (warmup > 0) {
|
||||||
teleportingPlayer.sendMessage(ChatColor.GRAY + "Commencing teleport in " + ChatColor.GOLD + "(" + warmup + ")" + ChatColor.GRAY + " seconds, please stand still..."); //TODO Locale!
|
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
|
||||||
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
|
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
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;
|
||||||
@@ -22,6 +25,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
private boolean canShake;
|
private boolean canShake;
|
||||||
private boolean canFishermansDiet;
|
private boolean canFishermansDiet;
|
||||||
private boolean canMasterAngler;
|
private boolean canMasterAngler;
|
||||||
|
private boolean canIceFish;
|
||||||
|
|
||||||
public FishingCommand() {
|
public FishingCommand() {
|
||||||
super(SkillType.FISHING);
|
super(SkillType.FISHING);
|
||||||
@@ -60,7 +64,18 @@ public class FishingCommand extends SkillCommand {
|
|||||||
|
|
||||||
// MASTER ANGLER
|
// MASTER ANGLER
|
||||||
if (canMasterAngler) {
|
if (canMasterAngler) {
|
||||||
biteChance = calculateAbilityDisplayValues(((Math.max((skillValue / 200.0), 1.0)) / (isStorming ? 300 : 500)) * 100.0)[0];
|
double rawBiteChance = ((Math.max((skillValue / 200.0), 1.0)) / (isStorming ? 300 : 500));
|
||||||
|
Biome biome = player.getLocation().getBlock().getBiome();
|
||||||
|
|
||||||
|
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
||||||
|
rawBiteChance = rawBiteChance * 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
|
||||||
|
rawBiteChance = rawBiteChance * 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0)[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,11 +86,12 @@ public class FishingCommand extends SkillCommand {
|
|||||||
canShake = Permissions.shake(player);
|
canShake = Permissions.shake(player);
|
||||||
canFishermansDiet = Permissions.fishermansDiet(player);
|
canFishermansDiet = Permissions.fishermansDiet(player);
|
||||||
canMasterAngler = Permissions.masterAngler(player);
|
canMasterAngler = Permissions.masterAngler(player);
|
||||||
|
canIceFish = Permissions.iceFishing(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean effectsHeaderPermissions() {
|
protected boolean effectsHeaderPermissions() {
|
||||||
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet;
|
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -101,11 +117,15 @@ public class FishingCommand extends SkillCommand {
|
|||||||
if (canMasterAngler) {
|
if (canMasterAngler) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canIceFish) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean statsHeaderPermissions() {
|
protected boolean statsHeaderPermissions() {
|
||||||
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet;
|
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -136,5 +156,16 @@ public class FishingCommand extends SkillCommand {
|
|||||||
if (canFishermansDiet) {
|
if (canFishermansDiet) {
|
||||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canIceFish) {
|
||||||
|
int unlockLevel = AdvancedConfig.getInstance().getIceFishingUnlockLevel();
|
||||||
|
|
||||||
|
if (skillValue < unlockLevel) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public abstract class SpoutCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled()) {
|
if (!mcMMO.isSpoutEnabled() || !SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* GENERAL */
|
/* GENERAL */
|
||||||
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
|
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
|
||||||
public int getEnchantBuff() { return config.getInt("Skills.General.Ability_EnchantBuff", 5); }
|
public int getEnchantBuff() {
|
||||||
|
int buff = config.getInt("Skills.General.Ability_EnchantBuff", 5);
|
||||||
|
return (buff <= 0) ? 1 : buff;
|
||||||
|
}
|
||||||
|
|
||||||
/* ACROBATICS */
|
/* ACROBATICS */
|
||||||
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
|
public double getDodgeChanceMax() { return config.getDouble("Skills.Acrobatics.Dodge_ChanceMax", 20.0D); }
|
||||||
@@ -34,7 +37,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); }
|
public double getGracefulRollChanceMax() { return config.getDouble("Skills.Acrobatics.GracefulRoll_ChanceMax", 100.0D); }
|
||||||
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
|
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
|
||||||
public int getGracefulRollDamageThreshold() { return config.getInt("Skills.Acrobatics.GracefulRoll_DamageThreshold", 14); }
|
public int getGracefulRollDamageThreshold() { return config.getInt("Skills.Acrobatics.GracefulRoll_DamageThreshold", 14); }
|
||||||
public int getGracefulRollSuccessModifer() { return config.getInt("Skills.Acrobatics.GracefulRoll_SuccessModifier", 2); }
|
|
||||||
|
|
||||||
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
|
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
|
||||||
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }
|
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }
|
||||||
@@ -52,6 +54,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
public double getRetrieveChanceMax() { return config.getDouble("Skills.Archery.Retrieve_MaxBonus", 100.0D); }
|
public double getRetrieveChanceMax() { return config.getDouble("Skills.Archery.Retrieve_MaxBonus", 100.0D); }
|
||||||
public int getRetrieveMaxBonusLevel() { return config.getInt("Skills.Archery.Retrieve_MaxBonusLevel", 1000); }
|
public int getRetrieveMaxBonusLevel() { return config.getInt("Skills.Archery.Retrieve_MaxBonusLevel", 1000); }
|
||||||
|
|
||||||
|
public double getForceMultiplier() { return config.getDouble("Skills.Archery.Force_Multiplier", 2.0D); }
|
||||||
|
|
||||||
/* AXES */
|
/* AXES */
|
||||||
public int getBonusDamageAxesBonusMax() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonus", 4); }
|
public int getBonusDamageAxesBonusMax() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonus", 4); }
|
||||||
public int getBonusDamageAxesMaxBonusLevel() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonusLevel", 200); }
|
public int getBonusDamageAxesMaxBonusLevel() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonusLevel", 200); }
|
||||||
@@ -85,6 +89,8 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.Fisherman_Diet_RankChange", 200); }
|
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.Fisherman_Diet_RankChange", 200); }
|
||||||
|
|
||||||
|
public int getIceFishingUnlockLevel() { return config.getInt("Skills.Fishing.Ice_Fishing_UnlockLevel", 50); }
|
||||||
|
|
||||||
/* Shake */
|
/* Shake */
|
||||||
public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); }
|
public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); }
|
||||||
public int getShakeChanceRank1() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_1", 25); }
|
public int getShakeChanceRank1() { return config.getInt("Skills.Fishing.Shake_Chance.Rank_1", 25); }
|
||||||
@@ -273,9 +279,17 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
public double getWoodcuttingDoubleDropChance() { return config.getDouble("Skills.Woodcutting.DoubleDrops_ChanceMax", 100.0D); }
|
public double getWoodcuttingDoubleDropChance() { return config.getDouble("Skills.Woodcutting.DoubleDrops_ChanceMax", 100.0D); }
|
||||||
public int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); }
|
public int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); }
|
||||||
|
|
||||||
/* SPOUT STUFF*/
|
/* KRAKEN STUFF */
|
||||||
public int getSpoutNotificationTier1() { return config.getInt("Spout.Notifications.Tier1", 200); }
|
public boolean getKrakenEnabled() { return config.getBoolean("Kraken.Enabled", true); }
|
||||||
public int getSpoutNotificationTier2() { return config.getInt("Spout.Notifications.Tier2", 400); }
|
public boolean getKrakenGlobalSoundsEnabled() { return config.getBoolean("Kraken.Global_Sounds", true); }
|
||||||
public int getSpoutNotificationTier3() { return config.getInt("Spout.Notifications.Tier3", 600); }
|
public boolean getKrakenEscapeAllowed() { return config.getBoolean("Kraken.Allow_Escaping", false); }
|
||||||
public int getSpoutNotificationTier4() { return config.getInt("Spout.Notifications.Tier4", 800); }
|
public int getKrakenTriesBeforeRelease() { return config.getInt("Kraken.Tries_Before_Release", 50); }
|
||||||
|
public int getKrakenHealth() { return config.getInt("Kraken.Health", 50); }
|
||||||
|
public String getKrakenName() { return config.getString("Kraken.Name", "The Kraken"); }
|
||||||
|
public String getServerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Server", "(PLAYER) has unleashed the kraken!"); }
|
||||||
|
public String getPlayerUnleashMessage() { return config.getString("Kraken.Unleashed_Message.Player", "THE KRAKEN HAS BEEN UNLEASHED!"); }
|
||||||
|
public String getPlayerDefeatMessage() { return config.getString("Kraken.Defeated_Message.Killed", "You have slain the kraken!"); }
|
||||||
|
public String getPlayerEscapeMessage() { return config.getString("Kraken.Defeated_Message.Escape", "You have escaped from the kraken!"); }
|
||||||
|
public int getKrakenAttackInterval() { return config.getInt("Kraken.Attack_Interval_Seconds", 1); }
|
||||||
|
public int getKrakenAttackDamage() { return config.getInt("Kraken.Attack_Damage", 1); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
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); }
|
||||||
|
|
||||||
|
public boolean getPotatoEnabled() { return config.getBoolean("General.Potato_Explosion_Enabled", false); }
|
||||||
|
public int getPotatoChance() { return config.getInt("General.Potato_Explosion_Chance", 1); }
|
||||||
|
|
||||||
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
|
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
|
||||||
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
|
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
|
||||||
|
|
||||||
@@ -66,7 +69,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public int getMcrankScoreboardTime() { return config.getInt("Scoreboards.Mcrank.Display_Time", 10); }
|
public int getMcrankScoreboardTime() { return config.getInt("Scoreboards.Mcrank.Display_Time", 10); }
|
||||||
|
|
||||||
public boolean getMcstatsScoreboardsEnabled() { return config.getBoolean("Scoreboards.Mcstats.Use", true); }
|
public boolean getMcstatsScoreboardsEnabled() { return config.getBoolean("Scoreboards.Mcstats.Use", true); }
|
||||||
public int getMcstatsScoreboardTime() { return config.getInt("Scoreboards.Mctop.Display_Time", 10); }
|
public int getMcstatsScoreboardTime() { return config.getInt("Scoreboards.Mcstats.Display_Time", 10); }
|
||||||
|
|
||||||
public boolean getMctopScoreboardEnabled() { return config.getBoolean("Scoreboards.Mctop.Use", true); }
|
public boolean getMctopScoreboardEnabled() { return config.getBoolean("Scoreboards.Mctop.Use", true); }
|
||||||
public int getMctopScoreboardTime() { return config.getInt("Scoreboards.Mctop.Display_Time", 10); }
|
public int getMctopScoreboardTime() { return config.getInt("Scoreboards.Mctop.Display_Time", 10); }
|
||||||
@@ -77,6 +80,8 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getSkillScoreboardEnabled() { return config.getBoolean("Scoreboards.Skillname.Use", true); }
|
public boolean getSkillScoreboardEnabled() { return config.getBoolean("Scoreboards.Skillname.Use", true); }
|
||||||
public int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); }
|
public int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); }
|
||||||
|
|
||||||
|
public boolean getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", false); }
|
||||||
|
|
||||||
/* Database Purging */
|
/* Database Purging */
|
||||||
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); }
|
||||||
@@ -147,6 +152,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getGreaterImpactEffectEnabled() { return config.getBoolean("Particles.Greater_Impact", true); }
|
public boolean getGreaterImpactEffectEnabled() { return config.getBoolean("Particles.Greater_Impact", true); }
|
||||||
public boolean getLevelUpEffectsEnabled() { return config.getBoolean("Particles.LevelUp_Enabled", true); }
|
public boolean getLevelUpEffectsEnabled() { return config.getBoolean("Particles.LevelUp_Enabled", true); }
|
||||||
public int getLevelUpEffectsTier() { return config.getInt("Particles.LevelUp_Tier", 100); }
|
public int getLevelUpEffectsTier() { return config.getInt("Particles.LevelUp_Tier", 100); }
|
||||||
|
public boolean getLargeFireworks() { return config.getBoolean("Particles.LargeFireworks", true); }
|
||||||
|
|
||||||
/* PARTY SETTINGS */
|
/* PARTY SETTINGS */
|
||||||
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
|
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
|
||||||
@@ -166,6 +172,9 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); }
|
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Confirm_Required", true); }
|
||||||
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
|
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
|
||||||
|
|
||||||
|
/* Inspect command distance */
|
||||||
|
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30); }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ABILITY SETTINGS
|
* ABILITY SETTINGS
|
||||||
*/
|
*/
|
||||||
@@ -272,7 +281,6 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* General Settings */
|
/* General Settings */
|
||||||
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
|
|
||||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
||||||
|
|
||||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
|
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
|
||||||
@@ -285,8 +293,9 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
|
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
|
||||||
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
|
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
|
||||||
|
|
||||||
|
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience.Gains.MobSpawners.Multiplier", 0.0); }
|
||||||
|
|
||||||
/* XP Formula Multiplier */
|
/* XP Formula Multiplier */
|
||||||
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
|
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
|
||||||
public double getForumulaMultiplier(SkillType skill) { return config.getDouble("Experience.Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
|
public double getFormulaSkillModifier(SkillType skill) { return config.getDouble("Experience.Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public abstract class ConfigLoader {
|
|||||||
OutputStream outputStream = null;
|
OutputStream outputStream = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
outputStream = new FileOutputStream(configFile);
|
outputStream = new FileOutputStream(configFile);
|
||||||
|
|
||||||
int read;
|
int read;
|
||||||
byte[] bytes = new byte[1024];
|
byte[] bytes = new byte[1024];
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.config.spout;
|
package com.gmail.nossr50.config.spout;
|
||||||
|
|
||||||
|
import org.getspout.spoutapi.keyboard.Keyboard;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
import com.gmail.nossr50.datatypes.spout.huds.HudType;
|
||||||
@@ -34,7 +36,14 @@ public class SpoutConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
||||||
public String getMenuKey() { return config.getString("Menu.Key", "KEY_M"); }
|
public Keyboard getMenuKey() {
|
||||||
|
try {
|
||||||
|
return Keyboard.valueOf(config.getString("Menu.Key", "KEY_M").toUpperCase().trim());
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ex) {
|
||||||
|
return Keyboard.KEY_M;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* XP Bar */
|
/* XP Bar */
|
||||||
public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); }
|
public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); }
|
||||||
@@ -57,4 +66,10 @@ public class SpoutConfig extends ConfigLoader {
|
|||||||
public double getRetroHUDRed(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
public double getRetroHUDRed(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
||||||
public double getRetroHUDGreen(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
public double getRetroHUDGreen(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
||||||
public double getRetroHUDBlue(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
public double getRetroHUDBlue(SkillType skill) { return config.getDouble("HUD.Retro.Colors." + skill.toString().toLowerCase() +".RED", 0.3); }
|
||||||
|
|
||||||
|
/* Notification Tiers */
|
||||||
|
public int getNotificationTier1() { return config.getInt("Notifications.Tier1", 200); }
|
||||||
|
public int getNotificationTier2() { return config.getInt("Notifications.Tier2", 400); }
|
||||||
|
public int getNotificationTier3() { return config.getInt("Notifications.Tier3", 600); }
|
||||||
|
public int getNotificationTier4() { return config.getInt("Notifications.Tier4", 800); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
reason.add("Invalid amount: " + amount);
|
reason.add("Invalid amount: " + amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data > 127 || data < -128) {
|
if (id < 256 && (data > 127 || data < -128)) {
|
||||||
reason.add("Invalid data: " + data);
|
reason.add("Invalid data: " + data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -294,11 +294,7 @@ public final class FlatfileDatabaseManager {
|
|||||||
|
|
||||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||||
|
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||||
if (skill.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
|
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,14 +92,13 @@ public final class SQLDatabaseManager {
|
|||||||
+ "`user` varchar(40) NOT NULL,"
|
+ "`user` varchar(40) NOT NULL,"
|
||||||
+ "`lastlogin` int(32) unsigned NOT NULL,"
|
+ "`lastlogin` int(32) unsigned NOT NULL,"
|
||||||
+ "PRIMARY KEY (`id`),"
|
+ "PRIMARY KEY (`id`),"
|
||||||
+ "UNIQUE KEY `user` (`user`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
+ "UNIQUE KEY `user` (`user`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
||||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
|
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
|
||||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||||
+ "`hudtype` varchar(50) NOT NULL DEFAULT 'STANDARD',"
|
+ "`hudtype` varchar(50) NOT NULL DEFAULT 'STANDARD',"
|
||||||
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT 'HEARTS',"
|
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "',"
|
||||||
+ "PRIMARY KEY (`user_id`),"
|
+ "PRIMARY KEY (`user_id`)) "
|
||||||
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
+ "DEFAULT CHARSET=latin1;");
|
||||||
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
|
||||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "cooldowns` ("
|
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "cooldowns` ("
|
||||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||||
+ "`taming` int(32) unsigned NOT NULL DEFAULT '0',"
|
+ "`taming` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||||
@@ -114,9 +113,8 @@ public final class SQLDatabaseManager {
|
|||||||
+ "`axes` int(32) unsigned NOT NULL DEFAULT '0',"
|
+ "`axes` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||||
+ "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0',"
|
+ "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||||
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
|
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||||
+ "PRIMARY KEY (`user_id`),"
|
+ "PRIMARY KEY (`user_id`)) "
|
||||||
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
+ "DEFAULT CHARSET=latin1;");
|
||||||
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
|
||||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "skills` ("
|
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "skills` ("
|
||||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||||
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
|
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||||
@@ -130,9 +128,8 @@ public final class SQLDatabaseManager {
|
|||||||
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
|
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||||
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
|
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||||
+ "PRIMARY KEY (`user_id`),"
|
+ "PRIMARY KEY (`user_id`)) "
|
||||||
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
+ "DEFAULT CHARSET=latin1;");
|
||||||
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
|
||||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "experience` ("
|
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "experience` ("
|
||||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||||
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
|
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||||
@@ -146,15 +143,15 @@ public final class SQLDatabaseManager {
|
|||||||
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
|
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||||
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
|
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||||
+ "PRIMARY KEY (`user_id`),"
|
+ "PRIMARY KEY (`user_id`)) "
|
||||||
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
|
+ "DEFAULT CHARSET=latin1;");
|
||||||
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
|
|
||||||
|
|
||||||
checkDatabaseStructure(DatabaseUpdateType.FISHING);
|
checkDatabaseStructure(DatabaseUpdateType.FISHING);
|
||||||
checkDatabaseStructure(DatabaseUpdateType.BLAST_MINING);
|
checkDatabaseStructure(DatabaseUpdateType.BLAST_MINING);
|
||||||
checkDatabaseStructure(DatabaseUpdateType.CASCADE_DELETE);
|
|
||||||
checkDatabaseStructure(DatabaseUpdateType.INDEX);
|
checkDatabaseStructure(DatabaseUpdateType.INDEX);
|
||||||
checkDatabaseStructure(DatabaseUpdateType.MOB_HEALTHBARS);
|
checkDatabaseStructure(DatabaseUpdateType.MOB_HEALTHBARS);
|
||||||
|
checkDatabaseStructure(DatabaseUpdateType.PARTY_NAMES);
|
||||||
|
checkDatabaseStructure(DatabaseUpdateType.KILL_ORPHANS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -175,7 +172,9 @@ public final class SQLDatabaseManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
printErrors(ex);
|
if (!sql.equalsIgnoreCase("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;")) {
|
||||||
|
printErrors(ex);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
@@ -191,7 +190,13 @@ public final class SQLDatabaseManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean removeUserSQL(String playerName) {
|
public static boolean removeUserSQL(String playerName) {
|
||||||
return SQLDatabaseManager.update("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.user = '" + playerName + "'") != 0;
|
return SQLDatabaseManager.update("DELETE FROM u, e, h, s, c " +
|
||||||
|
"USING " + tablePrefix + "users u " +
|
||||||
|
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " +
|
||||||
|
"WHERE u.user = '" + playerName + "'") != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -410,11 +415,7 @@ public final class SQLDatabaseManager {
|
|||||||
|
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
try {
|
try {
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String skillName = skillType.name().toLowerCase();
|
String skillName = skillType.name().toLowerCase();
|
||||||
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||||
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||||
@@ -489,8 +490,12 @@ public final class SQLDatabaseManager {
|
|||||||
|
|
||||||
public static int purgePowerlessSQL() {
|
public static int purgePowerlessSQL() {
|
||||||
HashMap<Integer, ArrayList<String>> usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0");
|
HashMap<Integer, ArrayList<String>> usernames = read("SELECT u.user FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0");
|
||||||
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT u.id FROM " + tablePrefix + "skills AS s, " + tablePrefix + "users AS u WHERE s.user_id = u.id AND (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0) AS p)");
|
write("DELETE FROM u, e, h, s, c USING " + tablePrefix + "users u " +
|
||||||
|
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " +
|
||||||
|
"WHERE (s.taming+s.mining+s.woodcutting+s.repair+s.unarmed+s.herbalism+s.excavation+s.archery+s.swords+s.axes+s.acrobatics+s.fishing) = 0");
|
||||||
return processPurge(usernames.values());
|
return processPurge(usernames.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,7 +504,12 @@ public final class SQLDatabaseManager {
|
|||||||
long purgeTime = ONE_MONTH * Config.getInstance().getOldUsersCutoff();
|
long purgeTime = ONE_MONTH * Config.getInstance().getOldUsersCutoff();
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<String>> usernames = read("SELECT user FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")");
|
HashMap<Integer, ArrayList<String>> usernames = read("SELECT user FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")");
|
||||||
write("DELETE FROM " + tablePrefix + "users WHERE " + tablePrefix + "users.id IN (SELECT * FROM (SELECT id FROM " + tablePrefix + "users WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")) AS p)");
|
write("DELETE FROM u, e, h, s, c USING " + tablePrefix + "users u " +
|
||||||
|
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " +
|
||||||
|
"WHERE ((" + currentTime + " - lastlogin*1000) > " + purgeTime + ")");
|
||||||
|
|
||||||
return processPurge(usernames.values());
|
return processPurge(usernames.values());
|
||||||
}
|
}
|
||||||
@@ -530,13 +540,6 @@ public final class SQLDatabaseManager {
|
|||||||
sql = "SELECT * FROM `" + tablePrefix + "cooldowns` ORDER BY `" + tablePrefix + "cooldowns`.`blast_mining` ASC LIMIT 0 , 30";
|
sql = "SELECT * FROM `" + tablePrefix + "cooldowns` ORDER BY `" + tablePrefix + "cooldowns`.`blast_mining` ASC LIMIT 0 , 30";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CASCADE_DELETE:
|
|
||||||
write("ALTER TABLE `" + tablePrefix + "huds` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
|
||||||
write("ALTER TABLE `" + tablePrefix + "experience` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
|
||||||
write("ALTER TABLE `" + tablePrefix + "cooldowns` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
|
||||||
write("ALTER TABLE `" + tablePrefix + "skills` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case FISHING:
|
case FISHING:
|
||||||
sql = "SELECT * FROM `" + tablePrefix + "experience` ORDER BY `" + tablePrefix + "experience`.`fishing` ASC LIMIT 0 , 30";
|
sql = "SELECT * FROM `" + tablePrefix + "experience` ORDER BY `" + tablePrefix + "experience`.`fishing` ASC LIMIT 0 , 30";
|
||||||
break;
|
break;
|
||||||
@@ -557,12 +560,44 @@ public final class SQLDatabaseManager {
|
|||||||
+ "ADD INDEX `idx_acrobatics` (`acrobatics`) USING BTREE, "
|
+ "ADD INDEX `idx_acrobatics` (`acrobatics`) USING BTREE, "
|
||||||
+ "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;");
|
+ "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;");
|
||||||
}
|
}
|
||||||
break;
|
return;
|
||||||
|
|
||||||
case MOB_HEALTHBARS:
|
case MOB_HEALTHBARS:
|
||||||
sql = "SELECT * FROM `" + tablePrefix + "huds` ORDER BY `" + tablePrefix + "huds`.`mobhealthbar` ASC LIMIT 0 , 30";
|
sql = "SELECT * FROM `" + tablePrefix + "huds` ORDER BY `" + tablePrefix + "huds`.`mobhealthbar` ASC LIMIT 0 , 30";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PARTY_NAMES:
|
||||||
|
write("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;");
|
||||||
|
return;
|
||||||
|
|
||||||
|
case KILL_ORPHANS:
|
||||||
|
mcMMO.p.getLogger().info("Killing orphans");
|
||||||
|
write(
|
||||||
|
"DELETE FROM " + tablePrefix + "experience " +
|
||||||
|
"WHERE NOT EXISTS (SELECT * FROM " +
|
||||||
|
tablePrefix + "users u WHERE " +
|
||||||
|
tablePrefix + "experience.user_id = u.id);"
|
||||||
|
);
|
||||||
|
write(
|
||||||
|
"DELETE FROM " + tablePrefix + "huds " +
|
||||||
|
"WHERE NOT EXISTS (SELECT * FROM " +
|
||||||
|
tablePrefix + "users u WHERE " +
|
||||||
|
tablePrefix + "huds.user_id = u.id);"
|
||||||
|
);
|
||||||
|
write(
|
||||||
|
"DELETE FROM " + tablePrefix + "cooldowns " +
|
||||||
|
"WHERE NOT EXISTS (SELECT * FROM " +
|
||||||
|
tablePrefix + "users u WHERE " +
|
||||||
|
tablePrefix + "cooldowns.user_id = u.id);"
|
||||||
|
);
|
||||||
|
write(
|
||||||
|
"DELETE FROM " + tablePrefix + "skills " +
|
||||||
|
"WHERE NOT EXISTS (SELECT * FROM " +
|
||||||
|
tablePrefix + "users u WHERE " +
|
||||||
|
tablePrefix + "skills.user_id = u.id);"
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -601,7 +636,7 @@ public final class SQLDatabaseManager {
|
|||||||
|
|
||||||
case MOB_HEALTHBARS:
|
case MOB_HEALTHBARS:
|
||||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for mob healthbars...");
|
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for mob healthbars...");
|
||||||
write("ALTER TABLE `" + tablePrefix + "huds` ADD `mobhealthbar` varchar(50) NOT NULL DEFAULT 'HEARTS' ;");
|
write("ALTER TABLE `" + tablePrefix + "huds` ADD `mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "' ;");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package com.gmail.nossr50.datatypes.database;
|
|||||||
public enum DatabaseUpdateType {
|
public enum DatabaseUpdateType {
|
||||||
FISHING,
|
FISHING,
|
||||||
BLAST_MINING,
|
BLAST_MINING,
|
||||||
CASCADE_DELETE,
|
|
||||||
INDEX,
|
INDEX,
|
||||||
MOB_HEALTHBARS;
|
MOB_HEALTHBARS,
|
||||||
|
PARTY_NAMES,
|
||||||
|
KILL_ORPHANS,
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.bukkit.OfflinePlayer;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
import com.gmail.nossr50.party.ShareHandler.ShareMode;
|
||||||
|
|
||||||
public class Party {
|
public class Party {
|
||||||
@@ -62,25 +63,24 @@ public class Party {
|
|||||||
public List<String> getItemShareCategories() {
|
public List<String> getItemShareCategories() {
|
||||||
List<String> shareCategories = new ArrayList<String>();
|
List<String> shareCategories = new ArrayList<String>();
|
||||||
|
|
||||||
// TODO Locale the category names!
|
|
||||||
if (shareLootDrops) {
|
if (shareLootDrops) {
|
||||||
shareCategories.add("Loot");
|
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Loot"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shareMiningDrops) {
|
if (shareMiningDrops) {
|
||||||
shareCategories.add("Mining");
|
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Mining"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shareHerbalismDrops) {
|
if (shareHerbalismDrops) {
|
||||||
shareCategories.add("Herbalism");
|
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Herbalism"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shareWoodcuttingDrops) {
|
if (shareWoodcuttingDrops) {
|
||||||
shareCategories.add("Woodcutting");
|
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Woodcutting"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shareMiscDrops) {
|
if (shareMiscDrops) {
|
||||||
shareCategories.add("Misc");
|
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Misc"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return shareCategories;
|
return shareCategories;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
|||||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
|
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||||
@@ -93,7 +94,7 @@ public class McMMOPlayer {
|
|||||||
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
profile = new PlayerProfile(playerName, true);
|
profile = new PlayerProfile(playerName, true);
|
||||||
party = PartyManager.getPlayerParty(playerName);
|
party = mcMMO.getPartyManager().getPlayerParty(playerName);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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),
|
||||||
@@ -182,7 +183,8 @@ public class McMMOPlayer {
|
|||||||
*/
|
*/
|
||||||
public void resetAbilityMode() {
|
public void resetAbilityMode() {
|
||||||
for (AbilityType ability : AbilityType.values()) {
|
for (AbilityType ability : AbilityType.values()) {
|
||||||
setAbilityMode(ability, false);
|
// Correctly disable and handle any special deactivate code
|
||||||
|
new AbilityDisableTask(this, ability).run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,11 +441,7 @@ public class McMMOPlayer {
|
|||||||
public int getPowerLevel() {
|
public int getPowerLevel() {
|
||||||
int powerLevel = 0;
|
int powerLevel = 0;
|
||||||
|
|
||||||
for (SkillType type : SkillType.values()) {
|
for (SkillType type : SkillType.nonChildSkills()) {
|
||||||
if (type.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Permissions.skillEnabled(player, type)) {
|
if (Permissions.skillEnabled(player, type)) {
|
||||||
powerLevel += profile.getSkillLevel(type);
|
powerLevel += profile.getSkillLevel(type);
|
||||||
}
|
}
|
||||||
@@ -506,14 +504,15 @@ public class McMMOPlayer {
|
|||||||
Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
|
Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
|
||||||
|
|
||||||
for (SkillType parentSkill : parentSkills) {
|
for (SkillType parentSkill : parentSkills) {
|
||||||
if (Permissions.skillEnabled(player, parentSkill)) {
|
applyXpGain(parentSkill, xp / parentSkills.size());
|
||||||
applyXpGain(parentSkill, xp / parentSkills.size());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Permissions.skillEnabled(player, skillType)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp);
|
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|||||||
@@ -42,18 +42,14 @@ public class PlayerProfile {
|
|||||||
public PlayerProfile(String playerName, boolean addNew) {
|
public PlayerProfile(String playerName, boolean addNew) {
|
||||||
this.playerName = playerName;
|
this.playerName = playerName;
|
||||||
|
|
||||||
hudType = mcMMO.spoutEnabled ? SpoutConfig.getInstance().getDefaultHudType() : HudType.DISABLED;
|
hudType = mcMMO.isSpoutEnabled() ? SpoutConfig.getInstance().getDefaultHudType() : HudType.DISABLED;
|
||||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||||
|
|
||||||
for (AbilityType abilityType : AbilityType.values()) {
|
for (AbilityType abilityType : AbilityType.values()) {
|
||||||
skillsDATS.put(abilityType, 0);
|
skillsDATS.put(abilityType, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
skills.put(skillType, 0);
|
skills.put(skillType, 0);
|
||||||
skillsXp.put(skillType, 0F);
|
skillsXp.put(skillType, 0F);
|
||||||
}
|
}
|
||||||
@@ -257,7 +253,7 @@ public class PlayerProfile {
|
|||||||
* @return the Xp remaining until next level
|
* @return the Xp remaining until next level
|
||||||
*/
|
*/
|
||||||
public int getXpToLevel(SkillType skillType) {
|
public int getXpToLevel(SkillType skillType) {
|
||||||
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
|
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getChildSkillLevel(SkillType skillType) {
|
private int getChildSkillLevel(SkillType skillType) {
|
||||||
@@ -287,80 +283,111 @@ public class PlayerProfile {
|
|||||||
private boolean loadMySQL() {
|
private boolean loadMySQL() {
|
||||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||||
|
|
||||||
userId = SQLDatabaseManager.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
ArrayList<String> playerData = SQLDatabaseManager.read(
|
||||||
|
"SELECT " +
|
||||||
|
"u.id, " +
|
||||||
|
"s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, " +
|
||||||
|
"e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, " +
|
||||||
|
"c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, " +
|
||||||
|
"h.hudtype, h.mobhealthbar " +
|
||||||
|
"FROM " + tablePrefix + "users u " +
|
||||||
|
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " +
|
||||||
|
"WHERE u.user = '" + playerName + "'"
|
||||||
|
).get(1);
|
||||||
|
|
||||||
if (userId == 0) {
|
if (playerData == null || playerData.size() == 0) {
|
||||||
return false;
|
userId = SQLDatabaseManager.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||||
|
|
||||||
|
// Check if user doesn't exist
|
||||||
|
if (userId == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write missing table rows
|
||||||
|
SQLDatabaseManager.write("INSERT IGNORE INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||||
|
SQLDatabaseManager.write("INSERT IGNORE INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||||
|
SQLDatabaseManager.write("INSERT IGNORE INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||||
|
SQLDatabaseManager.write("INSERT IGNORE INTO " + tablePrefix + "huds (user_id, mobhealthbar) VALUES (" + userId + ",'" + mobHealthbarType.name() + "')");
|
||||||
|
|
||||||
|
// Re-read data
|
||||||
|
playerData = SQLDatabaseManager.read(
|
||||||
|
"SELECT " +
|
||||||
|
"u.id, " +
|
||||||
|
"s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, " +
|
||||||
|
"e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, " +
|
||||||
|
"c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, " +
|
||||||
|
"h.hudtype, h.mobhealthbar " +
|
||||||
|
"FROM " + tablePrefix + "users u " +
|
||||||
|
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " +
|
||||||
|
"JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " +
|
||||||
|
"WHERE u.user = '" + playerName + "'"
|
||||||
|
).get(1);
|
||||||
|
|
||||||
|
// Should never happen but just in case
|
||||||
|
if (playerData == null || playerData.size() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> hudValues = SQLDatabaseManager.read("SELECT hudtype, mobhealthbar FROM " + tablePrefix + "huds WHERE user_id = " + userId).get(1);
|
userId = Integer.valueOf(playerData.get(0));
|
||||||
|
|
||||||
if (hudValues == null) {
|
skills.put(SkillType.TAMING, Integer.valueOf(playerData.get(1)));
|
||||||
SQLDatabaseManager.write("INSERT INTO " + tablePrefix + "huds (user_id, mobhealthbar) VALUES (" + userId + ",'" + mobHealthbarType.name() + "')");
|
skills.put(SkillType.MINING, Integer.valueOf(playerData.get(2)));
|
||||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the HUD table. Their HUDs will be reset.");
|
skills.put(SkillType.REPAIR, Integer.valueOf(playerData.get(3)));
|
||||||
|
skills.put(SkillType.WOODCUTTING, Integer.valueOf(playerData.get(4)));
|
||||||
|
skills.put(SkillType.UNARMED, Integer.valueOf(playerData.get(5)));
|
||||||
|
skills.put(SkillType.HERBALISM, Integer.valueOf(playerData.get(6)));
|
||||||
|
skills.put(SkillType.EXCAVATION, Integer.valueOf(playerData.get(7)));
|
||||||
|
skills.put(SkillType.ARCHERY, Integer.valueOf(playerData.get(8)));
|
||||||
|
skills.put(SkillType.SWORDS, Integer.valueOf(playerData.get(9)));
|
||||||
|
skills.put(SkillType.AXES, Integer.valueOf(playerData.get(10)));
|
||||||
|
skills.put(SkillType.ACROBATICS, Integer.valueOf(playerData.get(11)));
|
||||||
|
skills.put(SkillType.FISHING, Integer.valueOf(playerData.get(12)));
|
||||||
|
|
||||||
|
skillsXp.put(SkillType.TAMING, (float) Integer.valueOf(playerData.get(13)));
|
||||||
|
skillsXp.put(SkillType.MINING, (float) Integer.valueOf(playerData.get(14)));
|
||||||
|
skillsXp.put(SkillType.REPAIR, (float) Integer.valueOf(playerData.get(15)));
|
||||||
|
skillsXp.put(SkillType.WOODCUTTING, (float) Integer.valueOf(playerData.get(16)));
|
||||||
|
skillsXp.put(SkillType.UNARMED, (float) Integer.valueOf(playerData.get(17)));
|
||||||
|
skillsXp.put(SkillType.HERBALISM, (float) Integer.valueOf(playerData.get(18)));
|
||||||
|
skillsXp.put(SkillType.EXCAVATION, (float) Integer.valueOf(playerData.get(19)));
|
||||||
|
skillsXp.put(SkillType.ARCHERY, (float) Integer.valueOf(playerData.get(20)));
|
||||||
|
skillsXp.put(SkillType.SWORDS, (float) Integer.valueOf(playerData.get(21)));
|
||||||
|
skillsXp.put(SkillType.AXES, (float) Integer.valueOf(playerData.get(22)));
|
||||||
|
skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(playerData.get(23)));
|
||||||
|
skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(playerData.get(24)));
|
||||||
|
|
||||||
|
// Taming 25 - Unused
|
||||||
|
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(playerData.get(26)));
|
||||||
|
// Repair 27 - Unused
|
||||||
|
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(playerData.get(28)));
|
||||||
|
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(playerData.get(29)));
|
||||||
|
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(playerData.get(30)));
|
||||||
|
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(playerData.get(31)));
|
||||||
|
// Archery 32 - Unused
|
||||||
|
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(playerData.get(33)));
|
||||||
|
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(playerData.get(34)));
|
||||||
|
// Acrobatics 35 - Unused
|
||||||
|
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(playerData.get(36)));
|
||||||
|
|
||||||
|
try {
|
||||||
|
hudType = HudType.valueOf(playerData.get(37));
|
||||||
}
|
}
|
||||||
else {
|
catch (Exception e) {
|
||||||
hudType = HudType.valueOf(hudValues.get(0));
|
// Shouldn't happen unless database is being tampered with
|
||||||
mobHealthbarType = MobHealthbarType.valueOf(hudValues.get(1));
|
hudType = HudType.STANDARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<String> cooldownValues = SQLDatabaseManager.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + tablePrefix + "cooldowns WHERE user_id = " + userId).get(1);
|
try {
|
||||||
|
mobHealthbarType = MobHealthbarType.valueOf(playerData.get(38));
|
||||||
if (cooldownValues == null) {
|
|
||||||
SQLDatabaseManager.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
|
||||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the cooldown table. Their cooldowns will be reset.");
|
|
||||||
}
|
}
|
||||||
else {
|
catch (Exception e) {
|
||||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(cooldownValues.get(0)));
|
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||||
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(cooldownValues.get(1)));
|
|
||||||
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(cooldownValues.get(2)));
|
|
||||||
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(cooldownValues.get(3)));
|
|
||||||
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(cooldownValues.get(4)));
|
|
||||||
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(cooldownValues.get(5)));
|
|
||||||
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(cooldownValues.get(6)));
|
|
||||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldownValues.get(7)));
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<String> statValues = SQLDatabaseManager.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "skills WHERE user_id = " + userId).get(1);
|
|
||||||
|
|
||||||
if (statValues == null) {
|
|
||||||
SQLDatabaseManager.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
|
||||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the skills table. Their stats will be reset.");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skills.put(SkillType.TAMING, Integer.valueOf(statValues.get(0)));
|
|
||||||
skills.put(SkillType.MINING, Integer.valueOf(statValues.get(1)));
|
|
||||||
skills.put(SkillType.REPAIR, Integer.valueOf(statValues.get(2)));
|
|
||||||
skills.put(SkillType.WOODCUTTING, Integer.valueOf(statValues.get(3)));
|
|
||||||
skills.put(SkillType.UNARMED, Integer.valueOf(statValues.get(4)));
|
|
||||||
skills.put(SkillType.HERBALISM, Integer.valueOf(statValues.get(5)));
|
|
||||||
skills.put(SkillType.EXCAVATION, Integer.valueOf(statValues.get(6)));
|
|
||||||
skills.put(SkillType.ARCHERY, Integer.valueOf(statValues.get(7)));
|
|
||||||
skills.put(SkillType.SWORDS, Integer.valueOf(statValues.get(8)));
|
|
||||||
skills.put(SkillType.AXES, Integer.valueOf(statValues.get(9)));
|
|
||||||
skills.put(SkillType.ACROBATICS, Integer.valueOf(statValues.get(10)));
|
|
||||||
skills.put(SkillType.FISHING, Integer.valueOf(statValues.get(11)));
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<String> experienceValues = SQLDatabaseManager.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "experience WHERE user_id = " + userId).get(1);
|
|
||||||
|
|
||||||
if (experienceValues == null) {
|
|
||||||
SQLDatabaseManager.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
|
||||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the experience table. Their experience will be reset.");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skillsXp.put(SkillType.TAMING, (float) Integer.valueOf(experienceValues.get(0)));
|
|
||||||
skillsXp.put(SkillType.MINING, (float) Integer.valueOf(experienceValues.get(1)));
|
|
||||||
skillsXp.put(SkillType.REPAIR, (float) Integer.valueOf(experienceValues.get(2)));
|
|
||||||
skillsXp.put(SkillType.WOODCUTTING, (float) Integer.valueOf(experienceValues.get(3)));
|
|
||||||
skillsXp.put(SkillType.UNARMED, (float) Integer.valueOf(experienceValues.get(4)));
|
|
||||||
skillsXp.put(SkillType.HERBALISM, (float) Integer.valueOf(experienceValues.get(5)));
|
|
||||||
skillsXp.put(SkillType.EXCAVATION, (float) Integer.valueOf(experienceValues.get(6)));
|
|
||||||
skillsXp.put(SkillType.ARCHERY, (float) Integer.valueOf(experienceValues.get(7)));
|
|
||||||
skillsXp.put(SkillType.SWORDS, (float) Integer.valueOf(experienceValues.get(8)));
|
|
||||||
skillsXp.put(SkillType.AXES, (float) Integer.valueOf(experienceValues.get(9)));
|
|
||||||
skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(experienceValues.get(10)));
|
|
||||||
skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(experienceValues.get(11)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|||||||
@@ -68,6 +68,13 @@ public enum AbilityType {
|
|||||||
null),
|
null),
|
||||||
|
|
||||||
LEAF_BLOWER(
|
LEAF_BLOWER(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null),
|
||||||
|
|
||||||
|
BLOCK_CRACKER(
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -144,7 +151,6 @@ public enum AbilityType {
|
|||||||
* @return true if the player has permissions, false otherwise
|
* @return true if the player has permissions, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean getPermissions(Player player) {
|
public boolean getPermissions(Player player) {
|
||||||
|
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case BERSERK:
|
case BERSERK:
|
||||||
return Permissions.berserk(player);
|
return Permissions.berserk(player);
|
||||||
@@ -152,6 +158,9 @@ public enum AbilityType {
|
|||||||
case BLAST_MINING:
|
case BLAST_MINING:
|
||||||
return Permissions.remoteDetonation(player);
|
return Permissions.remoteDetonation(player);
|
||||||
|
|
||||||
|
case BLOCK_CRACKER:
|
||||||
|
return Permissions.blockCracker(player);
|
||||||
|
|
||||||
case GIGA_DRILL_BREAKER:
|
case GIGA_DRILL_BREAKER:
|
||||||
return Permissions.gigaDrillBreaker(player);
|
return Permissions.gigaDrillBreaker(player);
|
||||||
|
|
||||||
@@ -189,6 +198,9 @@ public enum AbilityType {
|
|||||||
case BERSERK:
|
case BERSERK:
|
||||||
return (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW);
|
return (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW);
|
||||||
|
|
||||||
|
case BLOCK_CRACKER:
|
||||||
|
return BlockUtils.affectedByBlockCracker(blockState);
|
||||||
|
|
||||||
case GIGA_DRILL_BREAKER:
|
case GIGA_DRILL_BREAKER:
|
||||||
return BlockUtils.affectedByGigaDrillBreaker(blockState);
|
return BlockUtils.affectedByGigaDrillBreaker(blockState);
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public enum SkillType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double getXpModifier() {
|
public double getXpModifier() {
|
||||||
return Config.getInstance().getForumulaMultiplier(this);
|
return Config.getInstance().getFormulaSkillModifier(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SkillType getSkill(String skillName) {
|
public static SkillType getSkill(String skillName) {
|
||||||
@@ -141,7 +141,36 @@ public enum SkillType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SkillType[] nonChildSkills() {
|
||||||
|
return new SkillType[] {SkillType.ACROBATICS,
|
||||||
|
SkillType.ARCHERY,
|
||||||
|
SkillType.AXES,
|
||||||
|
SkillType.EXCAVATION,
|
||||||
|
SkillType.FISHING,
|
||||||
|
SkillType.HERBALISM,
|
||||||
|
SkillType.MINING,
|
||||||
|
SkillType.REPAIR,
|
||||||
|
SkillType.SWORDS,
|
||||||
|
SkillType.TAMING,
|
||||||
|
SkillType.UNARMED,
|
||||||
|
SkillType.WOODCUTTING };
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkillType[] childSkills() {
|
||||||
|
return new SkillType[] { SkillType.SMELTING };
|
||||||
|
}
|
||||||
|
|
||||||
public Color getRunescapeModeColor() {
|
public Color getRunescapeModeColor() {
|
||||||
return runescapeColor;
|
return runescapeColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SkillType byAbility(AbilityType ability) {
|
||||||
|
for (SkillType type : values()) {
|
||||||
|
if (type.getAbility() == ability) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
|
|||||||
|
|
||||||
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained) {
|
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained) {
|
||||||
super(player, skill);
|
super(player, skill);
|
||||||
this.setLevelsGained(levelsGained);
|
this.levelsGained = levelsGained;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.gmail.nossr50.events.fake;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Fish;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
|
|
||||||
|
public class FakePlayerFishEvent extends PlayerFishEvent {
|
||||||
|
public FakePlayerFishEvent(Player player, Entity entity, Fish hookEntity, State state) {
|
||||||
|
super(player, entity, hookEntity, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.gmail.nossr50.events.skills.abilities;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||||
|
|
||||||
|
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||||
|
|
||||||
|
private AbilityType abilityType;
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
public McMMOPlayerAbilityActivateEvent(Player player, SkillType skill) {
|
||||||
|
super(player, skill);
|
||||||
|
abilityType = skill.getAbility();
|
||||||
|
cancelled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The ability type involved in this event
|
||||||
|
*/
|
||||||
|
public AbilityType getAbilityType() {
|
||||||
|
return abilityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean value) {
|
||||||
|
this.cancelled = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.gmail.nossr50.events.skills.abilities;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||||
|
|
||||||
|
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerSkillEvent {
|
||||||
|
|
||||||
|
private AbilityType ability;
|
||||||
|
|
||||||
|
public McMMOPlayerAbilityDeactivateEvent(Player player, SkillType skill) {
|
||||||
|
super(player, skill);
|
||||||
|
this.ability = skill.getAbility();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbilityType getAbility() {
|
||||||
|
return ability;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.gmail.nossr50.events.skills.fishing;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||||
|
|
||||||
|
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||||
|
|
||||||
|
private boolean cancelled = false;
|
||||||
|
private ItemStack treasure;
|
||||||
|
private int xp;
|
||||||
|
|
||||||
|
public McMMOPlayerFishingTreasureEvent(Player player, ItemStack treasure, int xp) {
|
||||||
|
super(player, SkillType.FISHING);
|
||||||
|
this.treasure = treasure;
|
||||||
|
this.xp = xp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getTreasure() {
|
||||||
|
return treasure;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTreasure(ItemStack item) {
|
||||||
|
this.treasure = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean newValue) {
|
||||||
|
this.cancelled = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getXp() {
|
||||||
|
return xp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXp(int xp) {
|
||||||
|
this.xp = xp;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.gmail.nossr50.events.skills.fishing;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class McMMOPlayerMagicHunterEvent extends McMMOPlayerFishingTreasureEvent {
|
||||||
|
|
||||||
|
private Map<Enchantment, Integer> enchants;
|
||||||
|
|
||||||
|
public McMMOPlayerMagicHunterEvent(Player player, ItemStack treasure, int xp, Map<Enchantment, Integer> enchants) {
|
||||||
|
super(player, treasure, xp);
|
||||||
|
this.enchants = enchants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Enchantment, Integer> getEnchantments() {
|
||||||
|
return enchants;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.gmail.nossr50.events.skills.fishing;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
|
||||||
|
|
||||||
|
public class McMMOPlayerShakeEvent extends McMMOPlayerSkillEvent implements Cancellable {
|
||||||
|
|
||||||
|
private boolean cancelled = false;
|
||||||
|
private ItemStack drop;
|
||||||
|
|
||||||
|
public McMMOPlayerShakeEvent(Player player, ItemStack drop) {
|
||||||
|
super(player, SkillType.FISHING);
|
||||||
|
this.drop = drop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(boolean newValue) {
|
||||||
|
this.cancelled = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getDrop() {
|
||||||
|
return drop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDrop(ItemStack drop) {
|
||||||
|
this.drop = drop;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -28,14 +28,12 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
|
||||||
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
|
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
|
||||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||||
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.Repair;
|
||||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||||
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.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
@@ -72,9 +70,11 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Block b : blocks) {
|
for (Block b : blocks) {
|
||||||
if (b.getRelative(direction).hasMetadata(mcMMO.blockMetadataKey)) {
|
Block nextBlock = b.getRelative(direction);
|
||||||
mcMMO.getPlaceStore().setTrue(b.getRelative(direction));
|
|
||||||
b.getRelative(direction).removeMetadata(mcMMO.blockMetadataKey, plugin);
|
if (nextBlock.hasMetadata(mcMMO.blockMetadataKey)) {
|
||||||
|
mcMMO.getPlaceStore().setTrue(nextBlock);
|
||||||
|
nextBlock.removeMetadata(mcMMO.blockMetadataKey, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,15 +106,14 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlockState blockState = event.getBlock().getState();
|
BlockState blockState = event.getBlock().getState();
|
||||||
int blockId = blockState.getTypeId();
|
|
||||||
|
|
||||||
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
|
||||||
if (BlockUtils.shouldBeWatched(blockState)) {
|
if (BlockUtils.shouldBeWatched(blockState)) {
|
||||||
mcMMO.getPlaceStore().setTrue(blockState);
|
mcMMO.getPlaceStore().setTrue(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Repair.anvilMessagesEnabled && (blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId)) {
|
if (Repair.anvilMessagesEnabled && BlockUtils.isMcMMOAnvil(blockState)) {
|
||||||
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockId);
|
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getTypeId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,41 +322,31 @@ public class BlockListener implements Listener {
|
|||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
BlockState blockState = block.getState();
|
BlockState blockState = block.getState();
|
||||||
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ABILITY TRIGGER CHECKS
|
* ABILITY TRIGGER CHECKS
|
||||||
*
|
*
|
||||||
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
||||||
*/
|
*/
|
||||||
if (herbalismManager.canGreenTerraBlock(blockState)) {
|
if (mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) {
|
||||||
if (herbalismManager.processGreenTerra(blockState)) {
|
if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) {
|
||||||
blockState.update(true);
|
blockState.update(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
|
else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
|
||||||
if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) {
|
if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||||
if (heldItem.getType() == Material.AIR) {
|
event.setInstaBreak(true);
|
||||||
plugin.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player));
|
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
||||||
|
|
||||||
event.setInstaBreak(true);
|
|
||||||
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Another perm check for the cracked blocks activation
|
else if (Permissions.blockCracker(player) && SkillUtils.triggerCheck(player, block, AbilityType.BLOCK_CRACKER)) {
|
||||||
else if (BlockUtils.affectedByBlockCracker(blockState)) {
|
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
|
||||||
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
|
||||||
|
|
||||||
if (unarmedManager.canUseBlockCracker() && SkillUtils.blockBreakSimulate(block, player, false) && unarmedManager.blockCrackerCheck(blockState)) {
|
|
||||||
blockState.update();
|
blockState.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (BlockUtils.isLeaves(blockState)) {
|
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||||
if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.blockBreakSimulate(block, player, true)) {
|
event.setInstaBreak(true);
|
||||||
event.setInstaBreak(true);
|
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
||||||
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.gmail.nossr50.listeners;
|
|||||||
|
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.AnimalTamer;
|
import org.bukkit.entity.AnimalTamer;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.FallingBlock;
|
import org.bukkit.entity.FallingBlock;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@@ -15,19 +17,22 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||||
import org.bukkit.event.entity.EntityTameEvent;
|
import org.bukkit.event.entity.EntityTameEvent;
|
||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||||
@@ -52,13 +57,35 @@ public class EntityListener implements Listener {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onEntityShootBow(EntityShootBowEvent event) {
|
||||||
|
ItemStack bow = event.getBow();
|
||||||
|
|
||||||
|
if (bow == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity projectile = event.getProjectile();
|
||||||
|
|
||||||
|
if (!(projectile instanceof Arrow)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bow.containsEnchantment(Enchantment.ARROW_INFINITE)) {
|
||||||
|
projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, Math.min(event.getForce() * AdvancedConfig.getInstance().getForceMultiplier(), 1.0)));
|
||||||
|
projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, Archery.locationToString(projectile.getLocation())));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitor EntityChangeBlock events.
|
* Monitor EntityChangeBlock events.
|
||||||
*
|
*
|
||||||
* @param event The event to watch
|
* @param event The event to watch
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
|
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
if (!(entity instanceof FallingBlock)) {
|
if (!(entity instanceof FallingBlock)) {
|
||||||
@@ -84,7 +111,13 @@ public class EntityListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||||
if (event instanceof FakeEntityDamageByEntityEvent || event.getDamage() <= 0) {
|
if (event instanceof FakeEntityDamageByEntityEvent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int damage = event.getDamage();
|
||||||
|
|
||||||
|
if (damage <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,13 +127,14 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity attacker = event.getDamager();
|
|
||||||
LivingEntity target = (LivingEntity) defender;
|
LivingEntity target = (LivingEntity) defender;
|
||||||
|
|
||||||
if (CombatUtils.isInvincible(target, event.getDamage())) {
|
if (CombatUtils.isInvincible(target, damage)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Entity attacker = event.getDamager();
|
||||||
|
|
||||||
if (attacker instanceof Projectile) {
|
if (attacker instanceof Projectile) {
|
||||||
attacker = ((Projectile) attacker).getShooter();
|
attacker = ((Projectile) attacker).getShooter();
|
||||||
}
|
}
|
||||||
@@ -121,7 +155,7 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PartyManager.inSameParty(defendingPlayer, attackingPlayer) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
|
if (mcMMO.getPartyManager().inSameParty(defendingPlayer, attackingPlayer) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -137,7 +171,13 @@ public class EntityListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onEntityDamage(EntityDamageEvent event) {
|
public void onEntityDamage(EntityDamageEvent event) {
|
||||||
if (event instanceof FakeEntityDamageEvent || event.getDamage() <= 0) {
|
if (event instanceof FakeEntityDamageEvent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int damage = event.getDamage();
|
||||||
|
|
||||||
|
if (damage <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,13 +187,14 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DamageCause cause = event.getCause();
|
|
||||||
LivingEntity livingEntity = (LivingEntity) entity;
|
LivingEntity livingEntity = (LivingEntity) entity;
|
||||||
|
|
||||||
if (CombatUtils.isInvincible(livingEntity, event.getDamage())) {
|
if (CombatUtils.isInvincible(livingEntity, damage)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DamageCause cause = event.getCause();
|
||||||
|
|
||||||
if (livingEntity instanceof Player) {
|
if (livingEntity instanceof Player) {
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
|
|
||||||
@@ -286,7 +327,6 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.setFireTicks(0);
|
|
||||||
BleedTimerTask.remove(entity);
|
BleedTimerTask.remove(entity);
|
||||||
Archery.arrowRetrievalCheck(entity);
|
Archery.arrowRetrievalCheck(entity);
|
||||||
}
|
}
|
||||||
@@ -298,14 +338,21 @@ public class EntityListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
if (Misc.isSpawnerXPEnabled) {
|
switch (event.getSpawnReason()) {
|
||||||
return;
|
case SPAWNER:
|
||||||
}
|
case SPAWNER_EGG:
|
||||||
|
LivingEntity entity = event.getEntity();
|
||||||
|
Entity passenger = entity.getPassenger();
|
||||||
|
|
||||||
SpawnReason reason = event.getSpawnReason();
|
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||||
|
|
||||||
if (reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG) {
|
if (passenger != null) {
|
||||||
event.getEntity().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,19 +365,21 @@ public class EntityListener implements Listener {
|
|||||||
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
if (entity instanceof TNTPrimed && entity.hasMetadata(mcMMO.tntMetadataKey)) {
|
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
|
||||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
return;
|
||||||
Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
}
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||||
return;
|
Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||||
}
|
|
||||||
|
|
||||||
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
if (Misc.isNPCEntity(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (miningManager.canUseBiggerBombs()) {
|
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
||||||
event.setRadius(miningManager.biggerBombs(event.getRadius()));
|
|
||||||
}
|
if (miningManager.canUseBiggerBombs()) {
|
||||||
|
event.setRadius(miningManager.biggerBombs(event.getRadius()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,20 +392,22 @@ public class EntityListener implements Listener {
|
|||||||
public void onEnitityExplode(EntityExplodeEvent event) {
|
public void onEnitityExplode(EntityExplodeEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
if (entity instanceof TNTPrimed && entity.hasMetadata(mcMMO.tntMetadataKey)) {
|
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
|
||||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
return;
|
||||||
Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
}
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||||
return;
|
Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||||
}
|
|
||||||
|
|
||||||
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
if (Misc.isNPCEntity(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (miningManager.canUseBlastMining()) {
|
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
||||||
miningManager.blastMiningDropProcessing(event.getYield(), event.blockList());
|
|
||||||
event.setYield(0);
|
if (miningManager.canUseBlastMining()) {
|
||||||
}
|
miningManager.blastMiningDropProcessing(event.getYield(), event.blockList());
|
||||||
|
event.setYield(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,63 +420,65 @@ public class EntityListener implements Listener {
|
|||||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
if (entity instanceof Player) {
|
if (!(entity instanceof Player)) {
|
||||||
Player player = (Player) entity;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
Player player = (Player) entity;
|
||||||
|
|
||||||
|
if (Misc.isNPCEntity(player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentFoodLevel = player.getFoodLevel();
|
||||||
|
int newFoodLevel = event.getFoodLevel();
|
||||||
|
int foodChange = newFoodLevel - currentFoodLevel;
|
||||||
|
|
||||||
|
if (foodChange <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some foods have 3 ranks
|
||||||
|
* Some foods have 5 ranks
|
||||||
|
* The number of ranks is based on how 'common' the item is
|
||||||
|
* We can adjust this quite easily if we find something is giving too much of a bonus
|
||||||
|
*/
|
||||||
|
switch (player.getItemInHand().getType()) {
|
||||||
|
case BAKED_POTATO: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||||
|
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||||
|
case CARROT_ITEM: /* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */
|
||||||
|
case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||||
|
case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||||
|
case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||||
|
if (Permissions.farmersDiet(player)) {
|
||||||
|
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
int currentFoodLevel = player.getFoodLevel();
|
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||||
int newFoodLevel = event.getFoodLevel();
|
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||||
int foodChange = newFoodLevel - currentFoodLevel;
|
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||||
|
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||||
if (foodChange <= 0) {
|
if (Permissions.farmersDiet(player)) {
|
||||||
|
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||||
* Some foods have 3 ranks
|
if (Permissions.fishermansDiet(player)) {
|
||||||
* Some foods have 5 ranks
|
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
|
||||||
* The number of ranks is based on how 'common' the item is
|
}
|
||||||
* We can adjust this quite easily if we find something is giving too much of a bonus
|
return;
|
||||||
*/
|
|
||||||
switch (player.getItemInHand().getType()) {
|
|
||||||
case BAKED_POTATO: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
|
||||||
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
|
||||||
case CARROT_ITEM: /* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */
|
|
||||||
case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
|
||||||
case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
|
||||||
case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
|
||||||
if (Permissions.farmersDiet(player)) {
|
|
||||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||||
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
if (Permissions.fishermansDiet(player)) {
|
||||||
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
|
||||||
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
}
|
||||||
if (Permissions.farmersDiet(player)) {
|
return;
|
||||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
default:
|
||||||
if (Permissions.fishermansDiet(player)) {
|
return;
|
||||||
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
|
||||||
if (Permissions.fishermansDiet(player)) {
|
|
||||||
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.block.Furnace;
|
import org.bukkit.block.Furnace;
|
||||||
@@ -19,8 +22,10 @@ import org.bukkit.inventory.FurnaceInventory;
|
|||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
import org.bukkit.metadata.MetadataValue;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
@@ -96,10 +101,11 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
if (furnaceState instanceof Furnace) {
|
if (furnaceState instanceof Furnace) {
|
||||||
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
|
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
|
||||||
|
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
|
||||||
|
|
||||||
if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
if (!metadata.isEmpty() && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
||||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||||
Player player = plugin.getServer().getPlayer(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString());
|
Player player = plugin.getServer().getPlayer(metadata.get(0).asString());
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || !Permissions.fuelEfficiency(player)) {
|
if (Misc.isNPCEntity(player) || !Permissions.fuelEfficiency(player)) {
|
||||||
return;
|
return;
|
||||||
@@ -117,10 +123,19 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
if (furnaceState instanceof Furnace) {
|
if (furnaceState instanceof Furnace) {
|
||||||
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
|
ItemStack smelting = ((Furnace) furnaceState).getInventory().getSmelting();
|
||||||
|
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
|
||||||
|
|
||||||
if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
if (Config.getInstance().getPotatoEnabled() && smelting.getType() == Material.POTATO_ITEM) {
|
||||||
|
if ((Config.getInstance().getPotatoChance() / 100.0) >= Misc.getRandom().nextDouble()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
furnaceState.getWorld().createExplosion(furnaceState.getLocation(), 4F, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!metadata.isEmpty() && smelting != null && ItemUtils.isSmeltable(smelting)) {
|
||||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||||
Player player = plugin.getServer().getPlayer(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString());
|
Player player = plugin.getServer().getPlayer(metadata.get(0).asString());
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.SMELTING)) {
|
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.SMELTING)) {
|
||||||
return;
|
return;
|
||||||
@@ -138,10 +153,11 @@ public class InventoryListener implements Listener {
|
|||||||
|
|
||||||
if (furnaceState instanceof Furnace) {
|
if (furnaceState instanceof Furnace) {
|
||||||
ItemStack result = ((Furnace) furnaceState).getInventory().getResult();
|
ItemStack result = ((Furnace) furnaceState).getInventory().getResult();
|
||||||
|
List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
|
||||||
|
|
||||||
if (furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && result != null && ItemUtils.isSmelted(result)) {
|
if (!metadata.isEmpty() && result != null && ItemUtils.isSmelted(result)) {
|
||||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||||
Player player = plugin.getServer().getPlayer(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).get(0).asString());
|
Player player = plugin.getServer().getPlayer(metadata.get(0).asString());
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player)) {
|
if (Misc.isNPCEntity(player)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Fish;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -54,6 +54,7 @@ import com.gmail.nossr50.util.MobHealthbarUtils;
|
|||||||
import com.gmail.nossr50.util.Motd;
|
import com.gmail.nossr50.util.Motd;
|
||||||
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;
|
||||||
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
@@ -144,6 +145,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UserManager.addUser(player).actualizeRespawnATS();
|
UserManager.addUser(player).actualizeRespawnATS();
|
||||||
|
ScoreboardManager.enablePowerLevelDisplay(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,6 +178,14 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
switch (event.getState()) {
|
switch (event.getState()) {
|
||||||
case FISHING:
|
case FISHING:
|
||||||
|
if (!Permissions.krakenBypass(player)) {
|
||||||
|
event.setCancelled(fishingManager.exploitPrevention());
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fishingManager.canMasterAngler()) {
|
if (fishingManager.canMasterAngler()) {
|
||||||
fishingManager.masterAngler(event.getHook());
|
fishingManager.masterAngler(event.getHook());
|
||||||
}
|
}
|
||||||
@@ -191,11 +201,22 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
case CAUGHT_ENTITY:
|
case CAUGHT_ENTITY:
|
||||||
Entity entity = event.getCaught();
|
Entity entity = event.getCaught();
|
||||||
|
|
||||||
if (fishingManager.canShake(entity)) {
|
if (fishingManager.canShake(entity)) {
|
||||||
fishingManager.shakeCheck((LivingEntity) entity);
|
fishingManager.shakeCheck((LivingEntity) entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IN_GROUND:
|
||||||
|
Fish hook = event.getHook();
|
||||||
|
Block block = event.getPlayer().getTargetBlock(null, 100);
|
||||||
|
|
||||||
|
if (fishingManager.canIceFish(block)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
fishingManager.iceFishing(hook, block);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -303,13 +324,20 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerInteractLowest(PlayerInteractEvent event) {
|
public void onPlayerInteractLowest(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
ItemStack heldItem = player.getItemInHand();
|
|
||||||
|
|
||||||
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
|
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
|
// This shouldn't be possible - this is probably a band-aid for a larger issue somewhere else.
|
||||||
|
if (mcMMOPlayer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MiningManager miningManager = mcMMOPlayer.getMiningManager();
|
||||||
|
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case RIGHT_CLICK_BLOCK:
|
case RIGHT_CLICK_BLOCK:
|
||||||
@@ -317,7 +345,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/* REPAIR CHECKS */
|
/* REPAIR CHECKS */
|
||||||
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||||
RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// Make sure the player knows what he's doing when trying to repair an enchanted item
|
// Make sure the player knows what he's doing when trying to repair an enchanted item
|
||||||
@@ -327,8 +355,8 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* SALVAGE CHECKS */
|
/* SALVAGE CHECKS */
|
||||||
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
|
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem) && !ItemUtils.isChainmailArmor(heldItem)) {
|
||||||
RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
// Make sure the player knows what he's doing when trying to salvage an enchanted item
|
// Make sure the player knows what he's doing when trying to salvage an enchanted item
|
||||||
@@ -354,22 +382,22 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
/* REPAIR CHECKS */
|
/* REPAIR CHECKS */
|
||||||
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
|
||||||
RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
|
|
||||||
// Cancel repairing an enchanted item
|
// Cancel repairing an enchanted item
|
||||||
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
|
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
|
||||||
UserManager.getPlayer(player).setLastAnvilUse(Repair.repairAnvilId, 0);
|
mcMMOPlayer.setLastAnvilUse(Repair.repairAnvilId, 0);
|
||||||
player.sendMessage(ChatColor.RED + "Repair cancelled!"); //TODO Locale!
|
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* SALVAGE CHECKS */
|
/* SALVAGE CHECKS */
|
||||||
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
|
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
|
||||||
RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
||||||
|
|
||||||
// Cancel salvaging an enchanted item
|
// Cancel salvaging an enchanted item
|
||||||
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
|
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
|
||||||
UserManager.getPlayer(player).setLastAnvilUse(Repair.salvageAnvilId, 0);
|
mcMMOPlayer.setLastAnvilUse(Repair.salvageAnvilId, 0);
|
||||||
player.sendMessage(ChatColor.RED + "Salvage cancelled!"); //TODO Locale!
|
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,6 +432,11 @@ public class PlayerListener implements Listener {
|
|||||||
ItemStack heldItem = player.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
|
// This shouldn't be possible - this is probably a band-aid for a larger issue somewhere else.
|
||||||
|
if (mcMMOPlayer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (event.getAction()) {
|
switch (event.getAction()) {
|
||||||
case RIGHT_CLICK_BLOCK:
|
case RIGHT_CLICK_BLOCK:
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
@@ -502,10 +535,16 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
|
if (mcMMOPlayer == null) {
|
||||||
|
mcMMO.p.debug(player.getName() + " is currently chatting, but has never logged on to the server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mcMMOPlayer.getPartyChatMode()) {
|
if (mcMMOPlayer.getPartyChatMode()) {
|
||||||
Party party = mcMMOPlayer.getParty();
|
Party party = mcMMOPlayer.getParty();
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
|
mcMMOPlayer.togglePartyChat();
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ import org.getspout.spoutapi.gui.Button;
|
|||||||
import org.getspout.spoutapi.gui.ScreenType;
|
import org.getspout.spoutapi.gui.ScreenType;
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton;
|
import com.gmail.nossr50.datatypes.spout.buttons.McMMOButton;
|
||||||
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||||
import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu;
|
import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.spout.SpoutUtils;
|
|
||||||
|
|
||||||
public class SpoutListener implements Listener {
|
public class SpoutListener implements Listener {
|
||||||
|
|
||||||
@@ -32,8 +32,8 @@ public class SpoutListener implements Listener {
|
|||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(spoutPlayer);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(spoutPlayer);
|
||||||
|
|
||||||
// TODO: Add custom titles based on skills
|
// TODO: Add custom titles based on skills
|
||||||
if (SpoutUtils.showPowerLevel) {
|
if (SpoutConfig.getInstance().getShowPowerLevel()) {
|
||||||
spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getName(), mcMMOPlayer.getPowerLevel()));
|
spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getTitle(), mcMMOPlayer.getPowerLevel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer.getProfile().setSpoutHud(new McMMOHud(mcMMOPlayer)); // Setup Party HUD stuff
|
mcMMOPlayer.getProfile().setSpoutHud(new McMMOHud(mcMMOPlayer)); // Setup Party HUD stuff
|
||||||
@@ -81,7 +81,7 @@ public class SpoutListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getKey() == SpoutUtils.menuKey) {
|
if (event.getKey() == SpoutConfig.getInstance().getMenuKey()) {
|
||||||
McMMOHud spoutHud = UserManager.getPlayer(spoutPlayer).getProfile().getSpoutHud();
|
McMMOHud spoutHud = UserManager.getPlayer(spoutPlayer).getProfile().getSpoutHud();
|
||||||
|
|
||||||
if (!spoutHud.isMenuOpened()) {
|
if (!spoutHud.isMenuOpened()) {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import java.io.File;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -19,8 +18,7 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain;
|
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain;
|
||||||
|
|
||||||
public class WorldListener implements Listener {
|
public class WorldListener implements Listener {
|
||||||
private ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
|
private final ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
|
||||||
|
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
|
|
||||||
public WorldListener(final mcMMO plugin) {
|
public WorldListener(final mcMMO plugin) {
|
||||||
@@ -34,12 +32,12 @@ public class WorldListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onStructureGrow(StructureGrowEvent event) {
|
public void onStructureGrow(StructureGrowEvent event) {
|
||||||
Location location = event.getLocation();
|
if (!mcMMO.getPlaceStore().isTrue(event.getLocation().getBlock())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mcMMO.getPlaceStore().isTrue(location.getBlockX(), location.getBlockY(), location.getBlockZ(), location.getWorld())) {
|
for (BlockState blockState : event.getBlocks()) {
|
||||||
for (BlockState blockState : event.getBlocks()) {
|
mcMMO.getPlaceStore().setFalse(blockState);
|
||||||
mcMMO.getPlaceStore().setFalse(blockState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,9 +49,8 @@ public class WorldListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onWorldInit(WorldInitEvent event) {
|
public void onWorldInit(WorldInitEvent event) {
|
||||||
World world = event.getWorld();
|
World world = event.getWorld();
|
||||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
|
||||||
|
|
||||||
if (!dataDir.exists() || plugin == null) {
|
if (!new File(world.getWorldFolder(), "mcmmo_data").exists() || plugin == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,13 +23,12 @@ import com.gmail.nossr50.config.mods.CustomToolConfig;
|
|||||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||||
import com.gmail.nossr50.database.DatabaseManager;
|
import com.gmail.nossr50.database.DatabaseManager;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
|
||||||
import com.gmail.nossr50.listeners.BlockListener;
|
import com.gmail.nossr50.listeners.BlockListener;
|
||||||
import com.gmail.nossr50.listeners.EntityListener;
|
import com.gmail.nossr50.listeners.EntityListener;
|
||||||
import com.gmail.nossr50.listeners.InventoryListener;
|
import com.gmail.nossr50.listeners.InventoryListener;
|
||||||
import com.gmail.nossr50.listeners.PlayerListener;
|
import com.gmail.nossr50.listeners.PlayerListener;
|
||||||
import com.gmail.nossr50.listeners.SelfListener;
|
import com.gmail.nossr50.listeners.SelfListener;
|
||||||
|
import com.gmail.nossr50.listeners.SpoutListener;
|
||||||
import com.gmail.nossr50.listeners.WorldListener;
|
import com.gmail.nossr50.listeners.WorldListener;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.metrics.MetricsManager;
|
import com.gmail.nossr50.metrics.MetricsManager;
|
||||||
@@ -54,18 +53,11 @@ import com.gmail.nossr50.util.player.UserManager;
|
|||||||
import com.gmail.nossr50.util.spout.SpoutUtils;
|
import com.gmail.nossr50.util.spout.SpoutUtils;
|
||||||
|
|
||||||
public class mcMMO extends JavaPlugin {
|
public class mcMMO extends JavaPlugin {
|
||||||
/* Listeners */
|
|
||||||
private final PlayerListener playerListener = new PlayerListener(this);
|
|
||||||
private final BlockListener blockListener = new BlockListener(this);
|
|
||||||
private final EntityListener entityListener = new EntityListener(this);
|
|
||||||
private final InventoryListener inventoryListener = new InventoryListener(this);
|
|
||||||
private final WorldListener worldListener = new WorldListener(this);
|
|
||||||
private final SelfListener selfListener = new SelfListener();
|
|
||||||
|
|
||||||
/* Managers */
|
/* Managers */
|
||||||
private static ChunkManager placeStore;
|
private static ChunkManager placeStore;
|
||||||
private static RepairableManager repairableManager;
|
private static RepairableManager repairableManager;
|
||||||
private static DatabaseManager databaseManager;
|
private static DatabaseManager databaseManager;
|
||||||
|
private static PartyManager partyManager;
|
||||||
|
|
||||||
/* File Paths */
|
/* File Paths */
|
||||||
private static String mainDirectory;
|
private static String mainDirectory;
|
||||||
@@ -81,14 +73,14 @@ public class mcMMO extends JavaPlugin {
|
|||||||
// Update Check
|
// Update Check
|
||||||
private boolean updateAvailable;
|
private boolean updateAvailable;
|
||||||
|
|
||||||
// Plugin Checks
|
/* Plugin Checks */
|
||||||
public static boolean spoutEnabled;
|
private static boolean spoutEnabled;
|
||||||
public static boolean combatTagEnabled;
|
private static boolean combatTagEnabled;
|
||||||
|
|
||||||
// XP Event Check
|
// XP Event Check
|
||||||
private boolean xpEventEnabled;
|
private boolean xpEventEnabled;
|
||||||
|
|
||||||
// Metadata Values
|
/* Metadata Values */
|
||||||
public final static String entityMetadataKey = "mcMMO: Spawned Entity";
|
public final static String entityMetadataKey = "mcMMO: Spawned Entity";
|
||||||
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
|
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
|
||||||
public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace";
|
public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace";
|
||||||
@@ -96,6 +88,9 @@ public class mcMMO extends JavaPlugin {
|
|||||||
public final static String customNameKey = "mcMMO: Custom Name";
|
public final static String customNameKey = "mcMMO: Custom Name";
|
||||||
public final static String customVisibleKey = "mcMMO: Name Visibility";
|
public final static String customVisibleKey = "mcMMO: Name Visibility";
|
||||||
public final static String droppedItemKey = "mcMMO: Tracked Item";
|
public final static String droppedItemKey = "mcMMO: Tracked Item";
|
||||||
|
public final static String infiniteArrowKey = "mcMMO: Infinite Arrow";
|
||||||
|
public final static String bowForceKey = "mcMMO: Bow Force";
|
||||||
|
public final static String arrowDistanceKey = "mcMMO: Arrow Distance";
|
||||||
|
|
||||||
public static FixedMetadataValue metadataValue;
|
public static FixedMetadataValue metadataValue;
|
||||||
|
|
||||||
@@ -113,14 +108,14 @@ public class mcMMO extends JavaPlugin {
|
|||||||
setupSpout();
|
setupSpout();
|
||||||
loadConfigFiles();
|
loadConfigFiles();
|
||||||
|
|
||||||
combatTagEnabled = getServer().getPluginManager().isPluginEnabled("CombatTag");
|
combatTagEnabled = getServer().getPluginManager().getPlugin("CombatTag") != null;
|
||||||
|
|
||||||
databaseManager = new DatabaseManager(this, Config.getInstance().getUseMySQL());
|
databaseManager = new DatabaseManager(this, Config.getInstance().getUseMySQL());
|
||||||
|
|
||||||
registerEvents();
|
registerEvents();
|
||||||
registerCustomRecipes();
|
registerCustomRecipes();
|
||||||
|
|
||||||
PartyManager.loadParties();
|
partyManager = new PartyManager(this);
|
||||||
|
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
UserManager.addUser(player); // In case of reload add all users back into UserManager
|
UserManager.addUser(player); // In case of reload add all users back into UserManager
|
||||||
@@ -129,7 +124,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
debug("Version " + getDescription().getVersion() + " is enabled!");
|
debug("Version " + getDescription().getVersion() + " is enabled!");
|
||||||
|
|
||||||
scheduleTasks();
|
scheduleTasks();
|
||||||
registerCommands();
|
CommandRegistrationManager.registerCommands();
|
||||||
|
|
||||||
MetricsManager.setup();
|
MetricsManager.setup();
|
||||||
|
|
||||||
@@ -161,9 +156,8 @@ public class mcMMO extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
try {
|
try {
|
||||||
reloadDisableHelper(); // Prevent Berserk from getting "stuck"
|
|
||||||
UserManager.saveAll(); // Make sure to save player information if the server shuts down
|
UserManager.saveAll(); // Make sure to save player information if the server shuts down
|
||||||
PartyManager.saveParties(); // Save our parties
|
partyManager.saveParties(); // Save our parties
|
||||||
placeStore.saveAll(); // Save our metadata
|
placeStore.saveAll(); // Save our metadata
|
||||||
placeStore.cleanUp(); // Cleanup empty metadata stores
|
placeStore.cleanUp(); // Cleanup empty metadata stores
|
||||||
}
|
}
|
||||||
@@ -242,6 +236,18 @@ public class mcMMO extends JavaPlugin {
|
|||||||
return repairableManager;
|
return repairableManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PartyManager getPartyManager() {
|
||||||
|
return partyManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isSpoutEnabled() {
|
||||||
|
return spoutEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isCombatTagEnabled() {
|
||||||
|
return combatTagEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the various storage file paths
|
* Setup the various storage file paths
|
||||||
*/
|
*/
|
||||||
@@ -313,8 +319,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
spoutEnabled = true;
|
spoutEnabled = true;
|
||||||
|
|
||||||
SpoutConfig.getInstance();
|
SpoutConfig.getInstance();
|
||||||
SpoutUtils.setupSpoutConfigs();
|
getServer().getPluginManager().registerEvents(new SpoutListener(), this);
|
||||||
SpoutUtils.registerCustomEvent();
|
|
||||||
SpoutUtils.preCacheFiles();
|
SpoutUtils.preCacheFiles();
|
||||||
SpoutUtils.reloadSpoutPlayers(); // Handle spout players after a /reload
|
SpoutUtils.reloadSpoutPlayers(); // Handle spout players after a /reload
|
||||||
}
|
}
|
||||||
@@ -324,53 +329,12 @@ public class mcMMO extends JavaPlugin {
|
|||||||
PluginManager pluginManager = getServer().getPluginManager();
|
PluginManager pluginManager = getServer().getPluginManager();
|
||||||
|
|
||||||
// Register events
|
// Register events
|
||||||
pluginManager.registerEvents(playerListener, this);
|
pluginManager.registerEvents(new PlayerListener(this), this);
|
||||||
pluginManager.registerEvents(blockListener, this);
|
pluginManager.registerEvents(new BlockListener(this), this);
|
||||||
pluginManager.registerEvents(entityListener, this);
|
pluginManager.registerEvents(new EntityListener(this), this);
|
||||||
pluginManager.registerEvents(inventoryListener, this);
|
pluginManager.registerEvents(new InventoryListener(this), this);
|
||||||
pluginManager.registerEvents(selfListener, this);
|
pluginManager.registerEvents(new SelfListener(), this);
|
||||||
pluginManager.registerEvents(worldListener, this);
|
pluginManager.registerEvents(new WorldListener(this), this);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the commands.
|
|
||||||
*/
|
|
||||||
private void registerCommands() {
|
|
||||||
CommandRegistrationManager.registerSkillCommands();
|
|
||||||
|
|
||||||
// mc* commands
|
|
||||||
CommandRegistrationManager.registerMcpurgeCommand();
|
|
||||||
CommandRegistrationManager.registerMcremoveCommand();
|
|
||||||
CommandRegistrationManager.registerMcabilityCommand();
|
|
||||||
CommandRegistrationManager.registerMcgodCommand();
|
|
||||||
CommandRegistrationManager.registerMcmmoCommand();
|
|
||||||
CommandRegistrationManager.registerMcrefreshCommand();
|
|
||||||
CommandRegistrationManager.registerMctopCommand();
|
|
||||||
CommandRegistrationManager.registerMcrankCommand();
|
|
||||||
CommandRegistrationManager.registerMcstatsCommand();
|
|
||||||
|
|
||||||
// Party commands
|
|
||||||
CommandRegistrationManager.registerAdminChatCommand();
|
|
||||||
CommandRegistrationManager.registerPartyCommand();
|
|
||||||
CommandRegistrationManager.registerPartyChatCommand();
|
|
||||||
CommandRegistrationManager.registerPtpCommand();
|
|
||||||
|
|
||||||
// Other commands
|
|
||||||
CommandRegistrationManager.registerAddxpCommand();
|
|
||||||
CommandRegistrationManager.registerAddlevelsCommand();
|
|
||||||
CommandRegistrationManager.registerMmoeditCommand();
|
|
||||||
CommandRegistrationManager.registerInspectCommand();
|
|
||||||
CommandRegistrationManager.registerXprateCommand();
|
|
||||||
CommandRegistrationManager.registerMmoupdateCommand();
|
|
||||||
CommandRegistrationManager.registerSkillresetCommand();
|
|
||||||
CommandRegistrationManager.registerHardcoreCommand();
|
|
||||||
CommandRegistrationManager.registerVampirismCommand();
|
|
||||||
CommandRegistrationManager.registerMcnotifyCommand();
|
|
||||||
CommandRegistrationManager.registerMobhealthCommand();
|
|
||||||
|
|
||||||
// Spout commands
|
|
||||||
CommandRegistrationManager.registerXplockCommand();
|
|
||||||
CommandRegistrationManager.registerMchudCommand();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerCustomRecipes() {
|
private void registerCustomRecipes() {
|
||||||
@@ -382,49 +346,29 @@ public class mcMMO extends JavaPlugin {
|
|||||||
private void scheduleTasks() {
|
private void scheduleTasks() {
|
||||||
// Periodic save timer (Saves every 10 minutes by default)
|
// Periodic save timer (Saves every 10 minutes by default)
|
||||||
long saveIntervalTicks = Config.getInstance().getSaveInterval() * 1200;
|
long saveIntervalTicks = Config.getInstance().getSaveInterval() * 1200;
|
||||||
|
|
||||||
new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks);
|
new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks);
|
||||||
|
|
||||||
// Bleed timer (Runs every two seconds)
|
// Bleed timer (Runs every two seconds)
|
||||||
new BleedTimerTask().runTaskTimer(this, 40, 40);
|
new BleedTimerTask().runTaskTimer(this, 40, 40);
|
||||||
|
|
||||||
// Old & Powerless User remover
|
// Old & Powerless User remover
|
||||||
int purgeInterval = Config.getInstance().getPurgeInterval();
|
long purgeIntervalTicks = Config.getInstance().getPurgeInterval() * 60 * 60 * 20;
|
||||||
UserPurgeTask userPurgeTask = new UserPurgeTask();
|
|
||||||
|
|
||||||
if (purgeInterval == 0) {
|
if (purgeIntervalTicks == 0) {
|
||||||
userPurgeTask.runTaskLater(this, 40);
|
new UserPurgeTask().runTaskLater(this, 40); // Start 2 seconds after startup.
|
||||||
}
|
}
|
||||||
else if (purgeInterval > 0) {
|
else if (purgeIntervalTicks > 0) {
|
||||||
long purgeIntervalTicks = purgeInterval * 60 * 60 * 20;
|
new UserPurgeTask().runTaskTimer(this, purgeIntervalTicks, purgeIntervalTicks);
|
||||||
|
|
||||||
userPurgeTask.runTaskTimer(this, purgeIntervalTicks, purgeIntervalTicks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Automatically remove old members from parties
|
// Automatically remove old members from parties
|
||||||
long kickInterval = Config.getInstance().getAutoPartyKickInterval();
|
long kickIntervalTicks = Config.getInstance().getAutoPartyKickInterval() * 60 * 60 * 20;
|
||||||
PartyAutoKickTask partyAutoKickTask = new PartyAutoKickTask();
|
|
||||||
|
|
||||||
if (kickInterval == 0) {
|
if (kickIntervalTicks == 0) {
|
||||||
partyAutoKickTask.runTaskLater(this, 40); // Start 2 seconds after startup.
|
new PartyAutoKickTask().runTaskLater(this, 40); // Start 2 seconds after startup.
|
||||||
}
|
}
|
||||||
else if (kickInterval > 0) {
|
else if (kickIntervalTicks > 0) {
|
||||||
long kickIntervalTicks = kickInterval * 60 * 60 * 20;
|
new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
|
||||||
|
|
||||||
partyAutoKickTask.runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Because /reload is the biggest piece of garbage in existence,
|
|
||||||
* we have to do some special checks to keep it from breaking everything.
|
|
||||||
*/
|
|
||||||
private void reloadDisableHelper() {
|
|
||||||
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers().values()) {
|
|
||||||
if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
|
|
||||||
mcMMOPlayer.setAbilityMode(AbilityType.BERSERK, false);
|
|
||||||
mcMMOPlayer.getPlayer().setCanPickupItems(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -18,15 +19,20 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public final class PartyManager {
|
public class PartyManager {
|
||||||
private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
|
private final mcMMO plugin;
|
||||||
private static List<Party> parties = new ArrayList<Party>();
|
private final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
|
||||||
private static File partyFile = new File(partiesFilePath);
|
private final List<Party> parties = new ArrayList<Party>();
|
||||||
|
private final File partyFile = new File(partiesFilePath);
|
||||||
|
|
||||||
private PartyManager() {}
|
public PartyManager(final mcMMO plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
|
||||||
public static boolean checkPartyExistence(Player player, Party party, String partyName) {
|
loadParties();
|
||||||
if (party == null) {
|
}
|
||||||
|
|
||||||
|
public boolean checkPartyExistence(Player player, String partyName) {
|
||||||
|
if (getParty(partyName) == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,8 +40,12 @@ public final class PartyManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, Player player, Party oldParty, String newPartyName) {
|
public boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, String newPartyName) {
|
||||||
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
if (mcMMOPlayer.inParty()) {
|
if (mcMMOPlayer.inParty()) {
|
||||||
|
Party oldParty = mcMMOPlayer.getParty();
|
||||||
|
|
||||||
if (!handlePartyChangeEvent(player, oldParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) {
|
if (!handlePartyChangeEvent(player, oldParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -56,7 +66,7 @@ public final class PartyManager {
|
|||||||
* @param secondPlayer The second player
|
* @param secondPlayer The second player
|
||||||
* @return true if they are in the same party, false otherwise
|
* @return true if they are in the same party, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
public boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
||||||
McMMOPlayer firstMcMMOPlayer = UserManager.getPlayer(firstPlayer);
|
McMMOPlayer firstMcMMOPlayer = UserManager.getPlayer(firstPlayer);
|
||||||
McMMOPlayer secondMcMMOPlayer = UserManager.getPlayer(secondPlayer);
|
McMMOPlayer secondMcMMOPlayer = UserManager.getPlayer(secondPlayer);
|
||||||
|
|
||||||
@@ -81,15 +91,20 @@ public final class PartyManager {
|
|||||||
* @param range The distance
|
* @param range The distance
|
||||||
* @return the near party members
|
* @return the near party members
|
||||||
*/
|
*/
|
||||||
public static List<Player> getNearMembers(Player player, Party party, double range) {
|
public List<Player> getNearbyPartyMembers(Player player, double range) {
|
||||||
List<Player> nearMembers = new ArrayList<Player>();
|
List<Player> nearMembers = new ArrayList<Player>();
|
||||||
|
Party party = UserManager.getPlayer(player).getParty();
|
||||||
|
|
||||||
if (party != null) {
|
if (party != null) {
|
||||||
|
Location playerLocation = player.getLocation();
|
||||||
|
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
if (!player.getName().equalsIgnoreCase(member.getName()) && !member.isDead() && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
|
if (!player.equals(member) && !member.isValid() && Misc.isNear(playerLocation, member.getLocation(), range)) {
|
||||||
nearMembers.add(member);
|
nearMembers.add(member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nearMembers;
|
return nearMembers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,9 +114,7 @@ public final class PartyManager {
|
|||||||
* @param player The player to check
|
* @param player The player to check
|
||||||
* @return all the players in the player's party
|
* @return all the players in the player's party
|
||||||
*/
|
*/
|
||||||
public static LinkedHashSet<String> getAllMembers(Player player) {
|
public LinkedHashSet<String> getAllMembers(Party party) {
|
||||||
Party party = UserManager.getPlayer(player).getParty();
|
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -115,7 +128,7 @@ public final class PartyManager {
|
|||||||
* @param partyName The party to check
|
* @param partyName The party to check
|
||||||
* @return all online players in this party
|
* @return all online players in this party
|
||||||
*/
|
*/
|
||||||
public static List<Player> getOnlineMembers(String partyName) {
|
public List<Player> getOnlineMembers(String partyName) {
|
||||||
Party party = getParty(partyName);
|
Party party = getParty(partyName);
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
@@ -125,29 +138,13 @@ public final class PartyManager {
|
|||||||
return party.getOnlineMembers();
|
return party.getOnlineMembers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a list of all online players in this party.
|
|
||||||
*
|
|
||||||
* @param player The player to check
|
|
||||||
* @return all online players in this party
|
|
||||||
*/
|
|
||||||
public static List<Player> getOnlineMembers(Player player) {
|
|
||||||
Party party = getPlayerParty(player.getName());
|
|
||||||
|
|
||||||
if (party == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return getOnlineMembers(party.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a party by its name
|
* Retrieve a party by its name
|
||||||
*
|
*
|
||||||
* @param partyName The party name
|
* @param partyName The party name
|
||||||
* @return the existing party, null otherwise
|
* @return the existing party, null otherwise
|
||||||
*/
|
*/
|
||||||
public static Party getParty(String partyName) {
|
public Party getParty(String partyName) {
|
||||||
for (Party party : parties) {
|
for (Party party : parties) {
|
||||||
if (party.getName().equals(partyName)) {
|
if (party.getName().equals(partyName)) {
|
||||||
return party;
|
return party;
|
||||||
@@ -163,7 +160,7 @@ public final class PartyManager {
|
|||||||
* @param playerName The member name
|
* @param playerName The member name
|
||||||
* @return the existing party, null otherwise
|
* @return the existing party, null otherwise
|
||||||
*/
|
*/
|
||||||
public static Party getPlayerParty(String playerName) {
|
public Party getPlayerParty(String playerName) {
|
||||||
for (Party party : parties) {
|
for (Party party : parties) {
|
||||||
for (String memberName : party.getMembers()) {
|
for (String memberName : party.getMembers()) {
|
||||||
if (memberName.equalsIgnoreCase(playerName)) {
|
if (memberName.equalsIgnoreCase(playerName)) {
|
||||||
@@ -180,7 +177,7 @@ public final class PartyManager {
|
|||||||
*
|
*
|
||||||
* @return the list of parties.
|
* @return the list of parties.
|
||||||
*/
|
*/
|
||||||
public static List<Party> getParties() {
|
public List<Party> getParties() {
|
||||||
return parties;
|
return parties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +187,7 @@ public final class PartyManager {
|
|||||||
* @param player The player to remove
|
* @param player The player to remove
|
||||||
* @param party The party
|
* @param party The party
|
||||||
*/
|
*/
|
||||||
public static void removeFromParty(OfflinePlayer player, Party party) {
|
public void removeFromParty(OfflinePlayer player, Party party) {
|
||||||
LinkedHashSet<String> members = party.getMembers();
|
LinkedHashSet<String> members = party.getMembers();
|
||||||
|
|
||||||
members.remove(player.getName());
|
members.remove(player.getName());
|
||||||
@@ -201,20 +198,13 @@ public final class PartyManager {
|
|||||||
else {
|
else {
|
||||||
// If the leaving player was the party leader, appoint a new leader from the party members
|
// If the leaving player was the party leader, appoint a new leader from the party members
|
||||||
if (party.getLeader().equalsIgnoreCase(player.getName())) {
|
if (party.getLeader().equalsIgnoreCase(player.getName())) {
|
||||||
String newLeader = members.iterator().next();
|
party.setLeader(members.iterator().next());
|
||||||
party.setLeader(newLeader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
informPartyMembersQuit(player, party);
|
informPartyMembersQuit(player, party);
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player.getName());
|
processPlayerLeaving(UserManager.getPlayer(player));
|
||||||
|
|
||||||
if (mcMMOPlayer != null) {
|
|
||||||
mcMMOPlayer.removeParty();
|
|
||||||
mcMMOPlayer.setPartyChat(false);
|
|
||||||
mcMMOPlayer.setItemShareModifier(10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -222,17 +212,11 @@ public final class PartyManager {
|
|||||||
*
|
*
|
||||||
* @param party The party to remove
|
* @param party The party to remove
|
||||||
*/
|
*/
|
||||||
public static void disbandParty(Party party) {
|
public void disbandParty(Party party) {
|
||||||
LinkedHashSet<String> members = party.getMembers();
|
LinkedHashSet<String> members = party.getMembers();
|
||||||
|
|
||||||
for (String memberName : members) {
|
for (String memberName : members) {
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(memberName);
|
processPlayerLeaving(UserManager.getPlayer(memberName));
|
||||||
|
|
||||||
if (mcMMOPlayer != null) {
|
|
||||||
mcMMOPlayer.removeParty();
|
|
||||||
mcMMOPlayer.setPartyChat(false);
|
|
||||||
mcMMOPlayer.setItemShareModifier(10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
members.clear();
|
members.clear();
|
||||||
@@ -243,11 +227,10 @@ public final class PartyManager {
|
|||||||
* Create a new party
|
* Create a new party
|
||||||
*
|
*
|
||||||
* @param player The player to add to the party
|
* @param player The player to add to the party
|
||||||
* @param mcMMOPlayer The player to add to the party
|
|
||||||
* @param partyName The party to add the player to
|
* @param partyName The party to add the player to
|
||||||
* @param password The password for this party, null if there was no password
|
* @param password The password for this party, null if there was no password
|
||||||
*/
|
*/
|
||||||
public static void createParty(Player player, McMMOPlayer mcMMOPlayer, String partyName, String password) {
|
public void createParty(Player player, String partyName, String password) {
|
||||||
partyName = partyName.replace(".", "");
|
partyName = partyName.replace(".", "");
|
||||||
Party party = getParty(partyName);
|
Party party = getParty(partyName);
|
||||||
|
|
||||||
@@ -271,7 +254,7 @@ public final class PartyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName()));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName()));
|
||||||
addToParty(player, mcMMOPlayer, party);
|
addToParty(player, party);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -282,17 +265,18 @@ public final class PartyManager {
|
|||||||
* @param party The party to add the player to
|
* @param party The party to add the player to
|
||||||
* @param password the password for this party, null if there was no password
|
* @param password the password for this party, null if there was no password
|
||||||
*/
|
*/
|
||||||
public static void joinParty(Player player, McMMOPlayer mcMMOPlayer, Party party, String password) {
|
public void joinParty(Player player, Party party, String password) {
|
||||||
if (!checkPartyPassword(player, party, password)) {
|
if (!checkPartyPassword(player, party, password)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMOPlayer.getParty() == party) {
|
// // Pretty sure this isn't possible.
|
||||||
return;
|
// if (mcMMOPlayer.getParty() == party) {
|
||||||
}
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", party.getName()));
|
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", party.getName()));
|
||||||
addToParty(player, mcMMOPlayer, party);
|
addToParty(player, party);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -303,7 +287,7 @@ public final class PartyManager {
|
|||||||
* @param password The password provided by the player
|
* @param password The password provided by the player
|
||||||
* @return true if the player can join the party
|
* @return true if the player can join the party
|
||||||
*/
|
*/
|
||||||
public static boolean checkPartyPassword(Player player, Party party, String password) {
|
public boolean checkPartyPassword(Player player, Party party, String password) {
|
||||||
// Don't care about passwords if it isn't locked
|
// Don't care about passwords if it isn't locked
|
||||||
if (party.isLocked()) {
|
if (party.isLocked()) {
|
||||||
String partyPassword = party.getPassword();
|
String partyPassword = party.getPassword();
|
||||||
@@ -333,20 +317,22 @@ public final class PartyManager {
|
|||||||
* @param Player The plaer to add to the party
|
* @param Player The plaer to add to the party
|
||||||
* @param mcMMOPlayer The player to add to the party
|
* @param mcMMOPlayer The player to add to the party
|
||||||
*/
|
*/
|
||||||
public static void joinInvitedParty(Player player, McMMOPlayer mcMMOPlayer) {
|
public void joinInvitedParty(Player player) {
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
Party invite = mcMMOPlayer.getPartyInvite();
|
Party invite = mcMMOPlayer.getPartyInvite();
|
||||||
|
|
||||||
if (mcMMOPlayer.getParty() == invite) {
|
if (mcMMOPlayer.getParty() == invite) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parties.contains(invite)) {
|
// // Pretty sure this isn't possible
|
||||||
parties.add(invite);
|
// if (!parties.contains(invite)) {
|
||||||
}
|
// parties.add(invite);
|
||||||
|
// }
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName()));
|
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName()));
|
||||||
mcMMOPlayer.removePartyInvite();
|
mcMMOPlayer.removePartyInvite();
|
||||||
addToParty(player, mcMMOPlayer, invite);
|
addToParty(player, invite);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -356,11 +342,17 @@ public final class PartyManager {
|
|||||||
* @param mcMMOPlayer The player to add to the party
|
* @param mcMMOPlayer The player to add to the party
|
||||||
* @param party The party
|
* @param party The party
|
||||||
*/
|
*/
|
||||||
public static void addToParty(OfflinePlayer player, McMMOPlayer mcMMOPlayer, Party party) {
|
public void addToParty(OfflinePlayer player, Party party) {
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
if (mcMMOPlayer.getParty() == party) {
|
if (mcMMOPlayer.getParty() == party) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!parties.contains(party)) {
|
||||||
|
parties.add(party);
|
||||||
|
}
|
||||||
|
|
||||||
informPartyMembersJoin(player, party);
|
informPartyMembersJoin(player, party);
|
||||||
mcMMOPlayer.setParty(party);
|
mcMMOPlayer.setParty(party);
|
||||||
|
|
||||||
@@ -373,7 +365,7 @@ public final class PartyManager {
|
|||||||
* @param partyName The party name
|
* @param partyName The party name
|
||||||
* @return the leader of the party
|
* @return the leader of the party
|
||||||
*/
|
*/
|
||||||
public static String getPartyLeader(String partyName) {
|
public String getPartyLeader(String partyName) {
|
||||||
Party party = getParty(partyName);
|
Party party = getParty(partyName);
|
||||||
|
|
||||||
if (party == null) {
|
if (party == null) {
|
||||||
@@ -389,7 +381,7 @@ public final class PartyManager {
|
|||||||
* @param playerName The name of the player to set as leader
|
* @param playerName The name of the player to set as leader
|
||||||
* @param party The party
|
* @param party The party
|
||||||
*/
|
*/
|
||||||
public static void setPartyLeader(String playerName, Party party) {
|
public void setPartyLeader(String playerName, Party party) {
|
||||||
String leaderName = party.getLeader();
|
String leaderName = party.getLeader();
|
||||||
|
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
@@ -414,7 +406,9 @@ public final class PartyManager {
|
|||||||
* @param mcMMOPlayer The player to check
|
* @param mcMMOPlayer The player to check
|
||||||
* @return true if the player can invite
|
* @return true if the player can invite
|
||||||
*/
|
*/
|
||||||
public static boolean canInvite(Player player, Party party) {
|
public boolean canInvite(Player player) {
|
||||||
|
Party party = getPlayerParty(player.getName());
|
||||||
|
|
||||||
if (party.isLocked() && !party.getLeader().equalsIgnoreCase(player.getName())) {
|
if (party.isLocked() && !party.getLeader().equalsIgnoreCase(player.getName())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -422,26 +416,10 @@ public final class PartyManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a string is a valid party name.
|
|
||||||
*
|
|
||||||
* @param partyName The party name to check
|
|
||||||
* @return true if this is a valid party, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean isParty(String partyName) {
|
|
||||||
for (Party party : parties) {
|
|
||||||
if (party.getName().equals(partyName)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load party file.
|
* Load party file.
|
||||||
*/
|
*/
|
||||||
public static void loadParties() {
|
private void loadParties() {
|
||||||
if (!partyFile.exists()) {
|
if (!partyFile.exists()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -472,7 +450,7 @@ public final class PartyManager {
|
|||||||
/**
|
/**
|
||||||
* Save party file.
|
* Save party file.
|
||||||
*/
|
*/
|
||||||
public static void saveParties() {
|
public void saveParties() {
|
||||||
if (partyFile.exists()) {
|
if (partyFile.exists()) {
|
||||||
partyFile.delete();
|
partyFile.delete();
|
||||||
}
|
}
|
||||||
@@ -516,7 +494,7 @@ public final class PartyManager {
|
|||||||
* @param reason The reason for changing parties
|
* @param reason The reason for changing parties
|
||||||
* @return true if the change event was successful, false otherwise
|
* @return true if the change event was successful, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
|
public boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
|
||||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, newPartyName, reason);
|
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, newPartyName, reason);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@@ -529,7 +507,7 @@ public final class PartyManager {
|
|||||||
* @param player The player that joins
|
* @param player The player that joins
|
||||||
* @param party The concerned party
|
* @param party The concerned party
|
||||||
*/
|
*/
|
||||||
private static void informPartyMembersJoin(OfflinePlayer player, Party party) {
|
private void informPartyMembersJoin(OfflinePlayer player, Party party) {
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
if (!member.equals(player)) {
|
if (!member.equals(player)) {
|
||||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", player.getName()));
|
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", player.getName()));
|
||||||
@@ -543,11 +521,21 @@ public final class PartyManager {
|
|||||||
* @param player The player that quits
|
* @param player The player that quits
|
||||||
* @param party The concerned party
|
* @param party The concerned party
|
||||||
*/
|
*/
|
||||||
private static void informPartyMembersQuit(OfflinePlayer player, Party party) {
|
private void informPartyMembersQuit(OfflinePlayer player, Party party) {
|
||||||
for (Player member : party.getOnlineMembers()) {
|
for (Player member : party.getOnlineMembers()) {
|
||||||
if (!member.equals(player)) {
|
if (!member.equals(player)) {
|
||||||
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", player.getName()));
|
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", player.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void processPlayerLeaving(McMMOPlayer mcMMOPlayer) {
|
||||||
|
if (mcMMOPlayer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.removeParty();
|
||||||
|
mcMMOPlayer.setPartyChat(false);
|
||||||
|
mcMMOPlayer.setItemShareModifier(10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.bukkit.entity.Item;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
||||||
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
import com.gmail.nossr50.datatypes.party.ItemShareType;
|
||||||
@@ -53,12 +54,10 @@ public final class ShareHandler {
|
|||||||
* @return True is the xp has been shared
|
* @return True is the xp has been shared
|
||||||
*/
|
*/
|
||||||
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
|
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
|
||||||
Party party = mcMMOPlayer.getParty();
|
switch (mcMMOPlayer.getParty().getXpShareMode()) {
|
||||||
|
|
||||||
switch (party.getXpShareMode()) {
|
|
||||||
case EQUAL:
|
case EQUAL:
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
|
nearMembers = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange());
|
||||||
|
|
||||||
if (nearMembers.isEmpty()) {
|
if (nearMembers.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -112,7 +111,7 @@ public final class ShareHandler {
|
|||||||
switch (party.getItemShareMode()) {
|
switch (party.getItemShareMode()) {
|
||||||
case EQUAL:
|
case EQUAL:
|
||||||
McMMOPlayer mcMMOTarget;
|
McMMOPlayer mcMMOTarget;
|
||||||
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
|
nearMembers = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange());
|
||||||
|
|
||||||
if (nearMembers.isEmpty()) {
|
if (nearMembers.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -159,7 +158,7 @@ public final class ShareHandler {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case RANDOM:
|
case RANDOM:
|
||||||
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
|
nearMembers = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange());
|
||||||
|
|
||||||
if (nearMembers.isEmpty()) {
|
if (nearMembers.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -19,6 +19,6 @@ public class SaveTimerTask extends BukkitRunnable {
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartyManager.saveParties();
|
mcMMO.getPartyManager().saveParties();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
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.database.SQLDatabaseManager;
|
|
||||||
import com.gmail.nossr50.database.FlatfileDatabaseManager;
|
import com.gmail.nossr50.database.FlatfileDatabaseManager;
|
||||||
|
import com.gmail.nossr50.database.SQLDatabaseManager;
|
||||||
|
|
||||||
public class McrankCommandAsyncTask extends BukkitRunnable {
|
public class McrankCommandAsyncTask extends BukkitRunnable {
|
||||||
private final String playerName;
|
private final String playerName;
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||||
|
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||||
if (skill.isChildSkill() || (player != null && !Permissions.skillEnabled(player, skill))) {
|
if (player != null && !Permissions.skillEnabled(player, skill)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.runnables.items;
|
package com.gmail.nossr50.runnables.items;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@@ -29,27 +28,31 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
|
|||||||
private void checkChimaeraWingTeleport() {
|
private void checkChimaeraWingTeleport() {
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation();
|
Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation();
|
||||||
Location newLocation = mcMMOPlayer.getPlayer().getLocation();
|
|
||||||
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
|
|
||||||
ItemStack inHand = player.getItemInHand();
|
|
||||||
|
|
||||||
mcMMOPlayer.setTeleportCommenceLocation(null);
|
mcMMOPlayer.setTeleportCommenceLocation(null);
|
||||||
|
|
||||||
if (newLocation.distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(0), 1)) {
|
if (player.getLocation().distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(0), 1)) {
|
||||||
player.sendMessage(ChatColor.DARK_RED + "Teleportation canceled!"); //TODO Locale!
|
player.sendMessage(LocaleLoader.getString("Teleport.Cancelled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ItemStack inHand = player.getItemInHand();
|
||||||
|
|
||||||
if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < Config.getInstance().getChimaeraUseCost()) {
|
if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < Config.getInstance().getChimaeraUseCost()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", "Chimaera Wings")); //TODO Locale!
|
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int recentlyhurt_cooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
|
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
|
||||||
|
int hurtCooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
|
||||||
|
|
||||||
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)) {
|
if (hurtCooldown > 0) {
|
||||||
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)));
|
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
|
||||||
return;
|
|
||||||
|
if (timeRemaining > 0) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChimaeraWing.chimaeraExecuteTeleport();
|
ChimaeraWing.chimaeraExecuteTeleport();
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.gmail.nossr50.runnables.items;
|
package com.gmail.nossr50.runnables.items;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
|
||||||
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;
|
||||||
@@ -38,21 +38,25 @@ public class TeleportationWarmup extends BukkitRunnable {
|
|||||||
|
|
||||||
mcMMOPlayer.setTeleportCommenceLocation(null);
|
mcMMOPlayer.setTeleportCommenceLocation(null);
|
||||||
|
|
||||||
if (!PartyManager.inSameParty(teleportingPlayer, targetPlayer)) {
|
if (!mcMMO.getPartyManager().inSameParty(teleportingPlayer, targetPlayer)) {
|
||||||
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetPlayer.getName()));
|
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetPlayer.getName()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newLocation.distanceSquared(previousLocation) > 1.0) {
|
if (newLocation.distanceSquared(previousLocation) > 1.0) {
|
||||||
teleportingPlayer.sendMessage(ChatColor.DARK_RED + "Teleportation canceled!"); //TODO Locale!
|
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Cancelled"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int recentlyhurt_cooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
|
int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
|
||||||
|
|
||||||
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, teleportingPlayer)) {
|
if (hurtCooldown > 0) {
|
||||||
teleportingPlayer.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, teleportingPlayer)));
|
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, teleportingPlayer);
|
||||||
return;
|
|
||||||
|
if (timeRemaining > 0) {
|
||||||
|
teleportingPlayer.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PtpCommand.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
PtpCommand.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class PartyAutoKickTask extends BukkitRunnable {
|
|||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
long kickTime = 24L * 60L * 60L * 1000L * Config.getInstance().getAutoPartyKickTime();
|
long kickTime = 24L * 60L * 60L * 1000L * Config.getInstance().getAutoPartyKickTime();
|
||||||
|
|
||||||
for (Iterator<Party> partyIterator = PartyManager.getParties().iterator(); partyIterator.hasNext();) {
|
for (Iterator<Party> partyIterator = mcMMO.getPartyManager().getParties().iterator(); partyIterator.hasNext();) {
|
||||||
Party party = partyIterator.next();
|
Party party = partyIterator.next();
|
||||||
|
|
||||||
for (String memberName : party.getMembers()) {
|
for (String memberName : party.getMembers()) {
|
||||||
@@ -44,7 +44,7 @@ public class PartyAutoKickTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Entry<OfflinePlayer, Party> entry : toRemove.entrySet()) {
|
for (Entry<OfflinePlayer, Party> entry : toRemove.entrySet()) {
|
||||||
PartyManager.removeFromParty(entry.getKey(), entry.getValue());
|
mcMMO.getPartyManager().removeFromParty(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ public class ScoreboardChangeTask extends BukkitRunnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
player.setScoreboard(oldScoreboard);
|
if (player.isOnline()) {
|
||||||
|
player.setScoreboard(oldScoreboard);
|
||||||
|
ScoreboardManager.enablePowerLevelDisplay(player);
|
||||||
|
}
|
||||||
|
|
||||||
ScoreboardManager.clearPendingTask(player.getName());
|
ScoreboardManager.clearPendingTask(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,11 @@ import com.gmail.nossr50.mcMMO;
|
|||||||
import com.gmail.nossr50.config.HiddenConfig;
|
import com.gmail.nossr50.config.HiddenConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
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.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||||
|
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class AbilityDisableTask extends BukkitRunnable {
|
public class AbilityDisableTask extends BukkitRunnable {
|
||||||
@@ -44,6 +47,9 @@ public class AbilityDisableTask extends BukkitRunnable {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, SkillType.byAbility(ability));
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
mcMMOPlayer.setAbilityMode(ability, false);
|
mcMMOPlayer.setAbilityMode(ability, false);
|
||||||
mcMMOPlayer.setAbilityInformed(ability, false);
|
mcMMOPlayer.setAbilityInformed(ability, false);
|
||||||
|
|
||||||
@@ -54,6 +60,6 @@ public class AbilityDisableTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayerOff(player));
|
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayerOff(player));
|
||||||
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLaterAsynchronously(mcMMO.p, ability.getCooldown() * 20);
|
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLaterAsynchronously(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package com.gmail.nossr50.runnables.skills;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Creature;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
|
public class KrakenAttackTask extends BukkitRunnable {
|
||||||
|
private Creature kraken;
|
||||||
|
private Player player;
|
||||||
|
private Location location;
|
||||||
|
private final boolean GLOBAL_SOUNDS = AdvancedConfig.getInstance().getKrakenGlobalSoundsEnabled();
|
||||||
|
|
||||||
|
public KrakenAttackTask(Creature kraken, Player player) {
|
||||||
|
this.kraken = kraken;
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public KrakenAttackTask(Creature kraken, Player player, Location location) {
|
||||||
|
this.kraken = kraken;
|
||||||
|
this.player = player;
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (location != null) {
|
||||||
|
Location playerLocation = player.getLocation();
|
||||||
|
|
||||||
|
if (player.isValid() && playerLocation.getBlock().isLiquid()) {
|
||||||
|
World world = player.getWorld();
|
||||||
|
|
||||||
|
player.damage(AdvancedConfig.getInstance().getKrakenAttackDamage(), kraken);
|
||||||
|
|
||||||
|
if (GLOBAL_SOUNDS) {
|
||||||
|
world.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
|
}
|
||||||
|
|
||||||
|
world.strikeLightningEffect(playerLocation);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(AdvancedConfig.getInstance().getPlayerEscapeMessage());
|
||||||
|
player.resetPlayerWeather();
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!kraken.isValid()) {
|
||||||
|
player.sendMessage(AdvancedConfig.getInstance().getPlayerDefeatMessage());
|
||||||
|
player.resetPlayerWeather();
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.isValid()) {
|
||||||
|
Location location = player.getLocation();
|
||||||
|
|
||||||
|
if (!location.getBlock().isLiquid() && AdvancedConfig.getInstance().getKrakenEscapeAllowed()) {
|
||||||
|
player.sendMessage(AdvancedConfig.getInstance().getPlayerEscapeMessage());
|
||||||
|
kraken.remove();
|
||||||
|
player.resetPlayerWeather();
|
||||||
|
cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
World world = player.getWorld();
|
||||||
|
|
||||||
|
kraken.teleport(player);
|
||||||
|
player.damage(AdvancedConfig.getInstance().getKrakenAttackDamage(), kraken);
|
||||||
|
|
||||||
|
if (GLOBAL_SOUNDS) {
|
||||||
|
world.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
|
}
|
||||||
|
|
||||||
|
world.strikeLightningEffect(location);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
kraken.remove();
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,6 @@ public final class Acrobatics {
|
|||||||
|
|
||||||
public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel();
|
public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel();
|
||||||
public static int gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold();
|
public static int gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold();
|
||||||
public static int gracefulRollSuccessModifier = AdvancedConfig.getInstance().getGracefulRollSuccessModifer();
|
|
||||||
public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax();
|
public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax();
|
||||||
|
|
||||||
public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier();
|
public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier();
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
|
|
||||||
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold);
|
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold);
|
||||||
|
|
||||||
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel, 1)) {
|
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
|
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
|
||||||
applyXpGain(damage * Acrobatics.rollXpModifier);
|
applyXpGain(damage * Acrobatics.rollXpModifier);
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
private int gracefulRollCheck(int damage) {
|
private int gracefulRollCheck(int damage) {
|
||||||
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold);
|
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold);
|
||||||
|
|
||||||
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollSuccessModifier)) {
|
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel)) {
|
||||||
getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
|
getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
|
||||||
applyXpGain(damage * Acrobatics.rollXpModifier);
|
applyXpGain(damage * Acrobatics.rollXpModifier);
|
||||||
|
|
||||||
@@ -116,8 +116,8 @@ public class AcrobaticsManager extends SkillManager {
|
|||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSuccessfulRoll(double maxChance, int maxLevel, int successModifier) {
|
private boolean isSuccessfulRoll(double maxChance, int maxLevel) {
|
||||||
return ((maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) * successModifier) > Misc.getRandom().nextInt(activationChance);
|
return (maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) > Misc.getRandom().nextInt(activationChance);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isFatal(int damage) {
|
private boolean isFatal(int damage) {
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
@@ -65,4 +67,14 @@ public class Archery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Location stringToLocation(String location) {
|
||||||
|
String[] values = location.split(",");
|
||||||
|
|
||||||
|
return new Location(mcMMO.p.getServer().getWorld(values[0]), Double.parseDouble(values[1]), Double.parseDouble(values[2]), Double.parseDouble(values[3]), Float.parseFloat(values[4]), Float.parseFloat(values[5]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String locationToString(Location location) {
|
||||||
|
return location.getWorld().getName() + "," + location.getX() + "," + location.getY() + "," + location.getZ() + "," + location.getYaw() + "," + location.getPitch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package com.gmail.nossr50.skills.archery;
|
package com.gmail.nossr50.skills.archery;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
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;
|
||||||
@@ -30,9 +31,7 @@ public class ArcheryManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canTrackArrows() {
|
public boolean canTrackArrows() {
|
||||||
Player player = getPlayer();
|
return Permissions.arrowRetrieval(getPlayer());
|
||||||
|
|
||||||
return !(player.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,20 +39,15 @@ public class ArcheryManager extends SkillManager {
|
|||||||
*
|
*
|
||||||
* @param target The {@link LivingEntity} damaged by the arrow
|
* @param target The {@link LivingEntity} damaged by the arrow
|
||||||
*/
|
*/
|
||||||
public void distanceXpBonus(LivingEntity target) {
|
public void distanceXpBonus(LivingEntity target, Entity damager) {
|
||||||
Player player = getPlayer();
|
Location firedLocation = Archery.stringToLocation(damager.getMetadata(mcMMO.arrowDistanceKey).get(0).asString());
|
||||||
Location shooterLocation = player.getLocation();
|
|
||||||
Location targetLocation = target.getLocation();
|
Location targetLocation = target.getLocation();
|
||||||
|
|
||||||
if (shooterLocation.getWorld() != targetLocation.getWorld()) {
|
if (firedLocation.getWorld() != targetLocation.getWorld()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cap distance at 100^2 to prevent teleport exploit.
|
applyXpGain((int) (firedLocation.distanceSquared(targetLocation) * Archery.DISTANCE_XP_MULTIPLIER));
|
||||||
// TODO: Better way to handle this would be great...
|
|
||||||
double squaredDistance = Math.min(shooterLocation.distanceSquared(targetLocation), 10000);
|
|
||||||
|
|
||||||
applyXpGain((int) (squaredDistance * Archery.DISTANCE_XP_MULTIPLIER));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,44 +19,42 @@ public class ChildConfig extends AutoUpdateConfigLoader {
|
|||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml")));
|
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml")));
|
||||||
|
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.childSkills()) {
|
||||||
if (skill.isChildSkill()) {
|
plugin.debug("Finding parents of " + skill.name());
|
||||||
plugin.debug("Finding parents of " + skill.name());
|
|
||||||
|
|
||||||
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
|
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
|
||||||
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
|
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
|
||||||
boolean useDefaults = false; // If we had an error we back out and use defaults
|
boolean useDefaults = false; // If we had an error we back out and use defaults
|
||||||
|
|
||||||
for (String name : parentNames) {
|
for (String name : parentNames) {
|
||||||
try {
|
try {
|
||||||
SkillType parentSkill = Enum.valueOf(SkillType.class, name.toUpperCase());
|
SkillType parentSkill = SkillType.valueOf(name.toUpperCase());
|
||||||
FamilyTree.enforceNotChildSkill(parentSkill);
|
FamilyTree.enforceNotChildSkill(parentSkill);
|
||||||
parentSkills.add(parentSkill);
|
parentSkills.add(parentSkill);
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex) {
|
|
||||||
plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
|
|
||||||
useDefaults = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (IllegalArgumentException ex) {
|
||||||
if (useDefaults) {
|
plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
|
||||||
parentSkills.clear();
|
useDefaults = true;
|
||||||
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
|
break;
|
||||||
/* We do less checks in here because it's from inside our jar.
|
|
||||||
* If they're dedicated enough to have modified it, they can have the errors it may produce.
|
|
||||||
* Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
|
|
||||||
*/
|
|
||||||
parentSkills.add(SkillType.valueOf(name.toUpperCase()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Register them
|
if (useDefaults) {
|
||||||
for (SkillType parentSkill : parentSkills) {
|
parentSkills.clear();
|
||||||
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
|
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
|
||||||
FamilyTree.registerParent(skill, parentSkill);
|
/* We do less checks in here because it's from inside our jar.
|
||||||
|
* If they're dedicated enough to have modified it, they can have the errors it may produce.
|
||||||
|
* Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
|
||||||
|
*/
|
||||||
|
parentSkills.add(SkillType.valueOf(name.toUpperCase()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register them
|
||||||
|
for (SkillType parentSkill : parentSkills) {
|
||||||
|
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
|
||||||
|
FamilyTree.registerParent(skill, parentSkill);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FamilyTree.closeRegistration();
|
FamilyTree.closeRegistration();
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.gmail.nossr50.skills.fishing;
|
package com.gmail.nossr50.skills.fishing;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@@ -49,6 +52,8 @@ public final class Fishing {
|
|||||||
abstract protected int getVanillaXPBoostModifier();
|
abstract protected int getVanillaXPBoostModifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static final HashMap<Material, List<Enchantment>> ENCHANTABLE_CACHE = new HashMap<Material, List<Enchantment>>();
|
||||||
|
|
||||||
public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange();
|
public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange();
|
||||||
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
|
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
|
||||||
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
|
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
|
||||||
|
|||||||
@@ -2,11 +2,23 @@ package com.gmail.nossr50.skills.fishing;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.WeatherType;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Fish;
|
import org.bukkit.entity.Fish;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@@ -14,8 +26,11 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.entity.Sheep;
|
import org.bukkit.entity.Sheep;
|
||||||
import org.bukkit.entity.Skeleton;
|
import org.bukkit.entity.Skeleton;
|
||||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||||
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
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.treasure.TreasureConfig;
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||||
@@ -23,7 +38,12 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||||
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
||||||
|
import com.gmail.nossr50.events.fake.FakePlayerFishEvent;
|
||||||
|
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
|
||||||
|
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
|
||||||
|
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.runnables.skills.KrakenAttackTask;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
@@ -33,6 +53,11 @@ import com.gmail.nossr50.util.skills.CombatUtils;
|
|||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class FishingManager extends SkillManager {
|
public class FishingManager extends SkillManager {
|
||||||
|
private final long FISHING_COOLDOWN_SECONDS = 1000L;
|
||||||
|
|
||||||
|
private int fishingTries = 0;
|
||||||
|
private long fishingTimestamp = 0L;
|
||||||
|
|
||||||
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
||||||
super(mcMMOPlayer, SkillType.FISHING);
|
super(mcMMOPlayer, SkillType.FISHING);
|
||||||
}
|
}
|
||||||
@@ -45,6 +70,111 @@ public class FishingManager extends SkillManager {
|
|||||||
return Permissions.masterAngler(getPlayer());
|
return Permissions.masterAngler(getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean unleashTheKraken() {
|
||||||
|
return unleashTheKraken(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean unleashTheKraken(boolean forceSpawn) {
|
||||||
|
if (!forceSpawn && (fishingTries < AdvancedConfig.getInstance().getKrakenTriesBeforeRelease() || fishingTries <= Misc.getRandom().nextInt(200))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = getPlayer();
|
||||||
|
World world = player.getWorld();
|
||||||
|
|
||||||
|
player.setPlayerWeather(WeatherType.DOWNFALL);
|
||||||
|
|
||||||
|
Entity vehicle = player.getVehicle();
|
||||||
|
|
||||||
|
if (vehicle != null && vehicle.getType() == EntityType.BOAT) {
|
||||||
|
vehicle.eject();
|
||||||
|
vehicle.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
player.teleport(player.getTargetBlock(null, 100).getLocation(), TeleportCause.PLUGIN);
|
||||||
|
|
||||||
|
Location location = player.getLocation();
|
||||||
|
|
||||||
|
world.strikeLightningEffect(location);
|
||||||
|
world.strikeLightningEffect(location);
|
||||||
|
world.strikeLightningEffect(location);
|
||||||
|
player.sendMessage(AdvancedConfig.getInstance().getPlayerUnleashMessage());
|
||||||
|
|
||||||
|
if (AdvancedConfig.getInstance().getKrakenGlobalSoundsEnabled()) {
|
||||||
|
world.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
|
||||||
|
}
|
||||||
|
|
||||||
|
String globalMessage = AdvancedConfig.getInstance().getServerUnleashMessage();
|
||||||
|
|
||||||
|
if (!globalMessage.isEmpty()) {
|
||||||
|
mcMMO.p.getServer().broadcastMessage(ChatColor.RED + AdvancedConfig.getInstance().getServerUnleashMessage().replace("(PLAYER)", player.getDisplayName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setItemInHand(null);
|
||||||
|
|
||||||
|
Creature kraken = (Creature) world.spawnEntity(player.getEyeLocation(), (Misc.getRandom().nextInt(100) == 0 ? EntityType.CHICKEN : EntityType.SQUID));
|
||||||
|
kraken.setCustomName(AdvancedConfig.getInstance().getKrakenName());
|
||||||
|
|
||||||
|
if (!kraken.isValid()) {
|
||||||
|
int attackInterval = AdvancedConfig.getInstance().getKrakenAttackInterval() * 20;
|
||||||
|
new KrakenAttackTask(kraken, player, player.getLocation()).runTaskTimer(mcMMO.p, attackInterval, attackInterval);
|
||||||
|
|
||||||
|
if (!forceSpawn) {
|
||||||
|
fishingTries = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
kraken.setMaxHealth(AdvancedConfig.getInstance().getKrakenHealth());
|
||||||
|
kraken.setHealth(kraken.getMaxHealth());
|
||||||
|
|
||||||
|
int attackInterval = AdvancedConfig.getInstance().getKrakenAttackInterval() * 20;
|
||||||
|
new KrakenAttackTask(kraken, player).runTaskTimer(mcMMO.p, attackInterval, attackInterval);
|
||||||
|
|
||||||
|
if (!forceSpawn) {
|
||||||
|
fishingTries = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean exploitPrevention() {
|
||||||
|
if (!AdvancedConfig.getInstance().getKrakenEnabled() || !getPlayer().getTargetBlock(null, 100).isLiquid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
long currentTime = System.currentTimeMillis();
|
||||||
|
boolean hasFished = (currentTime < fishingTimestamp + FISHING_COOLDOWN_SECONDS);
|
||||||
|
|
||||||
|
fishingTries = hasFished ? fishingTries + 1 : Math.max(fishingTries - 1, 0);
|
||||||
|
fishingTimestamp = currentTime;
|
||||||
|
return unleashTheKraken(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canIceFish(Block block) {
|
||||||
|
if (getSkillLevel() < AdvancedConfig.getInstance().getIceFishingUnlockLevel()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (block.getType() != Material.ICE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure this is a body of water, not just a block of ice.
|
||||||
|
Biome biome = block.getBiome();
|
||||||
|
boolean isFrozenBiome = (biome == Biome.FROZEN_OCEAN || biome == Biome.FROZEN_RIVER);
|
||||||
|
|
||||||
|
if (!isFrozenBiome && block.getRelative(BlockFace.DOWN, 3).getType() == (Material.STATIONARY_WATER)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Permissions.iceFishing(getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the loot tier
|
* Gets the loot tier
|
||||||
*
|
*
|
||||||
@@ -90,8 +220,38 @@ public class FishingManager extends SkillManager {
|
|||||||
return SkillUtils.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange);
|
return SkillUtils.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void iceFishing(Fish hook, Block block) {
|
||||||
|
// Make a hole
|
||||||
|
block.setType(Material.STATIONARY_WATER);
|
||||||
|
|
||||||
|
for (int x = -1; x <= 1; x++) {
|
||||||
|
for (int z = -1; z <= 1; z++) {
|
||||||
|
Block relative = block.getRelative(x, 0, z);
|
||||||
|
|
||||||
|
if (relative.getType() == Material.ICE) {
|
||||||
|
relative.setType(Material.STATIONARY_WATER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recast in the new spot
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(new FakePlayerFishEvent(getPlayer(), null, hook, PlayerFishEvent.State.FISHING));
|
||||||
|
}
|
||||||
|
|
||||||
public void masterAngler(Fish hook) {
|
public void masterAngler(Fish hook) {
|
||||||
hook.setBiteChance(Math.min(hook.getBiteChance() * Math.max((getSkillLevel() / 200.0), 1.0), 1.0));
|
Player player = getPlayer();
|
||||||
|
Biome biome = player.getLocation().getBlock().getBiome();
|
||||||
|
double biteChance = Math.min(hook.getBiteChance() * Math.max((getSkillLevel() / 200.0), 1.0), 1.0);
|
||||||
|
|
||||||
|
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
||||||
|
biteChance = biteChance * 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
|
||||||
|
biteChance = biteChance * 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook.setBiteChance(biteChance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -114,13 +274,43 @@ public class FishingManager extends SkillManager {
|
|||||||
treasureXp = treasure.getXp();
|
treasureXp = treasure.getXp();
|
||||||
ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
|
ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
|
||||||
|
|
||||||
if (Permissions.magicHunter(player) && ItemUtils.isEnchantable(treasureDrop) && handleMagicHunter(treasureDrop)) {
|
McMMOPlayerFishingTreasureEvent event;
|
||||||
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
|
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
|
||||||
|
|
||||||
|
if (Permissions.magicHunter(player) && ItemUtils.isEnchantable(treasureDrop)) {
|
||||||
|
enchants = handleMagicHunter(treasureDrop);
|
||||||
|
event = new McMMOPlayerMagicHunterEvent(player, treasureDrop, treasureXp, enchants);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event = new McMMOPlayerFishingTreasureEvent(player, treasureDrop, treasureXp);
|
||||||
|
}
|
||||||
|
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
treasureDrop = event.getTreasure();
|
||||||
|
treasureXp = event.getXp();
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
treasureDrop = null;
|
||||||
|
treasureXp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop the original catch at the feet of the player and set the treasure as the real catch
|
// Drop the original catch at the feet of the player and set the treasure as the real catch
|
||||||
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
|
if (treasureDrop != null) {
|
||||||
fishingCatch.setItemStack(treasureDrop);
|
boolean enchanted = false;
|
||||||
|
|
||||||
|
if (!enchants.isEmpty()) {
|
||||||
|
treasureDrop.addUnsafeEnchantments(enchants);
|
||||||
|
enchanted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enchanted) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
|
||||||
|
}
|
||||||
|
|
||||||
|
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
|
||||||
|
fishingCatch.setItemStack(treasureDrop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
applyXpGain(Config.getInstance().getFishingBaseXP() + treasureXp);
|
applyXpGain(Config.getInstance().getFishingBaseXP() + treasureXp);
|
||||||
@@ -142,6 +332,8 @@ public class FishingManager extends SkillManager {
|
|||||||
* @param mob The {@link LivingEntity} affected by the ability
|
* @param mob The {@link LivingEntity} affected by the ability
|
||||||
*/
|
*/
|
||||||
public void shakeCheck(LivingEntity target) {
|
public void shakeCheck(LivingEntity target) {
|
||||||
|
fishingTries--; // Because autoclicking to shake is OK.
|
||||||
|
|
||||||
if (getShakeProbability() > Misc.getRandom().nextInt(getActivationChance())) {
|
if (getShakeProbability() > Misc.getRandom().nextInt(getActivationChance())) {
|
||||||
List<ShakeTreasure> possibleDrops = Fishing.findPossibleDrops(target);
|
List<ShakeTreasure> possibleDrops = Fishing.findPossibleDrops(target);
|
||||||
|
|
||||||
@@ -194,6 +386,14 @@ public class FishingManager extends SkillManager {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
McMMOPlayerShakeEvent event = new McMMOPlayerShakeEvent(getPlayer(), drop);
|
||||||
|
|
||||||
|
drop = event.getDrop();
|
||||||
|
|
||||||
|
if (event.isCancelled() || drop == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Misc.dropItem(target.getLocation(), drop);
|
Misc.dropItem(target.getLocation(), drop);
|
||||||
CombatUtils.dealDamage(target, Math.max(target.getMaxHealth() / 4, 1)); // Make it so you can shake a mob no more than 4 times.
|
CombatUtils.dealDamage(target, Math.max(target.getMaxHealth() / 4, 1)); // Make it so you can shake a mob no more than 4 times.
|
||||||
}
|
}
|
||||||
@@ -242,7 +442,7 @@ public class FishingManager extends SkillManager {
|
|||||||
* @param treasureDrop The {@link ItemStack} to enchant
|
* @param treasureDrop The {@link ItemStack} to enchant
|
||||||
* @return true if the item has been enchanted
|
* @return true if the item has been enchanted
|
||||||
*/
|
*/
|
||||||
private boolean handleMagicHunter(ItemStack treasureDrop) {
|
private Map<Enchantment, Integer> handleMagicHunter(ItemStack treasureDrop) {
|
||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
int activationChance = this.activationChance;
|
int activationChance = this.activationChance;
|
||||||
|
|
||||||
@@ -250,8 +450,37 @@ public class FishingManager extends SkillManager {
|
|||||||
activationChance *= Fishing.STORM_MODIFIER;
|
activationChance *= Fishing.STORM_MODIFIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
|
||||||
|
|
||||||
if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) {
|
if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) {
|
||||||
return false;
|
return enchants;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Enchantment> possibleEnchantments = getPossibleEnchantments(treasureDrop);
|
||||||
|
|
||||||
|
// This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant
|
||||||
|
Collections.shuffle(possibleEnchantments, Misc.getRandom());
|
||||||
|
|
||||||
|
int specificChance = 1;
|
||||||
|
|
||||||
|
for (Enchantment possibleEnchantment : possibleEnchantments) {
|
||||||
|
if (treasureDrop.getItemMeta().hasConflictingEnchant(possibleEnchantment) || Misc.getRandom().nextInt(specificChance) != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
enchants.put(possibleEnchantment, Math.max(Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1, possibleEnchantment.getStartLevel()));
|
||||||
|
|
||||||
|
specificChance++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return enchants;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Enchantment> getPossibleEnchantments(ItemStack treasureDrop) {
|
||||||
|
Material dropType = treasureDrop.getType();
|
||||||
|
|
||||||
|
if (Fishing.ENCHANTABLE_CACHE.containsKey(dropType)) {
|
||||||
|
return Fishing.ENCHANTABLE_CACHE.get(dropType);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Enchantment> possibleEnchantments = new ArrayList<Enchantment>();
|
List<Enchantment> possibleEnchantments = new ArrayList<Enchantment>();
|
||||||
@@ -262,22 +491,8 @@ public class FishingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant
|
Fishing.ENCHANTABLE_CACHE.put(dropType, possibleEnchantments);
|
||||||
Collections.shuffle(possibleEnchantments, Misc.getRandom());
|
return possibleEnchantments;
|
||||||
|
|
||||||
boolean enchanted = false;
|
|
||||||
int specificChance = 1;
|
|
||||||
|
|
||||||
for (Enchantment possibleEnchantment : possibleEnchantments) {
|
|
||||||
if (!treasureDrop.getItemMeta().hasConflictingEnchant(possibleEnchantment) && Misc.getRandom().nextInt(specificChance) == 0) {
|
|
||||||
treasureDrop.addEnchantment(possibleEnchantment, Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1);
|
|
||||||
|
|
||||||
specificChance++;
|
|
||||||
enchanted = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return enchanted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class MiningManager extends SkillManager{
|
public class MiningManager extends SkillManager {
|
||||||
public MiningManager(McMMOPlayer mcMMOPlayer) {
|
public MiningManager(McMMOPlayer mcMMOPlayer) {
|
||||||
super(mcMMOPlayer, SkillType.MINING);
|
super(mcMMOPlayer, SkillType.MINING);
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ public class MiningManager extends SkillManager{
|
|||||||
|
|
||||||
getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
|
getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
|
||||||
mcMMOPlayer.setAbilityInformed(AbilityType.BLAST_MINING, false);
|
mcMMOPlayer.setAbilityInformed(AbilityType.BLAST_MINING, false);
|
||||||
new AbilityCooldownTask(mcMMOPlayer, AbilityType.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, AbilityType.BLAST_MINING.getCooldown());
|
new AbilityCooldownTask(mcMMOPlayer, AbilityType.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, AbilityType.BLAST_MINING.getCooldown() * 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,7 +158,7 @@ public class MiningManager extends SkillManager{
|
|||||||
if (debrisYield > 0) {
|
if (debrisYield > 0) {
|
||||||
for (BlockState blockState : debris) {
|
for (BlockState blockState : debris) {
|
||||||
if (Misc.getRandom().nextFloat() < debrisYield) {
|
if (Misc.getRandom().nextFloat() < debrisYield) {
|
||||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
|
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -287,9 +287,10 @@ public class MiningManager extends SkillManager{
|
|||||||
|
|
||||||
long oldTime = profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR;
|
long oldTime = profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR;
|
||||||
int cooldown = AbilityType.BLAST_MINING.getCooldown();
|
int cooldown = AbilityType.BLAST_MINING.getCooldown();
|
||||||
|
int timeRemaining = SkillUtils.calculateTimeLeft(oldTime, cooldown, player);
|
||||||
|
|
||||||
if (!SkillUtils.cooldownOver(oldTime, cooldown, player)) {
|
if (timeRemaining > 0) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", SkillUtils.calculateTimeLeft(oldTime, cooldown, player)));
|
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,30 @@ public class Repair {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getAnvilMessage(int blockId) {
|
||||||
|
if (blockId == repairAnvilId) {
|
||||||
|
return LocaleLoader.getString("Repair.Listener.Anvil");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockId == salvageAnvilId) {
|
||||||
|
return LocaleLoader.getString("Repair.Listener.Anvil2");
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getSpoutAnvilMessages(int blockId) {
|
||||||
|
if (blockId == repairAnvilId) {
|
||||||
|
return new String[] {LocaleLoader.getString("Repair.AnvilPlaced.Spout1"), LocaleLoader.getString("Repair.AnvilPlaced.Spout2")};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockId == salvageAnvilId) {
|
||||||
|
return new String[] {"[mcMMO] Anvil Placed", "Right click to salvage!"};
|
||||||
|
}
|
||||||
|
|
||||||
|
return new String[] {"", ""};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search the inventory for an item and return the index.
|
* Search the inventory for an item and return the index.
|
||||||
*
|
*
|
||||||
@@ -99,30 +123,6 @@ public class Repair {
|
|||||||
inventory.removeItem(item);
|
inventory.removeItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String[] getSpoutAnvilMessages(int blockId) {
|
|
||||||
if (blockId == repairAnvilId) {
|
|
||||||
return new String[] {LocaleLoader.getString("Repair.AnvilPlaced.Spout1"), LocaleLoader.getString("Repair.AnvilPlaced.Spout2")};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blockId == salvageAnvilId) {
|
|
||||||
return new String[] {"[mcMMO] Anvil Placed", "Right click to salvage!"};
|
|
||||||
}
|
|
||||||
|
|
||||||
return new String[] {"", ""};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static String getAnvilMessage(int blockId) {
|
|
||||||
if (blockId == repairAnvilId) {
|
|
||||||
return LocaleLoader.getString("Repair.Listener.Anvil");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blockId == salvageAnvilId) {
|
|
||||||
return LocaleLoader.getString("Repair.Listener.Anvil2");
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static Material getSalvagedItem(ItemStack inHand) {
|
protected static Material getSalvagedItem(ItemStack inHand) {
|
||||||
if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) {
|
if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) {
|
||||||
return Material.DIAMOND;
|
return Material.DIAMOND;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.repair;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@@ -11,8 +10,6 @@ import org.bukkit.enchantments.Enchantment;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
@@ -27,6 +24,7 @@ import com.gmail.nossr50.util.Permissions;
|
|||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import com.gmail.nossr50.util.spout.SpoutUtils;
|
||||||
|
|
||||||
public class RepairManager extends SkillManager {
|
public class RepairManager extends SkillManager {
|
||||||
public RepairManager(McMMOPlayer mcMMOPlayer) {
|
public RepairManager(McMMOPlayer mcMMOPlayer) {
|
||||||
@@ -45,16 +43,8 @@ public class RepairManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMO.spoutEnabled) {
|
if (mcMMO.isSpoutEnabled()) {
|
||||||
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
SpoutUtils.sendRepairNotifications(player, anvilId);
|
||||||
|
|
||||||
if (spoutPlayer.isSpoutCraftEnabled()) {
|
|
||||||
String[] spoutMessages = Repair.getSpoutAnvilMessages(anvilId);
|
|
||||||
spoutPlayer.sendNotification(spoutMessages[0], spoutMessages[1], Material.getMaterial(anvilId));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage(Repair.getAnvilMessage(anvilId));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(Repair.getAnvilMessage(anvilId));
|
player.sendMessage(Repair.getAnvilMessage(anvilId));
|
||||||
@@ -205,7 +195,7 @@ public class RepairManager extends SkillManager {
|
|||||||
Player player = getPlayer();
|
Player player = getPlayer();
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
long LastUse = mcMMOPlayer.getLastAnvilUse(anvilId);
|
long LastUse = mcMMOPlayer.getLastAnvilUse(anvilId);
|
||||||
|
|
||||||
// Don't use SkillUtils.cooldownOver() here since that also accounts for the cooldown perks
|
// Don't use SkillUtils.cooldownOver() here since that also accounts for the cooldown perks
|
||||||
if ((((LastUse + 3) * Misc.TIME_CONVERSION_FACTOR) >= System.currentTimeMillis()) || !Config.getInstance().getRepairConfirmRequired()) {
|
if ((((LastUse + 3) * Misc.TIME_CONVERSION_FACTOR) >= System.currentTimeMillis()) || !Config.getInstance().getRepairConfirmRequired()) {
|
||||||
@@ -219,11 +209,11 @@ public class RepairManager extends SkillManager {
|
|||||||
mcMMOPlayer.actualizeLastAnvilUse(anvilId);
|
mcMMOPlayer.actualizeLastAnvilUse(anvilId);
|
||||||
|
|
||||||
if (anvilId == Repair.repairAnvilId) {
|
if (anvilId == Repair.repairAnvilId) {
|
||||||
player.sendMessage(ChatColor.GREEN + "Right-click again to confirm " + ChatColor.GOLD + "Repair" + ChatColor.GREEN + ". Left-click to cancel."); //TODO Locale
|
player.sendMessage(LocaleLoader.getString("Skills.ConfirmOrCancel", LocaleLoader.getString("Repair.Pretty.Name")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anvilId == Repair.salvageAnvilId) {
|
if (anvilId == Repair.salvageAnvilId) {
|
||||||
player.sendMessage(ChatColor.GREEN + "Right-click again to confirm " + ChatColor.GOLD + "Salvage" + ChatColor.GREEN + ". Left-click to cancel."); //TODO Locale
|
player.sendMessage(LocaleLoader.getString("Skills.ConfirmOrCancel", LocaleLoader.getString("Salvage.Pretty.Name")));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ public class TamingManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.renamePets(player)) {
|
if (Permissions.renamePets(player)) {
|
||||||
entity.setCustomName(player.getName() + "\'s " + StringUtils.getPrettyEntityTypeString(entity.getType())); //TODO Localize, perhaps in a different language it makes more sense to switch this around
|
entity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", player.getName(), StringUtils.getPrettyEntityTypeString(entity.getType())));
|
||||||
entity.setCustomNameVisible(true);
|
entity.setCustomNameVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class Unarmed {
|
|||||||
|
|
||||||
ItemStack addStack = itemstack.clone();
|
ItemStack addStack = itemstack.clone();
|
||||||
|
|
||||||
if (dropAmount + itemAmount <= itemMax) {
|
if (dropAmount + itemAmount <= itemMax) {
|
||||||
drop.remove();
|
drop.remove();
|
||||||
addStack.setAmount(dropAmount + itemAmount);
|
addStack.setAmount(dropAmount + itemAmount);
|
||||||
inventory.setItem(nextSlot, addStack);
|
inventory.setItem(nextSlot, addStack);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.bukkit.material.CocoaPlant;
|
|||||||
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
|
||||||
import org.bukkit.material.NetherWarts;
|
import org.bukkit.material.NetherWarts;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
|
|
||||||
public final class BlockUtils {
|
public final class BlockUtils {
|
||||||
private BlockUtils() {}
|
private BlockUtils() {}
|
||||||
@@ -19,59 +19,7 @@ public final class BlockUtils {
|
|||||||
* @return true if the block awards XP, false otherwise
|
* @return true if the block awards XP, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean shouldBeWatched(BlockState blockState) {
|
public static boolean shouldBeWatched(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
return affectedByGigaDrillBreaker(blockState) || affectedByGreenTerra(blockState) || affectedBySuperBreaker(blockState) || isLog(blockState);
|
||||||
case BROWN_MUSHROOM:
|
|
||||||
case CACTUS:
|
|
||||||
case CLAY:
|
|
||||||
case COAL_ORE:
|
|
||||||
case DIAMOND_ORE:
|
|
||||||
case DIRT:
|
|
||||||
case ENDER_STONE:
|
|
||||||
case GLOWING_REDSTONE_ORE:
|
|
||||||
case GLOWSTONE:
|
|
||||||
case GOLD_ORE:
|
|
||||||
case GRASS:
|
|
||||||
case GRAVEL:
|
|
||||||
case HUGE_MUSHROOM_1:
|
|
||||||
case HUGE_MUSHROOM_2:
|
|
||||||
case IRON_ORE:
|
|
||||||
case LAPIS_ORE:
|
|
||||||
case LOG:
|
|
||||||
case MELON_BLOCK:
|
|
||||||
case MOSSY_COBBLESTONE:
|
|
||||||
case MYCEL:
|
|
||||||
case NETHERRACK:
|
|
||||||
case OBSIDIAN:
|
|
||||||
case PUMPKIN:
|
|
||||||
case QUARTZ_ORE:
|
|
||||||
case RED_MUSHROOM:
|
|
||||||
case RED_ROSE:
|
|
||||||
case REDSTONE_ORE:
|
|
||||||
case SAND:
|
|
||||||
case SANDSTONE:
|
|
||||||
case SOUL_SAND:
|
|
||||||
case STONE:
|
|
||||||
case SUGAR_CANE_BLOCK:
|
|
||||||
case VINE:
|
|
||||||
case WATER_LILY:
|
|
||||||
case YELLOW_FLOWER:
|
|
||||||
case EMERALD_ORE:
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case CARROT:
|
|
||||||
case CROPS:
|
|
||||||
case POTATO:
|
|
||||||
return blockState.getRawData() == CropState.RIPE.getData();
|
|
||||||
|
|
||||||
case NETHER_WARTS:
|
|
||||||
return ((NetherWarts) blockState.getData()).getState() == NetherWartsState.RIPE;
|
|
||||||
|
|
||||||
case COCOA:
|
|
||||||
return ((CocoaPlant) blockState.getData()).getSize() == CocoaPlantSize.LARGE;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return ModUtils.getCustomBlock(blockState) != null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,17 +59,7 @@ public final class BlockUtils {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
int blockId = blockState.getTypeId();
|
return !isMcMMOAnvil(blockState) && !ModUtils.isCustomAbilityBlock(blockState);
|
||||||
|
|
||||||
if (blockId == Config.getInstance().getRepairAnvilId() || blockId == Config.getInstance().getSalvageAnvilId()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ModUtils.isCustomAbilityBlock(blockState)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,26 +152,17 @@ public final class BlockUtils {
|
|||||||
*/
|
*/
|
||||||
public static Boolean affectedBySuperBreaker(BlockState blockState) {
|
public static Boolean affectedBySuperBreaker(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
switch (blockState.getType()) {
|
||||||
case COAL_ORE:
|
|
||||||
case DIAMOND_ORE:
|
|
||||||
case ENDER_STONE:
|
case ENDER_STONE:
|
||||||
case GLOWING_REDSTONE_ORE:
|
|
||||||
case GLOWSTONE:
|
case GLOWSTONE:
|
||||||
case GOLD_ORE:
|
|
||||||
case IRON_ORE:
|
|
||||||
case LAPIS_ORE:
|
|
||||||
case MOSSY_COBBLESTONE:
|
case MOSSY_COBBLESTONE:
|
||||||
case NETHERRACK:
|
case NETHERRACK:
|
||||||
case OBSIDIAN:
|
case OBSIDIAN:
|
||||||
case QUARTZ_ORE:
|
|
||||||
case REDSTONE_ORE:
|
|
||||||
case SANDSTONE:
|
case SANDSTONE:
|
||||||
case STONE:
|
case STONE:
|
||||||
case EMERALD_ORE:
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return ModUtils.isCustomMiningBlock(blockState);
|
return isOre(blockState) || ModUtils.isCustomMiningBlock(blockState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,16 +195,7 @@ public final class BlockUtils {
|
|||||||
* @return true if the block should affected by Tree Feller, false otherwise
|
* @return true if the block should affected by Tree Feller, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean affectedByTreeFeller(BlockState blockState) {
|
public static boolean affectedByTreeFeller(BlockState blockState) {
|
||||||
switch (blockState.getType()) {
|
return isLog(blockState) || isLeaves(blockState);
|
||||||
case LOG:
|
|
||||||
case LEAVES:
|
|
||||||
case HUGE_MUSHROOM_1:
|
|
||||||
case HUGE_MUSHROOM_2:
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return ModUtils.isCustomWoodcuttingBlock(blockState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -379,4 +299,16 @@ public final class BlockUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a given block is an mcMMO anvil
|
||||||
|
*
|
||||||
|
* @param blockState The {@link BlockState} of the block to check
|
||||||
|
* @return true if the block is an mcMMO anvil, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean isMcMMOAnvil(BlockState blockState) {
|
||||||
|
int blockId = blockState.getTypeId();
|
||||||
|
|
||||||
|
return blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,9 +35,13 @@ public final class ChimaeraWing {
|
|||||||
* @param player Player whose item usage to check
|
* @param player Player whose item usage to check
|
||||||
*/
|
*/
|
||||||
public static void activationCheck(Player player) {
|
public static void activationCheck(Player player) {
|
||||||
|
if (!Config.getInstance().getChimaeraEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ItemStack inHand = player.getItemInHand();
|
ItemStack inHand = player.getItemInHand();
|
||||||
|
|
||||||
if (!Config.getInstance().getChimaeraEnabled() || !ItemUtils.isChimaeraWing(inHand)) {
|
if (!ItemUtils.isChimaeraWing(inHand)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,36 +52,48 @@ public final class ChimaeraWing {
|
|||||||
|
|
||||||
mcMMOPlayer = UserManager.getPlayer(player);
|
mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
location = player.getLocation();
|
|
||||||
int amount = inHand.getAmount();
|
|
||||||
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
|
|
||||||
long lastTeleport = mcMMOPlayer.getLastTeleport();
|
|
||||||
|
|
||||||
if (mcMMOPlayer.getTeleportCommenceLocation() != null) {
|
if (mcMMOPlayer.getTeleportCommenceLocation() != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getChimaeraCooldown() > 0 && !SkillUtils.cooldownOver(lastTeleport * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player)) {
|
int amount = inHand.getAmount();
|
||||||
player.sendMessage(ChatColor.RED + "You need to wait before you can use this again! " + ChatColor.YELLOW + "(" + SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player) + ")"); //TODO Locale!
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int recentlyhurt_cooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
|
|
||||||
|
|
||||||
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (amount < Config.getInstance().getChimaeraUseCost()) {
|
if (amount < Config.getInstance().getChimaeraUseCost()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", "Chimaera Wings")); //TODO Locale!
|
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long lastTeleport = mcMMOPlayer.getLastTeleport();
|
||||||
|
int cooldown = Config.getInstance().getChimaeraCooldown();
|
||||||
|
|
||||||
|
if (cooldown > 0 ) {
|
||||||
|
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, cooldown, player);
|
||||||
|
|
||||||
|
if (timeRemaining > 0) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
|
||||||
|
int hurtCooldown = Config.getInstance().getChimaeraRecentlyHurtCooldown();
|
||||||
|
|
||||||
|
if (hurtCooldown > 0) {
|
||||||
|
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
|
||||||
|
|
||||||
|
if (timeRemaining > 0) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
location = player.getLocation();
|
||||||
|
|
||||||
if (Config.getInstance().getChimaeraPreventUseUnderground()) {
|
if (Config.getInstance().getChimaeraPreventUseUnderground()) {
|
||||||
if (location.getY() < player.getWorld().getHighestBlockYAt(location)) {
|
if (location.getY() < player.getWorld().getHighestBlockYAt(location)) {
|
||||||
player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost())));
|
player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost())));
|
||||||
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
|
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
|
||||||
|
player.updateInventory();
|
||||||
player.setVelocity(new Vector(0, 0.5D, 0));
|
player.setVelocity(new Vector(0, 0.5D, 0));
|
||||||
CombatUtils.dealDamage(player, Misc.getRandom().nextInt(player.getHealth() - 10));
|
CombatUtils.dealDamage(player, Misc.getRandom().nextInt(player.getHealth() - 10));
|
||||||
mcMMOPlayer.actualizeLastTeleport();
|
mcMMOPlayer.actualizeLastTeleport();
|
||||||
@@ -90,7 +106,7 @@ public final class ChimaeraWing {
|
|||||||
long warmup = Config.getInstance().getChimaeraWarmup();
|
long warmup = Config.getInstance().getChimaeraWarmup();
|
||||||
|
|
||||||
if (warmup > 0) {
|
if (warmup > 0) {
|
||||||
player.sendMessage(ChatColor.GRAY + "Commencing teleport in " + ChatColor.GOLD + "(" + warmup + ")" + ChatColor.GRAY + " seconds, please stand still..."); //TODO Locale!
|
player.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
|
||||||
new ChimaeraWingWarmup(mcMMOPlayer).runTaskLater(mcMMO.p, 20 * warmup);
|
new ChimaeraWingWarmup(mcMMOPlayer).runTaskLater(mcMMO.p, 20 * warmup);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -115,6 +131,7 @@ public final class ChimaeraWing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.setItemInHand(new ItemStack(getChimaeraWing(player.getItemInHand().getAmount() - Config.getInstance().getChimaeraUseCost())));
|
player.setItemInHand(new ItemStack(getChimaeraWing(player.getItemInHand().getAmount() - Config.getInstance().getChimaeraUseCost())));
|
||||||
|
player.updateInventory();
|
||||||
UserManager.getPlayer(player).actualizeLastTeleport();
|
UserManager.getPlayer(player).actualizeLastTeleport();
|
||||||
if (Config.getInstance().getStatsTrackingEnabled()) {
|
if (Config.getInstance().getStatsTrackingEnabled()) {
|
||||||
MetricsManager.chimeraWingUsed();
|
MetricsManager.chimeraWingUsed();
|
||||||
@@ -128,11 +145,11 @@ public final class ChimaeraWing {
|
|||||||
ItemStack itemStack = new ItemStack(ingredient, amount);
|
ItemStack itemStack = new ItemStack(ingredient, amount);
|
||||||
|
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
itemMeta.setDisplayName(ChatColor.GOLD + "Chimaera Wing"); //TODO Locale!
|
itemMeta.setDisplayName(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name"));
|
||||||
|
|
||||||
List<String> itemLore = new ArrayList<String>();
|
List<String> itemLore = new ArrayList<String>();
|
||||||
itemLore.add("mcMMO Item");
|
itemLore.add("mcMMO Item");
|
||||||
itemLore.add(ChatColor.GRAY + "Teleports you to your bed."); //TODO Locale!
|
itemLore.add(LocaleLoader.getString("Item.ChimaeraWing.Lore"));
|
||||||
itemMeta.setLore(itemLore);
|
itemMeta.setLore(itemLore);
|
||||||
|
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
|
|||||||
@@ -21,11 +21,7 @@ public final class HardcoreManager {
|
|||||||
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
|
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
|
||||||
int totalLost = 0;
|
int totalLost = 0;
|
||||||
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int playerSkillLevel = playerProfile.getSkillLevel(skillType);
|
int playerSkillLevel = playerProfile.getSkillLevel(skillType);
|
||||||
|
|
||||||
if (playerSkillLevel <= 0) {
|
if (playerSkillLevel <= 0) {
|
||||||
@@ -52,11 +48,7 @@ public final class HardcoreManager {
|
|||||||
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
|
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
|
||||||
int totalStolen = 0;
|
int totalStolen = 0;
|
||||||
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int killerSkillLevel = killerProfile.getSkillLevel(skillType);
|
int killerSkillLevel = killerProfile.getSkillLevel(skillType);
|
||||||
int victimSkillLevel = victimProfile.getSkillLevel(skillType);
|
int victimSkillLevel = victimProfile.getSkillLevel(skillType);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
@@ -14,20 +11,17 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||||
import com.gmail.nossr50.config.mods.CustomToolConfig;
|
import com.gmail.nossr50.config.mods.CustomToolConfig;
|
||||||
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
|
||||||
public class ItemUtils {
|
public class ItemUtils {
|
||||||
private static Config configInstance = Config.getInstance();
|
|
||||||
private static boolean customToolsEnabled = configInstance.getToolModsEnabled();
|
|
||||||
private static boolean customArmorEnabled = configInstance.getArmorModsEnabled();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the item is a sword.
|
* Checks if the item is a sword.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a sword, false otherwise
|
* @return true if the item is a sword, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isSword(ItemStack is) {
|
public static boolean isSword(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case DIAMOND_SWORD:
|
case DIAMOND_SWORD:
|
||||||
case GOLD_SWORD:
|
case GOLD_SWORD:
|
||||||
case IRON_SWORD:
|
case IRON_SWORD:
|
||||||
@@ -36,26 +30,18 @@ public class ItemUtils {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (customToolsEnabled && CustomToolConfig.getInstance().customSwordIDs.contains(is.getTypeId())) {
|
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customSwordIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutSwords.contains(item));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutSwords.contains(is)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the item is a hoe.
|
* Checks if the item is a hoe.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a hoe, false otherwise
|
* @return true if the item is a hoe, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isHoe(ItemStack is) {
|
public static boolean isHoe(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case DIAMOND_HOE:
|
case DIAMOND_HOE:
|
||||||
case GOLD_HOE:
|
case GOLD_HOE:
|
||||||
case IRON_HOE:
|
case IRON_HOE:
|
||||||
@@ -64,26 +50,18 @@ public class ItemUtils {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (customToolsEnabled && CustomToolConfig.getInstance().customHoeIDs.contains(is.getTypeId())) {
|
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customHoeIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutHoes.contains(item));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutHoes.contains(is)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the item is a shovel.
|
* Checks if the item is a shovel.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a shovel, false otherwise
|
* @return true if the item is a shovel, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isShovel(ItemStack is) {
|
public static boolean isShovel(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case DIAMOND_SPADE:
|
case DIAMOND_SPADE:
|
||||||
case GOLD_SPADE:
|
case GOLD_SPADE:
|
||||||
case IRON_SPADE:
|
case IRON_SPADE:
|
||||||
@@ -92,26 +70,18 @@ public class ItemUtils {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (customToolsEnabled && CustomToolConfig.getInstance().customShovelIDs.contains(is.getTypeId())) {
|
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customShovelIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutShovels.contains(item));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutShovels.contains(is)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the item is an axe.
|
* Checks if the item is an axe.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is an axe, false otherwise
|
* @return true if the item is an axe, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isAxe(ItemStack is) {
|
public static boolean isAxe(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case DIAMOND_AXE:
|
case DIAMOND_AXE:
|
||||||
case GOLD_AXE:
|
case GOLD_AXE:
|
||||||
case IRON_AXE:
|
case IRON_AXE:
|
||||||
@@ -120,26 +90,18 @@ public class ItemUtils {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (customToolsEnabled && CustomToolConfig.getInstance().customAxeIDs.contains(is.getTypeId())) {
|
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customAxeIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutAxes.contains(item));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutAxes.contains(is)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the item is a pickaxe.
|
* Checks if the item is a pickaxe.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a pickaxe, false otherwise
|
* @return true if the item is a pickaxe, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isPickaxe(ItemStack is) {
|
public static boolean isPickaxe(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case DIAMOND_PICKAXE:
|
case DIAMOND_PICKAXE:
|
||||||
case GOLD_PICKAXE:
|
case GOLD_PICKAXE:
|
||||||
case IRON_PICKAXE:
|
case IRON_PICKAXE:
|
||||||
@@ -148,138 +110,118 @@ public class ItemUtils {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (customToolsEnabled && CustomToolConfig.getInstance().customPickaxeIDs.contains(is.getTypeId())) {
|
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customPickaxeIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutPickaxes.contains(item));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutPickaxes.contains(is)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the item is a helmet.
|
* Checks if the item is a helmet.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a helmet, false otherwise
|
* @return true if the item is a helmet, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isHelmet(ItemStack is) {
|
public static boolean isHelmet(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case DIAMOND_HELMET:
|
case DIAMOND_HELMET:
|
||||||
case GOLD_HELMET:
|
case GOLD_HELMET:
|
||||||
case IRON_HELMET:
|
case IRON_HELMET:
|
||||||
|
case CHAINMAIL_HELMET:
|
||||||
case LEATHER_HELMET:
|
case LEATHER_HELMET:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customHelmetIDs.contains(is.getTypeId())) {
|
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customHelmetIDs.contains(item.getTypeId());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the item is a chestplate.
|
* Checks if the item is a chestplate.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a chestplate, false otherwise
|
* @return true if the item is a chestplate, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isChestplate(ItemStack is) {
|
public static boolean isChestplate(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case DIAMOND_CHESTPLATE:
|
case DIAMOND_CHESTPLATE:
|
||||||
case GOLD_CHESTPLATE:
|
case GOLD_CHESTPLATE:
|
||||||
case IRON_CHESTPLATE:
|
case IRON_CHESTPLATE:
|
||||||
|
case CHAINMAIL_CHESTPLATE:
|
||||||
case LEATHER_CHESTPLATE:
|
case LEATHER_CHESTPLATE:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customChestplateIDs.contains(is.getTypeId())) {
|
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customChestplateIDs.contains(item.getTypeId());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the item is a pair of pants.
|
* Checks if the item is a pair of pants.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a pair of pants, false otherwise
|
* @return true if the item is a pair of pants, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isLeggings(ItemStack is) {
|
public static boolean isLeggings(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case DIAMOND_LEGGINGS:
|
case DIAMOND_LEGGINGS:
|
||||||
case GOLD_LEGGINGS:
|
case GOLD_LEGGINGS:
|
||||||
case IRON_LEGGINGS:
|
case IRON_LEGGINGS:
|
||||||
|
case CHAINMAIL_LEGGINGS:
|
||||||
case LEATHER_LEGGINGS:
|
case LEATHER_LEGGINGS:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customLeggingIDs.contains(is.getTypeId())) {
|
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customLeggingIDs.contains(item.getTypeId());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the item is a pair of boots.
|
* Checks if the item is a pair of boots.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a pair of boots, false otherwise
|
* @return true if the item is a pair of boots, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isBoots(ItemStack is) {
|
public static boolean isBoots(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case DIAMOND_BOOTS:
|
case DIAMOND_BOOTS:
|
||||||
case GOLD_BOOTS:
|
case GOLD_BOOTS:
|
||||||
case IRON_BOOTS:
|
case IRON_BOOTS:
|
||||||
|
case CHAINMAIL_BOOTS:
|
||||||
case LEATHER_BOOTS:
|
case LEATHER_BOOTS:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customBootIDs.contains(is.getTypeId())) {
|
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customBootIDs.contains(item.getTypeId());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if an item is a wearable armor piece.
|
* Checks to see if an item is a wearable armor piece.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is armor, false otherwise
|
* @return true if the item is armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isArmor(ItemStack is) {
|
public static boolean isArmor(ItemStack item) {
|
||||||
return isHelmet(is) || isChestplate(is) || isLeggings(is) || isBoots(is);
|
return isHelmet(item) || isChestplate(item) || isLeggings(item) || isBoots(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if an item is a wearable armor piece.
|
* Checks to see if an item is a wearable *vanilla* armor piece.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is armor, false otherwise
|
* @return true if the item is armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isMinecraftArmor(ItemStack is) {
|
public static boolean isMinecraftArmor(ItemStack item) {
|
||||||
return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is);
|
return isLeatherArmor(item) || isGoldArmor(item) || isIronArmor(item) || isDiamondArmor(item) || isChainmailArmor(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if an item is a leather armor piece.
|
* Checks to see if an item is a leather armor piece.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is leather armor, false otherwise
|
* @return true if the item is leather armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isLeatherArmor(ItemStack is) {
|
public static boolean isLeatherArmor(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case LEATHER_BOOTS:
|
case LEATHER_BOOTS:
|
||||||
case LEATHER_CHESTPLATE:
|
case LEATHER_CHESTPLATE:
|
||||||
case LEATHER_HELMET:
|
case LEATHER_HELMET:
|
||||||
@@ -294,11 +236,11 @@ public class ItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an item is a gold armor piece.
|
* Checks to see if an item is a gold armor piece.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is gold armor, false otherwise
|
* @return true if the item is gold armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isGoldArmor(ItemStack is) {
|
public static boolean isGoldArmor(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case GOLD_BOOTS:
|
case GOLD_BOOTS:
|
||||||
case GOLD_CHESTPLATE:
|
case GOLD_CHESTPLATE:
|
||||||
case GOLD_HELMET:
|
case GOLD_HELMET:
|
||||||
@@ -313,11 +255,11 @@ public class ItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an item is an iron armor piece.
|
* Checks to see if an item is an iron armor piece.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is iron armor, false otherwise
|
* @return true if the item is iron armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isIronArmor(ItemStack is) {
|
public static boolean isIronArmor(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case IRON_BOOTS:
|
case IRON_BOOTS:
|
||||||
case IRON_CHESTPLATE:
|
case IRON_CHESTPLATE:
|
||||||
case IRON_HELMET:
|
case IRON_HELMET:
|
||||||
@@ -332,11 +274,11 @@ public class ItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an item is a diamond armor piece.
|
* Checks to see if an item is a diamond armor piece.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is diamond armor, false otherwise
|
* @return true if the item is diamond armor, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isDiamondArmor(ItemStack is) {
|
public static boolean isDiamondArmor(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case DIAMOND_BOOTS:
|
case DIAMOND_BOOTS:
|
||||||
case DIAMOND_CHESTPLATE:
|
case DIAMOND_CHESTPLATE:
|
||||||
case DIAMOND_HELMET:
|
case DIAMOND_HELMET:
|
||||||
@@ -349,23 +291,42 @@ public class ItemUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if an item is a tool.
|
* Checks to see if an item is a chainmail armor piece.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
|
* @return true if the item is chainmail armor, false otherwise
|
||||||
|
*/
|
||||||
|
public static boolean isChainmailArmor(ItemStack item) {
|
||||||
|
switch (item.getType()) {
|
||||||
|
case CHAINMAIL_BOOTS:
|
||||||
|
case CHAINMAIL_CHESTPLATE:
|
||||||
|
case CHAINMAIL_HELMET:
|
||||||
|
case CHAINMAIL_LEGGINGS:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks to see if an item is a *vanilla* tool.
|
||||||
|
*
|
||||||
|
* @param item Item to check
|
||||||
* @return true if the item is a tool, false otherwise
|
* @return true if the item is a tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isMinecraftTool(ItemStack is) {
|
public static boolean isMinecraftTool(ItemStack item) {
|
||||||
return isStoneTool(is) || isWoodTool(is) || isGoldTool(is) || isIronTool(is) || isDiamondTool(is) || isStringTool(is);
|
return isStoneTool(item) || isWoodTool(item) || isGoldTool(item) || isIronTool(item) || isDiamondTool(item) || isStringTool(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if an item is a stone tool.
|
* Checks to see if an item is a stone tool.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a stone tool, false otherwise
|
* @return true if the item is a stone tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isStoneTool(ItemStack is) {
|
public static boolean isStoneTool(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case STONE_AXE:
|
case STONE_AXE:
|
||||||
case STONE_HOE:
|
case STONE_HOE:
|
||||||
case STONE_PICKAXE:
|
case STONE_PICKAXE:
|
||||||
@@ -381,11 +342,11 @@ public class ItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an item is a wooden tool.
|
* Checks to see if an item is a wooden tool.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a wooden tool, false otherwise
|
* @return true if the item is a wooden tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isWoodTool(ItemStack is) {
|
public static boolean isWoodTool(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case WOOD_AXE:
|
case WOOD_AXE:
|
||||||
case WOOD_HOE:
|
case WOOD_HOE:
|
||||||
case WOOD_PICKAXE:
|
case WOOD_PICKAXE:
|
||||||
@@ -401,11 +362,11 @@ public class ItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an item is a string tool.
|
* Checks to see if an item is a string tool.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a string tool, false otherwise
|
* @return true if the item is a string tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isStringTool(ItemStack is) {
|
public static boolean isStringTool(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case BOW:
|
case BOW:
|
||||||
case CARROT_STICK:
|
case CARROT_STICK:
|
||||||
case FISHING_ROD:
|
case FISHING_ROD:
|
||||||
@@ -419,11 +380,11 @@ public class ItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an item is a gold tool.
|
* Checks to see if an item is a gold tool.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a stone tool, false otherwise
|
* @return true if the item is a stone tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isGoldTool(ItemStack is) {
|
public static boolean isGoldTool(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case GOLD_AXE:
|
case GOLD_AXE:
|
||||||
case GOLD_HOE:
|
case GOLD_HOE:
|
||||||
case GOLD_PICKAXE:
|
case GOLD_PICKAXE:
|
||||||
@@ -439,11 +400,11 @@ public class ItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an item is an iron tool.
|
* Checks to see if an item is an iron tool.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is an iron tool, false otherwise
|
* @return true if the item is an iron tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isIronTool(ItemStack is) {
|
public static boolean isIronTool(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case BUCKET:
|
case BUCKET:
|
||||||
case FLINT_AND_STEEL:
|
case FLINT_AND_STEEL:
|
||||||
case IRON_AXE:
|
case IRON_AXE:
|
||||||
@@ -462,11 +423,11 @@ public class ItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an item is a diamond tool.
|
* Checks to see if an item is a diamond tool.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a diamond tool, false otherwise
|
* @return true if the item is a diamond tool, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isDiamondTool(ItemStack is) {
|
public static boolean isDiamondTool(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case DIAMOND_AXE:
|
case DIAMOND_AXE:
|
||||||
case DIAMOND_HOE:
|
case DIAMOND_HOE:
|
||||||
case DIAMOND_PICKAXE:
|
case DIAMOND_PICKAXE:
|
||||||
@@ -482,16 +443,25 @@ public class ItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an item is enchantable.
|
* Checks to see if an item is enchantable.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is enchantable, false otherwise
|
* @return true if the item is enchantable, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isEnchantable(ItemStack is) {
|
public static boolean isEnchantable(ItemStack item) {
|
||||||
Material type = is.getType();
|
switch (item.getType()) {
|
||||||
return isArmor(is) || isSword(is) || isAxe(is) || isShovel(is) || isPickaxe(is) || type == Material.SHEARS || type == Material.FISHING_ROD || type == Material.CARROT_STICK || type == Material.FLINT_AND_STEEL || type == Material.BOW;
|
case SHEARS:
|
||||||
|
case FISHING_ROD:
|
||||||
|
case CARROT_STICK:
|
||||||
|
case BOW:
|
||||||
|
case FLINT_AND_STEEL:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return isArmor(item) || isSword(item) || isAxe(item) || isShovel(item) || isPickaxe(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSmeltable(ItemStack itemStack) {
|
public static boolean isSmeltable(ItemStack item) {
|
||||||
switch (itemStack.getType()) {
|
switch (item.getType()) {
|
||||||
case COAL_ORE:
|
case COAL_ORE:
|
||||||
case DIAMOND_ORE:
|
case DIAMOND_ORE:
|
||||||
case GLOWING_REDSTONE_ORE:
|
case GLOWING_REDSTONE_ORE:
|
||||||
@@ -500,6 +470,7 @@ public class ItemUtils {
|
|||||||
case LAPIS_ORE:
|
case LAPIS_ORE:
|
||||||
case REDSTONE_ORE:
|
case REDSTONE_ORE:
|
||||||
case EMERALD_ORE:
|
case EMERALD_ORE:
|
||||||
|
case QUARTZ_ORE:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -507,22 +478,19 @@ public class ItemUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSmelted(ItemStack itemStack) {
|
public static boolean isSmelted(ItemStack item) {
|
||||||
switch (itemStack.getType()) {
|
switch (item.getType()) {
|
||||||
case COAL:
|
case COAL:
|
||||||
case DIAMOND:
|
case DIAMOND:
|
||||||
case REDSTONE:
|
case REDSTONE:
|
||||||
case GOLD_INGOT:
|
case GOLD_INGOT:
|
||||||
case IRON_INGOT:
|
case IRON_INGOT:
|
||||||
case EMERALD:
|
case EMERALD:
|
||||||
|
case QUARTZ:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case INK_SACK:
|
case INK_SACK:
|
||||||
if (itemStack.getData().getData() == DyeColor.BLUE.getDyeData()) {
|
return item.getData().getData() == DyeColor.BLUE.getDyeData();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@@ -535,18 +503,18 @@ public class ItemUtils {
|
|||||||
* @param item Item that will get shared
|
* @param item Item that will get shared
|
||||||
* @return True if the item can be shared.
|
* @return True if the item can be shared.
|
||||||
*/
|
*/
|
||||||
public static boolean isShareable(ItemStack is) {
|
public static boolean isShareable(ItemStack item) {
|
||||||
return isMiningDrop(is) || isWoodcuttingDrop(is) || isMobDrop(is) || isHerbalismDrop(is) || isMiscDrop(is);
|
return isMiningDrop(item) || isWoodcuttingDrop(item) || isMobDrop(item) || isHerbalismDrop(item) || isMiscDrop(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if an item is a mining drop.
|
* Checks to see if an item is a mining drop.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a mining drop, false otherwise
|
* @return true if the item is a mining drop, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isMiningDrop(ItemStack is) {
|
public static boolean isMiningDrop(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case COAL:
|
case COAL:
|
||||||
case COAL_ORE:
|
case COAL_ORE:
|
||||||
case DIAMOND:
|
case DIAMOND:
|
||||||
@@ -556,17 +524,15 @@ public class ItemUtils {
|
|||||||
case GOLD_ORE:
|
case GOLD_ORE:
|
||||||
case IRON_ORE:
|
case IRON_ORE:
|
||||||
case LAPIS_ORE:
|
case LAPIS_ORE:
|
||||||
case REDSTONE_ORE:
|
case REDSTONE_ORE: // Should we also have Glowing Redstone Ore here?
|
||||||
case REDSTONE:
|
case REDSTONE:
|
||||||
case GLOWSTONE_DUST:
|
case GLOWSTONE_DUST: // Should we also have Glowstone here?
|
||||||
|
case QUARTZ:
|
||||||
|
case QUARTZ_ORE:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case INK_SACK:
|
case INK_SACK:
|
||||||
if (is.getData().getData() == DyeColor.BLUE.getDyeData()) {
|
return item.getData().getData() == DyeColor.BLUE.getDyeData();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@@ -576,11 +542,11 @@ public class ItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an item is a herbalism drop.
|
* Checks to see if an item is a herbalism drop.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a herbalism drop, false otherwise
|
* @return true if the item is a herbalism drop, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isHerbalismDrop(ItemStack is) {
|
public static boolean isHerbalismDrop(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case WHEAT:
|
case WHEAT:
|
||||||
case SEEDS:
|
case SEEDS:
|
||||||
case CARROT_ITEM:
|
case CARROT_ITEM:
|
||||||
@@ -601,7 +567,7 @@ public class ItemUtils {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case INK_SACK:
|
case INK_SACK:
|
||||||
return is.getData().getData() == DyeColor.BROWN.getDyeData();
|
return item.getData().getData() == DyeColor.BROWN.getDyeData();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@@ -611,11 +577,11 @@ public class ItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an item is a mob drop.
|
* Checks to see if an item is a mob drop.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a mob drop, false otherwise
|
* @return true if the item is a mob drop, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isMobDrop(ItemStack is) {
|
public static boolean isMobDrop(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case STRING:
|
case STRING:
|
||||||
case FEATHER:
|
case FEATHER:
|
||||||
case RAW_CHICKEN:
|
case RAW_CHICKEN:
|
||||||
@@ -626,7 +592,7 @@ public class ItemUtils {
|
|||||||
case PORK:
|
case PORK:
|
||||||
case GRILLED_PORK:
|
case GRILLED_PORK:
|
||||||
case WOOL:
|
case WOOL:
|
||||||
case RED_ROSE:
|
case RED_ROSE: // Not sure we should include this, as it will also trigger from herbalism
|
||||||
case IRON_INGOT:
|
case IRON_INGOT:
|
||||||
case SNOW_BALL:
|
case SNOW_BALL:
|
||||||
case BLAZE_ROD:
|
case BLAZE_ROD:
|
||||||
@@ -639,7 +605,7 @@ public class ItemUtils {
|
|||||||
case ARROW:
|
case ARROW:
|
||||||
case SLIME_BALL:
|
case SLIME_BALL:
|
||||||
case NETHER_STAR:
|
case NETHER_STAR:
|
||||||
case COAL:
|
case COAL: // Not sure we should include this, as it will also trigger when mining
|
||||||
case ROTTEN_FLESH:
|
case ROTTEN_FLESH:
|
||||||
case GOLD_NUGGET:
|
case GOLD_NUGGET:
|
||||||
case EGG:
|
case EGG:
|
||||||
@@ -653,11 +619,11 @@ public class ItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an item is a woodcutting drop.
|
* Checks to see if an item is a woodcutting drop.
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a woodcutting drop, false otherwise
|
* @return true if the item is a woodcutting drop, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isWoodcuttingDrop(ItemStack is) {
|
public static boolean isWoodcuttingDrop(ItemStack item) {
|
||||||
switch (is.getType()) {
|
switch (item.getType()) {
|
||||||
case LOG:
|
case LOG:
|
||||||
case LEAVES:
|
case LEAVES:
|
||||||
case SAPLING:
|
case SAPLING:
|
||||||
@@ -672,38 +638,28 @@ public class ItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if an item is a miscellaneous drop. These items are read from the config file
|
* Checks to see if an item is a miscellaneous drop. These items are read from the config file
|
||||||
*
|
*
|
||||||
* @param is Item to check
|
* @param item Item to check
|
||||||
* @return true if the item is a miscellaneous drop, false otherwise
|
* @return true if the item is a miscellaneous drop, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isMiscDrop(ItemStack is) {
|
public static boolean isMiscDrop(ItemStack item) {
|
||||||
return ItemWeightConfig.getInstance().getMiscItems().contains(is.getType());
|
return ItemWeightConfig.getInstance().getMiscItems().contains(item.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isMcMMOItem(ItemStack is) {
|
public static boolean isMcMMOItem(ItemStack item) {
|
||||||
if (!is.hasItemMeta()) {
|
if (!item.hasItemMeta()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemMeta itemMeta = is.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
if (itemMeta.hasLore()) {
|
return itemMeta.hasLore() && itemMeta.getLore().contains("mcMMO Item");
|
||||||
List<String> itemLore = itemMeta.getLore();
|
|
||||||
if (itemLore.contains("mcMMO Item")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isChimaeraWing(ItemStack is) {
|
public static boolean isChimaeraWing(ItemStack item) {
|
||||||
if (!isMcMMOItem(is)) {
|
if (!isMcMMOItem(item)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemMeta itemMeta = is.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
if (itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + "Chimaera Wing")) { //TODO Get localized name
|
return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name"));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Item;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
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.spout.huds.McMMOHud;
|
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
|
||||||
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
|
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
|
||||||
@@ -20,7 +20,6 @@ import com.gmail.nossr50.util.spout.SpoutUtils;
|
|||||||
|
|
||||||
public final class Misc {
|
public final class Misc {
|
||||||
private static Random random = new Random();
|
private static Random random = new Random();
|
||||||
public static boolean isSpawnerXPEnabled = Config.getInstance().getExperienceGainsMobspawnersEnabled();
|
|
||||||
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
|
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
|
||||||
public static final int TIME_CONVERSION_FACTOR = 1000;
|
public static final int TIME_CONVERSION_FACTOR = 1000;
|
||||||
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
|
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
|
||||||
@@ -32,6 +31,7 @@ public final class Misc {
|
|||||||
public static final float POP_VOLUME = 0.2F;
|
public static final float POP_VOLUME = 0.2F;
|
||||||
public static final float BAT_VOLUME = 1.0F;
|
public static final float BAT_VOLUME = 1.0F;
|
||||||
public static final float BAT_PITCH = 0.6F;
|
public static final float BAT_PITCH = 0.6F;
|
||||||
|
public static final float GHAST_VOLUME = 1.0F;
|
||||||
|
|
||||||
private Misc() {};
|
private Misc() {};
|
||||||
|
|
||||||
@@ -43,8 +43,12 @@ public final class Misc {
|
|||||||
return ((getRandom().nextFloat() - getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F;
|
return ((getRandom().nextFloat() - getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float getGhastPitch() {
|
||||||
|
return (getRandom().nextFloat() - getRandom().nextFloat()) * 0.2F + 1.0F;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isNPCEntity(Entity entity) {
|
public static boolean isNPCEntity(Entity entity) {
|
||||||
return (entity == null || entity.hasMetadata("NPC") || (mcMMO.combatTagEnabled && entity instanceof HumanEntity && ((HumanEntity) entity).getName().contains("PvpLogger")));
|
return (entity == null || entity.hasMetadata("NPC") || (mcMMO.isCombatTagEnabled() && entity instanceof HumanEntity && ((HumanEntity) entity).getName().contains("PvpLogger")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,11 +95,13 @@ public final class Misc {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first.distanceSquared(second) < (maxDistance * maxDistance)) {
|
return first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
public static void dropItems(Location location, Collection<ItemStack> drops) {
|
||||||
|
for (ItemStack drop : drops) {
|
||||||
|
dropItem(location, drop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,7 +154,6 @@ public final class Misc {
|
|||||||
* @param itemStack The item to drop
|
* @param itemStack The item to drop
|
||||||
*/
|
*/
|
||||||
public static void dropItem(Location location, ItemStack itemStack) {
|
public static void dropItem(Location location, ItemStack itemStack) {
|
||||||
|
|
||||||
if (itemStack.getType() == Material.AIR) {
|
if (itemStack.getType() == Material.AIR) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -161,12 +166,7 @@ public final class Misc {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item newItem = location.getWorld().dropItemNaturally(location, itemStack);
|
location.getWorld().dropItemNaturally(location, itemStack);
|
||||||
|
|
||||||
ItemStack cloned = itemStack.clone();
|
|
||||||
cloned.setAmount(newItem.getItemStack().getAmount());
|
|
||||||
|
|
||||||
newItem.setItemStack(cloned);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void profileCleanup(String playerName) {
|
public static void profileCleanup(String playerName) {
|
||||||
@@ -185,7 +185,7 @@ public final class Misc {
|
|||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
UserManager.addUser(player);
|
UserManager.addUser(player);
|
||||||
|
|
||||||
if (mcMMO.spoutEnabled) {
|
if (mcMMO.isSpoutEnabled()) {
|
||||||
SpoutUtils.reloadSpoutPlayer(player);
|
SpoutUtils.reloadSpoutPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,8 +193,12 @@ public final class Misc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void resendChunkRadiusAt(Player player, int radius) {
|
public static void resendChunkRadiusAt(Player player, int radius) {
|
||||||
for (int x = player.getLocation().getChunk().getX() - radius; x < player.getLocation().getChunk().getX() + radius; x++) {
|
Chunk chunk = player.getLocation().getChunk();
|
||||||
for (int z = player.getLocation().getChunk().getZ() - radius; z < player.getLocation().getChunk().getZ() + radius; z++) {
|
int chunkX = chunk.getX();
|
||||||
|
int chunkZ = chunk.getZ();
|
||||||
|
|
||||||
|
for (int x = chunkX - radius; x < chunkX + radius; x++) {
|
||||||
|
for (int z = chunkZ - radius; z < chunkZ + radius; z++) {
|
||||||
player.getWorld().refreshChunk(x, z);
|
player.getWorld().refreshChunk(x, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
@@ -34,9 +35,9 @@ public final class MobHealthbarUtils {
|
|||||||
/**
|
/**
|
||||||
* Handle the creation of mob healthbars.
|
* Handle the creation of mob healthbars.
|
||||||
*
|
*
|
||||||
* @param profile The
|
* @param player the attacking player
|
||||||
* @param target
|
* @param target the targetted entity
|
||||||
* @param damage
|
* @param damage damage done by the attack triggering this
|
||||||
*/
|
*/
|
||||||
public static void handleMobHealthbars(Player player, LivingEntity target, int damage) {
|
public static void handleMobHealthbars(Player player, LivingEntity target, int damage) {
|
||||||
if (!Permissions.mobHealthDisplay(player)) {
|
if (!Permissions.mobHealthDisplay(player)) {
|
||||||
@@ -45,11 +46,23 @@ public final class MobHealthbarUtils {
|
|||||||
|
|
||||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||||
|
|
||||||
|
if (profile.getMobHealthbarType() == null) {
|
||||||
|
profile.setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
|
||||||
|
}
|
||||||
|
|
||||||
if (profile.getMobHealthbarType() == MobHealthbarType.DISABLED) {
|
if (profile.getMobHealthbarType() == MobHealthbarType.DISABLED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String oldName = target.getCustomName();
|
String oldName = target.getCustomName();
|
||||||
|
|
||||||
|
if (oldName == null) {
|
||||||
|
oldName = "";
|
||||||
|
}
|
||||||
|
else if (oldName.equalsIgnoreCase(AdvancedConfig.getInstance().getKrakenName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean oldNameVisible = target.isCustomNameVisible();
|
boolean oldNameVisible = target.isCustomNameVisible();
|
||||||
String newName = createHealthDisplay(profile, target, damage);
|
String newName = createHealthDisplay(profile, target, damage);
|
||||||
|
|
||||||
@@ -59,10 +72,6 @@ public final class MobHealthbarUtils {
|
|||||||
int displayTime = Config.getInstance().getMobHealthbarTime();
|
int displayTime = Config.getInstance().getMobHealthbarTime();
|
||||||
|
|
||||||
if (displayTime != -1) {
|
if (displayTime != -1) {
|
||||||
if (oldName == null) {
|
|
||||||
oldName = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean updateName = !ChatColor.stripColor(oldName).equalsIgnoreCase(ChatColor.stripColor(newName));
|
boolean updateName = !ChatColor.stripColor(oldName).equalsIgnoreCase(ChatColor.stripColor(newName));
|
||||||
|
|
||||||
if (updateName) {
|
if (updateName) {
|
||||||
@@ -123,7 +132,7 @@ public final class MobHealthbarUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int coloredDisplay = (int) (fullDisplay * (healthPercentage / 100.0D));
|
int coloredDisplay = (int) Math.ceil(fullDisplay * (healthPercentage / 100.0D));
|
||||||
int grayDisplay = fullDisplay - coloredDisplay;
|
int grayDisplay = fullDisplay - coloredDisplay;
|
||||||
|
|
||||||
String healthbar = color + "";
|
String healthbar = color + "";
|
||||||
@@ -140,5 +149,4 @@ public final class MobHealthbarUtils {
|
|||||||
|
|
||||||
return healthbar;
|
return healthbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public final class Permissions {
|
|||||||
/* BYPASS */
|
/* BYPASS */
|
||||||
public static boolean hardcoreBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.hardcoremode"); }
|
public static boolean hardcoreBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.hardcoremode"); }
|
||||||
public static boolean arcaneBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.arcanebypass"); }
|
public static boolean arcaneBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.arcanebypass"); }
|
||||||
|
public static boolean krakenBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.kraken"); }
|
||||||
|
|
||||||
/* CHAT */
|
/* CHAT */
|
||||||
public static boolean partyChat(Permissible permissible) { return permissible.hasPermission("mcmmo.chat.partychat"); }
|
public static boolean partyChat(Permissible permissible) { return permissible.hasPermission("mcmmo.chat.partychat"); }
|
||||||
@@ -49,6 +50,9 @@ public final class Permissions {
|
|||||||
public static boolean inspectFar(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.far")); }
|
public static boolean inspectFar(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.far")); }
|
||||||
public static boolean inspectOffline(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.offline")); }
|
public static boolean inspectOffline(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.offline")); }
|
||||||
|
|
||||||
|
public static boolean kraken(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.kraken"); }
|
||||||
|
public static boolean krakenOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.kraken.others"); }
|
||||||
|
|
||||||
public static boolean mcability(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability")); }
|
public static boolean mcability(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability")); }
|
||||||
public static boolean mcabilityOthers(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability.others")); }
|
public static boolean mcabilityOthers(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability.others")); }
|
||||||
|
|
||||||
@@ -142,6 +146,7 @@ public final class Permissions {
|
|||||||
/* FISHING */
|
/* FISHING */
|
||||||
public static boolean fishermansDiet(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.fishermansdiet"); }
|
public static boolean fishermansDiet(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.fishermansdiet"); }
|
||||||
public static boolean fishingTreasureHunter(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.treasures"); }
|
public static boolean fishingTreasureHunter(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.treasures"); }
|
||||||
|
public static boolean iceFishing(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.icefishing"); }
|
||||||
public static boolean magicHunter(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.magic"); }
|
public static boolean magicHunter(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.magic"); }
|
||||||
public static boolean masterAngler(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.masterangler"); }
|
public static boolean masterAngler(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.masterangler"); }
|
||||||
public static boolean shake(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.shakemob"); }
|
public static boolean shake(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.shakemob"); }
|
||||||
|
|||||||
@@ -11,11 +11,7 @@ public class StringUtils {
|
|||||||
* @return the capitalized string
|
* @return the capitalized string
|
||||||
*/
|
*/
|
||||||
public static String getCapitalized(String target) {
|
public static String getCapitalized(String target) {
|
||||||
String firstLetter = target.substring(0, 1);
|
return target.substring(0, 1).toUpperCase() + target.substring(1).toLowerCase();
|
||||||
String remainder = target.substring(1);
|
|
||||||
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
|
|
||||||
|
|
||||||
return capitalized;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,22 +96,6 @@ public class StringUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if a string represents a Long
|
|
||||||
*
|
|
||||||
* @param string String to check
|
|
||||||
* @return true if the string is a Long, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean isLong(String string) {
|
|
||||||
try {
|
|
||||||
Long.parseLong(string);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (NumberFormatException nFE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a string represents a Double
|
* Determine if a string represents a Double
|
||||||
*
|
*
|
||||||
@@ -131,5 +111,4 @@ public class StringUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ import java.util.List;
|
|||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.commands.KrakenCommand;
|
||||||
import com.gmail.nossr50.commands.McabilityCommand;
|
import com.gmail.nossr50.commands.McabilityCommand;
|
||||||
import com.gmail.nossr50.commands.McgodCommand;
|
import com.gmail.nossr50.commands.McgodCommand;
|
||||||
import com.gmail.nossr50.commands.McmmoCommand;
|
import com.gmail.nossr50.commands.McmmoCommand;
|
||||||
import com.gmail.nossr50.commands.McnotifyCommand;
|
import com.gmail.nossr50.commands.McnotifyCommand;
|
||||||
import com.gmail.nossr50.commands.McrefreshCommand;
|
import com.gmail.nossr50.commands.McrefreshCommand;
|
||||||
|
import com.gmail.nossr50.commands.McscoreboardCommand;
|
||||||
import com.gmail.nossr50.commands.MobhealthCommand;
|
import com.gmail.nossr50.commands.MobhealthCommand;
|
||||||
import com.gmail.nossr50.commands.XprateCommand;
|
import com.gmail.nossr50.commands.XprateCommand;
|
||||||
import com.gmail.nossr50.commands.chat.AdminChatCommand;
|
import com.gmail.nossr50.commands.chat.AdminChatCommand;
|
||||||
@@ -56,7 +58,7 @@ public final class CommandRegistrationManager {
|
|||||||
|
|
||||||
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
|
||||||
|
|
||||||
public static void registerSkillCommands() {
|
private static void registerSkillCommands() {
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.values()) {
|
||||||
String commandName = skill.toString().toLowerCase();
|
String commandName = skill.toString().toLowerCase();
|
||||||
String localizedName = SkillUtils.getSkillName(skill).toLowerCase();
|
String localizedName = SkillUtils.getSkillName(skill).toLowerCase();
|
||||||
@@ -129,7 +131,7 @@ public final class CommandRegistrationManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerAddlevelsCommand() {
|
private static void registerAddlevelsCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("addlevels");
|
PluginCommand command = mcMMO.p.getCommand("addlevels");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.addlevels"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.addlevels"));
|
||||||
command.setPermission("mcmmo.commands.addlevels;mcmmo.commands.addlevels.others");
|
command.setPermission("mcmmo.commands.addlevels;mcmmo.commands.addlevels.others");
|
||||||
@@ -138,7 +140,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new AddlevelsCommand());
|
command.setExecutor(new AddlevelsCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerAddxpCommand() {
|
private static void registerAddxpCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("addxp");
|
PluginCommand command = mcMMO.p.getCommand("addxp");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.addxp"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.addxp"));
|
||||||
command.setPermission("mcmmo.commands.addxp;mcmmo.commands.addxp.others");
|
command.setPermission("mcmmo.commands.addxp;mcmmo.commands.addxp.others");
|
||||||
@@ -147,7 +149,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new AddxpCommand());
|
command.setExecutor(new AddxpCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMcgodCommand() {
|
private static void registerMcgodCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mcgod");
|
PluginCommand command = mcMMO.p.getCommand("mcgod");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcgod"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.mcgod"));
|
||||||
command.setPermission("mcmmo.commands.mcgod;mcmmo.commands.mcgod.others");
|
command.setPermission("mcmmo.commands.mcgod;mcmmo.commands.mcgod.others");
|
||||||
@@ -156,7 +158,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new McgodCommand());
|
command.setExecutor(new McgodCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMcrefreshCommand() {
|
private static void registerMcrefreshCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mcrefresh");
|
PluginCommand command = mcMMO.p.getCommand("mcrefresh");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh"));
|
||||||
command.setPermission("mcmmo.commands.mcrefresh;mcmmo.commands.mcrefresh.others");
|
command.setPermission("mcmmo.commands.mcrefresh;mcmmo.commands.mcrefresh.others");
|
||||||
@@ -165,7 +167,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new McrefreshCommand());
|
command.setExecutor(new McrefreshCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMmoeditCommand() {
|
private static void registerMmoeditCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mmoedit");
|
PluginCommand command = mcMMO.p.getCommand("mmoedit");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.mmoedit"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.mmoedit"));
|
||||||
command.setPermission("mcmmo.commands.mmoedit;mcmmo.commands.mmoedit.others");
|
command.setPermission("mcmmo.commands.mmoedit;mcmmo.commands.mmoedit.others");
|
||||||
@@ -174,7 +176,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new MmoeditCommand());
|
command.setExecutor(new MmoeditCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerSkillresetCommand() {
|
private static void registerSkillresetCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("skillreset");
|
PluginCommand command = mcMMO.p.getCommand("skillreset");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.skillreset"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.skillreset"));
|
||||||
command.setPermission("mcmmo.commands.skillreset;mcmmo.commands.skillreset.others"); // Only need the main ones, not the individual skill ones
|
command.setPermission("mcmmo.commands.skillreset;mcmmo.commands.skillreset.others"); // Only need the main ones, not the individual skill ones
|
||||||
@@ -183,7 +185,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new SkillresetCommand());
|
command.setExecutor(new SkillresetCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerXprateCommand() {
|
private static void registerXprateCommand() {
|
||||||
List<String> aliasList = new ArrayList<String>();
|
List<String> aliasList = new ArrayList<String>();
|
||||||
aliasList.add("mcxprate");
|
aliasList.add("mcxprate");
|
||||||
|
|
||||||
@@ -197,7 +199,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new XprateCommand());
|
command.setExecutor(new XprateCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerInspectCommand() {
|
private static void registerInspectCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("inspect");
|
PluginCommand command = mcMMO.p.getCommand("inspect");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.inspect"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.inspect"));
|
||||||
command.setPermission("mcmmo.commands.inspect;mcmmo.commands.inspect.far;mcmmo.commands.inspect.offline");
|
command.setPermission("mcmmo.commands.inspect;mcmmo.commands.inspect.far;mcmmo.commands.inspect.offline");
|
||||||
@@ -206,7 +208,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new InspectCommand());
|
command.setExecutor(new InspectCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMcabilityCommand() {
|
private static void registerMcabilityCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mcability");
|
PluginCommand command = mcMMO.p.getCommand("mcability");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcability"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.mcability"));
|
||||||
command.setPermission("mcmmo.commands.mcability;mcmmo.commands.mcability.others");
|
command.setPermission("mcmmo.commands.mcability;mcmmo.commands.mcability.others");
|
||||||
@@ -215,7 +217,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new McabilityCommand());
|
command.setExecutor(new McabilityCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMcmmoCommand() {
|
private static void registerMcmmoCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mcmmo");
|
PluginCommand command = mcMMO.p.getCommand("mcmmo");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcmmo"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.mcmmo"));
|
||||||
command.setPermission("mcmmo.commands.mcmmo.description;mcmmo.commands.mcmmo.help");
|
command.setPermission("mcmmo.commands.mcmmo.description;mcmmo.commands.mcmmo.help");
|
||||||
@@ -225,7 +227,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new McmmoCommand());
|
command.setExecutor(new McmmoCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMcrankCommand() {
|
private static void registerMcrankCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mcrank");
|
PluginCommand command = mcMMO.p.getCommand("mcrank");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcrank"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.mcrank"));
|
||||||
command.setPermission("mcmmo.commands.mcrank;mcmmo.commands.mcrank.others;mcmmo.commands.mcrank.others.far;mcmmo.commands.mcrank.others.offline");
|
command.setPermission("mcmmo.commands.mcrank;mcmmo.commands.mcrank.others;mcmmo.commands.mcrank.others.far;mcmmo.commands.mcrank.others.offline");
|
||||||
@@ -234,7 +236,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new McrankCommand());
|
command.setExecutor(new McrankCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMcstatsCommand() {
|
private static void registerMcstatsCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mcstats");
|
PluginCommand command = mcMMO.p.getCommand("mcstats");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcstats"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.mcstats"));
|
||||||
command.setPermission("mcmmo.commands.mcstats");
|
command.setPermission("mcmmo.commands.mcstats");
|
||||||
@@ -243,7 +245,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new McstatsCommand());
|
command.setExecutor(new McstatsCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMctopCommand() {
|
private static void registerMctopCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mctop");
|
PluginCommand command = mcMMO.p.getCommand("mctop");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.mctop"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.mctop"));
|
||||||
command.setPermission("mcmmo.commands.mctop"); // Only need the main one, not the individual skill ones
|
command.setPermission("mcmmo.commands.mctop"); // Only need the main one, not the individual skill ones
|
||||||
@@ -252,31 +254,34 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new MctopCommand());
|
command.setExecutor(new MctopCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMcpurgeCommand() {
|
private static void registerMcpurgeCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mcpurge");
|
PluginCommand command = mcMMO.p.getCommand("mcpurge");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcpurge", Config.getInstance().getOldUsersCutoff()));
|
command.setDescription(LocaleLoader.getString("Commands.Description.mcpurge", Config.getInstance().getOldUsersCutoff()));
|
||||||
|
command.setPermission("mcmmo.commands.mcpurge");
|
||||||
command.setPermissionMessage(permissionsMessage);
|
command.setPermissionMessage(permissionsMessage);
|
||||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge"));
|
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge"));
|
||||||
command.setExecutor(new McpurgeCommand());
|
command.setExecutor(new McpurgeCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMcremoveCommand() {
|
private static void registerMcremoveCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mcremove");
|
PluginCommand command = mcMMO.p.getCommand("mcremove");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcremove"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.mcremove"));
|
||||||
|
command.setPermission("mcmmo.commands.mcremove");
|
||||||
command.setPermissionMessage(permissionsMessage);
|
command.setPermissionMessage(permissionsMessage);
|
||||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||||
command.setExecutor(new McremoveCommand());
|
command.setExecutor(new McremoveCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMmoupdateCommand() {
|
private static void registerMmoupdateCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mmoupdate");
|
PluginCommand command = mcMMO.p.getCommand("mmoupdate");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.mmoupdate"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.mmoupdate"));
|
||||||
|
command.setPermission("mcmmo.commands.mmoupdate");
|
||||||
command.setPermissionMessage(permissionsMessage);
|
command.setPermissionMessage(permissionsMessage);
|
||||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mmoupdate"));
|
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mmoupdate"));
|
||||||
command.setExecutor(new MmoupdateCommand());
|
command.setExecutor(new MmoupdateCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerAdminChatCommand() {
|
private static void registerAdminChatCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("adminchat");
|
PluginCommand command = mcMMO.p.getCommand("adminchat");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.adminchat"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.adminchat"));
|
||||||
command.setPermission("mcmmo.chat.adminchat");
|
command.setPermission("mcmmo.chat.adminchat");
|
||||||
@@ -287,7 +292,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new AdminChatCommand());
|
command.setExecutor(new AdminChatCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerPartyChatCommand() {
|
private static void registerPartyChatCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("partychat");
|
PluginCommand command = mcMMO.p.getCommand("partychat");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.partychat"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.partychat"));
|
||||||
command.setPermission("mcmmo.chat.partychat;mcmmo.commands.party");
|
command.setPermission("mcmmo.chat.partychat;mcmmo.commands.party");
|
||||||
@@ -298,7 +303,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new PartyChatCommand());
|
command.setExecutor(new PartyChatCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMchudCommand() {
|
private static void registerMchudCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mchud");
|
PluginCommand command = mcMMO.p.getCommand("mchud");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.mchud"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.mchud"));
|
||||||
command.setPermission("mcmmo.commands.mchud");
|
command.setPermission("mcmmo.commands.mchud");
|
||||||
@@ -307,7 +312,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new MchudCommand());
|
command.setExecutor(new MchudCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerXplockCommand() {
|
private static void registerXplockCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("xplock");
|
PluginCommand command = mcMMO.p.getCommand("xplock");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.xplock"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.xplock"));
|
||||||
command.setPermission("mcmmo.commands.xplock");
|
command.setPermission("mcmmo.commands.xplock");
|
||||||
@@ -318,7 +323,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new XplockCommand());
|
command.setExecutor(new XplockCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerPartyCommand() {
|
private static void registerPartyCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("party");
|
PluginCommand command = mcMMO.p.getCommand("party");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.party"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.party"));
|
||||||
command.setPermission("mcmmo.commands.party;mcmmo.commands.party.accept;mcmmo.commands.party.create;mcmmo.commands.party.disband;" +
|
command.setPermission("mcmmo.commands.party;mcmmo.commands.party.accept;mcmmo.commands.party.create;mcmmo.commands.party.disband;" +
|
||||||
@@ -329,7 +334,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new PartyCommand());
|
command.setExecutor(new PartyCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerPtpCommand() {
|
private static void registerPtpCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("ptp");
|
PluginCommand command = mcMMO.p.getCommand("ptp");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.ptp"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.ptp"));
|
||||||
command.setPermission("mcmmo.commands.ptp"); // Only need the main one, not the individual ones for toggle/accept/acceptall
|
command.setPermission("mcmmo.commands.ptp"); // Only need the main one, not the individual ones for toggle/accept/acceptall
|
||||||
@@ -339,7 +344,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new PtpCommand());
|
command.setExecutor(new PtpCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerHardcoreCommand() {
|
private static void registerHardcoreCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("hardcore");
|
PluginCommand command = mcMMO.p.getCommand("hardcore");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.hardcore"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.hardcore"));
|
||||||
command.setPermission("mcmmo.commands.hardcore;mcmmo.commands.hardcore.toggle;mcmmo.commands.hardcore.modify");
|
command.setPermission("mcmmo.commands.hardcore;mcmmo.commands.hardcore.toggle;mcmmo.commands.hardcore.modify");
|
||||||
@@ -349,7 +354,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new HardcoreCommand());
|
command.setExecutor(new HardcoreCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerVampirismCommand() {
|
private static void registerVampirismCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("vampirism");
|
PluginCommand command = mcMMO.p.getCommand("vampirism");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.vampirism"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.vampirism"));
|
||||||
command.setPermission("mcmmo.commands.vampirism;mcmmo.commands.vampirism.toggle;mcmmo.commands.vampirism.modify");
|
command.setPermission("mcmmo.commands.vampirism;mcmmo.commands.vampirism.toggle;mcmmo.commands.vampirism.modify");
|
||||||
@@ -359,7 +364,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new VampirismCommand());
|
command.setExecutor(new VampirismCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMcnotifyCommand() {
|
private static void registerMcnotifyCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mcnotify");
|
PluginCommand command = mcMMO.p.getCommand("mcnotify");
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcnotify"));
|
command.setDescription(LocaleLoader.getString("Commands.Description.mcnotify"));
|
||||||
command.setPermission("mcmmo.commands.mcnotify");
|
command.setPermission("mcmmo.commands.mcnotify");
|
||||||
@@ -368,7 +373,7 @@ public final class CommandRegistrationManager {
|
|||||||
command.setExecutor(new McnotifyCommand());
|
command.setExecutor(new McnotifyCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMobhealthCommand() {
|
private static void registerMobhealthCommand() {
|
||||||
PluginCommand command = mcMMO.p.getCommand("mobhealth");
|
PluginCommand command = mcMMO.p.getCommand("mobhealth");
|
||||||
command.setDescription("Change the style of the mob healthbar"); //TODO: Localize
|
command.setDescription("Change the style of the mob healthbar"); //TODO: Localize
|
||||||
command.setPermission("mcmmo.commands.mobhealth");
|
command.setPermission("mcmmo.commands.mobhealth");
|
||||||
@@ -376,4 +381,72 @@ public final class CommandRegistrationManager {
|
|||||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mobhealth", "<DISABLED | HEARTS | BAR>"));
|
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mobhealth", "<DISABLED | HEARTS | BAR>"));
|
||||||
command.setExecutor(new MobhealthCommand());
|
command.setExecutor(new MobhealthCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void registerMcscoreboardCommand() {
|
||||||
|
PluginCommand command = mcMMO.p.getCommand("mcscoreboard");
|
||||||
|
command.setDescription("Change the current mcMMO scoreboard being displayed"); //TODO: Localize
|
||||||
|
command.setPermission("mcmmo.commands.mcscoreboard");
|
||||||
|
command.setPermissionMessage(permissionsMessage);
|
||||||
|
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcscoreboard", "<CLEAR | RANK | STATS | TOP>"));
|
||||||
|
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.3", "mcscoreboard", "top", "[" + LocaleLoader.getString("Commands.Usage.Skill") + "]", "[" + LocaleLoader.getString("Commands.Usage.Page") + "]"));
|
||||||
|
command.setExecutor(new McscoreboardCommand());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void registerKrakenCommand() {
|
||||||
|
PluginCommand command = mcMMO.p.getCommand("kraken");
|
||||||
|
command.setDescription("Unleash the kraken!"); //TODO: Localize
|
||||||
|
command.setPermission("mcmmo.commands.kraken;mcmmo.commands.kraken.others");
|
||||||
|
command.setPermissionMessage(permissionsMessage);
|
||||||
|
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "kraken", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
||||||
|
command.setExecutor(new KrakenCommand());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerCommands() {
|
||||||
|
// Generic Commands
|
||||||
|
registerKrakenCommand();
|
||||||
|
registerMcabilityCommand();
|
||||||
|
registerMcgodCommand();
|
||||||
|
registerMcmmoCommand();
|
||||||
|
registerMcnotifyCommand();
|
||||||
|
registerMcrefreshCommand();
|
||||||
|
registerMcscoreboardCommand();
|
||||||
|
registerMobhealthCommand();
|
||||||
|
registerXprateCommand();
|
||||||
|
|
||||||
|
// Chat Commands
|
||||||
|
registerPartyChatCommand();
|
||||||
|
registerAdminChatCommand();
|
||||||
|
|
||||||
|
// Database Commands
|
||||||
|
registerMcpurgeCommand();
|
||||||
|
registerMcremoveCommand();
|
||||||
|
registerMmoupdateCommand();
|
||||||
|
|
||||||
|
// Experience Commands
|
||||||
|
registerAddlevelsCommand();
|
||||||
|
registerAddxpCommand();
|
||||||
|
registerMmoeditCommand();
|
||||||
|
registerSkillresetCommand();
|
||||||
|
|
||||||
|
// Hardcore Commands
|
||||||
|
registerHardcoreCommand();
|
||||||
|
registerVampirismCommand();
|
||||||
|
|
||||||
|
// Party Commands
|
||||||
|
registerPartyCommand();
|
||||||
|
registerPtpCommand();
|
||||||
|
|
||||||
|
// Player Commands
|
||||||
|
registerInspectCommand();
|
||||||
|
registerMcrankCommand();
|
||||||
|
registerMcstatsCommand();
|
||||||
|
registerMctopCommand();
|
||||||
|
|
||||||
|
// Skill Commands
|
||||||
|
registerSkillCommands();
|
||||||
|
|
||||||
|
// Spout Commands
|
||||||
|
registerXplockCommand();
|
||||||
|
registerMchudCommand();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
import org.bukkit.command.CommandSender;
|
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.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
@@ -46,7 +47,7 @@ public final class CommandUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean tooFar(CommandSender sender, Player target, boolean hasPermission) {
|
public static boolean tooFar(CommandSender sender, Player target, boolean hasPermission) {
|
||||||
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !hasPermission) {
|
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), Config.getInstance().getInspectDistance()) && !hasPermission) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,16 @@ import org.bukkit.scoreboard.Objective;
|
|||||||
import org.bukkit.scoreboard.Scoreboard;
|
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.database.FlatfileDatabaseManager;
|
import com.gmail.nossr50.database.FlatfileDatabaseManager;
|
||||||
import com.gmail.nossr50.database.SQLDatabaseManager;
|
import com.gmail.nossr50.database.SQLDatabaseManager;
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
import com.gmail.nossr50.datatypes.database.PlayerStat;
|
||||||
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.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.runnables.scoreboards.ScoreboardChangeTask;
|
import com.gmail.nossr50.runnables.scoreboards.ScoreboardChangeTask;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class ScoreboardManager {
|
public class ScoreboardManager {
|
||||||
@@ -32,6 +33,7 @@ public class ScoreboardManager {
|
|||||||
private final static String PLAYER_STATS_HEADER = "mcMMO Stats";
|
private final static String PLAYER_STATS_HEADER = "mcMMO Stats";
|
||||||
private final static String PLAYER_RANK_HEADER = "mcMMO Rankings";
|
private final static String PLAYER_RANK_HEADER = "mcMMO Rankings";
|
||||||
private final static String PLAYER_INSPECT_HEADER = "mcMMO Stats: ";
|
private final static String PLAYER_INSPECT_HEADER = "mcMMO Stats: ";
|
||||||
|
private final static String POWER_LEVEL_HEADER = "Power Level";
|
||||||
|
|
||||||
private final static List<String> SCOREBOARD_TASKS = new ArrayList<String>();
|
private final static List<String> SCOREBOARD_TASKS = new ArrayList<String>();
|
||||||
|
|
||||||
@@ -43,6 +45,32 @@ public class ScoreboardManager {
|
|||||||
PLAYER_SCOREBOARDS.put(playerName, mcMMO.p.getServer().getScoreboardManager().getNewScoreboard());
|
PLAYER_SCOREBOARDS.put(playerName, mcMMO.p.getServer().getScoreboardManager().getNewScoreboard());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void enablePowerLevelDisplay(Player player) {
|
||||||
|
if (!Config.getInstance().getPowerLevelsEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Scoreboard scoreboard = player.getScoreboard();
|
||||||
|
Objective objective;
|
||||||
|
|
||||||
|
if (scoreboard.getObjective(DisplaySlot.BELOW_NAME) == null) {
|
||||||
|
objective = scoreboard.registerNewObjective(POWER_LEVEL_HEADER, "dummy");
|
||||||
|
|
||||||
|
objective.getScore(player).setScore(UserManager.getPlayer(player).getPowerLevel());
|
||||||
|
objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
objective = scoreboard.getObjective(POWER_LEVEL_HEADER);
|
||||||
|
|
||||||
|
if (scoreboard.getObjective(POWER_LEVEL_HEADER) != null) {
|
||||||
|
objective.getScore(player).setScore(UserManager.getPlayer(player).getPowerLevel());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mcMMO.p.debug("Another plugin is using this scoreboard slot, so power levels cannot be enabled."); //TODO: Locale
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void enablePlayerSkillScoreboard(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
public static void enablePlayerSkillScoreboard(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
Scoreboard oldScoreboard = player.getScoreboard();
|
Scoreboard oldScoreboard = player.getScoreboard();
|
||||||
@@ -140,10 +168,11 @@ public class ScoreboardManager {
|
|||||||
|
|
||||||
private static void updatePlayerSkillScores(PlayerProfile profile, SkillType skill, Objective objective) {
|
private static void updatePlayerSkillScores(PlayerProfile profile, SkillType skill, Objective objective) {
|
||||||
Server server = mcMMO.p.getServer();
|
Server server = mcMMO.p.getServer();
|
||||||
|
int currentXP = profile.getSkillXpLevel(skill);
|
||||||
|
|
||||||
objective.getScore(server.getOfflinePlayer("Level")).setScore(profile.getSkillLevel(skill));
|
objective.getScore(server.getOfflinePlayer("Level")).setScore(profile.getSkillLevel(skill));
|
||||||
objective.getScore(server.getOfflinePlayer("Current XP")).setScore(profile.getSkillXpLevel(skill));
|
objective.getScore(server.getOfflinePlayer("Current XP")).setScore(currentXP);
|
||||||
objective.getScore(server.getOfflinePlayer("Remaining XP")).setScore(profile.getXpToLevel(skill));
|
objective.getScore(server.getOfflinePlayer("Remaining XP")).setScore(profile.getXpToLevel(skill) - currentXP);
|
||||||
|
|
||||||
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
}
|
}
|
||||||
@@ -153,8 +182,8 @@ public class ScoreboardManager {
|
|||||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||||
Server server = mcMMO.p.getServer();
|
Server server = mcMMO.p.getServer();
|
||||||
|
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||||
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) {
|
if (!Permissions.skillEnabled(player, skill)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,8 +201,8 @@ public class ScoreboardManager {
|
|||||||
|
|
||||||
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(playerName) : FlatfileDatabaseManager.getPlayerRanks(playerName);
|
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(playerName) : FlatfileDatabaseManager.getPlayerRanks(playerName);
|
||||||
|
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||||
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) {
|
if (!Permissions.skillEnabled(player, skill)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,11 +228,7 @@ public class ScoreboardManager {
|
|||||||
|
|
||||||
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(targetName) : FlatfileDatabaseManager.getPlayerRanks(targetName);
|
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(targetName) : FlatfileDatabaseManager.getPlayerRanks(targetName);
|
||||||
|
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||||
if (skill.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rank = skills.get(skill.name());
|
rank = skills.get(skill.name());
|
||||||
|
|
||||||
if (rank != null) {
|
if (rank != null) {
|
||||||
@@ -228,8 +253,8 @@ public class ScoreboardManager {
|
|||||||
int powerLevel = 0;
|
int powerLevel = 0;
|
||||||
int skillLevel;
|
int skillLevel;
|
||||||
|
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||||
if (skill.isChildSkill() || !Permissions.skillEnabled(target, skill)) {
|
if (!Permissions.skillEnabled(target, skill)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,11 +273,7 @@ public class ScoreboardManager {
|
|||||||
int powerLevel = 0;
|
int powerLevel = 0;
|
||||||
int skillLevel;
|
int skillLevel;
|
||||||
|
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.nonChildSkills()) {
|
||||||
if (skill.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
skillLevel = targetProfile.getSkillLevel(skill);
|
skillLevel = targetProfile.getSkillLevel(skill);
|
||||||
objective.getScore(server.getOfflinePlayer(SkillUtils.getSkillName(skill))).setScore(skillLevel);
|
objective.getScore(server.getOfflinePlayer(SkillUtils.getSkillName(skill))).setScore(skillLevel);
|
||||||
powerLevel += skillLevel;
|
powerLevel += skillLevel;
|
||||||
@@ -277,6 +298,10 @@ public class ScoreboardManager {
|
|||||||
String playerName = stat.get(1);
|
String playerName = stat.get(1);
|
||||||
playerName = (playerName.equals(player.getName()) ? ChatColor.GOLD : "") + playerName;
|
playerName = (playerName.equals(player.getName()) ? ChatColor.GOLD : "") + playerName;
|
||||||
|
|
||||||
|
if (playerName.length() > 16) {
|
||||||
|
playerName = playerName.substring(0, 16);
|
||||||
|
}
|
||||||
|
|
||||||
objective.getScore(server.getOfflinePlayer(playerName)).setScore(Integer.valueOf(stat.get(0)));
|
objective.getScore(server.getOfflinePlayer(playerName)).setScore(Integer.valueOf(stat.get(0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,6 +310,10 @@ public class ScoreboardManager {
|
|||||||
String playerName = stat.name;
|
String playerName = stat.name;
|
||||||
playerName = (playerName.equals(player.getName()) ? ChatColor.GOLD : "") + playerName;
|
playerName = (playerName.equals(player.getName()) ? ChatColor.GOLD : "") + playerName;
|
||||||
|
|
||||||
|
if (playerName.length() > 16) {
|
||||||
|
playerName = playerName.substring(0, 16);
|
||||||
|
}
|
||||||
|
|
||||||
objective.getScore(server.getOfflinePlayer(playerName)).setScore(stat.statVal);
|
objective.getScore(server.getOfflinePlayer(playerName)).setScore(stat.statVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -298,6 +327,7 @@ public class ScoreboardManager {
|
|||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
|
|
||||||
player.setScoreboard(newScoreboard);
|
player.setScoreboard(newScoreboard);
|
||||||
|
enablePowerLevelDisplay(player);
|
||||||
|
|
||||||
if (displayTime != -1 && !SCOREBOARD_TASKS.contains(playerName)) {
|
if (displayTime != -1 && !SCOREBOARD_TASKS.contains(playerName)) {
|
||||||
new ScoreboardChangeTask(player, oldScoreboard).runTaskLater(mcMMO.p, displayTime * 20);
|
new ScoreboardChangeTask(player, oldScoreboard).runTaskLater(mcMMO.p, displayTime * 20);
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import org.bukkit.entity.Wolf;
|
|||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@@ -24,6 +23,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||||
|
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.runnables.skills.AwardCombatXpTask;
|
import com.gmail.nossr50.runnables.skills.AwardCombatXpTask;
|
||||||
@@ -245,12 +245,13 @@ public final class CombatUtils {
|
|||||||
event.setDamage(archeryManager.dazeCheck((Player) target, event.getDamage()));
|
event.setDamage(archeryManager.dazeCheck((Player) target, event.getDamage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (archeryManager.canTrackArrows()) {
|
if (!damager.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canTrackArrows()) {
|
||||||
archeryManager.trackArrows(target);
|
archeryManager.trackArrows(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
archeryManager.distanceXpBonus(target);
|
archeryManager.distanceXpBonus(target, damager);
|
||||||
startGainXp(mcMMOPlayer, target, SkillType.ARCHERY);
|
|
||||||
|
startGainXp(mcMMOPlayer, target, SkillType.ARCHERY, damager.getMetadata(mcMMO.bowForceKey).get(0).asDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -284,6 +285,24 @@ public final class CombatUtils {
|
|||||||
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
|
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (damager.getType() == EntityType.ARROW) {
|
||||||
|
LivingEntity shooter = ((Arrow) damager).getShooter();
|
||||||
|
|
||||||
|
if (shooter instanceof Player || !SkillType.UNARMED.getPVEEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
|
||||||
|
|
||||||
|
if (unarmedManager.canDeflect()) {
|
||||||
|
event.setCancelled(unarmedManager.deflectCheck());
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (attacker instanceof Player) {
|
else if (attacker instanceof Player) {
|
||||||
Player player = (Player) attacker;
|
Player player = (Player) attacker;
|
||||||
@@ -362,48 +381,45 @@ public final class CombatUtils {
|
|||||||
*/
|
*/
|
||||||
public static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, SkillType type) {
|
public static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, SkillType type) {
|
||||||
int numberOfTargets = Misc.getTier(attacker.getItemInHand()); // The higher the weapon tier, the more targets you hit
|
int numberOfTargets = Misc.getTier(attacker.getItemInHand()); // The higher the weapon tier, the more targets you hit
|
||||||
int damageAmount = damage;
|
int damageAmount = Math.max(damage, 1);
|
||||||
|
|
||||||
if (damageAmount < 1) {
|
while (numberOfTargets > 0) {
|
||||||
damageAmount = 1;
|
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
|
||||||
|
if (Misc.isNPCEntity(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
LivingEntity livingEntity = (LivingEntity) entity;
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(attacker));
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case SWORDS:
|
||||||
|
if (entity instanceof Player) {
|
||||||
|
((Player) entity).sendMessage(LocaleLoader.getString("Swords.Combat.SS.Struck"));
|
||||||
|
}
|
||||||
|
|
||||||
|
BleedTimerTask.add(livingEntity, Swords.serratedStrikesBleedTicks);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AXES:
|
||||||
|
if (entity instanceof Player) {
|
||||||
|
((Player) entity).sendMessage(LocaleLoader.getString("Axes.Combat.Cleave.Struck"));
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
dealDamage(livingEntity, damageAmount, attacker);
|
||||||
|
numberOfTargets--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
|
public static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, SkillType skillType) {
|
||||||
if (Misc.isNPCEntity(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) {
|
startGainXp(mcMMOPlayer, target, skillType, 1.0);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numberOfTargets <= 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(attacker);
|
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case SWORDS:
|
|
||||||
if (entity instanceof Player) {
|
|
||||||
((Player) entity).sendMessage(LocaleLoader.getString("Swords.Combat.SS.Struck"));
|
|
||||||
}
|
|
||||||
|
|
||||||
BleedTimerTask.add((LivingEntity) entity, Swords.serratedStrikesBleedTicks);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AXES:
|
|
||||||
if (entity instanceof Player) {
|
|
||||||
((Player) entity).sendMessage(LocaleLoader.getString("Axes.Combat.Cleave.Struck"));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
dealDamage((LivingEntity) entity, damageAmount, attacker);
|
|
||||||
numberOfTargets--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -413,7 +429,7 @@ public final class CombatUtils {
|
|||||||
* @param target The defending entity
|
* @param target The defending entity
|
||||||
* @param skillType The skill being used
|
* @param skillType The skill being used
|
||||||
*/
|
*/
|
||||||
public static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, SkillType skillType) {
|
public static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, SkillType skillType, double multiplier) {
|
||||||
double baseXP = 0;
|
double baseXP = 0;
|
||||||
|
|
||||||
if (target instanceof Player) {
|
if (target instanceof Player) {
|
||||||
@@ -427,7 +443,7 @@ public final class CombatUtils {
|
|||||||
baseXP = 20 * Config.getInstance().getPlayerVersusPlayerXP();
|
baseXP = 20 * Config.getInstance().getPlayerVersusPlayerXP();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!target.hasMetadata(mcMMO.entityMetadataKey)) {
|
else {
|
||||||
if (target instanceof Animals) {
|
if (target instanceof Animals) {
|
||||||
if (ModUtils.isCustomEntity(target)) {
|
if (ModUtils.isCustomEntity(target)) {
|
||||||
baseXP = ModUtils.getCustomEntity(target).getXpMultiplier();
|
baseXP = ModUtils.getCustomEntity(target).getXpMultiplier();
|
||||||
@@ -487,11 +503,17 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (target.hasMetadata(mcMMO.entityMetadataKey)) {
|
||||||
|
baseXP *= Config.getInstance().getSpawnedMobXpMultiplier();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
baseXP *= 10;
|
baseXP *= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
baseXP *= multiplier;
|
||||||
|
|
||||||
if (baseXP != 0) {
|
if (baseXP != 0) {
|
||||||
new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target).runTaskLater(mcMMO.p, 0);
|
new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target).runTaskLater(mcMMO.p, 0);
|
||||||
}
|
}
|
||||||
@@ -512,7 +534,7 @@ public final class CombatUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PartyManager.inSameParty(player, defender) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) {
|
if (mcMMO.getPartyManager().inSameParty(player, defender) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -546,16 +568,11 @@ public final class CombatUtils {
|
|||||||
* @return true if the entity is invincible, false otherwise
|
* @return true if the entity is invincible, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isInvincible(LivingEntity entity, int eventDamage) {
|
public static boolean isInvincible(LivingEntity entity, int eventDamage) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility.
|
* So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility.
|
||||||
* So yeah, this is for that.
|
* So yeah, this is for that.
|
||||||
*/
|
*/
|
||||||
if ((entity.getNoDamageTicks() > entity.getMaximumNoDamageTicks() / 2.0F) && (eventDamage <= entity.getLastDamage())) {
|
return (entity.getNoDamageTicks() > entity.getMaximumNoDamageTicks() / 2.0F) && (eventDamage <= entity.getLastDamage());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -572,7 +589,7 @@ public final class CombatUtils {
|
|||||||
if (tamer instanceof Player) {
|
if (tamer instanceof Player) {
|
||||||
Player owner = (Player) tamer;
|
Player owner = (Player) tamer;
|
||||||
|
|
||||||
if (owner == attacker || PartyManager.inSameParty(attacker, owner)) {
|
if (owner == attacker || mcMMO.getPartyManager().inSameParty(attacker, owner)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -582,15 +599,6 @@ public final class CombatUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldProcessSkill(Entity target, SkillType skill) {
|
public static boolean shouldProcessSkill(Entity target, SkillType skill) {
|
||||||
boolean process;
|
return (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) ? skill.getPVPEnabled() : skill.getPVEEnabled();
|
||||||
|
|
||||||
if (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) {
|
|
||||||
process = skill.getPVPEnabled();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
process = skill.getPVEEnabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
return process;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.bukkit.FireworkEffect.Type;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Firework;
|
import org.bukkit.entity.Firework;
|
||||||
@@ -63,7 +64,9 @@ public final class ParticleEffectUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fireworkParticleShower(player, Color.GREEN);
|
if (hasHeadRoom(player)) {
|
||||||
|
fireworkParticleShower(player, Color.GREEN);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void playAbilityDisabledEffect(Player player) {
|
public static void playAbilityDisabledEffect(Player player) {
|
||||||
@@ -71,7 +74,9 @@ public final class ParticleEffectUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fireworkParticleShower(player, Color.RED);
|
if (hasHeadRoom(player)) {
|
||||||
|
fireworkParticleShower(player, Color.RED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runescapeModeCelebration(Player player, SkillType skill) {
|
public static void runescapeModeCelebration(Player player, SkillType skill) {
|
||||||
@@ -85,10 +90,24 @@ public final class ParticleEffectUtils {
|
|||||||
|
|
||||||
Firework firework = (Firework) player.getWorld().spawnEntity(location, EntityType.FIREWORK);
|
Firework firework = (Firework) player.getWorld().spawnEntity(location, EntityType.FIREWORK);
|
||||||
FireworkMeta fireworkMeta = firework.getFireworkMeta();
|
FireworkMeta fireworkMeta = firework.getFireworkMeta();
|
||||||
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(color).with(Type.BALL_LARGE).trail(true).build();
|
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(color).with((Config.getInstance().getLargeFireworks() ? Type.BALL_LARGE : Type.BALL)).trail(true).build();
|
||||||
fireworkMeta.addEffect(effect);
|
fireworkMeta.addEffect(effect);
|
||||||
fireworkMeta.addEffect(effect);
|
fireworkMeta.addEffect(effect);
|
||||||
fireworkMeta.setPower(0);
|
fireworkMeta.setPower(0);
|
||||||
firework.setFireworkMeta(fireworkMeta);
|
firework.setFireworkMeta(fireworkMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean hasHeadRoom(Player player) {
|
||||||
|
boolean hasHeadRoom = true;
|
||||||
|
Block headBlock = player.getEyeLocation().getBlock();
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
if (!headBlock.getRelative(BlockFace.UP, i).isEmpty()) {
|
||||||
|
hasHeadRoom = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hasHeadRoom;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ public final class PerksUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int handleActivationPerks(Player player, int ticks, int maxTicks) {
|
public static int handleActivationPerks(Player player, int ticks, int maxTicks) {
|
||||||
|
if (maxTicks != 0) {
|
||||||
|
ticks = Math.min(ticks, maxTicks);
|
||||||
|
}
|
||||||
|
|
||||||
if (Permissions.twelveSecondActivationBoost(player)) {
|
if (Permissions.twelveSecondActivationBoost(player)) {
|
||||||
ticks += 12;
|
ticks += 12;
|
||||||
}
|
}
|
||||||
@@ -36,10 +40,6 @@ public final class PerksUtils {
|
|||||||
ticks += 4;
|
ticks += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maxTicks != 0) {
|
|
||||||
ticks = Math.min(ticks, maxTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ticks;
|
return ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,14 +13,11 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
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.HiddenConfig;
|
import com.gmail.nossr50.config.HiddenConfig;
|
||||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
|
||||||
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.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
@@ -30,6 +27,7 @@ import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
|
|||||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||||
|
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
|
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
|
||||||
import com.gmail.nossr50.runnables.skills.ToolLowerTask;
|
import com.gmail.nossr50.runnables.skills.ToolLowerTask;
|
||||||
@@ -42,8 +40,6 @@ import com.gmail.nossr50.util.player.UserManager;
|
|||||||
import com.gmail.nossr50.util.spout.SpoutUtils;
|
import com.gmail.nossr50.util.spout.SpoutUtils;
|
||||||
|
|
||||||
public class SkillUtils {
|
public class SkillUtils {
|
||||||
private static int enchantBuff = AdvancedConfig.getInstance().getEnchantBuff();
|
|
||||||
|
|
||||||
public static int handleFoodSkills(Player player, SkillType skill, int eventFoodLevel, int baseLevel, int maxLevel, int rankChange) {
|
public static int handleFoodSkills(Player player, SkillType skill, int eventFoodLevel, int baseLevel, int maxLevel, int rankChange) {
|
||||||
int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
|
int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
|
||||||
|
|
||||||
@@ -59,25 +55,6 @@ public class SkillUtils {
|
|||||||
return currentFoodLevel + foodChange;
|
return currentFoodLevel + foodChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks to see if the cooldown for an item or ability is expired.
|
|
||||||
*
|
|
||||||
* @param oldTime The time the ability or item was last used
|
|
||||||
* @param cooldown The amount of time that must pass between uses
|
|
||||||
* @param player The player whose cooldown is being checked
|
|
||||||
* @return true if the cooldown is over, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean cooldownOver(long oldTime, int cooldown, Player player) {
|
|
||||||
long currentTime = System.currentTimeMillis();
|
|
||||||
int adjustedCooldown = PerksUtils.handleCooldownPerks(player, cooldown);
|
|
||||||
|
|
||||||
if (currentTime - oldTime >= (adjustedCooldown * Misc.TIME_CONVERSION_FACTOR)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the time remaining until the cooldown expires.
|
* Calculate the time remaining until the cooldown expires.
|
||||||
*
|
*
|
||||||
@@ -100,15 +77,14 @@ public class SkillUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
|
||||||
AbilityType ability = skill.getAbility();
|
|
||||||
ToolType tool = skill.getTool();
|
|
||||||
ItemStack inHand = player.getItemInHand();
|
ItemStack inHand = player.getItemInHand();
|
||||||
|
|
||||||
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
if (!mcMMOPlayer.getAbilityUse()) {
|
if (!mcMMOPlayer.getAbilityUse()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -120,6 +96,8 @@ public class SkillUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
|
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
|
||||||
|
AbilityType ability = skill.getAbility();
|
||||||
|
ToolType tool = skill.getTool();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Woodcutting & Axes need to be treated differently.
|
* Woodcutting & Axes need to be treated differently.
|
||||||
@@ -127,8 +105,10 @@ public class SkillUtils {
|
|||||||
*/
|
*/
|
||||||
if (ability.getPermissions(player) && tool.inHand(inHand) && !mcMMOPlayer.getToolPreparationMode(tool)) {
|
if (ability.getPermissions(player) && tool.inHand(inHand) && !mcMMOPlayer.getToolPreparationMode(tool)) {
|
||||||
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
|
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
|
||||||
if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
int timeRemaining = calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)));
|
|
||||||
|
if (!mcMMOPlayer.getAbilityMode(ability) && timeRemaining > 0) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +131,7 @@ public class SkillUtils {
|
|||||||
* @param profile The profile of the player whose skill to check
|
* @param profile The profile of the player whose skill to check
|
||||||
*/
|
*/
|
||||||
public static void xpCheckSkill(SkillType skillType, Player player, PlayerProfile profile) {
|
public static void xpCheckSkill(SkillType skillType, Player player, PlayerProfile profile) {
|
||||||
int skillups = 0;
|
int levelsGained = 0;
|
||||||
float xpRemoved = 0;
|
float xpRemoved = 0;
|
||||||
|
|
||||||
if (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
|
if (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
|
||||||
@@ -163,7 +143,7 @@ public class SkillUtils {
|
|||||||
xpRemoved += xp;
|
xpRemoved += xp;
|
||||||
|
|
||||||
profile.removeXp(skillType, xp);
|
profile.removeXp(skillType, xp);
|
||||||
skillups++;
|
levelsGained++;
|
||||||
profile.skillUp(skillType, 1);
|
profile.skillUp(skillType, 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -171,46 +151,27 @@ public class SkillUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType, skillups);
|
McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType, levelsGained);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(eventToFire);
|
mcMMO.p.getServer().getPluginManager().callEvent(eventToFire);
|
||||||
|
|
||||||
if (eventToFire.isCancelled()) {
|
if (eventToFire.isCancelled()) {
|
||||||
profile.modifySkill(skillType, profile.getSkillLevel(skillType) - skillups);
|
profile.modifySkill(skillType, profile.getSkillLevel(skillType) - levelsGained);
|
||||||
profile.setSkillXpLevel(skillType, profile.getSkillXpLevelRaw(skillType) + xpRemoved);
|
profile.setSkillXpLevel(skillType, profile.getSkillXpLevelRaw(skillType) + xpRemoved);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String capitalized = StringUtils.getCapitalized(skillType.toString());
|
String capitalized = StringUtils.getCapitalized(skillType.toString());
|
||||||
|
|
||||||
/* Spout Stuff */
|
if (mcMMO.isSpoutEnabled()) {
|
||||||
if (mcMMO.spoutEnabled) {
|
SpoutUtils.processLevelup(mcMMOPlayer, skillType, levelsGained);
|
||||||
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
|
||||||
|
|
||||||
if (spoutPlayer != null && spoutPlayer.isSpoutCraftEnabled()) {
|
|
||||||
SpoutUtils.levelUpNotification(skillType, spoutPlayer);
|
|
||||||
|
|
||||||
/* Update custom titles */
|
|
||||||
if (SpoutConfig.getInstance().getShowPowerLevel()) {
|
|
||||||
spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getName(), UserManager.getPlayer(player).getPowerLevel()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage(LocaleLoader.getString(capitalized + ".Skillup", skillups, profile.getSkillLevel(skillType)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString(capitalized + ".Skillup", skillups, profile.getSkillLevel(skillType)));
|
player.sendMessage(LocaleLoader.getString(capitalized + ".Skillup", levelsGained, profile.getSkillLevel(skillType)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcMMO.spoutEnabled) {
|
if (mcMMO.isSpoutEnabled()) {
|
||||||
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
SpoutUtils.processXpGain(player, profile);
|
||||||
|
|
||||||
if (spoutPlayer != null && spoutPlayer.isSpoutCraftEnabled()) {
|
|
||||||
if (SpoutConfig.getInstance().getXPBarEnabled()) {
|
|
||||||
profile.getSpoutHud().updateXpBar();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,11 +186,7 @@ public class SkillUtils {
|
|||||||
return isLocalizedSkill(skillName);
|
return isLocalizedSkill(skillName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SkillType.getSkill(skillName) != null) {
|
return SkillType.getSkill(skillName) != null;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isLocalizedSkill(String skillName) {
|
private static boolean isLocalizedSkill(String skillName) {
|
||||||
@@ -257,15 +214,11 @@ public class SkillUtils {
|
|||||||
* @return true if the player has combat skills, false otherwise
|
* @return true if the player has combat skills, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean hasCombatSkills(Player player) {
|
public static boolean hasCombatSkills(Player player) {
|
||||||
if (Permissions.skillEnabled(player, SkillType.AXES)
|
return Permissions.skillEnabled(player, SkillType.AXES)
|
||||||
|| Permissions.skillEnabled(player, SkillType.ARCHERY)
|
|| Permissions.skillEnabled(player, SkillType.ARCHERY)
|
||||||
|| Permissions.skillEnabled(player, SkillType.SWORDS)
|
|| Permissions.skillEnabled(player, SkillType.SWORDS)
|
||||||
|| Permissions.skillEnabled(player, SkillType.TAMING)
|
|| Permissions.skillEnabled(player, SkillType.TAMING)
|
||||||
|| Permissions.skillEnabled(player, SkillType.UNARMED)) {
|
|| Permissions.skillEnabled(player, SkillType.UNARMED);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -275,15 +228,11 @@ public class SkillUtils {
|
|||||||
* @return true if the player has gathering skills, false otherwise
|
* @return true if the player has gathering skills, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean hasGatheringSkills(Player player) {
|
public static boolean hasGatheringSkills(Player player) {
|
||||||
if (Permissions.skillEnabled(player, SkillType.EXCAVATION)
|
return Permissions.skillEnabled(player, SkillType.EXCAVATION)
|
||||||
|| Permissions.skillEnabled(player, SkillType.FISHING)
|
|| Permissions.skillEnabled(player, SkillType.FISHING)
|
||||||
|| Permissions.skillEnabled(player, SkillType.HERBALISM)
|
|| Permissions.skillEnabled(player, SkillType.HERBALISM)
|
||||||
|| Permissions.skillEnabled(player, SkillType.MINING)
|
|| Permissions.skillEnabled(player, SkillType.MINING)
|
||||||
|| Permissions.skillEnabled(player, SkillType.WOODCUTTING)) {
|
|| Permissions.skillEnabled(player, SkillType.WOODCUTTING);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -293,13 +242,9 @@ public class SkillUtils {
|
|||||||
* @return true if the player has misc skills, false otherwise
|
* @return true if the player has misc skills, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean hasMiscSkills(Player player) {
|
public static boolean hasMiscSkills(Player player) {
|
||||||
if (Permissions.skillEnabled(player, SkillType.ACROBATICS)
|
return Permissions.skillEnabled(player, SkillType.ACROBATICS)
|
||||||
|| Permissions.skillEnabled(player, SkillType.SMELTING)
|
|| Permissions.skillEnabled(player, SkillType.SMELTING)
|
||||||
|| Permissions.skillEnabled(player, SkillType.REPAIR)) {
|
|| Permissions.skillEnabled(player, SkillType.REPAIR);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -317,18 +262,27 @@ public class SkillUtils {
|
|||||||
Player player = mcMMOPlayer.getPlayer();
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
|
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
|
int timeRemaining = calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Axes and Woodcutting are odd because they share the same tool.
|
* Axes and Woodcutting are odd because they share the same tool.
|
||||||
* We show them the too tired message when they take action.
|
* We show them the too tired message when they take action.
|
||||||
*/
|
*/
|
||||||
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
|
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
|
||||||
if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
if (!mcMMOPlayer.getAbilityMode(ability) && timeRemaining > 0) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(playerProfile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)));
|
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mcMMOPlayer.getAbilityMode(ability) && cooldownOver(playerProfile.getSkillDATS(ability), ability.getCooldown(), player)) {
|
if (!mcMMOPlayer.getAbilityMode(ability) && timeRemaining <= 0) {
|
||||||
|
McMMOPlayerAbilityActivateEvent event = new McMMOPlayerAbilityActivateEvent(player, type);
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int ticks = PerksUtils.handleActivationPerks(player, 2 + (playerProfile.getSkillLevel(type) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks());
|
int ticks = PerksUtils.handleActivationPerks(player, 2 + (playerProfile.getSkillLevel(type) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks());
|
||||||
|
|
||||||
ParticleEffectUtils.playAbilityEnabledEffect(player);
|
ParticleEffectUtils.playAbilityEnabledEffect(player);
|
||||||
@@ -363,6 +317,7 @@ public class SkillUtils {
|
|||||||
|
|
||||||
switch (ability) {
|
switch (ability) {
|
||||||
case BERSERK:
|
case BERSERK:
|
||||||
|
case BLOCK_CRACKER:
|
||||||
case LEAF_BLOWER:
|
case LEAF_BLOWER:
|
||||||
if (!ability.blockCheck(block.getState())) {
|
if (!ability.blockCheck(block.getState())) {
|
||||||
activate = false;
|
activate = false;
|
||||||
@@ -417,7 +372,7 @@ public class SkillUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
itemLore.add("mcMMO Ability Tool");
|
itemLore.add("mcMMO Ability Tool");
|
||||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + enchantBuff, true);
|
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + AdvancedConfig.getInstance().getEnchantBuff(), true);
|
||||||
|
|
||||||
itemMeta.setLore(itemLore);
|
itemMeta.setLore(itemLore);
|
||||||
heldItem.setItemMeta(itemMeta);
|
heldItem.setItemMeta(itemMeta);
|
||||||
@@ -483,11 +438,11 @@ public class SkillUtils {
|
|||||||
if (itemLore.remove("mcMMO Ability Tool")) {
|
if (itemLore.remove("mcMMO Ability Tool")) {
|
||||||
int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED);
|
int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED);
|
||||||
|
|
||||||
if (efficiencyLevel <= enchantBuff) {
|
if (efficiencyLevel <= AdvancedConfig.getInstance().getEnchantBuff()) {
|
||||||
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
|
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - enchantBuff, true);
|
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - AdvancedConfig.getInstance().getEnchantBuff(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
itemMeta.setLore(itemLore);
|
itemMeta.setLore(itemLore);
|
||||||
@@ -521,11 +476,7 @@ public class SkillUtils {
|
|||||||
FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player);
|
FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player);
|
||||||
pluginManger.callEvent(breakEvent);
|
pluginManger.callEvent(breakEvent);
|
||||||
|
|
||||||
if (!damageEvent.isCancelled() && !breakEvent.isCancelled()) {
|
return !damageEvent.isCancelled() && !breakEvent.isCancelled();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) {
|
public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) {
|
||||||
|
|||||||
@@ -9,61 +9,132 @@ import java.io.InputStream;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
import org.getspout.spoutapi.SpoutManager;
|
||||||
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||||
import org.getspout.spoutapi.keyboard.Keyboard;
|
|
||||||
import org.getspout.spoutapi.player.FileManager;
|
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.config.spout.SpoutConfig;
|
import com.gmail.nossr50.config.spout.SpoutConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
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.listeners.SpoutListener;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
public class SpoutUtils {
|
public class SpoutUtils {
|
||||||
private static mcMMO plugin = mcMMO.p;
|
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||||
|
protected enum Tier {
|
||||||
|
FOUR(4) {
|
||||||
|
@Override public int getLevel() { return SpoutConfig.getInstance().getNotificationTier4(); }
|
||||||
|
@Override protected Material getAcrobaticsNotificationItem() { return Material.DIAMOND_BOOTS; }
|
||||||
|
@Override protected Material getArcheryNotificationItem() { return Material.BOW; }
|
||||||
|
@Override protected Material getAxesNotificationItem() { return Material.DIAMOND_AXE; }
|
||||||
|
@Override protected Material getExcavationNotificationItem() { return Material.CLAY; }
|
||||||
|
@Override protected Material getFishingNotificationItem() { return Material.FISHING_ROD; }
|
||||||
|
@Override protected Material getHerbalismNotificationItem() { return Material.WATER_LILY; }
|
||||||
|
@Override protected Material getMiningNotificationItem() { return Material.EMERALD_ORE; }
|
||||||
|
@Override protected Material getSwordsNotificationItem() { return Material.DIAMOND_SWORD; }
|
||||||
|
@Override protected Material getTamingNotificationItem() { return Material.BONE; }
|
||||||
|
@Override protected Material getUnarmedNotificationItem() { return Material.DIAMOND_HELMET; }
|
||||||
|
@Override protected Material getWoodcuttingNotificationItem() { return Material.LOG; }},
|
||||||
|
THREE(3) {
|
||||||
|
@Override public int getLevel() { return SpoutConfig.getInstance().getNotificationTier3(); }
|
||||||
|
@Override protected Material getAcrobaticsNotificationItem() { return Material.GOLD_BOOTS; }
|
||||||
|
@Override protected Material getArcheryNotificationItem() { return Material.ARROW; }
|
||||||
|
@Override protected Material getAxesNotificationItem() { return Material.GOLD_AXE; }
|
||||||
|
@Override protected Material getExcavationNotificationItem() { return Material.SAND; }
|
||||||
|
@Override protected Material getFishingNotificationItem() { return Material.COOKED_FISH; }
|
||||||
|
@Override protected Material getHerbalismNotificationItem() { return Material.RED_ROSE; }
|
||||||
|
@Override protected Material getMiningNotificationItem() { return Material.DIAMOND_ORE; }
|
||||||
|
@Override protected Material getSwordsNotificationItem() { return Material.GOLD_SWORD; }
|
||||||
|
@Override protected Material getTamingNotificationItem() { return Material.GRILLED_PORK; }
|
||||||
|
@Override protected Material getUnarmedNotificationItem() { return Material.GOLD_HELMET; }
|
||||||
|
@Override protected Material getWoodcuttingNotificationItem() { return Material.WOOD; }},
|
||||||
|
TWO(2) {
|
||||||
|
@Override public int getLevel() { return SpoutConfig.getInstance().getNotificationTier2(); }
|
||||||
|
@Override protected Material getAcrobaticsNotificationItem() { return Material.IRON_BOOTS; }
|
||||||
|
@Override protected Material getArcheryNotificationItem() { return Material.ARROW; }
|
||||||
|
@Override protected Material getAxesNotificationItem() { return Material.IRON_AXE; }
|
||||||
|
@Override protected Material getExcavationNotificationItem() { return Material.GRAVEL; }
|
||||||
|
@Override protected Material getFishingNotificationItem() { return Material.COOKED_FISH; }
|
||||||
|
@Override protected Material getHerbalismNotificationItem() { return Material.YELLOW_FLOWER; }
|
||||||
|
@Override protected Material getMiningNotificationItem() { return Material.GOLD_ORE; }
|
||||||
|
@Override protected Material getSwordsNotificationItem() { return Material.IRON_SWORD; }
|
||||||
|
@Override protected Material getTamingNotificationItem() { return Material.GRILLED_PORK; }
|
||||||
|
@Override protected Material getUnarmedNotificationItem() { return Material.IRON_HELMET; }
|
||||||
|
@Override protected Material getWoodcuttingNotificationItem() { return Material.LEAVES; }},
|
||||||
|
ONE(1) {
|
||||||
|
@Override public int getLevel() { return SpoutConfig.getInstance().getNotificationTier1(); }
|
||||||
|
@Override protected Material getAcrobaticsNotificationItem() { return Material.CHAINMAIL_BOOTS; }
|
||||||
|
@Override protected Material getArcheryNotificationItem() { return Material.FLINT; }
|
||||||
|
@Override protected Material getAxesNotificationItem() { return Material.STONE_AXE; }
|
||||||
|
@Override protected Material getExcavationNotificationItem() { return Material.GRASS; }
|
||||||
|
@Override protected Material getFishingNotificationItem() { return Material.RAW_FISH; }
|
||||||
|
@Override protected Material getHerbalismNotificationItem() { return Material.CACTUS; }
|
||||||
|
@Override protected Material getMiningNotificationItem() { return Material.IRON_ORE; }
|
||||||
|
@Override protected Material getSwordsNotificationItem() { return Material.STONE_SWORD; }
|
||||||
|
@Override protected Material getTamingNotificationItem() { return Material.PORK; }
|
||||||
|
@Override protected Material getUnarmedNotificationItem() { return Material.CHAINMAIL_HELMET; }
|
||||||
|
@Override protected Material getWoodcuttingNotificationItem() { return Material.SAPLING; }};
|
||||||
|
|
||||||
public final static String spoutDirectory = mcMMO.getMainDirectory() + "Resources" + File.separator;
|
int numerical;
|
||||||
public final static String hudDirectory = spoutDirectory + "HUD" + File.separator;
|
|
||||||
public final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator;
|
|
||||||
public final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator;
|
|
||||||
public final static String soundDirectory = spoutDirectory + "Sound" + File.separator;
|
|
||||||
|
|
||||||
public static boolean showPowerLevel;
|
private Tier(int numerical) {
|
||||||
|
this.numerical = numerical;
|
||||||
|
}
|
||||||
|
|
||||||
private final static SpoutListener spoutListener = new SpoutListener();
|
public int toNumerical() {
|
||||||
public static Keyboard menuKey;
|
return numerical;
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract protected int getLevel();
|
||||||
|
abstract protected Material getAcrobaticsNotificationItem();
|
||||||
|
abstract protected Material getArcheryNotificationItem();
|
||||||
|
abstract protected Material getAxesNotificationItem();
|
||||||
|
abstract protected Material getExcavationNotificationItem();
|
||||||
|
abstract protected Material getFishingNotificationItem();
|
||||||
|
abstract protected Material getHerbalismNotificationItem();
|
||||||
|
abstract protected Material getMiningNotificationItem();
|
||||||
|
abstract protected Material getSwordsNotificationItem();
|
||||||
|
abstract protected Material getTamingNotificationItem();
|
||||||
|
abstract protected Material getUnarmedNotificationItem();
|
||||||
|
abstract protected Material getWoodcuttingNotificationItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static String spoutDirectory = mcMMO.getMainDirectory() + "Resources" + File.separator;
|
||||||
|
private final static String hudDirectory = spoutDirectory + "HUD" + File.separator;
|
||||||
|
private final static String hudStandardDirectory = hudDirectory + "Standard" + File.separator;
|
||||||
|
private final static String hudRetroDirectory = hudDirectory + "Retro" + File.separator;
|
||||||
|
private final static String soundDirectory = spoutDirectory + "Sound" + File.separator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write file to disk.
|
* Write file to disk.
|
||||||
*
|
*
|
||||||
* @param theFileName The name of the file
|
* @param fileName The name of the file
|
||||||
* @param theFilePath The name of the file path
|
* @param filePath The name of the file path
|
||||||
*/
|
*/
|
||||||
private static void writeFile(String theFileName, String theFilePath) {
|
private static File writeFile(String fileName, String filePath) {
|
||||||
|
File currentFile = new File(filePath + fileName);
|
||||||
BufferedOutputStream os = null;
|
BufferedOutputStream os = null;
|
||||||
JarFile jar = null;
|
JarFile jar = null;
|
||||||
|
|
||||||
|
// No point in writing the file again if it already exists.
|
||||||
|
if (currentFile.exists()) {
|
||||||
|
return currentFile;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
File currentFile = new File(theFilePath + theFileName);
|
|
||||||
|
|
||||||
// No point in writing the file again if it already exists.
|
|
||||||
if (currentFile.exists()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
jar = new JarFile(mcMMO.mcmmo);
|
jar = new JarFile(mcMMO.mcmmo);
|
||||||
|
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
InputStream is = jar.getInputStream(jar.getJarEntry("resources/" + theFileName));
|
InputStream is = jar.getInputStream(jar.getJarEntry("resources/" + fileName));
|
||||||
|
|
||||||
byte[] buf = new byte[2048];
|
byte[] buf = new byte[2048];
|
||||||
int nbRead;
|
int nbRead;
|
||||||
@@ -98,12 +169,16 @@ public class SpoutUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return currentFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract Spout files to the Resources directory.
|
* Extract Spout files to the Resources directory.
|
||||||
*/
|
*/
|
||||||
public static void extractFiles() {
|
public static ArrayList<File> extractFiles() {
|
||||||
|
ArrayList<File> files = new ArrayList<File>();
|
||||||
|
|
||||||
// Setup directories
|
// Setup directories
|
||||||
new File(spoutDirectory).mkdir();
|
new File(spoutDirectory).mkdir();
|
||||||
new File(hudDirectory).mkdir();
|
new File(hudDirectory).mkdir();
|
||||||
@@ -113,110 +188,39 @@ public class SpoutUtils {
|
|||||||
|
|
||||||
// XP Bar images
|
// XP Bar images
|
||||||
for (int x = 0; x < 255; x++) {
|
for (int x = 0; x < 255; x++) {
|
||||||
String theFileName;
|
String fileName;
|
||||||
|
|
||||||
if (x < 10) {
|
if (x < 10) {
|
||||||
theFileName = "xpbar_inc00" + x + ".png";
|
fileName = "xpbar_inc00" + x + ".png";
|
||||||
}
|
}
|
||||||
else if (x < 100) {
|
else if (x < 100) {
|
||||||
theFileName = "xpbar_inc0" + x + ".png";
|
fileName = "xpbar_inc0" + x + ".png";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
theFileName = "xpbar_inc" + x + ".png";
|
fileName = "xpbar_inc" + x + ".png";
|
||||||
}
|
}
|
||||||
|
|
||||||
writeFile(theFileName, hudStandardDirectory);
|
files.add(writeFile(fileName, hudStandardDirectory));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Standard XP Icons
|
// Standard XP Icons
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.nonChildSkills()) {
|
||||||
if (skillType.isChildSkill()) {
|
String skillName = StringUtils.getCapitalized(skillType.toString());
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String skillTypeString = StringUtils.getCapitalized(skillType.toString());
|
files.add(writeFile(skillName + ".png", hudStandardDirectory));
|
||||||
|
files.add(writeFile(skillName + "_r.png", hudRetroDirectory));
|
||||||
writeFile(skillTypeString + ".png", hudStandardDirectory);
|
|
||||||
writeFile(skillTypeString + "_r.png", hudRetroDirectory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Blank icons
|
// Blank icons
|
||||||
writeFile("Icon.png", hudStandardDirectory);
|
files.add(writeFile("Icon.png", hudStandardDirectory));
|
||||||
writeFile("Icon_r.png", hudRetroDirectory);
|
files.add(writeFile("Icon_r.png", hudRetroDirectory));
|
||||||
|
|
||||||
// Sound FX
|
// Sound FX
|
||||||
writeFile("level.wav", soundDirectory);
|
files.add(writeFile("level.wav", soundDirectory));
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup Spout config options
|
|
||||||
*/
|
|
||||||
public static void setupSpoutConfigs() {
|
|
||||||
showPowerLevel = SpoutConfig.getInstance().getShowPowerLevel();
|
|
||||||
String temp = SpoutConfig.getInstance().getMenuKey();
|
|
||||||
|
|
||||||
for (Keyboard x : Keyboard.values()) {
|
|
||||||
if (x.toString().equalsIgnoreCase(temp)) {
|
|
||||||
menuKey = x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (menuKey == null) {
|
|
||||||
mcMMO.p.getLogger().warning("Invalid KEY for Menu.Key, using KEY_M");
|
|
||||||
menuKey = Keyboard.KEY_M;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all the Spout files in the Resources folder.
|
|
||||||
*
|
|
||||||
* @return a list of all files is the Resources folder
|
|
||||||
*/
|
|
||||||
public static ArrayList<File> getFiles() {
|
|
||||||
ArrayList<File> files = new ArrayList<File>();
|
|
||||||
|
|
||||||
// XP BAR
|
|
||||||
for (int x = 0; x < 255; x++) {
|
|
||||||
if (x < 10) {
|
|
||||||
files.add(new File(hudStandardDirectory + "xpbar_inc00" + x + ".png"));
|
|
||||||
}
|
|
||||||
else if (x < 100) {
|
|
||||||
files.add(new File(hudStandardDirectory + "xpbar_inc0" + x + ".png"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
files.add(new File(hudStandardDirectory + "xpbar_inc" + x + ".png"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Standard XP Icons
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
if (skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String skillTypeString = StringUtils.getCapitalized(skillType.toString());
|
|
||||||
|
|
||||||
files.add(new File(hudStandardDirectory + skillTypeString + ".png"));
|
|
||||||
files.add(new File(hudRetroDirectory + skillTypeString + "_r.png"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Blank icons
|
|
||||||
files.add(new File(hudStandardDirectory + "Icon.png"));
|
|
||||||
files.add(new File(hudRetroDirectory + "Icon_r.png"));
|
|
||||||
|
|
||||||
// Level SFX
|
|
||||||
files.add(new File(soundDirectory + "level.wav"));
|
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Register custom Spout events.
|
|
||||||
*/
|
|
||||||
public static void registerCustomEvent() {
|
|
||||||
plugin.getServer().getPluginManager().registerEvents(spoutListener, plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle level-up notifications through Spout.
|
* Handle level-up notifications through Spout.
|
||||||
*
|
*
|
||||||
@@ -225,334 +229,185 @@ public class SpoutUtils {
|
|||||||
*/
|
*/
|
||||||
public static void levelUpNotification(SkillType skillType, SpoutPlayer spoutPlayer) {
|
public static void levelUpNotification(SkillType skillType, SpoutPlayer spoutPlayer) {
|
||||||
PlayerProfile profile = UserManager.getPlayer(spoutPlayer).getProfile();
|
PlayerProfile profile = UserManager.getPlayer(spoutPlayer).getProfile();
|
||||||
int notificationTier = getNotificationTier(profile.getSkillLevel(skillType));
|
int skillLevel = profile.getSkillLevel(skillType);
|
||||||
Material mat = null;
|
Material notificationItem;
|
||||||
|
|
||||||
switch (skillType) {
|
switch (skillType) {
|
||||||
case TAMING:
|
|
||||||
switch (notificationTier) {
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
mat = Material.PORK;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
mat = Material.GRILLED_PORK;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
mat = Material.BONE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MINING:
|
|
||||||
switch (notificationTier) {
|
|
||||||
case 1:
|
|
||||||
mat = Material.COAL_ORE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
mat = Material.IRON_ORE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
mat = Material.GOLD_ORE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
mat = Material.DIAMOND_ORE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
mat = Material.EMERALD_ORE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WOODCUTTING:
|
|
||||||
switch (notificationTier) {
|
|
||||||
case 1:
|
|
||||||
mat = Material.STICK;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
mat = Material.WOOD;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
mat = Material.LOG;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case REPAIR:
|
|
||||||
mat = Material.ANVIL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HERBALISM:
|
|
||||||
switch (notificationTier) {
|
|
||||||
case 1:
|
|
||||||
mat = Material.YELLOW_FLOWER;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
mat = Material.RED_ROSE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
mat = Material.BROWN_MUSHROOM;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
mat = Material.RED_MUSHROOM;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
mat = Material.PUMPKIN;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ACROBATICS:
|
case ACROBATICS:
|
||||||
switch (notificationTier) {
|
notificationItem = getAcrobaticsNotificationItem(skillLevel);
|
||||||
case 1:
|
|
||||||
mat = Material.LEATHER_BOOTS;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
mat = Material.CHAINMAIL_BOOTS;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
mat = Material.IRON_BOOTS;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
mat = Material.GOLD_BOOTS;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
mat = Material.DIAMOND_BOOTS;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SWORDS:
|
|
||||||
switch (notificationTier) {
|
|
||||||
case 1:
|
|
||||||
mat = Material.WOOD_SWORD;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
mat = Material.STONE_SWORD;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
mat = Material.IRON_SWORD;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
mat = Material.GOLD_SWORD;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
mat = Material.DIAMOND_SWORD;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARCHERY:
|
case ARCHERY:
|
||||||
switch (notificationTier) {
|
notificationItem = getArcheryNotificationItem(skillLevel);
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
mat = Material.ARROW;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
mat = Material.BOW;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UNARMED:
|
|
||||||
switch (notificationTier) {
|
|
||||||
case 1:
|
|
||||||
mat = Material.LEATHER_HELMET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
mat = Material.CHAINMAIL_HELMET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
mat = Material.IRON_HELMET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
mat = Material.GOLD_HELMET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
mat = Material.DIAMOND_HELMET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EXCAVATION:
|
|
||||||
switch (notificationTier) {
|
|
||||||
case 1:
|
|
||||||
mat = Material.WOOD_SPADE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
mat = Material.STONE_SPADE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
mat = Material.IRON_SPADE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
mat = Material.GOLD_SPADE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
mat = Material.DIAMOND_SPADE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AXES:
|
case AXES:
|
||||||
switch (notificationTier) {
|
notificationItem = getAxesNotificationItem(skillLevel);
|
||||||
case 1:
|
break;
|
||||||
mat = Material.WOOD_AXE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
mat = Material.STONE_AXE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
mat = Material.IRON_AXE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
mat = Material.GOLD_AXE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
|
||||||
mat = Material.DIAMOND_AXE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
case EXCAVATION:
|
||||||
|
notificationItem = getExcavationNotificationItem(skillLevel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FISHING:
|
case FISHING:
|
||||||
switch (notificationTier) {
|
notificationItem = getFishingNotificationItem(skillLevel);
|
||||||
case 1:
|
break;
|
||||||
case 2:
|
|
||||||
mat = Material.RAW_FISH;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
case HERBALISM:
|
||||||
case 4:
|
notificationItem = getHerbalismNotificationItem(skillLevel);
|
||||||
mat = Material.COOKED_FISH;
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case 5:
|
case MINING:
|
||||||
mat = Material.FISHING_ROD;
|
notificationItem = getMiningNotificationItem(skillLevel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
case REPAIR:
|
||||||
break;
|
notificationItem = Material.ANVIL;
|
||||||
}
|
break;
|
||||||
|
|
||||||
|
case SWORDS:
|
||||||
|
notificationItem = getSwordsNotificationItem(skillLevel);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TAMING:
|
||||||
|
notificationItem = getTamingNotificationItem(skillLevel);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UNARMED:
|
||||||
|
notificationItem = getUnarmedNotificationItem(skillLevel);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WOODCUTTING:
|
||||||
|
notificationItem = getWoodcuttingNotificationItem(skillLevel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
mat = Material.WATCH;
|
notificationItem = Material.MAP;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.LevelUp.1"), LocaleLoader.getString("Spout.LevelUp.2", SkillUtils.getSkillName(skillType), profile.getSkillLevel(skillType)), mat);
|
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.LevelUp.1"), LocaleLoader.getString("Spout.LevelUp.2", SkillUtils.getSkillName(skillType), skillLevel), notificationItem);
|
||||||
SpoutManager.getSoundManager().playCustomSoundEffect(plugin, spoutPlayer, "level.wav", false);
|
SpoutManager.getSoundManager().playCustomSoundEffect(mcMMO.p, spoutPlayer, "level.wav", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static Material getAcrobaticsNotificationItem(int skillLevel) {
|
||||||
* Gets the notification tier of a skill.
|
for (Tier tier : Tier.values()) {
|
||||||
*
|
if (skillLevel >= tier.getLevel()) {
|
||||||
* @param level The level of the skill
|
return tier.getAcrobaticsNotificationItem();
|
||||||
* @return the notification tier of the skill
|
}
|
||||||
*/
|
|
||||||
private static int getNotificationTier(int level) {
|
|
||||||
if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier4()) {
|
|
||||||
return 5;
|
|
||||||
}
|
}
|
||||||
else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier3()) {
|
|
||||||
return 4;
|
return Material.LEATHER_BOOTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Material getArcheryNotificationItem(int skillLevel) {
|
||||||
|
for (Tier tier : Tier.values()) {
|
||||||
|
if (skillLevel >= tier.getLevel()) {
|
||||||
|
return tier.getArcheryNotificationItem();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier2()) {
|
|
||||||
return 3;
|
return Material.FEATHER;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Material getAxesNotificationItem(int skillLevel) {
|
||||||
|
for (Tier tier : Tier.values()) {
|
||||||
|
if (skillLevel >= tier.getLevel()) {
|
||||||
|
return tier.getAxesNotificationItem();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier1()) {
|
|
||||||
return 2;
|
return Material.WOOD_AXE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Material getExcavationNotificationItem(int skillLevel) {
|
||||||
|
for (Tier tier : Tier.values()) {
|
||||||
|
if (skillLevel >= tier.getLevel()) {
|
||||||
|
return tier.getExcavationNotificationItem();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return 1;
|
return Material.DIRT;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Material getFishingNotificationItem(int skillLevel) {
|
||||||
|
for (Tier tier : Tier.values()) {
|
||||||
|
if (skillLevel >= tier.getLevel()) {
|
||||||
|
return tier.getFishingNotificationItem();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Material.RAW_FISH;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Material getHerbalismNotificationItem(int skillLevel) {
|
||||||
|
for (Tier tier : Tier.values()) {
|
||||||
|
if (skillLevel >= tier.getLevel()) {
|
||||||
|
return tier.getHerbalismNotificationItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Material.VINE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Material getMiningNotificationItem(int skillLevel) {
|
||||||
|
for (Tier tier : Tier.values()) {
|
||||||
|
if (skillLevel >= tier.getLevel()) {
|
||||||
|
return tier.getMiningNotificationItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Material.COAL_ORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Material getSwordsNotificationItem(int skillLevel) {
|
||||||
|
for (Tier tier : Tier.values()) {
|
||||||
|
if (skillLevel >= tier.getLevel()) {
|
||||||
|
return tier.getSwordsNotificationItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Material.WOOD_SWORD;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Material getTamingNotificationItem(int skillLevel) {
|
||||||
|
for (Tier tier : Tier.values()) {
|
||||||
|
if (skillLevel >= tier.getLevel()) {
|
||||||
|
return tier.getTamingNotificationItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Material.PORK;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Material getUnarmedNotificationItem(int skillLevel) {
|
||||||
|
for (Tier tier : Tier.values()) {
|
||||||
|
if (skillLevel >= tier.getLevel()) {
|
||||||
|
return tier.getUnarmedNotificationItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Material.LEATHER_HELMET;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Material getWoodcuttingNotificationItem(int skillLevel) {
|
||||||
|
for (Tier tier : Tier.values()) {
|
||||||
|
if (skillLevel >= tier.getLevel()) {
|
||||||
|
return tier.getWoodcuttingNotificationItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Material.STICK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-enable SpoutCraft for players after a /reload
|
* Re-enable SpoutCraft for players after a /reload
|
||||||
*/
|
*/
|
||||||
public static void reloadSpoutPlayers() {
|
public static void reloadSpoutPlayers() {
|
||||||
|
PluginManager pluginManager = mcMMO.p.getServer().getPluginManager();
|
||||||
|
|
||||||
for (SpoutPlayer spoutPlayer : SpoutManager.getPlayerChunkMap().getOnlinePlayers()) {
|
for (SpoutPlayer spoutPlayer : SpoutManager.getPlayerChunkMap().getOnlinePlayers()) {
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(new SpoutCraftEnableEvent(spoutPlayer));
|
pluginManager.callEvent(new SpoutCraftEnableEvent(spoutPlayer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,9 +420,55 @@ public class SpoutUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void preCacheFiles() {
|
public static void preCacheFiles() {
|
||||||
extractFiles(); // Extract source materials
|
SpoutManager.getFileManager().addToPreLoginCache(mcMMO.p, extractFiles());
|
||||||
|
}
|
||||||
|
|
||||||
FileManager FM = SpoutManager.getFileManager();
|
public static void processLevelup(McMMOPlayer mcMMOPlayer, SkillType skillType, int levelsGained) {
|
||||||
FM.addToPreLoginCache(plugin, getFiles());
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
||||||
|
|
||||||
|
if (spoutPlayer.isSpoutCraftEnabled()) {
|
||||||
|
levelUpNotification(skillType, spoutPlayer);
|
||||||
|
|
||||||
|
/* Update custom titles */
|
||||||
|
if (SpoutConfig.getInstance().getShowPowerLevel()) {
|
||||||
|
spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getName(), mcMMOPlayer.getPowerLevel()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, mcMMOPlayer.getProfile().getSkillLevel(skillType)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void processXpGain(Player player, PlayerProfile profile) {
|
||||||
|
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
||||||
|
|
||||||
|
if (spoutPlayer.isSpoutCraftEnabled() && SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||||
|
profile.getSpoutHud().updateXpBar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendRepairNotifications(Player player, int anvilId) {
|
||||||
|
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
||||||
|
|
||||||
|
if (spoutPlayer.isSpoutCraftEnabled()) {
|
||||||
|
String[] spoutMessages = Repair.getSpoutAnvilMessages(anvilId);
|
||||||
|
spoutPlayer.sendNotification(spoutMessages[0], spoutMessages[1], Material.getMaterial(anvilId));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(Repair.getAnvilMessage(anvilId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendDonationNotification(Player player) {
|
||||||
|
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
||||||
|
|
||||||
|
if (spoutPlayer.isSpoutCraftEnabled()) {
|
||||||
|
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("MOTD.Donate"));
|
||||||
|
player.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "gjmcferrin@gmail.com" + ChatColor.GOLD + " Paypal");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#
|
#
|
||||||
# Advanced configuration
|
# Advanced configuration
|
||||||
#
|
|
||||||
# For advanced users only! There is no need to change anything here.
|
|
||||||
#
|
#
|
||||||
# You can customize almost every aspect of every skill here.
|
# For advanced users only! There is no need to change anything here.
|
||||||
|
#
|
||||||
|
# You can customize almost every aspect of every skill here.
|
||||||
# Its mainly here if you've changed "Experience.Formula.Curve_Modifier"
|
# Its mainly here if you've changed "Experience.Formula.Curve_Modifier"
|
||||||
# Configure at what level you get better with certain abilities.
|
# Configure at what level you get better with certain abilities.
|
||||||
#
|
#
|
||||||
@@ -43,7 +43,6 @@ Skills:
|
|||||||
GracefulRoll_ChanceMax: 100.0
|
GracefulRoll_ChanceMax: 100.0
|
||||||
GracefulRoll_MaxBonusLevel: 500
|
GracefulRoll_MaxBonusLevel: 500
|
||||||
GracefulRoll_DamageThreshold: 14
|
GracefulRoll_DamageThreshold: 14
|
||||||
GracefulRoll_SuccessModifier: 2
|
|
||||||
|
|
||||||
# Amount of experience for performing a dodge, roll or fall
|
# Amount of experience for performing a dodge, roll or fall
|
||||||
Dodge_XP_Modifier: 120
|
Dodge_XP_Modifier: 120
|
||||||
@@ -71,6 +70,9 @@ Skills:
|
|||||||
# Retrieve_MaxBonusLevel: Maximum bonus level for Arrow retrieval, at this level the chance of retrieving arrows from mobs is Retrieve_MaxBonus
|
# Retrieve_MaxBonusLevel: Maximum bonus level for Arrow retrieval, at this level the chance of retrieving arrows from mobs is Retrieve_MaxBonus
|
||||||
Retrieve_MaxChance: 100.0
|
Retrieve_MaxChance: 100.0
|
||||||
Retrieve_MaxBonusLevel: 1000
|
Retrieve_MaxBonusLevel: 1000
|
||||||
|
|
||||||
|
#Force_Multiplier: Multiply the force of the bow by this for an XP boost.
|
||||||
|
Force_Multiplier: 2.0
|
||||||
#
|
#
|
||||||
# Settings for Axes
|
# Settings for Axes
|
||||||
###
|
###
|
||||||
@@ -139,6 +141,9 @@ Skills:
|
|||||||
|
|
||||||
# This determines when Fisherman's Diet adds extra hunger recovery to food
|
# This determines when Fisherman's Diet adds extra hunger recovery to food
|
||||||
Fisherman_Diet_RankChange: 200
|
Fisherman_Diet_RankChange: 200
|
||||||
|
|
||||||
|
# Ice_Fishing_UnlockLevel: Fishing level when the Ice Fishing ability unlocks
|
||||||
|
Ice_Fishing_UnlockLevel: 50
|
||||||
#
|
#
|
||||||
# Settings for Herbalism
|
# Settings for Herbalism
|
||||||
###
|
###
|
||||||
@@ -400,12 +405,21 @@ Skills:
|
|||||||
# DoubleDrops_MaxBonusLevel: Level when the maximum chance of receiving double drops is reached
|
# DoubleDrops_MaxBonusLevel: Level when the maximum chance of receiving double drops is reached
|
||||||
DoubleDrops_ChanceMax: 100.0
|
DoubleDrops_ChanceMax: 100.0
|
||||||
DoubleDrops_MaxBonusLevel: 1000
|
DoubleDrops_MaxBonusLevel: 1000
|
||||||
Spout:
|
#
|
||||||
#
|
# Customize the kraken!
|
||||||
# Settings for the Spout notifications, when a player reaches a higher tier, the image of the notification will change.
|
###
|
||||||
###
|
Kraken:
|
||||||
Notifications:
|
Enabled: true
|
||||||
Tier1: 200
|
Tries_Before_Release: 50
|
||||||
Tier2: 400
|
Health: 50
|
||||||
Tier3: 600
|
Name: The Kraken
|
||||||
Tier4: 800
|
Attack_Interval_Seconds: 1
|
||||||
|
Attack_Damage: 1
|
||||||
|
Global_Sounds: true
|
||||||
|
Allow_Escaping: false
|
||||||
|
Unleashed_Message:
|
||||||
|
Server: (PLAYER) has unleashed the kraken!
|
||||||
|
Player: THE KRAKEN HAS BEEN UNLEASHED!
|
||||||
|
Defeated_Message:
|
||||||
|
Escape: You have escaped from the kraken!
|
||||||
|
Killed: You have slain the kraken!
|
||||||
@@ -26,34 +26,39 @@ General:
|
|||||||
Verbose_Logging: false
|
Verbose_Logging: false
|
||||||
# Should mcMMO over-write configs to update, or make new ones ending in .new?
|
# Should mcMMO over-write configs to update, or make new ones ending in .new?
|
||||||
Config_Update_Overwrite: true
|
Config_Update_Overwrite: true
|
||||||
|
# Enable potato easter egg?
|
||||||
|
Potato_Explosion_Enabled: false
|
||||||
|
Potato_Explosion_Chance: 1
|
||||||
|
|
||||||
Scoreboards:
|
Scoreboards:
|
||||||
|
# Should mcMMO use scoreboards for /inspect?
|
||||||
|
# Amount of time (in seconds) to display. To display permanently, set to -1
|
||||||
Inspect:
|
Inspect:
|
||||||
# Should mcMMO use scoreboards for /inspect?
|
|
||||||
Use: true
|
Use: true
|
||||||
# Amount of time (in seconds) to display. To display permanently, set to -1
|
|
||||||
Display_Time: 10
|
Display_Time: 10
|
||||||
|
# Should mcMMO use scoreboards for /mcrank?
|
||||||
|
# Amount of time (in seconds) to display. To display permanently, set to -1
|
||||||
Mcrank:
|
Mcrank:
|
||||||
# Should mcMMO use scoreboards for /mcrank?
|
|
||||||
Use: true
|
Use: true
|
||||||
# Amount of time (in seconds) to display. To display permanently, set to -1
|
|
||||||
Display_Time: 10
|
Display_Time: 10
|
||||||
|
# Should mcMMO use scoreboards for /mcstats?
|
||||||
|
# Amount of time (in seconds) to display. To display permanently, set to -1
|
||||||
Mcstats:
|
Mcstats:
|
||||||
# Should mcMMO use scoreboards for /mcstats?
|
|
||||||
Use: true
|
Use: true
|
||||||
# Amount of time (in seconds) to display. To display permanently, set to -1
|
|
||||||
Display_Time: 10
|
Display_Time: 10
|
||||||
|
# Should mcMMO use scoreboards for /mctop?
|
||||||
|
# Amount of time (in seconds) to display. To display permanently, set to -1
|
||||||
Mctop:
|
Mctop:
|
||||||
# Should mcMMO use scoreboards for /mctop?
|
|
||||||
Use: true
|
Use: true
|
||||||
# Amount of time (in seconds) to display. To display permanently, set to -1
|
|
||||||
Display_Time: 10
|
Display_Time: 10
|
||||||
|
# Should mcMMO use scoreboards for /skillname (/mining, /fishing, etc.)?
|
||||||
|
# Amount of time (in seconds) to display. To display permanently, set to -1
|
||||||
Skillname:
|
Skillname:
|
||||||
# Should mcMMO use scoreboards for /skillname (/mining, /fishing, etc.)?
|
|
||||||
Use: true
|
Use: true
|
||||||
# Amount of time (in seconds) to display. To display permanently, set to -1
|
|
||||||
Display_Time: 10
|
Display_Time: 10
|
||||||
|
# Should mcMMO display power levels on scoreboards? (below player name-tags)
|
||||||
|
Power_Level:
|
||||||
|
Use: false
|
||||||
|
|
||||||
Mob_Healthbar:
|
Mob_Healthbar:
|
||||||
# Default display for mob health bars - HEARTS, BAR, or DISABLED
|
# Default display for mob health bars - HEARTS, BAR, or DISABLED
|
||||||
@@ -69,6 +74,7 @@ Database_Purging:
|
|||||||
# Any user who hasn't connected in this many months will be purged from the database
|
# Any user who hasn't connected in this many months will be purged from the database
|
||||||
# To never purge old users, set to -1
|
# To never purge old users, set to -1
|
||||||
Old_User_Cutoff: 6
|
Old_User_Cutoff: 6
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for using a mySQL database
|
# Settings for using a mySQL database
|
||||||
###
|
###
|
||||||
@@ -82,6 +88,7 @@ MySQL:
|
|||||||
Server:
|
Server:
|
||||||
Port: 3306
|
Port: 3306
|
||||||
Address: localhost
|
Address: localhost
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for Hardcore mode
|
# Settings for Hardcore mode
|
||||||
###
|
###
|
||||||
@@ -273,8 +280,9 @@ Double_Drops:
|
|||||||
###
|
###
|
||||||
Experience:
|
Experience:
|
||||||
Gains:
|
Gains:
|
||||||
|
# Experience gained from mobs not naturally spawned will get multiplied by this value. 0 by default.
|
||||||
Mobspawners:
|
Mobspawners:
|
||||||
Enabled: false
|
Multiplier: 0
|
||||||
|
|
||||||
# Experience gained in every skill will get multiplied by this value. 1.0 by default, 2.0 means two times as much
|
# Experience gained in every skill will get multiplied by this value. 1.0 by default, 2.0 means two times as much
|
||||||
Multiplier:
|
Multiplier:
|
||||||
@@ -379,12 +387,15 @@ Experience:
|
|||||||
Magma_Cube: 2.0
|
Magma_Cube: 2.0
|
||||||
Iron_Golem: 2.0
|
Iron_Golem: 2.0
|
||||||
Wither_Skeleton: 4.0
|
Wither_Skeleton: 4.0
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for commands
|
# Settings for commands
|
||||||
###
|
###
|
||||||
Commands:
|
Commands:
|
||||||
mcmmo:
|
mcmmo:
|
||||||
Donate_Message: true
|
Donate_Message: true
|
||||||
|
inspect:
|
||||||
|
Max_Distance: 30
|
||||||
ptp:
|
ptp:
|
||||||
Cooldown: 120
|
Cooldown: 120
|
||||||
Warmup: 5
|
Warmup: 5
|
||||||
@@ -400,6 +411,7 @@ Commands:
|
|||||||
a:
|
a:
|
||||||
# Allow mcMMO to use player display names in chat instead of their usernames
|
# Allow mcMMO to use player display names in chat instead of their usernames
|
||||||
Use_Display_Names: true
|
Use_Display_Names: true
|
||||||
|
|
||||||
#
|
#
|
||||||
# Settings for particles
|
# Settings for particles
|
||||||
###
|
###
|
||||||
@@ -408,6 +420,9 @@ Particles:
|
|||||||
Ability_Activation: true
|
Ability_Activation: true
|
||||||
Ability_Deactivation: true
|
Ability_Deactivation: true
|
||||||
|
|
||||||
|
# Determines if the fireworks should be a large ball or a small one
|
||||||
|
LargeFireworks: true
|
||||||
|
|
||||||
# Use particle effect when these abilities trigger
|
# Use particle effect when these abilities trigger
|
||||||
Dodge: true
|
Dodge: true
|
||||||
Bleed: true
|
Bleed: true
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#####
|
#####
|
||||||
Item_Weights:
|
Item_Weights:
|
||||||
Default: 5
|
Default: 5
|
||||||
|
Quartz: 200
|
||||||
|
Quartz_Ore: 200
|
||||||
Emerald: 150
|
Emerald: 150
|
||||||
Emerald_Ore: 150
|
Emerald_Ore: 150
|
||||||
Diamond: 100
|
Diamond: 100
|
||||||
@@ -25,6 +27,32 @@ Item_Weights:
|
|||||||
Coal: 10
|
Coal: 10
|
||||||
Coal_Ore: 10
|
Coal_Ore: 10
|
||||||
|
|
||||||
|
# Item weights for armor and tools
|
||||||
|
Diamond_Sword: 150
|
||||||
|
Diamond_Spade: 150
|
||||||
|
Diamond_Pickaxe: 150
|
||||||
|
Diamond_Axe: 150
|
||||||
|
Diamond_Helmet: 150
|
||||||
|
Diamond_Chestplate: 150
|
||||||
|
Diamond_Leggings: 150
|
||||||
|
Diamond_Boots: 150
|
||||||
|
Gold_Sword: 75
|
||||||
|
Gold_Spade: 75
|
||||||
|
Gold_Pickaxe: 75
|
||||||
|
Gold_Axe: 75
|
||||||
|
Gold_Helmet: 75
|
||||||
|
Gold_Chestplate: 75
|
||||||
|
Gold_Leggings: 75
|
||||||
|
Gold_Boots: 75
|
||||||
|
Iron_Sword: 60
|
||||||
|
Iron_Spade: 60
|
||||||
|
Iron_Pickaxe: 60
|
||||||
|
Iron_Axe: 60
|
||||||
|
Iron_Helmet: 60
|
||||||
|
Iron_Chestplate: 60
|
||||||
|
Iron_Leggings: 60
|
||||||
|
Iron_Boots: 60
|
||||||
|
|
||||||
# Items in this section will get added to the Misc share category.
|
# Items in this section will get added to the Misc share category.
|
||||||
# Case insensitive, though the name must be exactly the same as set in the Bukkit Material enum.
|
# Case insensitive, though the name must be exactly the same as set in the Bukkit Material enum.
|
||||||
Party_Shareables:
|
Party_Shareables:
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user