mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 22:26:46 +01:00
Merge branch 'master' of github.com:mcMMO-Dev/mcMMO into tridentsxbows
This commit is contained in:
commit
148647709a
212
Changelog.txt
212
Changelog.txt
@ -87,6 +87,207 @@ Version 2.2.000
|
|||||||
Parties got unnecessarily complex in my absence, I have removed many party features in order to simplify parties and bring them closer to my vision. I have also added new features which should improve parties where it matters.
|
Parties got unnecessarily complex in my absence, I have removed many party features in order to simplify parties and bring them closer to my vision. I have also added new features which should improve parties where it matters.
|
||||||
About the removed party features, all the features I removed I consider poor quality features and I don't think they belong in mcMMO. Feel free to yell at me in discord if you disagree.
|
About the removed party features, all the features I removed I consider poor quality features and I don't think they belong in mcMMO. Feel free to yell at me in discord if you disagree.
|
||||||
I don't know what genius decided to make parties public by default, when I found out that parties had been changed to such a system I could barely contain my disgust. Parties are back to being private, you get invited by a party leader or party officer. That is the only way to join a party.
|
I don't know what genius decided to make parties public by default, when I found out that parties had been changed to such a system I could barely contain my disgust. Parties are back to being private, you get invited by a party leader or party officer. That is the only way to join a party.
|
||||||
|
Version 2.1.156
|
||||||
|
Added Woodcutting skill 'Knock on Wood' - This ability gives you goodies (saplings, xp orbs, apples, etc) when using Tree Feller
|
||||||
|
Tree Feller no longer gives non-wood items by default, it now requires Knock on Wood for additional loot
|
||||||
|
When you raise your axe you will now see information about any super abilities on CD
|
||||||
|
Fixed a bug where Green Thumb would replant blocks floating in the air
|
||||||
|
Fixed a bug where the admin and party chat toggles in chat.yml didn't function as intended
|
||||||
|
* Fixed a bug where Master Angler rank 1 level requirement was set too high (default configs)
|
||||||
|
Added some errors that trigger if a plugin hooking into mcMMO is grabbing leaderboards for child skills through our SQL/FlatFile class (which don't exist)
|
||||||
|
mcMMO will automatically fix some errors in logic for user settings in skillranks.yml
|
||||||
|
Corrected some logic errors when checking for oddities in skillranks.yml
|
||||||
|
Removed incorrect translations of Master Angler from various locales
|
||||||
|
Modified Master Angler stat lines in /fishing
|
||||||
|
Updated Green Thumb description to mention that it needs a hoe
|
||||||
|
'Abilities.Limits.Tree_Feller_Threshold' in config.yml now defaults to 1000 instead of 500 (edit your config)
|
||||||
|
Added new permission node 'mcmmo.ability.woodcutting.knockonwood'
|
||||||
|
Added new locale line 'Woodcutting.SubSkill.KnockOnWood.Name'
|
||||||
|
Added new locale line 'Woodcutting.SubSkill.KnockOnWood.Stat'
|
||||||
|
Added new locale line 'Woodcutting.SubSkill.KnockOnWood.Description'
|
||||||
|
Added new locale line 'Woodcutting.SubSkill.KnockOnWood.Loot.Normal'
|
||||||
|
Added new locale line 'Woodcutting.SubSkill.KnockOnWood.Loot.Rank2'
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
You don't need to touch your config files unless you want to get the new tree feller threshold (1000 instead of 500), you could also delete config.yml and regenerate it, for all the other config changes in this update, they are handled automagically.
|
||||||
|
* - If you haven't manually edited your Master Angler entries in skillranks.yml then the previous mcMMO update has rank 1 for Master Angler too high, this update automatically fixes it.
|
||||||
|
You may have noticed sometimes config file entries are in a strange jumbled order, yeah that's "normal". We'll be moving to HOCON for the config update and wont' have to deal with this crap for much longer.
|
||||||
|
I'll probably be doing a bunch of tweaks to mcMMO UI in the near future, I don't know, or I'll work on T&C
|
||||||
|
|
||||||
|
Version 2.1.155
|
||||||
|
Master Angler now has 8 ranks
|
||||||
|
Master Angler is now supported by the latest builds of Spigot on 1.16.4
|
||||||
|
Wolves will now earn a lot more XP from combat than before (Wolves are going to be tweaked a lot in the near future)
|
||||||
|
Fixed a bug where Spectral Arrow awarded too much XP
|
||||||
|
Fixed a bug where party members other than the party leader had names that weren't properly hex colored
|
||||||
|
Added 'Skills.Fishing.MasterAngler.Tick_Reduction_Per_Rank.Min_Wait' to advanced.yml
|
||||||
|
Added 'Skills.Fishing.MasterAngler.Tick_Reduction_Per_Rank.Max_Wait' to advanced.yml
|
||||||
|
Added 'Skills.Fishing.MasterAngler.Boat_Tick_Reduction.Max_Wait' to advanced.yml
|
||||||
|
Added 'Skills.Fishing.MasterAngler.Boat_Tick_Reduction.Min_Wait' to advanced.yml
|
||||||
|
Added 'Skills.Fishing.MasterAngler.Tick_Reduction_Caps.Min_Wait' to advanced.yml
|
||||||
|
Added 'Skills.Fishing.MasterAngler.Tick_Reduction_Caps.Max_Wait' to advanced.yml
|
||||||
|
Removed Skills.Fishing.MasterAngler.BoatModifier from advanced.yml
|
||||||
|
Removed Skills.Fishing.MasterAngler.BoatModifier from advanced.yml
|
||||||
|
Optimized party/admin chat a bit
|
||||||
|
Added some misc safeguards against possible NPEs
|
||||||
|
Added some debug output when fishing if mmodebug is on
|
||||||
|
(API) Removed AbstractPlayerAuthor#getComponentDisplayName
|
||||||
|
(API) Removed AbstractPlayerAuthor#getComponentUserName
|
||||||
|
(API) Removed Author#getAuthoredComponentName
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
Master Angler won't work if you aren't on 1.16.4, the truth is it hasn't worked for a very long time (Since before 1.13.2)
|
||||||
|
The Spigot API related to it has been broken since years and years ago, and they finally updated the API but it is only in the newest builds of Spigot.
|
||||||
|
If you are on something that doesn't support the new Master Angler that skill will be missing when you type /fishing
|
||||||
|
The boat bonus for master angler is static and doesn't improve when leveling master angler.
|
||||||
|
All the new master angler stuff is configurable and can be found in advanced.yml
|
||||||
|
The configurable reduction tick stuff for master angler is multiplied by the rank level when determining the final bonus (use /mmodebug when fishing to see some details)
|
||||||
|
Master Angler stacks with the Lure enchant
|
||||||
|
Removed some unnecessary API, we aren't a chat plugin so these things shouldn't be here.
|
||||||
|
Slowly adding Nullability annotations to the codebase
|
||||||
|
|
||||||
|
Version 2.1.154
|
||||||
|
Hex colors are now supported in Party & Admin chat
|
||||||
|
Added support for &#RRGGBB color codes (hex colors) in chat and nicknames for party and admin chat
|
||||||
|
Added hex colored nickname support to admin/party chat
|
||||||
|
Fixed a bug where Tree Feller was not dropping some items like saplings
|
||||||
|
Fixed a bug where using admin chat would in some circumstances throw a NPE
|
||||||
|
(API) Author class has been reworked
|
||||||
|
(API) McMMOChatEvent::getSender removed (use getDisplayName() instead)
|
||||||
|
(API) McMMMOChatEvent::setDisplayName() removed
|
||||||
|
(API) Removed Author::setName use Player::SetDisplayName instead
|
||||||
|
(API) Modified Author::getAuthoredName signature to -> Author::getAuthoredName(ChatChannel)
|
||||||
|
(API) Added Author::getAuthoredComponentName(ChatChannel)
|
||||||
|
(API) PartyAuthor and AdminAuthor removed, replaced by PlayerAuthor
|
||||||
|
(API) Probably some more undocumented changes that I'm forgetting...
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
For example '/p &#ccFF33hi guys' will send a message colored in hex colors
|
||||||
|
You'll see ~§x in console when hex color codes are used, this is a quirk of how the 'adventure' library we are using is handling some bungee component related things, so it's outside of my hands for now
|
||||||
|
|
||||||
|
Version 2.1.153
|
||||||
|
Fixed a bug where most sub-skills were not being displayed when using a skills command (for example /taming)
|
||||||
|
Fixed a bug where some URL links were not being colored
|
||||||
|
Updated fr locale (thanks Vlammar)
|
||||||
|
|
||||||
|
Version 2.1.152
|
||||||
|
Fixed a bug where Tree Feller would sometimes double drop blocks inappropriately
|
||||||
|
Fixed a bug with bleed damage calculations and player armor
|
||||||
|
Added some code to prevent a possible NPE when spawning items in a world that got unloaded
|
||||||
|
Added the missing 'pc' alias for party chat
|
||||||
|
Added the missing 'ac' alias for admin chat
|
||||||
|
(API) New ENUM ItemSpawnReason which gives context for why mcMMO is dropping an item
|
||||||
|
(API) McMMOItemSpawnEvent::getItemSpawnReason() was added
|
||||||
|
(API) Many instances of spawning items that didn't used to create and call an McMMOItemSpawnEvent now do
|
||||||
|
Updated hu_HU locale (thanks andris)
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
I really should stop letting my OCD compel me to rewrite code all the time.
|
||||||
|
Bleed was meant to do reduced damage to players wearing 4 pieces of armor or more, it was incorrectly counting everyone as wearing 4 pieces even when they weren't.
|
||||||
|
This means Bleed was doing a bit less damage than was intended against players without a full set of armor equipped.
|
||||||
|
|
||||||
|
Version 2.1.151
|
||||||
|
Added new config for chat options named 'chat.yml'
|
||||||
|
Added 'Chat.Channels.Party.Spies.Automatically_Enable_Spying' to chat.yml which when enabled will start users who have the chat spy permission in chat spying mode
|
||||||
|
All chat settings that used to be in 'config.yml' are now in 'chat.yml'
|
||||||
|
The list of party members shown when using the party command has been simplified, this will change again in the T&C update
|
||||||
|
Fixed a bug where players could use the party chat command without the party chat permission
|
||||||
|
Party Leaders now use a different style when chatting than normal party members (can be customized)
|
||||||
|
Added 'Chat.Style.Party.Leader' to the locale, party leaders use this as their chat style
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
I greatly disliked the old party member list but was avoiding rewriting it until later, someone pointed out how ugly it was and my OCD triggered and now it is rewritten. I will rewrite it again in Tridents & Crossbows.
|
||||||
|
The new config file lets you disable the chat system (you can disable all of it, or just party chat, and or just admin chat) without permission nodes.
|
||||||
|
If you disable the party/admin chat, then the party/admin chat command never gets registered and attempting to use the command will result in a whole lot of nothing, so if you want users to have a permission denied message then just stick to negating permission nodes.
|
||||||
|
I'll probably be tweaking mcMMO visually a lot in the near future, probably after Tridents & Crossbows goes out.
|
||||||
|
I hate adding more config files using the old .yml system, but the config update is a ways out and this works for now.
|
||||||
|
Reminder that the look/feel of party/admin chat is now determined by locale entries
|
||||||
|
https://mcmmo.org/wiki/Locale can help you understand how to change the locale
|
||||||
|
|
||||||
|
Version 2.1.150
|
||||||
|
Fixed an ArrayIndexOutOfBounds exception when using /skillreset
|
||||||
|
You can now add "-s" at the end of mmoedit, addlevels, or addxp to silence the command. Which will prevent the target of the command from being informed that the command was executed.
|
||||||
|
mcMMO should now be compatible with 1.16.4's new social features (affects Party/Admin chat)
|
||||||
|
mcMMO Party & Admin Chat have had a complete rewrite
|
||||||
|
Players & Console can now use color codes (including stuff like &a or [[GREEN]]) in party or admin chat
|
||||||
|
Added new permission node 'mcmmo.chat.colors' which allows players to use color codes, negate to disallow this
|
||||||
|
The style and look of admin/party chat is now determined by locale file instead of options in config.yml
|
||||||
|
The default style of admin/party chat has been updated, and it may be updated again in the future
|
||||||
|
Improved messages players receive when they toggle on or off admin or party chat
|
||||||
|
All locale files have had 99.9% of their [[]] color codes replaced by & color codes, you can still use [[GOLD]] and stuff if you want
|
||||||
|
Added new locale entry 'Commands.Usage.3.XP'
|
||||||
|
Added new locale entry 'Chat.Identity.Console'
|
||||||
|
Added new locale entry 'Chat.Style.Admin'
|
||||||
|
Added new locale entry 'Chat.Style.Party'
|
||||||
|
Added new locale entry 'Chat.Spy.Party'
|
||||||
|
Added new locale entry 'Chat.Channel.On'
|
||||||
|
Added new locale entry 'Chat.Channel.Off'
|
||||||
|
(API) ChatAPI::getPartyChatManager() has been removed
|
||||||
|
(API) ChatAPI::sendPartyChat has been removed (similar functionality can be found in the new ChatManager class)
|
||||||
|
(API) ChatAPI::sendAdminChat has been removed (similar functionality can be found in the new ChatManager class)
|
||||||
|
(API) Fake events in mcMMO now implement 'FakeEvent' (thanks TheBusyBiscuit)
|
||||||
|
(API) Updated Adventure Library to 4.1.1
|
||||||
|
(API) McMMOChatEvent has been reworked, plugins dependent on this event should review this class and make appropriate changes
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
The yet to be released Tridents & Crossbows update will also feature some new features related to party chat, so expect more tweaks to those features in the future.
|
||||||
|
I actually spent a little over a week on this, the old code for party/admin chat was absolutely horrid and when porting in the new 1.16.4 features I couldn't stand the sight of it so I burned everything to the ground and rewrote all of it.
|
||||||
|
The mcMMO chat events now make use of adventure library by Kyori, you can override the message payload with a TextComponent, which allows for some fancy stuff potentially.
|
||||||
|
I'll put in some of my own fancy stuff for party and admin chat in a future update.
|
||||||
|
|
||||||
|
Version 2.1.149
|
||||||
|
Added a new config file 'persistent_data.yml'
|
||||||
|
Almost all persistent mob data is now off by default and needs to be turned on in persistent_data.yml (new config file) for performance concerns
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
There are some performance issues with how Spigot/MC saves NBT when you start adding NBT to mobs, because of this I have decided that the new persistent data from 2.1.148 is now opt-in.
|
||||||
|
|
||||||
|
Not every server will suffer a TPS hit when using the persistent data options, but there is a significant IO cost which can affect TPS if you have them on
|
||||||
|
|
||||||
|
I am therefore making many persistent options (the problematic ones involving mobs) opt-in so only those aware of the performance risk will be using the feature.
|
||||||
|
|
||||||
|
Persistent data on mobs was a new feature that was introduced in 2.1.148, it was not in mcMMO for the last 10 years and most of you probably didn't even know that it was missing
|
||||||
|
|
||||||
|
An example of persistent data would be, normally mcMMO would give 0 XP for a mob from a mob spawner, in the last 10 years if the server rebooted then those existing mobs would give XP again. But with the persistent data option turned on in persistentdata.yml they will be saved to disk, and mcMMO will not forget about them upon reboot.
|
||||||
|
|
||||||
|
For now it is not recommended to use persistent data without monitoring performance of ticks afterwards to make sure it was something your server could handle.
|
||||||
|
|
||||||
|
I have a solution in mind to make persistent data not so expensive, but writing the code for that will take some time. This will serve as an interim fix.
|
||||||
|
|
||||||
|
I am going to focus on Tridents & Crossbows instead of that alternative solution, so don't expect it anytime soon. Use persistent data only if you understand the potential performance cost risk.
|
||||||
|
@
|
||||||
|
Version 2.1.148
|
||||||
|
Fixed a memory leak involving entity metadata
|
||||||
|
Alchemy progression is now more reasonable (delete skillranks.yml or edit it yourself to receive the change, see notes)
|
||||||
|
Made some optimizations to combat processing
|
||||||
|
New experience multiplier labeled 'Eggs' in experience.yml with a default value of 0 (previously mobs from eggs were using the Mobspawner experience multiplier)
|
||||||
|
New experience multiplier labeled 'Nether_Portal' in experience.yml with a default value of 0
|
||||||
|
New experience multiplier labeled 'Player_Tamed' in experience.yml with a default value of 0
|
||||||
|
New advanced.yml config setting 'Skills.Mining.SuperBreaker.AllowTripleDrops' defaults to true
|
||||||
|
|
||||||
|
Fixed a bug where mobs from eggs were only tracked if it was dispensed (egg tracking now tracks from egg items as well)
|
||||||
|
Fixed a bug where egg spawned mobs were sometimes not marked as being from an egg (used in experience multipliers)
|
||||||
|
Fixed a bug where entities transformed by a single event (such as lightning) weren't tracked properly if there was more than one entity involved
|
||||||
|
mmodebug now prints out some information about final damage when attacking an entity in certain circumstances
|
||||||
|
|
||||||
|
(1.14+ required)
|
||||||
|
Mobs spawned from mob spawners are tracked persistently and are no longer forgotten about after a restart
|
||||||
|
Tamed mobs are tracked persistently and are no longer forgotten about after a restart
|
||||||
|
Egg spawned mobs are tracked persistently and are no longer forgotten about after a restart
|
||||||
|
Nether Portal spawned mobs are tracked persistently and are no longer forgotten about after a restart
|
||||||
|
Endermen who target endermite are tracked persistently and are no longer forgotten about after a restart
|
||||||
|
COTW spawned mobs are tracked persistently and are no longer forgotten about after a restart
|
||||||
|
Player bred mobs are tracked persistently and are no longer forgotten about after a restart
|
||||||
|
Player tamed mobs are tracked persistently and are no longer forgotten about after a restart
|
||||||
|
|
||||||
|
NOTES:
|
||||||
|
Egg mobs & Nether portal pigs being assigned to the mobspawner xp multiplier didn't make sense to me, so it has been changed. They have their own XP multipliers now.
|
||||||
|
While working on making data persistent I stumbled upon some alarming memory leak candidates, one of them was 7 years old. Sigh.
|
||||||
|
Alchemy now progresses much smoother, with rank 2 no longer unlocking right away. Thanks to Momshroom for pointing out this oddity. Delete skillranks.yml or edit it yourself to recieve this change.
|
||||||
|
https://gist.github.com/nossr50/4c8efc980314781a960a3bdd7bb34f0d This link shows the new Alchemy progression in skillranks.yml feel free to copy paste (or just delete the file and regenerate it)
|
||||||
|
There's no persistent API for entities in Spigot for 1.13.2, but in the future I'll wire up NMS and write it to NBT myself.
|
||||||
|
This means the new persistence stuff requires 1.14.0 or higher, if you're still on 1.13.2 for now that stuff will behave like it always did
|
||||||
|
|
||||||
Version 2.1.147
|
Version 2.1.147
|
||||||
Fixed a bug where players below the level threshold on a hardcore mode enabled server would gain levels on death in certain circumstances
|
Fixed a bug where players below the level threshold on a hardcore mode enabled server would gain levels on death in certain circumstances
|
||||||
|
|
||||||
@ -100,7 +301,7 @@ Version 2.1.146
|
|||||||
|
|
||||||
NOTES:
|
NOTES:
|
||||||
Shout out to Kashike
|
Shout out to Kashike
|
||||||
Kashike is a developer on the mcMMO team, however after I recruited him had a lot of life stuff come at him and hasn't had a chance to contribute until now!
|
Kashike is a developer on the mcMMO team, however after I recruited him had a lot of life stuff come at him and has./tn't had a chance to contribute until now!
|
||||||
|
|
||||||
JSON is used by Minecraft for a lot of stuff, in this case the JSON mcMMO made use of was related to displaying text in chat or displaying text on the clients screen in other places such as the action bar, there's been a bad bug in Spigot since 1.16 that would disconnect players some of the time when sending JSON components.
|
JSON is used by Minecraft for a lot of stuff, in this case the JSON mcMMO made use of was related to displaying text in chat or displaying text on the clients screen in other places such as the action bar, there's been a bad bug in Spigot since 1.16 that would disconnect players some of the time when sending JSON components.
|
||||||
mcMMO makes heavy use of these components, so since spigot has yet to fix the bug I decided we needed a work around for the time being.
|
mcMMO makes heavy use of these components, so since spigot has yet to fix the bug I decided we needed a work around for the time being.
|
||||||
@ -145,7 +346,6 @@ Version 2.1.144
|
|||||||
I was waiting to make Steel Arm Customizable for the config update (due in the future), but enough people ask for it that I decided to do the extra work to put it into 2.1.XX
|
I was waiting to make Steel Arm Customizable for the config update (due in the future), but enough people ask for it that I decided to do the extra work to put it into 2.1.XX
|
||||||
Tridents & Crossbows is likely going to be in development continuing into September, I am taking my time to make it feature packed and I hope you guys will appreciate it.
|
Tridents & Crossbows is likely going to be in development continuing into September, I am taking my time to make it feature packed and I hope you guys will appreciate it.
|
||||||
|
|
||||||
>>>>>>> 2810d36e085d6adaa209a6a119f92504234a0560
|
|
||||||
Version 2.1.143
|
Version 2.1.143
|
||||||
mcMMO now tracks super ability boosted items through persistent metadata
|
mcMMO now tracks super ability boosted items through persistent metadata
|
||||||
mcMMO no longer relies on lore to tell if an item has been modified by a super ability
|
mcMMO no longer relies on lore to tell if an item has been modified by a super ability
|
||||||
@ -165,7 +365,6 @@ Version 2.1.142
|
|||||||
Added locale entry 'Unarmed.SubSkill.SteelArmStyle.Description'
|
Added locale entry 'Unarmed.SubSkill.SteelArmStyle.Description'
|
||||||
Updated locale entry 'Unarmed.Ability.Bonus.0'
|
Updated locale entry 'Unarmed.Ability.Bonus.0'
|
||||||
|
|
||||||
>>>>>>> b35c58ec21f8eaec83f57f11b869fba6765b3856
|
|
||||||
Version 2.1.141
|
Version 2.1.141
|
||||||
Added some missing values for 1.16.2 compatibility modes
|
Added some missing values for 1.16.2 compatibility modes
|
||||||
|
|
||||||
@ -225,7 +424,6 @@ Version 2.1.134
|
|||||||
NOTES:
|
NOTES:
|
||||||
It used to be that Furnaces would assign an owner and that would be their owner until the server shutdown, now owners will change based on who last had their hands on the furnace.
|
It used to be that Furnaces would assign an owner and that would be their owner until the server shutdown, now owners will change based on who last had their hands on the furnace.
|
||||||
You won't become the owner if you are not allowed to view the inventory of a furnace, or break the furnace, or interact with the contents of the furnace
|
You won't become the owner if you are not allowed to view the inventory of a furnace, or break the furnace, or interact with the contents of the furnace
|
||||||
>>>>>>> a28d1cd537caddb07a27ba2b7dd0ed7a37b39a48
|
|
||||||
|
|
||||||
Version 2.1.133
|
Version 2.1.133
|
||||||
A fix for an 'array out of bounds' error related to players clicking outside the inventory windows has been fixed
|
A fix for an 'array out of bounds' error related to players clicking outside the inventory windows has been fixed
|
||||||
@ -1198,7 +1396,7 @@ Version 2.1.43
|
|||||||
|
|
||||||
Version 2.1.42
|
Version 2.1.42
|
||||||
Fixed McMMOPlayerNotFoundException being thrown instead of null
|
Fixed McMMOPlayerNotFoundException being thrown instead of null
|
||||||
(API) mcMMO.getUserManager().getPlayer() returns null again (oopsie)
|
(API) UserManager.getPlayer() returns null again (oopsie)
|
||||||
Added new perk permission node `mcmmo.perks.bypass.salvageenchant` - guarantees full enchantment return for Salvage
|
Added new perk permission node `mcmmo.perks.bypass.salvageenchant` - guarantees full enchantment return for Salvage
|
||||||
Added alternative permission node `mcmmo.perks.bypass.repairenchant` - guarantees full enchantment return for Repair
|
Added alternative permission node `mcmmo.perks.bypass.repairenchant` - guarantees full enchantment return for Repair
|
||||||
Added new wildcard perk `mcmmo.perks.bypass.*` and `mcmmo.perks.bypass.all` (either of these will grant all new mcmmo.perks.bypass perk permissions)
|
Added new wildcard perk `mcmmo.perks.bypass.*` and `mcmmo.perks.bypass.all` (either of these will grant all new mcmmo.perks.bypass perk permissions)
|
||||||
@ -1214,7 +1412,7 @@ Version 2.1.41
|
|||||||
Fixed a display error preventing the remaining time on /mcrank from being shown if it was on cooldown
|
Fixed a display error preventing the remaining time on /mcrank from being shown if it was on cooldown
|
||||||
|
|
||||||
Version 2.1.40
|
Version 2.1.40
|
||||||
(API) mcMMO will now return null in all cases for mcMMO.getUserManager() if they have not been loaded yet
|
(API) mcMMO will now return null in all cases for UserManager.getPlayerProfile() if they have not been loaded yet
|
||||||
(API) Roll stores exploit data in AcrobaticsManager now
|
(API) Roll stores exploit data in AcrobaticsManager now
|
||||||
Added new locale string "Profile.Loading.FailureNotice"
|
Added new locale string "Profile.Loading.FailureNotice"
|
||||||
Added new locale string "Profile.Loading.FailurePlayer"
|
Added new locale string "Profile.Loading.FailurePlayer"
|
||||||
@ -1779,7 +1977,7 @@ Version 1.5.01
|
|||||||
= Fixed bug where pistons would mess with the block tracking
|
= Fixed bug where pistons would mess with the block tracking
|
||||||
= Fixed bug where the Updater was running on the main thread.
|
= Fixed bug where the Updater was running on the main thread.
|
||||||
= Fixed bug when players would use /ptp without being in a party
|
= Fixed bug when players would use /ptp without being in a party
|
||||||
= Fixed bug where player didn't have a mmoPlayer object in AsyncPlayerChatEvent
|
= Fixed bug where player didn't have a mcMMOPlayer object in AsyncPlayerChatEvent
|
||||||
= Fixed bug where dodge would check the wrong player skill level
|
= Fixed bug where dodge would check the wrong player skill level
|
||||||
= Fixed bug which causes /party teleport to stop working
|
= Fixed bug which causes /party teleport to stop working
|
||||||
= Fixed bug where SaveTimerTask would produce an IndexOutOfBoundsException
|
= Fixed bug where SaveTimerTask would produce an IndexOutOfBoundsException
|
||||||
|
54
pom.xml
54
pom.xml
@ -63,8 +63,11 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<compilerArgs>
|
||||||
|
<arg>-parameters</arg> <!-- used for ACF syntax stuff -->
|
||||||
|
</compilerArgs>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
<excludes>
|
<excludes>
|
||||||
@ -91,7 +94,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.1.1</version>
|
<version>3.2.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<artifactSet>
|
<artifactSet>
|
||||||
<includes>
|
<includes>
|
||||||
@ -105,33 +108,45 @@
|
|||||||
<include>net.kyori:adventure-platform-api</include>
|
<include>net.kyori:adventure-platform-api</include>
|
||||||
<include>net.kyori:adventure-platform-common</include>
|
<include>net.kyori:adventure-platform-common</include>
|
||||||
<include>net.kyori:adventure-platform-viaversion</include>
|
<include>net.kyori:adventure-platform-viaversion</include>
|
||||||
|
<include>net.kyori:adventure-platform-facet</include>
|
||||||
<include>net.kyori:adventure-nbt</include>
|
<include>net.kyori:adventure-nbt</include>
|
||||||
<include>net.kyori:examination-api</include>
|
<include>net.kyori:examination-api</include>
|
||||||
<include>net.kyori:examination-string</include>
|
<include>net.kyori:examination-string</include>
|
||||||
<include>net.kyori:adventure-text-serializer-legacy</include>
|
<include>net.kyori:adventure-text-serializer-legacy</include>
|
||||||
<include>net.kyori:adventure-text-serializer-bungeecord</include>
|
<include>net.kyori:adventure-text-serializer-bungeecord</include>
|
||||||
|
<include>net.kyori:adventure-text-serializer-craftbukkit</include>
|
||||||
|
<include>co.aikar:acf-bukkit</include>
|
||||||
</includes>
|
</includes>
|
||||||
</artifactSet>
|
</artifactSet>
|
||||||
|
<!-- <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>-->
|
||||||
<relocations>
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>co.aikar.commands</pattern>
|
||||||
|
<shadedPattern>com.gmail.nossr50.mcmmo.acf</shadedPattern> <!-- Replace this -->
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>co.aikar.locales</pattern>
|
||||||
|
<shadedPattern>com.gmail.nossr50.mcmmo.locales</shadedPattern> <!-- Replace this -->
|
||||||
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>org.apache.commons.logging</pattern>
|
<pattern>org.apache.commons.logging</pattern>
|
||||||
<shadedPattern>com.gmail.nossr50.commons.logging</shadedPattern>
|
<shadedPattern>com.gmail.nossr50.mcmmo.commons.logging</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>org.apache.juli</pattern>
|
<pattern>org.apache.juli</pattern>
|
||||||
<shadedPattern>com.gmail.nossr50.database.tomcat.juli</shadedPattern>
|
<shadedPattern>com.gmail.nossr50.mcmmo.database.tomcat.juli</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>org.apache.tomcat</pattern>
|
<pattern>org.apache.tomcat</pattern>
|
||||||
<shadedPattern>com.gmail.nossr50.database.tomcat</shadedPattern>
|
<shadedPattern>com.gmail.nossr50.mcmmo.database.tomcat</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>net.kyori.adventure</pattern>
|
<pattern>net.kyori.adventure</pattern>
|
||||||
<shadedPattern>com.gmail.nossr50.kyori.adventure</shadedPattern>
|
<shadedPattern>com.gmail.nossr50.mcmmo.kyori.adventure</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>org.bstats</pattern>
|
<pattern>org.bstats</pattern>
|
||||||
<shadedPattern>com.gmail.nossr50.metrics.bstat</shadedPattern>
|
<shadedPattern>com.gmail.nossr50.mcmmo.metrics.bstat</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -166,6 +181,10 @@
|
|||||||
<id>sk89q-repo</id>
|
<id>sk89q-repo</id>
|
||||||
<url>https://maven.sk89q.com/repo/</url>
|
<url>https://maven.sk89q.com/repo/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>aikar</id>
|
||||||
|
<url>https://repo.aikar.co/content/groups/aikar/</url>
|
||||||
|
</repository>
|
||||||
<!-- ... -->
|
<!-- ... -->
|
||||||
<repository> <!-- for development builds -->
|
<repository> <!-- for development builds -->
|
||||||
<id>sonatype-oss</id>
|
<id>sonatype-oss</id>
|
||||||
@ -174,21 +193,26 @@
|
|||||||
<!-- ... -->
|
<!-- ... -->
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>co.aikar</groupId>
|
||||||
|
<artifactId>acf-bukkit</artifactId> <!-- Don't forget to replace this -->
|
||||||
|
<version>0.5.0-SNAPSHOT</version> <!-- Replace this as well -->
|
||||||
|
</dependency>
|
||||||
<!-- adventure-api, adventure-text-serializer-gson, adventure-platform-bukkit-->
|
<!-- adventure-api, adventure-text-serializer-gson, adventure-platform-bukkit-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-text-serializer-gson</artifactId>
|
<artifactId>adventure-text-serializer-gson</artifactId>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<version>4.2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-api</artifactId>
|
<artifactId>adventure-api</artifactId>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<version>4.2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-nbt</artifactId>
|
<artifactId>adventure-nbt</artifactId>
|
||||||
<version>4.0.0-SNAPSHOT</version>
|
<version>4.2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
@ -219,13 +243,21 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.16.2-R0.1-SNAPSHOT</version>
|
<version>1.16.4-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q.worldguard</groupId>
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
<artifactId>worldguard-core</artifactId>
|
<artifactId>worldguard-core</artifactId>
|
||||||
<version>7.0.1-SNAPSHOT</version>
|
<version>7.0.1-SNAPSHOT</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<!-- We use jetbrains instead. Excluding this -->
|
||||||
|
<!-- prevents us from using inconsistent annotations -->
|
||||||
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
|
<artifactId>jsr305</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q.worldguard</groupId>
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
|
@ -1,79 +1,41 @@
|
|||||||
package com.gmail.nossr50.api;
|
package com.gmail.nossr50.api;
|
||||||
|
|
||||||
import com.gmail.nossr50.chat.ChatManager;
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
import com.gmail.nossr50.chat.ChatManagerFactory;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.chat.PartyChatManager;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public final class ChatAPI {
|
public final class ChatAPI {
|
||||||
private ChatAPI() {}
|
private ChatAPI() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message to all members of a party
|
* Check if a {@link Player} is in the Party chat channel
|
||||||
* </br>
|
|
||||||
* This function is designed for API usage.
|
|
||||||
*
|
*
|
||||||
* @param plugin The plugin sending the message
|
* @param player target player
|
||||||
* @param sender The name of the sender
|
* @return true if the player is targeting the party chat channel
|
||||||
* @param displayName The display name of the sender
|
* @deprecated Use {@link #isUsingPartyChat(McMMOPlayer)} instead
|
||||||
* @param party The name of the party to send to
|
|
||||||
* @param message The message to send
|
|
||||||
*/
|
*/
|
||||||
public static void sendPartyChat(Plugin plugin, String sender, String displayName, String party, String message) {
|
@Deprecated
|
||||||
getPartyChatManager(plugin, party).handleChat(sender, displayName, message);
|
public static boolean isUsingPartyChat(@NotNull Player player) {
|
||||||
|
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
|
||||||
|
|
||||||
|
if(mmoPlayer != null)
|
||||||
|
return mmoPlayer.getChatChannel() == ChatChannel.PARTY;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message to all members of a party
|
* Check if a {@link McMMOPlayer} is in the Party chat channel
|
||||||
* </br>
|
|
||||||
* This function is designed for API usage.
|
|
||||||
*
|
*
|
||||||
* @param plugin The plugin sending the message
|
* @param mmoPlayer target player
|
||||||
* @param sender The name of the sender to display in the chat
|
* @return true if the player is targeting the party chat channel
|
||||||
* @param party The name of the party to send to
|
|
||||||
* @param message The message to send
|
|
||||||
*/
|
*/
|
||||||
public static void sendPartyChat(Plugin plugin, String sender, String party, String message) {
|
public static boolean isUsingPartyChat(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
getPartyChatManager(plugin, party).handleChat(sender, message);
|
return mmoPlayer.getChatChannel() == ChatChannel.PARTY;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a message to administrators
|
|
||||||
* </br>
|
|
||||||
* This function is designed for API usage.
|
|
||||||
*
|
|
||||||
* @param plugin The plugin sending the message
|
|
||||||
* @param sender The name of the sender
|
|
||||||
* @param displayName The display name of the sender
|
|
||||||
* @param message The message to send
|
|
||||||
*/
|
|
||||||
public static void sendAdminChat(Plugin plugin, String sender, String displayName, String message) {
|
|
||||||
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, displayName, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a message to administrators
|
|
||||||
* </br>
|
|
||||||
* This function is designed for API usage.
|
|
||||||
*
|
|
||||||
* @param plugin The plugin sending the message
|
|
||||||
* @param sender The name of the sender to display in the chat
|
|
||||||
* @param message The message to send
|
|
||||||
*/
|
|
||||||
public static void sendAdminChat(Plugin plugin, String sender, String message) {
|
|
||||||
ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN).handleChat(sender, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a player is currently talking in party chat.
|
|
||||||
*
|
|
||||||
* @param player The player to check
|
|
||||||
* @return true if the player is using party chat, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean isUsingPartyChat(Player player) {
|
|
||||||
return mcMMO.getUserManager().getPlayer(player).isChatEnabled(ChatMode.PARTY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,19 +43,42 @@ public final class ChatAPI {
|
|||||||
*
|
*
|
||||||
* @param playerName The name of the player to check
|
* @param playerName The name of the player to check
|
||||||
* @return true if the player is using party chat, false otherwise
|
* @return true if the player is using party chat, false otherwise
|
||||||
|
* @deprecated use {@link #isUsingPartyChat(McMMOPlayer)} instead for performance reasons
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static boolean isUsingPartyChat(String playerName) {
|
public static boolean isUsingPartyChat(String playerName) {
|
||||||
return mcMMO.getUserManager().getPlayer(playerName).isChatEnabled(ChatMode.PARTY);
|
if(mcMMO.getUserManager().queryMcMMOPlayer(playerName) != null) {
|
||||||
|
return mcMMO.getUserManager().queryMcMMOPlayer(playerName).getChatChannel() == ChatChannel.PARTY;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a player is currently talking in admin chat.
|
* Check if a {@link Player} is in the Admin chat channel
|
||||||
*
|
*
|
||||||
* @param player The player to check
|
* @param player target player
|
||||||
* @return true if the player is using admin chat, false otherwise
|
* @return true if the player is targeting the admin chat channel
|
||||||
|
* @deprecated Use {@link #isUsingAdminChat(McMMOPlayer)} instead
|
||||||
*/
|
*/
|
||||||
public static boolean isUsingAdminChat(Player player) {
|
@Deprecated
|
||||||
return mcMMO.getUserManager().getPlayer(player).isChatEnabled(ChatMode.ADMIN);
|
public static boolean isUsingAdminChat(@NotNull Player player) {
|
||||||
|
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
|
||||||
|
|
||||||
|
if(mmoPlayer != null)
|
||||||
|
return mmoPlayer.getChatChannel() == ChatChannel.ADMIN;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a {@link McMMOPlayer} is in the Admin chat channel
|
||||||
|
*
|
||||||
|
* @param mmoPlayer target player
|
||||||
|
* @return true if the player is targeting the admin chat channel
|
||||||
|
*/
|
||||||
|
public static boolean isUsingAdminChat(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
|
return mmoPlayer.getChatChannel() == ChatChannel.ADMIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,51 +86,76 @@ public final class ChatAPI {
|
|||||||
*
|
*
|
||||||
* @param playerName The name of the player to check
|
* @param playerName The name of the player to check
|
||||||
* @return true if the player is using admin chat, false otherwise
|
* @return true if the player is using admin chat, false otherwise
|
||||||
|
* @deprecated use {@link #isUsingAdminChat(McMMOPlayer)} instead for performance reasons
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static boolean isUsingAdminChat(String playerName) {
|
public static boolean isUsingAdminChat(String playerName) {
|
||||||
return mcMMO.getUserManager().getPlayer(playerName).isChatEnabled(ChatMode.ADMIN);
|
if(mcMMO.getUserManager().queryMcMMOPlayer(playerName) != null) {
|
||||||
|
return mcMMO.getUserManager().queryMcMMOPlayer(playerName).getChatChannel() == ChatChannel.ADMIN;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle the party chat channel of a {@link McMMOPlayer}
|
||||||
|
*
|
||||||
|
* @param mmoPlayer The player to toggle party chat on.
|
||||||
|
*/
|
||||||
|
public static void togglePartyChat(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
|
mcMMO.p.getChatManager().setOrToggleChatChannel(mmoPlayer, ChatChannel.PARTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle the party chat mode of a player.
|
* Toggle the party chat mode of a player.
|
||||||
*
|
*
|
||||||
* @param player The player to toggle party chat on.
|
* @param player The player to toggle party chat on.
|
||||||
|
* @deprecated use {@link #togglePartyChat(McMMOPlayer)}
|
||||||
*/
|
*/
|
||||||
public static void togglePartyChat(Player player) {
|
@Deprecated
|
||||||
mcMMO.getUserManager().getPlayer(player).toggleChat(ChatMode.PARTY);
|
public static void togglePartyChat(Player player) throws NullPointerException {
|
||||||
|
mcMMO.p.getChatManager().setOrToggleChatChannel(Objects.requireNonNull(mcMMO.getUserManager().queryMcMMOPlayer(player)), ChatChannel.PARTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle the party chat mode of a player.
|
* Toggle the party chat mode of a player.
|
||||||
*
|
*
|
||||||
* @param playerName The name of the player to toggle party chat on.
|
* @param playerName The name of the player to toggle party chat on.
|
||||||
|
* @deprecated Use {@link #togglePartyChat(McMMOPlayer)} instead
|
||||||
*/
|
*/
|
||||||
public static void togglePartyChat(String playerName) {
|
@Deprecated
|
||||||
mcMMO.getUserManager().getPlayer(playerName).toggleChat(ChatMode.PARTY);
|
public static void togglePartyChat(String playerName) throws NullPointerException {
|
||||||
|
mcMMO.p.getChatManager().setOrToggleChatChannel(Objects.requireNonNull(mcMMO.getUserManager().queryMcMMOPlayer(playerName)), ChatChannel.PARTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle the admin chat channel of a {@link McMMOPlayer}
|
||||||
|
*
|
||||||
|
* @param mmoPlayer The player to toggle admin chat on.
|
||||||
|
*/
|
||||||
|
public static void toggleAdminChat(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
|
mcMMO.p.getChatManager().setOrToggleChatChannel(mmoPlayer, ChatChannel.ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle the admin chat mode of a player.
|
* Toggle the admin chat mode of a player.
|
||||||
*
|
*
|
||||||
* @param player The player to toggle admin chat on.
|
* @param player The player to toggle admin chat on.
|
||||||
|
* @deprecated Use {@link #toggleAdminChat(McMMOPlayer)} instead
|
||||||
*/
|
*/
|
||||||
public static void toggleAdminChat(Player player) {
|
@Deprecated
|
||||||
mcMMO.getUserManager().getPlayer(player).toggleChat(ChatMode.ADMIN);
|
public static void toggleAdminChat(Player player) throws NullPointerException {
|
||||||
|
mcMMO.p.getChatManager().setOrToggleChatChannel(Objects.requireNonNull(mcMMO.getUserManager().queryMcMMOPlayer(player)), ChatChannel.ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggle the admin chat mode of a player.
|
* Toggle the admin chat mode of a player.
|
||||||
*
|
*
|
||||||
* @param playerName The name of the player to toggle party chat on.
|
* @param playerName The name of the player to toggle party chat on.
|
||||||
|
* @deprecated Use {@link #toggleAdminChat(McMMOPlayer)} instead
|
||||||
*/
|
*/
|
||||||
public static void toggleAdminChat(String playerName) {
|
@Deprecated
|
||||||
mcMMO.getUserManager().getPlayer(playerName).toggleChat(ChatMode.ADMIN);
|
public static void toggleAdminChat(String playerName) throws NullPointerException {
|
||||||
}
|
mcMMO.p.getChatManager().setOrToggleChatChannel(Objects.requireNonNull(mcMMO.getUserManager().queryMcMMOPlayer(playerName)), ChatChannel.ADMIN);
|
||||||
|
|
||||||
private static ChatManager getPartyChatManager(Plugin plugin, String party) {
|
|
||||||
ChatManager chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY);
|
|
||||||
((PartyChatManager) chatManager).setParty(mcMMO.getPartyManager().getParty(party));
|
|
||||||
|
|
||||||
return chatManager;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
src/main/java/com/gmail/nossr50/api/ItemSpawnReason.java
Normal file
17
src/main/java/com/gmail/nossr50/api/ItemSpawnReason.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package com.gmail.nossr50.api;
|
||||||
|
|
||||||
|
public enum ItemSpawnReason {
|
||||||
|
ARROW_RETRIEVAL_ACTIVATED, //Players sometimes can retrieve arrows instead of losing them when hitting a mob
|
||||||
|
EXCAVATION_TREASURE, //Any drops when excavation treasures activate fall under this
|
||||||
|
FISHING_EXTRA_FISH, //A config setting allows more fish to be found when fishing, the extra fish are part of this
|
||||||
|
FISHING_SHAKE_TREASURE, //When using a fishing rod on a mob and finding a treasure via Shake
|
||||||
|
HYLIAN_LUCK_TREASURE, //When finding a treasure in grass via hylian luck
|
||||||
|
BLAST_MINING_DEBRIS_NON_ORES, //The non-ore debris that are dropped from blast mining
|
||||||
|
BLAST_MINING_ORES, //The ore(s) which may include player placed ores being dropped from blast mining
|
||||||
|
BLAST_MINING_ORES_BONUS_DROP, //Any bonus ores that drop from a result of a players Mining skills
|
||||||
|
UNARMED_DISARMED_ITEM, //When you disarm an opponent and they drop their weapon
|
||||||
|
SALVAGE_ENCHANTMENT_BOOK, //When you salvage an enchanted item and get the enchantment back in book form
|
||||||
|
SALVAGE_MATERIALS, //When you salvage an item and get materials back
|
||||||
|
TREE_FELLER_DISPLACED_BLOCK,
|
||||||
|
BONUS_DROPS, //Can be from Mining, Woodcutting, Herbalism, etc
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.gmail.nossr50.api.exceptions;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class IncompleteNamespacedKeyRegister extends RuntimeException {
|
||||||
|
private static final long serialVersionUID = -6905157273569301219L;
|
||||||
|
|
||||||
|
public IncompleteNamespacedKeyRegister(@NotNull String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
@ -6,4 +6,8 @@ public class InvalidSkillException extends RuntimeException {
|
|||||||
public InvalidSkillException() {
|
public InvalidSkillException() {
|
||||||
super("That is not a valid skill.");
|
super("That is not a valid skill.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public InvalidSkillException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package com.gmail.nossr50.api.exceptions;
|
package com.gmail.nossr50.api.exceptions;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class McMMOPlayerNotFoundException extends RuntimeException {
|
public class McMMOPlayerNotFoundException extends RuntimeException {
|
||||||
private static final long serialVersionUID = 761917904993202836L;
|
private static final long serialVersionUID = 761917904993202836L;
|
||||||
|
|
||||||
public McMMOPlayerNotFoundException(Player player) {
|
public McMMOPlayerNotFoundException(@NotNull Player player) {
|
||||||
super("McMMOPlayer object was not found for [NOTE: This can mean the profile is not loaded yet!] : " + player.getName() + " " + player.getUniqueId());
|
super("McMMOPlayer object was not found for [NOTE: This can mean the profile is not loaded yet!] : " + player.getName() + " " + player.getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package com.gmail.nossr50.chat;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
public class AdminChatManager extends ChatManager {
|
|
||||||
protected AdminChatManager(Plugin plugin) {
|
|
||||||
super(plugin, Config.getInstance().getAdminDisplayNames(), Config.getInstance().getAdminChatPrefix());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleChat(String senderName, String displayName, String message, boolean isAsync) {
|
|
||||||
handleChat(new McMMOAdminChatEvent(plugin, senderName, displayName, message, isAsync));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void sendMessage() {
|
|
||||||
plugin.getServer().broadcast(message, "mcmmo.chat.adminchat");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,87 +1,225 @@
|
|||||||
package com.gmail.nossr50.chat;
|
package com.gmail.nossr50.chat;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.chat.author.Author;
|
||||||
|
import com.gmail.nossr50.chat.author.ConsoleAuthor;
|
||||||
|
import com.gmail.nossr50.chat.mailer.AdminChatMailer;
|
||||||
|
import com.gmail.nossr50.chat.mailer.PartyChatMailer;
|
||||||
|
import com.gmail.nossr50.config.ChatConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.events.chat.McMMOChatEvent;
|
|
||||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import org.bukkit.entity.Player;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import org.bukkit.plugin.Plugin;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public abstract class ChatManager {
|
//TODO: Micro optimization - Cache audiences and update cache when needed
|
||||||
protected Plugin plugin;
|
public class ChatManager {
|
||||||
protected boolean useDisplayNames;
|
|
||||||
protected String chatPrefix;
|
|
||||||
|
|
||||||
protected String senderName;
|
private final @NotNull AdminChatMailer adminChatMailer;
|
||||||
protected String displayName;
|
private final @NotNull PartyChatMailer partyChatMailer;
|
||||||
protected String message;
|
|
||||||
|
|
||||||
protected ChatManager(Plugin plugin, boolean useDisplayNames, String chatPrefix) {
|
private final @NotNull ConsoleAuthor consoleAuthor;
|
||||||
this.plugin = plugin;
|
private final @NotNull Audience consoleAudience;
|
||||||
this.useDisplayNames = useDisplayNames;
|
|
||||||
this.chatPrefix = chatPrefix;
|
private final boolean isChatEnabled;
|
||||||
|
|
||||||
|
public ChatManager(@NotNull mcMMO pluginRef) {
|
||||||
|
adminChatMailer = new AdminChatMailer(pluginRef);
|
||||||
|
partyChatMailer = new PartyChatMailer(pluginRef);
|
||||||
|
|
||||||
|
this.consoleAuthor = new ConsoleAuthor(LocaleLoader.getString("Chat.Identity.Console"));
|
||||||
|
this.consoleAudience = mcMMO.getAudiences().filter((cs) -> cs instanceof ConsoleCommandSender);
|
||||||
|
this.isChatEnabled = ChatConfig.getInstance().isChatEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleChat(McMMOChatEvent event) {
|
/**
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
* Handles player messaging when they are either in party chat or admin chat modes
|
||||||
|
*
|
||||||
if (event.isCancelled()) {
|
* @param mmoPlayer target player
|
||||||
return;
|
* @param rawMessage the raw message from the player as it was typed
|
||||||
}
|
* @param isAsync whether or not this is getting processed via async
|
||||||
|
|
||||||
senderName = event.getSender();
|
|
||||||
displayName = useDisplayNames ? event.getDisplayName() : senderName;
|
|
||||||
message = LocaleLoader.formatString(chatPrefix, displayName) + " " + event.getMessage();
|
|
||||||
|
|
||||||
sendMessage();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Party Chat Spying
|
|
||||||
* Party messages will be copied to people with the mcmmo.admin.chatspy permission node
|
|
||||||
*/
|
*/
|
||||||
if(event instanceof McMMOPartyChatEvent)
|
public void processPlayerMessage(@NotNull McMMOPlayer mmoPlayer, @NotNull String rawMessage, boolean isAsync) {
|
||||||
{
|
processPlayerMessage(mmoPlayer, mmoPlayer.getChatChannel(), rawMessage, isAsync);
|
||||||
//We need to grab the party chat name
|
}
|
||||||
McMMOPartyChatEvent partyChatEvent = (McMMOPartyChatEvent) event;
|
|
||||||
|
|
||||||
//Find the people with permissions
|
/**
|
||||||
for(McMMOPlayer mmoPlayer : mcMMO.getUserManager().getPlayers())
|
* Handles player messaging for a specific chat channel
|
||||||
{
|
*
|
||||||
Player player = mmoPlayer.getPlayer();
|
* @param mmoPlayer target player
|
||||||
|
* @param args the raw command arguments from the player
|
||||||
|
* @param chatChannel target channel
|
||||||
|
*/
|
||||||
|
public void processPlayerMessage(@NotNull McMMOPlayer mmoPlayer, @NotNull String[] args, @NotNull ChatChannel chatChannel) {
|
||||||
|
String chatMessageWithoutCommand = buildChatMessage(args);
|
||||||
|
|
||||||
//Check for toggled players
|
//Commands are never async
|
||||||
if(mmoPlayer.isPartyChatSpying())
|
processPlayerMessage(mmoPlayer, chatChannel, chatMessageWithoutCommand, false);
|
||||||
{
|
}
|
||||||
Party adminParty = mmoPlayer.getParty();
|
|
||||||
|
|
||||||
//Only message admins not part of this party
|
/**
|
||||||
if(adminParty != null)
|
* Handles player messaging for a specific chat channel
|
||||||
{
|
*
|
||||||
//TODO: Incorporate JSON
|
* @param mmoPlayer target player
|
||||||
if(!adminParty.getPartyName().equalsIgnoreCase(partyChatEvent.getParty()))
|
* @param chatChannel target chat channel
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Chat", partyChatEvent.getParty(), message));
|
* @param rawMessage raw chat message as it was typed
|
||||||
|
* @param isAsync whether or not this is getting processed via async
|
||||||
|
*/
|
||||||
|
private void processPlayerMessage(@NotNull McMMOPlayer mmoPlayer, @NotNull ChatChannel chatChannel, @NotNull String rawMessage, boolean isAsync) {
|
||||||
|
switch (chatChannel) {
|
||||||
|
case ADMIN:
|
||||||
|
adminChatMailer.processChatMessage(mmoPlayer.getPlayerAuthor(), rawMessage, isAsync, Permissions.colorChat(mmoPlayer.getPlayer()));
|
||||||
|
break;
|
||||||
|
case PARTY:
|
||||||
|
partyChatMailer.processChatMessage(mmoPlayer.getPlayerAuthor(), rawMessage, mmoPlayer.getParty(), isAsync, Permissions.colorChat(mmoPlayer.getPlayer()), Misc.isPartyLeader(mmoPlayer));
|
||||||
|
break;
|
||||||
|
case PARTY_OFFICER:
|
||||||
|
case NONE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles console messaging to admins
|
||||||
|
* @param rawMessage raw message from the console
|
||||||
|
*/
|
||||||
|
public void processConsoleMessage(@NotNull String rawMessage) {
|
||||||
|
adminChatMailer.processChatMessage(getConsoleAuthor(), rawMessage, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles console messaging to admins
|
||||||
|
* @param args raw command args from the console
|
||||||
|
*/
|
||||||
|
public void processConsoleMessage(@NotNull String[] args) {
|
||||||
|
processConsoleMessage(buildChatMessage(args));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles console messaging to a specific party
|
||||||
|
* @param rawMessage raw message from the console
|
||||||
|
* @param party target party
|
||||||
|
*/
|
||||||
|
public void processConsoleMessage(@NotNull String rawMessage, @NotNull Party party) {
|
||||||
|
partyChatMailer.processChatMessage(getConsoleAuthor(), rawMessage, party, false, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a console author
|
||||||
|
* @return a {@link ConsoleAuthor}
|
||||||
|
*/
|
||||||
|
private @NotNull Author getConsoleAuthor() {
|
||||||
|
return consoleAuthor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the chat channel of a {@link McMMOPlayer}
|
||||||
|
* Targeting the channel a player is already in will remove that player from the chat channel
|
||||||
|
* @param mmoPlayer target player
|
||||||
|
* @param targetChatChannel target chat channel
|
||||||
|
*/
|
||||||
|
public void setOrToggleChatChannel(@NotNull McMMOPlayer mmoPlayer, @NotNull ChatChannel targetChatChannel) {
|
||||||
|
if(targetChatChannel == mmoPlayer.getChatChannel()) {
|
||||||
|
//Disabled message
|
||||||
|
mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Chat.Channel.Off", StringUtils.getCapitalized(targetChatChannel.toString())));
|
||||||
|
mmoPlayer.setChatMode(ChatChannel.NONE);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.AdminChatSpy.Chat", partyChatEvent.getParty(), message));
|
mmoPlayer.setChatMode(targetChatChannel);
|
||||||
|
mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Chat.Channel.On", StringUtils.getCapitalized(targetChatChannel.toString())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a chat message from an array of {@link String}
|
||||||
|
* @param args array of {@link String}
|
||||||
|
* @return a String built from the array
|
||||||
|
*/
|
||||||
|
private @NotNull String buildChatMessage(@NotNull String[] args) {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
for(int i = 0; i < args.length; i++) {
|
||||||
|
if(i + 1 >= args.length) {
|
||||||
|
stringBuilder.append(args[i]);
|
||||||
|
} else {
|
||||||
|
stringBuilder.append(args[i]).append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringBuilder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the player is allowed to send a message to the chat channel they are targeting
|
||||||
|
* @param mmoPlayer target player
|
||||||
|
* @return true if the player can send messages to that chat channel
|
||||||
|
*/
|
||||||
|
public boolean isMessageAllowed(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
|
switch (mmoPlayer.getChatChannel()) {
|
||||||
|
case ADMIN:
|
||||||
|
if(mmoPlayer.getPlayer().isOp() || Permissions.adminChat(mmoPlayer.getPlayer())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PARTY:
|
||||||
|
if(mmoPlayer.getParty() != null && Permissions.partyChat(mmoPlayer.getPlayer())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PARTY_OFFICER:
|
||||||
|
case NONE:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends just the console a message
|
||||||
|
* @param author author of the message
|
||||||
|
* @param message message contents in component form
|
||||||
|
*/
|
||||||
|
public void sendConsoleMessage(@NotNull Author author, @NotNull TextComponent message) {
|
||||||
|
consoleAudience.sendMessage(author, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the mcMMO chat system which handles party and admin chat is enabled or disabled
|
||||||
|
* @return true if mcMMO chat processing (for party/admin chat) is enabled
|
||||||
|
*/
|
||||||
|
public boolean isChatEnabled() {
|
||||||
|
return isChatEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not a specific chat channel is enabled
|
||||||
|
* ChatChannels are enabled/disabled via user config
|
||||||
|
*
|
||||||
|
* If chat is disabled, this always returns false
|
||||||
|
* If NONE is passed as a {@link ChatChannel} it will return true
|
||||||
|
* @param chatChannel target chat channel
|
||||||
|
* @return true if the chat channel is enabled
|
||||||
|
*/
|
||||||
|
public boolean isChatChannelEnabled(@NotNull ChatChannel chatChannel) {
|
||||||
|
if(!isChatEnabled) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
switch(chatChannel) {
|
||||||
|
case ADMIN:
|
||||||
|
case PARTY:
|
||||||
|
case PARTY_OFFICER:
|
||||||
|
return ChatConfig.getInstance().isChatChannelEnabled(chatChannel);
|
||||||
|
case NONE:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleChat(String senderName, String message) {
|
|
||||||
handleChat(senderName, senderName, message, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleChat(Player player, String message, boolean isAsync) {
|
|
||||||
handleChat(player.getName(), player.getDisplayName(), message, isAsync);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleChat(String senderName, String displayName, String message) {
|
|
||||||
handleChat(senderName, displayName, message, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void handleChat(String senderName, String displayName, String message, boolean isAsync);
|
|
||||||
|
|
||||||
protected abstract void sendMessage();
|
|
||||||
}
|
}
|
@ -1,30 +0,0 @@
|
|||||||
package com.gmail.nossr50.chat;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class ChatManagerFactory {
|
|
||||||
private static final HashMap<Plugin, AdminChatManager> adminChatManagers = new HashMap<>();
|
|
||||||
private static final HashMap<Plugin, PartyChatManager> partyChatManagers = new HashMap<>();
|
|
||||||
|
|
||||||
public static ChatManager getChatManager(Plugin plugin, ChatMode mode) {
|
|
||||||
switch (mode) {
|
|
||||||
case ADMIN:
|
|
||||||
if (!adminChatManagers.containsKey(plugin)) {
|
|
||||||
adminChatManagers.put(plugin, new AdminChatManager(plugin));
|
|
||||||
}
|
|
||||||
|
|
||||||
return adminChatManagers.get(plugin);
|
|
||||||
case PARTY:
|
|
||||||
if (!partyChatManagers.containsKey(plugin)) {
|
|
||||||
partyChatManagers.put(plugin, new PartyChatManager(plugin));
|
|
||||||
}
|
|
||||||
|
|
||||||
return partyChatManagers.get(plugin);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package com.gmail.nossr50.chat;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
|
||||||
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
|
||||||
import com.gmail.nossr50.runnables.party.PartyChatTask;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
public class PartyChatManager extends ChatManager {
|
|
||||||
private Party party;
|
|
||||||
|
|
||||||
protected PartyChatManager(Plugin plugin) {
|
|
||||||
super(plugin, Config.getInstance().getPartyDisplayNames(), Config.getInstance().getPartyChatPrefix());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParty(Party party) {
|
|
||||||
this.party = party;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handleChat(String senderName, String displayName, String message, boolean isAsync) {
|
|
||||||
handleChat(new McMMOPartyChatEvent(plugin, senderName, displayName, party.getPartyName(), message, isAsync));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void sendMessage() {
|
|
||||||
new PartyChatTask(plugin, party, senderName, displayName, message).runTask(plugin);
|
|
||||||
}
|
|
||||||
}
|
|
36
src/main/java/com/gmail/nossr50/chat/SamePartyPredicate.java
Normal file
36
src/main/java/com/gmail/nossr50/chat/SamePartyPredicate.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package com.gmail.nossr50.chat;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
public class SamePartyPredicate<T extends CommandSender> implements Predicate<T> {
|
||||||
|
|
||||||
|
final Party party;
|
||||||
|
|
||||||
|
public SamePartyPredicate(Party party) {
|
||||||
|
this.party = party;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean test(T t) {
|
||||||
|
//Include the console in the audience
|
||||||
|
if(t instanceof ConsoleCommandSender) {
|
||||||
|
return false; //Party audiences are special, we exclude console from them to avoid double messaging since we send a more verbose version to consoles
|
||||||
|
} else {
|
||||||
|
if(t instanceof Player) {
|
||||||
|
Player player = (Player) t;
|
||||||
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
|
if(mcMMOPlayer != null) {
|
||||||
|
return mcMMOPlayer.getParty() == party;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,120 @@
|
|||||||
|
package com.gmail.nossr50.chat.author;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
|
import com.gmail.nossr50.util.text.TextUtils;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public abstract class AbstractPlayerAuthor implements Author {
|
||||||
|
private final @NotNull Player player;
|
||||||
|
private @NotNull String lastKnownDisplayName;
|
||||||
|
private final @NotNull HashMap<ChatChannel, String> sanitizedNameCache;
|
||||||
|
|
||||||
|
public AbstractPlayerAuthor(@NotNull Player player) {
|
||||||
|
this.player = player;
|
||||||
|
this.lastKnownDisplayName = player.getDisplayName();
|
||||||
|
this.sanitizedNameCache = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if a players display name has changed
|
||||||
|
*
|
||||||
|
* @return true if the players display name has changed
|
||||||
|
*/
|
||||||
|
private boolean hasPlayerDisplayNameChanged() {
|
||||||
|
return !player.getDisplayName().equals(lastKnownDisplayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Player display names can change and this method will update the last known display name of this player
|
||||||
|
*/
|
||||||
|
private void updateLastKnownDisplayName() {
|
||||||
|
lastKnownDisplayName = player.getDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a sanitized name for a channel
|
||||||
|
* Sanitized names are names that are friendly to the {@link net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer}
|
||||||
|
* Sanitized names for authors are cached by channel and are only created as needed
|
||||||
|
* Sanitized names will update if a players display name has updated
|
||||||
|
*
|
||||||
|
* @param chatChannel target chat channel
|
||||||
|
* @return the sanitized name for a player
|
||||||
|
*/
|
||||||
|
protected @NotNull String getSanitizedName(@NotNull ChatChannel chatChannel, boolean useDisplayName) {
|
||||||
|
//Already in cache
|
||||||
|
if(sanitizedNameCache.containsKey(chatChannel)) {
|
||||||
|
//Update cache
|
||||||
|
if(useDisplayName && hasPlayerDisplayNameChanged()) {
|
||||||
|
updateLastKnownDisplayName();
|
||||||
|
updateSanitizedNameCache(chatChannel, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//Update last known display name
|
||||||
|
if(useDisplayName && hasPlayerDisplayNameChanged()) {
|
||||||
|
updateLastKnownDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add cache entry
|
||||||
|
updateSanitizedNameCache(chatChannel, useDisplayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sanitizedNameCache.get(chatChannel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the sanitized name cache
|
||||||
|
* This will add entries if one didn't exit
|
||||||
|
* Sanitized names are associated with a {@link ChatChannel} as different chat channels have different chat name settings
|
||||||
|
*
|
||||||
|
* @param chatChannel target chat channel
|
||||||
|
* @param useDisplayName whether or not to use this authors display name
|
||||||
|
*/
|
||||||
|
private void updateSanitizedNameCache(@NotNull ChatChannel chatChannel, boolean useDisplayName) {
|
||||||
|
if(useDisplayName) {
|
||||||
|
sanitizedNameCache.put(chatChannel, TextUtils.sanitizeForSerializer(player.getDisplayName()));
|
||||||
|
} else {
|
||||||
|
//No need to sanitize a basic String
|
||||||
|
sanitizedNameCache.put(chatChannel, player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConsole() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPlayer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull UUID uuid() {
|
||||||
|
return player.getUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
AbstractPlayerAuthor that = (AbstractPlayerAuthor) o;
|
||||||
|
return Objects.equal(player, that.player) &&
|
||||||
|
Objects.equal(lastKnownDisplayName, that.lastKnownDisplayName) &&
|
||||||
|
Objects.equal(sanitizedNameCache, that.sanitizedNameCache);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(player, lastKnownDisplayName, sanitizedNameCache);
|
||||||
|
}
|
||||||
|
}
|
31
src/main/java/com/gmail/nossr50/chat/author/Author.java
Normal file
31
src/main/java/com/gmail/nossr50/chat/author/Author.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package com.gmail.nossr50.chat.author;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
|
import net.kyori.adventure.identity.Identity;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public interface Author extends Identity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of this author as used in mcMMO chat
|
||||||
|
* This is the {@link String} representation of the users current chat username
|
||||||
|
* This can either be the player's display name or the player's official registered nickname with Mojang it depends on the servers chat settings for mcMMO
|
||||||
|
*
|
||||||
|
* @param chatChannel which chat channel this is going to
|
||||||
|
* @return The name of this author as used in mcMMO chat
|
||||||
|
*/
|
||||||
|
@NotNull String getAuthoredName(@NotNull ChatChannel chatChannel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not this author is a {@link org.bukkit.command.ConsoleCommandSender}
|
||||||
|
*
|
||||||
|
* @return true if this author is the console
|
||||||
|
*/
|
||||||
|
boolean isConsole();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not this author is a {@link org.bukkit.entity.Player}
|
||||||
|
* @return true if this author is a player
|
||||||
|
*/
|
||||||
|
boolean isPlayer();
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.gmail.nossr50.chat.author;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
|
import com.gmail.nossr50.util.text.TextUtils;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class ConsoleAuthor implements Author {
|
||||||
|
private final UUID uuid;
|
||||||
|
private final @NotNull String name;
|
||||||
|
|
||||||
|
public ConsoleAuthor(@NotNull String name) {
|
||||||
|
this.uuid = new UUID(0, 0);
|
||||||
|
this.name = TextUtils.sanitizeForSerializer(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Think of a less clunky solution later
|
||||||
|
@Override
|
||||||
|
public @NotNull String getAuthoredName(@NotNull ChatChannel chatChannel) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isConsole() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPlayer() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull UUID uuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package com.gmail.nossr50.chat.author;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.ChatConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class PlayerAuthor extends AbstractPlayerAuthor {
|
||||||
|
|
||||||
|
public PlayerAuthor(@NotNull Player player) {
|
||||||
|
super(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getAuthoredName(@NotNull ChatChannel chatChannel) {
|
||||||
|
return getSanitizedName(chatChannel, ChatConfig.getInstance().useDisplayNames(chatChannel));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.gmail.nossr50.chat.mailer;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
||||||
|
public abstract class AbstractChatMailer implements ChatMailer {
|
||||||
|
protected final @NotNull Plugin pluginRef;
|
||||||
|
|
||||||
|
public AbstractChatMailer(@NotNull Plugin pluginRef) {
|
||||||
|
this.pluginRef = pluginRef;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
package com.gmail.nossr50.chat.mailer;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.chat.author.Author;
|
||||||
|
import com.gmail.nossr50.chat.message.AdminChatMessage;
|
||||||
|
import com.gmail.nossr50.chat.message.ChatMessage;
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
|
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||||
|
import com.gmail.nossr50.events.chat.McMMOChatEvent;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.text.TextUtils;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
public class AdminChatMailer extends AbstractChatMailer {
|
||||||
|
|
||||||
|
public AdminChatMailer(Plugin pluginRef) {
|
||||||
|
super(pluginRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final @NotNull String MCMMO_CHAT_ADMINCHAT_PERMISSION = "mcmmo.chat.adminchat";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an audience of admins
|
||||||
|
*
|
||||||
|
* @return an audience of admins
|
||||||
|
*/
|
||||||
|
public @NotNull Audience constructAudience() {
|
||||||
|
return mcMMO.getAudiences().filter(predicate());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Predicate used to filter the audience
|
||||||
|
*
|
||||||
|
* @return admin chat audience predicate
|
||||||
|
*/
|
||||||
|
public @NotNull Predicate<CommandSender> predicate() {
|
||||||
|
return (commandSender) -> commandSender.isOp()
|
||||||
|
|| commandSender.hasPermission(MCMMO_CHAT_ADMINCHAT_PERMISSION)
|
||||||
|
|| commandSender instanceof ConsoleCommandSender;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Styles a string using a locale entry
|
||||||
|
*
|
||||||
|
* @param author message author
|
||||||
|
* @param message message contents
|
||||||
|
* @param canColor whether to replace colors codes with colors in the raw message
|
||||||
|
* @return the styled string, based on a locale entry
|
||||||
|
*/
|
||||||
|
public @NotNull TextComponent addStyle(@NotNull Author author, @NotNull String message, boolean canColor) {
|
||||||
|
if(canColor) {
|
||||||
|
return LocaleLoader.getTextComponent("Chat.Style.Admin", author.getAuthoredName(ChatChannel.ADMIN), message);
|
||||||
|
} else {
|
||||||
|
return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Admin", author.getAuthoredName(ChatChannel.ADMIN), message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMail(@NotNull ChatMessage chatMessage) {
|
||||||
|
chatMessage.sendMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes a chat message from an author to an audience of admins
|
||||||
|
*
|
||||||
|
* @param author the author
|
||||||
|
* @param rawString the raw message as the author typed it before any styling
|
||||||
|
* @param isAsync whether or not this is being processed asynchronously
|
||||||
|
* @param canColor whether or not the author can use colors in chat
|
||||||
|
*/
|
||||||
|
public void processChatMessage(@NotNull Author author, @NotNull String rawString, boolean isAsync, boolean canColor) {
|
||||||
|
AdminChatMessage chatMessage = new AdminChatMessage(pluginRef, author, constructAudience(), rawString, addStyle(author, rawString, canColor));
|
||||||
|
|
||||||
|
McMMOChatEvent chatEvent = new McMMOAdminChatEvent(pluginRef, chatMessage, isAsync);
|
||||||
|
Bukkit.getPluginManager().callEvent(chatEvent);
|
||||||
|
|
||||||
|
if(!chatEvent.isCancelled()) {
|
||||||
|
sendMail(chatMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
12
src/main/java/com/gmail/nossr50/chat/mailer/ChatMailer.java
Normal file
12
src/main/java/com/gmail/nossr50/chat/mailer/ChatMailer.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package com.gmail.nossr50.chat.mailer;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.chat.message.ChatMessage;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public interface ChatMailer {
|
||||||
|
/**
|
||||||
|
* Send out a chat message
|
||||||
|
* @param chatMessage the {@link ChatMessage}
|
||||||
|
*/
|
||||||
|
void sendMail(@NotNull ChatMessage chatMessage);
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
package com.gmail.nossr50.chat.mailer;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.chat.author.Author;
|
||||||
|
import com.gmail.nossr50.chat.message.ChatMessage;
|
||||||
|
import com.gmail.nossr50.chat.message.PartyChatMessage;
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.events.chat.McMMOChatEvent;
|
||||||
|
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.text.TextUtils;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class PartyChatMailer extends AbstractChatMailer {
|
||||||
|
|
||||||
|
public PartyChatMailer(@NotNull Plugin pluginRef) {
|
||||||
|
super(pluginRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes a chat message from an author to an audience of party members
|
||||||
|
*
|
||||||
|
* @param author the author
|
||||||
|
* @param rawString the raw message as the author typed it before any styling
|
||||||
|
* @param isAsync whether or not this is being processed asynchronously
|
||||||
|
* @param canColor whether or not the author can use colors in chat
|
||||||
|
*/
|
||||||
|
public void processChatMessage(@NotNull Author author, @NotNull String rawString, @NotNull Party party, boolean isAsync, boolean canColor, boolean isLeader) {
|
||||||
|
PartyChatMessage chatMessage = new PartyChatMessage(pluginRef, author, constructPartyAudience(party), rawString, addStyle(author, rawString, canColor, isLeader), party);
|
||||||
|
|
||||||
|
McMMOChatEvent chatEvent = new McMMOPartyChatEvent(pluginRef, chatMessage, party, isAsync);
|
||||||
|
Bukkit.getPluginManager().callEvent(chatEvent);
|
||||||
|
|
||||||
|
if(!chatEvent.isCancelled()) {
|
||||||
|
sendMail(chatMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an {@link Audience} of party members
|
||||||
|
*
|
||||||
|
* @param party target party
|
||||||
|
* @return an {@link Audience} of party members
|
||||||
|
*/
|
||||||
|
public @NotNull Audience constructPartyAudience(@NotNull Party party) {
|
||||||
|
return mcMMO.getAudiences().filter(party.getSamePartyPredicate());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Styles a string using a locale entry
|
||||||
|
*
|
||||||
|
* @param author message author
|
||||||
|
* @param message message contents
|
||||||
|
* @param canColor whether to replace colors codes with colors in the raw message
|
||||||
|
* @return the styled string, based on a locale entry
|
||||||
|
*/
|
||||||
|
public @NotNull TextComponent addStyle(@NotNull Author author, @NotNull String message, boolean canColor, boolean isLeader) {
|
||||||
|
if(canColor) {
|
||||||
|
if(isLeader) {
|
||||||
|
return LocaleLoader.getTextComponent("Chat.Style.Party.Leader", author.getAuthoredName(ChatChannel.PARTY), message);
|
||||||
|
} else {
|
||||||
|
return LocaleLoader.getTextComponent("Chat.Style.Party", author.getAuthoredName(ChatChannel.PARTY), message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(isLeader) {
|
||||||
|
return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Party.Leader", author.getAuthoredName(ChatChannel.PARTY), message));
|
||||||
|
} else {
|
||||||
|
return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Party", author.getAuthoredName(ChatChannel.PARTY), message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMail(@NotNull ChatMessage chatMessage) {
|
||||||
|
chatMessage.sendMessage();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
package com.gmail.nossr50.chat.message;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.chat.author.Author;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public abstract class AbstractChatMessage implements ChatMessage {
|
||||||
|
|
||||||
|
protected final @NotNull Plugin pluginRef;
|
||||||
|
protected final @NotNull Author author;
|
||||||
|
protected final @NotNull String rawMessage;
|
||||||
|
protected @NotNull TextComponent componentMessage;
|
||||||
|
protected @NotNull Audience audience;
|
||||||
|
|
||||||
|
public AbstractChatMessage(@NotNull Plugin pluginRef, @NotNull Author author, @NotNull Audience audience, @NotNull String rawMessage, @NotNull TextComponent componentMessage) {
|
||||||
|
this.pluginRef = pluginRef;
|
||||||
|
this.author = author;
|
||||||
|
this.audience = audience;
|
||||||
|
this.rawMessage = rawMessage;
|
||||||
|
this.componentMessage = componentMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String rawMessage() {
|
||||||
|
return rawMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Author getAuthor() {
|
||||||
|
return author;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Audience getAudience() {
|
||||||
|
return audience;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull TextComponent getChatMessage() {
|
||||||
|
return componentMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setChatMessage(@NotNull TextComponent textComponent) {
|
||||||
|
this.componentMessage = textComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAudience(@NotNull Audience newAudience) {
|
||||||
|
audience = newAudience;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
AbstractChatMessage that = (AbstractChatMessage) o;
|
||||||
|
return Objects.equal(pluginRef, that.pluginRef) &&
|
||||||
|
Objects.equal(author, that.author) &&
|
||||||
|
Objects.equal(rawMessage, that.rawMessage) &&
|
||||||
|
Objects.equal(componentMessage, that.componentMessage) &&
|
||||||
|
Objects.equal(audience, that.audience);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(pluginRef, author, rawMessage, componentMessage, audience);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.gmail.nossr50.chat.message;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.chat.author.Author;
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class AdminChatMessage extends AbstractChatMessage {
|
||||||
|
public AdminChatMessage(@NotNull Plugin pluginRef, @NotNull Author author, @NotNull Audience audience, @NotNull String rawMessage, @NotNull TextComponent componentMessage) {
|
||||||
|
super(pluginRef, author, audience, rawMessage, componentMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage() {
|
||||||
|
audience.sendMessage(author, componentMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getAuthorDisplayName() {
|
||||||
|
return author.getAuthoredName(ChatChannel.ADMIN);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
package com.gmail.nossr50.chat.message;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.chat.author.Author;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public interface ChatMessage {
|
||||||
|
/**
|
||||||
|
* The original message from the {@link Author}
|
||||||
|
* This is formatted and styled before being sent out to players by mcMMO
|
||||||
|
*
|
||||||
|
* @return the original message without any formatting or alterations
|
||||||
|
* @see #getChatMessage()
|
||||||
|
*/
|
||||||
|
@NotNull String rawMessage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Author} from which this payload originated
|
||||||
|
*
|
||||||
|
* @see #getChatMessage()
|
||||||
|
* @return the source of the chat message
|
||||||
|
*/
|
||||||
|
@NotNull Author getAuthor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The authors display name which is used in the initial creation of the message payload, it is provided for convenience.
|
||||||
|
*
|
||||||
|
* This is a name generated by mcMMO during the creation of the {@link ChatMessage}
|
||||||
|
*
|
||||||
|
* This is used by mcMMO when generating the message payload
|
||||||
|
*
|
||||||
|
* This method provides the display name for the convenience of plugins constructing their own {@link TextComponent payloads}
|
||||||
|
*
|
||||||
|
* @see #getChatMessage()
|
||||||
|
* @return the author display name as generated by mcMMO
|
||||||
|
*/
|
||||||
|
@NotNull String getAuthorDisplayName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The target audience of this chat message
|
||||||
|
* Unless modified, this will include the {@link Author}
|
||||||
|
*
|
||||||
|
* @return target audience
|
||||||
|
*/
|
||||||
|
@NotNull Audience getAudience();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link TextComponent message} being sent to the audience
|
||||||
|
*
|
||||||
|
* @return the {@link TextComponent message} that will be sent to the audience
|
||||||
|
*/
|
||||||
|
@NotNull TextComponent getChatMessage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the value of the {@link TextComponent message}
|
||||||
|
*
|
||||||
|
* @param textComponent new message value
|
||||||
|
*/
|
||||||
|
void setChatMessage(@NotNull TextComponent textComponent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the audience
|
||||||
|
*
|
||||||
|
* @param newAudience the replacement audience
|
||||||
|
*/
|
||||||
|
void setAudience(@NotNull Audience newAudience);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deliver the message to the audience
|
||||||
|
*/
|
||||||
|
void sendMessage();
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
package com.gmail.nossr50.chat.message;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.chat.author.Author;
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class PartyChatMessage extends AbstractChatMessage {
|
||||||
|
|
||||||
|
private final @NotNull Party party;
|
||||||
|
|
||||||
|
public PartyChatMessage(@NotNull Plugin pluginRef, @NotNull Author author, @NotNull Audience audience, @NotNull String rawMessage, @NotNull TextComponent componentMessage, @NotNull Party party) {
|
||||||
|
super(pluginRef, author, audience, rawMessage, componentMessage);
|
||||||
|
this.party = party;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The party that this chat message was intended for
|
||||||
|
* @return the party that this message was intended for
|
||||||
|
*/
|
||||||
|
public @NotNull Party getParty() {
|
||||||
|
return party;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getAuthorDisplayName() {
|
||||||
|
return author.getAuthoredName(ChatChannel.PARTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage() {
|
||||||
|
/*
|
||||||
|
* It should be noted that Party messages don't include console as part of the audience to avoid double messaging
|
||||||
|
* The console gets a message that has the party name included, player parties do not
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Sends to everyone but console
|
||||||
|
audience.sendMessage(author, componentMessage);
|
||||||
|
TextComponent spyMessage = LocaleLoader.getTextComponent("Chat.Spy.Party", author.getAuthoredName(ChatChannel.PARTY), rawMessage, party.getName());
|
||||||
|
|
||||||
|
//Relay to spies
|
||||||
|
messagePartyChatSpies(spyMessage);
|
||||||
|
|
||||||
|
//Console message
|
||||||
|
mcMMO.p.getChatManager().sendConsoleMessage(author, spyMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Console and Party Chat Spies get a more verbose version of the message
|
||||||
|
* Party Chat Spies will get a copy of the message as well
|
||||||
|
* @param spyMessage the message to copy to spies
|
||||||
|
*/
|
||||||
|
private void messagePartyChatSpies(@NotNull TextComponent spyMessage) {
|
||||||
|
//Find the people with permissions
|
||||||
|
for(McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
||||||
|
Player player = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
|
//Check for toggled players
|
||||||
|
if(mcMMOPlayer.isPartyChatSpying()) {
|
||||||
|
Party adminParty = mcMMOPlayer.getParty();
|
||||||
|
|
||||||
|
//Only message admins not part of this party
|
||||||
|
if(adminParty == null || adminParty != getParty()) {
|
||||||
|
//TODO: Hacky, rewrite later
|
||||||
|
Audience audience = mcMMO.getAudiences().player(player);
|
||||||
|
audience.sendMessage(spyMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
if (!super.equals(o)) return false;
|
||||||
|
PartyChatMessage that = (PartyChatMessage) o;
|
||||||
|
return Objects.equal(party, that.party);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(super.hashCode(), party);
|
||||||
|
}
|
||||||
|
}
|
116
src/main/java/com/gmail/nossr50/commands/CommandManager.java
Normal file
116
src/main/java/com/gmail/nossr50/commands/CommandManager.java
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
package com.gmail.nossr50.commands;
|
||||||
|
|
||||||
|
import co.aikar.commands.BukkitCommandIssuer;
|
||||||
|
import co.aikar.commands.BukkitCommandManager;
|
||||||
|
import co.aikar.commands.ConditionFailedException;
|
||||||
|
import com.gmail.nossr50.commands.chat.AdminChatCommand;
|
||||||
|
import com.gmail.nossr50.commands.chat.PartyChatCommand;
|
||||||
|
import com.gmail.nossr50.config.ChatConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.permissions.Permissible;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For now this class will only handle ACF converted commands, all other commands will be handled elsewhere
|
||||||
|
*/
|
||||||
|
public class CommandManager {
|
||||||
|
public static final @NotNull String ADMIN_CONDITION = "adminCondition";
|
||||||
|
public static final @NotNull String PARTY_CONDITION = "partyCondition";
|
||||||
|
public static final @NotNull String MMO_DATA_LOADED = "mmoDataLoaded";
|
||||||
|
|
||||||
|
private final @NotNull mcMMO pluginRef;
|
||||||
|
private final @NotNull BukkitCommandManager bukkitCommandManager;
|
||||||
|
|
||||||
|
public CommandManager(@NotNull mcMMO pluginRef) {
|
||||||
|
this.pluginRef = pluginRef;
|
||||||
|
bukkitCommandManager = new BukkitCommandManager(pluginRef);
|
||||||
|
|
||||||
|
registerConditions();
|
||||||
|
registerCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerCommands() {
|
||||||
|
registerChatCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers chat commands if the chat system is enabled
|
||||||
|
*/
|
||||||
|
private void registerChatCommands() {
|
||||||
|
if(ChatConfig.getInstance().isChatEnabled()) {
|
||||||
|
if(ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.ADMIN)) {
|
||||||
|
bukkitCommandManager.registerCommand(new AdminChatCommand(pluginRef));
|
||||||
|
}
|
||||||
|
if(ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.PARTY)) {
|
||||||
|
bukkitCommandManager.registerCommand(new PartyChatCommand(pluginRef));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerConditions() {
|
||||||
|
// Method or Class based - Can only be used on methods
|
||||||
|
bukkitCommandManager.getCommandConditions().addCondition(ADMIN_CONDITION, (context) -> {
|
||||||
|
BukkitCommandIssuer issuer = context.getIssuer();
|
||||||
|
|
||||||
|
if(issuer.getIssuer() instanceof Player) {
|
||||||
|
validateLoadedData(issuer.getPlayer());
|
||||||
|
validateAdmin(issuer.getPlayer());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bukkitCommandManager.getCommandConditions().addCondition(MMO_DATA_LOADED, (context) -> {
|
||||||
|
BukkitCommandIssuer bukkitCommandIssuer = context.getIssuer();
|
||||||
|
|
||||||
|
if(bukkitCommandIssuer.getIssuer() instanceof Player) {
|
||||||
|
validateLoadedData(bukkitCommandIssuer.getPlayer());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bukkitCommandManager.getCommandConditions().addCondition(PARTY_CONDITION, (context) -> {
|
||||||
|
BukkitCommandIssuer bukkitCommandIssuer = context.getIssuer();
|
||||||
|
|
||||||
|
if(bukkitCommandIssuer.getIssuer() instanceof Player) {
|
||||||
|
validateLoadedData(bukkitCommandIssuer.getPlayer());
|
||||||
|
validatePlayerParty(bukkitCommandIssuer.getPlayer());
|
||||||
|
validatePermission("mcmmo.chat.partychat", bukkitCommandIssuer.getPlayer());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validatePermission(@NotNull String permissionNode, @NotNull Permissible permissible) {
|
||||||
|
if(!permissible.hasPermission(permissionNode)) {
|
||||||
|
throw new ConditionFailedException("You do not have the appropriate permission to use this command.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void validateAdmin(@NotNull Player player) {
|
||||||
|
if(!player.isOp() && !Permissions.adminChat(player)) {
|
||||||
|
throw new ConditionFailedException("You are lacking the correct permissions to use this command.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validateLoadedData(@NotNull Player player) {
|
||||||
|
if(UserManager.getPlayer(player) == null) {
|
||||||
|
throw new ConditionFailedException("Your mcMMO player data has not yet loaded!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validatePlayerParty(@NotNull Player player) {
|
||||||
|
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||||
|
|
||||||
|
if(mmoPlayer.getParty() == null) {
|
||||||
|
throw new ConditionFailedException(LocaleLoader.getString("Commands.Party.None"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull BukkitCommandManager getBukkitCommandManager() {
|
||||||
|
return bukkitCommandManager;
|
||||||
|
}
|
||||||
|
}
|
@ -7,9 +7,9 @@ import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.NotificationManager;
|
import com.gmail.nossr50.util.player.NotificationManager;
|
||||||
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
@ -1,15 +1,50 @@
|
|||||||
package com.gmail.nossr50.commands.chat;
|
package com.gmail.nossr50.commands.chat;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
import co.aikar.commands.BaseCommand;
|
||||||
import org.bukkit.command.CommandSender;
|
import co.aikar.commands.BukkitCommandIssuer;
|
||||||
|
import co.aikar.commands.annotation.CommandAlias;
|
||||||
|
import co.aikar.commands.annotation.Conditions;
|
||||||
|
import co.aikar.commands.annotation.Default;
|
||||||
|
import com.gmail.nossr50.commands.CommandManager;
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class AdminChatCommand extends ChatCommand {
|
@CommandAlias("ac|a|adminchat|achat") //Kept for historical reasons
|
||||||
public AdminChatCommand() {
|
public class AdminChatCommand extends BaseCommand {
|
||||||
super(ChatMode.ADMIN);
|
private final @NotNull mcMMO pluginRef;
|
||||||
|
|
||||||
|
public AdminChatCommand(@NotNull mcMMO pluginRef) {
|
||||||
|
this.pluginRef = pluginRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Default @Conditions(CommandManager.ADMIN_CONDITION)
|
||||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
public void processCommand(String[] args) {
|
||||||
chatManager.handleChat(sender.getName(), getDisplayName(sender), buildChatMessage(args, 0));
|
BukkitCommandIssuer bukkitCommandIssuer = (BukkitCommandIssuer) getCurrentCommandIssuer();
|
||||||
|
if(args == null || args.length == 0) {
|
||||||
|
//Process with no arguments
|
||||||
|
if(bukkitCommandIssuer.isPlayer()) {
|
||||||
|
McMMOPlayer mmoPlayer = UserManager.getPlayer(bukkitCommandIssuer.getPlayer());
|
||||||
|
pluginRef.getChatManager().setOrToggleChatChannel(mmoPlayer, ChatChannel.ADMIN);
|
||||||
|
} else {
|
||||||
|
//Not support for console
|
||||||
|
mcMMO.p.getLogger().info("You cannot switch chat channels as console, please provide full arguments.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(bukkitCommandIssuer.isPlayer()) {
|
||||||
|
McMMOPlayer mmoPlayer = UserManager.getPlayer(bukkitCommandIssuer.getPlayer());
|
||||||
|
|
||||||
|
if(mmoPlayer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Message contains the original command so it needs to be passed to this method to trim it
|
||||||
|
pluginRef.getChatManager().processPlayerMessage(mmoPlayer, args, ChatChannel.ADMIN);
|
||||||
|
} else {
|
||||||
|
pluginRef.getChatManager().processConsoleMessage(args);
|
||||||
|
}
|
||||||
|
//Arguments are greater than 0, therefore directly send message and skip toggles
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,158 +0,0 @@
|
|||||||
package com.gmail.nossr50.commands.chat;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.chat.ChatManager;
|
|
||||||
import com.gmail.nossr50.chat.ChatManagerFactory;
|
|
||||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
|
||||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
|
||||||
import com.gmail.nossr50.util.player.PartyUtils;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
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 org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class ChatCommand implements TabExecutor {
|
|
||||||
private final ChatMode chatMode;
|
|
||||||
protected ChatManager chatManager;
|
|
||||||
|
|
||||||
public ChatCommand(ChatMode chatMode) {
|
|
||||||
this.chatMode = chatMode;
|
|
||||||
this.chatManager = ChatManagerFactory.getChatManager(mcMMO.p, chatMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
|
||||||
McMMOPlayer mmoPlayer;
|
|
||||||
Player player;
|
|
||||||
|
|
||||||
if(sender instanceof Player) {
|
|
||||||
player = (Player) sender;
|
|
||||||
|
|
||||||
if (!CommandUtils.hasPlayerDataKey(sender)) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
|
|
||||||
|
|
||||||
switch (args.length) {
|
|
||||||
case 0:
|
|
||||||
if (CommandUtils.noConsoleUsage(sender)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CommandUtils.hasPlayerDataKey(sender)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mmoPlayer.isChatEnabled(chatMode)) {
|
|
||||||
disableChatMode(mmoPlayer, sender);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
enableChatMode(mmoPlayer, sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
if (CommandUtils.shouldEnableToggle(args[0])) {
|
|
||||||
if (CommandUtils.noConsoleUsage(sender)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!CommandUtils.hasPlayerDataKey(sender)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
enableChatMode(mcMMO.getUserManager().queryMcMMOPlayer(player), sender);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CommandUtils.shouldDisableToggle(args[0])) {
|
|
||||||
if (CommandUtils.noConsoleUsage(sender)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!CommandUtils.hasPlayerDataKey(sender)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
disableChatMode(mcMMO.getUserManager().queryMcMMOPlayer(player), sender);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallthrough
|
|
||||||
|
|
||||||
default:
|
|
||||||
handleChatSending(sender, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.NoConsole"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
|
||||||
if (args.length == 1) {
|
|
||||||
return StringUtil.copyPartialMatches(args[0], CommandUtils.TRUE_FALSE_OPTIONS, new ArrayList<>(CommandUtils.TRUE_FALSE_OPTIONS.size()));
|
|
||||||
}
|
|
||||||
return ImmutableList.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String buildChatMessage(String[] args, int index) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append(args[index]);
|
|
||||||
|
|
||||||
for (int i = index + 1; i < args.length; i++) {
|
|
||||||
builder.append(" ");
|
|
||||||
builder.append(args[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getDisplayName(CommandSender sender) {
|
|
||||||
return (sender instanceof Player) ? ((Player) sender).getDisplayName() : LocaleLoader.getString("Commands.Chat.Console");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void handleChatSending(CommandSender sender, @NotNull String[] args);
|
|
||||||
|
|
||||||
private void enableChatMode(@NotNull McMMOPlayer mmoPlayer, @NotNull CommandSender sender) {
|
|
||||||
if (chatMode == ChatMode.PARTY) {
|
|
||||||
Party party = mmoPlayer.getParty();
|
|
||||||
if(party == null) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(PartyUtils.isAllowed(party, PartyFeature.CHAT)) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mmoPlayer.enableChat(chatMode);
|
|
||||||
sender.sendMessage(chatMode.getEnabledMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void disableChatMode(McMMOPlayer mmoPlayer, CommandSender sender) {
|
|
||||||
if (chatMode == ChatMode.PARTY && mmoPlayer.getParty() == null) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mmoPlayer.disableChat(chatMode);
|
|
||||||
sender.sendMessage(chatMode.getDisabledMessage());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,60 +1,88 @@
|
|||||||
package com.gmail.nossr50.commands.chat;
|
package com.gmail.nossr50.commands.chat;
|
||||||
|
|
||||||
import com.gmail.nossr50.chat.PartyChatManager;
|
import co.aikar.commands.BaseCommand;
|
||||||
import com.gmail.nossr50.config.Config;
|
import co.aikar.commands.BukkitCommandIssuer;
|
||||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
import co.aikar.commands.annotation.CommandAlias;
|
||||||
|
import co.aikar.commands.annotation.Conditions;
|
||||||
|
import co.aikar.commands.annotation.Default;
|
||||||
|
import com.gmail.nossr50.commands.CommandManager;
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import org.bukkit.command.CommandSender;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PartyChatCommand extends ChatCommand {
|
@CommandAlias("pc|p|partychat|pchat") //Kept for historical reasons
|
||||||
public PartyChatCommand() {
|
public class PartyChatCommand extends BaseCommand {
|
||||||
super(ChatMode.PARTY);
|
private final @NotNull mcMMO pluginRef;
|
||||||
|
|
||||||
|
public PartyChatCommand(@NotNull mcMMO pluginRef) {
|
||||||
|
this.pluginRef = pluginRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Default
|
||||||
protected void handleChatSending(CommandSender sender, String[] args) {
|
@Conditions(CommandManager.PARTY_CONDITION)
|
||||||
Party party;
|
public void processCommand(String[] args) {
|
||||||
String message;
|
BukkitCommandIssuer bukkitCommandIssuer = (BukkitCommandIssuer) getCurrentCommandIssuer();
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if(args == null || args.length == 0) {
|
||||||
//Check if player profile is loaded
|
//Process with no arguments
|
||||||
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
|
if(bukkitCommandIssuer.isPlayer()) {
|
||||||
return;
|
McMMOPlayer mmoPlayer = UserManager.getPlayer(bukkitCommandIssuer.getPlayer());
|
||||||
|
pluginRef.getChatManager().setOrToggleChatChannel(mmoPlayer, ChatChannel.PARTY);
|
||||||
party = mcMMO.getUserManager().getPlayer((Player) sender).getParty();
|
} else {
|
||||||
|
//Not support for console
|
||||||
if (party == null) {
|
mcMMO.p.getLogger().info("You cannot switch chat channels as console, please provide full arguments.");
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
//Here we split the logic, consoles need to target a party name and players do not
|
||||||
|
|
||||||
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT)) {
|
/*
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1"));
|
* Player Logic
|
||||||
return;
|
*/
|
||||||
}
|
if(bukkitCommandIssuer.getIssuer() instanceof Player) {
|
||||||
|
McMMOPlayer mmoPlayer = UserManager.getPlayer(bukkitCommandIssuer.getPlayer());
|
||||||
message = buildChatMessage(args, 0);
|
processCommandArgsPlayer(mmoPlayer, args);
|
||||||
}
|
/*
|
||||||
else {
|
* Console Logic
|
||||||
if (args.length < 2) {
|
*/
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Specify"));
|
} else {
|
||||||
return;
|
processCommandArgsConsole(args);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
party = mcMMO.getPartyManager().getParty(args[0]);
|
}
|
||||||
|
|
||||||
if (party == null) {
|
/**
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
|
* Processes the command with arguments for a {@link McMMOPlayer}
|
||||||
return;
|
* @param mmoPlayer target player
|
||||||
}
|
* @param args command arguments
|
||||||
|
*/
|
||||||
message = buildChatMessage(args, 1);
|
private void processCommandArgsPlayer(@NotNull McMMOPlayer mmoPlayer, @NotNull String[] args) {
|
||||||
}
|
//Player is not toggling and is chatting directly to party
|
||||||
|
pluginRef.getChatManager().processPlayerMessage(mmoPlayer, args, ChatChannel.PARTY);
|
||||||
((PartyChatManager) chatManager).setParty(party);
|
}
|
||||||
chatManager.handleChat(sender.getName(), getDisplayName(sender), message);
|
|
||||||
|
/**
|
||||||
|
* Processes the command with arguments for a {@link com.gmail.nossr50.chat.author.ConsoleAuthor}
|
||||||
|
* @param args command arguments
|
||||||
|
*/
|
||||||
|
private void processCommandArgsConsole(@NotNull String[] args) {
|
||||||
|
if(args.length <= 1) {
|
||||||
|
//Only specific a party and not the message
|
||||||
|
mcMMO.p.getLogger().severe("You need to specify a party name and then write a message afterwards.");
|
||||||
|
} else {
|
||||||
|
//Grab party
|
||||||
|
Party targetParty = PartyManager.getParty(args[0]);
|
||||||
|
|
||||||
|
if(targetParty != null) {
|
||||||
|
pluginRef.getChatManager().processConsoleMessage(StringUtils.buildStringAfterNthElement(args, 1), targetParty);
|
||||||
|
} else {
|
||||||
|
mcMMO.p.getLogger().severe("A party with that name doesn't exist!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,18 @@ public class AddlevelsCommand extends ExperienceCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageAll(Player player, int value) {
|
protected void handlePlayerMessageAll(Player player, int value, boolean isSilent) {
|
||||||
|
if(isSilent)
|
||||||
|
return;
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value));
|
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
|
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
|
||||||
|
if(isSilent)
|
||||||
|
return;
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getName()));
|
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,18 @@ public class AddxpCommand extends ExperienceCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageAll(Player player, int value) {
|
protected void handlePlayerMessageAll(Player player, int value, boolean isSilent) {
|
||||||
|
if(isSilent)
|
||||||
|
return;
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value));
|
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
|
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
|
||||||
|
if(isSilent)
|
||||||
|
return;
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName()));
|
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,10 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
PrimarySkillType skill;
|
PrimarySkillType skill;
|
||||||
|
|
||||||
switch (args.length) {
|
if(args.length < 2) {
|
||||||
case 2:
|
return false;
|
||||||
|
} else {
|
||||||
|
if(args.length == 2 && !isSilent(args) || args.length == 3 && isSilent(args)) {
|
||||||
if (CommandUtils.noConsoleUsage(sender)) {
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -61,10 +63,10 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
editValues((Player) sender, mcMMO.getUserManager().getPlayer(sender.getName()), skill, Integer.parseInt(args[1]));
|
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]), isSilent(args));
|
||||||
return true;
|
return true;
|
||||||
|
} else if((args.length == 3 && !isSilent(args))
|
||||||
case 3:
|
|| (args.length == 4 && isSilent(args))) {
|
||||||
if (!permissionsCheckOthers(sender)) {
|
if (!permissionsCheckOthers(sender)) {
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return true;
|
return true;
|
||||||
@ -104,19 +106,29 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
editValues(null, profile, skill, value);
|
editValues(null, profile, skill, value, isSilent(args));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
editValues(mmoPlayer.getPlayer(), mmoPlayer, skill, value);
|
editValues(mmoPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value, isSilent(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSenderMessage(sender, playerName, skill);
|
handleSenderMessage(sender, playerName, skill);
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
default:
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSilent(String[] args) {
|
||||||
|
int length = args.length;
|
||||||
|
|
||||||
|
if(length == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return args[length-1].equalsIgnoreCase("-s");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||||
@ -134,8 +146,8 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
protected abstract boolean permissionsCheckSelf(CommandSender sender);
|
protected abstract boolean permissionsCheckSelf(CommandSender sender);
|
||||||
protected abstract boolean permissionsCheckOthers(CommandSender sender);
|
protected abstract boolean permissionsCheckOthers(CommandSender sender);
|
||||||
protected abstract void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value);
|
protected abstract void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value);
|
||||||
protected abstract void handlePlayerMessageAll(Player player, int value);
|
protected abstract void handlePlayerMessageAll(Player player, int value, boolean isSilent);
|
||||||
protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill);
|
protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent);
|
||||||
|
|
||||||
private boolean validateArguments(CommandSender sender, String skillName, String value) {
|
private boolean validateArguments(CommandSender sender, String skillName, String value) {
|
||||||
return !(CommandUtils.isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && CommandUtils.isInvalidSkill(sender, skillName)));
|
return !(CommandUtils.isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && CommandUtils.isInvalidSkill(sender, skillName)));
|
||||||
@ -150,21 +162,21 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
|
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value, boolean isSilent) {
|
||||||
if (skill == null) {
|
if (skill == null) {
|
||||||
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
|
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
|
||||||
handleCommand(player, profile, primarySkillType, value);
|
handleCommand(player, profile, primarySkillType, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
handlePlayerMessageAll(player, value);
|
handlePlayerMessageAll(player, value, isSilent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
handleCommand(player, profile, skill, value);
|
handleCommand(player, profile, skill, value);
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
handlePlayerMessageSkill(player, value, skill);
|
handlePlayerMessageSkill(player, value, skill, isSilent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,12 +40,18 @@ public class MmoeditCommand extends ExperienceCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageAll(Player player, int value) {
|
protected void handlePlayerMessageAll(Player player, int value, boolean isSilent) {
|
||||||
|
if(isSilent)
|
||||||
|
return;
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value));
|
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill) {
|
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
|
||||||
|
if(isSilent)
|
||||||
|
return;
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getName(), value));
|
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getName(), value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class SkillresetCommand implements TabExecutor {
|
|||||||
skill = null;
|
skill = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
skill = PrimarySkillType.getSkill(args[1]);
|
skill = PrimarySkillType.getSkill(args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
editValues((Player) sender, mcMMO.getUserManager().getPlayer(sender.getName()), skill);
|
editValues((Player) sender, mcMMO.getUserManager().getPlayer(sender.getName()), skill);
|
||||||
|
@ -2,8 +2,8 @@ package com.gmail.nossr50.commands.hardcore;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -124,8 +124,6 @@ public class PartyCommand implements TabExecutor {
|
|||||||
return partyInviteCommand.onCommand(sender, command, label, args);
|
return partyInviteCommand.onCommand(sender, command, label, args);
|
||||||
case TELEPORT:
|
case TELEPORT:
|
||||||
return partyTeleportCommand.onCommand(sender, command, label, extractArgs(args));
|
return partyTeleportCommand.onCommand(sender, command, label, extractArgs(args));
|
||||||
case CHAT:
|
|
||||||
return partyChatCommand.onCommand(sender, command, label, extractArgs(args));
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@ import com.gmail.nossr50.datatypes.party.PartyFeature;
|
|||||||
import com.gmail.nossr50.datatypes.party.ShareMode;
|
import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -52,7 +52,7 @@ public class MccooldownCommand implements TabExecutor {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int seconds = mmoPlayer.calculateTimeRemaining(ability);
|
int seconds = mmoPlayer.getCooldownSeconds(ability);
|
||||||
|
|
||||||
if (seconds <= 0) {
|
if (seconds <= 0) {
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getLocalizedName()));
|
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getLocalizedName()));
|
||||||
|
@ -7,8 +7,8 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -2,10 +2,10 @@ package com.gmail.nossr50.commands.player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
||||||
import com.gmail.nossr50.util.player.NotificationManager;
|
import com.gmail.nossr50.util.player.NotificationManager;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -5,10 +5,10 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||||
import com.gmail.nossr50.listeners.InteractionManager;
|
import com.gmail.nossr50.listeners.InteractionManager;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
|
||||||
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
|
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -28,18 +31,23 @@ public class AlchemyCommand extends SkillCommand {
|
|||||||
super(PrimarySkillType.ALCHEMY);
|
super(PrimarySkillType.ALCHEMY);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] calculateAbilityDisplayValues(Player player) {
|
protected String[] calculateAbilityDisplayValues(@NotNull Player player) {
|
||||||
//TODO: Needed?
|
//TODO: Needed?
|
||||||
if(mcMMO.getUserManager().getPlayer(player) == null)
|
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer(player);
|
||||||
|
if(mmoPlayer == null)
|
||||||
{
|
{
|
||||||
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||||
return new String[] {"DATA NOT LOADED", "DATA NOT LOADED"};
|
return new String[] {"DATA NOT LOADED", "DATA NOT LOADED"};
|
||||||
}
|
}
|
||||||
|
|
||||||
AlchemyManager alchemyManager = mcMMO.getUserManager().getPlayer(player).getAlchemyManager();
|
return calculateAbilityDisplayValues(mmoPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String[] calculateAbilityDisplayValues(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
|
AlchemyManager alchemyManager = mmoPlayer.getAlchemyManager();
|
||||||
String[] displayValues = new String[2];
|
String[] displayValues = new String[2];
|
||||||
|
|
||||||
boolean isLucky = Permissions.lucky(player, PrimarySkillType.ALCHEMY);
|
boolean isLucky = Permissions.lucky(mmoPlayer.getPlayer(), PrimarySkillType.ALCHEMY);
|
||||||
|
|
||||||
displayValues[0] = decimal.format(alchemyManager.calculateBrewSpeed(false)) + "x";
|
displayValues[0] = decimal.format(alchemyManager.calculateBrewSpeed(false)) + "x";
|
||||||
displayValues[1] = isLucky ? decimal.format(alchemyManager.calculateBrewSpeed(true)) + "x" : null;
|
displayValues[1] = isLucky ? decimal.format(alchemyManager.calculateBrewSpeed(true)) + "x" : null;
|
||||||
@ -47,18 +55,19 @@ public class AlchemyCommand extends SkillCommand {
|
|||||||
return displayValues;
|
return displayValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations(Player player, float skillValue) {
|
protected void dataCalculations(McMMOPlayer mmoPlayer, float skillValue) {
|
||||||
// ALCHEMY_CATALYSIS
|
// ALCHEMY_CATALYSIS
|
||||||
if (canCatalysis) {
|
if (canCatalysis) {
|
||||||
String[] catalysisStrings = calculateAbilityDisplayValues(player);
|
String[] catalysisStrings = calculateAbilityDisplayValues(mmoPlayer.getPlayer());
|
||||||
brewSpeed = catalysisStrings[0];
|
brewSpeed = catalysisStrings[0];
|
||||||
brewSpeedLucky = catalysisStrings[1];
|
brewSpeedLucky = catalysisStrings[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ALCHEMY_CONCOCTIONS
|
// ALCHEMY_CONCOCTIONS
|
||||||
if (canConcoctions) {
|
if (canConcoctions) {
|
||||||
AlchemyManager alchemyManager = mcMMO.getUserManager().getPlayer(player).getAlchemyManager();
|
AlchemyManager alchemyManager = mmoPlayer.getAlchemyManager();
|
||||||
tier = alchemyManager.getTier();
|
tier = alchemyManager.getTier();
|
||||||
ingredientCount = alchemyManager.getIngredients().size();
|
ingredientCount = alchemyManager.getIngredients().size();
|
||||||
ingredientList = alchemyManager.getIngredientList();
|
ingredientList = alchemyManager.getIngredientList();
|
||||||
|
@ -3,8 +3,8 @@ package com.gmail.nossr50.commands.skills;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.HolidayManager.FakeSkillType;
|
import com.gmail.nossr50.util.HolidayManager.FakeSkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -157,40 +157,40 @@ public class AprilCommand implements TabExecutor {
|
|||||||
|
|
||||||
switch (fakeSkillType) {
|
switch (fakeSkillType) {
|
||||||
case MACHO:
|
case MACHO:
|
||||||
messages.add(LocaleLoader.formatString("[[RED]]Damage Taken: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(77))));
|
messages.add(LocaleLoader.formatString("&cDamage Taken: &e{0}%", decimal.format(Misc.getRandom().nextInt(77))));
|
||||||
break;
|
break;
|
||||||
case JUMPING:
|
case JUMPING:
|
||||||
messages.add(LocaleLoader.formatString("[[RED]]Double Jump Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
messages.add(LocaleLoader.formatString("&cDouble Jump Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
break;
|
break;
|
||||||
case THROWING:
|
case THROWING:
|
||||||
messages.add(LocaleLoader.formatString("[[RED]]Drop Item Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(87))));
|
messages.add(LocaleLoader.formatString("&cDrop Item Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(87))));
|
||||||
break;
|
break;
|
||||||
case WRECKING:
|
case WRECKING:
|
||||||
messages.add(LocaleLoader.formatString("[[RED]]Wrecking Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(14))));
|
messages.add(LocaleLoader.formatString("&cWrecking Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(14))));
|
||||||
break;
|
break;
|
||||||
case CRAFTING:
|
case CRAFTING:
|
||||||
messages.add(LocaleLoader.formatString("[[RED]]Crafting Success: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
messages.add(LocaleLoader.formatString("&cCrafting Success: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
break;
|
break;
|
||||||
case WALKING:
|
case WALKING:
|
||||||
messages.add(LocaleLoader.formatString("[[RED]]Walk Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
messages.add(LocaleLoader.formatString("&cWalk Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
break;
|
break;
|
||||||
case SWIMMING:
|
case SWIMMING:
|
||||||
messages.add(LocaleLoader.formatString("[[RED]]Swim Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
messages.add(LocaleLoader.formatString("&cSwim Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
break;
|
break;
|
||||||
case FALLING:
|
case FALLING:
|
||||||
messages.add(LocaleLoader.formatString("[[RED]]Skydiving Success: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(37))));
|
messages.add(LocaleLoader.formatString("&cSkydiving Success: &e{0}%", decimal.format(Misc.getRandom().nextInt(37))));
|
||||||
break;
|
break;
|
||||||
case CLIMBING:
|
case CLIMBING:
|
||||||
messages.add(LocaleLoader.formatString("[[RED]]Rock Climber Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
messages.add(LocaleLoader.formatString("&cRock Climber Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
break;
|
break;
|
||||||
case FLYING:
|
case FLYING:
|
||||||
messages.add(LocaleLoader.formatString("[[RED]]Fly Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
messages.add(LocaleLoader.formatString("&cFly Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
break;
|
break;
|
||||||
case DIVING:
|
case DIVING:
|
||||||
messages.add(LocaleLoader.formatString("[[RED]]Hold Breath Chance: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
messages.add(LocaleLoader.formatString("&cHold Breath Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
|
||||||
break;
|
break;
|
||||||
case PIGGY:
|
case PIGGY:
|
||||||
messages.add(LocaleLoader.formatString("[[RED]]Carrot Turbo Boost: [[YELLOW]]{0}%", decimal.format(Misc.getRandom().nextInt(80)) + 10));
|
messages.add(LocaleLoader.formatString("&cCarrot Turbo Boost: &e{0}%", decimal.format(Misc.getRandom().nextInt(80)) + 10));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,9 +4,9 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.archery.Archery;
|
import com.gmail.nossr50.skills.archery.Archery;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.axes.Axes;
|
import com.gmail.nossr50.skills.axes.Axes;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -34,10 +37,10 @@ public class AxesCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations(Player player, float skillValue) {
|
protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
|
||||||
// ARMOR IMPACT
|
// ARMOR IMPACT
|
||||||
if (canImpact) {
|
if (canImpact) {
|
||||||
impactDamage = mcMMO.getUserManager().getPlayer(player).getAxesManager().getImpactDurabilityDamage();
|
impactDamage = mmoPlayer.getAxesManager().getImpactDurabilityDamage();
|
||||||
}
|
}
|
||||||
|
|
||||||
// AXE MASTERY
|
// AXE MASTERY
|
||||||
@ -61,12 +64,12 @@ public class AxesCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void permissionsCheck(Player player) {
|
protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
canSkullSplitter = Permissions.skullSplitter(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.AXES_SKULL_SPLITTER);
|
canSkullSplitter = Permissions.skullSplitter(mmoPlayer.getPlayer()) && RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.AXES_SKULL_SPLITTER);
|
||||||
canCritical = canUseSubskill(player, SubSkillType.AXES_CRITICAL_STRIKES);
|
canCritical = canUseSubskill(mmoPlayer, SubSkillType.AXES_CRITICAL_STRIKES);
|
||||||
canAxeMastery = canUseSubskill(player, SubSkillType.AXES_AXE_MASTERY);
|
canAxeMastery = canUseSubskill(mmoPlayer, SubSkillType.AXES_AXE_MASTERY);
|
||||||
canImpact = canUseSubskill(player, SubSkillType.AXES_ARMOR_IMPACT);
|
canImpact = canUseSubskill(mmoPlayer, SubSkillType.AXES_ARMOR_IMPACT);
|
||||||
canGreaterImpact = canUseSubskill(player, SubSkillType.AXES_GREATER_IMPACT);
|
canGreaterImpact = canUseSubskill(mmoPlayer, SubSkillType.AXES_GREATER_IMPACT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
import com.gmail.nossr50.util.TextComponentFactory;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -41,10 +45,10 @@ public class ExcavationCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
protected List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
|
|
||||||
ExcavationManager excavationManager = mcMMO.getUserManager().getPlayer(player).getExcavationManager();
|
ExcavationManager excavationManager = mmoPlayer.getExcavationManager();
|
||||||
|
|
||||||
if (canGigaDrill) {
|
if (canGigaDrill) {
|
||||||
messages.add(getStatMessage(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, gigaDrillBreakerLength)
|
messages.add(getStatMessage(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, gigaDrillBreakerLength)
|
||||||
@ -53,7 +57,7 @@ public class ExcavationCommand extends SkillCommand {
|
|||||||
//messages.add(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
|
//messages.add(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(canUseSubskill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
|
if(canUseSubskill(mmoPlayer, SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
|
||||||
messages.add(getStatMessage(false, false, SubSkillType.EXCAVATION_ARCHAEOLOGY,
|
messages.add(getStatMessage(false, false, SubSkillType.EXCAVATION_ARCHAEOLOGY,
|
||||||
percent.format(excavationManager.getArchaelogyExperienceOrbChance() / 100.0D)));
|
percent.format(excavationManager.getArchaelogyExperienceOrbChance() / 100.0D)));
|
||||||
messages.add(getStatMessage(true, false, SubSkillType.EXCAVATION_ARCHAEOLOGY,
|
messages.add(getStatMessage(true, false, SubSkillType.EXCAVATION_ARCHAEOLOGY,
|
||||||
@ -65,10 +69,10 @@ public class ExcavationCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getTextComponents(Player player) {
|
protected List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
|
|
||||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.EXCAVATION);
|
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.EXCAVATION);
|
||||||
|
|
||||||
return textComponents;
|
return textComponents;
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.fishing.Fishing;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -25,9 +24,7 @@ public class FishingCommand extends SkillCommand {
|
|||||||
private String shakeChance;
|
private String shakeChance;
|
||||||
private String shakeChanceLucky;
|
private String shakeChanceLucky;
|
||||||
private int fishermansDietRank;
|
private int fishermansDietRank;
|
||||||
private String biteChance;
|
|
||||||
|
|
||||||
private String trapTreasure;
|
|
||||||
private String commonTreasure;
|
private String commonTreasure;
|
||||||
private String uncommonTreasure;
|
private String uncommonTreasure;
|
||||||
private String rareTreasure;
|
private String rareTreasure;
|
||||||
@ -44,13 +41,15 @@ public class FishingCommand extends SkillCommand {
|
|||||||
private boolean canMasterAngler;
|
private boolean canMasterAngler;
|
||||||
private boolean canIceFish;
|
private boolean canIceFish;
|
||||||
|
|
||||||
|
private String maMinWaitTime, maMaxWaitTime;
|
||||||
|
|
||||||
public FishingCommand() {
|
public FishingCommand() {
|
||||||
super(PrimarySkillType.FISHING);
|
super(PrimarySkillType.FISHING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations(Player player, float skillValue) {
|
protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
|
||||||
FishingManager fishingManager = mcMMO.getUserManager().getPlayer(player).getFishingManager();
|
FishingManager fishingManager = mmoPlayer.getFishingManager();
|
||||||
|
|
||||||
// TREASURE HUNTER
|
// TREASURE HUNTER
|
||||||
if (canTreasureHunt) {
|
if (canTreasureHunt) {
|
||||||
@ -81,52 +80,35 @@ public class FishingCommand extends SkillCommand {
|
|||||||
|
|
||||||
// FISHING_SHAKE
|
// FISHING_SHAKE
|
||||||
if (canShake) {
|
if (canShake) {
|
||||||
String[] shakeStrings = RandomChanceUtil.calculateAbilityDisplayValuesStatic(player, PrimarySkillType.FISHING, fishingManager.getShakeChance());
|
String[] shakeStrings = RandomChanceUtil.calculateAbilityDisplayValuesStatic(mmoPlayer, PrimarySkillType.FISHING, fishingManager.getShakeChance());
|
||||||
shakeChance = shakeStrings[0];
|
shakeChance = shakeStrings[0];
|
||||||
shakeChanceLucky = shakeStrings[1];
|
shakeChanceLucky = shakeStrings[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// FISHERMAN'S DIET
|
// FISHERMAN'S DIET
|
||||||
if (canFishermansDiet) {
|
if (canFishermansDiet) {
|
||||||
fishermansDietRank = RankUtils.getRank(player, SubSkillType.FISHING_FISHERMANS_DIET);
|
fishermansDietRank = RankUtils.getRank(mmoPlayer, SubSkillType.FISHING_FISHERMANS_DIET);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MASTER ANGLER
|
// MASTER ANGLER
|
||||||
if (canMasterAngler) {
|
if (canMasterAngler) {
|
||||||
double rawBiteChance = 1.0 / (player.getWorld().hasStorm() ? 300 : 500);
|
maMinWaitTime = StringUtils.ticksToSeconds(fishingManager.getMasterAnglerTickMinWaitReduction(RankUtils.getRank(mmoPlayer, SubSkillType.FISHING_MASTER_ANGLER), false));
|
||||||
|
maMaxWaitTime = StringUtils.ticksToSeconds(fishingManager.getMasterAnglerTickMaxWaitReduction(RankUtils.getRank(mmoPlayer, SubSkillType.FISHING_MASTER_ANGLER), false));
|
||||||
Location location = fishingManager.getHookLocation();
|
|
||||||
|
|
||||||
if (location == null) {
|
|
||||||
location = player.getLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Fishing.masterAnglerBiomes.contains(location.getBlock().getBiome())) {
|
|
||||||
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
|
|
||||||
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
|
|
||||||
}
|
|
||||||
|
|
||||||
double luckyModifier = Permissions.lucky(player, PrimarySkillType.FISHING) ? 1.333D : 1.0D;
|
|
||||||
|
|
||||||
biteChance = percent.format((rawBiteChance * 100.0D) * luckyModifier);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void permissionsCheck(Player player) {
|
protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
canTreasureHunt = canUseSubskill(player, SubSkillType.FISHING_TREASURE_HUNTER);
|
canTreasureHunt = canUseSubskill(mmoPlayer, SubSkillType.FISHING_TREASURE_HUNTER);
|
||||||
canMagicHunt = canUseSubskill(player, SubSkillType.FISHING_MAGIC_HUNTER) && canUseSubskill(player, SubSkillType.FISHING_TREASURE_HUNTER);
|
canMagicHunt = canUseSubskill(mmoPlayer, SubSkillType.FISHING_MAGIC_HUNTER) && canUseSubskill(mmoPlayer, SubSkillType.FISHING_TREASURE_HUNTER);
|
||||||
canShake = canUseSubskill(player, SubSkillType.FISHING_SHAKE);
|
canShake = canUseSubskill(mmoPlayer, SubSkillType.FISHING_SHAKE);
|
||||||
canFishermansDiet = canUseSubskill(player, SubSkillType.FISHING_FISHERMANS_DIET);
|
canFishermansDiet = canUseSubskill(mmoPlayer, SubSkillType.FISHING_FISHERMANS_DIET);
|
||||||
canMasterAngler = canUseSubskill(player, SubSkillType.FISHING_MASTER_ANGLER);
|
canMasterAngler = mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() != null && canUseSubskill(mmoPlayer, SubSkillType.FISHING_MASTER_ANGLER);
|
||||||
canIceFish = canUseSubskill(player, SubSkillType.FISHING_ICE_FISHING);
|
canIceFish = canUseSubskill(mmoPlayer, SubSkillType.FISHING_ICE_FISHING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
protected List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
|
|
||||||
if (canFishermansDiet) {
|
if (canFishermansDiet) {
|
||||||
@ -142,8 +124,13 @@ public class FishingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canMasterAngler) {
|
if (canMasterAngler) {
|
||||||
//TODO: Update this with more details
|
messages.add(getStatMessage(false,true,
|
||||||
messages.add(getStatMessage(false, true, SubSkillType.FISHING_MASTER_ANGLER, biteChance));
|
SubSkillType.FISHING_MASTER_ANGLER,
|
||||||
|
maMinWaitTime));
|
||||||
|
|
||||||
|
messages.add(getStatMessage(true,true,
|
||||||
|
SubSkillType.FISHING_MASTER_ANGLER,
|
||||||
|
maMaxWaitTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canShake) {
|
if (canShake) {
|
||||||
@ -166,10 +153,10 @@ public class FishingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getTextComponents(Player player) {
|
protected List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
|
|
||||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.FISHING);
|
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.FISHING);
|
||||||
|
|
||||||
return textComponents;
|
return textComponents;
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -38,10 +41,10 @@ public class MiningCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations(Player player, float skillValue) {
|
protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
|
||||||
// BLAST MINING
|
// BLAST MINING
|
||||||
if (canBlast || canDemoExpert || canBiggerBombs) {
|
if (canBlast || canDemoExpert || canBiggerBombs) {
|
||||||
MiningManager miningManager = mcMMO.getUserManager().getPlayer(player).getMiningManager();
|
MiningManager miningManager = mmoPlayer.getMiningManager();
|
||||||
|
|
||||||
blastMiningRank = miningManager.getBlastMiningTier();
|
blastMiningRank = miningManager.getBlastMiningTier();
|
||||||
bonusTNTDrops = miningManager.getDropMultiplier();
|
bonusTNTDrops = miningManager.getDropMultiplier();
|
||||||
@ -67,16 +70,16 @@ public class MiningCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void permissionsCheck(Player player) {
|
protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
canBiggerBombs = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_BIGGER_BOMBS) && Permissions.biggerBombs(player);
|
canBiggerBombs = RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.MINING_BIGGER_BOMBS) && Permissions.biggerBombs(player);
|
||||||
canBlast = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_BLAST_MINING) && Permissions.remoteDetonation(player);
|
canBlast = RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.MINING_BLAST_MINING) && Permissions.remoteDetonation(player);
|
||||||
canDemoExpert = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_DEMOLITIONS_EXPERTISE) && Permissions.demolitionsExpertise(player);
|
canDemoExpert = RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.MINING_DEMOLITIONS_EXPERTISE) && Permissions.demolitionsExpertise(player);
|
||||||
canDoubleDrop = canUseSubskill(player, SubSkillType.MINING_DOUBLE_DROPS);
|
canDoubleDrop = canUseSubskill(mmoPlayer, SubSkillType.MINING_DOUBLE_DROPS);
|
||||||
canSuperBreaker = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_SUPER_BREAKER) && Permissions.superBreaker(player);
|
canSuperBreaker = RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.MINING_SUPER_BREAKER) && Permissions.superBreaker(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
protected List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
|
|
||||||
if (canBiggerBombs) {
|
if (canBiggerBombs) {
|
||||||
@ -110,10 +113,10 @@ public class MiningCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getTextComponents(Player player) {
|
protected List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
|
|
||||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.MINING);
|
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.MINING);
|
||||||
|
|
||||||
return textComponents;
|
return textComponents;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
|||||||
import com.gmail.nossr50.listeners.InteractionManager;
|
import com.gmail.nossr50.listeners.InteractionManager;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
@ -10,12 +11,13 @@ import com.gmail.nossr50.skills.repair.Repair;
|
|||||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -47,7 +49,7 @@ public class RepairCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations(Player player, float skillValue) {
|
protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
|
||||||
// We're using pickaxes here, not the best but it works
|
// We're using pickaxes here, not the best but it works
|
||||||
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
|
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
|
||||||
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLDEN_PICKAXE);
|
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLDEN_PICKAXE);
|
||||||
@ -89,7 +91,7 @@ public class RepairCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
protected List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
|
|
||||||
if (canArcaneForge) {
|
if (canArcaneForge) {
|
||||||
@ -97,7 +99,7 @@ public class RepairCommand extends SkillCommand {
|
|||||||
|
|
||||||
messages.add(getStatMessage(false, true,
|
messages.add(getStatMessage(false, true,
|
||||||
SubSkillType.REPAIR_ARCANE_FORGING,
|
SubSkillType.REPAIR_ARCANE_FORGING,
|
||||||
String.valueOf(RankUtils.getRank(player, SubSkillType.REPAIR_ARCANE_FORGING)),
|
String.valueOf(RankUtils.getRank(mmoPlayer, SubSkillType.REPAIR_ARCANE_FORGING)),
|
||||||
RankUtils.getHighestRankStr(SubSkillType.REPAIR_ARCANE_FORGING)));
|
RankUtils.getHighestRankStr(SubSkillType.REPAIR_ARCANE_FORGING)));
|
||||||
|
|
||||||
if (ArcaneForging.arcaneForgingEnchantLoss || ArcaneForging.arcaneForgingDowngrades) {
|
if (ArcaneForging.arcaneForgingEnchantLoss || ArcaneForging.arcaneForgingDowngrades) {
|
||||||
@ -120,10 +122,10 @@ public class RepairCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getTextComponents(Player player) {
|
protected List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
|
|
||||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.REPAIR);
|
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.REPAIR);
|
||||||
|
|
||||||
return textComponents;
|
return textComponents;
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||||
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -28,20 +30,20 @@ public class SalvageCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void permissionsCheck(Player player) {
|
protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
canScrapCollector = canUseSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR);
|
canScrapCollector = canUseSubskill(mmoPlayer, SubSkillType.SALVAGE_SCRAP_COLLECTOR);
|
||||||
canArcaneSalvage = canUseSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE);
|
canArcaneSalvage = canUseSubskill(mmoPlayer, SubSkillType.SALVAGE_ARCANE_SALVAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
protected List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
SalvageManager salvageManager = mcMMO.getUserManager().getPlayer(player).getSalvageManager();
|
SalvageManager salvageManager = mmoPlayer.getSalvageManager();
|
||||||
|
|
||||||
if (canScrapCollector) {
|
if (canScrapCollector) {
|
||||||
messages.add(getStatMessage(false, true,
|
messages.add(getStatMessage(false, true,
|
||||||
SubSkillType.SALVAGE_SCRAP_COLLECTOR,
|
SubSkillType.SALVAGE_SCRAP_COLLECTOR,
|
||||||
String.valueOf(RankUtils.getRank(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)),
|
String.valueOf(RankUtils.getRank(mmoPlayer, SubSkillType.SALVAGE_SCRAP_COLLECTOR)),
|
||||||
RankUtils.getHighestRankStr(SubSkillType.SALVAGE_SCRAP_COLLECTOR)));
|
RankUtils.getHighestRankStr(SubSkillType.SALVAGE_SCRAP_COLLECTOR)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,10 +65,10 @@ public class SalvageCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getTextComponents(Player player) {
|
protected List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
|
|
||||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.SALVAGE);
|
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.SALVAGE);
|
||||||
|
|
||||||
return textComponents;
|
return textComponents;
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,9 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.NotificationManager;
|
import com.gmail.nossr50.util.player.NotificationManager;
|
||||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||||
@ -17,10 +16,11 @@ import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
|||||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -59,19 +59,19 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mcMMO.getUserManager().getPlayer((Player) sender) == null)
|
McMMOPlayer mmoPlayer = mcMMO.getUserManager().queryMcMMOPlayer((Player) sender);
|
||||||
{
|
|
||||||
|
if(mmoPlayer == null) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
McMMOPlayer mmoPlayer = mcMMO.getUserManager().getPlayer(player);
|
|
||||||
|
|
||||||
boolean isLucky = Permissions.lucky(player, skill);
|
boolean isLucky = Permissions.lucky(player, skill);
|
||||||
boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
|
boolean hasEndurance = (PerksUtils.handleActivationPerks(player, 0, 0) != 0);
|
||||||
float skillValue = mmoPlayer.getSkillLevel(skill);
|
float skillValue = mmoPlayer.getExperienceManager().getSkillLevel(skill);
|
||||||
|
|
||||||
//Send the players a few blank lines to make finding the top of the skill command easier
|
//Send the players a few blank lines to make finding the top of the skill command easier
|
||||||
if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines())
|
if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines())
|
||||||
@ -80,12 +80,12 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
permissionsCheck(player);
|
permissionsCheck(player);
|
||||||
dataCalculations(player, skillValue);
|
dataCalculations(mmoPlayer, skillValue);
|
||||||
|
|
||||||
sendSkillCommandHeader(player, mmoPlayer, (int) skillValue);
|
sendSkillCommandHeader(player, mmoPlayer, (int) skillValue);
|
||||||
|
|
||||||
//Make JSON text components
|
//Make JSON text components
|
||||||
List<Component> subskillTextComponents = getTextComponents(player);
|
List<Component> subskillTextComponents = getTextComponents(mmoPlayer);
|
||||||
|
|
||||||
//Subskills Header
|
//Subskills Header
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", LocaleLoader.getString("Effects.SubSkills.Overhaul")));
|
player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", LocaleLoader.getString("Effects.SubSkills.Overhaul")));
|
||||||
@ -100,7 +100,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
//Stats
|
//Stats
|
||||||
getStatMessages(player, isLucky, hasEndurance, skillValue);
|
sendStatMessages(mmoPlayer, isLucky, hasEndurance, skillValue);
|
||||||
|
|
||||||
//Header
|
//Header
|
||||||
|
|
||||||
@ -121,18 +121,18 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
return skillGuideCommand.onCommand(sender, command, label, args);
|
return skillGuideCommand.onCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getStatMessages(Player player, boolean isLucky, boolean hasEndurance, float skillValue) {
|
private void sendStatMessages(@NotNull McMMOPlayer mmoPlayer, boolean isLucky, boolean hasEndurance, float skillValue) {
|
||||||
List<String> statsMessages = statsDisplay(player, skillValue, hasEndurance, isLucky);
|
List<String> statsMessages = statsDisplay(mmoPlayer, skillValue, hasEndurance, isLucky);
|
||||||
|
|
||||||
if (!statsMessages.isEmpty()) {
|
if (!statsMessages.isEmpty()) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", LocaleLoader.getString("Commands.Stats.Self.Overhaul")));
|
mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", LocaleLoader.getString("Commands.Stats.Self.Overhaul")));
|
||||||
|
|
||||||
for (String message : statsMessages) {
|
for (String message : statsMessages) {
|
||||||
player.sendMessage(message);
|
mmoPlayer.getPlayer().sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase(Locale.ENGLISH)));
|
mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase(Locale.ENGLISH)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendSkillCommandHeader(Player player, McMMOPlayer mmoPlayer, int skillValue) {
|
private void sendSkillCommandHeader(Player player, McMMOPlayer mmoPlayer, int skillValue) {
|
||||||
@ -153,7 +153,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
|
player.sendMessage(LocaleLoader.getString("Commands.XPGain.Overhaul", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
|
||||||
|
|
||||||
//LEVEL
|
//LEVEL
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Level.Overhaul", skillValue, mmoPlayer.getSkillXpLevel(skill), mmoPlayer.getXpToLevel(skill)));
|
player.sendMessage(LocaleLoader.getString("Effects.Level.Overhaul", skillValue, mmoPlayer.getExperienceManager().getSkillXpValue(skill), mmoPlayer.getExperienceManager().getXpToLevel(skill)));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -173,10 +173,10 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
{
|
{
|
||||||
if(i+1 < parentList.size())
|
if(i+1 < parentList.size())
|
||||||
{
|
{
|
||||||
parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mmoPlayer.getSkillLevel(parentList.get(i))));
|
parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mmoPlayer.getExperienceManager().getSkillLevel(parentList.get(i))));
|
||||||
parentMessage.append(ChatColor.GRAY).append(", ");
|
parentMessage.append(ChatColor.GRAY).append(", ");
|
||||||
} else {
|
} else {
|
||||||
parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mmoPlayer.getSkillLevel(parentList.get(i))));
|
parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mmoPlayer.getExperienceManager().getSkillLevel(parentList.get(i))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,11 +220,11 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
|
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] getAbilityDisplayValues(SkillActivationType skillActivationType, Player player, SubSkillType subSkill) {
|
protected String[] getAbilityDisplayValues(@NotNull SkillActivationType skillActivationType, @NotNull McMMOPlayer mmoPlayer, @NotNull SubSkillType subSkill) {
|
||||||
return RandomChanceUtil.calculateAbilityDisplayValues(skillActivationType, player, subSkill);
|
return RandomChanceUtil.calculateAbilityDisplayValues(skillActivationType, mmoPlayer.getPlayer(), subSkill);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String[] calculateLengthDisplayValues(Player player, float skillValue) {
|
protected String[] calculateLengthDisplayValues(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
|
||||||
int maxLength = skill.getSuperAbilityType().getMaxLength();
|
int maxLength = skill.getSuperAbilityType().getMaxLength();
|
||||||
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
|
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
|
||||||
int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
|
int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
|
||||||
@ -239,7 +239,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar);
|
length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar);
|
||||||
}
|
}
|
||||||
|
|
||||||
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
|
int enduranceLength = PerksUtils.handleActivationPerks(mmoPlayer.getPlayer(), length, maxLength);
|
||||||
|
|
||||||
if (maxLength != 0) {
|
if (maxLength != 0) {
|
||||||
length = Math.min(length, maxLength);
|
length = Math.min(length, maxLength);
|
||||||
@ -267,7 +267,7 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getLimitBreakDescriptionParameter() {
|
protected @NotNull String getLimitBreakDescriptionParameter() {
|
||||||
if(AdvancedConfig.getInstance().canApplyLimitBreakPVE()) {
|
if(AdvancedConfig.getInstance().canApplyLimitBreakPVE()) {
|
||||||
return "(PVP/PVE)";
|
return "(PVP/PVE)";
|
||||||
} else {
|
} else {
|
||||||
@ -275,24 +275,23 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void dataCalculations(Player player, float skillValue);
|
protected abstract void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue);
|
||||||
|
|
||||||
protected abstract void permissionsCheck(Player player);
|
protected abstract void permissionsCheck(@NotNull Player player);
|
||||||
|
|
||||||
//protected abstract List<String> effectsDisplay();
|
//protected abstract List<String> effectsDisplay();
|
||||||
|
|
||||||
protected abstract List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky);
|
protected abstract List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky);
|
||||||
|
|
||||||
protected abstract List<Component> getTextComponents(Player player);
|
protected abstract List<Component> getTextComponents(@NotNull McMMOPlayer player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a player can use a skill
|
* Checks if a player can use a skill
|
||||||
* @param player target player
|
* @param mmoPlayer target player
|
||||||
* @param subSkillType target subskill
|
* @param subSkillType target subskill
|
||||||
* @return true if the player has permission and has the skill unlocked
|
* @return true if the player has permission and has the skill unlocked
|
||||||
*/
|
*/
|
||||||
protected boolean canUseSubskill(Player player, SubSkillType subSkillType)
|
protected boolean canUseSubskill(@NotNull McMMOPlayer mmoPlayer, SubSkillType subSkillType) {
|
||||||
{
|
return Permissions.isSubSkillEnabled(mmoPlayer.getPlayer(), subSkillType) && RankUtils.hasUnlockedSubskill(mmoPlayer, subSkillType);
|
||||||
return Permissions.isSubSkillEnabled(player, subSkillType) && RankUtils.hasUnlockedSubskill(player, subSkillType);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.skills;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -30,10 +33,10 @@ public class SmeltingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations(Player player, float skillValue) {
|
protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
|
||||||
// FUEL EFFICIENCY
|
// FUEL EFFICIENCY
|
||||||
if (canFuelEfficiency) {
|
if (canFuelEfficiency) {
|
||||||
burnTimeModifier = String.valueOf(mcMMO.getUserManager().getPlayer(player).getSmeltingManager().getFuelEfficiencyMultiplier());
|
burnTimeModifier = String.valueOf(mmoPlayer.getSmeltingManager().getFuelEfficiencyMultiplier());
|
||||||
}
|
}
|
||||||
|
|
||||||
// FLUX MINING
|
// FLUX MINING
|
||||||
@ -52,15 +55,15 @@ public class SmeltingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void permissionsCheck(Player player) {
|
protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
canFuelEfficiency = canUseSubskill(player, SubSkillType.SMELTING_FUEL_EFFICIENCY);
|
canFuelEfficiency = canUseSubskill(mmoPlayer, SubSkillType.SMELTING_FUEL_EFFICIENCY);
|
||||||
canSecondSmelt = canUseSubskill(player, SubSkillType.SMELTING_SECOND_SMELT);
|
canSecondSmelt = canUseSubskill(mmoPlayer, SubSkillType.SMELTING_SECOND_SMELT);
|
||||||
//canFluxMine = canUseSubskill(player, SubSkillType.SMELTING_FLUX_MINING);
|
//canFluxMine = canUseSubskill(player, SubSkillType.SMELTING_FLUX_MINING);
|
||||||
canUnderstandTheArt = Permissions.vanillaXpBoost(player, skill) && RankUtils.hasUnlockedSubskill(player, SubSkillType.SMELTING_UNDERSTANDING_THE_ART);
|
canUnderstandTheArt = Permissions.vanillaXpBoost(mmoPlayer.getPlayer(), skill) && RankUtils.hasUnlockedSubskill(player, SubSkillType.SMELTING_UNDERSTANDING_THE_ART);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
protected List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
|
|
||||||
/*if (canFluxMine) {
|
/*if (canFluxMine) {
|
||||||
@ -80,17 +83,17 @@ public class SmeltingCommand extends SkillCommand {
|
|||||||
|
|
||||||
if (canUnderstandTheArt) {
|
if (canUnderstandTheArt) {
|
||||||
messages.add(getStatMessage(false, true, SubSkillType.SMELTING_UNDERSTANDING_THE_ART,
|
messages.add(getStatMessage(false, true, SubSkillType.SMELTING_UNDERSTANDING_THE_ART,
|
||||||
String.valueOf(mcMMO.getUserManager().getPlayer(player).getSmeltingManager().getVanillaXpMultiplier())));
|
String.valueOf(mmoPlayer.getSmeltingManager().getVanillaXpMultiplier())));
|
||||||
}
|
}
|
||||||
|
|
||||||
return messages;
|
return messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Component> getTextComponents(Player player) {
|
protected List<Component> getTextComponents(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
List<Component> textComponents = new ArrayList<>();
|
List<Component> textComponents = new ArrayList<>();
|
||||||
|
|
||||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.SMELTING);
|
TextComponentFactory.getSubSkillTextComponents(mmoPlayer, textComponents, PrimarySkillType.SMELTING);
|
||||||
|
|
||||||
return textComponents;
|
return textComponents;
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -33,7 +36,7 @@ public class SwordsCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations(Player player, float skillValue) {
|
protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
|
||||||
// SWORDS_COUNTER_ATTACK
|
// SWORDS_COUNTER_ATTACK
|
||||||
if (canCounter) {
|
if (canCounter) {
|
||||||
String[] counterStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SWORDS_COUNTER_ATTACK);
|
String[] counterStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SWORDS_COUNTER_ATTACK);
|
||||||
@ -43,7 +46,7 @@ public class SwordsCommand extends SkillCommand {
|
|||||||
|
|
||||||
// SWORDS_RUPTURE
|
// SWORDS_RUPTURE
|
||||||
if (canBleed) {
|
if (canBleed) {
|
||||||
bleedLength = mcMMO.getUserManager().getPlayer(player).getSwordsManager().getRuptureBleedTicks();
|
bleedLength = mmoPlayer.getSwordsManager().getRuptureBleedTicks();
|
||||||
|
|
||||||
String[] bleedStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SWORDS_RUPTURE);
|
String[] bleedStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SWORDS_RUPTURE);
|
||||||
bleedChance = bleedStrings[0];
|
bleedChance = bleedStrings[0];
|
||||||
@ -59,19 +62,19 @@ public class SwordsCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void permissionsCheck(Player player) {
|
protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
canBleed = canUseSubskill(player, SubSkillType.SWORDS_RUPTURE);
|
canBleed = canUseSubskill(mmoPlayer, SubSkillType.SWORDS_RUPTURE);
|
||||||
canCounter = canUseSubskill(player, SubSkillType.SWORDS_COUNTER_ATTACK);
|
canCounter = canUseSubskill(mmoPlayer, SubSkillType.SWORDS_COUNTER_ATTACK);
|
||||||
canSerratedStrike = RankUtils.hasUnlockedSubskill(player, SubSkillType.SWORDS_SERRATED_STRIKES) && Permissions.serratedStrikes(player);
|
canSerratedStrike = RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.SWORDS_SERRATED_STRIKES) && Permissions.serratedStrikes(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
protected List<String> statsDisplay(@NotNull McMMOPlayer mmoPlayer, Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||||
List<String> messages = new ArrayList<>();
|
List<String> messages = new ArrayList<>();
|
||||||
|
|
||||||
int ruptureTicks = mcMMO.getUserManager().getPlayer(player).getSwordsManager().getRuptureBleedTicks();
|
int ruptureTicks = mmoPlayer.getSwordsManager().getRuptureBleedTicks();
|
||||||
double ruptureDamagePlayers = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamagePlayer() * 1.5D : AdvancedConfig.getInstance().getRuptureDamagePlayer();
|
double ruptureDamagePlayers = RankUtils.getRank(mmoPlayer, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamagePlayer() * 1.5D : AdvancedConfig.getInstance().getRuptureDamagePlayer();
|
||||||
double ruptureDamageMobs = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamageMobs() * 1.5D : AdvancedConfig.getInstance().getRuptureDamageMobs();
|
double ruptureDamageMobs = RankUtils.getRank(mmoPlayer, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamageMobs() * 1.5D : AdvancedConfig.getInstance().getRuptureDamageMobs();
|
||||||
|
|
||||||
if (canCounter) {
|
if (canCounter) {
|
||||||
messages.add(getStatMessage(SubSkillType.SWORDS_COUNTER_ATTACK, counterChance)
|
messages.add(getStatMessage(SubSkillType.SWORDS_COUNTER_ATTACK, counterChance)
|
||||||
@ -94,13 +97,13 @@ public class SwordsCommand extends SkillCommand {
|
|||||||
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
|
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(canUseSubskill(player, SubSkillType.SWORDS_STAB))
|
if(canUseSubskill(mmoPlayer, SubSkillType.SWORDS_STAB))
|
||||||
{
|
{
|
||||||
messages.add(getStatMessage(SubSkillType.SWORDS_STAB,
|
messages.add(getStatMessage(SubSkillType.SWORDS_STAB,
|
||||||
String.valueOf(mcMMO.getUserManager().getPlayer(player).getSwordsManager().getStabDamage())));
|
String.valueOf(mmoPlayer.getSwordsManager().getStabDamage())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {
|
if(canUseSubskill(mmoPlayer, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {
|
||||||
messages.add(getStatMessage(SubSkillType.SWORDS_SWORDS_LIMIT_BREAK,
|
messages.add(getStatMessage(SubSkillType.SWORDS_SWORDS_LIMIT_BREAK,
|
||||||
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK, 1000))));
|
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK, 1000))));
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
|||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.taming.Taming;
|
import com.gmail.nossr50.skills.taming.Taming;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -37,7 +40,7 @@ public class UnarmedCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations(Player player, float skillValue) {
|
protected void dataCalculations(@NotNull McMMOPlayer mmoPlayer, float skillValue) {
|
||||||
// UNARMED_ARROW_DEFLECT
|
// UNARMED_ARROW_DEFLECT
|
||||||
if (canDeflect) {
|
if (canDeflect) {
|
||||||
String[] deflectStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_ARROW_DEFLECT);
|
String[] deflectStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_ARROW_DEFLECT);
|
||||||
@ -47,7 +50,7 @@ public class UnarmedCommand extends SkillCommand {
|
|||||||
|
|
||||||
// BERSERK
|
// BERSERK
|
||||||
if (canBerserk) {
|
if (canBerserk) {
|
||||||
String[] berserkStrings = calculateLengthDisplayValues(player, skillValue);
|
String[] berserkStrings = calculateLengthDisplayValues(mmoPlayer, skillValue);
|
||||||
berserkLength = berserkStrings[0];
|
berserkLength = berserkStrings[0];
|
||||||
berserkLengthEndurance = berserkStrings[1];
|
berserkLengthEndurance = berserkStrings[1];
|
||||||
}
|
}
|
||||||
@ -61,7 +64,7 @@ public class UnarmedCommand extends SkillCommand {
|
|||||||
|
|
||||||
// IRON ARM
|
// IRON ARM
|
||||||
if (canIronArm) {
|
if (canIronArm) {
|
||||||
ironArmBonus = mcMMO.getUserManager().queryMcMMOPlayer(player).getUnarmedManager().getSteelArmStyleDamage();
|
ironArmBonus = mmoPlayer.getUnarmedManager().getSteelArmStyleDamage();
|
||||||
}
|
}
|
||||||
|
|
||||||
// IRON GRIP
|
// IRON GRIP
|
||||||
@ -73,12 +76,12 @@ public class UnarmedCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void permissionsCheck(Player player) {
|
protected void permissionsCheck(@NotNull McMMOPlayer mmoPlayer) {
|
||||||
canBerserk = RankUtils.hasUnlockedSubskill(player, SubSkillType.UNARMED_BERSERK) && Permissions.berserk(player);
|
canBerserk = RankUtils.hasUnlockedSubskill(mmoPlayer, SubSkillType.UNARMED_BERSERK) && Permissions.berserk(player);
|
||||||
canIronArm = canUseSubskill(player, SubSkillType.UNARMED_STEEL_ARM_STYLE);
|
canIronArm = canUseSubskill(mmoPlayer, SubSkillType.UNARMED_STEEL_ARM_STYLE);
|
||||||
canDeflect = canUseSubskill(player, SubSkillType.UNARMED_ARROW_DEFLECT);
|
canDeflect = canUseSubskill(mmoPlayer, SubSkillType.UNARMED_ARROW_DEFLECT);
|
||||||
canDisarm = canUseSubskill(player, SubSkillType.UNARMED_DISARM);
|
canDisarm = canUseSubskill(mmoPlayer, SubSkillType.UNARMED_DISARM);
|
||||||
canIronGrip = canUseSubskill(player, SubSkillType.UNARMED_IRON_GRIP);
|
canIronGrip = canUseSubskill(mmoPlayer, SubSkillType.UNARMED_IRON_GRIP);
|
||||||
// TODO: Apparently we forgot about block cracker?
|
// TODO: Apparently we forgot about block cracker?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,9 +4,9 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||||
|
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -22,6 +22,7 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
private boolean canTreeFell;
|
private boolean canTreeFell;
|
||||||
private boolean canLeafBlow;
|
private boolean canLeafBlow;
|
||||||
private boolean canDoubleDrop;
|
private boolean canDoubleDrop;
|
||||||
|
private boolean canKnockOnWood;
|
||||||
private boolean canSplinter;
|
private boolean canSplinter;
|
||||||
private boolean canBarkSurgeon;
|
private boolean canBarkSurgeon;
|
||||||
private boolean canNaturesBounty;
|
private boolean canNaturesBounty;
|
||||||
@ -56,6 +57,7 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
canTreeFell = RankUtils.hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_TREE_FELLER) && Permissions.treeFeller(player);
|
canTreeFell = RankUtils.hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_TREE_FELLER) && Permissions.treeFeller(player);
|
||||||
canDoubleDrop = canUseSubskill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) && !skill.getDoubleDropsDisabled() && RankUtils.getRank(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) >= 1;
|
canDoubleDrop = canUseSubskill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) && !skill.getDoubleDropsDisabled() && RankUtils.getRank(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) >= 1;
|
||||||
canLeafBlow = canUseSubskill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER);
|
canLeafBlow = canUseSubskill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER);
|
||||||
|
canKnockOnWood = canTreeFell && canUseSubskill(player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD);
|
||||||
/*canSplinter = canUseSubskill(player, SubSkillType.WOODCUTTING_SPLINTER);
|
/*canSplinter = canUseSubskill(player, SubSkillType.WOODCUTTING_SPLINTER);
|
||||||
canBarkSurgeon = canUseSubskill(player, SubSkillType.WOODCUTTING_BARK_SURGEON);
|
canBarkSurgeon = canUseSubskill(player, SubSkillType.WOODCUTTING_BARK_SURGEON);
|
||||||
canNaturesBounty = canUseSubskill(player, SubSkillType.WOODCUTTING_NATURES_BOUNTY);*/
|
canNaturesBounty = canUseSubskill(player, SubSkillType.WOODCUTTING_NATURES_BOUNTY);*/
|
||||||
@ -70,6 +72,18 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
|
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (canKnockOnWood) {
|
||||||
|
String lootNote;
|
||||||
|
|
||||||
|
if(RankUtils.hasReachedRank(2, player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD)) {
|
||||||
|
lootNote = LocaleLoader.getString("Woodcutting.SubSkill.KnockOnWood.Loot.Rank2");
|
||||||
|
} else {
|
||||||
|
lootNote = LocaleLoader.getString("Woodcutting.SubSkill.KnockOnWood.Loot.Normal");
|
||||||
|
}
|
||||||
|
|
||||||
|
messages.add(getStatMessage(SubSkillType.WOODCUTTING_KNOCK_ON_WOOD, lootNote));
|
||||||
|
}
|
||||||
|
|
||||||
if (canLeafBlow) {
|
if (canLeafBlow) {
|
||||||
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1")));
|
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1")));
|
||||||
}
|
}
|
||||||
|
@ -275,62 +275,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
reason.add("Skills.Mining.DoubleDrops.MaxBonusLevel should be at least 1!");
|
reason.add("Skills.Mining.DoubleDrops.MaxBonusLevel should be at least 1!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*List<BlastMining.Tier> blastMiningTierList = Arrays.asList(BlastMining.Tier.values());
|
|
||||||
|
|
||||||
for (int rank : blastMiningTierList) {
|
|
||||||
if (getBlastMiningRankLevel(tier) < 0) {
|
|
||||||
reason.add("Skills.Mining.BlastMining.Rank_Levels.Rank_" + rank + " should be at least 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getBlastDamageDecrease(tier) < 0) {
|
|
||||||
reason.add("Skills.Mining.BlastMining.BlastDamageDecrease.Rank_" + rank + " should be at least 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getOreBonus(tier) < 0) {
|
|
||||||
reason.add("Skills.Mining.BlastMining.OreBonus.Rank_" + rank + " should be at least 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getDebrisReduction(tier) < 0) {
|
|
||||||
reason.add("Skills.Mining.BlastMining.DebrisReduction.Rank_" + rank + " should be at least 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getDropMultiplier(tier) < 0) {
|
|
||||||
reason.add("Skills.Mining.BlastMining.DropMultiplier.Rank_" + rank + " should be at least 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getBlastRadiusModifier(tier) < 0) {
|
|
||||||
reason.add("Skills.Mining.BlastMining.BlastRadiusModifier.Rank_" + rank + " should be at least 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tier != BlastMining.Tier.EIGHT) {
|
|
||||||
BlastMining.Tier nextTier = blastMiningTierList.get(blastMiningTierList.indexOf(tier) - 1);
|
|
||||||
|
|
||||||
if (getBlastMiningRankLevel(tier) > getBlastMiningRankLevel(nextTier)) {
|
|
||||||
reason.add("Skills.Mining.BlastMining.Rank_Levels.Rank_" + rank + " should be less than or equal to Skills.Mining.BlastMining.Rank_Levels.Rank_" + nextrank + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getBlastDamageDecrease(tier) > getBlastDamageDecrease(nextTier)) {
|
|
||||||
reason.add("Skills.Mining.BlastMining.BlastDamageDecrease.Rank_" + rank + " should be less than or equal to Skills.Mining.BlastMining.BlastDamageDecrease.Rank_" + nextrank + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getOreBonus(tier) > getOreBonus(nextTier)) {
|
|
||||||
reason.add("Skills.Mining.BlastMining.OreBonus.Rank_" + rank + " should be less than or equal to Skills.Mining.BlastMining.OreBonus.Rank_" + nextrank + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getDebrisReduction(tier) > getDebrisReduction(nextTier)) {
|
|
||||||
reason.add("Skills.Mining.BlastMining.DebrisReduction.Rank_" + rank + " should be less than or equal to Skills.Mining.BlastMining.DebrisReduction.Rank_" + nextrank + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getDropMultiplier(tier) > getDropMultiplier(nextTier)) {
|
|
||||||
reason.add("Skills.Mining.BlastMining.DropMultiplier.Rank_" + rank + " should be less than or equal to Skills.Mining.BlastMining.DropMultiplier.Rank_" + nextrank + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getBlastRadiusModifier(tier) > getBlastRadiusModifier(nextTier)) {
|
|
||||||
reason.add("Skills.Mining.BlastMining.BlastRadiusModifier.Rank_" + rank + " should be less than or equal to Skills.Mining.BlastMining.BlastRadiusModifier.Rank_" + nextrank + "!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/* REPAIR */
|
/* REPAIR */
|
||||||
if (getRepairMasteryMaxBonus() < 1) {
|
if (getRepairMasteryMaxBonus() < 1) {
|
||||||
reason.add("Skills.Repair.RepairMastery.MaxBonusPercentage should be at least 1!");
|
reason.add("Skills.Repair.RepairMastery.MaxBonusPercentage should be at least 1!");
|
||||||
@ -348,83 +292,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
reason.add("Skills.Repair.SuperRepair.MaxBonusLevel should be at least 1!");
|
reason.add("Skills.Repair.SuperRepair.MaxBonusLevel should be at least 1!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*List<ArcaneForging.Tier> arcaneForgingTierList = Arrays.asList(ArcaneForging.Tier.values());
|
|
||||||
|
|
||||||
for (ArcaneForging.Tier tier : arcaneForgingTierList) {
|
|
||||||
if (getArcaneForgingRankLevel(tier) < 0) {
|
|
||||||
reason.add("Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + rank + " should be at least 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getArcaneForgingDowngradeChance(tier) < 0 || getArcaneForgingDowngradeChance(tier) > 100) {
|
|
||||||
reason.add("Skills.Repair.ArcaneForging.Downgrades.Chance.Rank_" + rank + " only accepts values from 0 to 100!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getArcaneForgingKeepEnchantsChance(tier) < 0 || getArcaneForgingKeepEnchantsChance(tier) > 100) {
|
|
||||||
reason.add("Skills.Repair.ArcaneForging.Keep_Enchants.Chance.Rank_" + rank + " only accepts values from 0 to 100!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tier != ArcaneForging.Tier.EIGHT) {
|
|
||||||
ArcaneForging.Tier nextTier = arcaneForgingTierList.get(arcaneForgingTierList.indexOf(tier) - 1);
|
|
||||||
|
|
||||||
if (getArcaneForgingRankLevel(tier) > getArcaneForgingRankLevel(nextTier)) {
|
|
||||||
reason.add("Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + rank + " should be less than or equal to Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + nextrank + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getArcaneForgingDowngradeChance(nextTier) > getArcaneForgingDowngradeChance(tier)) {
|
|
||||||
reason.add("Skills.Repair.ArcaneForging.Downgrades.Chance.Rank_" + nextrank + " should be less than or equal to Skills.Repair.ArcaneForging.Downgrades.Chance.Rank_" + rank + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getArcaneForgingKeepEnchantsChance(tier) > getArcaneForgingKeepEnchantsChance(nextTier)) {
|
|
||||||
reason.add("Skills.Repair.ArcaneForging.Keep_Enchants.Chance.Rank_" + rank + " should be less than or equal to Skills.Repair.ArcaneForging.Keep_Enchants.Chance.Rank_" + nextrank + "!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/* SALVAGE */
|
|
||||||
/*if (getSalvageMaxPercentage() < 1) {
|
|
||||||
reason.add("Skills.Salvage.MaxPercentage should be at least 1!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getSalvageMaxPercentageLevel() < 1) {
|
|
||||||
reason.add("Skills.Salvage.MaxPercentageLevel should be at least 1!");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*if (getAdvancedSalvageUnlockLevel() < 0) {
|
|
||||||
reason.add("Skills.Salvage.AdvancedSalvage.UnlockLevel should be at least 0!");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*List<Salvage.Tier> salvageTierList = Arrays.asList(Salvage.Tier.values());
|
|
||||||
|
|
||||||
for (Salvage.Tier tier : salvageTierList) {
|
|
||||||
if (getArcaneSalvageRankLevel(tier) < 0) {
|
|
||||||
reason.add("Skills.Salvage.ArcaneSalvage.Rank_Levels.Rank_" + rank + " should be at least 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getArcaneSalvageExtractFullEnchantsChance(tier) < 0 || getArcaneSalvageExtractFullEnchantsChance(tier) > 100) {
|
|
||||||
reason.add("Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + rank + " only accepts values from 0 to 100!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getArcaneSalvageExtractPartialEnchantsChance(tier) < 0 || getArcaneSalvageExtractPartialEnchantsChance(tier) > 100) {
|
|
||||||
reason.add("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + rank + " only accepts values from 0 to 100!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tier != Salvage.Tier.EIGHT) {
|
|
||||||
Salvage.Tier nextTier = salvageTierList.get(salvageTierList.indexOf(tier) - 1);
|
|
||||||
|
|
||||||
if (getArcaneSalvageRankLevel(tier) > getArcaneSalvageRankLevel(nextTier)) {
|
|
||||||
reason.add("Skills.Salvage.ArcaneSalvage.Rank_Levels.Rank_" + rank + " should be less than or equal to Skills.Salvage.ArcaneSalvage.Rank_Levels.Rank_" + nextrank + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getArcaneSalvageExtractFullEnchantsChance(tier) > getArcaneSalvageExtractFullEnchantsChance(nextTier)) {
|
|
||||||
reason.add("Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + rank + " should be less than or equal to Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + nextrank + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getArcaneSalvageExtractPartialEnchantsChance(tier) > getArcaneSalvageExtractPartialEnchantsChance(nextTier)) {
|
|
||||||
reason.add("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + rank + " should be less than or equal to Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + nextrank + "!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/* SMELTING */
|
/* SMELTING */
|
||||||
if (getBurnModifierMaxLevel() < 1) {
|
if (getBurnModifierMaxLevel() < 1) {
|
||||||
reason.add("Skills.Smelting.FuelEfficiency.MaxBonusLevel should be at least 1!");
|
reason.add("Skills.Smelting.FuelEfficiency.MaxBonusLevel should be at least 1!");
|
||||||
@ -438,38 +305,10 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
reason.add("Skills.Smelting.SecondSmelt.ChanceMax should be at least 1!");
|
reason.add("Skills.Smelting.SecondSmelt.ChanceMax should be at least 1!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (getFluxMiningUnlockLevel() < 0) {
|
|
||||||
reason.add("Skills.Smelting.FluxMining.UnlockLevel should be at least 0!");
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (getFluxMiningChance() < 1) {
|
if (getFluxMiningChance() < 1) {
|
||||||
reason.add("Skills.Smelting.FluxMining.Chance should be at least 1!");
|
reason.add("Skills.Smelting.FluxMining.Chance should be at least 1!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*List<Smelting.Tier> smeltingTierList = Arrays.asList(Smelting.Tier.values());
|
|
||||||
|
|
||||||
for (int rank : smeltingTierList) {
|
|
||||||
if (getSmeltingRankLevel(tier) < 0) {
|
|
||||||
reason.add("Skills.Smelting.Rank_Levels.Rank_" + rank + " should be at least 0!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getSmeltingVanillaXPBoostMultiplier(tier) < 1) {
|
|
||||||
reason.add("Skills.Smelting.VanillaXPMultiplier.Rank_" + rank + " should be at least 1!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tier != Smelting.Tier.EIGHT) {
|
|
||||||
Smelting.Tier nextTier = smeltingTierList.get(smeltingTierList.indexOf(tier) - 1);
|
|
||||||
|
|
||||||
if (getSmeltingRankLevel(tier) > getSmeltingRankLevel(nextTier)) {
|
|
||||||
reason.add("Skills.Smelting.Rank_Levels.Rank_" + rank + " should be less than or equal to Skills.Smelting.Rank_Levels.Rank_" + nextrank + "!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getSmeltingVanillaXPBoostMultiplier(tier) > getSmeltingVanillaXPBoostMultiplier(nextTier)) {
|
|
||||||
reason.add("Skills.Smelting.VanillaXPMultiplier.Rank_" + rank + " should be less than or equal to Skills.Smelting.VanillaXPMultiplier.Rank_" + nextrank + "!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/* SWORDS */
|
/* SWORDS */
|
||||||
if (getMaximumProbability(SubSkillType.SWORDS_RUPTURE) < 1) {
|
if (getMaximumProbability(SubSkillType.SWORDS_RUPTURE) < 1) {
|
||||||
reason.add("Skills.Swords.Rupture.ChanceMax should be at least 1!");
|
reason.add("Skills.Swords.Rupture.ChanceMax should be at least 1!");
|
||||||
@ -882,6 +721,12 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
public double getShakeChance(int rank) { return config.getDouble("Skills.Fishing.ShakeChance.Rank_" + rank); }
|
public double getShakeChance(int rank) { return config.getDouble("Skills.Fishing.ShakeChance.Rank_" + rank); }
|
||||||
public int getFishingVanillaXPModifier(int rank) { return config.getInt("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank); }
|
public int getFishingVanillaXPModifier(int rank) { return config.getInt("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank); }
|
||||||
|
|
||||||
|
public int getFishingReductionMinWaitTicks() { return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Per_Rank.Min_Wait", 10);}
|
||||||
|
public int getFishingReductionMaxWaitTicks() { return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Per_Rank.Max_Wait", 30);}
|
||||||
|
public int getFishingBoatReductionMinWaitTicks() { return config.getInt("Skills.Fishing.MasterAngler.Boat_Tick_Reduction.Min_Wait", 10);}
|
||||||
|
public int getFishingBoatReductionMaxWaitTicks() { return config.getInt("Skills.Fishing.MasterAngler.Boat_Tick_Reduction.Max_Wait", 30);}
|
||||||
|
public int getFishingReductionMinWaitCap() { return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Caps.Min_Wait", 40);}
|
||||||
|
public int getFishingReductionMaxWaitCap() { return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Caps.Max_Wait", 100);}
|
||||||
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.FishermansDiet.RankChange", 200); }
|
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.FishermansDiet.RankChange", 200); }
|
||||||
|
|
||||||
/*public int getIceFishingUnlockLevel() { return config.getInt("Skills.Fishing.IceFishing.UnlockLevel", 50); }
|
/*public int getIceFishingUnlockLevel() { return config.getInt("Skills.Fishing.IceFishing.UnlockLevel", 50); }
|
||||||
@ -897,6 +742,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* MINING */
|
/* MINING */
|
||||||
public boolean getDoubleDropSilkTouchEnabled() { return config.getBoolean("Skills.Mining.DoubleDrops.SilkTouch", true); }
|
public boolean getDoubleDropSilkTouchEnabled() { return config.getBoolean("Skills.Mining.DoubleDrops.SilkTouch", true); }
|
||||||
|
public boolean getAllowMiningTripleDrops() { return config.getBoolean("Skills.Mining.SuperBreaker.AllowTripleDrops", true); }
|
||||||
public int getBlastMiningRankLevel(int rank) { return config.getInt("Skills.Mining.BlastMining.Rank_Levels.Rank_" + rank); }
|
public int getBlastMiningRankLevel(int rank) { return config.getInt("Skills.Mining.BlastMining.Rank_Levels.Rank_" + rank); }
|
||||||
public double getBlastDamageDecrease(int rank) { return config.getDouble("Skills.Mining.BlastMining.BlastDamageDecrease.Rank_" + rank); }
|
public double getBlastDamageDecrease(int rank) { return config.getDouble("Skills.Mining.BlastMining.BlastDamageDecrease.Rank_" + rank); }
|
||||||
public double getOreBonus(int rank) { return config.getDouble("Skills.Mining.BlastMining.OreBonus.Rank_" + rank); }
|
public double getOreBonus(int rank) { return config.getDouble("Skills.Mining.BlastMining.OreBonus.Rank_" + rank); }
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.config;
|
|||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -18,6 +19,19 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
|||||||
super(fileName);
|
super(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void saveConfig() {
|
||||||
|
try {
|
||||||
|
plugin.getLogger().info("Saving changes to config file - "+fileName);
|
||||||
|
config.save(configFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected @NotNull FileConfiguration getInternalConfig() {
|
||||||
|
return YamlConfiguration.loadConfiguration(plugin.getResourceAsReader(fileName));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadFile() {
|
protected void loadFile() {
|
||||||
super.loadFile();
|
super.loadFile();
|
||||||
|
56
src/main/java/com/gmail/nossr50/config/ChatConfig.java
Normal file
56
src/main/java/com/gmail/nossr50/config/ChatConfig.java
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class ChatConfig extends AutoUpdateConfigLoader {
|
||||||
|
private static ChatConfig instance;
|
||||||
|
|
||||||
|
private ChatConfig() {
|
||||||
|
super("chat.yml");
|
||||||
|
validate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ChatConfig getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new ChatConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadKeys() {
|
||||||
|
//Sigh this old config system...
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean validateKeys() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isChatEnabled() {
|
||||||
|
return config.getBoolean("Chat.Enable", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isChatChannelEnabled(@NotNull ChatChannel chatChannel) {
|
||||||
|
String key = "Chat.Channels." + StringUtils.getCapitalized(chatChannel.toString()) + ".Enable";
|
||||||
|
return config.getBoolean(key, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not to use display names for players in target {@link ChatChannel}
|
||||||
|
* @param chatChannel target chat channel
|
||||||
|
* @return true if display names should be used
|
||||||
|
*/
|
||||||
|
public boolean useDisplayNames(@NotNull ChatChannel chatChannel) {
|
||||||
|
String key = "Chat.Channels." + StringUtils.getCapitalized(chatChannel.toString()) + ".Use_Display_Names";
|
||||||
|
return config.getBoolean(key, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSpyingAutomatic() {
|
||||||
|
return config.getBoolean("Chat.Channels.Party.Spies.Automatically_Enable_Spying", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,7 +5,7 @@ import com.gmail.nossr50.datatypes.MobHealthBarType;
|
|||||||
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
import com.gmail.nossr50.datatypes.party.PartyFeature;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -259,13 +259,6 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
|
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
|
||||||
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
|
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
|
||||||
|
|
||||||
public String getPartyChatPrefix() { return config.getString("Commands.partychat.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
|
|
||||||
public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.partychat.Gold_Leader_Name", true); }
|
|
||||||
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.partychat.Use_Display_Names", true); }
|
|
||||||
public String getPartyChatPrefixAlly() { return config.getString("Commands.partychat.Chat_Prefix_Format_Ally", "[[GREEN]](A)[[RESET]]"); }
|
|
||||||
|
|
||||||
public String getAdminChatPrefix() { return config.getString("Commands.adminchat.Chat_Prefix_Format", "[[AQUA]][[[WHITE]]{0}[[AQUA]]]"); }
|
|
||||||
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.adminchat.Use_Display_Names", true); }
|
|
||||||
|
|
||||||
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
|
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
|
||||||
public long getDatabasePlayerCooldown() { return config.getLong("Commands.Database.Player_Cooldown", 1750); }
|
public long getDatabasePlayerCooldown() { return config.getLong("Commands.Database.Player_Cooldown", 1750); }
|
||||||
@ -451,7 +444,7 @@ public class Config extends AutoUpdateConfigLoader {
|
|||||||
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); }
|
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); }
|
||||||
|
|
||||||
/* Thresholds */
|
/* Thresholds */
|
||||||
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
|
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 1000); }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SKILL SETTINGS
|
* SKILL SETTINGS
|
||||||
|
@ -10,7 +10,7 @@ import java.util.List;
|
|||||||
public abstract class ConfigLoader {
|
public abstract class ConfigLoader {
|
||||||
protected static final mcMMO plugin = mcMMO.p;
|
protected static final mcMMO plugin = mcMMO.p;
|
||||||
protected String fileName;
|
protected String fileName;
|
||||||
private final File configFile;
|
protected final File configFile;
|
||||||
protected FileConfiguration config;
|
protected FileConfiguration config;
|
||||||
|
|
||||||
public ConfigLoader(String relativePath, String fileName) {
|
public ConfigLoader(String relativePath, String fileName) {
|
||||||
|
@ -2,7 +2,7 @@ package com.gmail.nossr50.config;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
|
|
||||||
public class CoreSkillsConfig extends AutoUpdateConfigLoader {
|
public class CoreSkillsConfig extends AutoUpdateConfigLoader {
|
||||||
private static CoreSkillsConfig instance;
|
private static CoreSkillsConfig instance;
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.gmail.nossr50.config;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.util.compat.layers.persistentdata.MobMetaFlagType;
|
||||||
|
|
||||||
|
public class PersistentDataConfig extends AutoUpdateConfigLoader {
|
||||||
|
private static PersistentDataConfig instance;
|
||||||
|
|
||||||
|
private PersistentDataConfig() {
|
||||||
|
super("persistent_data.yml");
|
||||||
|
validate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PersistentDataConfig getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new PersistentDataConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadKeys() {
|
||||||
|
//Sigh this old config system...
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean validateKeys() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Persistent Data Toggles
|
||||||
|
public boolean isMobPersistent(MobMetaFlagType mobMetaFlagType) {
|
||||||
|
String key = "Persistent_Data.Mobs.Flags." + mobMetaFlagType.toString() + ".Saved_To_Disk";
|
||||||
|
return config.getBoolean(key, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,8 +2,10 @@ package com.gmail.nossr50.config;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class RankConfig extends AutoUpdateConfigLoader {
|
public class RankConfig extends AutoUpdateConfigLoader {
|
||||||
@ -54,6 +56,18 @@ public class RankConfig extends AutoUpdateConfigLoader {
|
|||||||
return findRankByRootAddress(rank, key);
|
return findRankByRootAddress(rank, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the unlock level for a subskill depending on the gamemode
|
||||||
|
* @param subSkillType target subskill
|
||||||
|
* @param rank the rank we are checking
|
||||||
|
* @return the level requirement for a subskill at this particular rank
|
||||||
|
*/
|
||||||
|
public int getSubSkillUnlockLevel(SubSkillType subSkillType, int rank, boolean retroMode)
|
||||||
|
{
|
||||||
|
String key = getRankAddressKey(subSkillType, rank, retroMode);
|
||||||
|
return config.getInt(key, getInternalConfig().getInt(key));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the unlock level for a subskill depending on the gamemode
|
* Returns the unlock level for a subskill depending on the gamemode
|
||||||
* @param abstractSubSkill target subskill
|
* @param abstractSubSkill target subskill
|
||||||
@ -84,12 +98,61 @@ public class RankConfig extends AutoUpdateConfigLoader {
|
|||||||
return config.getInt(key);
|
return config.getInt(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRankAddressKey(SubSkillType subSkillType, int rank, boolean retroMode) {
|
||||||
|
String key = subSkillType.getRankConfigAddress();
|
||||||
|
String scalingKey = retroMode ? ".RetroMode." : ".Standard.";
|
||||||
|
|
||||||
|
String targetRank = "Rank_" + rank;
|
||||||
|
|
||||||
|
key += scalingKey;
|
||||||
|
key += targetRank;
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRankAddressKey(AbstractSubSkill subSkillType, int rank, boolean retroMode) {
|
||||||
|
String key = subSkillType.getPrimaryKeyName() + "." + subSkillType.getConfigKeyName();
|
||||||
|
String scalingKey = retroMode ? ".RetroMode." : ".Standard.";
|
||||||
|
|
||||||
|
String targetRank = "Rank_" + rank;
|
||||||
|
|
||||||
|
key += scalingKey;
|
||||||
|
key += targetRank;
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetRankValue(@NotNull SubSkillType subSkillType, int rank, boolean retroMode) {
|
||||||
|
String key = getRankAddressKey(subSkillType, rank, retroMode);
|
||||||
|
int defaultValue = getInternalConfig().getInt(key);
|
||||||
|
config.set(key, defaultValue);
|
||||||
|
plugin.getLogger().info(key +" SET -> " + defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for valid keys for subskill ranks
|
* Checks for valid keys for subskill ranks
|
||||||
*/
|
*/
|
||||||
private void checkKeys(List<String> reasons)
|
private void checkKeys(@NotNull List<String> reasons)
|
||||||
{
|
{
|
||||||
|
HashSet<SubSkillType> badSkillSetup = new HashSet<>();
|
||||||
|
|
||||||
//For now we will only check ranks of stuff I've overhauled
|
//For now we will only check ranks of stuff I've overhauled
|
||||||
|
checkConfig(reasons, badSkillSetup, true);
|
||||||
|
checkConfig(reasons, badSkillSetup, false);
|
||||||
|
|
||||||
|
//Fix bad entries
|
||||||
|
if(badSkillSetup.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
plugin.getLogger().info("(FIXING CONFIG) mcMMO is correcting a few mistakes found in your skill rank config setup");
|
||||||
|
|
||||||
|
for(SubSkillType subSkillType : badSkillSetup) {
|
||||||
|
plugin.getLogger().info("(FIXING CONFIG) Resetting rank config settings for skill named - "+subSkillType.toString());
|
||||||
|
fixBadEntries(subSkillType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkConfig(@NotNull List<String> reasons, @NotNull HashSet<SubSkillType> badSkillSetup, boolean retroMode) {
|
||||||
for(SubSkillType subSkillType : SubSkillType.values())
|
for(SubSkillType subSkillType : SubSkillType.values())
|
||||||
{
|
{
|
||||||
//Keeping track of the rank requirements and making sure there are no logical errors
|
//Keeping track of the rank requirements and making sure there are no logical errors
|
||||||
@ -98,23 +161,42 @@ public class RankConfig extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
for(int x = 0; x < subSkillType.getNumRanks(); x++)
|
for(int x = 0; x < subSkillType.getNumRanks(); x++)
|
||||||
{
|
{
|
||||||
|
int index = x+1;
|
||||||
|
|
||||||
if(curRank > 0)
|
if(curRank > 0)
|
||||||
prevRank = curRank;
|
prevRank = curRank;
|
||||||
|
|
||||||
curRank = getSubSkillUnlockLevel(subSkillType, x);
|
curRank = getSubSkillUnlockLevel(subSkillType, index, retroMode);
|
||||||
|
|
||||||
//Do we really care if its below 0? Probably not
|
//Do we really care if its below 0? Probably not
|
||||||
if(curRank < 0)
|
if(curRank < 0)
|
||||||
{
|
{
|
||||||
reasons.add(subSkillType.getAdvConfigAddress() + ".Rank_Levels.Rank_"+curRank+".LevelReq should be above or equal to 0!");
|
reasons.add("(CONFIG ISSUE) " + subSkillType.toString() + " should not have any ranks that require a negative level!");
|
||||||
|
badSkillSetup.add(subSkillType);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(prevRank > curRank)
|
if(prevRank > curRank)
|
||||||
{
|
{
|
||||||
//We're going to allow this but we're going to warn them
|
//We're going to allow this but we're going to warn them
|
||||||
plugin.getLogger().info("You have the ranks for the subskill "+ subSkillType.toString()+" set up poorly, sequential ranks should have ascending requirements");
|
plugin.getLogger().info("(CONFIG ISSUE) You have the ranks for the subskill "+ subSkillType.toString()+" set up poorly, sequential ranks should have ascending requirements");
|
||||||
|
badSkillSetup.add(subSkillType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fixBadEntries(@NotNull SubSkillType subSkillType) {
|
||||||
|
for(int x = 0; x < subSkillType.getNumRanks(); x++)
|
||||||
|
{
|
||||||
|
int index = x+1;
|
||||||
|
|
||||||
|
//Reset Retromode entries
|
||||||
|
resetRankValue(subSkillType, index, true);
|
||||||
|
//Reset Standard Entries
|
||||||
|
resetRankValue(subSkillType, index, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import com.gmail.nossr50.datatypes.experience.FormulaType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
@ -175,6 +175,9 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
|||||||
|
|
||||||
/* Spawned Mob modifier */
|
/* Spawned Mob modifier */
|
||||||
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
|
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
|
||||||
|
public double getEggXpMultiplier() { return config.getDouble("Experience_Formula.Eggs.Multiplier", 0.0); }
|
||||||
|
public double getTamedMobXpMultiplier() { return config.getDouble("Experience_Formula.Player_Tamed.Multiplier", 0.0); }
|
||||||
|
public double getNetherPortalXpMultiplier() { return config.getDouble("Experience_Formula.Nether_Portal.Multiplier", 0.0); }
|
||||||
public double getBredMobXpMultiplier() { return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0); }
|
public double getBredMobXpMultiplier() { return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0); }
|
||||||
|
|
||||||
/* Skill modifiers */
|
/* Skill modifiers */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.gmail.nossr50.config.party;
|
package com.gmail.nossr50.config.party;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -3,7 +3,7 @@ package com.gmail.nossr50.config.treasure;
|
|||||||
import com.gmail.nossr50.config.ConfigLoader;
|
import com.gmail.nossr50.config.ConfigLoader;
|
||||||
import com.gmail.nossr50.datatypes.treasure.*;
|
import com.gmail.nossr50.datatypes.treasure.*;
|
||||||
import com.gmail.nossr50.util.EnchantmentUtils;
|
import com.gmail.nossr50.util.EnchantmentUtils;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Tag;
|
import org.bukkit.Tag;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.database;
|
package com.gmail.nossr50.database;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
||||||
import com.gmail.nossr50.api.exceptions.ProfileRetrievalException;
|
import com.gmail.nossr50.api.exceptions.ProfileRetrievalException;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
import com.gmail.nossr50.datatypes.database.DatabaseType;
|
||||||
@ -65,7 +66,7 @@ public interface DatabaseManager {
|
|||||||
* @param statsPerPage The number of stats per page
|
* @param statsPerPage The number of stats per page
|
||||||
* @return the requested leaderboard information
|
* @return the requested leaderboard information
|
||||||
*/
|
*/
|
||||||
@NotNull List<PlayerStat> readLeaderboard(@NotNull PrimarySkillType skill, int pageNumber, int statsPerPage);
|
@NotNull List<PlayerStat> readLeaderboard(@NotNull PrimarySkillType skill, int pageNumber, int statsPerPage) throws InvalidSkillException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve rank info into a HashMap from PrimarySkillType to the rank.
|
* Retrieve rank info into a HashMap from PrimarySkillType to the rank.
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.database;
|
package com.gmail.nossr50.database;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
||||||
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.api.exceptions.ProfileRetrievalException;
|
import com.gmail.nossr50.api.exceptions.ProfileRetrievalException;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.MobHealthBarType;
|
import com.gmail.nossr50.datatypes.MobHealthBarType;
|
||||||
@ -403,9 +405,16 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull List<PlayerStat> readLeaderboard(@NotNull PrimarySkillType skill, int pageNumber, int statsPerPage) {
|
public @NotNull List<PlayerStat> readLeaderboard(@NotNull PrimarySkillType skill, int pageNumber, int statsPerPage) throws InvalidSkillException {
|
||||||
List<PlayerStat> stats = new ArrayList<>();
|
List<PlayerStat> stats = new ArrayList<>();
|
||||||
|
|
||||||
|
//Fix for a plugin that people are using that is throwing SQL errors
|
||||||
|
if(skill.isChildSkill()) {
|
||||||
|
mcMMO.p.getLogger().severe("A plugin hooking into mcMMO is being naughty with our database commands, update all plugins that hook into mcMMO and contact their devs!");
|
||||||
|
throw new InvalidSkillException("A plugin hooking into mcMMO that you are using is attempting to read leaderboard skills for child skills, child skills do not have leaderboards! This is NOT an mcMMO error!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String query = skill == null ? ALL_QUERY_VERSION : skill.name().toLowerCase(Locale.ENGLISH);
|
String query = skill == null ? ALL_QUERY_VERSION : skill.name().toLowerCase(Locale.ENGLISH);
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
package com.gmail.nossr50.datatypes.chat;
|
package com.gmail.nossr50.datatypes.chat;
|
||||||
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public enum ChatMode {
|
public enum ChatChannel {
|
||||||
ADMIN(LocaleLoader.getString("Commands.AdminChat.On"), LocaleLoader.getString("Commands.AdminChat.Off")),
|
ADMIN(LocaleLoader.getString("Commands.AdminChat.On"), LocaleLoader.getString("Commands.AdminChat.Off")),
|
||||||
PARTY(LocaleLoader.getString("Commands.Party.Chat.On"), LocaleLoader.getString("Commands.Party.Chat.Off"));
|
PARTY(LocaleLoader.getString("Commands.Party.Chat.On"), LocaleLoader.getString("Commands.Party.Chat.Off")),
|
||||||
|
PARTY_OFFICER(null, null),
|
||||||
|
NONE(null, null);
|
||||||
|
|
||||||
private final String enabledMessage;
|
private final String enabledMessage;
|
||||||
private final String disabledMessage;
|
private final String disabledMessage;
|
||||||
|
|
||||||
ChatMode(String enabledMessage, String disabledMessage) {
|
ChatChannel(@Nullable String enabledMessage, @Nullable String disabledMessage) {
|
||||||
this.enabledMessage = enabledMessage;
|
this.enabledMessage = enabledMessage;
|
||||||
this.disabledMessage = disabledMessage;
|
this.disabledMessage = disabledMessage;
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package com.gmail.nossr50.datatypes.json;
|
package com.gmail.nossr50.datatypes.json;
|
||||||
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
|
|
||||||
public enum McMMOWebLinks {
|
public enum McMMOWebLinks {
|
||||||
WEBSITE,
|
WEBSITE,
|
||||||
|
@ -2,7 +2,7 @@ package com.gmail.nossr50.datatypes.party;
|
|||||||
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public enum ItemShareType {
|
public enum ItemShareType {
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
package com.gmail.nossr50.datatypes.party;
|
package com.gmail.nossr50.datatypes.party;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.chat.SamePartyPredicate;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -12,8 +16,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
public class Party {
|
public class Party {
|
||||||
|
private final @NotNull Predicate<CommandSender> samePartyPredicate;
|
||||||
private final @NotNull PersistentPartyData persistentPartyData;
|
private final @NotNull PersistentPartyData persistentPartyData;
|
||||||
private final @NotNull PartyMemberManager partyMemberManager;
|
private final @NotNull PartyMemberManager partyMemberManager;
|
||||||
private final @NotNull PartyExperienceManager partyExperienceManager;
|
private final @NotNull PartyExperienceManager partyExperienceManager;
|
||||||
@ -22,8 +28,9 @@ public class Party {
|
|||||||
this.persistentPartyData = persistentPartyData;
|
this.persistentPartyData = persistentPartyData;
|
||||||
|
|
||||||
//Initialize Managers
|
//Initialize Managers
|
||||||
partyMemberManager = new PartyMemberManager();
|
partyMemberManager = new PartyMemberManager(persistentPartyData);
|
||||||
partyExperienceManager = new PartyExperienceManager();
|
partyExperienceManager = new PartyExperienceManager();
|
||||||
|
samePartyPredicate = new SamePartyPredicate<>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull PartyMemberManager getPartyMemberManager() {
|
public @NotNull PartyMemberManager getPartyMemberManager() {
|
||||||
@ -80,9 +87,35 @@ public class Party {
|
|||||||
* @return formatted list of party members from the POV of a player
|
* @return formatted list of party members from the POV of a player
|
||||||
*/
|
*/
|
||||||
public String createMembersList(Player player) {
|
public String createMembersList(Player player) {
|
||||||
/* BUILD THE PARTY LIST WITH FORMATTING */
|
StringBuilder memberList = new StringBuilder();
|
||||||
boolean useDisplayNames = Config.getInstance().getPartyDisplayNames();
|
List<String> coloredNames = new ArrayList<>();
|
||||||
StringBuilder formattedPartyMemberList = new StringBuilder();
|
|
||||||
|
for(UUID playerUUID : members.keySet()) {
|
||||||
|
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerUUID);
|
||||||
|
|
||||||
|
if(offlinePlayer.isOnline() && player.canSee((Player) offlinePlayer)) {
|
||||||
|
ChatColor onlineColor = leader.getUniqueId().equals(playerUUID) ? ChatColor.GOLD : ChatColor.GREEN;
|
||||||
|
coloredNames.add(onlineColor + offlinePlayer.getName());
|
||||||
|
} else {
|
||||||
|
coloredNames.add(ChatColor.DARK_GRAY + members.get(playerUUID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildChatMessage(memberList, coloredNames.toArray(new String[0]));
|
||||||
|
return memberList.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildChatMessage(@NotNull StringBuilder stringBuilder, String @NotNull [] names) {
|
||||||
|
for(int i = 0; i < names.length; i++) {
|
||||||
|
if(i + 1 >= names.length) {
|
||||||
|
stringBuilder
|
||||||
|
.append(names[i]);
|
||||||
|
} else {
|
||||||
|
stringBuilder
|
||||||
|
.append(names[i])
|
||||||
|
.append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -124,4 +157,8 @@ public class Party {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(persistentPartyData);
|
return Objects.hashCode(persistentPartyData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @NotNull Predicate<CommandSender> getSamePartyPredicate() {
|
||||||
|
return samePartyPredicate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import com.gmail.nossr50.commands.party.PartySubCommandType;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public enum PartyFeature {
|
public enum PartyFeature {
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
package com.gmail.nossr50.datatypes.player;
|
package com.gmail.nossr50.datatypes.player;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.WorldBlacklist;
|
import com.gmail.nossr50.config.WorldBlacklist;
|
||||||
import com.gmail.nossr50.datatypes.chat.ChatMode;
|
import com.gmail.nossr50.chat.author.PlayerAuthor;
|
||||||
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
|
import com.gmail.nossr50.config.ChatConfig;
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
|
import com.gmail.nossr50.datatypes.experience.XPGainSource;
|
||||||
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.interfaces.Toolable;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
@ -30,7 +39,12 @@ import com.gmail.nossr50.util.Permissions;
|
|||||||
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
|
||||||
import com.gmail.nossr50.util.input.AbilityActivationProcessor;
|
import com.gmail.nossr50.util.input.AbilityActivationProcessor;
|
||||||
import com.gmail.nossr50.util.input.SuperAbilityManager;
|
import com.gmail.nossr50.util.input.SuperAbilityManager;
|
||||||
|
import com.gmail.nossr50.util.player.NotificationManager;
|
||||||
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
|
import net.kyori.adventure.identity.Identified;
|
||||||
|
import net.kyori.adventure.identity.Identity;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -39,10 +53,14 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class McMMOPlayer extends PlayerProfile {
|
public class McMMOPlayer extends PlayerProfile implements Identified {
|
||||||
private final @NotNull Player player;
|
private final @NotNull Player player;
|
||||||
|
private final @NotNull Identity identity;
|
||||||
|
|
||||||
|
//Used in our chat systems for chat messages
|
||||||
|
private final @NotNull PlayerAuthor playerAuthor;
|
||||||
private final @NotNull Map<PrimarySkillType, SkillManager> skillManagers = new HashMap<>();
|
private final @NotNull Map<PrimarySkillType, SkillManager> skillManagers = new HashMap<>();
|
||||||
private final @NotNull MMOExperienceBarManager experienceBarManager;
|
private final @NotNull MMOExperienceBarManager experienceBarManager;
|
||||||
|
|
||||||
@ -55,6 +73,9 @@ public class McMMOPlayer extends PlayerProfile {
|
|||||||
private boolean godMode;
|
private boolean godMode;
|
||||||
private boolean displaySkillNotifications = true;
|
private boolean displaySkillNotifications = true;
|
||||||
|
|
||||||
|
private ChatChannel chatChannel;
|
||||||
|
private boolean chatSpy = false; //Off by default
|
||||||
|
|
||||||
private int recentlyHurt;
|
private int recentlyHurt;
|
||||||
private int respawnATS;
|
private int respawnATS;
|
||||||
private int teleportATS;
|
private int teleportATS;
|
||||||
@ -76,6 +97,8 @@ public class McMMOPlayer extends PlayerProfile {
|
|||||||
* Player
|
* Player
|
||||||
*/
|
*/
|
||||||
super(player);
|
super(player);
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
identity = Identity.identity(uuid);
|
||||||
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
playerMetadata = new FixedMetadataValue(mcMMO.p, player.getName());
|
playerMetadata = new FixedMetadataValue(mcMMO.p, player.getName());
|
||||||
@ -84,6 +107,17 @@ public class McMMOPlayer extends PlayerProfile {
|
|||||||
superAbilityManager = new SuperAbilityManager(this);
|
superAbilityManager = new SuperAbilityManager(this);
|
||||||
abilityActivationProcessor = new AbilityActivationProcessor(this);
|
abilityActivationProcessor = new AbilityActivationProcessor(this);
|
||||||
|
|
||||||
|
debugMode = false; //Debug mode helps solve support issues, players can toggle it on or off
|
||||||
|
|
||||||
|
this.playerAuthor = new PlayerAuthor(player);
|
||||||
|
|
||||||
|
this.chatChannel = ChatChannel.NONE;
|
||||||
|
|
||||||
|
if(ChatConfig.getInstance().isSpyingAutomatic() && Permissions.adminChatSpy(getPlayer())) {
|
||||||
|
chatSpy = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Update last login
|
//Update last login
|
||||||
updateLastLogin();
|
updateLastLogin();
|
||||||
}
|
}
|
||||||
@ -99,9 +133,10 @@ public class McMMOPlayer extends PlayerProfile {
|
|||||||
* Player
|
* Player
|
||||||
*/
|
*/
|
||||||
super(persistentPlayerData);
|
super(persistentPlayerData);
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
this.player = player;
|
identity = Identity.identity(uuid);
|
||||||
playerMetadata = new FixedMetadataValue(mcMMO.p, player.getName());
|
playerMetadata = new FixedMetadataValue(mcMMO.p, player.getName());
|
||||||
|
this.player = player;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually),
|
* I'm using this method because it makes code shorter and safer (we don't have to add all SkillTypes manually),
|
||||||
@ -122,6 +157,16 @@ public class McMMOPlayer extends PlayerProfile {
|
|||||||
abilityActivationProcessor = new AbilityActivationProcessor(this);
|
abilityActivationProcessor = new AbilityActivationProcessor(this);
|
||||||
experienceBarManager = new MMOExperienceBarManager(this, persistentPlayerData.getBarStateMap());
|
experienceBarManager = new MMOExperienceBarManager(this, persistentPlayerData.getBarStateMap());
|
||||||
|
|
||||||
|
debugMode = false; //Debug mode helps solve support issues, players can toggle it on or off
|
||||||
|
|
||||||
|
this.playerAuthor = new PlayerAuthor(player);
|
||||||
|
|
||||||
|
this.chatChannel = ChatChannel.NONE;
|
||||||
|
|
||||||
|
if(ChatConfig.getInstance().isSpyingAutomatic() && Permissions.adminChatSpy(getPlayer())) {
|
||||||
|
chatSpy = true;
|
||||||
|
}
|
||||||
|
|
||||||
//Update last login
|
//Update last login
|
||||||
updateLastLogin();
|
updateLastLogin();
|
||||||
}
|
}
|
||||||
@ -133,6 +178,10 @@ public class McMMOPlayer extends PlayerProfile {
|
|||||||
getPersistentPlayerData().setLastLogin(System.currentTimeMillis());
|
getPersistentPlayerData().setLastLogin(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @NotNull String getPlayerName() {
|
||||||
|
return player.getName();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grab the {@link MMOExperienceBarManager} for this player
|
* Grab the {@link MMOExperienceBarManager} for this player
|
||||||
* @return this player's experience bar manager
|
* @return this player's experience bar manager
|
||||||
@ -422,77 +471,12 @@ public class McMMOPlayer extends PlayerProfile {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Chat modes
|
|
||||||
*/
|
|
||||||
|
|
||||||
public boolean isChatEnabled(ChatMode mode) {
|
|
||||||
switch (mode) {
|
|
||||||
case ADMIN:
|
|
||||||
return adminChatMode;
|
|
||||||
|
|
||||||
case PARTY:
|
|
||||||
return partyChatMode;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disableChat(ChatMode mode) {
|
|
||||||
switch (mode) {
|
|
||||||
case ADMIN:
|
|
||||||
adminChatMode = false;
|
|
||||||
return;
|
|
||||||
|
|
||||||
case PARTY:
|
|
||||||
partyChatMode = false;
|
|
||||||
return;
|
|
||||||
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enableChat(ChatMode mode) {
|
|
||||||
switch (mode) {
|
|
||||||
case ADMIN:
|
|
||||||
adminChatMode = true;
|
|
||||||
partyChatMode = false;
|
|
||||||
return;
|
|
||||||
|
|
||||||
case PARTY:
|
|
||||||
partyChatMode = true;
|
|
||||||
adminChatMode = false;
|
|
||||||
return;
|
|
||||||
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void toggleChat(ChatMode mode) {
|
|
||||||
switch (mode) {
|
|
||||||
case ADMIN:
|
|
||||||
adminChatMode = !adminChatMode;
|
|
||||||
partyChatMode = !adminChatMode && partyChatMode;
|
|
||||||
return;
|
|
||||||
|
|
||||||
case PARTY:
|
|
||||||
partyChatMode = !partyChatMode;
|
|
||||||
adminChatMode = !partyChatMode && adminChatMode;
|
|
||||||
return;
|
|
||||||
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the experience bars for this player
|
* Update the experience bars for this player
|
||||||
* @param primarySkillType target skill
|
* @param primarySkillType target skill
|
||||||
* @param plugin your {@link Plugin}
|
* @param plugin your {@link Plugin}
|
||||||
*/
|
*/
|
||||||
public void updateXPBar(PrimarySkillType primarySkillType, Plugin plugin)
|
public void updateXPBar(PrimarySkillType primarySkillType, Plugin plugin) {
|
||||||
{
|
|
||||||
//XP BAR UPDATES
|
//XP BAR UPDATES
|
||||||
experienceBarManager.updateExperienceBar(primarySkillType, plugin);
|
experienceBarManager.updateExperienceBar(primarySkillType, plugin);
|
||||||
}
|
}
|
||||||
@ -508,6 +492,13 @@ public class McMMOPlayer extends PlayerProfile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkParty() {
|
||||||
|
if (inParty() && !Permissions.party(player)) {
|
||||||
|
removeParty();
|
||||||
|
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the time remaining until the superAbilityType's cooldown expires.
|
* Calculate the time remaining until the superAbilityType's cooldown expires.
|
||||||
*
|
*
|
||||||
@ -515,7 +506,7 @@ public class McMMOPlayer extends PlayerProfile {
|
|||||||
*
|
*
|
||||||
* @return the number of seconds remaining before the cooldown expires
|
* @return the number of seconds remaining before the cooldown expires
|
||||||
*/
|
*/
|
||||||
public int calculateTimeRemaining(SuperAbilityType superAbilityType) {
|
public int getCooldownSeconds(SuperAbilityType superAbilityType) {
|
||||||
return superAbilityManager.calculateTimeRemaining(superAbilityType);
|
return superAbilityManager.calculateTimeRemaining(superAbilityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,8 +561,33 @@ public class McMMOPlayer extends PlayerProfile {
|
|||||||
getPersistentPlayerData().togglePartyChatSpying();
|
getPersistentPlayerData().togglePartyChatSpying();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Rewrite this
|
/**
|
||||||
public double getAttackStrength() {
|
* For use with Adventure API (Kyori lib)
|
||||||
return 1.0F;
|
* @return this players identity
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public @NotNull Identity identity() {
|
||||||
|
return identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link com.gmail.nossr50.chat.author.Author} for this player, used by mcMMO chat
|
||||||
|
* @return the {@link com.gmail.nossr50.chat.author.Author} for this player
|
||||||
|
*/
|
||||||
|
public @NotNull PlayerAuthor getPlayerAuthor() {
|
||||||
|
return playerAuthor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull ChatChannel getChatChannel() {
|
||||||
|
return chatChannel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the chat channel for a player
|
||||||
|
* This does not inform the player
|
||||||
|
* @param chatChannel new chat channel
|
||||||
|
*/
|
||||||
|
public void setChatMode(@NotNull ChatChannel chatChannel) {
|
||||||
|
this.chatChannel = chatChannel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ import com.gmail.nossr50.skills.tridents.TridentManager;
|
|||||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
import com.gmail.nossr50.util.skills.RankUtils;
|
||||||
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -65,7 +65,7 @@ public enum PrimarySkillType {
|
|||||||
UNARMED(UnarmedManager.class, Color.BLACK, SuperAbilityType.BERSERK,
|
UNARMED(UnarmedManager.class, Color.BLACK, SuperAbilityType.BERSERK,
|
||||||
ImmutableList.of(SubSkillType.UNARMED_BERSERK, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK, SubSkillType.UNARMED_BLOCK_CRACKER, SubSkillType.UNARMED_ARROW_DEFLECT, SubSkillType.UNARMED_DISARM, SubSkillType.UNARMED_STEEL_ARM_STYLE, SubSkillType.UNARMED_IRON_GRIP)),
|
ImmutableList.of(SubSkillType.UNARMED_BERSERK, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK, SubSkillType.UNARMED_BLOCK_CRACKER, SubSkillType.UNARMED_ARROW_DEFLECT, SubSkillType.UNARMED_DISARM, SubSkillType.UNARMED_STEEL_ARM_STYLE, SubSkillType.UNARMED_IRON_GRIP)),
|
||||||
WOODCUTTING(WoodcuttingManager.class, Color.OLIVE, SuperAbilityType.TREE_FELLER,
|
WOODCUTTING(WoodcuttingManager.class, Color.OLIVE, SuperAbilityType.TREE_FELLER,
|
||||||
ImmutableList.of(SubSkillType.WOODCUTTING_LEAF_BLOWER, SubSkillType.WOODCUTTING_TREE_FELLER, SubSkillType.WOODCUTTING_HARVEST_LUMBER)),
|
ImmutableList.of(SubSkillType.WOODCUTTING_LEAF_BLOWER, SubSkillType.WOODCUTTING_TREE_FELLER, SubSkillType.WOODCUTTING_HARVEST_LUMBER, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD)),
|
||||||
TRIDENTS(TridentManager.class, Color.TEAL, ImmutableList.of(SubSkillType.TRIDENTS_MULTI_TASKING, SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK)),
|
TRIDENTS(TridentManager.class, Color.TEAL, ImmutableList.of(SubSkillType.TRIDENTS_MULTI_TASKING, SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK)),
|
||||||
CROSSBOWS(CrossbowManager.class, Color.ORANGE, ImmutableList.of(SubSkillType.CROSSBOWS_SUPER_SHOTGUN, SubSkillType.CROSSBOWS_CROSSBOWS_LIMIT_BREAK));
|
CROSSBOWS(CrossbowManager.class, Color.ORANGE, ImmutableList.of(SubSkillType.CROSSBOWS_SUPER_SHOTGUN, SubSkillType.CROSSBOWS_CROSSBOWS_LIMIT_BREAK));
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.gmail.nossr50.datatypes.skills;
|
package com.gmail.nossr50.datatypes.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ public enum SubSkillType {
|
|||||||
FISHING_FISHERMANS_DIET(5),
|
FISHING_FISHERMANS_DIET(5),
|
||||||
FISHING_ICE_FISHING(1),
|
FISHING_ICE_FISHING(1),
|
||||||
FISHING_MAGIC_HUNTER(1),
|
FISHING_MAGIC_HUNTER(1),
|
||||||
FISHING_MASTER_ANGLER(1),
|
FISHING_MASTER_ANGLER(8),
|
||||||
FISHING_TREASURE_HUNTER(8),
|
FISHING_TREASURE_HUNTER(8),
|
||||||
FISHING_SHAKE(1),
|
FISHING_SHAKE(1),
|
||||||
|
|
||||||
@ -101,6 +101,7 @@ public enum SubSkillType {
|
|||||||
|
|
||||||
/* Woodcutting */
|
/* Woodcutting */
|
||||||
/* WOODCUTTING_BARK_SURGEON(3),*/
|
/* WOODCUTTING_BARK_SURGEON(3),*/
|
||||||
|
WOODCUTTING_KNOCK_ON_WOOD(2),
|
||||||
WOODCUTTING_HARVEST_LUMBER(1),
|
WOODCUTTING_HARVEST_LUMBER(1),
|
||||||
WOODCUTTING_LEAF_BLOWER(1),
|
WOODCUTTING_LEAF_BLOWER(1),
|
||||||
/* WOODCUTTING_NATURES_BOUNTY(3),
|
/* WOODCUTTING_NATURES_BOUNTY(3),
|
||||||
|
@ -5,7 +5,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.BlockUtils;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -251,7 +251,7 @@ public enum SuperAbilityType {
|
|||||||
return BlockUtils.affectedBySuperBreaker(blockState);
|
return BlockUtils.affectedBySuperBreaker(blockState);
|
||||||
|
|
||||||
case TREE_FELLER:
|
case TREE_FELLER:
|
||||||
return BlockUtils.isLog(blockState);
|
return BlockUtils.hasWoodcuttingXP(blockState);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -6,7 +6,7 @@ import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
|||||||
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
|
import com.gmail.nossr50.datatypes.skills.subskills.interfaces.InteractType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import com.gmail.nossr50.util.skills.SkillActivationType;
|
|||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||||
import com.gmail.nossr50.util.sounds.SoundType;
|
import com.gmail.nossr50.util.sounds.SoundType;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -141,21 +142,21 @@ public class Roll extends AcrobaticsSubSkill {
|
|||||||
componentBuilder.append("\n");*/
|
componentBuilder.append("\n");*/
|
||||||
|
|
||||||
//Acrobatics.SubSkill.Roll.Chance
|
//Acrobatics.SubSkill.Roll.Chance
|
||||||
componentBuilder.append(LocaleLoader.getString("Acrobatics.SubSkill.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : ""));
|
componentBuilder.append(Component.text(LocaleLoader.getString("Acrobatics.SubSkill.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : "")));
|
||||||
componentBuilder.append("\n");
|
componentBuilder.append(Component.newline());
|
||||||
componentBuilder.append(LocaleLoader.getString("Acrobatics.SubSkill.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : ""));
|
componentBuilder.append(Component.text(LocaleLoader.getString("Acrobatics.SubSkill.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : "")));
|
||||||
//Activation Tips
|
//Activation Tips
|
||||||
componentBuilder.append("\n").append(LocaleLoader.getString("JSON.Hover.Tips")).append("\n");
|
componentBuilder.append(Component.newline()).append(Component.text(LocaleLoader.getString("JSON.Hover.Tips"))).append(Component.newline());
|
||||||
componentBuilder.append(getTips());
|
componentBuilder.append(Component.text(getTips()));
|
||||||
componentBuilder.append("\n");
|
componentBuilder.append(Component.newline());
|
||||||
//Advanced
|
//Advanced
|
||||||
|
|
||||||
//Lucky Notice
|
//Lucky Notice
|
||||||
if(isLucky)
|
if(isLucky)
|
||||||
{
|
{
|
||||||
componentBuilder.append(LocaleLoader.getString("JSON.JWrapper.Perks.Header"));
|
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.JWrapper.Perks.Header")));
|
||||||
componentBuilder.append("\n");
|
componentBuilder.append(Component.newline());
|
||||||
componentBuilder.append(LocaleLoader.getString("JSON.JWrapper.Perks.Lucky", "33"));
|
componentBuilder.append(Component.text(LocaleLoader.getString("JSON.JWrapper.Perks.Lucky", "33")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package com.gmail.nossr50.datatypes.skills.subskills.interfaces;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
|
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public interface SubSkill extends Skill {
|
public interface SubSkill extends Skill {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.gmail.nossr50.datatypes.skills.subskills.taming;
|
package com.gmail.nossr50.datatypes.skills.subskills.taming;
|
||||||
|
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.text.StringUtils;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
public enum CallOfTheWildType {
|
public enum CallOfTheWildType {
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
package com.gmail.nossr50.events.chat;
|
package com.gmail.nossr50.events.chat;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.chat.message.AbstractChatMessage;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a chat is sent to the admin chat channel
|
* Called when a chat is sent to the admin chat channel
|
||||||
*/
|
*/
|
||||||
public class McMMOAdminChatEvent extends McMMOChatEvent {
|
public class McMMOAdminChatEvent extends McMMOChatEvent {
|
||||||
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message) {
|
public McMMOAdminChatEvent(@NotNull Plugin plugin, @NotNull AbstractChatMessage chatMessage, boolean isAsync) {
|
||||||
super(plugin, sender, displayName, message);
|
super(plugin, chatMessage, isAsync);
|
||||||
}
|
|
||||||
|
|
||||||
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) {
|
|
||||||
super(plugin, sender, displayName, message, isAsync);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
package com.gmail.nossr50.events.chat;
|
package com.gmail.nossr50.events.chat;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.chat.author.Author;
|
||||||
|
import com.gmail.nossr50.chat.message.AbstractChatMessage;
|
||||||
|
import com.gmail.nossr50.chat.message.ChatMessage;
|
||||||
|
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
@ -8,66 +15,105 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public abstract class McMMOChatEvent extends Event implements Cancellable {
|
public abstract class McMMOChatEvent extends Event implements Cancellable {
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
private final Plugin plugin;
|
protected final @NotNull Plugin plugin;
|
||||||
private final String sender;
|
protected final @NotNull AbstractChatMessage chatMessage;
|
||||||
private String displayName;
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message) {
|
protected McMMOChatEvent(@NotNull Plugin plugin, @NotNull AbstractChatMessage chatMessage, boolean isAsync) {
|
||||||
this.plugin = plugin;
|
|
||||||
this.sender = sender;
|
|
||||||
this.displayName = displayName;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected McMMOChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) {
|
|
||||||
super(isAsync);
|
super(isAsync);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.sender = sender;
|
this.chatMessage = chatMessage;
|
||||||
this.displayName = displayName;
|
|
||||||
this.message = message;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The plugin responsible for this event, note this can be null
|
* The {@link Author} of this message
|
||||||
|
*
|
||||||
|
* @return the {@link Author} of this message
|
||||||
*/
|
*/
|
||||||
public Plugin getPlugin() {
|
public @NotNull Author getAuthor() {
|
||||||
|
return chatMessage.getAuthor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Audience} for this message
|
||||||
|
*
|
||||||
|
* @return the {@link Audience} for this message
|
||||||
|
*/
|
||||||
|
public @NotNull Audience getAudience() {
|
||||||
|
return chatMessage.getAudience();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the {@link Audience} for this message
|
||||||
|
*
|
||||||
|
* @param audience target {@link Audience}
|
||||||
|
*/
|
||||||
|
public void setAudience(@NotNull Audience audience) {
|
||||||
|
chatMessage.setAudience(audience);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The plugin responsible for this event
|
||||||
|
*/
|
||||||
|
public @NotNull Plugin getPlugin() {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String name of the player who sent the chat, or "Console"
|
* The name of the author
|
||||||
|
* Will return the display name if mcMMO chat config is set to, otherwise returns the players Mojang registered nickname
|
||||||
|
* @return the author's name
|
||||||
*/
|
*/
|
||||||
public String getSender() {
|
public @NotNull String getDisplayName(ChatChannel chatChannel) {
|
||||||
return sender;
|
return getAuthor().getAuthoredName(chatChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String display name of the player who sent the chat, or "Console"
|
* Don't use this method
|
||||||
|
*
|
||||||
|
* @return The raw message
|
||||||
|
* @deprecated use {@link #getComponentMessage()} instead
|
||||||
*/
|
*/
|
||||||
public String getDisplayName() {
|
@Deprecated
|
||||||
return displayName;
|
public @NotNull String getMessage() {
|
||||||
|
return chatMessage.rawMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String message that will be sent
|
* The original message typed by the player before any formatting
|
||||||
|
* The raw message is immutable
|
||||||
|
*
|
||||||
|
* @return the message as it was typed by the player, this is before any formatting
|
||||||
*/
|
*/
|
||||||
public String getMessage() {
|
public @NotNull String getRawMessage() {
|
||||||
return message;
|
return chatMessage.rawMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param displayName String display name of the player who sent the chat
|
* The {@link TextComponent} as it will be sent to all players which should include formatting such as adding chat prefixes, player names, etc
|
||||||
|
*
|
||||||
|
* @return the message that will be sent to the {@link Audience}
|
||||||
*/
|
*/
|
||||||
public void setDisplayName(String displayName) {
|
public @NotNull TextComponent getComponentMessage() {
|
||||||
this.displayName = displayName;
|
return chatMessage.getChatMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param message String message to be sent in chat
|
* This will be the final message sent to the audience, this should be the message after its been formatted and has had player names added to it etc
|
||||||
|
*
|
||||||
|
* @param chatMessage the new chat message
|
||||||
*/
|
*/
|
||||||
public void setMessage(String message) {
|
public void setMessagePayload(@NotNull TextComponent chatMessage) {
|
||||||
this.message = message;
|
this.chatMessage.setChatMessage(chatMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param message Adjusts the final message sent to players in the party
|
||||||
|
*
|
||||||
|
* @deprecated use {{@link #setMessagePayload(TextComponent)}}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void setMessage(@NotNull String message) {
|
||||||
|
chatMessage.setChatMessage(Component.text(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Following are required for Cancellable **/
|
/** Following are required for Cancellable **/
|
||||||
@ -82,14 +128,22 @@ public abstract class McMMOChatEvent extends Event implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Rest of file is required boilerplate for custom events **/
|
/** Rest of file is required boilerplate for custom events **/
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final @NotNull HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static @NotNull HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link ChatMessage}
|
||||||
|
* @return the chat message
|
||||||
|
*/
|
||||||
|
public @NotNull ChatMessage getChatMessage() {
|
||||||
|
return chatMessage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,43 @@
|
|||||||
package com.gmail.nossr50.events.chat;
|
package com.gmail.nossr50.events.chat;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.chat.message.PartyChatMessage;
|
||||||
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a chat is sent to a party channel
|
* Called when a chat is sent to a party channel
|
||||||
*/
|
*/
|
||||||
public class McMMOPartyChatEvent extends McMMOChatEvent {
|
public class McMMOPartyChatEvent extends McMMOChatEvent {
|
||||||
private final String party;
|
private final @NotNull String party; //Not going to break the API to rename this for now
|
||||||
|
private final @NotNull Party targetParty;
|
||||||
|
|
||||||
public McMMOPartyChatEvent(Plugin plugin, String sender, String displayName, String party, String message) {
|
public McMMOPartyChatEvent(@NotNull Plugin pluginRef, @NotNull PartyChatMessage chatMessage, @NotNull Party party, boolean isAsync) {
|
||||||
super(plugin, sender, displayName, message);
|
super(pluginRef, chatMessage, isAsync);
|
||||||
this.party = party;
|
this.party = party.getName();
|
||||||
}
|
this.targetParty = party;
|
||||||
|
|
||||||
public McMMOPartyChatEvent(Plugin plugin, String sender, String displayName, String party, String message, boolean isAsync) {
|
|
||||||
super(plugin, sender, displayName, message, isAsync);
|
|
||||||
this.party = party;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return String name of the party the message will be sent to
|
* @return String name of the party the message will be sent to
|
||||||
|
*
|
||||||
|
* @deprecated this will be removed in the future
|
||||||
*/
|
*/
|
||||||
public String getParty() {
|
@Deprecated
|
||||||
|
public @NotNull String getParty() {
|
||||||
return party;
|
return party;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public @NotNull PartyChatMessage getPartyChatMessage() {
|
||||||
|
return (PartyChatMessage) chatMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The authors party
|
||||||
|
*
|
||||||
|
* @return the party that this message will be delivered to
|
||||||
|
*/
|
||||||
|
public @NotNull Party getAuthorParty() {
|
||||||
|
return targetParty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import org.bukkit.event.block.BlockBreakEvent;
|
|||||||
/**
|
/**
|
||||||
* Called when mcMMO breaks a block due to a special ability.
|
* Called when mcMMO breaks a block due to a special ability.
|
||||||
*/
|
*/
|
||||||
public class FakeBlockBreakEvent extends BlockBreakEvent {
|
public class FakeBlockBreakEvent extends BlockBreakEvent implements FakeEvent {
|
||||||
public FakeBlockBreakEvent(Block theBlock, Player player) {
|
public FakeBlockBreakEvent(Block theBlock, Player player) {
|
||||||
super(theBlock, player);
|
super(theBlock, player);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
/**
|
/**
|
||||||
* Called when mcMMO damages a block due to a special ability.
|
* Called when mcMMO damages a block due to a special ability.
|
||||||
*/
|
*/
|
||||||
public class FakeBlockDamageEvent extends BlockDamageEvent {
|
public class FakeBlockDamageEvent extends BlockDamageEvent implements FakeEvent {
|
||||||
public FakeBlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) {
|
public FakeBlockDamageEvent(Player player, Block block, ItemStack itemInHand, boolean instaBreak) {
|
||||||
super(player, block, itemInHand, instaBreak);
|
super(player, block, itemInHand, instaBreak);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.event.inventory.BrewEvent;
|
import org.bukkit.event.inventory.BrewEvent;
|
||||||
import org.bukkit.inventory.BrewerInventory;
|
import org.bukkit.inventory.BrewerInventory;
|
||||||
|
|
||||||
public class FakeBrewEvent extends BrewEvent {
|
public class FakeBrewEvent extends BrewEvent implements FakeEvent {
|
||||||
public FakeBrewEvent(Block brewer, BrewerInventory contents, int fuelLevel) {
|
public FakeBrewEvent(Block brewer, BrewerInventory contents, int fuelLevel) {
|
||||||
super(brewer, contents, fuelLevel);
|
super(brewer, contents, fuelLevel);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* Called when mcMMO applies damage from an entity due to special abilities.
|
* Called when mcMMO applies damage from an entity due to special abilities.
|
||||||
*/
|
*/
|
||||||
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
|
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent implements FakeEvent {
|
||||||
|
|
||||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
|
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
|
||||||
super(damager, damagee, cause, modifiers, getFunctionModifiers(modifiers));
|
super(damager, damagee, cause, modifiers, getFunctionModifiers(modifiers));
|
||||||
|
@ -11,7 +11,7 @@ import java.util.Map;
|
|||||||
/**
|
/**
|
||||||
* Called when mcMMO applies damage due to special abilities.
|
* Called when mcMMO applies damage due to special abilities.
|
||||||
*/
|
*/
|
||||||
public class FakeEntityDamageEvent extends EntityDamageEvent {
|
public class FakeEntityDamageEvent extends EntityDamageEvent implements FakeEvent {
|
||||||
|
|
||||||
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
|
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
|
||||||
super(damagee, cause, modifiers, getFunctionModifiers(modifiers));
|
super(damagee, cause, modifiers, getFunctionModifiers(modifiers));
|
||||||
|
@ -7,7 +7,7 @@ import org.bukkit.event.entity.EntityTameEvent;
|
|||||||
/**
|
/**
|
||||||
* Called when mcMMO tames an animal via Call of the Wild
|
* Called when mcMMO tames an animal via Call of the Wild
|
||||||
*/
|
*/
|
||||||
public class FakeEntityTameEvent extends EntityTameEvent {
|
public class FakeEntityTameEvent extends EntityTameEvent implements FakeEvent {
|
||||||
public FakeEntityTameEvent(LivingEntity entity, AnimalTamer owner) {
|
public FakeEntityTameEvent(LivingEntity entity, AnimalTamer owner) {
|
||||||
super(entity, owner);
|
super(entity, owner);
|
||||||
}
|
}
|
||||||
|
11
src/main/java/com/gmail/nossr50/events/fake/FakeEvent.java
Normal file
11
src/main/java/com/gmail/nossr50/events/fake/FakeEvent.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package com.gmail.nossr50.events.fake;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface marks an {@link Event} as "fake".
|
||||||
|
* This is just a handy way of checking if an {@link Event} is fake or not, maybe there
|
||||||
|
* will be methods suitable for this in the future.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface FakeEvent {}
|
@ -6,7 +6,7 @@ import org.bukkit.event.player.PlayerAnimationEvent;
|
|||||||
/**
|
/**
|
||||||
* Called when handling extra drops to avoid issues with NoCheat.
|
* Called when handling extra drops to avoid issues with NoCheat.
|
||||||
*/
|
*/
|
||||||
public class FakePlayerAnimationEvent extends PlayerAnimationEvent {
|
public class FakePlayerAnimationEvent extends PlayerAnimationEvent implements FakeEvent {
|
||||||
public FakePlayerAnimationEvent(Player player) {
|
public FakePlayerAnimationEvent(Player player) {
|
||||||
super(player);
|
super(player);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import org.bukkit.entity.FishHook;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerFishEvent;
|
import org.bukkit.event.player.PlayerFishEvent;
|
||||||
|
|
||||||
public class FakePlayerFishEvent extends PlayerFishEvent {
|
public class FakePlayerFishEvent extends PlayerFishEvent implements FakeEvent {
|
||||||
public FakePlayerFishEvent(Player player, Entity entity, FishHook hookEntity, State state) {
|
public FakePlayerFishEvent(Player player, Entity entity, FishHook hookEntity, State state) {
|
||||||
super(player, entity, hookEntity, state);
|
super(player, entity, hookEntity, state);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.events.items;
|
package com.gmail.nossr50.events.items;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.api.ItemSpawnReason;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -14,38 +15,49 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable {
|
|||||||
private Location location;
|
private Location location;
|
||||||
private ItemStack itemStack;
|
private ItemStack itemStack;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
private final ItemSpawnReason itemSpawnReason;
|
||||||
|
|
||||||
public McMMOItemSpawnEvent(Location location, ItemStack itemStack) {
|
public McMMOItemSpawnEvent(@NotNull Location location, @NotNull ItemStack itemStack, @NotNull ItemSpawnReason itemSpawnReason) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.itemStack = itemStack;
|
this.itemStack = itemStack;
|
||||||
|
this.itemSpawnReason = itemSpawnReason;
|
||||||
this.cancelled = false;
|
this.cancelled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The reason an item is being spawned by mcMMO
|
||||||
|
* @see ItemSpawnReason
|
||||||
|
* @return the item drop reason
|
||||||
|
*/
|
||||||
|
public ItemSpawnReason getItemSpawnReason() {
|
||||||
|
return itemSpawnReason;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Location where the item will be dropped
|
* @return Location where the item will be dropped
|
||||||
*/
|
*/
|
||||||
public Location getLocation() {
|
public @NotNull Location getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param location Location where to drop the item
|
* @param location Location where to drop the item
|
||||||
*/
|
*/
|
||||||
public void setLocation(Location location) {
|
public void setLocation(@NotNull Location location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ItemStack that will be dropped
|
* @return ItemStack that will be dropped
|
||||||
*/
|
*/
|
||||||
public ItemStack getItemStack() {
|
public @NotNull ItemStack getItemStack() {
|
||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param itemStack ItemStack to drop
|
* @param itemStack ItemStack to drop
|
||||||
*/
|
*/
|
||||||
public void setItemStack(ItemStack itemStack) {
|
public void setItemStack(@NotNull ItemStack itemStack) {
|
||||||
this.itemStack = itemStack;
|
this.itemStack = itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,14 +73,14 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Rest of file is required boilerplate for custom events **/
|
/** Rest of file is required boilerplate for custom events **/
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final @NotNull HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static @NotNull HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.gmail.nossr50.events.skills;
|
package com.gmail.nossr50.events.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
import com.gmail.nossr50.util.McMMOMessageType;
|
import com.gmail.nossr50.util.text.McMMOMessageType;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.listeners;
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.api.ItemSpawnReason;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.HiddenConfig;
|
import com.gmail.nossr50.config.HiddenConfig;
|
||||||
import com.gmail.nossr50.config.WorldBlacklist;
|
import com.gmail.nossr50.config.WorldBlacklist;
|
||||||
@ -19,10 +20,7 @@ import com.gmail.nossr50.skills.mining.MiningManager;
|
|||||||
import com.gmail.nossr50.skills.repair.Repair;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||||
import com.gmail.nossr50.util.BlockUtils;
|
import com.gmail.nossr50.util.*;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
|
||||||
import com.gmail.nossr50.util.ItemUtils;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
import com.gmail.nossr50.util.sounds.SoundManager;
|
import com.gmail.nossr50.util.sounds.SoundManager;
|
||||||
import com.gmail.nossr50.util.sounds.SoundType;
|
import com.gmail.nossr50.util.sounds.SoundType;
|
||||||
@ -97,7 +95,7 @@ public class BlockListener implements Listener {
|
|||||||
int bonusCount = bonusDropMeta.asInt();
|
int bonusCount = bonusDropMeta.asInt();
|
||||||
|
|
||||||
for (int i = 0; i < bonusCount; i++) {
|
for (int i = 0; i < bonusCount; i++) {
|
||||||
event.getBlock().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
|
Misc.spawnItemNaturally(event.getBlockState().getLocation(), is, ItemSpawnReason.BONUS_DROPS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,16 +244,16 @@ public class BlockListener implements Listener {
|
|||||||
mcMMO.getPlaceStore().setTrue(blockState);
|
mcMMO.getPlaceStore().setTrue(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* WORLD BLACKLIST CHECK */
|
// /* WORLD BLACKLIST CHECK */
|
||||||
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) {
|
// if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Player player = event.getPlayer();
|
// Player player = event.getPlayer();
|
||||||
|
//
|
||||||
if (!mcMMO.getUserManager().hasPlayerDataKey(player)) {
|
// if (!UserManager.hasPlayerDataKey(player)) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
@ -355,13 +353,17 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* WOOD CUTTING */
|
/* WOOD CUTTING */
|
||||||
else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && PrimarySkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
else if (BlockUtils.hasWoodcuttingXP(blockState) && ItemUtils.isAxe(heldItem) && PrimarySkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
|
||||||
WoodcuttingManager woodcuttingManager = mmoPlayer.getWoodcuttingManager();
|
WoodcuttingManager woodcuttingManager = mmoPlayer.getWoodcuttingManager();
|
||||||
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
||||||
woodcuttingManager.processTreeFeller(blockState);
|
woodcuttingManager.processTreeFeller(blockState);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
woodcuttingManager.woodcuttingBlockCheck(blockState);
|
//Check for XP
|
||||||
|
woodcuttingManager.processWoodcuttingBlockXP(blockState);
|
||||||
|
|
||||||
|
//Check for bonus drops
|
||||||
|
woodcuttingManager.processHarvestLumber(blockState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,7 +492,7 @@ public class BlockListener implements Listener {
|
|||||||
if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.GREEN_TERRA_TOOL) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.GREEN_TERRA_TOOL) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
|
||||||
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.HERBALISM);
|
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.HERBALISM);
|
||||||
}
|
}
|
||||||
else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SKULL_SPLITTER_TOOL) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
|
else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SKULL_SPLITTER_TOOL) && ItemUtils.isAxe(heldItem) && BlockUtils.hasWoodcuttingXP(blockState) && Permissions.treeFeller(player)) {
|
||||||
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.WOODCUTTING);
|
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.WOODCUTTING);
|
||||||
}
|
}
|
||||||
else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SUPER_BREAKER_TOOL) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
|
else if (mmoPlayer.getSuperAbilityManager().isAbilityToolPrimed(AbilityToolType.SUPER_BREAKER_TOOL) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
|
||||||
@ -524,7 +526,7 @@ public class BlockListener implements Listener {
|
|||||||
*
|
*
|
||||||
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
* We don't need to check permissions here because they've already been checked for the ability to even activate.
|
||||||
*/
|
*/
|
||||||
if (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.TREE_FELLER) && BlockUtils.isLog(blockState) && Config.getInstance().getTreeFellerSoundsEnabled()) {
|
if (mmoPlayer.getSuperAbilityManager().getAbilityMode(SuperAbilityType.TREE_FELLER) && BlockUtils.hasWoodcuttingXP(blockState) && Config.getInstance().getTreeFellerSoundsEnabled()) {
|
||||||
SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ);
|
SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -595,7 +597,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mmoPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
|
else if (mmoPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.hasWoodcuttingXP(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
|
||||||
event.setInstaBreak(true);
|
event.setInstaBreak(true);
|
||||||
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
|
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user