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

Compare commits

..

149 Commits

Author SHA1 Message Date
GJ
663d54d31f OOP is good. 2013-05-21 15:56:09 -04:00
GJ
9a5f4b638f Little more cleaning. 2013-05-21 14:15:28 -04:00
GJ
9aa49a09da Little more cleanup. 2013-05-21 14:03:00 -04:00
GJ
bf8945ac59 Try to clean CombatUtils a bit... 2013-05-21 13:36:44 -04:00
GJ
d9926bab4e Try to clean up our poor EntityListener... 2013-05-21 13:27:52 -04:00
GJ
38ba2c21e5 Back to normal development. 2013-05-21 12:22:11 -04:00
GJ
a48fb30edf New beta! 2013-05-21 12:20:50 -04:00
GJ
92ec04bd46 Better boolean handling. 2013-05-21 11:44:16 -04:00
GJ
0b6372a6ea Don't run these calculations twice. Also, pretty sure one of these was
bugged.
2013-05-21 11:41:39 -04:00
GJ
4f8b66f94d Clean up our block listener some. 2013-05-21 11:11:55 -04:00
GJ
0c52b3016c We've got these functions, might as well use them. 2013-05-21 10:02:09 -04:00
GJ
a2f80569e3 Fire McMMOPlayerLevelUp events for our experience commands, when
applicable. Fixes #921
2013-05-21 09:31:25 -04:00
GJ
87df536a1f Only check for kraken if you're actually fishing. 2013-05-21 09:14:54 -04:00
T00thpick1
12e70490d8 Cooldowns messages need to be affected by perks too 2013-05-20 22:35:34 -04:00
TfT_02
23b1518dc0 More formatting :) 2013-05-20 17:28:02 -04:00
T00thpick1
6dbf2e0d95 FishingTreasureEvent, FishingShakeEvent and MagicHunterEvent 2013-05-20 17:27:59 -04:00
GJ
60304e9643 Because Minecraft does stupid things with "/" in the chat.
Fixes #994
2013-05-20 08:56:02 -04:00
GJ
614557e2fa It'd be nice if Ice Fishing actually worked. 2013-05-20 08:07:39 -04:00
TfT_02
e312e95aed Refactor to a more descriptive name,
also fixes a small typo.
2013-05-20 10:55:17 +02:00
t00thpick1
2ee919b51f Update gravatar 2013-05-19 18:18:55 -03:00
T00thpick1
22f6ae858b Update inventories after chimera wing 2013-05-19 16:13:19 -04:00
T00thpick1
3c3b4af2c4 No salvaging chainmail - FIXES 1118 2013-05-19 12:55:18 -04:00
T00thpick1
feb0d1fe5d Things that should never happen, but are. 2013-05-18 22:15:32 -04:00
TfT_02
2d66b8ed12 Cleanup - fixing various formatting issues 2013-05-18 22:41:42 +02:00
TfT_02
483f348403 Fixed bug with Blast Mining where the Ability refreshed message was being send too early 2013-05-18 22:27:17 +02:00
TfT_02
a8a5100f58 Update the changelog
Also made a minor edit to a comment about the powerlevel display
2013-05-18 14:27:14 +02:00
TfT_02
1f9dc70bb1 I forgot to remove the setting from advanced.yml 2013-05-18 14:12:45 +02:00
TfT_02
7f1ef61657 Get rid of the SuccessModifier
There's no need for this modifier, because the user can define the
exact chance for Rolls and Gracefull Rolls in the config file. This
means that the ratio between the two is already configurable.
2013-05-18 14:12:07 +02:00
TfT_02
2e74c079b0 Set the enchant buff level to 1 if it's lower than 0
Prevents issue #1006 from happening again.

If a user wants to disable SuperBreaker, they should do this using
permissions and not by setting the Enchant Buff level to zero.
2013-05-18 11:37:40 +02:00
TfT_02
ce4295289a Changed powerlevel display setting to disabled by default.
Because scoreboards are being cached by Minecraft in scoreboard.dat it
is no user friendly to enabled this by default. Users will have to
manually delete this file in order to actually disable this.
Described in #1105
2013-05-18 11:27:17 +02:00
T00thpick1
7fde04851d Typo 2013-05-17 18:44:23 -04:00
riking
71d030e5ad Change rounding strategy to ceiling for mob healthbars 2013-05-17 00:19:59 -04:00
T00thpick1
b08649d0a4 Not much help if not static 2013-05-16 23:58:49 -04:00
T00thpick1
0a11a9a2c8 More methods for SkillType 2013-05-16 22:00:40 -04:00
T00thpick1
068f47b523 Option for any distance 2013-05-16 19:53:58 -04:00
T00thpick1
79aab57abc Configure the inspect distance 2013-05-16 19:31:12 -04:00
T00thpick1
2cf58f1b5b Why break when we can return? 2013-05-16 18:04:14 -04:00
T00thpick1
9678875b4b We do enjoy killing off orphans 2013-05-16 17:26:16 -04:00
GJ
d1a7ce827a Back to active development. Again. 2013-05-16 16:24:19 -04:00
GJ
9b2f4b7bde Because the old beta broke all the things. 2013-05-16 16:23:12 -04:00
GJ
24e5147a2a This was never an issue. 2013-05-16 16:13:53 -04:00
T00thpick1
0423a7831d Those were right the first time... 2013-05-16 15:55:25 -04:00
T00thpick1
feea22b3a4 Correctly order 2013-05-16 15:52:49 -04:00
T00thpick1
7f40a9f284 Explicitely state columns wanted to account for altered tables 2013-05-16 15:50:19 -04:00
GJ
bc706109e0 Fix issue with tables without party names. 2013-05-16 13:37:22 -04:00
GJ
a25bddba5e Back to active development. 2013-05-16 10:55:13 -04:00
GJ
ab897724d3 Weekly beta! 2013-05-16 10:54:40 -04:00
GJ
a7861fc54b Move all miscellaneous Spout code to a single location. 2013-05-16 10:51:18 -04:00
GJ
936bec8ff5 Unused import. 2013-05-16 09:32:48 -04:00
GJ
01d10971a1 Calling things that many times is BAD. 2013-05-16 09:32:27 -04:00
T00thpick1
12e388a392 Null checks 2013-05-16 09:30:02 -04:00
T00thpick1
fb450671d6 Alternative SQL player loading 2013-05-16 09:29:59 -04:00
GJ
fca5f9ec98 We shouldn't need to do this. If issues arise, then there's a bug in
Bukkit that needs patching.
2013-05-16 09:23:35 -04:00
GJ
c9ae6436bd Because we forget things too often. 2013-05-16 08:41:57 -04:00
GJ
b6c4d2b4ad Fixed bug where Nether Quartz wasn't included in Smelting or item
sharing
2013-05-16 08:13:01 -04:00
GJ
27ab2f5b12 Update localization files. 2013-05-16 07:35:00 -04:00
T00thpick1
9b08062a58 Typo 2013-05-15 20:36:43 -04:00
T00thpick1
401bdfa9ac Reset ability modes safely 2013-05-15 20:35:30 -04:00
TfT_02
68d8d6dd30 Added permission node to bypass the fishing exploit prevention
Permission node: `mcmmo.bypass.kraken` false by default.
2013-05-15 23:35:17 +02:00
GJ
2a57d7007d Don't go through everything twice. Also, those were horrible variable
names.
2013-05-15 17:28:47 -04:00
GJ
fd675ac291 Changed Spout notification tiers to be stored in SpoutConfig instead of
AdvancedConfig. Also restructured some Spout stuff for easier
readability.
2013-05-15 17:08:43 -04:00
GJ
41f020bbb7 Cleaning up our listeners, as well as some Spout stuff. 2013-05-15 15:39:40 -04:00
GJ
00dee500e0 Caching options is bad, and so was that way of getting the menu key. 2013-05-15 15:28:05 -04:00
GJ
36bdb8a63e Fixed mcMMO overwritting Spout titles set by other plugins. 2013-05-15 15:14:47 -04:00
GJ
aa9eb0868c Add option to use scoreboards for power level display, similar to the
Spout titles. This will NOT override any existing plugin that uses the
overhead scoreboard slot.
2013-05-15 15:13:11 -04:00
T00thpick1
48aafa9834 Unused import 2013-05-15 14:27:31 -04:00
T00thpick1
78f53f294a Debris should drop normal drops 2013-05-15 13:02:21 -04:00
TfT_02
3158c7e3eb List /party itemshare and /party expshare in /party ?
Closes #913
2013-05-15 19:00:34 +02:00
GJ
47d27ebf31 Update changelog. 2013-05-15 09:29:54 -04:00
GJ
bc3773ae75 Because apparently you can have metadata and an empty list too.
Fixes #1080
2013-05-15 09:29:24 -04:00
GJ
d8ddd27d71 Calculate bonus XP based on initial arrow location, rather than final
shooter location.
2013-05-15 08:35:12 -04:00
GJ
8d5696507a Add bow force multiplier to Archery XP. 2013-05-15 01:20:12 -04:00
T00thpick1
9ec376a228 Unused import and update changelog 2013-05-15 00:53:01 -04:00
T00thpick1
a05a0da9fb Mob Spawner XP multiplier 2013-05-15 00:48:18 -04:00
T00thpick1
5029ad9d93 Apply Perks after cutoff 2013-05-14 23:54:54 -04:00
T00thpick1
1444be665c No reason to specify MyISAM 2013-05-14 23:54:52 -04:00
GJ
3dedb94bdc Add new Experience API functions and clarify some old ones. 2013-05-14 23:30:36 -04:00
T00thpick1
c0f6c15a80 Fix SQL Syntax 2013-05-14 23:28:45 -04:00
T00thpick1
00626a4893 Update changelog.txt 2013-05-14 23:03:26 -04:00
T00thpick1
b416a59bb7 Don't cache config options to prepare for eventual config reload support 2013-05-14 22:59:16 -04:00
GJ
bf96fb2214 Update changelog 2013-05-14 22:45:10 -04:00
GJ
2e79c8d770 Properly track infinite arrows. 2013-05-14 22:45:09 -04:00
T00thpick1
6c9d1c4953 Make SQL removes delete from all tables 2013-05-14 22:20:06 -04:00
T00thpick1
df8df192d3 Update Changelog 2013-05-14 19:57:18 -04:00
T00thpick1
e5f43462c8 Certain operations do not work with child skills 2013-05-14 19:31:40 -04:00
GJ
1867a3e040 If they aren't in a party, they shouldn't be in party chat mode. 2013-05-14 13:10:54 -04:00
GJ
6818f98de3 Feedback is good. 2013-05-14 13:10:07 -04:00
GJ
f910c76248 Conventions. 2013-05-14 12:46:45 -04:00
GJ
975cbf0bf8 The cache should be here, not in the manager. 2013-05-14 12:46:04 -04:00
GJ
f10b3cef01 Config option for escaping from the Kraken. 2013-05-14 12:43:02 -04:00
T00thpick1
ad39c94773 AbilityDeactivateEvent 2013-05-14 12:18:52 -04:00
T00thpick1
f189ab30e5 Default should be default 2013-05-14 11:32:57 -04:00
GJ
0ad18ee971 Fix some config formatting issues. 2013-05-14 11:32:22 -04:00
GJ
501f5de55a Fixing everything you guys broke while I was gone... 2013-05-14 11:28:50 -04:00
T00thpick1
0b18ae8ff2 Formatting and things 2013-05-13 22:28:42 -04:00
T00thpick1
de12970486 New api event 2013-05-13 22:28:39 -04:00
Glitchfinder
7550b99aaa Patching more NPEs involving invbalid players, plus mob health bars. 2013-05-13 18:46:19 -07:00
Glitchfinder
ed5a43966d Patching NPEs involving invalid player objects and player interactions. 2013-05-13 18:46:18 -07:00
Glitchfinder
95ea6703f1 Fixing an NPE involving invalid players chatting. 2013-05-13 18:46:17 -07:00
T00thpick1
55f9092aa6 Fireworks adjustment 2013-05-13 21:23:16 -04:00
Glitchfinder
5f50a46603 Setting the treasure config to only enforce data limits for blocks. 2013-05-13 20:22:09 -04:00
Paul J Thordarson
c5e6704530 Magic Hunter fix and optimization
There was a small bug in magic hunter, where it tried to apply an
enchantment level between 1 and the Enchantment.getMaxLevel(), however
it didn't take into account Enchantment.getStartLevel(), so when it
tried to apply an enchantment level below the start level, an
IllegalArgumentException was being thrown and the magic hunter event
wasn't happening.

Also, it's potentially inefficient to recalculate which enchantments
are possible for each ItemStack every time, so I added a HashMap to
cache the possibleEnchantments for each material type, then check this
cache instead of just looping to regenerate the list each time.
2013-05-13 20:22:08 -04:00
T00thpick1
8552192894 Only apply permissions when skill is enabled 2013-05-13 20:19:50 -04:00
NuclearW
0261d16140 Give no mcMMO xp for skeletons that spawn as a spider jokey pair from spawners. 2013-05-11 18:54:25 -04:00
NuclearW
2b414526e5 Unleash the Quacken! 2013-05-09 11:04:34 -04:00
NuclearW
c0b7eb526a Change Squid variables to Creature. 2013-05-09 11:00:28 -04:00
t00thpick1
7b7196a8c4 Potatoes shouldn't explode by default 2013-05-05 23:00:14 -03:00
t00thpick1
f648289035 Potato fixes 2013-05-05 22:58:04 -03:00
TfT_02
8a0b1d548d Add item weights for armor and tools in the default file 2013-05-05 11:32:10 +02:00
NuclearW
1f17d5d11e Move the comment section attached to the Kraken in advanced.yml
This is to fix a shortcoming in the autoupdate-config loader, which will attach related comments to nodes.
Issue: A nodes will get comments from another node of the same name, anywhere else in the config.
Solution: Move the comment to be attached to the "Kraken" node.

Long term: This can be a known bug and worked around by the team, or can be addressed more seriously by looking into changing how comments are applied to configs.  For now, this is a patch solution that should work fine.

Fixes #1043
2013-05-05 05:27:11 -04:00
TfT_02
18efd09421 Remove \' since it somehow breaks the name display
For some reason using \' will show the pets name as:
"<player-name>'s {1}"
2013-05-05 00:36:58 +02:00
TfT_02
18d3b30647 Add a missing space 2013-05-04 23:34:19 +02:00
GJ
7f0243b2df For Iaccidentally. 2013-05-03 18:16:42 -04:00
GJ
33610c8997 Whoops. 2013-05-03 16:15:34 -04:00
GJ
8e0a1f4f70 Summon the kraken at will! 2013-05-03 16:14:03 -04:00
GJ
b07cf6bdde It's now possible to run away from the Kraken. 2013-05-03 15:49:29 -04:00
GJ
7ed218ee7f Cleanup this task a bit. 2013-05-03 13:43:23 -04:00
GJ
3aedeea220 Remove client-side rain if the player kills the kraken. 2013-05-03 12:11:52 -04:00
GJ
4f9b7b2609 Because you might be legitimately fishing at 5 seconds. 2013-05-03 07:51:59 -04:00
GJ
09abab1b5d Kraken sounds can now be set to either player-only or global (default). 2013-05-03 07:51:58 -04:00
GJ
499713c8e7 Because autoclicking to shake is OK. 2013-05-03 07:51:57 -04:00
GJ
cb953a1619 Disable global chat spam from the kraken by setting the server message
to an empty string in the config.
2013-05-03 07:51:56 -04:00
TfT_02
3ab4938f3d Also need to locale these two strings
Closes #1019
2013-05-02 21:08:20 +02:00
TfT_02
f6e9fd9f3a Add more localisation 2013-05-02 21:02:12 +02:00
GJ
8dab75f3cb Can't use brackets in YAML. 2013-05-02 08:48:17 -04:00
GJ
b36096e54d Fixed bug where non-player arrows couldn't be deflected. 2013-05-02 08:23:18 -04:00
GJ
0574de4a29 Configure the Kraken! 2013-05-02 07:56:29 -04:00
GJ
6d6bc3de76 Trim player names to 16 chars when needed. 2013-05-02 07:16:07 -04:00
GJ
5c4c3cf59c The Kraken hates boats. 2013-05-01 22:50:12 -04:00
GJ
0033c8864e A dead kraken can't attack. 2013-05-01 22:17:48 -04:00
GJ
e7c749ee3a Added boosts to Fishing chance depending on conditions. Also, the
kraken, now with 100% more sound!
2013-05-01 21:57:42 -04:00
GJ
5c026be0cd Don't need those. 2013-05-01 21:19:29 -04:00
GJ
c465546871 Unleash the Kraken! 2013-05-01 21:17:59 -04:00
GJ
3322677d32 Added "Ice Fishing" ability to Fishing 2013-05-01 10:18:19 -04:00
GJ
76cf0ebb01 Only play ability effects if there's room above the player. 2013-05-01 08:59:45 -04:00
GJ
d34a0cca30 Fix issue with using /mcpurge, /mcremove, and /mmoupdate from the
console. These commands now default to OP, because frankly there are
much worse things someone can do with OP status than mess with the mcMMO
database.
2013-05-01 08:40:01 -04:00
GJ
a77a916fcc One more time... 2013-04-30 17:31:06 -04:00
GJ
e1ebb96545 Still need to remove from pending even if offline. 2013-04-30 15:47:19 -04:00
GJ
d85a6bec43 Don't create a task we'll possibly never run. 2013-04-30 15:19:41 -04:00
GJ
78eb7787e9 We don't need this any more. 2013-04-30 15:13:55 -04:00
GJ
b55ce30b2d Clean up our main class a bit more. Still not perfect, but it's getting
there.
2013-04-30 15:07:29 -04:00
GJ
14050cf096 Oops. 2013-04-30 14:24:31 -04:00
GJ
5930128b7f Add soft-depend on CombatTag so it loads before mcMMO, allowing us to
ensure the name check is ONLY run if CombatTag is installed.
2013-04-30 13:53:21 -04:00
GJ
08be78fa35 Avoid possible IllegalStateException if player has logged out before
this processes.
2013-04-30 10:02:28 -04:00
GJ
88f43d9a91 Add command to clear or change scoreboards. 2013-04-30 09:48:53 -04:00
GJ
6cbf960dea Use the right value here. 2013-04-30 08:24:16 -04:00
TfT_02
374d34f76d Fixed that for you 2013-04-30 14:20:16 +02:00
GJ
cc486c2dc7 Update the localization files. 2013-04-29 16:27:25 -04:00
GJ
724dce07a9 Back to regular development. 2013-04-29 15:59:56 -04:00
115 changed files with 3897 additions and 1868 deletions

View File

@@ -6,8 +6,9 @@ Key:
= Fix
! Change
- Removal
Version 1.4.06-dev
+ Added "Ice Fishing" ability to Fishing
+ Added global scoreboards to track skill rankings (display using /mctop)
+ Added per-player scoreboard displays for the /inspect, /mcrank, /mcstats, and /<skillname> 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 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 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 displaying partial names when trying to use /ptp
= 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 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 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 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
@@ -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
! Items dropped by players are now being tracked and are not being shared with party members
! Optimized tracking of tool & ability cooldowns.
! Updated the localization files
Version 1.4.05
+ Added option to allow refreshing of chunks after block-breaking abilities. (Disabled by default)

View File

@@ -29,7 +29,7 @@ mcMMO is currently developed by a team of individuals from all over the world.
(https://github.com/shatteredbeam)
[![TfT_02](http://www.gravatar.com/avatar/b8914f9970e1f6ffd5281ce4770e20a7.png)]
(https://github.com/TfT-02)
[![t00thpick1](http://www.gravatar.com/avatar/??.png)]
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)]
(https://github.com/t00thpick1)
## Compiling

View File

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

View File

@@ -3,6 +3,7 @@ package com.gmail.nossr50.api;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
@@ -22,7 +23,7 @@ public final class ChatAPI {
* @param message The message to send
*/
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
*/
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.
*/
public static void toggleAdminChat(String playerName){
public static void toggleAdminChat(String playerName) {
UserManager.getPlayer(playerName).setAdminChat(!isUsingAdminChat(playerName));
}
}

View File

@@ -119,7 +119,7 @@ public final class ExperienceAPI {
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
*
* @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) {
SkillType skill = SkillType.getSkill(skillType);
@@ -183,6 +184,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException();
}
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
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 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) {
SkillType skill = SkillType.getSkill(skillType);
@@ -205,6 +211,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException();
}
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
return getOfflineProfile(playerName).getSkillXpLevel(skill);
}
@@ -218,6 +228,7 @@ public final class ExperienceAPI {
* @return the amount of XP in a given skill
*
* @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) {
SkillType skill = SkillType.getSkill(skillType);
@@ -226,6 +237,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException();
}
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
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 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) {
SkillType skill = SkillType.getSkill(skillType);
@@ -248,19 +264,24 @@ public final class ExperienceAPI {
throw new InvalidSkillException();
}
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
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>
* 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 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 UnsupportedOperationException if the given skill is a child skill
*/
public static int getXPToNextLevel(Player player, String skillType) {
SkillType skill = SkillType.getSkill(skillType);
@@ -269,9 +290,68 @@ public final class ExperienceAPI {
throw new InvalidSkillException();
}
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
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.
* </br>
@@ -279,19 +359,26 @@ public final class ExperienceAPI {
*
* @param playerName The player 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 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);
if (skill == null) {
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;
PlayerProfile profile = getOfflineProfile(playerName);
for (SkillType type : SkillType.values()) {
if (type.isChildSkill()) {
continue;
}
for (SkillType type : SkillType.nonChildSkills()) {
powerLevel += profile.getSkillLevel(type);
}
@@ -514,6 +597,7 @@ public final class ExperienceAPI {
* @param newValue The value to set the XP to
*
* @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) {
SkillType skill = SkillType.getSkill(skillType);
@@ -522,6 +606,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException();
}
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
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 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) {
SkillType skill = SkillType.getSkill(skillType);
@@ -544,6 +633,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException();
}
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
getOfflineProfile(playerName).setSkillXpLevel(skill, newValue);
}
@@ -557,6 +650,7 @@ public final class ExperienceAPI {
* @param xp The amount of XP to remove
*
* @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) {
SkillType skill = SkillType.getSkill(skillType);
@@ -565,6 +659,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException();
}
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have 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 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) {
SkillType skill = SkillType.getSkill(skillType);
@@ -587,6 +686,10 @@ public final class ExperienceAPI {
throw new InvalidSkillException();
}
if (skill.isChildSkill()) {
throw new UnsupportedOperationException("Child skills do not have XP");
}
getOfflineProfile(playerName).removeXp(skill, xp);
}

View File

@@ -53,7 +53,7 @@ public final class PartyAPI {
* @return true if the two players are in the same party, false otherwise
*/
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.
*/
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
*/
public static void addToParty(Player player, String partyName) {
Party party = PartyManager.getParty(partyName);
Party party = mcMMO.getPartyManager().getParty(partyName);
if (party == null) {
party = new Party();
@@ -84,7 +84,7 @@ public final class PartyAPI {
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
*/
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
*/
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
*/
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) {
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);
members.add(member);
}
@@ -150,7 +150,7 @@ public final class PartyAPI {
* @return all the player names in the player's party
*/
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
*/
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
*/
public static List<Player> getOnlineMembers(Player player) {
return PartyManager.getOnlineMembers(player);
return mcMMO.getPartyManager().getOnlineMembers(UserManager.getPlayer(player).getParty().getName());
}
}

View File

@@ -12,7 +12,7 @@ import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader;
public final class ChatManager {
public ChatManager () {}
public ChatManager() {}
public static void handleAdminChat(Plugin plugin, String playerName, String displayName, String message, boolean isAsync) {
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(plugin, playerName, displayName, message, isAsync);

View 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();
}
}
}

View File

@@ -1,17 +1,17 @@
package com.gmail.nossr50.commands;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
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.commands.party.PartySubcommandType;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.spout.SpoutUtils;
public class McmmoCommand implements CommandExecutor {
@Override
@@ -28,13 +28,13 @@ public class McmmoCommand implements CommandExecutor {
sender.sendMessage(mcSplit);
if (Config.getInstance().getDonateMessageEnabled()) {
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
SpoutPlayer spoutPlayer = (SpoutPlayer) sender;
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.Donate"), ChatColor.GREEN + "gjmcferrin@gmail.com", Material.DIAMOND);
if (mcMMO.isSpoutEnabled() && sender instanceof Player) {
SpoutUtils.sendDonationNotification((Player) sender);
}
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()));
@@ -62,52 +62,52 @@ public class McmmoCommand implements CommandExecutor {
private void displayPartyCommands(CommandSender sender) {
if (Permissions.party(sender)) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
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 quit " + LocaleLoader.getString("Commands.Party.Quit"));
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 quit " + LocaleLoader.getString("Commands.Party.Quit"));
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 accept " + LocaleLoader.getString("Commands.Party.Accept"));
sender.sendMessage(" /party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
sender.sendMessage(" /party accept " + LocaleLoader.getString("Commands.Party.Accept"));
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) {
sender.sendMessage(LocaleLoader.getString("Commands.Other"));
sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
sender.sendMessage(" /mcstats " + LocaleLoader.getString("Commands.Stats"));
sender.sendMessage(" /mctop " + LocaleLoader.getString("Commands.Leaderboards"));
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)) {
sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
sender.sendMessage(" /mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
}
if (Permissions.adminChat(sender)) {
sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
sender.sendMessage(" /adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
}
if (Permissions.inspect(sender)) {
sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
sender.sendMessage(" /inspect " + LocaleLoader.getString("Commands.Inspect"));
}
if (Permissions.mmoedit(sender)) {
sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
sender.sendMessage(" /mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
}
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"));
}
}

View File

@@ -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
}
}

View File

@@ -35,7 +35,7 @@ public class PartyChatCommand extends ChatCommand {
return;
}
Party party = PartyManager.getParty(args[0]);
Party party = mcMMO.getPartyManager().getParty(args[0]);
if (party == null) {
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));

View File

@@ -9,18 +9,12 @@ import org.bukkit.command.TabExecutor;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.google.common.collect.ImmutableList;
public class McpurgeCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Permissions.mcpurge(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
switch (args.length) {
case 0:
mcMMO.getDatabaseManager().purgePowerlessUsers();

View File

@@ -12,7 +12,6 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@@ -21,11 +20,6 @@ import com.google.common.collect.ImmutableList;
public class McremoveCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Permissions.mcremove(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
switch (args.length) {
case 1:
if (UserManager.getPlayer(args[0]) == null && CommandUtils.unloadedProfile(sender, new PlayerProfile(args[0], false))) {

View File

@@ -11,7 +11,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.database.SQLConversionTask;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
@@ -19,11 +18,6 @@ import com.google.common.collect.ImmutableList;
public class MmoupdateCommand implements TabExecutor {
@Override
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()) {
sender.sendMessage("SQL Mode is not enabled."); // TODO: Localize
return true;

View File

@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
@@ -21,6 +23,10 @@ public class AddlevelsCommand extends ExperienceCommand {
@Override
protected void handleCommand(SkillType skill) {
profile.addLevels(skill, value);
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value));
}
}
@Override

View File

@@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
@@ -21,6 +23,10 @@ public class MmoeditCommand extends ExperienceCommand {
@Override
protected void handleCommand(SkillType skill) {
profile.modifySkill(skill, value);
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - profile.getSkillLevel(skill)));
}
}
@Override

View File

@@ -3,8 +3,10 @@ package com.gmail.nossr50.commands.experience;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
@@ -84,13 +86,11 @@ public class SkillresetCommand extends ExperienceCommand {
@Override
protected boolean permissionsCheckSelf(CommandSender sender) {
// TODO Auto-generated method stub
return false;
}
@Override
protected boolean permissionsCheckOthers(CommandSender sender) {
// TODO Auto-generated method stub
return false;
}
@@ -102,6 +102,10 @@ public class SkillresetCommand extends ExperienceCommand {
}
profile.modifySkill(skill, 0);
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, 0 - profile.getSkillLevel(skill)));
}
}
@Override

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
@@ -24,11 +25,11 @@ public class PartyAcceptCommand implements CommandExecutor {
}
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), mcMMOPlayer.getPartyInvite().getName())) {
if (!mcMMO.getPartyManager().changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
return true;
}
PartyManager.joinInvitedParty(player, mcMMOPlayer);
mcMMO.getPartyManager().joinInvitedParty(player);
return true;
default:

View File

@@ -4,6 +4,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
@@ -21,7 +22,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
return true;
}
PartyManager.setPartyLeader(args[1], playerParty);
mcMMO.getPartyManager().setPartyLeader(args[1], playerParty);
return true;
default:

View File

@@ -5,7 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
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.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
@@ -17,22 +17,20 @@ public class PartyCreateCommand implements CommandExecutor {
switch (args.length) {
case 2:
case 3:
Party newParty = PartyManager.getParty(args[1]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
Player player = mcMMOPlayer.getPlayer();
// 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;
}
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) {
if (!mcMMO.getPartyManager().changeOrJoinParty(mcMMOPlayer, args[1])) {
return true;
}
PartyManager.createParty(player, mcMMOPlayer, args[1], getPassword(args));
mcMMO.getPartyManager().createParty(player, args[1], getPassword(args));
return true;
default:

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -20,14 +21,14 @@ public class PartyDisbandCommand implements CommandExecutor {
String partyName = playerParty.getName();
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;
}
member.sendMessage(LocaleLoader.getString("Party.Disband"));
}
PartyManager.disbandParty(playerParty);
mcMMO.getPartyManager().disbandParty(playerParty);
return true;
default:

View File

@@ -19,6 +19,8 @@ public class PartyHelpCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick"));
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party leader"));
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;
default:

View File

@@ -104,7 +104,7 @@ public class PartyInfoCommand implements CommandExecutor {
}
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;
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -32,14 +33,14 @@ public class PartyInviteCommand implements CommandExecutor {
return true;
}
if (PartyManager.inSameParty(player, target)) {
if (mcMMO.getPartyManager().inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
return true;
}
Party playerParty = mcMMOPlayer.getParty();
if (!PartyManager.canInvite(player, playerParty)) {
if (!mcMMO.getPartyManager().canInvite(player)) {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true;
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -37,16 +38,16 @@ public class PartyJoinCommand implements CommandExecutor {
String password = getPassword(args);
// Make sure party passwords match
if (!PartyManager.checkPartyPassword(player, targetParty, password)) {
if (!mcMMO.getPartyManager().checkPartyPassword(player, targetParty, password)) {
return true;
}
// Changing parties
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, playerParty, targetParty.getName())) {
if (!mcMMO.getPartyManager().changeOrJoinParty(mcMMOPlayer, targetParty.getName())) {
return true;
}
PartyManager.joinParty(player, mcMMOPlayer, targetParty, password);
mcMMO.getPartyManager().joinParty(player, targetParty, password);
return true;
default:

View File

@@ -30,14 +30,14 @@ public class PartyKickCommand implements CommandExecutor {
Player onlineTarget = target.getPlayer();
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;
}
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
}
PartyManager.removeFromParty(target, playerParty);
mcMMO.getPartyManager().removeFromParty(target, playerParty);
return true;
default:

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -19,11 +20,11 @@ public class PartyQuitCommand implements CommandExecutor {
Player player = (Player) sender;
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;
}
PartyManager.removeFromParty(player, playerParty);
mcMMO.getPartyManager().removeFromParty(player, playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
return true;

View File

@@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
@@ -30,17 +31,16 @@ public class PartyRenameCommand implements CommandExecutor {
}
Player player = mcMMOPlayer.getPlayer();
Party newParty = PartyManager.getParty(newPartyName);
// 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;
}
String leaderName = playerParty.getLeader();
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;
}

View File

@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -56,11 +55,15 @@ public class PtpCommand implements TabExecutor {
Player player = mcMMOPlayer.getPlayer();
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)) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)));
return true;
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 true;
}
}
if (args[0].equalsIgnoreCase("accept")) {
@@ -75,9 +78,13 @@ public class PtpCommand implements TabExecutor {
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
long lastTeleport = mcMMOPlayer.getLastTeleport();
if (!SkillUtils.cooldownOver(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player)) {
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!
return true;
if (ptpCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player);
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Item.Generic.Wait", timeRemaining));
return true;
}
}
sendTeleportRequest(sender, player, args[0]);
@@ -139,7 +146,7 @@ public class PtpCommand implements TabExecutor {
return false;
}
if (!PartyManager.inSameParty(player, target)) {
if (!mcMMO.getPartyManager().inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return false;
}
@@ -166,7 +173,7 @@ public class PtpCommand implements TabExecutor {
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
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);
}
else {

View File

@@ -1,5 +1,8 @@
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.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -22,6 +25,7 @@ public class FishingCommand extends SkillCommand {
private boolean canShake;
private boolean canFishermansDiet;
private boolean canMasterAngler;
private boolean canIceFish;
public FishingCommand() {
super(SkillType.FISHING);
@@ -60,7 +64,18 @@ public class FishingCommand extends SkillCommand {
// MASTER ANGLER
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);
canFishermansDiet = Permissions.fishermansDiet(player);
canMasterAngler = Permissions.masterAngler(player);
canIceFish = Permissions.iceFishing(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet;
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish;
}
@Override
@@ -101,11 +117,15 @@ public class FishingCommand extends SkillCommand {
if (canMasterAngler) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
}
if (canIceFish) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet;
return canTreasureHunt || canMagicHunt || canShake || canMasterAngler || canFishermansDiet || canIceFish;
}
@Override
@@ -136,5 +156,16 @@ public class FishingCommand extends SkillCommand {
if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
}
if (canIceFish) {
int unlockLevel = AdvancedConfig.getInstance().getIceFishingUnlockLevel();
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.1", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing"));
}
}
}
}

View File

@@ -22,7 +22,7 @@ public abstract class SpoutCommand implements TabExecutor {
return true;
}
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled()) {
if (!mcMMO.isSpoutEnabled() || !SpoutConfig.getInstance().getXPBarEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}

View File

@@ -20,7 +20,10 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
/* GENERAL */
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 */
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 int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
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 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 int getRetrieveMaxBonusLevel() { return config.getInt("Skills.Archery.Retrieve_MaxBonusLevel", 1000); }
public double getForceMultiplier() { return config.getDouble("Skills.Archery.Force_Multiplier", 2.0D); }
/* AXES */
public int getBonusDamageAxesBonusMax() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonus", 4); }
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 getIceFishingUnlockLevel() { return config.getInt("Skills.Fishing.Ice_Fishing_UnlockLevel", 50); }
/* Shake */
public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); }
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 int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); }
/* SPOUT STUFF*/
public int getSpoutNotificationTier1() { return config.getInt("Spout.Notifications.Tier1", 200); }
public int getSpoutNotificationTier2() { return config.getInt("Spout.Notifications.Tier2", 400); }
public int getSpoutNotificationTier3() { return config.getInt("Spout.Notifications.Tier3", 600); }
public int getSpoutNotificationTier4() { return config.getInt("Spout.Notifications.Tier4", 800); }
/* KRAKEN STUFF */
public boolean getKrakenEnabled() { return config.getBoolean("Kraken.Enabled", true); }
public boolean getKrakenGlobalSoundsEnabled() { return config.getBoolean("Kraken.Global_Sounds", true); }
public boolean getKrakenEscapeAllowed() { return config.getBoolean("Kraken.Allow_Escaping", false); }
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); }
}

View File

@@ -46,6 +46,9 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
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 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 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 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 int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); }
public boolean getPowerLevelsEnabled() { return config.getBoolean("Scoreboards.Power_Level.Use", false); }
/* Database Purging */
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
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 getLevelUpEffectsEnabled() { return config.getBoolean("Particles.LevelUp_Enabled", true); }
public int getLevelUpEffectsTier() { return config.getInt("Particles.LevelUp_Tier", 100); }
public boolean getLargeFireworks() { return config.getBoolean("Particles.LargeFireworks", true); }
/* PARTY SETTINGS */
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 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
*/
@@ -272,7 +281,6 @@ public class Config extends AutoUpdateConfigLoader {
*/
/* General Settings */
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
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 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 */
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())); }
}

View File

@@ -57,7 +57,7 @@ public abstract class ConfigLoader {
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream(configFile);
outputStream = new FileOutputStream(configFile);
int read;
byte[] bytes = new byte[1024];

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.config.spout;
import org.getspout.spoutapi.keyboard.Keyboard;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.skills.SkillType;
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 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 */
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 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); }
/* 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); }
}

View File

@@ -117,7 +117,7 @@ public class TreasureConfig extends ConfigLoader {
reason.add("Invalid amount: " + amount);
}
if (data > 127 || data < -128) {
if (id < 256 && (data > 127 || data < -128)) {
reason.add("Invalid data: " + data);
}

View File

@@ -294,11 +294,7 @@ public final class FlatfileDatabaseManager {
Map<String, Integer> skills = new HashMap<String, Integer>();
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
continue;
}
for (SkillType skill : SkillType.nonChildSkills()) {
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
}

View File

@@ -92,14 +92,13 @@ public final class SQLDatabaseManager {
+ "`user` varchar(40) NOT NULL,"
+ "`lastlogin` int(32) unsigned NOT NULL,"
+ "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` ("
+ "`user_id` int(10) unsigned NOT NULL,"
+ "`hudtype` varchar(50) NOT NULL DEFAULT 'STANDARD',"
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT 'HEARTS',"
+ "PRIMARY KEY (`user_id`),"
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "',"
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "cooldowns` ("
+ "`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(32) unsigned NOT NULL DEFAULT '0',"
@@ -114,9 +113,8 @@ public final class SQLDatabaseManager {
+ "`axes` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`),"
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "skills` ("
+ "`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
@@ -130,9 +128,8 @@ public final class SQLDatabaseManager {
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`),"
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "experience` ("
+ "`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
@@ -146,15 +143,15 @@ public final class SQLDatabaseManager {
+ "`swords` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`),"
+ "FOREIGN KEY (`user_id`) REFERENCES `" + tablePrefix + "users` (`id`) "
+ "ON DELETE CASCADE) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;");
checkDatabaseStructure(DatabaseUpdateType.FISHING);
checkDatabaseStructure(DatabaseUpdateType.BLAST_MINING);
checkDatabaseStructure(DatabaseUpdateType.CASCADE_DELETE);
checkDatabaseStructure(DatabaseUpdateType.INDEX);
checkDatabaseStructure(DatabaseUpdateType.MOB_HEALTHBARS);
checkDatabaseStructure(DatabaseUpdateType.PARTY_NAMES);
checkDatabaseStructure(DatabaseUpdateType.KILL_ORPHANS);
}
/**
@@ -175,7 +172,9 @@ public final class SQLDatabaseManager {
return true;
}
catch (SQLException ex) {
printErrors(ex);
if (!sql.equalsIgnoreCase("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;")) {
printErrors(ex);
}
return false;
}
finally {
@@ -191,7 +190,13 @@ public final class SQLDatabaseManager {
}
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()) {
try {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
String skillName = skillType.name().toLowerCase();
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
@@ -489,8 +490,12 @@ public final class SQLDatabaseManager {
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");
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());
}
@@ -499,7 +504,12 @@ public final class SQLDatabaseManager {
long purgeTime = ONE_MONTH * Config.getInstance().getOldUsersCutoff();
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());
}
@@ -530,13 +540,6 @@ public final class SQLDatabaseManager {
sql = "SELECT * FROM `" + tablePrefix + "cooldowns` ORDER BY `" + tablePrefix + "cooldowns`.`blast_mining` ASC LIMIT 0 , 30";
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:
sql = "SELECT * FROM `" + tablePrefix + "experience` ORDER BY `" + tablePrefix + "experience`.`fishing` ASC LIMIT 0 , 30";
break;
@@ -557,12 +560,44 @@ public final class SQLDatabaseManager {
+ "ADD INDEX `idx_acrobatics` (`acrobatics`) USING BTREE, "
+ "ADD INDEX `idx_fishing` (`fishing`) USING BTREE;");
}
break;
return;
case MOB_HEALTHBARS:
sql = "SELECT * FROM `" + tablePrefix + "huds` ORDER BY `" + tablePrefix + "huds`.`mobhealthbar` ASC LIMIT 0 , 30";
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:
break;
}
@@ -601,7 +636,7 @@ public final class SQLDatabaseManager {
case 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;
default:

View File

@@ -3,7 +3,9 @@ package com.gmail.nossr50.datatypes.database;
public enum DatabaseUpdateType {
FISHING,
BLAST_MINING,
CASCADE_DELETE,
INDEX,
MOB_HEALTHBARS;
MOB_HEALTHBARS,
PARTY_NAMES,
KILL_ORPHANS,
;
}

View File

@@ -8,6 +8,7 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.ShareHandler.ShareMode;
public class Party {
@@ -62,25 +63,24 @@ public class Party {
public List<String> getItemShareCategories() {
List<String> shareCategories = new ArrayList<String>();
// TODO Locale the category names!
if (shareLootDrops) {
shareCategories.add("Loot");
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Loot"));
}
if (shareMiningDrops) {
shareCategories.add("Mining");
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Mining"));
}
if (shareHerbalismDrops) {
shareCategories.add("Herbalism");
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Herbalism"));
}
if (shareWoodcuttingDrops) {
shareCategories.add("Woodcutting");
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Woodcutting"));
}
if (shareMiscDrops) {
shareCategories.add("Misc");
shareCategories.add(LocaleLoader.getString("Party.ItemShare.Category.Misc"));
}
return shareCategories;

View File

@@ -20,6 +20,7 @@ import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
import com.gmail.nossr50.skills.archery.ArcheryManager;
@@ -93,7 +94,7 @@ public class McMMOPlayer {
this.player = player;
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),
@@ -182,7 +183,8 @@ public class McMMOPlayer {
*/
public void resetAbilityMode() {
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() {
int powerLevel = 0;
for (SkillType type : SkillType.values()) {
if (type.isChildSkill()) {
continue;
}
for (SkillType type : SkillType.nonChildSkills()) {
if (Permissions.skillEnabled(player, type)) {
powerLevel += profile.getSkillLevel(type);
}
@@ -506,14 +504,15 @@ public class McMMOPlayer {
Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
for (SkillType parentSkill : parentSkills) {
if (Permissions.skillEnabled(player, parentSkill)) {
applyXpGain(parentSkill, xp / parentSkills.size());
}
applyXpGain(parentSkill, xp / parentSkills.size());
}
return;
}
if (!Permissions.skillEnabled(player, skillType)) {
return;
}
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp);
mcMMO.p.getServer().getPluginManager().callEvent(event);

View File

@@ -42,18 +42,14 @@ public class PlayerProfile {
public PlayerProfile(String playerName, boolean addNew) {
this.playerName = playerName;
hudType = mcMMO.spoutEnabled ? SpoutConfig.getInstance().getDefaultHudType() : HudType.DISABLED;
hudType = mcMMO.isSpoutEnabled() ? SpoutConfig.getInstance().getDefaultHudType() : HudType.DISABLED;
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
for (AbilityType abilityType : AbilityType.values()) {
skillsDATS.put(abilityType, 0);
}
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
skills.put(skillType, 0);
skillsXp.put(skillType, 0F);
}
@@ -257,7 +253,7 @@ public class PlayerProfile {
* @return the Xp remaining until next level
*/
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) {
@@ -287,80 +283,111 @@ public class PlayerProfile {
private boolean loadMySQL() {
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) {
return false;
if (playerData == null || playerData.size() == 0) {
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) {
SQLDatabaseManager.write("INSERT INTO " + tablePrefix + "huds (user_id, mobhealthbar) VALUES (" + userId + ",'" + mobHealthbarType.name() + "')");
mcMMO.p.getLogger().warning(playerName + "does not exist in the HUD table. Their HUDs will be reset.");
skills.put(SkillType.TAMING, Integer.valueOf(playerData.get(1)));
skills.put(SkillType.MINING, Integer.valueOf(playerData.get(2)));
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 {
hudType = HudType.valueOf(hudValues.get(0));
mobHealthbarType = MobHealthbarType.valueOf(hudValues.get(1));
catch (Exception e) {
// Shouldn't happen unless database is being tampered with
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);
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.");
try {
mobHealthbarType = MobHealthbarType.valueOf(playerData.get(38));
}
else {
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(cooldownValues.get(0)));
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)));
catch (Exception e) {
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
}
loaded = true;

View File

@@ -68,6 +68,13 @@ public enum AbilityType {
null),
LEAF_BLOWER(
null,
null,
null,
null,
null),
BLOCK_CRACKER(
null,
null,
null,
@@ -144,7 +151,6 @@ public enum AbilityType {
* @return true if the player has permissions, false otherwise
*/
public boolean getPermissions(Player player) {
switch (this) {
case BERSERK:
return Permissions.berserk(player);
@@ -152,6 +158,9 @@ public enum AbilityType {
case BLAST_MINING:
return Permissions.remoteDetonation(player);
case BLOCK_CRACKER:
return Permissions.blockCracker(player);
case GIGA_DRILL_BREAKER:
return Permissions.gigaDrillBreaker(player);
@@ -189,6 +198,9 @@ public enum AbilityType {
case BERSERK:
return (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW);
case BLOCK_CRACKER:
return BlockUtils.affectedByBlockCracker(blockState);
case GIGA_DRILL_BREAKER:
return BlockUtils.affectedByGigaDrillBreaker(blockState);

View File

@@ -108,7 +108,7 @@ public enum SkillType {
}
public double getXpModifier() {
return Config.getInstance().getForumulaMultiplier(this);
return Config.getInstance().getFormulaSkillModifier(this);
}
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() {
return runescapeColor;
}
public static SkillType byAbility(AbilityType ability) {
for (SkillType type : values()) {
if (type.getAbility() == ability) {
return type;
}
}
return null;
}
}

View File

@@ -17,7 +17,7 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained) {
super(player, skill);
this.setLevelsGained(levelsGained);
this.levelsGained = levelsGained;
}
/**

View File

@@ -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);
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -28,14 +28,12 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair;
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.util.BlockUtils;
import com.gmail.nossr50.util.ItemUtils;
@@ -72,9 +70,11 @@ public class BlockListener implements Listener {
}
for (Block b : blocks) {
if (b.getRelative(direction).hasMetadata(mcMMO.blockMetadataKey)) {
mcMMO.getPlaceStore().setTrue(b.getRelative(direction));
b.getRelative(direction).removeMetadata(mcMMO.blockMetadataKey, plugin);
Block nextBlock = b.getRelative(direction);
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();
int blockId = blockState.getTypeId();
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockUtils.shouldBeWatched(blockState)) {
mcMMO.getPlaceStore().setTrue(blockState);
}
if (Repair.anvilMessagesEnabled && (blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId)) {
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockId);
if (Repair.anvilMessagesEnabled && BlockUtils.isMcMMOAnvil(blockState)) {
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getTypeId());
}
}
@@ -323,41 +322,31 @@ public class BlockListener implements Listener {
ItemStack heldItem = player.getItemInHand();
Block block = event.getBlock();
BlockState blockState = block.getState();
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
/*
* ABILITY TRIGGER CHECKS
*
* 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 (herbalismManager.processGreenTerra(blockState)) {
if (mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState)) {
if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) {
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 (heldItem.getType() == Material.AIR) {
plugin.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player));
event.setInstaBreak(true);
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 (BlockUtils.affectedByBlockCracker(blockState)) {
UnarmedManager unarmedManager = mcMMOPlayer.getUnarmedManager();
if (unarmedManager.canUseBlockCracker() && SkillUtils.blockBreakSimulate(block, player, false) && unarmedManager.blockCrackerCheck(blockState)) {
else if (Permissions.blockCracker(player) && SkillUtils.triggerCheck(player, block, AbilityType.BLOCK_CRACKER)) {
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
blockState.update();
}
}
}
else if (BlockUtils.isLeaves(blockState)) {
if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.blockBreakSimulate(block, player, true)) {
event.setInstaBreak(true);
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
event.setInstaBreak(true);
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}
}
}

View File

@@ -2,7 +2,9 @@ package com.gmail.nossr50.listeners;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity;
@@ -15,19 +17,22 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
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.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
@@ -52,13 +57,35 @@ public class EntityListener implements Listener {
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.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlockEvent(EntityChangeBlockEvent event) {
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof FallingBlock)) {
@@ -84,7 +111,13 @@ public class EntityListener implements Listener {
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
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;
}
@@ -94,13 +127,14 @@ public class EntityListener implements Listener {
return;
}
Entity attacker = event.getDamager();
LivingEntity target = (LivingEntity) defender;
if (CombatUtils.isInvincible(target, event.getDamage())) {
if (CombatUtils.isInvincible(target, damage)) {
return;
}
Entity attacker = event.getDamager();
if (attacker instanceof Projectile) {
attacker = ((Projectile) attacker).getShooter();
}
@@ -121,7 +155,7 @@ public class EntityListener implements Listener {
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);
return;
}
@@ -137,7 +171,13 @@ public class EntityListener implements Listener {
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
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;
}
@@ -147,13 +187,14 @@ public class EntityListener implements Listener {
return;
}
DamageCause cause = event.getCause();
LivingEntity livingEntity = (LivingEntity) entity;
if (CombatUtils.isInvincible(livingEntity, event.getDamage())) {
if (CombatUtils.isInvincible(livingEntity, damage)) {
return;
}
DamageCause cause = event.getCause();
if (livingEntity instanceof Player) {
Player player = (Player) entity;
@@ -286,7 +327,6 @@ public class EntityListener implements Listener {
return;
}
entity.setFireTicks(0);
BleedTimerTask.remove(entity);
Archery.arrowRetrievalCheck(entity);
}
@@ -298,14 +338,21 @@ public class EntityListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
if (Misc.isSpawnerXPEnabled) {
return;
}
switch (event.getSpawnReason()) {
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) {
event.getEntity().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
if (passenger != null) {
passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
}
return;
default:
return;
}
}
@@ -318,19 +365,21 @@ public class EntityListener implements Listener {
public void onExplosionPrime(ExplosionPrimeEvent event) {
Entity entity = event.getEntity();
if (entity instanceof TNTPrimed && entity.hasMetadata(mcMMO.tntMetadataKey)) {
// We can make this assumption because we (should) be the only ones using this exact metadata
Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
return;
}
if (Misc.isNPCEntity(player)) {
return;
}
// We can make this assumption because we (should) be the only ones using this exact metadata
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()) {
event.setRadius(miningManager.biggerBombs(event.getRadius()));
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
if (miningManager.canUseBiggerBombs()) {
event.setRadius(miningManager.biggerBombs(event.getRadius()));
}
}
@@ -343,20 +392,22 @@ public class EntityListener implements Listener {
public void onEnitityExplode(EntityExplodeEvent event) {
Entity entity = event.getEntity();
if (entity instanceof TNTPrimed && entity.hasMetadata(mcMMO.tntMetadataKey)) {
// We can make this assumption because we (should) be the only ones using this exact metadata
Player player = plugin.getServer().getPlayer(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
return;
}
if (Misc.isNPCEntity(player)) {
return;
}
// We can make this assumption because we (should) be the only ones using this exact metadata
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.blastMiningDropProcessing(event.getYield(), event.blockList());
event.setYield(0);
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
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) {
Entity entity = event.getEntity();
if (entity instanceof Player) {
Player player = (Player) entity;
if (!(entity instanceof Player)) {
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;
}
int currentFoodLevel = player.getFoodLevel();
int newFoodLevel = event.getFoodLevel();
int foodChange = newFoodLevel - currentFoodLevel;
if (foodChange <= 0) {
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (Permissions.farmersDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
}
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;
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
if (Permissions.fishermansDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
}
return;
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (Permissions.farmersDiet(player)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, 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;
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
if (Permissions.fishermansDiet(player)) {
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;
}
default:
return;
}
}

View File

@@ -1,5 +1,8 @@
package com.gmail.nossr50.listeners;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Furnace;
@@ -19,8 +22,10 @@ import org.bukkit.inventory.FurnaceInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.util.ItemUtils;
@@ -96,10 +101,11 @@ public class InventoryListener implements Listener {
if (furnaceState instanceof Furnace) {
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
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)) {
return;
@@ -117,10 +123,19 @@ public class InventoryListener implements Listener {
if (furnaceState instanceof Furnace) {
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
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)) {
return;
@@ -138,10 +153,11 @@ public class InventoryListener implements Listener {
if (furnaceState instanceof Furnace) {
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
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)) {
return;

View File

@@ -1,12 +1,12 @@
package com.gmail.nossr50.listeners;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Fish;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
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.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.SkillUtils;
public class PlayerListener implements Listener {
@@ -144,6 +145,7 @@ public class PlayerListener implements Listener {
}
UserManager.addUser(player).actualizeRespawnATS();
ScoreboardManager.enablePowerLevelDisplay(player);
}
/**
@@ -176,6 +178,14 @@ public class PlayerListener implements Listener {
switch (event.getState()) {
case FISHING:
if (!Permissions.krakenBypass(player)) {
event.setCancelled(fishingManager.exploitPrevention());
if (event.isCancelled()) {
return;
}
}
if (fishingManager.canMasterAngler()) {
fishingManager.masterAngler(event.getHook());
}
@@ -191,11 +201,22 @@ public class PlayerListener implements Listener {
case CAUGHT_ENTITY:
Entity entity = event.getCaught();
if (fishingManager.canShake(entity)) {
fishingManager.shakeCheck((LivingEntity) entity);
}
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:
break;
}
@@ -303,13 +324,20 @@ public class PlayerListener implements Listener {
public void onPlayerInteractLowest(PlayerInteractEvent event) {
Player player = event.getPlayer();
Block block = event.getClickedBlock();
ItemStack heldItem = player.getItemInHand();
if (Misc.isNPCEntity(player) || player.getGameMode() == GameMode.CREATIVE) {
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()) {
case RIGHT_CLICK_BLOCK:
@@ -317,7 +345,7 @@ public class PlayerListener implements Listener {
/* REPAIR CHECKS */
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);
// 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 */
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem) && !ItemUtils.isChainmailArmor(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
event.setCancelled(true);
// 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 */
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
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
UserManager.getPlayer(player).setLastAnvilUse(Repair.repairAnvilId, 0);
player.sendMessage(ChatColor.RED + "Repair cancelled!"); //TODO Locale!
mcMMOPlayer.setLastAnvilUse(Repair.repairAnvilId, 0);
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name")));
}
}
/* SALVAGE CHECKS */
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
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
UserManager.getPlayer(player).setLastAnvilUse(Repair.salvageAnvilId, 0);
player.sendMessage(ChatColor.RED + "Salvage cancelled!"); //TODO Locale!
mcMMOPlayer.setLastAnvilUse(Repair.salvageAnvilId, 0);
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name")));
}
}
@@ -404,6 +432,11 @@ public class PlayerListener implements Listener {
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;
}
switch (event.getAction()) {
case RIGHT_CLICK_BLOCK:
Block block = event.getClickedBlock();
@@ -502,10 +535,16 @@ public class PlayerListener implements Listener {
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()) {
Party party = mcMMOPlayer.getParty();
if (party == null) {
mcMMOPlayer.togglePartyChat();
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return;
}

View File

@@ -11,13 +11,13 @@ import org.getspout.spoutapi.gui.Button;
import org.getspout.spoutapi.gui.ScreenType;
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.spout.buttons.McMMOButton;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.datatypes.spout.popups.McMMOMenu;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.spout.SpoutUtils;
public class SpoutListener implements Listener {
@@ -32,8 +32,8 @@ public class SpoutListener implements Listener {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(spoutPlayer);
// TODO: Add custom titles based on skills
if (SpoutUtils.showPowerLevel) {
spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getName(), mcMMOPlayer.getPowerLevel()));
if (SpoutConfig.getInstance().getShowPowerLevel()) {
spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getTitle(), mcMMOPlayer.getPowerLevel()));
}
mcMMOPlayer.getProfile().setSpoutHud(new McMMOHud(mcMMOPlayer)); // Setup Party HUD stuff
@@ -81,7 +81,7 @@ public class SpoutListener implements Listener {
return;
}
if (event.getKey() == SpoutUtils.menuKey) {
if (event.getKey() == SpoutConfig.getInstance().getMenuKey()) {
McMMOHud spoutHud = UserManager.getPlayer(spoutPlayer).getProfile().getSpoutHud();
if (!spoutHud.isMenuOpened()) {

View File

@@ -4,7 +4,6 @@ import java.io.File;
import java.util.ArrayList;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
@@ -19,8 +18,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionMain;
public class WorldListener implements Listener {
private ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
private final ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
private final mcMMO plugin;
public WorldListener(final mcMMO plugin) {
@@ -34,12 +32,12 @@ public class WorldListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
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()) {
mcMMO.getPlaceStore().setFalse(blockState);
}
for (BlockState blockState : event.getBlocks()) {
mcMMO.getPlaceStore().setFalse(blockState);
}
}
@@ -51,9 +49,8 @@ public class WorldListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldInit(WorldInitEvent event) {
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;
}

View File

@@ -23,13 +23,12 @@ import com.gmail.nossr50.config.mods.CustomToolConfig;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
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.EntityListener;
import com.gmail.nossr50.listeners.InventoryListener;
import com.gmail.nossr50.listeners.PlayerListener;
import com.gmail.nossr50.listeners.SelfListener;
import com.gmail.nossr50.listeners.SpoutListener;
import com.gmail.nossr50.listeners.WorldListener;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.metrics.MetricsManager;
@@ -54,18 +53,11 @@ import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.spout.SpoutUtils;
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 */
private static ChunkManager placeStore;
private static ChunkManager placeStore;
private static RepairableManager repairableManager;
private static DatabaseManager databaseManager;
private static DatabaseManager databaseManager;
private static PartyManager partyManager;
/* File Paths */
private static String mainDirectory;
@@ -81,14 +73,14 @@ public class mcMMO extends JavaPlugin {
// Update Check
private boolean updateAvailable;
// Plugin Checks
public static boolean spoutEnabled;
public static boolean combatTagEnabled;
/* Plugin Checks */
private static boolean spoutEnabled;
private static boolean combatTagEnabled;
// XP Event Check
private boolean xpEventEnabled;
// Metadata Values
/* Metadata Values */
public final static String entityMetadataKey = "mcMMO: Spawned Entity";
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
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 customVisibleKey = "mcMMO: Name Visibility";
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;
@@ -113,14 +108,14 @@ public class mcMMO extends JavaPlugin {
setupSpout();
loadConfigFiles();
combatTagEnabled = getServer().getPluginManager().isPluginEnabled("CombatTag");
combatTagEnabled = getServer().getPluginManager().getPlugin("CombatTag") != null;
databaseManager = new DatabaseManager(this, Config.getInstance().getUseMySQL());
registerEvents();
registerCustomRecipes();
PartyManager.loadParties();
partyManager = new PartyManager(this);
for (Player player : getServer().getOnlinePlayers()) {
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!");
scheduleTasks();
registerCommands();
CommandRegistrationManager.registerCommands();
MetricsManager.setup();
@@ -161,9 +156,8 @@ public class mcMMO extends JavaPlugin {
@Override
public void onDisable() {
try {
reloadDisableHelper(); // Prevent Berserk from getting "stuck"
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.cleanUp(); // Cleanup empty metadata stores
}
@@ -242,6 +236,18 @@ public class mcMMO extends JavaPlugin {
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
*/
@@ -313,8 +319,7 @@ public class mcMMO extends JavaPlugin {
spoutEnabled = true;
SpoutConfig.getInstance();
SpoutUtils.setupSpoutConfigs();
SpoutUtils.registerCustomEvent();
getServer().getPluginManager().registerEvents(new SpoutListener(), this);
SpoutUtils.preCacheFiles();
SpoutUtils.reloadSpoutPlayers(); // Handle spout players after a /reload
}
@@ -324,53 +329,12 @@ public class mcMMO extends JavaPlugin {
PluginManager pluginManager = getServer().getPluginManager();
// Register events
pluginManager.registerEvents(playerListener, this);
pluginManager.registerEvents(blockListener, this);
pluginManager.registerEvents(entityListener, this);
pluginManager.registerEvents(inventoryListener, this);
pluginManager.registerEvents(selfListener, this);
pluginManager.registerEvents(worldListener, 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();
pluginManager.registerEvents(new PlayerListener(this), this);
pluginManager.registerEvents(new BlockListener(this), this);
pluginManager.registerEvents(new EntityListener(this), this);
pluginManager.registerEvents(new InventoryListener(this), this);
pluginManager.registerEvents(new SelfListener(), this);
pluginManager.registerEvents(new WorldListener(this), this);
}
private void registerCustomRecipes() {
@@ -382,49 +346,29 @@ public class mcMMO extends JavaPlugin {
private void scheduleTasks() {
// Periodic save timer (Saves every 10 minutes by default)
long saveIntervalTicks = Config.getInstance().getSaveInterval() * 1200;
new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks);
// Bleed timer (Runs every two seconds)
new BleedTimerTask().runTaskTimer(this, 40, 40);
// Old & Powerless User remover
int purgeInterval = Config.getInstance().getPurgeInterval();
UserPurgeTask userPurgeTask = new UserPurgeTask();
long purgeIntervalTicks = Config.getInstance().getPurgeInterval() * 60 * 60 * 20;
if (purgeInterval == 0) {
userPurgeTask.runTaskLater(this, 40);
if (purgeIntervalTicks == 0) {
new UserPurgeTask().runTaskLater(this, 40); // Start 2 seconds after startup.
}
else if (purgeInterval > 0) {
long purgeIntervalTicks = purgeInterval * 60 * 60 * 20;
userPurgeTask.runTaskTimer(this, purgeIntervalTicks, purgeIntervalTicks);
else if (purgeIntervalTicks > 0) {
new UserPurgeTask().runTaskTimer(this, purgeIntervalTicks, purgeIntervalTicks);
}
// Automatically remove old members from parties
long kickInterval = Config.getInstance().getAutoPartyKickInterval();
PartyAutoKickTask partyAutoKickTask = new PartyAutoKickTask();
long kickIntervalTicks = Config.getInstance().getAutoPartyKickInterval() * 60 * 60 * 20;
if (kickInterval == 0) {
partyAutoKickTask.runTaskLater(this, 40); // Start 2 seconds after startup.
if (kickIntervalTicks == 0) {
new PartyAutoKickTask().runTaskLater(this, 40); // Start 2 seconds after startup.
}
else if (kickInterval > 0) {
long kickIntervalTicks = kickInterval * 60 * 60 * 20;
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);
}
else if (kickIntervalTicks > 0) {
new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
}
}
}

View File

@@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration;
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.player.UserManager;
public final class PartyManager {
private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
private static List<Party> parties = new ArrayList<Party>();
private static File partyFile = new File(partiesFilePath);
public class PartyManager {
private final mcMMO plugin;
private final String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
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) {
if (party == null) {
loadParties();
}
public boolean checkPartyExistence(Player player, String partyName) {
if (getParty(partyName) == null) {
return false;
}
@@ -34,8 +40,12 @@ public final class PartyManager {
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()) {
Party oldParty = mcMMOPlayer.getParty();
if (!handlePartyChangeEvent(player, oldParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) {
return false;
}
@@ -56,7 +66,7 @@ public final class PartyManager {
* @param secondPlayer The second player
* @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 secondMcMMOPlayer = UserManager.getPlayer(secondPlayer);
@@ -81,15 +91,20 @@ public final class PartyManager {
* @param range The distance
* @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>();
Party party = UserManager.getPlayer(player).getParty();
if (party != null) {
Location playerLocation = player.getLocation();
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);
}
}
}
return nearMembers;
}
@@ -99,9 +114,7 @@ public final class PartyManager {
* @param player The player to check
* @return all the players in the player's party
*/
public static LinkedHashSet<String> getAllMembers(Player player) {
Party party = UserManager.getPlayer(player).getParty();
public LinkedHashSet<String> getAllMembers(Party party) {
if (party == null) {
return null;
}
@@ -115,7 +128,7 @@ public final class PartyManager {
* @param partyName The party to check
* @return all online players in this party
*/
public static List<Player> getOnlineMembers(String partyName) {
public List<Player> getOnlineMembers(String partyName) {
Party party = getParty(partyName);
if (party == null) {
@@ -125,29 +138,13 @@ public final class PartyManager {
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
*
* @param partyName The party name
* @return the existing party, null otherwise
*/
public static Party getParty(String partyName) {
public Party getParty(String partyName) {
for (Party party : parties) {
if (party.getName().equals(partyName)) {
return party;
@@ -163,7 +160,7 @@ public final class PartyManager {
* @param playerName The member name
* @return the existing party, null otherwise
*/
public static Party getPlayerParty(String playerName) {
public Party getPlayerParty(String playerName) {
for (Party party : parties) {
for (String memberName : party.getMembers()) {
if (memberName.equalsIgnoreCase(playerName)) {
@@ -180,7 +177,7 @@ public final class PartyManager {
*
* @return the list of parties.
*/
public static List<Party> getParties() {
public List<Party> getParties() {
return parties;
}
@@ -190,7 +187,7 @@ public final class PartyManager {
* @param player The player to remove
* @param party The party
*/
public static void removeFromParty(OfflinePlayer player, Party party) {
public void removeFromParty(OfflinePlayer player, Party party) {
LinkedHashSet<String> members = party.getMembers();
members.remove(player.getName());
@@ -201,20 +198,13 @@ public final class PartyManager {
else {
// If the leaving player was the party leader, appoint a new leader from the party members
if (party.getLeader().equalsIgnoreCase(player.getName())) {
String newLeader = members.iterator().next();
party.setLeader(newLeader);
party.setLeader(members.iterator().next());
}
informPartyMembersQuit(player, party);
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player.getName());
if (mcMMOPlayer != null) {
mcMMOPlayer.removeParty();
mcMMOPlayer.setPartyChat(false);
mcMMOPlayer.setItemShareModifier(10);
}
processPlayerLeaving(UserManager.getPlayer(player));
}
/**
@@ -222,17 +212,11 @@ public final class PartyManager {
*
* @param party The party to remove
*/
public static void disbandParty(Party party) {
public void disbandParty(Party party) {
LinkedHashSet<String> members = party.getMembers();
for (String memberName : members) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(memberName);
if (mcMMOPlayer != null) {
mcMMOPlayer.removeParty();
mcMMOPlayer.setPartyChat(false);
mcMMOPlayer.setItemShareModifier(10);
}
processPlayerLeaving(UserManager.getPlayer(memberName));
}
members.clear();
@@ -243,11 +227,10 @@ public final class PartyManager {
* Create a new 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 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(".", "");
Party party = getParty(partyName);
@@ -271,7 +254,7 @@ public final class PartyManager {
}
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 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)) {
return;
}
if (mcMMOPlayer.getParty() == party) {
return;
}
// // Pretty sure this isn't possible.
// if (mcMMOPlayer.getParty() == party) {
// return;
// }
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
* @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
if (party.isLocked()) {
String partyPassword = party.getPassword();
@@ -333,20 +317,22 @@ public final class PartyManager {
* @param Player The plaer 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();
if (mcMMOPlayer.getParty() == invite) {
return;
}
if (!parties.contains(invite)) {
parties.add(invite);
}
// // Pretty sure this isn't possible
// if (!parties.contains(invite)) {
// parties.add(invite);
// }
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName()));
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 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) {
return;
}
if (!parties.contains(party)) {
parties.add(party);
}
informPartyMembersJoin(player, party);
mcMMOPlayer.setParty(party);
@@ -373,7 +365,7 @@ public final class PartyManager {
* @param partyName The party name
* @return the leader of the party
*/
public static String getPartyLeader(String partyName) {
public String getPartyLeader(String partyName) {
Party party = getParty(partyName);
if (party == null) {
@@ -389,7 +381,7 @@ public final class PartyManager {
* @param playerName The name of the player to set as leader
* @param party The party
*/
public static void setPartyLeader(String playerName, Party party) {
public void setPartyLeader(String playerName, Party party) {
String leaderName = party.getLeader();
for (Player member : party.getOnlineMembers()) {
@@ -414,7 +406,9 @@ public final class PartyManager {
* @param mcMMOPlayer The player to check
* @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())) {
return false;
}
@@ -422,26 +416,10 @@ public final class PartyManager {
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.
*/
public static void loadParties() {
private void loadParties() {
if (!partyFile.exists()) {
return;
}
@@ -472,7 +450,7 @@ public final class PartyManager {
/**
* Save party file.
*/
public static void saveParties() {
public void saveParties() {
if (partyFile.exists()) {
partyFile.delete();
}
@@ -516,7 +494,7 @@ public final class PartyManager {
* @param reason The reason for changing parties
* @return true if the change event was successful, false otherwise
*/
public static boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
public boolean handlePartyChangeEvent(Player player, String oldPartyName, String newPartyName, EventReason reason) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, oldPartyName, newPartyName, reason);
mcMMO.p.getServer().getPluginManager().callEvent(event);
@@ -529,7 +507,7 @@ public final class PartyManager {
* @param player The player that joins
* @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()) {
if (!member.equals(player)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", player.getName()));
@@ -543,11 +521,21 @@ public final class PartyManager {
* @param player The player that quits
* @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()) {
if (!member.equals(player)) {
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);
}
}

View File

@@ -6,6 +6,7 @@ import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.party.ItemWeightConfig;
import com.gmail.nossr50.datatypes.party.ItemShareType;
@@ -53,12 +54,10 @@ public final class ShareHandler {
* @return True is the xp has been shared
*/
public static boolean handleXpShare(float xp, McMMOPlayer mcMMOPlayer, SkillType skillType) {
Party party = mcMMOPlayer.getParty();
switch (party.getXpShareMode()) {
switch (mcMMOPlayer.getParty().getXpShareMode()) {
case EQUAL:
Player player = mcMMOPlayer.getPlayer();
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
nearMembers = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange());
if (nearMembers.isEmpty()) {
return false;
@@ -112,7 +111,7 @@ public final class ShareHandler {
switch (party.getItemShareMode()) {
case EQUAL:
McMMOPlayer mcMMOTarget;
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
nearMembers = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange());
if (nearMembers.isEmpty()) {
return false;
@@ -159,7 +158,7 @@ public final class ShareHandler {
return true;
case RANDOM:
nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
nearMembers = mcMMO.getPartyManager().getNearbyPartyMembers(player, Config.getInstance().getPartyShareRange());
if (nearMembers.isEmpty()) {
return false;

View File

@@ -19,6 +19,6 @@ public class SaveTimerTask extends BukkitRunnable {
count++;
}
PartyManager.saveParties();
mcMMO.getPartyManager().saveParties();
}
}

View File

@@ -7,8 +7,8 @@ import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.SQLDatabaseManager;
import com.gmail.nossr50.database.FlatfileDatabaseManager;
import com.gmail.nossr50.database.SQLDatabaseManager;
public class McrankCommandAsyncTask extends BukkitRunnable {
private final String playerName;

View File

@@ -31,8 +31,8 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || (player != null && !Permissions.skillEnabled(player, skill))) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (player != null && !Permissions.skillEnabled(player, skill)) {
continue;
}

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.runnables.items;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -29,27 +28,31 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
private void checkChimaeraWingTeleport() {
Player player = mcMMOPlayer.getPlayer();
Location previousLocation = mcMMOPlayer.getTeleportCommenceLocation();
Location newLocation = mcMMOPlayer.getPlayer().getLocation();
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
ItemStack inHand = player.getItemInHand();
mcMMOPlayer.setTeleportCommenceLocation(null);
if (newLocation.distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(0), 1)) {
player.sendMessage(ChatColor.DARK_RED + "Teleportation canceled!"); //TODO Locale!
if (player.getLocation().distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(0), 1)) {
player.sendMessage(LocaleLoader.getString("Teleport.Cancelled"));
return;
}
ItemStack inHand = player.getItemInHand();
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;
}
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)) {
player.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, player)));
return;
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;
}
}
ChimaeraWing.chimaeraExecuteTeleport();

View File

@@ -1,10 +1,10 @@
package com.gmail.nossr50.runnables.items;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@@ -38,21 +38,25 @@ public class TeleportationWarmup extends BukkitRunnable {
mcMMOPlayer.setTeleportCommenceLocation(null);
if (!PartyManager.inSameParty(teleportingPlayer, targetPlayer)) {
if (!mcMMO.getPartyManager().inSameParty(teleportingPlayer, targetPlayer)) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetPlayer.getName()));
return;
}
if (newLocation.distanceSquared(previousLocation) > 1.0) {
teleportingPlayer.sendMessage(ChatColor.DARK_RED + "Teleportation canceled!"); //TODO Locale!
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Cancelled"));
return;
}
int recentlyhurt_cooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
if (!SkillUtils.cooldownOver(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, teleportingPlayer)) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Item.Injured.Wait", SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, recentlyhurt_cooldown, teleportingPlayer)));
return;
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, teleportingPlayer);
if (timeRemaining > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Item.Injured.Wait", timeRemaining));
return;
}
}
PtpCommand.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);

View File

@@ -27,7 +27,7 @@ public class PartyAutoKickTask extends BukkitRunnable {
long currentTime = System.currentTimeMillis();
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();
for (String memberName : party.getMembers()) {
@@ -44,7 +44,7 @@ public class PartyAutoKickTask extends BukkitRunnable {
}
for (Entry<OfflinePlayer, Party> entry : toRemove.entrySet()) {
PartyManager.removeFromParty(entry.getKey(), entry.getValue());
mcMMO.getPartyManager().removeFromParty(entry.getKey(), entry.getValue());
}
}
}

View File

@@ -17,7 +17,11 @@ public class ScoreboardChangeTask extends BukkitRunnable {
@Override
public void run() {
player.setScoreboard(oldScoreboard);
if (player.isOnline()) {
player.setScoreboard(oldScoreboard);
ScoreboardManager.enablePowerLevelDisplay(player);
}
ScoreboardManager.clearPendingTask(player.getName());
}
}

View File

@@ -7,8 +7,11 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class AbilityDisableTask extends BukkitRunnable {
@@ -44,6 +47,9 @@ public class AbilityDisableTask extends BukkitRunnable {
break;
}
McMMOPlayerAbilityDeactivateEvent event = new McMMOPlayerAbilityDeactivateEvent(player, SkillType.byAbility(ability));
mcMMO.p.getServer().getPluginManager().callEvent(event);
mcMMOPlayer.setAbilityMode(ability, false);
mcMMOPlayer.setAbilityInformed(ability, false);
@@ -54,6 +60,6 @@ public class AbilityDisableTask extends BukkitRunnable {
}
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);
}
}

View File

@@ -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();
}
}
}

View File

@@ -14,7 +14,6 @@ public final class Acrobatics {
public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel();
public static int gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold();
public static int gracefulRollSuccessModifier = AdvancedConfig.getInstance().getGracefulRollSuccessModifer();
public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax();
public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier();

View File

@@ -81,7 +81,7 @@ public class AcrobaticsManager extends SkillManager {
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"));
applyXpGain(damage * Acrobatics.rollXpModifier);
@@ -103,7 +103,7 @@ public class AcrobaticsManager extends SkillManager {
private int gracefulRollCheck(int damage) {
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"));
applyXpGain(damage * Acrobatics.rollXpModifier);
@@ -116,8 +116,8 @@ public class AcrobaticsManager extends SkillManager {
return damage;
}
private boolean isSuccessfulRoll(double maxChance, int maxLevel, int successModifier) {
return ((maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) * successModifier) > Misc.getRandom().nextInt(activationChance);
private boolean isSuccessfulRoll(double maxChance, int maxLevel) {
return (maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) > Misc.getRandom().nextInt(activationChance);
}
private boolean isFatal(int damage) {

View File

@@ -4,10 +4,12 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
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();
}
}

View File

@@ -1,12 +1,13 @@
package com.gmail.nossr50.skills.archery;
import org.bukkit.Location;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
@@ -30,9 +31,7 @@ public class ArcheryManager extends SkillManager {
}
public boolean canTrackArrows() {
Player player = getPlayer();
return !(player.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(player);
return Permissions.arrowRetrieval(getPlayer());
}
/**
@@ -40,20 +39,15 @@ public class ArcheryManager extends SkillManager {
*
* @param target The {@link LivingEntity} damaged by the arrow
*/
public void distanceXpBonus(LivingEntity target) {
Player player = getPlayer();
Location shooterLocation = player.getLocation();
public void distanceXpBonus(LivingEntity target, Entity damager) {
Location firedLocation = Archery.stringToLocation(damager.getMetadata(mcMMO.arrowDistanceKey).get(0).asString());
Location targetLocation = target.getLocation();
if (shooterLocation.getWorld() != targetLocation.getWorld()) {
if (firedLocation.getWorld() != targetLocation.getWorld()) {
return;
}
// Cap distance at 100^2 to prevent teleport exploit.
// TODO: Better way to handle this would be great...
double squaredDistance = Math.min(shooterLocation.distanceSquared(targetLocation), 10000);
applyXpGain((int) (squaredDistance * Archery.DISTANCE_XP_MULTIPLIER));
applyXpGain((int) (firedLocation.distanceSquared(targetLocation) * Archery.DISTANCE_XP_MULTIPLIER));
}
/**

View File

@@ -19,44 +19,42 @@ public class ChildConfig extends AutoUpdateConfigLoader {
protected void loadKeys() {
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml")));
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
plugin.debug("Finding parents of " + skill.name());
for (SkillType skill : SkillType.childSkills()) {
plugin.debug("Finding parents of " + skill.name());
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
boolean useDefaults = false; // If we had an error we back out and use defaults
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
boolean useDefaults = false; // If we had an error we back out and use defaults
for (String name : parentNames) {
try {
SkillType parentSkill = Enum.valueOf(SkillType.class, name.toUpperCase());
FamilyTree.enforceNotChildSkill(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;
}
for (String name : parentNames) {
try {
SkillType parentSkill = SkillType.valueOf(name.toUpperCase());
FamilyTree.enforceNotChildSkill(parentSkill);
parentSkills.add(parentSkill);
}
if (useDefaults) {
parentSkills.clear();
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
/* 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()));
}
catch (IllegalArgumentException ex) {
plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
useDefaults = true;
break;
}
}
// Register them
for (SkillType parentSkill : parentSkills) {
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
FamilyTree.registerParent(skill, parentSkill);
if (useDefaults) {
parentSkills.clear();
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
/* 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();

View File

@@ -1,7 +1,10 @@
package com.gmail.nossr50.skills.fishing;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
@@ -49,6 +52,8 @@ public final class Fishing {
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 fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;

View File

@@ -2,11 +2,23 @@ package com.gmail.nossr50.skills.fishing;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Location;
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.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fish;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
@@ -14,8 +26,11 @@ import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Skeleton;
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 com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
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.treasure.FishingTreasure;
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.runnables.skills.KrakenAttackTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
import com.gmail.nossr50.util.ItemUtils;
@@ -33,6 +53,11 @@ import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class FishingManager extends SkillManager {
private final long FISHING_COOLDOWN_SECONDS = 1000L;
private int fishingTries = 0;
private long fishingTimestamp = 0L;
public FishingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.FISHING);
}
@@ -45,6 +70,111 @@ public class FishingManager extends SkillManager {
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
*
@@ -90,8 +220,38 @@ public class FishingManager extends SkillManager {
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) {
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();
ItemStack treasureDrop = treasure.getDrop().clone(); // Not cloning is bad, m'kay?
if (Permissions.magicHunter(player) && ItemUtils.isEnchantable(treasureDrop) && handleMagicHunter(treasureDrop)) {
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
McMMOPlayerFishingTreasureEvent event;
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
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
fishingCatch.setItemStack(treasureDrop);
if (treasureDrop != null) {
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);
@@ -142,6 +332,8 @@ public class FishingManager extends SkillManager {
* @param mob The {@link LivingEntity} affected by the ability
*/
public void shakeCheck(LivingEntity target) {
fishingTries--; // Because autoclicking to shake is OK.
if (getShakeProbability() > Misc.getRandom().nextInt(getActivationChance())) {
List<ShakeTreasure> possibleDrops = Fishing.findPossibleDrops(target);
@@ -194,6 +386,14 @@ public class FishingManager extends SkillManager {
break;
}
McMMOPlayerShakeEvent event = new McMMOPlayerShakeEvent(getPlayer(), drop);
drop = event.getDrop();
if (event.isCancelled() || drop == null) {
return;
}
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.
}
@@ -242,7 +442,7 @@ public class FishingManager extends SkillManager {
* @param treasureDrop The {@link ItemStack} to enchant
* @return true if the item has been enchanted
*/
private boolean handleMagicHunter(ItemStack treasureDrop) {
private Map<Enchantment, Integer> handleMagicHunter(ItemStack treasureDrop) {
Player player = getPlayer();
int activationChance = this.activationChance;
@@ -250,8 +450,37 @@ public class FishingManager extends SkillManager {
activationChance *= Fishing.STORM_MODIFIER;
}
Map<Enchantment, Integer> enchants = new HashMap<Enchantment, Integer>();
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>();
@@ -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
Collections.shuffle(possibleEnchantments, Misc.getRandom());
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;
Fishing.ENCHANTABLE_CACHE.put(dropType, possibleEnchantments);
return possibleEnchantments;
}
/**

View File

@@ -27,7 +27,7 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class MiningManager extends SkillManager{
public class MiningManager extends SkillManager {
public MiningManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.MINING);
}
@@ -109,7 +109,7 @@ public class MiningManager extends SkillManager{
getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
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) {
for (BlockState blockState : debris) {
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;
int cooldown = AbilityType.BLAST_MINING.getCooldown();
int timeRemaining = SkillUtils.calculateTimeLeft(oldTime, cooldown, player);
if (!SkillUtils.cooldownOver(oldTime, cooldown, player)) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", SkillUtils.calculateTimeLeft(oldTime, cooldown, player)));
if (timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
return false;
}

View File

@@ -40,6 +40,30 @@ public class Repair {
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.
*
@@ -99,30 +123,6 @@ public class Repair {
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) {
if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) {
return Material.DIAMOND;

View File

@@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.repair;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@@ -11,8 +10,6 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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.config.Config;
@@ -27,6 +24,7 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.spout.SpoutUtils;
public class RepairManager extends SkillManager {
public RepairManager(McMMOPlayer mcMMOPlayer) {
@@ -45,16 +43,8 @@ public class RepairManager extends SkillManager {
return;
}
if (mcMMO.spoutEnabled) {
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));
}
if (mcMMO.isSpoutEnabled()) {
SpoutUtils.sendRepairNotifications(player, anvilId);
}
else {
player.sendMessage(Repair.getAnvilMessage(anvilId));
@@ -205,7 +195,7 @@ public class RepairManager extends SkillManager {
Player player = getPlayer();
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
if ((((LastUse + 3) * Misc.TIME_CONVERSION_FACTOR) >= System.currentTimeMillis()) || !Config.getInstance().getRepairConfirmRequired()) {
@@ -219,11 +209,11 @@ public class RepairManager extends SkillManager {
mcMMOPlayer.actualizeLastAnvilUse(anvilId);
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) {
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;
}

View File

@@ -199,7 +199,7 @@ public class TamingManager extends SkillManager {
}
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);
}

View File

@@ -43,7 +43,7 @@ public class Unarmed {
ItemStack addStack = itemstack.clone();
if (dropAmount + itemAmount <= itemMax) {
if (dropAmount + itemAmount <= itemMax) {
drop.remove();
addStack.setAmount(dropAmount + itemAmount);
inventory.setItem(nextSlot, addStack);

View File

@@ -7,7 +7,7 @@ import org.bukkit.material.CocoaPlant;
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
import org.bukkit.material.NetherWarts;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.skills.repair.Repair;
public final class BlockUtils {
private BlockUtils() {}
@@ -19,59 +19,7 @@ public final class BlockUtils {
* @return true if the block awards XP, false otherwise
*/
public static boolean shouldBeWatched(BlockState blockState) {
switch (blockState.getType()) {
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;
}
return affectedByGigaDrillBreaker(blockState) || affectedByGreenTerra(blockState) || affectedBySuperBreaker(blockState) || isLog(blockState);
}
/**
@@ -111,17 +59,7 @@ public final class BlockUtils {
return false;
default:
int blockId = blockState.getTypeId();
if (blockId == Config.getInstance().getRepairAnvilId() || blockId == Config.getInstance().getSalvageAnvilId()) {
return false;
}
if (ModUtils.isCustomAbilityBlock(blockState)) {
return false;
}
return true;
return !isMcMMOAnvil(blockState) && !ModUtils.isCustomAbilityBlock(blockState);
}
}
@@ -214,26 +152,17 @@ public final class BlockUtils {
*/
public static Boolean affectedBySuperBreaker(BlockState blockState) {
switch (blockState.getType()) {
case COAL_ORE:
case DIAMOND_ORE:
case ENDER_STONE:
case GLOWING_REDSTONE_ORE:
case GLOWSTONE:
case GOLD_ORE:
case IRON_ORE:
case LAPIS_ORE:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case QUARTZ_ORE:
case REDSTONE_ORE:
case SANDSTONE:
case STONE:
case EMERALD_ORE:
return true;
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
*/
public static boolean affectedByTreeFeller(BlockState blockState) {
switch (blockState.getType()) {
case LOG:
case LEAVES:
case HUGE_MUSHROOM_1:
case HUGE_MUSHROOM_2:
return true;
default:
return ModUtils.isCustomWoodcuttingBlock(blockState);
}
return isLog(blockState) || isLeaves(blockState);
}
/**
@@ -379,4 +299,16 @@ public final class BlockUtils {
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;
}
}

View File

@@ -35,9 +35,13 @@ public final class ChimaeraWing {
* @param player Player whose item usage to check
*/
public static void activationCheck(Player player) {
if (!Config.getInstance().getChimaeraEnabled()) {
return;
}
ItemStack inHand = player.getItemInHand();
if (!Config.getInstance().getChimaeraEnabled() || !ItemUtils.isChimaeraWing(inHand)) {
if (!ItemUtils.isChimaeraWing(inHand)) {
return;
}
@@ -48,36 +52,48 @@ public final class ChimaeraWing {
mcMMOPlayer = UserManager.getPlayer(player);
location = player.getLocation();
int amount = inHand.getAmount();
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
long lastTeleport = mcMMOPlayer.getLastTeleport();
if (mcMMOPlayer.getTeleportCommenceLocation() != null) {
return;
}
if (Config.getInstance().getChimaeraCooldown() > 0 && !SkillUtils.cooldownOver(lastTeleport * Misc.TIME_CONVERSION_FACTOR, Config.getInstance().getChimaeraCooldown(), player)) {
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;
}
int amount = inHand.getAmount();
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;
}
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 (location.getY() < player.getWorld().getHighestBlockYAt(location)) {
player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost())));
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
player.updateInventory();
player.setVelocity(new Vector(0, 0.5D, 0));
CombatUtils.dealDamage(player, Misc.getRandom().nextInt(player.getHealth() - 10));
mcMMOPlayer.actualizeLastTeleport();
@@ -90,7 +106,7 @@ public final class ChimaeraWing {
long warmup = Config.getInstance().getChimaeraWarmup();
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);
}
else {
@@ -115,6 +131,7 @@ public final class ChimaeraWing {
}
player.setItemInHand(new ItemStack(getChimaeraWing(player.getItemInHand().getAmount() - Config.getInstance().getChimaeraUseCost())));
player.updateInventory();
UserManager.getPlayer(player).actualizeLastTeleport();
if (Config.getInstance().getStatsTrackingEnabled()) {
MetricsManager.chimeraWingUsed();
@@ -128,11 +145,11 @@ public final class ChimaeraWing {
ItemStack itemStack = new ItemStack(ingredient, amount);
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>();
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);
itemStack.setItemMeta(itemMeta);

View File

@@ -21,11 +21,7 @@ public final class HardcoreManager {
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
int totalLost = 0;
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
int playerSkillLevel = playerProfile.getSkillLevel(skillType);
if (playerSkillLevel <= 0) {
@@ -52,11 +48,7 @@ public final class HardcoreManager {
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
int totalStolen = 0;
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
int killerSkillLevel = killerProfile.getSkillLevel(skillType);
int victimSkillLevel = victimProfile.getSkillLevel(skillType);

View File

@@ -1,10 +1,7 @@
package com.gmail.nossr50.util;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
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.CustomToolConfig;
import com.gmail.nossr50.config.party.ItemWeightConfig;
import com.gmail.nossr50.locale.LocaleLoader;
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.
*
* @param is Item to check
* @param item Item to check
* @return true if the item is a sword, false otherwise
*/
public static boolean isSword(ItemStack is) {
switch (is.getType()) {
public static boolean isSword(ItemStack item) {
switch (item.getType()) {
case DIAMOND_SWORD:
case GOLD_SWORD:
case IRON_SWORD:
@@ -36,26 +30,18 @@ public class ItemUtils {
return true;
default:
if (customToolsEnabled && CustomToolConfig.getInstance().customSwordIDs.contains(is.getTypeId())) {
return true;
}
else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutSwords.contains(is)) {
return true;
}
else {
return false;
}
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customSwordIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutSwords.contains(item));
}
}
/**
* 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
*/
public static boolean isHoe(ItemStack is) {
switch (is.getType()) {
public static boolean isHoe(ItemStack item) {
switch (item.getType()) {
case DIAMOND_HOE:
case GOLD_HOE:
case IRON_HOE:
@@ -64,26 +50,18 @@ public class ItemUtils {
return true;
default:
if (customToolsEnabled && CustomToolConfig.getInstance().customHoeIDs.contains(is.getTypeId())) {
return true;
}
else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutHoes.contains(is)) {
return true;
}
else {
return false;
}
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customHoeIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutHoes.contains(item));
}
}
/**
* 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
*/
public static boolean isShovel(ItemStack is) {
switch (is.getType()) {
public static boolean isShovel(ItemStack item) {
switch (item.getType()) {
case DIAMOND_SPADE:
case GOLD_SPADE:
case IRON_SPADE:
@@ -92,26 +70,18 @@ public class ItemUtils {
return true;
default:
if (customToolsEnabled && CustomToolConfig.getInstance().customShovelIDs.contains(is.getTypeId())) {
return true;
}
else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutShovels.contains(is)) {
return true;
}
else {
return false;
}
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customShovelIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutShovels.contains(item));
}
}
/**
* 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
*/
public static boolean isAxe(ItemStack is) {
switch (is.getType()) {
public static boolean isAxe(ItemStack item) {
switch (item.getType()) {
case DIAMOND_AXE:
case GOLD_AXE:
case IRON_AXE:
@@ -120,26 +90,18 @@ public class ItemUtils {
return true;
default:
if (customToolsEnabled && CustomToolConfig.getInstance().customAxeIDs.contains(is.getTypeId())) {
return true;
}
else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutAxes.contains(is)) {
return true;
}
else {
return false;
}
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customAxeIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutAxes.contains(item));
}
}
/**
* 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
*/
public static boolean isPickaxe(ItemStack is) {
switch (is.getType()) {
public static boolean isPickaxe(ItemStack item) {
switch (item.getType()) {
case DIAMOND_PICKAXE:
case GOLD_PICKAXE:
case IRON_PICKAXE:
@@ -148,138 +110,118 @@ public class ItemUtils {
return true;
default:
if (customToolsEnabled && CustomToolConfig.getInstance().customPickaxeIDs.contains(is.getTypeId())) {
return true;
}
else if (mcMMO.spoutEnabled && SpoutToolsAPI.spoutPickaxes.contains(is)) {
return true;
}
else {
return false;
}
return (Config.getInstance().getToolModsEnabled() && CustomToolConfig.getInstance().customPickaxeIDs.contains(item.getTypeId())) || (mcMMO.isSpoutEnabled() && SpoutToolsAPI.spoutPickaxes.contains(item));
}
}
/**
* 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
*/
public static boolean isHelmet(ItemStack is) {
switch (is.getType()) {
public static boolean isHelmet(ItemStack item) {
switch (item.getType()) {
case DIAMOND_HELMET:
case GOLD_HELMET:
case IRON_HELMET:
case CHAINMAIL_HELMET:
case LEATHER_HELMET:
return true;
default:
if (customArmorEnabled && CustomArmorConfig.getInstance().customHelmetIDs.contains(is.getTypeId())) {
return true;
}
return false;
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customHelmetIDs.contains(item.getTypeId());
}
}
/**
* 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
*/
public static boolean isChestplate(ItemStack is) {
switch (is.getType()) {
public static boolean isChestplate(ItemStack item) {
switch (item.getType()) {
case DIAMOND_CHESTPLATE:
case GOLD_CHESTPLATE:
case IRON_CHESTPLATE:
case CHAINMAIL_CHESTPLATE:
case LEATHER_CHESTPLATE:
return true;
default:
if (customArmorEnabled && CustomArmorConfig.getInstance().customChestplateIDs.contains(is.getTypeId())) {
return true;
}
return false;
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customChestplateIDs.contains(item.getTypeId());
}
}
/**
* 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
*/
public static boolean isLeggings(ItemStack is) {
switch (is.getType()) {
public static boolean isLeggings(ItemStack item) {
switch (item.getType()) {
case DIAMOND_LEGGINGS:
case GOLD_LEGGINGS:
case IRON_LEGGINGS:
case CHAINMAIL_LEGGINGS:
case LEATHER_LEGGINGS:
return true;
default:
if (customArmorEnabled && CustomArmorConfig.getInstance().customLeggingIDs.contains(is.getTypeId())) {
return true;
}
return false;
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customLeggingIDs.contains(item.getTypeId());
}
}
/**
* 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
*/
public static boolean isBoots(ItemStack is) {
switch (is.getType()) {
public static boolean isBoots(ItemStack item) {
switch (item.getType()) {
case DIAMOND_BOOTS:
case GOLD_BOOTS:
case IRON_BOOTS:
case CHAINMAIL_BOOTS:
case LEATHER_BOOTS:
return true;
default:
if (customArmorEnabled && CustomArmorConfig.getInstance().customBootIDs.contains(is.getTypeId())) {
return true;
}
return false;
return Config.getInstance().getArmorModsEnabled() && CustomArmorConfig.getInstance().customBootIDs.contains(item.getTypeId());
}
}
/**
* 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
*/
public static boolean isArmor(ItemStack is) {
return isHelmet(is) || isChestplate(is) || isLeggings(is) || isBoots(is);
public static boolean isArmor(ItemStack item) {
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
*/
public static boolean isMinecraftArmor(ItemStack is) {
return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is);
public static boolean isMinecraftArmor(ItemStack item) {
return isLeatherArmor(item) || isGoldArmor(item) || isIronArmor(item) || isDiamondArmor(item) || isChainmailArmor(item);
}
/**
* 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
*/
public static boolean isLeatherArmor(ItemStack is) {
switch (is.getType()) {
public static boolean isLeatherArmor(ItemStack item) {
switch (item.getType()) {
case LEATHER_BOOTS:
case LEATHER_CHESTPLATE:
case LEATHER_HELMET:
@@ -294,11 +236,11 @@ public class ItemUtils {
/**
* 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
*/
public static boolean isGoldArmor(ItemStack is) {
switch (is.getType()) {
public static boolean isGoldArmor(ItemStack item) {
switch (item.getType()) {
case GOLD_BOOTS:
case GOLD_CHESTPLATE:
case GOLD_HELMET:
@@ -313,11 +255,11 @@ public class ItemUtils {
/**
* 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
*/
public static boolean isIronArmor(ItemStack is) {
switch (is.getType()) {
public static boolean isIronArmor(ItemStack item) {
switch (item.getType()) {
case IRON_BOOTS:
case IRON_CHESTPLATE:
case IRON_HELMET:
@@ -332,11 +274,11 @@ public class ItemUtils {
/**
* 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
*/
public static boolean isDiamondArmor(ItemStack is) {
switch (is.getType()) {
public static boolean isDiamondArmor(ItemStack item) {
switch (item.getType()) {
case DIAMOND_BOOTS:
case DIAMOND_CHESTPLATE:
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
*/
public static boolean isMinecraftTool(ItemStack is) {
return isStoneTool(is) || isWoodTool(is) || isGoldTool(is) || isIronTool(is) || isDiamondTool(is) || isStringTool(is);
public static boolean isMinecraftTool(ItemStack item) {
return isStoneTool(item) || isWoodTool(item) || isGoldTool(item) || isIronTool(item) || isDiamondTool(item) || isStringTool(item);
}
/**
* 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
*/
public static boolean isStoneTool(ItemStack is) {
switch (is.getType()) {
public static boolean isStoneTool(ItemStack item) {
switch (item.getType()) {
case STONE_AXE:
case STONE_HOE:
case STONE_PICKAXE:
@@ -381,11 +342,11 @@ public class ItemUtils {
/**
* 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
*/
public static boolean isWoodTool(ItemStack is) {
switch (is.getType()) {
public static boolean isWoodTool(ItemStack item) {
switch (item.getType()) {
case WOOD_AXE:
case WOOD_HOE:
case WOOD_PICKAXE:
@@ -401,11 +362,11 @@ public class ItemUtils {
/**
* 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
*/
public static boolean isStringTool(ItemStack is) {
switch (is.getType()) {
public static boolean isStringTool(ItemStack item) {
switch (item.getType()) {
case BOW:
case CARROT_STICK:
case FISHING_ROD:
@@ -419,11 +380,11 @@ public class ItemUtils {
/**
* 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
*/
public static boolean isGoldTool(ItemStack is) {
switch (is.getType()) {
public static boolean isGoldTool(ItemStack item) {
switch (item.getType()) {
case GOLD_AXE:
case GOLD_HOE:
case GOLD_PICKAXE:
@@ -439,11 +400,11 @@ public class ItemUtils {
/**
* 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
*/
public static boolean isIronTool(ItemStack is) {
switch (is.getType()) {
public static boolean isIronTool(ItemStack item) {
switch (item.getType()) {
case BUCKET:
case FLINT_AND_STEEL:
case IRON_AXE:
@@ -462,11 +423,11 @@ public class ItemUtils {
/**
* 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
*/
public static boolean isDiamondTool(ItemStack is) {
switch (is.getType()) {
public static boolean isDiamondTool(ItemStack item) {
switch (item.getType()) {
case DIAMOND_AXE:
case DIAMOND_HOE:
case DIAMOND_PICKAXE:
@@ -482,16 +443,25 @@ public class ItemUtils {
/**
* 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
*/
public static boolean isEnchantable(ItemStack is) {
Material type = is.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;
public static boolean isEnchantable(ItemStack item) {
switch (item.getType()) {
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) {
switch (itemStack.getType()) {
public static boolean isSmeltable(ItemStack item) {
switch (item.getType()) {
case COAL_ORE:
case DIAMOND_ORE:
case GLOWING_REDSTONE_ORE:
@@ -500,6 +470,7 @@ public class ItemUtils {
case LAPIS_ORE:
case REDSTONE_ORE:
case EMERALD_ORE:
case QUARTZ_ORE:
return true;
default:
@@ -507,22 +478,19 @@ public class ItemUtils {
}
}
public static boolean isSmelted(ItemStack itemStack) {
switch (itemStack.getType()) {
public static boolean isSmelted(ItemStack item) {
switch (item.getType()) {
case COAL:
case DIAMOND:
case REDSTONE:
case GOLD_INGOT:
case IRON_INGOT:
case EMERALD:
case QUARTZ:
return true;
case INK_SACK:
if (itemStack.getData().getData() == DyeColor.BLUE.getDyeData()) {
return true;
}
return false;
return item.getData().getData() == DyeColor.BLUE.getDyeData();
default:
return false;
@@ -535,18 +503,18 @@ public class ItemUtils {
* @param item Item that will get shared
* @return True if the item can be shared.
*/
public static boolean isShareable(ItemStack is) {
return isMiningDrop(is) || isWoodcuttingDrop(is) || isMobDrop(is) || isHerbalismDrop(is) || isMiscDrop(is);
public static boolean isShareable(ItemStack item) {
return isMiningDrop(item) || isWoodcuttingDrop(item) || isMobDrop(item) || isHerbalismDrop(item) || isMiscDrop(item);
}
/**
* 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
*/
public static boolean isMiningDrop(ItemStack is) {
switch (is.getType()) {
public static boolean isMiningDrop(ItemStack item) {
switch (item.getType()) {
case COAL:
case COAL_ORE:
case DIAMOND:
@@ -556,17 +524,15 @@ public class ItemUtils {
case GOLD_ORE:
case IRON_ORE:
case LAPIS_ORE:
case REDSTONE_ORE:
case REDSTONE_ORE: // Should we also have Glowing Redstone Ore here?
case REDSTONE:
case GLOWSTONE_DUST:
case GLOWSTONE_DUST: // Should we also have Glowstone here?
case QUARTZ:
case QUARTZ_ORE:
return true;
case INK_SACK:
if (is.getData().getData() == DyeColor.BLUE.getDyeData()) {
return true;
}
return false;
return item.getData().getData() == DyeColor.BLUE.getDyeData();
default:
return false;
@@ -576,11 +542,11 @@ public class ItemUtils {
/**
* 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
*/
public static boolean isHerbalismDrop(ItemStack is) {
switch (is.getType()) {
public static boolean isHerbalismDrop(ItemStack item) {
switch (item.getType()) {
case WHEAT:
case SEEDS:
case CARROT_ITEM:
@@ -601,7 +567,7 @@ public class ItemUtils {
return true;
case INK_SACK:
return is.getData().getData() == DyeColor.BROWN.getDyeData();
return item.getData().getData() == DyeColor.BROWN.getDyeData();
default:
return false;
@@ -611,11 +577,11 @@ public class ItemUtils {
/**
* 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
*/
public static boolean isMobDrop(ItemStack is) {
switch (is.getType()) {
public static boolean isMobDrop(ItemStack item) {
switch (item.getType()) {
case STRING:
case FEATHER:
case RAW_CHICKEN:
@@ -626,7 +592,7 @@ public class ItemUtils {
case PORK:
case GRILLED_PORK:
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 SNOW_BALL:
case BLAZE_ROD:
@@ -639,7 +605,7 @@ public class ItemUtils {
case ARROW:
case SLIME_BALL:
case NETHER_STAR:
case COAL:
case COAL: // Not sure we should include this, as it will also trigger when mining
case ROTTEN_FLESH:
case GOLD_NUGGET:
case EGG:
@@ -653,11 +619,11 @@ public class ItemUtils {
/**
* 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
*/
public static boolean isWoodcuttingDrop(ItemStack is) {
switch (is.getType()) {
public static boolean isWoodcuttingDrop(ItemStack item) {
switch (item.getType()) {
case LOG:
case LEAVES:
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
*
* @param is Item to check
* @param item Item to check
* @return true if the item is a miscellaneous drop, false otherwise
*/
public static boolean isMiscDrop(ItemStack is) {
return ItemWeightConfig.getInstance().getMiscItems().contains(is.getType());
public static boolean isMiscDrop(ItemStack item) {
return ItemWeightConfig.getInstance().getMiscItems().contains(item.getType());
}
public static boolean isMcMMOItem(ItemStack is) {
if (!is.hasItemMeta()) {
public static boolean isMcMMOItem(ItemStack item) {
if (!item.hasItemMeta()) {
return false;
}
ItemMeta itemMeta = is.getItemMeta();
if (itemMeta.hasLore()) {
List<String> itemLore = itemMeta.getLore();
if (itemLore.contains("mcMMO Item")) {
return true;
}
}
return false;
ItemMeta itemMeta = item.getItemMeta();
return itemMeta.hasLore() && itemMeta.getLore().contains("mcMMO Item");
}
public static boolean isChimaeraWing(ItemStack is) {
if (!isMcMMOItem(is)) {
public static boolean isChimaeraWing(ItemStack item) {
if (!isMcMMOItem(item)) {
return false;
}
ItemMeta itemMeta = is.getItemMeta();
if (itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + "Chimaera Wing")) { //TODO Get localized name
return true;
}
return false;
ItemMeta itemMeta = item.getItemMeta();
return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name"));
}
}

View File

@@ -1,17 +1,17 @@
package com.gmail.nossr50.util;
import java.util.Collection;
import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
@@ -20,7 +20,6 @@ import com.gmail.nossr50.util.spout.SpoutUtils;
public final class Misc {
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 TIME_CONVERSION_FACTOR = 1000;
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 BAT_VOLUME = 1.0F;
public static final float BAT_PITCH = 0.6F;
public static final float GHAST_VOLUME = 1.0F;
private Misc() {};
@@ -43,8 +43,12 @@ public final class Misc {
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) {
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;
}
if (first.distanceSquared(second) < (maxDistance * maxDistance)) {
return true;
}
return first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0;
}
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
*/
public static void dropItem(Location location, ItemStack itemStack) {
if (itemStack.getType() == Material.AIR) {
return;
}
@@ -161,12 +166,7 @@ public final class Misc {
return;
}
Item newItem = location.getWorld().dropItemNaturally(location, itemStack);
ItemStack cloned = itemStack.clone();
cloned.setAmount(newItem.getItemStack().getAmount());
newItem.setItemStack(cloned);
location.getWorld().dropItemNaturally(location, itemStack);
}
public static void profileCleanup(String playerName) {
@@ -185,7 +185,7 @@ public final class Misc {
if (player.isOnline()) {
UserManager.addUser(player);
if (mcMMO.spoutEnabled) {
if (mcMMO.isSpoutEnabled()) {
SpoutUtils.reloadSpoutPlayer(player);
}
}
@@ -193,8 +193,12 @@ public final class Misc {
}
public static void resendChunkRadiusAt(Player player, int radius) {
for (int x = player.getLocation().getChunk().getX() - radius; x < player.getLocation().getChunk().getX() + radius; x++) {
for (int z = player.getLocation().getChunk().getZ() - radius; z < player.getLocation().getChunk().getZ() + radius; z++) {
Chunk chunk = player.getLocation().getChunk();
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);
}
}

View File

@@ -8,6 +8,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
@@ -34,9 +35,9 @@ public final class MobHealthbarUtils {
/**
* Handle the creation of mob healthbars.
*
* @param profile The
* @param target
* @param damage
* @param player the attacking player
* @param target the targetted entity
* @param damage damage done by the attack triggering this
*/
public static void handleMobHealthbars(Player player, LivingEntity target, int damage) {
if (!Permissions.mobHealthDisplay(player)) {
@@ -45,11 +46,23 @@ public final class MobHealthbarUtils {
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
if (profile.getMobHealthbarType() == null) {
profile.setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
}
if (profile.getMobHealthbarType() == MobHealthbarType.DISABLED) {
return;
}
String oldName = target.getCustomName();
if (oldName == null) {
oldName = "";
}
else if (oldName.equalsIgnoreCase(AdvancedConfig.getInstance().getKrakenName())) {
return;
}
boolean oldNameVisible = target.isCustomNameVisible();
String newName = createHealthDisplay(profile, target, damage);
@@ -59,10 +72,6 @@ public final class MobHealthbarUtils {
int displayTime = Config.getInstance().getMobHealthbarTime();
if (displayTime != -1) {
if (oldName == null) {
oldName = "";
}
boolean updateName = !ChatColor.stripColor(oldName).equalsIgnoreCase(ChatColor.stripColor(newName));
if (updateName) {
@@ -123,7 +132,7 @@ public final class MobHealthbarUtils {
return null;
}
int coloredDisplay = (int) (fullDisplay * (healthPercentage / 100.0D));
int coloredDisplay = (int) Math.ceil(fullDisplay * (healthPercentage / 100.0D));
int grayDisplay = fullDisplay - coloredDisplay;
String healthbar = color + "";
@@ -140,5 +149,4 @@ public final class MobHealthbarUtils {
return healthbar;
}
}

View File

@@ -27,6 +27,7 @@ public final class Permissions {
/* BYPASS */
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 krakenBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.kraken"); }
/* CHAT */
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 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 mcabilityOthers(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability.others")); }
@@ -142,6 +146,7 @@ public final class Permissions {
/* FISHING */
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 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 masterAngler(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.masterangler"); }
public static boolean shake(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.fishing.shakemob"); }

View File

@@ -11,11 +11,7 @@ public class StringUtils {
* @return the capitalized string
*/
public static String getCapitalized(String target) {
String firstLetter = target.substring(0, 1);
String remainder = target.substring(1);
String capitalized = firstLetter.toUpperCase() + remainder.toLowerCase();
return capitalized;
return target.substring(0, 1).toUpperCase() + target.substring(1).toLowerCase();
}
/**
@@ -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
*
@@ -131,5 +111,4 @@ public class StringUtils {
return false;
}
}
}

View File

@@ -6,11 +6,13 @@ import java.util.List;
import org.bukkit.command.PluginCommand;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.KrakenCommand;
import com.gmail.nossr50.commands.McabilityCommand;
import com.gmail.nossr50.commands.McgodCommand;
import com.gmail.nossr50.commands.McmmoCommand;
import com.gmail.nossr50.commands.McnotifyCommand;
import com.gmail.nossr50.commands.McrefreshCommand;
import com.gmail.nossr50.commands.McscoreboardCommand;
import com.gmail.nossr50.commands.MobhealthCommand;
import com.gmail.nossr50.commands.XprateCommand;
import com.gmail.nossr50.commands.chat.AdminChatCommand;
@@ -56,7 +58,7 @@ public final class CommandRegistrationManager {
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
public static void registerSkillCommands() {
private static void registerSkillCommands() {
for (SkillType skill : SkillType.values()) {
String commandName = skill.toString().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");
command.setDescription(LocaleLoader.getString("Commands.Description.addlevels"));
command.setPermission("mcmmo.commands.addlevels;mcmmo.commands.addlevels.others");
@@ -138,7 +140,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new AddlevelsCommand());
}
public static void registerAddxpCommand() {
private static void registerAddxpCommand() {
PluginCommand command = mcMMO.p.getCommand("addxp");
command.setDescription(LocaleLoader.getString("Commands.Description.addxp"));
command.setPermission("mcmmo.commands.addxp;mcmmo.commands.addxp.others");
@@ -147,7 +149,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new AddxpCommand());
}
public static void registerMcgodCommand() {
private static void registerMcgodCommand() {
PluginCommand command = mcMMO.p.getCommand("mcgod");
command.setDescription(LocaleLoader.getString("Commands.Description.mcgod"));
command.setPermission("mcmmo.commands.mcgod;mcmmo.commands.mcgod.others");
@@ -156,7 +158,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McgodCommand());
}
public static void registerMcrefreshCommand() {
private static void registerMcrefreshCommand() {
PluginCommand command = mcMMO.p.getCommand("mcrefresh");
command.setDescription(LocaleLoader.getString("Commands.Description.mcrefresh"));
command.setPermission("mcmmo.commands.mcrefresh;mcmmo.commands.mcrefresh.others");
@@ -165,7 +167,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McrefreshCommand());
}
public static void registerMmoeditCommand() {
private static void registerMmoeditCommand() {
PluginCommand command = mcMMO.p.getCommand("mmoedit");
command.setDescription(LocaleLoader.getString("Commands.Description.mmoedit"));
command.setPermission("mcmmo.commands.mmoedit;mcmmo.commands.mmoedit.others");
@@ -174,7 +176,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new MmoeditCommand());
}
public static void registerSkillresetCommand() {
private static void registerSkillresetCommand() {
PluginCommand command = mcMMO.p.getCommand("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
@@ -183,7 +185,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new SkillresetCommand());
}
public static void registerXprateCommand() {
private static void registerXprateCommand() {
List<String> aliasList = new ArrayList<String>();
aliasList.add("mcxprate");
@@ -197,7 +199,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new XprateCommand());
}
public static void registerInspectCommand() {
private static void registerInspectCommand() {
PluginCommand command = mcMMO.p.getCommand("inspect");
command.setDescription(LocaleLoader.getString("Commands.Description.inspect"));
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());
}
public static void registerMcabilityCommand() {
private static void registerMcabilityCommand() {
PluginCommand command = mcMMO.p.getCommand("mcability");
command.setDescription(LocaleLoader.getString("Commands.Description.mcability"));
command.setPermission("mcmmo.commands.mcability;mcmmo.commands.mcability.others");
@@ -215,7 +217,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McabilityCommand());
}
public static void registerMcmmoCommand() {
private static void registerMcmmoCommand() {
PluginCommand command = mcMMO.p.getCommand("mcmmo");
command.setDescription(LocaleLoader.getString("Commands.Description.mcmmo"));
command.setPermission("mcmmo.commands.mcmmo.description;mcmmo.commands.mcmmo.help");
@@ -225,7 +227,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McmmoCommand());
}
public static void registerMcrankCommand() {
private static void registerMcrankCommand() {
PluginCommand command = mcMMO.p.getCommand("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");
@@ -234,7 +236,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McrankCommand());
}
public static void registerMcstatsCommand() {
private static void registerMcstatsCommand() {
PluginCommand command = mcMMO.p.getCommand("mcstats");
command.setDescription(LocaleLoader.getString("Commands.Description.mcstats"));
command.setPermission("mcmmo.commands.mcstats");
@@ -243,7 +245,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McstatsCommand());
}
public static void registerMctopCommand() {
private static void registerMctopCommand() {
PluginCommand command = mcMMO.p.getCommand("mctop");
command.setDescription(LocaleLoader.getString("Commands.Description.mctop"));
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());
}
public static void registerMcpurgeCommand() {
private static void registerMcpurgeCommand() {
PluginCommand command = mcMMO.p.getCommand("mcpurge");
command.setDescription(LocaleLoader.getString("Commands.Description.mcpurge", Config.getInstance().getOldUsersCutoff()));
command.setPermission("mcmmo.commands.mcpurge");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcpurge"));
command.setExecutor(new McpurgeCommand());
}
public static void registerMcremoveCommand() {
private static void registerMcremoveCommand() {
PluginCommand command = mcMMO.p.getCommand("mcremove");
command.setDescription(LocaleLoader.getString("Commands.Description.mcremove"));
command.setPermission("mcmmo.commands.mcremove");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcremove", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
command.setExecutor(new McremoveCommand());
}
public static void registerMmoupdateCommand() {
private static void registerMmoupdateCommand() {
PluginCommand command = mcMMO.p.getCommand("mmoupdate");
command.setDescription(LocaleLoader.getString("Commands.Description.mmoupdate"));
command.setPermission("mcmmo.commands.mmoupdate");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mmoupdate"));
command.setExecutor(new MmoupdateCommand());
}
public static void registerAdminChatCommand() {
private static void registerAdminChatCommand() {
PluginCommand command = mcMMO.p.getCommand("adminchat");
command.setDescription(LocaleLoader.getString("Commands.Description.adminchat"));
command.setPermission("mcmmo.chat.adminchat");
@@ -287,7 +292,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new AdminChatCommand());
}
public static void registerPartyChatCommand() {
private static void registerPartyChatCommand() {
PluginCommand command = mcMMO.p.getCommand("partychat");
command.setDescription(LocaleLoader.getString("Commands.Description.partychat"));
command.setPermission("mcmmo.chat.partychat;mcmmo.commands.party");
@@ -298,7 +303,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new PartyChatCommand());
}
public static void registerMchudCommand() {
private static void registerMchudCommand() {
PluginCommand command = mcMMO.p.getCommand("mchud");
command.setDescription(LocaleLoader.getString("Commands.Description.mchud"));
command.setPermission("mcmmo.commands.mchud");
@@ -307,7 +312,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new MchudCommand());
}
public static void registerXplockCommand() {
private static void registerXplockCommand() {
PluginCommand command = mcMMO.p.getCommand("xplock");
command.setDescription(LocaleLoader.getString("Commands.Description.xplock"));
command.setPermission("mcmmo.commands.xplock");
@@ -318,7 +323,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new XplockCommand());
}
public static void registerPartyCommand() {
private static void registerPartyCommand() {
PluginCommand command = mcMMO.p.getCommand("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;" +
@@ -329,7 +334,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new PartyCommand());
}
public static void registerPtpCommand() {
private static void registerPtpCommand() {
PluginCommand command = mcMMO.p.getCommand("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
@@ -339,7 +344,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new PtpCommand());
}
public static void registerHardcoreCommand() {
private static void registerHardcoreCommand() {
PluginCommand command = mcMMO.p.getCommand("hardcore");
command.setDescription(LocaleLoader.getString("Commands.Description.hardcore"));
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());
}
public static void registerVampirismCommand() {
private static void registerVampirismCommand() {
PluginCommand command = mcMMO.p.getCommand("vampirism");
command.setDescription(LocaleLoader.getString("Commands.Description.vampirism"));
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());
}
public static void registerMcnotifyCommand() {
private static void registerMcnotifyCommand() {
PluginCommand command = mcMMO.p.getCommand("mcnotify");
command.setDescription(LocaleLoader.getString("Commands.Description.mcnotify"));
command.setPermission("mcmmo.commands.mcnotify");
@@ -368,7 +373,7 @@ public final class CommandRegistrationManager {
command.setExecutor(new McnotifyCommand());
}
public static void registerMobhealthCommand() {
private static void registerMobhealthCommand() {
PluginCommand command = mcMMO.p.getCommand("mobhealth");
command.setDescription("Change the style of the mob healthbar"); //TODO: Localize
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.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();
}
}

View File

@@ -5,6 +5,7 @@ import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
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) {
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"));
return true;
}

View File

@@ -14,15 +14,16 @@ import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.FlatfileDatabaseManager;
import com.gmail.nossr50.database.SQLDatabaseManager;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.runnables.scoreboards.ScoreboardChangeTask;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
public class ScoreboardManager {
@@ -32,6 +33,7 @@ public class ScoreboardManager {
private final static String PLAYER_STATS_HEADER = "mcMMO Stats";
private final static String PLAYER_RANK_HEADER = "mcMMO Rankings";
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>();
@@ -43,6 +45,32 @@ public class ScoreboardManager {
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) {
Player player = mcMMOPlayer.getPlayer();
Scoreboard oldScoreboard = player.getScoreboard();
@@ -140,10 +168,11 @@ public class ScoreboardManager {
private static void updatePlayerSkillScores(PlayerProfile profile, SkillType skill, Objective objective) {
Server server = mcMMO.p.getServer();
int currentXP = profile.getSkillXpLevel(skill);
objective.getScore(server.getOfflinePlayer("Level")).setScore(profile.getSkillLevel(skill));
objective.getScore(server.getOfflinePlayer("Current XP")).setScore(profile.getSkillXpLevel(skill));
objective.getScore(server.getOfflinePlayer("Remaining XP")).setScore(profile.getXpToLevel(skill));
objective.getScore(server.getOfflinePlayer("Current XP")).setScore(currentXP);
objective.getScore(server.getOfflinePlayer("Remaining XP")).setScore(profile.getXpToLevel(skill) - currentXP);
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
}
@@ -153,8 +182,8 @@ public class ScoreboardManager {
PlayerProfile profile = mcMMOPlayer.getProfile();
Server server = mcMMO.p.getServer();
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (!Permissions.skillEnabled(player, skill)) {
continue;
}
@@ -172,8 +201,8 @@ public class ScoreboardManager {
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(playerName) : FlatfileDatabaseManager.getPlayerRanks(playerName);
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(player, skill)) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (!Permissions.skillEnabled(player, skill)) {
continue;
}
@@ -199,11 +228,7 @@ public class ScoreboardManager {
Map<String, Integer> skills = Config.getInstance().getUseMySQL() ? SQLDatabaseManager.readSQLRank(targetName) : FlatfileDatabaseManager.getPlayerRanks(targetName);
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
continue;
}
for (SkillType skill : SkillType.nonChildSkills()) {
rank = skills.get(skill.name());
if (rank != null) {
@@ -228,8 +253,8 @@ public class ScoreboardManager {
int powerLevel = 0;
int skillLevel;
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill() || !Permissions.skillEnabled(target, skill)) {
for (SkillType skill : SkillType.nonChildSkills()) {
if (!Permissions.skillEnabled(target, skill)) {
continue;
}
@@ -248,11 +273,7 @@ public class ScoreboardManager {
int powerLevel = 0;
int skillLevel;
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
continue;
}
for (SkillType skill : SkillType.nonChildSkills()) {
skillLevel = targetProfile.getSkillLevel(skill);
objective.getScore(server.getOfflinePlayer(SkillUtils.getSkillName(skill))).setScore(skillLevel);
powerLevel += skillLevel;
@@ -277,6 +298,10 @@ public class ScoreboardManager {
String playerName = stat.get(1);
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)));
}
}
@@ -285,6 +310,10 @@ public class ScoreboardManager {
String playerName = stat.name;
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);
}
}
@@ -298,6 +327,7 @@ public class ScoreboardManager {
String playerName = player.getName();
player.setScoreboard(newScoreboard);
enablePowerLevelDisplay(player);
if (displayTime != -1 && !SCOREBOARD_TASKS.contains(playerName)) {
new ScoreboardChangeTask(player, oldScoreboard).runTaskLater(mcMMO.p, displayTime * 20);

View File

@@ -15,7 +15,6 @@ import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.inventory.ItemStack;
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.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.skills.AwardCombatXpTask;
@@ -245,12 +245,13 @@ public final class CombatUtils {
event.setDamage(archeryManager.dazeCheck((Player) target, event.getDamage()));
}
if (archeryManager.canTrackArrows()) {
if (!damager.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canTrackArrows()) {
archeryManager.trackArrows(target);
}
archeryManager.distanceXpBonus(target);
startGainXp(mcMMOPlayer, target, SkillType.ARCHERY);
archeryManager.distanceXpBonus(target, damager);
startGainXp(mcMMOPlayer, target, SkillType.ARCHERY, damager.getMetadata(mcMMO.bowForceKey).get(0).asDouble());
}
break;
@@ -284,6 +285,24 @@ public final class CombatUtils {
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) {
Player player = (Player) attacker;
@@ -362,48 +381,45 @@ public final class CombatUtils {
*/
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 damageAmount = damage;
int damageAmount = Math.max(damage, 1);
if (damageAmount < 1) {
damageAmount = 1;
while (numberOfTargets > 0) {
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)) {
if (Misc.isNPCEntity(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) {
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--;
}
public static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, SkillType skillType) {
startGainXp(mcMMOPlayer, target, skillType, 1.0);
}
/**
@@ -413,7 +429,7 @@ public final class CombatUtils {
* @param target The defending entity
* @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;
if (target instanceof Player) {
@@ -427,7 +443,7 @@ public final class CombatUtils {
baseXP = 20 * Config.getInstance().getPlayerVersusPlayerXP();
}
}
else if (!target.hasMetadata(mcMMO.entityMetadataKey)) {
else {
if (target instanceof Animals) {
if (ModUtils.isCustomEntity(target)) {
baseXP = ModUtils.getCustomEntity(target).getXpMultiplier();
@@ -487,11 +503,17 @@ public final class CombatUtils {
}
break;
}
if (target.hasMetadata(mcMMO.entityMetadataKey)) {
baseXP *= Config.getInstance().getSpawnedMobXpMultiplier();
}
}
baseXP *= 10;
}
baseXP *= multiplier;
if (baseXP != 0) {
new AwardCombatXpTask(mcMMOPlayer, skillType, baseXP, target).runTaskLater(mcMMO.p, 0);
}
@@ -512,7 +534,7 @@ public final class CombatUtils {
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;
}
@@ -546,16 +568,11 @@ public final class CombatUtils {
* @return true if the entity is invincible, false otherwise
*/
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 yeah, this is for that.
*/
if ((entity.getNoDamageTicks() > entity.getMaximumNoDamageTicks() / 2.0F) && (eventDamage <= entity.getLastDamage())) {
return true;
}
return false;
return (entity.getNoDamageTicks() > entity.getMaximumNoDamageTicks() / 2.0F) && (eventDamage <= entity.getLastDamage());
}
/**
@@ -572,7 +589,7 @@ public final class CombatUtils {
if (tamer instanceof Player) {
Player owner = (Player) tamer;
if (owner == attacker || PartyManager.inSameParty(attacker, owner)) {
if (owner == attacker || mcMMO.getPartyManager().inSameParty(attacker, owner)) {
return true;
}
}
@@ -582,15 +599,6 @@ public final class CombatUtils {
}
public static boolean shouldProcessSkill(Entity target, SkillType skill) {
boolean process;
if (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) {
process = skill.getPVPEnabled();
}
else {
process = skill.getPVEEnabled();
}
return process;
return (target instanceof Player || (target instanceof Tameable && ((Tameable) target).isTamed())) ? skill.getPVPEnabled() : skill.getPVEEnabled();
}
}

View File

@@ -7,6 +7,7 @@ import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
@@ -63,7 +64,9 @@ public final class ParticleEffectUtils {
return;
}
fireworkParticleShower(player, Color.GREEN);
if (hasHeadRoom(player)) {
fireworkParticleShower(player, Color.GREEN);
}
}
public static void playAbilityDisabledEffect(Player player) {
@@ -71,7 +74,9 @@ public final class ParticleEffectUtils {
return;
}
fireworkParticleShower(player, Color.RED);
if (hasHeadRoom(player)) {
fireworkParticleShower(player, Color.RED);
}
}
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);
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.setPower(0);
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;
}
}

View File

@@ -26,6 +26,10 @@ public final class PerksUtils {
}
public static int handleActivationPerks(Player player, int ticks, int maxTicks) {
if (maxTicks != 0) {
ticks = Math.min(ticks, maxTicks);
}
if (Permissions.twelveSecondActivationBoost(player)) {
ticks += 12;
}
@@ -36,10 +40,6 @@ public final class PerksUtils {
ticks += 4;
}
if (maxTicks != 0) {
ticks = Math.min(ticks, maxTicks);
}
return ticks;
}

View File

@@ -13,14 +13,11 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.PluginManager;
import org.bukkit.potion.PotionEffect;
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.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
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.PlayerProfile;
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.FakeBlockDamageEvent;
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.runnables.skills.AbilityDisableTask;
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;
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) {
int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(skill);
@@ -59,25 +55,6 @@ public class SkillUtils {
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.
*
@@ -100,15 +77,14 @@ public class SkillUtils {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
AbilityType ability = skill.getAbility();
ToolType tool = skill.getTool();
ItemStack inHand = player.getItemInHand();
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (!mcMMOPlayer.getAbilityUse()) {
return;
}
@@ -120,6 +96,8 @@ public class SkillUtils {
}
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
AbilityType ability = skill.getAbility();
ToolType tool = skill.getTool();
/*
* 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 (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(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)));
int timeRemaining = 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;
}
}
@@ -151,7 +131,7 @@ public class SkillUtils {
* @param profile The profile of the player whose skill to check
*/
public static void xpCheckSkill(SkillType skillType, Player player, PlayerProfile profile) {
int skillups = 0;
int levelsGained = 0;
float xpRemoved = 0;
if (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
@@ -163,7 +143,7 @@ public class SkillUtils {
xpRemoved += xp;
profile.removeXp(skillType, xp);
skillups++;
levelsGained++;
profile.skillUp(skillType, 1);
}
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);
if (eventToFire.isCancelled()) {
profile.modifySkill(skillType, profile.getSkillLevel(skillType) - skillups);
profile.modifySkill(skillType, profile.getSkillLevel(skillType) - levelsGained);
profile.setSkillXpLevel(skillType, profile.getSkillXpLevelRaw(skillType) + xpRemoved);
return;
}
String capitalized = StringUtils.getCapitalized(skillType.toString());
/* Spout Stuff */
if (mcMMO.spoutEnabled) {
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)));
}
if (mcMMO.isSpoutEnabled()) {
SpoutUtils.processLevelup(mcMMOPlayer, skillType, levelsGained);
}
else {
player.sendMessage(LocaleLoader.getString(capitalized + ".Skillup", skillups, profile.getSkillLevel(skillType)));
player.sendMessage(LocaleLoader.getString(capitalized + ".Skillup", levelsGained, profile.getSkillLevel(skillType)));
}
}
if (mcMMO.spoutEnabled) {
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
if (spoutPlayer != null && spoutPlayer.isSpoutCraftEnabled()) {
if (SpoutConfig.getInstance().getXPBarEnabled()) {
profile.getSpoutHud().updateXpBar();
}
}
if (mcMMO.isSpoutEnabled()) {
SpoutUtils.processXpGain(player, profile);
}
}
@@ -225,11 +186,7 @@ public class SkillUtils {
return isLocalizedSkill(skillName);
}
if (SkillType.getSkill(skillName) != null) {
return true;
}
return false;
return SkillType.getSkill(skillName) != null;
}
private static boolean isLocalizedSkill(String skillName) {
@@ -257,15 +214,11 @@ public class SkillUtils {
* @return true if the player has combat skills, false otherwise
*/
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.SWORDS)
|| Permissions.skillEnabled(player, SkillType.TAMING)
|| Permissions.skillEnabled(player, SkillType.UNARMED)) {
return true;
}
return false;
|| Permissions.skillEnabled(player, SkillType.UNARMED);
}
/**
@@ -275,15 +228,11 @@ public class SkillUtils {
* @return true if the player has gathering skills, false otherwise
*/
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.HERBALISM)
|| Permissions.skillEnabled(player, SkillType.MINING)
|| Permissions.skillEnabled(player, SkillType.WOODCUTTING)) {
return true;
}
return false;
|| Permissions.skillEnabled(player, SkillType.WOODCUTTING);
}
/**
@@ -293,13 +242,9 @@ public class SkillUtils {
* @return true if the player has misc skills, false otherwise
*/
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.REPAIR)) {
return true;
}
return false;
|| Permissions.skillEnabled(player, SkillType.REPAIR);
}
/**
@@ -317,18 +262,27 @@ public class SkillUtils {
Player player = mcMMOPlayer.getPlayer();
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.
* We show them the too tired message when they take action.
*/
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
if (!mcMMOPlayer.getAbilityMode(ability) && !cooldownOver(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;
}
}
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());
ParticleEffectUtils.playAbilityEnabledEffect(player);
@@ -363,6 +317,7 @@ public class SkillUtils {
switch (ability) {
case BERSERK:
case BLOCK_CRACKER:
case LEAF_BLOWER:
if (!ability.blockCheck(block.getState())) {
activate = false;
@@ -417,7 +372,7 @@ public class SkillUtils {
}
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);
heldItem.setItemMeta(itemMeta);
@@ -483,11 +438,11 @@ public class SkillUtils {
if (itemLore.remove("mcMMO Ability Tool")) {
int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED);
if (efficiencyLevel <= enchantBuff) {
if (efficiencyLevel <= AdvancedConfig.getInstance().getEnchantBuff()) {
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
}
else {
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - enchantBuff, true);
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - AdvancedConfig.getInstance().getEnchantBuff(), true);
}
itemMeta.setLore(itemLore);
@@ -521,11 +476,7 @@ public class SkillUtils {
FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player);
pluginManger.callEvent(breakEvent);
if (!damageEvent.isCancelled() && !breakEvent.isCancelled()) {
return true;
}
return false;
return !damageEvent.isCancelled() && !breakEvent.isCancelled();
}
public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) {

View File

@@ -9,61 +9,132 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.jar.JarFile;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.getspout.spoutapi.SpoutManager;
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 com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
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.skills.SkillType;
import com.gmail.nossr50.listeners.SpoutListener;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
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;
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;
int numerical;
public static boolean showPowerLevel;
private Tier(int numerical) {
this.numerical = numerical;
}
private final static SpoutListener spoutListener = new SpoutListener();
public static Keyboard menuKey;
public int toNumerical() {
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.
*
* @param theFileName The name of the file
* @param theFilePath The name of the file path
* @param fileName The name of the file
* @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;
JarFile jar = null;
// No point in writing the file again if it already exists.
if (currentFile.exists()) {
return currentFile;
}
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);
@SuppressWarnings("resource")
InputStream is = jar.getInputStream(jar.getJarEntry("resources/" + theFileName));
InputStream is = jar.getInputStream(jar.getJarEntry("resources/" + fileName));
byte[] buf = new byte[2048];
int nbRead;
@@ -98,12 +169,16 @@ public class SpoutUtils {
}
}
}
return currentFile;
}
/**
* Extract Spout files to the Resources directory.
*/
public static void extractFiles() {
public static ArrayList<File> extractFiles() {
ArrayList<File> files = new ArrayList<File>();
// Setup directories
new File(spoutDirectory).mkdir();
new File(hudDirectory).mkdir();
@@ -113,110 +188,39 @@ public class SpoutUtils {
// XP Bar images
for (int x = 0; x < 255; x++) {
String theFileName;
String fileName;
if (x < 10) {
theFileName = "xpbar_inc00" + x + ".png";
fileName = "xpbar_inc00" + x + ".png";
}
else if (x < 100) {
theFileName = "xpbar_inc0" + x + ".png";
fileName = "xpbar_inc0" + x + ".png";
}
else {
theFileName = "xpbar_inc" + x + ".png";
fileName = "xpbar_inc" + x + ".png";
}
writeFile(theFileName, hudStandardDirectory);
files.add(writeFile(fileName, hudStandardDirectory));
}
// Standard XP Icons
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
for (SkillType skillType : SkillType.nonChildSkills()) {
String skillName = StringUtils.getCapitalized(skillType.toString());
String skillTypeString = StringUtils.getCapitalized(skillType.toString());
writeFile(skillTypeString + ".png", hudStandardDirectory);
writeFile(skillTypeString + "_r.png", hudRetroDirectory);
files.add(writeFile(skillName + ".png", hudStandardDirectory));
files.add(writeFile(skillName + "_r.png", hudRetroDirectory));
}
// Blank icons
writeFile("Icon.png", hudStandardDirectory);
writeFile("Icon_r.png", hudRetroDirectory);
files.add(writeFile("Icon.png", hudStandardDirectory));
files.add(writeFile("Icon_r.png", hudRetroDirectory));
// Sound FX
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"));
files.add(writeFile("level.wav", soundDirectory));
return files;
}
/**
* Register custom Spout events.
*/
public static void registerCustomEvent() {
plugin.getServer().getPluginManager().registerEvents(spoutListener, plugin);
}
/**
* Handle level-up notifications through Spout.
*
@@ -225,334 +229,185 @@ public class SpoutUtils {
*/
public static void levelUpNotification(SkillType skillType, SpoutPlayer spoutPlayer) {
PlayerProfile profile = UserManager.getPlayer(spoutPlayer).getProfile();
int notificationTier = getNotificationTier(profile.getSkillLevel(skillType));
Material mat = null;
int skillLevel = profile.getSkillLevel(skillType);
Material notificationItem;
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:
switch (notificationTier) {
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;
}
notificationItem = getAcrobaticsNotificationItem(skillLevel);
break;
case ARCHERY:
switch (notificationTier) {
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;
}
notificationItem = getArcheryNotificationItem(skillLevel);
break;
case AXES:
switch (notificationTier) {
case 1:
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;
}
notificationItem = getAxesNotificationItem(skillLevel);
break;
case EXCAVATION:
notificationItem = getExcavationNotificationItem(skillLevel);
break;
case FISHING:
switch (notificationTier) {
case 1:
case 2:
mat = Material.RAW_FISH;
break;
notificationItem = getFishingNotificationItem(skillLevel);
break;
case 3:
case 4:
mat = Material.COOKED_FISH;
break;
case HERBALISM:
notificationItem = getHerbalismNotificationItem(skillLevel);
break;
case 5:
mat = Material.FISHING_ROD;
break;
case MINING:
notificationItem = getMiningNotificationItem(skillLevel);
break;
default:
break;
}
case REPAIR:
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;
default:
mat = Material.WATCH;
notificationItem = Material.MAP;
break;
}
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.LevelUp.1"), LocaleLoader.getString("Spout.LevelUp.2", SkillUtils.getSkillName(skillType), profile.getSkillLevel(skillType)), mat);
SpoutManager.getSoundManager().playCustomSoundEffect(plugin, spoutPlayer, "level.wav", false);
spoutPlayer.sendNotification(LocaleLoader.getString("Spout.LevelUp.1"), LocaleLoader.getString("Spout.LevelUp.2", SkillUtils.getSkillName(skillType), skillLevel), notificationItem);
SpoutManager.getSoundManager().playCustomSoundEffect(mcMMO.p, spoutPlayer, "level.wav", false);
}
/**
* Gets the notification tier of a skill.
*
* @param level The level of the skill
* @return the notification tier of the skill
*/
private static int getNotificationTier(int level) {
if (level >= AdvancedConfig.getInstance().getSpoutNotificationTier4()) {
return 5;
private static Material getAcrobaticsNotificationItem(int skillLevel) {
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getAcrobaticsNotificationItem();
}
}
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
*/
public static void reloadSpoutPlayers() {
PluginManager pluginManager = mcMMO.p.getServer().getPluginManager();
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() {
extractFiles(); // Extract source materials
SpoutManager.getFileManager().addToPreLoginCache(mcMMO.p, extractFiles());
}
FileManager FM = SpoutManager.getFileManager();
FM.addToPreLoginCache(plugin, getFiles());
public static void processLevelup(McMMOPlayer mcMMOPlayer, SkillType skillType, int levelsGained) {
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");
}
}
}

View File

@@ -1,9 +1,9 @@
#
# 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"
# Configure at what level you get better with certain abilities.
#
@@ -43,7 +43,6 @@ Skills:
GracefulRoll_ChanceMax: 100.0
GracefulRoll_MaxBonusLevel: 500
GracefulRoll_DamageThreshold: 14
GracefulRoll_SuccessModifier: 2
# Amount of experience for performing a dodge, roll or fall
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_MaxChance: 100.0
Retrieve_MaxBonusLevel: 1000
#Force_Multiplier: Multiply the force of the bow by this for an XP boost.
Force_Multiplier: 2.0
#
# Settings for Axes
###
@@ -139,6 +141,9 @@ Skills:
# This determines when Fisherman's Diet adds extra hunger recovery to food
Fisherman_Diet_RankChange: 200
# Ice_Fishing_UnlockLevel: Fishing level when the Ice Fishing ability unlocks
Ice_Fishing_UnlockLevel: 50
#
# Settings for Herbalism
###
@@ -400,12 +405,21 @@ Skills:
# DoubleDrops_MaxBonusLevel: Level when the maximum chance of receiving double drops is reached
DoubleDrops_ChanceMax: 100.0
DoubleDrops_MaxBonusLevel: 1000
Spout:
#
# Settings for the Spout notifications, when a player reaches a higher tier, the image of the notification will change.
###
Notifications:
Tier1: 200
Tier2: 400
Tier3: 600
Tier4: 800
#
# Customize the kraken!
###
Kraken:
Enabled: true
Tries_Before_Release: 50
Health: 50
Name: The Kraken
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!

View File

@@ -26,34 +26,39 @@ General:
Verbose_Logging: false
# Should mcMMO over-write configs to update, or make new ones ending in .new?
Config_Update_Overwrite: true
# Enable potato easter egg?
Potato_Explosion_Enabled: false
Potato_Explosion_Chance: 1
Scoreboards:
# Should mcMMO use scoreboards for /inspect?
# Amount of time (in seconds) to display. To display permanently, set to -1
Inspect:
# Should mcMMO use scoreboards for /inspect?
Use: true
# Amount of time (in seconds) to display. To display permanently, set to -1
Display_Time: 10
# Should mcMMO use scoreboards for /mcrank?
# Amount of time (in seconds) to display. To display permanently, set to -1
Mcrank:
# Should mcMMO use scoreboards for /mcrank?
Use: true
# Amount of time (in seconds) to display. To display permanently, set to -1
Display_Time: 10
# Should mcMMO use scoreboards for /mcstats?
# Amount of time (in seconds) to display. To display permanently, set to -1
Mcstats:
# Should mcMMO use scoreboards for /mcstats?
Use: true
# Amount of time (in seconds) to display. To display permanently, set to -1
Display_Time: 10
# Should mcMMO use scoreboards for /mctop?
# Amount of time (in seconds) to display. To display permanently, set to -1
Mctop:
# Should mcMMO use scoreboards for /mctop?
Use: true
# Amount of time (in seconds) to display. To display permanently, set to -1
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:
# Should mcMMO use scoreboards for /skillname (/mining, /fishing, etc.)?
Use: true
# Amount of time (in seconds) to display. To display permanently, set to -1
Display_Time: 10
# Should mcMMO display power levels on scoreboards? (below player name-tags)
Power_Level:
Use: false
Mob_Healthbar:
# 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
# To never purge old users, set to -1
Old_User_Cutoff: 6
#
# Settings for using a mySQL database
###
@@ -82,6 +88,7 @@ MySQL:
Server:
Port: 3306
Address: localhost
#
# Settings for Hardcore mode
###
@@ -273,8 +280,9 @@ Double_Drops:
###
Experience:
Gains:
# Experience gained from mobs not naturally spawned will get multiplied by this value. 0 by default.
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
Multiplier:
@@ -379,12 +387,15 @@ Experience:
Magma_Cube: 2.0
Iron_Golem: 2.0
Wither_Skeleton: 4.0
#
# Settings for commands
###
Commands:
mcmmo:
Donate_Message: true
inspect:
Max_Distance: 30
ptp:
Cooldown: 120
Warmup: 5
@@ -400,6 +411,7 @@ Commands:
a:
# Allow mcMMO to use player display names in chat instead of their usernames
Use_Display_Names: true
#
# Settings for particles
###
@@ -408,6 +420,9 @@ Particles:
Ability_Activation: 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
Dodge: true
Bleed: true

View File

@@ -10,6 +10,8 @@
#####
Item_Weights:
Default: 5
Quartz: 200
Quartz_Ore: 200
Emerald: 150
Emerald_Ore: 150
Diamond: 100
@@ -25,6 +27,32 @@ Item_Weights:
Coal: 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.
# Case insensitive, though the name must be exactly the same as set in the Bukkit Material enum.
Party_Shareables:

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