mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 17:53:00 +01:00
Compare commits
107 Commits
experiment
...
maces
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f1532cf96 | ||
|
|
5bbb389d9a | ||
|
|
87bd92a5b0 | ||
|
|
c94039ab45 | ||
|
|
e1dee2778d | ||
|
|
02c732bdf2 | ||
|
|
e32bde3c32 | ||
|
|
a11ac782fa | ||
|
|
10e8b19e53 | ||
|
|
ac3c6da298 | ||
|
|
4fce053804 | ||
|
|
eeecf18caf | ||
|
|
b9b1127087 | ||
|
|
009f64cba1 | ||
|
|
2a4487cde2 | ||
|
|
8633f7b63a | ||
|
|
0708b0a6a2 | ||
|
|
6c1502fc67 | ||
|
|
4277384c22 | ||
|
|
590b00aeca | ||
|
|
2f1278c784 | ||
|
|
d0ab2bdb2f | ||
|
|
7266563ca9 | ||
|
|
364d4cd6e7 | ||
|
|
32ff8c6818 | ||
|
|
fc600796ca | ||
|
|
db9f8e46d1 | ||
|
|
19a8a9ff52 | ||
|
|
ab8ba8acbe | ||
|
|
d38404927b | ||
|
|
b65247cbb0 | ||
|
|
9b09f06ad8 | ||
|
|
8b82163e3d | ||
|
|
c2054a5d45 | ||
|
|
46c9ea5a25 | ||
|
|
e6ff219a5c | ||
|
|
fc66c9f3fd | ||
|
|
8d2a08c421 | ||
|
|
291effdbc8 | ||
|
|
435a6fde34 | ||
|
|
3ba6b93135 | ||
|
|
17052861d1 | ||
|
|
cae2132d8d | ||
|
|
ed0c9469e2 | ||
|
|
64206c3ac8 | ||
|
|
0bf1bbe6ac | ||
|
|
b3edca5304 | ||
|
|
07b4736be3 | ||
|
|
df6ddd6faa | ||
|
|
fb0c8ec934 | ||
|
|
5ba6305ad4 | ||
|
|
75561350c1 | ||
|
|
5b822bc626 | ||
|
|
e29a977b9a | ||
|
|
78558107b3 | ||
|
|
5628df988f | ||
|
|
c078e853eb | ||
|
|
0db5330416 | ||
|
|
1cac6b1165 | ||
|
|
c0952a2ba3 | ||
|
|
4d98d25215 | ||
|
|
ffc6061f8b | ||
|
|
0363ee2e90 | ||
|
|
b6e512b09e | ||
|
|
aecf17a2a2 | ||
|
|
c769813892 | ||
|
|
e509876658 | ||
|
|
a047bca94c | ||
|
|
b5a50da09b | ||
|
|
2d79b364db | ||
|
|
657d7cafa7 | ||
|
|
d92c60fc84 | ||
|
|
b56ddebde8 | ||
|
|
cf49fc7599 | ||
|
|
86a5d14a9b | ||
|
|
d45e48c401 | ||
|
|
77f6a3945f | ||
|
|
6016e69663 | ||
|
|
8902c86864 | ||
|
|
f6d2479f2e | ||
|
|
81ac48904c | ||
|
|
2594dc1bca | ||
|
|
bead5feb14 | ||
|
|
ed8c8107f9 | ||
|
|
b6697141f7 | ||
|
|
04ed2a47d4 | ||
|
|
7da8c8c83a | ||
|
|
4d060b192b | ||
|
|
2117c67084 | ||
|
|
4d85f24d98 | ||
|
|
416c5383c9 | ||
|
|
7f9ed94d23 | ||
|
|
b0d0030d60 | ||
|
|
cdc187b211 | ||
|
|
3361d28887 | ||
|
|
c358c8ce0b | ||
|
|
aa65be0e1b | ||
|
|
85f27fdbdb | ||
|
|
5bfca3c218 | ||
|
|
94754b150c | ||
|
|
415e3df226 | ||
|
|
b5608ccb01 | ||
|
|
d57e225576 | ||
|
|
2f166507ca | ||
|
|
347e6112fb | ||
|
|
65dfcb492d | ||
|
|
23a549a6d3 |
307
Changelog.txt
307
Changelog.txt
@@ -1,8 +1,291 @@
|
||||
Version 2.1.227
|
||||
Optimized mcMMO onChunkUnload(ChunkUnloadEvent)
|
||||
Version 2.2.015
|
||||
Added Maces skill
|
||||
Added Mace to repair.vanilla.yml (see notes)
|
||||
Fixed a bug where spamming attacks would still apply full bonus dmg and full chance to proc abilities (see notes)
|
||||
Fixed some misc missing permissions for crossbows/tridents
|
||||
|
||||
NOTES:
|
||||
This update should greatly improve impact on TPS from mcMMO in the ChunkUnloadEvent, thanks to M_G_P and Epicurious for testing.
|
||||
You shouldn't need to update repair.vanilla.yml, it should update automatically
|
||||
Maces is a new skill that is in early development, feedback is appreciated.
|
||||
Some ideas I had for the Maces are on hold as they are lacking proper API from Spigot.
|
||||
This is mostly pertaining to smash attacks, I had some ideas for enhancing them but without the proper API I will hold off for now.
|
||||
While working on Maces, I noticed a bug where spamming attacks would still apply full bonus damage and full chance to proc abilities, this has been fixed.
|
||||
When you swing your weapon in Minecraft, you gain an "Attack Strength" value, which is relative to your cooldown, mcMMO was supposed to be making use of this value, but at some point in the past this was broken.
|
||||
I have fixed this and now mcMMO will use the attack strength value to determine the bonus damage and chance to proc abilities.
|
||||
For servers modifying Minecraft combat to not have this "cooldown", mcMMO should behave as you would expect, with full damage and full chance to proc abilities.
|
||||
|
||||
Version 2.2.014
|
||||
Fixed a bug where Luck Of The Sea was being applied for Super Breaker (and other abilities)
|
||||
|
||||
Version 2.2.013
|
||||
Added Breeze to experience.yml
|
||||
Added Bogged to experience.yml
|
||||
(Locale) Updates to zh_TW (thanks chunkiuu)
|
||||
(Locale) Updates to zh_CN (thanks haha44444)
|
||||
Modified the RNG for dropping non-ore blocks from Blast Mining to yield about 50% of what was destroyed
|
||||
(API) Deprecated com.gmail.nossr50.mcMMO.getPlaceStore
|
||||
(API) Added com.gmail.nossr50.mcMMO.getUserBlockTracker
|
||||
(API) Added com.gmail.nossr50.mcMMO.getChunkManager
|
||||
(API) Added new methods to com.gmail.nossr50.util.blockmeta.UserBlockTracker for easier readability
|
||||
(API) Deprecated many poorly named methods in UserBlockTracker (see notes)
|
||||
(Codebase) Cleaned up and organized unit tests relating to UserBlockTracker
|
||||
Added missing entries for Tridents/Xbows/Maces to config.yml (see notes)
|
||||
|
||||
NOTES:
|
||||
Some settings such as Hardcore.Death_Stat_Loss.Enabled were missing entries for the new skills, I have added them to the default config.
|
||||
Missing entries does not mean these things wouldn't work without them present, as default values will be used when config entries are not present.
|
||||
These missing entries should be added to your config upon start up with this update.
|
||||
Regarding the API changes, not planning to delete the deprecated methods in UserBlockTracker anytime soon, as nothing has really changed other than the names.
|
||||
For anyone consuming mcMMO API, I would still recommend switching off these deprecated methods as soon as you can, just for future-proofing.
|
||||
|
||||
Version 2.2.012
|
||||
Fixed a bug where Daze would cause an exception in older game versions (1.20.4 and older)
|
||||
|
||||
Version 2.2.011
|
||||
Fixed bug where some potions on older versions (1.20.4 and older) were not brewable (night vision extended, etc)
|
||||
Improved logging for Alchemy potion look up (see notes)
|
||||
|
||||
NOTES:
|
||||
Added detailed logging when multiple configured potions match an ItemStack.
|
||||
This will help identify issues with potion configuration.
|
||||
|
||||
Version 2.2.010
|
||||
Fixed being unable to load REGEN potion type on new versions of Paper/Spigot 1.20.6
|
||||
Fixed some potions not gaining XP when brewed (Level 2 potions, etc)
|
||||
BrewingStands will now remember who owns them, this persists across restarts (see notes)
|
||||
Fixed rare NPE in mcMMO events when player data was unable to be retrieved
|
||||
Fixed a NPE that could happen when damaging armor with Axes
|
||||
Fixed a bug where Alchemy brewing would be cancelled if the player died
|
||||
(API) Added getMcMMOPlayer() to McMMOPlayerSkillEvent
|
||||
(API) Added new ctor McMMOPlayerSkillEvent(@NotNull McMMOPlayer mmoPlayer, @NotNull PrimarySkillType primarySkillType)
|
||||
(API) Deprecated ctor McMMOPlayerSkillEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
(API) Added ctor McMMOPlayerAbilityEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
(API) Deprecated ctor McMMOPlayerAbilityEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
(API) Deprecated ctor McMMOPlayerAbilityActivateEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
(API) Added ctor McMMOPlayerAbilityActivateEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
(API) Deprecated ctor McMMOPlayerCatalysisEvent(org.bukkit.entity.Player, double)
|
||||
(API) Added ctor McMMOPlayerCatalysisEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, double)
|
||||
(API) Deprecated util method EventUtils.callPlayerAbilityActivateEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
(API) Added util method EventUtils.callPlayerAbilityActivateEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
(API) Deprecated ctor McMMOPlayerFishingEvent(org.bukkit.entity.Player)
|
||||
(API) Added ctor McMMOPlayerFishingEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer)
|
||||
(API) Deprecated ctor McMMOPlayerFishingTreasureEvent.McMMOPlayerFishingTreasureEvent(org.bukkit.entity.Player, org.bukkit.inventory.ItemStack, int)
|
||||
(API) Added ctor McMMOPlayerFishingTreasureEvent.McMMOPlayerFishingTreasureEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, org.bukkit.inventory.ItemStack, int)
|
||||
(API) Deprecated ctor McMMOPlayerMagicHunterEvent(org.bukkit.entity.Player, org.bukkit.inventory.ItemStack, int, java.util.Map<org.bukkit.enchantments.Enchantment,java.lang.Integer>)
|
||||
(API) Added ctor McMMOPlayerMagicHunterEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, org.bukkit.inventory.ItemStack, int, java.util.Map<org.bukkit.enchantments.Enchantment,java.lang.Integer>)
|
||||
(API) Deprecated ctor McMMOPlayerAbilityDeactivateEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
(API) Added ctor McMMOPlayerAbilityDeactivateEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.PrimarySkillType)
|
||||
(API) Deprecated util method EventUtils.callAbilityDeactivateEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.SuperAbilityType)
|
||||
(API) Added util method EventUtils.callAbilityDeactivateEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.SuperAbilityType)
|
||||
(API) Deprecated util EventUtils.callSubSkillEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.SubSkillType)
|
||||
(API) Added util EventUtils.callSubSkillEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.SubSkillType)
|
||||
(API) Deprecated ctor SubSkillEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.SubSkillType)
|
||||
(API) Added ctor SubSkillEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.SubSkillType)
|
||||
(API) Deprecated ctor SubSkillEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.SubSkillType, double)
|
||||
(API) Added ctor SubSkillEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.SubSkillType, double)
|
||||
(API) Deprecated ctor SubSkillEvent(org.bukkit.entity.Player, com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill)
|
||||
(API) Added ctor SubSkillEvent(com.gmail.nossr50.datatypes.player.McMMOPlayer, com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill)
|
||||
(API) Deprecated ctor AlchemyBrewCheckTask(org.bukkit.entity.Player, org.bukkit.block.BrewingStand)
|
||||
(API) Added ctor AlchemyBrewCheckTask(org.bukkit.block.BrewingStand)
|
||||
|
||||
NOTES:
|
||||
You can now use hoppers and brewing stands and not have to worry about having to re-interact with the brewing stand over and over again
|
||||
Ownership of a brewing stand is whoever last interacted with it, this persists across restarts
|
||||
This is not an exhaustive list of API changes in this update, but most of the important ones should be documented here.
|
||||
|
||||
Version 2.2.009
|
||||
Fixed a bug that prevented mcMMO from loading on MC versions older than 1.20.6
|
||||
Dramatically increased the base XP for Alchemy again (see notes)
|
||||
|
||||
NOTES:
|
||||
Alchemy leveling still felt too slow, so I've increased it again. You can either delete experience.yml to get the new values or adjust them manually.
|
||||
If you haven't updated mcMMO since 2.2.006 or older you don't need to do anything to get these new values.
|
||||
The new default values are...
|
||||
Potion_Brewing:
|
||||
Stage_1: 666
|
||||
Stage_2: 1111
|
||||
Stage_3: 1750
|
||||
Stage_4: 2250
|
||||
|
||||
Version 2.2.008
|
||||
Fixed alchemy potions not upgrading correctly (This will only affect new potions made, see notes)
|
||||
Fixed a bug where alchemy potions had italicized names
|
||||
Fixed a bug where messages were not being sent to the action bar in 1.20.6
|
||||
(SQL) Fixed bug that broke /mccooldowns and /archery in some circumstances
|
||||
Fixed some exceptions that could happen with parties disabled (thanks IAISI)
|
||||
|
||||
NOTES:
|
||||
mcMMO-exclusive Potions (haste, etc) made on version 2.2.007 of mcMMO will not upgrade correctly, you'll just have to make new ones. Sorry for the inconvenience.
|
||||
Alchemy potions will now be brewed as type "Mundane" behind the scenes, this used to be Uncraftable/Water. This led to some issues. So I've changed it to be Mundane.
|
||||
|
||||
Version 2.2.007
|
||||
Compatibility with the 1.20.5 / 1.20.6 MC Update
|
||||
Fixed bug where Alchemy was not brewing certain potions (haste, etc)
|
||||
Tree Feller no longer restricts how many saplings can drop
|
||||
Tree Feller now drops leaves 25% of the time (up from 10%)
|
||||
Alchemy XP has been DRAMATICALLY increased, it was extremely grindy by default
|
||||
Alchemy experience values in experience.yml are now found under 'Experience_Values.Alchemy.Potion_Brewing'
|
||||
Fixed bug where the probability of success of Graceful Roll was not being calculated correctly
|
||||
Fixed bug where Green Thumb did not replant if seed was in the off hand
|
||||
Added armadillo to combat experience in experience.yml
|
||||
|
||||
NOTES:
|
||||
While fixing various Alchemy bugs, I noticed Alchemy leveled SUPER slow, I have increased it dramatically. Feel free to change it back by modifying the new values in experience.yml
|
||||
I did my best to keep mcMMO compatible with older versions of Minecraft for this update.
|
||||
This update to MC was quite large, with breaking changes to a lot of code relating to Alchemy, and some other things.
|
||||
I expect there to be bugs, please report them on GitHub or Discord, but preferably GitHub.
|
||||
I will be working on fixing these bugs as they come in, so please be patient.
|
||||
Version 2.2.006
|
||||
Added new config custom_item_support.yml
|
||||
Added support for hex color codes in the locale file, uses the format &#RRGGBB (see notes)
|
||||
Added setting to disable repair on items with custom models, this is not on by default
|
||||
Fixed a bug where sometimes the locale name of a skill would get lowercased
|
||||
Fixed a bug where JSON text components did not get colored properly some of the time
|
||||
Fixed en_US locale string 'Commands.Skill.Leaderboard' not being colored properly
|
||||
Fixed skill commands incorrectly telling you to use their locale name, this isn't currently possible
|
||||
Updated outdated wiki URLs in commands to point to the new wiki
|
||||
Removed the msg about skills being migrated to a new system when using /mmoinfo command
|
||||
Added new locale entry 'Anvil.Repair.Reject.CustomModelData'
|
||||
Added new locale entry 'Anvil.Salvage.Reject.CustomModelData'
|
||||
Updated en_US locale entry 'JSON.DescriptionHeader'
|
||||
(API/Codebase) Added some util methods and basic unit tests for LocaleLoader
|
||||
|
||||
NOTES:
|
||||
Hex Color support in locale files is here!
|
||||
The hex color code format for the locale files is &#RRGGBB
|
||||
An example entry applying yellow as a hex color code would look like this:
|
||||
Axes.SkillName=&#FFFF00Axes
|
||||
In general, JSON locale entries will either not work with hex color codes or will have the color code stripped out, in the future I will add support for the JSON components to use hex colors from the locale
|
||||
|
||||
Let me know in detail what kind of support you'd like to see in mcMMO regarding custom items, I'm open to suggestions.
|
||||
This update adds a new config file to allow server owners to disable repair or salvage on items with custom models,
|
||||
This prevention mechanism is not enabled by default, change the settings in custom_item_support.yml if you want to enable it.
|
||||
This feature is off by default for now to keep compatibility with existing servers, but it may be enabled by default in the future if feedback suggests it should be.
|
||||
As a reminder, anyone can update the wiki by clicking on the "edit on github" link on various pages, this will take you to the wiki's source code on GitHub, submit a PR to make changes
|
||||
|
||||
Version 2.2.005
|
||||
Fixed a bug where certain skills such as Dodge/Arrow Deflect had no skill cap and would continue improving forever
|
||||
Reduced messages on startup for SQL DB
|
||||
(API) Constructor for ProbabilityImpl now takes a raw value between 0 and 1 instead of an inflated percentage
|
||||
(API) Added some convenience methods to Probability, and ProbabilityUtil classes
|
||||
(Codebase) Added more unit tests revolving around Probability/RNG
|
||||
|
||||
Version 2.2.004
|
||||
Fixed bug where values from Experience_Formula.Skill_Multiplier were not functioning
|
||||
|
||||
NOTES:
|
||||
A reminder that these values are multipliers and no longer divisors, if you want 10x lower XP, a value of .1 would do the job.
|
||||
|
||||
Version 2.2.003
|
||||
(SQLDB) Fixed a bug where lastlogin was using a value that was too large
|
||||
(SQLDB) Fixed bug where crossbows was not getting added to SQL schema for some users
|
||||
|
||||
Version 2.2.002
|
||||
Fixed bug where thrown tridents did not grant XP or benefit from subskills
|
||||
Fixed bug where trickshot marked bounced arrows as being shot from a bow instead of being shot from a crossbow
|
||||
|
||||
Version 2.2.001
|
||||
Fixed Crossbow's Powered shot showing the text for the wrong skill from the locale when using /crossbows command
|
||||
|
||||
Version 2.2.000
|
||||
General
|
||||
Added Crossbows Skill, this skill is an early preview / WIP and feedback on discord is appreciated
|
||||
Added Tridents Skill, this skill is an early preview / WIP and feedback on discord is appreciated
|
||||
Added an "endgame" triple drop subskill 'Mother Lode' to Mining
|
||||
Added an "endgame" triple drop subskill 'Clean Cuts' to Woodcutting
|
||||
Added an "endgame" triple drop subskill 'Verdant Bounty' to Herbalism
|
||||
Added /mmopower command which simply shows your power level (aliases /mmopowerlevel /powerlevel)
|
||||
Quite a few misc bugs were patched relating to random chance, some involving perk permissions
|
||||
|
||||
Config
|
||||
Added 'Send_To_Console' settings to chat.yml to toggle sending party or admin chat messages to console
|
||||
Replaced 'Experience_Formula.Modifier' in experience.yml with 'Experience_Formula.Skill_Multiplier' which is easier to understand and less prone to divide by zero bugs
|
||||
child.yml config is gone now, feel free to delete it
|
||||
Added ExploitFix.PreventArmorStandInteraction to experience.yml to prevent players from triggering mcMMO abilities off armor stands
|
||||
|
||||
Tweaks
|
||||
Tree Feller now drops 90% less non-wood block rewards (leaves/etc) on average from Knock on Wood.
|
||||
Treasure drop rate from Shake, Fishing, Hylian, and Excavation now benefit from the Luck perk
|
||||
Updated advanced.yml with entries for the new skills
|
||||
|
||||
Permission nodes
|
||||
Added 'mcmmo.commands.mmopower' permission node for the new /mmopower command
|
||||
Added 'mcmmo.commands.crossbows' permission node
|
||||
Added 'mcmmo.ability.crossbows.crossbowslimitbreak' permission node
|
||||
Added 'mcmmo.ability.crossbows.trickshot' permission node
|
||||
Added 'mcmmo.ability.crossbows.poweredshot' permission node
|
||||
Added 'mcmmo.commands.tridents' permission node
|
||||
Added 'mcmmo.ability.tridents.tridentslimitbreak' permission node
|
||||
Added 'mcmmo.ability.tridents.impale' permission node
|
||||
Added 'mcmmo.ability.herbalism.verdantbounty' permission node
|
||||
Added 'mcmmo.ability.mining.motherlode' permission node
|
||||
Added 'mcmmo.ability.woodcutting.cleancuts' permission node
|
||||
|
||||
Locale
|
||||
Added locale entries for all the new skills/subskills
|
||||
|
||||
Codebase / Misc
|
||||
PAPI's '/papi reload' command will no longer unload mcMMO (thanks gecko10000)
|
||||
Major rewrite for how random chance was handled in the code
|
||||
Many skills with RNG elements now send out a SubSkillEvent (which can be used to modify probability or cancel the results), some skills without RNG still send out this event when activated, this event is cancellable so it can be used to make a skill fail
|
||||
A lot of new unit tests were added to help keep mcMMO stable as part of this update, of course, more could always be added.
|
||||
|
||||
NOTES:
|
||||
One feature of this update is to provide a endgame benefits to some skills that you can grind for a long time, ideally for a long while. I will likely expand upon this idea in future updates.
|
||||
A few skills have these endgame oriented subskills, these new subskills provide a small benefit at first that grows and scales up to level 10,000 (or 1,000 for Standard mode which no one uses) and does not have ranks (other than the initial rank to unlock it).
|
||||
These endgame sub skills unlock at level 1000 for users with default mcMMO settings, or 100 for those using the optional Standard scaling.
|
||||
You can tweak the benefits of these skills in advanced.yml, the default settings are meant to be a good starting point.
|
||||
|
||||
Crossbows and Tridents are WIP skills, I would like feedback on discord about them.
|
||||
Tridents especially is very early, I have some ideas but I want to hear what you think about it.
|
||||
|
||||
More info on the new Triple Drop skills (Mother Lode, Clean Cuts, Verdant Bounty):
|
||||
Currently these start at about 5% chance and can reach a maximum 50% chance if a player acquired 10,000 skill, you can adjust this in advanced.yml
|
||||
These skills respect double drop settings from config.yml just like the corresponding Double Drop skills do, if a double drop is disabled for an item, then its disabled for triple drops too.
|
||||
I added a new Power Level Command, for now this just shows you your current power level. If I ever add features based on power level, this command will likely display output related to those features.
|
||||
|
||||
Regarding Maces, I will likely add that as a WIP skill when the next Minecraft update drops.
|
||||
|
||||
Version 2.1.231
|
||||
Fixed a bug preventing parties from being made without passwords (Thanks Momshroom)
|
||||
Updated korean locale (thanks mangchi57)
|
||||
Added some unit tests for party creation
|
||||
|
||||
Version 2.1.230
|
||||
Fixed an error that could happen when mcMMO was saving when parties were disabled by party.yml (thanks IAISI & L4BORG)
|
||||
Fixed several exceptions when checking PVP damage when parties were disabled by party.yml (thanks IAISI & L4BORG)
|
||||
|
||||
Version 2.1.229
|
||||
Added new party.yml config, which lets admins disable the party system entirely without having to use permissions
|
||||
Fixed error caused by missing API in McMMOEntityDamageByRuptureEvent
|
||||
(API) Major API changes to PartyManager
|
||||
(API) PartyManager is no longer a static singleton class, use mcMMO.getPartyManager() to get the PartyManager
|
||||
(API) Added com.gmail.nossr50.mcMMO.isPartySystemEnabled to check if the party system is enabled
|
||||
(API) Added com.gmail.nossr50.api.PartyAPI.isPartySystemEnabled as an alternative, to check if the party system is enabled
|
||||
(API) Added missing com.gmail.nossr50.events.skills.rupture.McMMOEntityDamageByRuptureEvent.getHandlerList
|
||||
|
||||
NOTES:
|
||||
Admins can now enable/disable the whole party system with a setting in the new party.yml config
|
||||
You'll have to start your server one time to generate the config, then change the setting and reboot your server.
|
||||
|
||||
Version 2.1.228
|
||||
Fixed a stack trace due to Spigot API break on EntityDamageEvent and EntityDamageByEntity event
|
||||
(API) - Removed FakeEntityDamageEvent and FakeEntityDamageByEntityEvent
|
||||
(API) - Reworked McMMOEntityDamageByRuptureEvent, this no longer extends EntityDamageByEntityEvent, instead it extends EntityEvent
|
||||
|
||||
Notes:
|
||||
Some care went into keeping mcMMO compatible with older versions despite a big API break from Spigot, this may introduce some new bugs, so please report them if you run into any.
|
||||
|
||||
Version 2.1.227
|
||||
Fixed bug where some text would not be displayed to players (Adventure dependency update)
|
||||
Repair sound effect from mcMMO can now be adjusted in Minecraft sound options (Thanks MithicSpirit)
|
||||
Korean locale updated (Thanks Pindang2)
|
||||
Simplified Chinese locale updated (Thanks YuanYuanOwO)
|
||||
|
||||
NOTES:
|
||||
For those curious, mcMMO uses Adventure to do a lot of the message sending to players.
|
||||
It typically needs updating when new versions of MC come out, sorry for the delay on my part.
|
||||
|
||||
Version 2.1.226
|
||||
Added Short_Grass to experience.yml for Herbalism
|
||||
Updated Hylian Treasures "Bushes" alias to use short_grass when playing on new Minecraft versions
|
||||
@@ -1296,7 +1579,7 @@ Version 2.1.128
|
||||
Fixed a bug where certain types of ore did not receive bonuses from Blast Mining
|
||||
Fixed a few locale errors with commands
|
||||
(API) Added ExperienceAPI::addCombatXP for adding combat XP to players, signature may change so its deprecated for now
|
||||
mcMMO now logs whether or not its using FlatFile or SQL database on load
|
||||
mcMMO now logs whether its using FlatFile or SQL database on load
|
||||
(1.16) Strider added to combat experience with a value of 1.2
|
||||
|
||||
NOTES: A more thorough look at Unarmed balance will happen in the future, the intention of this nerf is to make Unarmed less rewarding until it is leveled quite a bit.
|
||||
@@ -1316,7 +1599,7 @@ Version 2.1.127
|
||||
Version 2.1.126
|
||||
mcMMO now relies on NMS for some of its features, if NMS cannot properly be wired up when initializing mcMMO behaviours relying on NMS will either be partially supported or disabled
|
||||
mcMMO now has a compatibility mode, any features that require specific versions of Minecraft for full functionality will be disabled if your server is not running a compatible version, mcMMO will still function in compatibility mode, but either the feature will be modified or disabled depending on the version of the server software
|
||||
New command /mmocompat - Shows information about whether or not mcMMO is fully functional or if some features are disabled due to the server software not being fully supported. Can be used by players or console.
|
||||
New command /mmocompat - Shows information about whether mcMMO is fully functional or if some features are disabled due to the server software not being fully supported. Can be used by players or console.
|
||||
New command /mmoxpbar (alias /xpbarsettings) - Players can choose to always show XP bars or to never show XP bars on a per skill basis
|
||||
XPBars now last for 3 seconds before hiding instead of 2 seconds
|
||||
Fixed an exploit involving fishing rods
|
||||
@@ -1952,7 +2235,7 @@ Version 2.1.68
|
||||
Fixed a bug where consuming food in the off hand did not trigger the Diet abilities
|
||||
|
||||
Version 2.1.67
|
||||
The XP bar now reflects whether or not the player is receiving the early game boost
|
||||
The XP bar now reflects whether the player is receiving the early game boost
|
||||
Players who are receiving an early game boost will be shown "Learning a skill..." as the title of the XP bar while gaining XP
|
||||
New locale string 'XPBar.Template.EarlyGameBoost'
|
||||
|
||||
@@ -2001,7 +2284,7 @@ Version 2.1.63
|
||||
Version 2.1.62
|
||||
Added a new admin notification system, sensitive commands will print chat messages to "admins" (players with either Operator status or admin chat permission)
|
||||
Added a setting to disable the new admin notifications to config.yml 'General.AdminNotifications' (this will be more configurable in 2.2)
|
||||
OPs and players with the admin chat permission will now see details about XP rate event commands regardless of whether or not the XP rate event messages are enabled
|
||||
OPs and players with the admin chat permission will now see details about XP rate event commands regardless of whether the XP rate event messages are enabled
|
||||
Updated hu_HU locale (thanks andris155)
|
||||
Added XP for mining Magma_Block (default 30 XP - Update your config, see notes)
|
||||
Diamond tools & armor in the repair config now have a minimum level of 0 (Update your config, temporary hotfix, 2.2 addresses this issue, see notes)
|
||||
@@ -2009,9 +2292,9 @@ Version 2.1.62
|
||||
New locale string - 'Server.ConsoleName' the name of the server console, this will be used in place of player names when sending admin notifications out if the command was used from console
|
||||
New locale string - 'Notifications.Admin.Format.Others' style formatting + prefix for admin notifications used in the other new strings below
|
||||
New locale string - 'Notifications.Admin.Format.Self' style formatting + prefix for admin command confirmations sent to the user who executed the command
|
||||
New locale string - 'Notifications.Admin.XPRate.Start.Self' sent to the user who modifies the XP rate regardless of whether or not messages for the event are enabled
|
||||
New locale string - 'Notifications.Admin.XPRate.Start.Self' sent to the user who modifies the XP rate regardless of whether messages for the event are enabled
|
||||
New locale string - 'Notifications.Admin.XPRate.Start.Others' details of who started an XP rate event are sent to players who have Operator status or admin chat permission when the command to start or modify XP of an event has been issued
|
||||
New locale string - 'Notifications.Admin.XPRate.End.Self' sent to the user who ended the XP rate event regardless of whether or not messages for the event are enabled
|
||||
New locale string - 'Notifications.Admin.XPRate.End.Self' sent to the user who ended the XP rate event regardless of whether messages for the event are enabled
|
||||
New locale string - 'Notifications.Admin.XPRate.End.Others' details of who ended an XP rate event are sent to players who have Operator status or admin chat permission when the command to end the event has been issued
|
||||
|
||||
NOTES:
|
||||
@@ -2282,7 +2565,7 @@ Version 2.1.26
|
||||
|
||||
Notes:
|
||||
The new Limit Break subskills are intended to make Prot IV players less tanky and for you to feel more powerful for having high skill level.
|
||||
Limit Break has 10 ranks, each rank gives 1 extra RAW damage, this is damage before reductions from armor and enchantments. The net result is you deal about 50% more damage with an end game skill compared to before.
|
||||
Limit Break has 10 ranks, each rank gives 1 extra RAW damage, this is damage before reductions from armor and enchantments. The net result is you deal about 50% more damage with an endgame skill compared to before.
|
||||
With these new changes, most skills can 2 shot normal diamond armor, and it takes about 5 hits to kill someone in Prot IV Diamond Armor.
|
||||
I'm not sure everyone will like these changes, the net result is players are a lot easier to kill now, whereas before you could take quite a beating before getting killed.
|
||||
I collected several sets of data before making these changes, including damage to player with and without prot 4 diamond armor, damage to those players with and without enchanted weapons, damage with and without leveling your skills, and combinations of the previously mentioned things.
|
||||
@@ -3983,7 +4266,7 @@ Removed performance debugging
|
||||
Removed some useless settings from the config file
|
||||
|
||||
Version 1.0.34
|
||||
Fixed the PVP setting determining whether or not you would hurt yourself from AoE Abilities
|
||||
Fixed the PVP setting determining whether you would hurt yourself from AoE Abilities
|
||||
Added Dutch (nl) language support
|
||||
Super Breaker now gives the correct XP as determined by config.yml
|
||||
Sand Stone XP is now configurable and no longer shares the 'stone' node
|
||||
@@ -3993,7 +4276,7 @@ Version 1.0.33
|
||||
Fixed the toggle for the Excavation drop 'Cocoa Beans'
|
||||
Fixed bug where Unarmed users could disarm without being bare handed
|
||||
Cocoa Beans now have an XP modifier in config.yml
|
||||
You can now toggle whether or not Mobspawners will give XP (in config.yml)
|
||||
You can now toggle whether Mobspawners will give XP (in config.yml)
|
||||
MySQL version now makes requests to the MySQL server less frequently (should help performance)
|
||||
Fixed bug with Skull Splitter hitting the user
|
||||
|
||||
|
||||
68
README.md
68
README.md
@@ -10,8 +10,29 @@ Spigot Resource: https://spigot.mcmmo.org
|
||||
|
||||
I plan to post links to our new wiki (its still under development), downloads, and dev blogs there.
|
||||
|
||||
## API
|
||||
If you are using maven, you can add mcMMO API to your plugin by adding it to pom.xml like so...
|
||||
|
||||
```
|
||||
<repository>
|
||||
<id>neetgames</id>
|
||||
<url>https://nexus.neetgames.com/repository/maven-releases/</url>
|
||||
</repository>
|
||||
```
|
||||
```
|
||||
<dependency>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.2.004</version>
|
||||
</dependency>
|
||||
```
|
||||
### Builds
|
||||
Currently, you can obtain our builds via the Spigot resource page: http://spigot.mcmmo.org
|
||||
Currently, you can obtain our builds via the Spigot or Polymart:
|
||||
|
||||
|
||||
http://spigot.mcmmo.org
|
||||
|
||||
https://polymart.org/resource/mcmmo.727
|
||||
|
||||
### Brief Description
|
||||
The goal of mcMMO is to take core Minecraft game mechanics and expand them into an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds fourteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
|
||||
@@ -21,26 +42,14 @@ In December 2018, the original author and creator of mcMMO (nossr50) returned an
|
||||
#### Project Lead & Founder
|
||||
[](https://github.com/nossr50)
|
||||
|
||||
#### mcMMO Devs
|
||||
#### Current mcMMO Devs
|
||||
[](https://github.com/nossr50)
|
||||
[](https://github.com/kashike)
|
||||
[](https://github.com/electronicboy)
|
||||
|
||||
#### Classic Maintainer
|
||||
[](https://github.com/t00thpick1)
|
||||
|
||||
#### Folia Inquisitors
|
||||
[<img src="https://github.com/HSGamer.png" width=80 alt="HSGamer">](https://github.com/HSGamer)
|
||||
[<img src="https://github.com/TechnicallyCoded.png" width=80 alt="TechnicallyCoded">](https://github.com/TechnicallyCoded)
|
||||
[<img src="https://github.com/Yomamaeatstoes.png" width=80 alt="Yomamaeatstoes">](https://github.com/Yomamaeatstoes)
|
||||
[<img src="https://github.com/Rockyers.png" width=80 alt="Rockyers">](https://github.com/Rockyers)
|
||||
|
||||
## Former Team Members
|
||||
|
||||
### Former Lead & Awesome guy
|
||||
[](https://github.com/gmcferrin)
|
||||
|
||||
### Former team members
|
||||
[](https://github.com/gmcferrin)
|
||||
[](https://github.com/kashike)
|
||||
[](https://github.com/electronicboy)
|
||||
[](https://github.com/t00thpick1)
|
||||
[](https://github.com/bm01)
|
||||
[](https://github.com/Glitchfinder)
|
||||
[](https://github.com/NuclearW)
|
||||
@@ -49,20 +58,23 @@ In December 2018, the original author and creator of mcMMO (nossr50) returned an
|
||||
[](https://github.com/riking)
|
||||
[](https://github.com/TheYeti)
|
||||
|
||||
#### Folia Contributors
|
||||
[<img src="https://github.com/HSGamer.png" width=80 alt="HSGamer">](https://github.com/HSGamer)
|
||||
[<img src="https://github.com/TechnicallyCoded.png" width=80 alt="TechnicallyCoded">](https://github.com/TechnicallyCoded)
|
||||
[<img src="https://github.com/Yomamaeatstoes.png" width=80 alt="Yomamaeatstoes">](https://github.com/Yomamaeatstoes)
|
||||
[<img src="https://github.com/Rockyers.png" width=80 alt="Rockyers">](https://github.com/Rockyers)
|
||||
|
||||
## Compiling
|
||||
|
||||
mcMMO uses Maven 3 to manage dependencies, packaging, and shading of necessary classes; Maven 3 is required to compile mcMMO.
|
||||
mcMMO uses Maven to manage dependencies, packaging, and shading of necessary classes; Maven is required to compile mcMMO. It is recommended to always use the latest version of maven.
|
||||
|
||||
The typical command used to build mcMMO is: `mvn clean package install`
|
||||
|
||||
Required Libraries:
|
||||
* Spigot
|
||||
* JUnit
|
||||
* WorldGuard 7
|
||||
* bStats Bukkit
|
||||
The typical command used to build mcMMO is: `mvn clean install`
|
||||
|
||||
https://spigot.mcmmo.org for more up to date information.
|
||||
|
||||
Resource Page
|
||||
Downloads:
|
||||
|
||||
https://www.spigotmc.org/resources/official-mcmmo-original-author-returns.64348/
|
||||
|
||||
https://www.spigotmc.org/resources/official-mcmmo-original-author-returns.64348/
|
||||
|
||||
https://polymart.org/resource/mcmmo.727
|
||||
|
||||
148
pom.xml
148
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.227-SNAPSHOT</version>
|
||||
<version>2.2.015-SNAPSHOT</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<scm>
|
||||
@@ -14,9 +14,9 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>16</maven.compiler.source>
|
||||
<maven.compiler.target>16</maven.compiler.target>
|
||||
<java.version>16</java.version>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
<issueManagement>
|
||||
@@ -75,16 +75,17 @@
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M7</version>
|
||||
<version>3.2.5</version>
|
||||
|
||||
<configuration>
|
||||
<junitArtifactName>org.junit.jupiter:junit-jupiter</junitArtifactName>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
<excludedGroups>skip</excludedGroups>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>3.0.0-M7</version>
|
||||
<version>3.2.5</version>
|
||||
|
||||
<configuration>
|
||||
<junitArtifactName>org.junit.jupiter:junit-jupiter</junitArtifactName>
|
||||
@@ -95,14 +96,14 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>3.0.0-M6</version>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<release>16</release>
|
||||
<release>17</release>
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg> <!-- used for ACF syntax stuff -->
|
||||
</compilerArgs>
|
||||
@@ -112,6 +113,7 @@
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.7.1</version>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/package.xml</descriptor>
|
||||
@@ -130,7 +132,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.5.3</version>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
@@ -140,22 +142,22 @@
|
||||
<include>org.bstats:bstats-base</include>
|
||||
<include>org.bstats:bstats-bukkit</include>
|
||||
<include>net.kyori:adventure-api</include>
|
||||
<include>net.kyori:adventure-text-serializer-gson</include>
|
||||
<include>net.kyori:adventure-platform-bukkit</include>
|
||||
<include>net.kyori:adventure-platform-api</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-key</include>
|
||||
<include>net.kyori:adventure-nbt</include>
|
||||
<include>net.kyori:adventure-platform-api</include>
|
||||
<include>net.kyori:adventure-platform-bukkit</include>
|
||||
<include>net.kyori:adventure-platform-facet</include>
|
||||
<include>net.kyori:adventure-platform-viaversion</include>
|
||||
<include>net.kyori:adventure-text-serializer-bungeecord</include>
|
||||
<include>net.kyori:adventure-text-serializer-gson</include>
|
||||
<include>net.kyori:adventure-text-serializer-gson-legacy-impl</include>
|
||||
<include>net.kyori:adventure-text-serializer-json</include>
|
||||
<include>net.kyori:adventure-text-serializer-json-legacy-impl</include>
|
||||
<include>net.kyori:adventure-text-serializer-legacy</include>
|
||||
<include>net.kyori:examination-api</include>
|
||||
<include>net.kyori:examination-string</include>
|
||||
<include>net.kyori:adventure-text-serializer-legacy</include>
|
||||
<include>net.kyori:adventure-text-serializer-gson</include>
|
||||
<include>net.kyori:adventure-text-serializer-json</include>
|
||||
<include>net.kyori:adventure-text-serializer-bungeecord</include>
|
||||
<include>net.kyori:option</include>
|
||||
<include>net.kyori:adventure-text-serializer-craftbukkit</include>
|
||||
<include>net.kyori:adventure-text-serializer-gson-legacy-impl</include>
|
||||
<include>net.kyori:adventure-text-serializer-json-legacy-impl</include>
|
||||
<include>co.aikar:acf-bukkit</include>
|
||||
<include>com.tcoded:FoliaLib</include>
|
||||
</includes>
|
||||
@@ -221,6 +223,11 @@
|
||||
</pluginRepositories>
|
||||
|
||||
<repositories>
|
||||
<!-- Protocol Lib Repository -->
|
||||
<repository>
|
||||
<id>dmulloy2-repo</id>
|
||||
<url>https://repo.dmulloy2.net/repository/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
@@ -253,10 +260,32 @@
|
||||
<id>devmart-other</id>
|
||||
<url>https://nexuslite.gcnt.net/repos/other/</url>
|
||||
</repository>
|
||||
<!-- ... -->
|
||||
<!-- ... -->
|
||||
<!-- MockBukkit -->
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>3.25.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>2.2.224</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
@@ -271,78 +300,83 @@
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-bungeecord</artifactId>
|
||||
<version>4.3.1</version>
|
||||
<version>4.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-gson</artifactId>
|
||||
<version>4.14.0</version>
|
||||
<version>4.17.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-gson-legacy-impl</artifactId>
|
||||
<version>4.14.0</version>
|
||||
<version>4.17.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-json</artifactId>
|
||||
<version>4.14.0</version>
|
||||
<version>4.17.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-json-legacy-impl</artifactId>
|
||||
<version>4.14.0</version>
|
||||
<version>4.17.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<version>4.14.0</version>
|
||||
<version>4.17.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-nbt</artifactId>
|
||||
<version>4.14.0</version>
|
||||
<version>4.17.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-key</artifactId>
|
||||
<version>4.14.0</version>
|
||||
<version>4.17.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-api</artifactId>
|
||||
<version>4.3.1</version>
|
||||
<version>4.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
<version>4.3.1</version>
|
||||
<version>LATEST</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-facet</artifactId>
|
||||
<version>4.3.1</version>
|
||||
<version>4.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-viaversion</artifactId>
|
||||
<version>4.3.1</version>
|
||||
<version>4.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>option</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.scm</groupId>
|
||||
<artifactId>maven-scm-provider-gitexe</artifactId>
|
||||
<version>2.0.0-M1</version>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.21-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -378,36 +412,36 @@
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>5.9.0</version>
|
||||
<version>5.11.0-M2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>4.6.1</version>
|
||||
<version>5.12.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-inline</artifactId>
|
||||
<version>4.6.1</version>
|
||||
<version>5.2.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>tomcat-jdbc</artifactId>
|
||||
<version>10.1.0-M17</version>
|
||||
<version>10.1.24</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>23.0.0</version>
|
||||
<version>24.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>32.1.1-jre</version> <!-- At this time Spigot is including 29.0 Guava classes that we are using -->
|
||||
<version>33.2.0-jre</version> <!-- At this time Spigot is including 29.0 Guava classes that we are using -->
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -416,5 +450,29 @@
|
||||
<version>0.3.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.logging.log4j</groupId>-->
|
||||
<!-- <artifactId>log4j-core</artifactId>-->
|
||||
<!-- <version>2.22.1</version> <!– Make sure this version matches the other log4j dependencies –>-->
|
||||
<!-- <scope>test</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.logging.log4j</groupId>-->
|
||||
<!-- <artifactId>log4j-api</artifactId>-->
|
||||
<!-- <version>2.22.1</version>-->
|
||||
<!-- <scope>test</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.apache.logging.log4j</groupId>-->
|
||||
<!-- <artifactId>log4j-slf4j-impl</artifactId>-->
|
||||
<!-- <version>2.22.1</version>-->
|
||||
<!-- <scope>test</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.seeseemelk</groupId>-->
|
||||
<!-- <artifactId>MockBukkit-v1.19</artifactId>-->
|
||||
<!-- <version>LATEST</version>-->
|
||||
<!-- <scope>test</scope>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -83,8 +83,8 @@ public final class AbilityAPI {
|
||||
}
|
||||
|
||||
public static boolean isBleeding(LivingEntity entity) {
|
||||
if(entity.isValid()) {
|
||||
if(entity.hasMetadata(MetadataConstants.METADATA_KEY_RUPTURE)) {
|
||||
if (entity.isValid()) {
|
||||
if (entity.hasMetadata(MetadataConstants.METADATA_KEY_RUPTURE)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
@@ -20,7 +19,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ExperienceAPI {
|
||||
@@ -518,7 +516,7 @@ public final class ExperienceAPI {
|
||||
}
|
||||
|
||||
public static float getOfflineXPRaw(@NotNull OfflinePlayer offlinePlayer, @NotNull PrimarySkillType skillType) throws InvalidPlayerException, UnsupportedOperationException {
|
||||
if(SkillTools.isChildSkill(skillType))
|
||||
if (SkillTools.isChildSkill(skillType))
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
return getOfflineProfile(offlinePlayer).getSkillXpLevelRaw(skillType);
|
||||
@@ -706,7 +704,7 @@ public final class ExperienceAPI {
|
||||
PrimarySkillType skill = getSkillType(skillType);
|
||||
|
||||
if (SkillTools.isChildSkill(skill)) {
|
||||
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
|
||||
var parentSkills = mcMMO.p.getSkillTools().getChildSkillParents(skill);
|
||||
|
||||
for (PrimarySkillType parentSkill : parentSkills) {
|
||||
profile.addLevels(parentSkill, (levels / parentSkills.size()));
|
||||
@@ -737,7 +735,7 @@ public final class ExperienceAPI {
|
||||
PrimarySkillType skill = getSkillType(skillType);
|
||||
|
||||
if (SkillTools.isChildSkill(skill)) {
|
||||
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
|
||||
var parentSkills = mcMMO.p.getSkillTools().getChildSkillParents(skill);
|
||||
|
||||
for (PrimarySkillType parentSkill : parentSkills) {
|
||||
profile.addLevels(parentSkill, (levels / parentSkills.size()));
|
||||
@@ -1145,14 +1143,10 @@ public final class ExperienceAPI {
|
||||
* @param blockStates the blocks to reward XP for
|
||||
* @param mcMMOPlayer the target player
|
||||
*/
|
||||
public static void addXpFromBlocks(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer)
|
||||
{
|
||||
for(BlockState bs : blockStates)
|
||||
{
|
||||
for(PrimarySkillType skillType : PrimarySkillType.values())
|
||||
{
|
||||
if(ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0)
|
||||
{
|
||||
public static void addXpFromBlocks(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer) {
|
||||
for(BlockState bs : blockStates) {
|
||||
for(PrimarySkillType skillType : PrimarySkillType.values()) {
|
||||
if (ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0) {
|
||||
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF);
|
||||
}
|
||||
}
|
||||
@@ -1165,12 +1159,9 @@ public final class ExperienceAPI {
|
||||
* @param mcMMOPlayer the target player
|
||||
* @param skillType target primary skill
|
||||
*/
|
||||
public static void addXpFromBlocksBySkill(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType)
|
||||
{
|
||||
for(BlockState bs : blockStates)
|
||||
{
|
||||
if(ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0)
|
||||
{
|
||||
public static void addXpFromBlocksBySkill(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) {
|
||||
for(BlockState bs : blockStates) {
|
||||
if (ExperienceConfig.getInstance().getXp(skillType, bs.getType()) > 0) {
|
||||
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF);
|
||||
}
|
||||
}
|
||||
@@ -1181,12 +1172,9 @@ public final class ExperienceAPI {
|
||||
* @param blockState The target blockstate
|
||||
* @param mcMMOPlayer The target player
|
||||
*/
|
||||
public static void addXpFromBlock(BlockState blockState, McMMOPlayer mcMMOPlayer)
|
||||
{
|
||||
for(PrimarySkillType skillType : PrimarySkillType.values())
|
||||
{
|
||||
if(ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0)
|
||||
{
|
||||
public static void addXpFromBlock(BlockState blockState, McMMOPlayer mcMMOPlayer) {
|
||||
for(PrimarySkillType skillType : PrimarySkillType.values()) {
|
||||
if (ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0) {
|
||||
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF);
|
||||
}
|
||||
}
|
||||
@@ -1198,10 +1186,8 @@ public final class ExperienceAPI {
|
||||
* @param mcMMOPlayer The target player
|
||||
* @param skillType target primary skill
|
||||
*/
|
||||
public static void addXpFromBlockBySkill(BlockState blockState, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType)
|
||||
{
|
||||
if(ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0)
|
||||
{
|
||||
public static void addXpFromBlockBySkill(BlockState blockState, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) {
|
||||
if (ExperienceConfig.getInstance().getXp(skillType, blockState.getType()) > 0) {
|
||||
mcMMOPlayer.applyXpGain(skillType, ExperienceConfig.getInstance().getXp(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@ package com.gmail.nossr50.api;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.party.PartyLeader;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -24,13 +25,22 @@ public final class PartyAPI {
|
||||
* @return the name of the player's party, or null if not in a party
|
||||
*/
|
||||
public static String getPartyName(Player player) {
|
||||
if (!inParty(player)) {
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled() || !inParty(player)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return UserManager.getPlayer(player).getParty().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the party system is enabled.
|
||||
*
|
||||
* @return true if the party system is enabled, false otherwise
|
||||
*/
|
||||
public static boolean isPartySystemEnabled() {
|
||||
return mcMMO.p.getPartyConfig().isPartyEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player is in a party.
|
||||
* </br>
|
||||
@@ -40,7 +50,7 @@ public final class PartyAPI {
|
||||
* @return true if the player is in a party, false otherwise
|
||||
*/
|
||||
public static boolean inParty(Player player) {
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled() || UserManager.getPlayer(player) == null)
|
||||
return false;
|
||||
|
||||
return UserManager.getPlayer(player).inParty();
|
||||
@@ -51,12 +61,15 @@ public final class PartyAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param playera The first player to check
|
||||
* @param playerb The second player to check
|
||||
* @param playerA The first player to check
|
||||
* @param playerB The second player to check
|
||||
* @return true if the two players are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player playera, Player playerb) {
|
||||
return PartyManager.inSameParty(playera, playerb);
|
||||
public static boolean inSameParty(Player playerA, Player playerB) {
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled())
|
||||
return false;
|
||||
|
||||
return mcMMO.p.getPartyManager().inSameParty(playerA, playerB);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +80,7 @@ public final class PartyAPI {
|
||||
* @return the list of parties.
|
||||
*/
|
||||
public static List<Party> getParties() {
|
||||
return PartyManager.getParties();
|
||||
return mcMMO.p.getPartyManager().getParties();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,23 +94,28 @@ public final class PartyAPI {
|
||||
*/
|
||||
@Deprecated
|
||||
public static void addToParty(Player player, String partyName) {
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if player profile is loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
final McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (mmoPlayer == null)
|
||||
return;
|
||||
|
||||
Party party = PartyManager.getParty(partyName);
|
||||
Party party = mcMMO.p.getPartyManager().getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
|
||||
} else {
|
||||
if(PartyManager.isPartyFull(player, party))
|
||||
{
|
||||
if (mcMMO.p.getPartyManager().isPartyFull(player, party)) {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PartyManager.addToParty(UserManager.getPlayer(player), party);
|
||||
mcMMO.p.getPartyManager().addToParty(mmoPlayer, party);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,8 +123,7 @@ public final class PartyAPI {
|
||||
* 0 or less for no size limit
|
||||
* @return the max party size on this server
|
||||
*/
|
||||
public static int getMaxPartySize()
|
||||
{
|
||||
public static int getMaxPartySize() {
|
||||
return mcMMO.p.getGeneralConfig().getPartyMaxSize();
|
||||
}
|
||||
|
||||
@@ -119,19 +136,18 @@ public final class PartyAPI {
|
||||
* @param partyName The party to add the player to
|
||||
* @param bypassLimit if true bypasses party size limits
|
||||
*/
|
||||
//TODO: bypasslimit not used?
|
||||
public static void addToParty(Player player, String partyName, boolean bypassLimit) {
|
||||
//Check if player profile is loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled() || UserManager.getPlayer(player) == null)
|
||||
return;
|
||||
|
||||
Party party = PartyManager.getParty(partyName);
|
||||
Party party = mcMMO.p.getPartyManager().getParty(partyName);
|
||||
|
||||
if (party == null) {
|
||||
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
|
||||
}
|
||||
|
||||
PartyManager.addToParty(UserManager.getPlayer(player), party);
|
||||
mcMMO.p.getPartyManager().addToParty(UserManager.getPlayer(player), party);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,10 +159,10 @@ public final class PartyAPI {
|
||||
*/
|
||||
public static void removeFromParty(Player player) {
|
||||
//Check if player profile is loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled() || UserManager.getPlayer(player) == null)
|
||||
return;
|
||||
|
||||
PartyManager.removeFromParty(UserManager.getPlayer(player));
|
||||
mcMMO.p.getPartyManager().removeFromParty(UserManager.getPlayer(player));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,8 +173,11 @@ public final class PartyAPI {
|
||||
* @param partyName The party name
|
||||
* @return the leader of the party
|
||||
*/
|
||||
public static String getPartyLeader(String partyName) {
|
||||
return PartyManager.getPartyLeaderName(partyName);
|
||||
public static @Nullable String getPartyLeader(String partyName) {
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled())
|
||||
return null;
|
||||
|
||||
return mcMMO.p.getPartyManager().getPartyLeaderName(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +190,10 @@ public final class PartyAPI {
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setPartyLeader(String partyName, String playerName) {
|
||||
PartyManager.setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), PartyManager.getParty(partyName));
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled())
|
||||
return;
|
||||
|
||||
mcMMO.p.getPartyManager().setPartyLeader(mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId(), mcMMO.p.getPartyManager().getParty(partyName));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,9 +206,12 @@ public final class PartyAPI {
|
||||
*/
|
||||
@Deprecated
|
||||
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
|
||||
List<OfflinePlayer> members = new ArrayList<>();
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (UUID memberUniqueId : PartyManager.getAllMembers(player).keySet()) {
|
||||
List<OfflinePlayer> members = new ArrayList<>();
|
||||
for (UUID memberUniqueId : mcMMO.p.getPartyManager().getAllMembers(player).keySet()) {
|
||||
OfflinePlayer member = mcMMO.p.getServer().getOfflinePlayer(memberUniqueId);
|
||||
members.add(member);
|
||||
}
|
||||
@@ -203,7 +228,10 @@ public final class PartyAPI {
|
||||
*/
|
||||
@Deprecated
|
||||
public static LinkedHashSet<String> getMembers(Player player) {
|
||||
return (LinkedHashSet<String>) PartyManager.getAllMembers(player).values();
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled())
|
||||
return null;
|
||||
|
||||
return (LinkedHashSet<String>) mcMMO.p.getPartyManager().getAllMembers(player).values();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +243,10 @@ public final class PartyAPI {
|
||||
* @return all the player names and uuids in the player's party
|
||||
*/
|
||||
public static LinkedHashMap<UUID, String> getMembersMap(Player player) {
|
||||
return PartyManager.getAllMembers(player);
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled())
|
||||
return null;
|
||||
|
||||
return mcMMO.p.getPartyManager().getAllMembers(player);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,7 +258,10 @@ public final class PartyAPI {
|
||||
* @return all online players in this party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(String partyName) {
|
||||
return PartyManager.getOnlineMembers(partyName);
|
||||
if (!mcMMO.p.getPartyConfig().isPartyEnabled())
|
||||
return null;
|
||||
|
||||
return mcMMO.p.getPartyManager().getOnlineMembers(partyName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,7 +273,7 @@ public final class PartyAPI {
|
||||
* @return all online players in the player's party
|
||||
*/
|
||||
public static List<Player> getOnlineMembers(Player player) {
|
||||
return PartyManager.getOnlineMembers(player);
|
||||
return mcMMO.p.getPartyManager().getOnlineMembers(player);
|
||||
}
|
||||
|
||||
public static boolean hasAlly(String partyName) {
|
||||
@@ -247,7 +281,7 @@ public final class PartyAPI {
|
||||
}
|
||||
|
||||
public static String getAllyName(String partyName) {
|
||||
Party ally = PartyManager.getParty(partyName).getAlly();
|
||||
Party ally = mcMMO.p.getPartyManager().getParty(partyName).getAlly();
|
||||
if (ally != null) {
|
||||
return ally.getName();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.gmail.nossr50.api.exceptions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ValueOutOfBoundsException extends RuntimeException {
|
||||
public ValueOutOfBoundsException(@NotNull String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class ChatManager {
|
||||
* @param targetChatChannel target chat channel
|
||||
*/
|
||||
public void setOrToggleChatChannel(@NotNull McMMOPlayer mmoPlayer, @NotNull ChatChannel targetChatChannel) {
|
||||
if(targetChatChannel == mmoPlayer.getChatChannel()) {
|
||||
if (targetChatChannel == mmoPlayer.getChatChannel()) {
|
||||
//Disabled message
|
||||
mmoPlayer.getPlayer().sendMessage(LocaleLoader.getString("Chat.Channel.Off", StringUtils.getCapitalized(targetChatChannel.toString())));
|
||||
mmoPlayer.setChatMode(ChatChannel.NONE);
|
||||
@@ -144,7 +144,7 @@ public class ChatManager {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
for(int i = 0; i < args.length; i++) {
|
||||
if(i + 1 >= args.length) {
|
||||
if (i + 1 >= args.length) {
|
||||
stringBuilder.append(args[i]);
|
||||
} else {
|
||||
stringBuilder.append(args[i]).append(" ");
|
||||
@@ -162,12 +162,12 @@ public class ChatManager {
|
||||
public boolean isMessageAllowed(@NotNull McMMOPlayer mmoPlayer) {
|
||||
switch (mmoPlayer.getChatChannel()) {
|
||||
case ADMIN:
|
||||
if(mmoPlayer.getPlayer().isOp() || Permissions.adminChat(mmoPlayer.getPlayer())) {
|
||||
if (mmoPlayer.getPlayer().isOp() || Permissions.adminChat(mmoPlayer.getPlayer())) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case PARTY:
|
||||
if(mmoPlayer.getParty() != null && Permissions.partyChat(mmoPlayer.getPlayer())) {
|
||||
if (mmoPlayer.getParty() != null && Permissions.partyChat(mmoPlayer.getPlayer())) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
@@ -206,7 +206,7 @@ public class ChatManager {
|
||||
* @return true if the chat channel is enabled
|
||||
*/
|
||||
public boolean isChatChannelEnabled(@NotNull ChatChannel chatChannel) {
|
||||
if(!isChatEnabled) {
|
||||
if (!isChatEnabled) {
|
||||
return false;
|
||||
} else {
|
||||
switch(chatChannel) {
|
||||
|
||||
@@ -20,12 +20,12 @@ public class SamePartyPredicate<T extends CommandSender> implements Predicate<T>
|
||||
@Override
|
||||
public boolean test(T t) {
|
||||
//Include the console in the audience
|
||||
if(t instanceof ConsoleCommandSender) {
|
||||
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) {
|
||||
if (t instanceof Player player) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
if(mcMMOPlayer != null) {
|
||||
if (mcMMOPlayer != null) {
|
||||
return mcMMOPlayer.getParty() == party;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,15 +48,15 @@ public abstract class AbstractPlayerAuthor implements Author {
|
||||
*/
|
||||
protected @NotNull String getSanitizedName(@NotNull ChatChannel chatChannel, boolean useDisplayName) {
|
||||
//Already in cache
|
||||
if(sanitizedNameCache.containsKey(chatChannel)) {
|
||||
if (sanitizedNameCache.containsKey(chatChannel)) {
|
||||
//Update cache
|
||||
if(useDisplayName && hasPlayerDisplayNameChanged()) {
|
||||
if (useDisplayName && hasPlayerDisplayNameChanged()) {
|
||||
updateLastKnownDisplayName();
|
||||
updateSanitizedNameCache(chatChannel, true);
|
||||
}
|
||||
} else {
|
||||
//Update last known display name
|
||||
if(useDisplayName && hasPlayerDisplayNameChanged()) {
|
||||
if (useDisplayName && hasPlayerDisplayNameChanged()) {
|
||||
updateLastKnownDisplayName();
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public abstract class AbstractPlayerAuthor implements Author {
|
||||
* @param useDisplayName whether to use this authors display name
|
||||
*/
|
||||
private void updateSanitizedNameCache(@NotNull ChatChannel chatChannel, boolean useDisplayName) {
|
||||
if(useDisplayName) {
|
||||
if (useDisplayName) {
|
||||
sanitizedNameCache.put(chatChannel, TextUtils.sanitizeForSerializer(player.getDisplayName()));
|
||||
} else {
|
||||
//No need to sanitize a basic String
|
||||
|
||||
@@ -3,6 +3,7 @@ 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.config.ChatConfig;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
|
||||
import com.gmail.nossr50.events.chat.McMMOChatEvent;
|
||||
@@ -44,7 +45,7 @@ public class AdminChatMailer extends AbstractChatMailer {
|
||||
public @NotNull Predicate<CommandSender> predicate() {
|
||||
return (commandSender) -> commandSender.isOp()
|
||||
|| commandSender.hasPermission(MCMMO_CHAT_ADMINCHAT_PERMISSION)
|
||||
|| commandSender instanceof ConsoleCommandSender;
|
||||
|| (ChatConfig.getInstance().isConsoleIncludedInAudience(ChatChannel.ADMIN) && commandSender instanceof ConsoleCommandSender);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,7 +57,7 @@ public class AdminChatMailer extends AbstractChatMailer {
|
||||
* @return the styled string, based on a locale entry
|
||||
*/
|
||||
public @NotNull TextComponent addStyle(@NotNull Author author, @NotNull String message, boolean canColor) {
|
||||
if(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));
|
||||
@@ -82,7 +83,7 @@ public class AdminChatMailer extends AbstractChatMailer {
|
||||
McMMOChatEvent chatEvent = new McMMOAdminChatEvent(pluginRef, chatMessage, isAsync);
|
||||
Bukkit.getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if(!chatEvent.isCancelled()) {
|
||||
if (!chatEvent.isCancelled()) {
|
||||
sendMail(chatMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PartyChatMailer extends AbstractChatMailer {
|
||||
McMMOChatEvent chatEvent = new McMMOPartyChatEvent(pluginRef, chatMessage, party, isAsync);
|
||||
Bukkit.getPluginManager().callEvent(chatEvent);
|
||||
|
||||
if(!chatEvent.isCancelled()) {
|
||||
if (!chatEvent.isCancelled()) {
|
||||
sendMail(chatMessage);
|
||||
}
|
||||
}
|
||||
@@ -60,14 +60,14 @@ public class PartyChatMailer extends AbstractChatMailer {
|
||||
* @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) {
|
||||
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) {
|
||||
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));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.chat.message;
|
||||
|
||||
import com.gmail.nossr50.chat.author.Author;
|
||||
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.player.McMMOPlayer;
|
||||
@@ -51,7 +52,8 @@ public class PartyChatMessage extends AbstractChatMessage {
|
||||
messagePartyChatSpies(spyMessage);
|
||||
|
||||
//Console message
|
||||
mcMMO.p.getChatManager().sendConsoleMessage(author, spyMessage);
|
||||
if (ChatConfig.getInstance().isConsoleIncludedInAudience(ChatChannel.PARTY))
|
||||
mcMMO.p.getChatManager().sendConsoleMessage(author, spyMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,11 +67,11 @@ public class PartyChatMessage extends AbstractChatMessage {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
//Check for toggled players
|
||||
if(mcMMOPlayer.isPartyChatSpying()) {
|
||||
if (mcMMOPlayer.isPartyChatSpying()) {
|
||||
Party adminParty = mcMMOPlayer.getParty();
|
||||
|
||||
//Only message admins not part of this party
|
||||
if(adminParty == null || adminParty != getParty()) {
|
||||
if (adminParty == null || adminParty != getParty()) {
|
||||
//TODO: Hacky, rewrite later
|
||||
Audience audience = mcMMO.getAudiences().player(player);
|
||||
audience.sendMessage(spyMessage);
|
||||
|
||||
@@ -5,6 +5,7 @@ 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.commands.skills.PowerLevelCommand;
|
||||
import com.gmail.nossr50.config.ChatConfig;
|
||||
import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
@@ -20,9 +21,14 @@ 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 MMO_DATA_LOADED = "mmoDataLoaded";
|
||||
|
||||
//CHAT
|
||||
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";
|
||||
|
||||
//SKILLS
|
||||
public static final @NotNull String POWER_LEVEL_CONDITION = "powerLevelCondition";
|
||||
|
||||
private final @NotNull mcMMO pluginRef;
|
||||
private final @NotNull BukkitCommandManager bukkitCommandManager;
|
||||
@@ -36,29 +42,53 @@ public class CommandManager {
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
registerSkillCommands(); //TODO: Implement other skills not just power level
|
||||
registerChatCommands();
|
||||
}
|
||||
|
||||
private void registerSkillCommands() {
|
||||
if (mcMMO.p.getGeneralConfig().isMasterySystemEnabled()) {
|
||||
bukkitCommandManager.registerCommand(new PowerLevelCommand(pluginRef));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers chat commands if the chat system is enabled
|
||||
*/
|
||||
private void registerChatCommands() {
|
||||
if(ChatConfig.getInstance().isChatEnabled()) {
|
||||
if(ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.ADMIN)) {
|
||||
if (ChatConfig.getInstance().isChatEnabled()) {
|
||||
if (ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.ADMIN)) {
|
||||
bukkitCommandManager.registerCommand(new AdminChatCommand(pluginRef));
|
||||
}
|
||||
if(ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.PARTY)) {
|
||||
if (pluginRef.getPartyConfig().isPartyEnabled() && ChatConfig.getInstance().isChatChannelEnabled(ChatChannel.PARTY)) {
|
||||
bukkitCommandManager.registerCommand(new PartyChatCommand(pluginRef));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerConditions() {
|
||||
registerChatCommandConditions(); //Chat Commands
|
||||
registerSkillConditions();
|
||||
}
|
||||
|
||||
private void registerSkillConditions() {
|
||||
bukkitCommandManager.getCommandConditions().addCondition(POWER_LEVEL_CONDITION, (context) -> {
|
||||
BukkitCommandIssuer issuer = context.getIssuer();
|
||||
|
||||
if (issuer.getIssuer() instanceof Player) {
|
||||
validateLoadedData(issuer.getPlayer());
|
||||
} else {
|
||||
throw new ConditionFailedException(LocaleLoader.getString("Commands.NoConsole"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void registerChatCommandConditions() {
|
||||
// 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) {
|
||||
if (issuer.getIssuer() instanceof Player) {
|
||||
validateLoadedData(issuer.getPlayer());
|
||||
validateAdmin(issuer.getPlayer());
|
||||
}
|
||||
@@ -67,7 +97,7 @@ public class CommandManager {
|
||||
bukkitCommandManager.getCommandConditions().addCondition(MMO_DATA_LOADED, (context) -> {
|
||||
BukkitCommandIssuer bukkitCommandIssuer = context.getIssuer();
|
||||
|
||||
if(bukkitCommandIssuer.getIssuer() instanceof Player) {
|
||||
if (bukkitCommandIssuer.getIssuer() instanceof Player) {
|
||||
validateLoadedData(bukkitCommandIssuer.getPlayer());
|
||||
}
|
||||
});
|
||||
@@ -75,29 +105,30 @@ public class CommandManager {
|
||||
bukkitCommandManager.getCommandConditions().addCondition(PARTY_CONDITION, (context) -> {
|
||||
BukkitCommandIssuer bukkitCommandIssuer = context.getIssuer();
|
||||
|
||||
if(bukkitCommandIssuer.getIssuer() instanceof Player) {
|
||||
if (bukkitCommandIssuer.getIssuer() instanceof Player) {
|
||||
validateLoadedData(bukkitCommandIssuer.getPlayer());
|
||||
validatePlayerParty(bukkitCommandIssuer.getPlayer());
|
||||
//TODO: Is there even a point in validating permission? look into this later
|
||||
validatePermission("mcmmo.chat.partychat", bukkitCommandIssuer.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void validatePermission(@NotNull String permissionNode, @NotNull Permissible permissible) {
|
||||
if(!permissible.hasPermission(permissionNode)) {
|
||||
if (!permissible.hasPermission(permissionNode)) {
|
||||
throw new ConditionFailedException(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void validateAdmin(@NotNull Player player) {
|
||||
if(!player.isOp() && !Permissions.adminChat(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) {
|
||||
if (UserManager.getPlayer(player) == null) {
|
||||
throw new ConditionFailedException(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
}
|
||||
}
|
||||
@@ -105,7 +136,7 @@ public class CommandManager {
|
||||
public void validatePlayerParty(@NotNull Player player) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if(mmoPlayer.getParty() == null) {
|
||||
if (!pluginRef.getPartyConfig().isPartyEnabled() || mmoPlayer.getParty() == null) {
|
||||
throw new ConditionFailedException(LocaleLoader.getString("Commands.Party.None"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,14 +200,11 @@ public class McImportCommand implements CommandExecutor {
|
||||
String skillName = "UNIDENTIFIED";
|
||||
if (materialName.contains("ORE")) {
|
||||
skillName = "Mining";
|
||||
}
|
||||
else if (materialName.contains("LOG") || materialName.contains("LEAVES")) {
|
||||
} else if (materialName.contains("LOG") || materialName.contains("LEAVES")) {
|
||||
skillName = "Woodcutting";
|
||||
}
|
||||
else if (materialName.contains("GRASS") || materialName.contains("SHORT_GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
|
||||
} else if (materialName.contains("GRASS") || materialName.contains("SHORT_GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
|
||||
skillName = "Herbalism";
|
||||
}
|
||||
else if (materialName.contains("DIRT") || materialName.contains("SAND")) {
|
||||
} else if (materialName.contains("DIRT") || materialName.contains("SAND")) {
|
||||
skillName = "Excavation";
|
||||
}
|
||||
|
||||
@@ -222,8 +219,7 @@ public class McImportCommand implements CommandExecutor {
|
||||
|
||||
if (skillName.equals("Mining")) {
|
||||
skillContents.add(" " + " " + "Smelting_XP_Gain: 9");
|
||||
}
|
||||
else if (skillName.equals("Woodcutting")) {
|
||||
} else if (skillName.equals("Woodcutting")) {
|
||||
skillContents.add(" " + " " + "Is_Log: " + materialName.contains("LOG"));
|
||||
}
|
||||
}
|
||||
@@ -239,20 +235,15 @@ public class McImportCommand implements CommandExecutor {
|
||||
String toolType = "UNIDENTIFIED";
|
||||
if (materialName.contains("PICKAXE")) {
|
||||
toolType = "Pickaxes";
|
||||
}
|
||||
else if (materialName.contains("AXE")) {
|
||||
} else if (materialName.contains("AXE")) {
|
||||
toolType = "Axes";
|
||||
}
|
||||
else if (materialName.contains("BOW")) {
|
||||
} else if (materialName.contains("BOW")) {
|
||||
toolType = "Bows";
|
||||
}
|
||||
else if (materialName.contains("HOE")) {
|
||||
} else if (materialName.contains("HOE")) {
|
||||
toolType = "Hoes";
|
||||
}
|
||||
else if (materialName.contains("SHOVEL") || materialName.contains("SPADE")) {
|
||||
} else if (materialName.contains("SHOVEL") || materialName.contains("SPADE")) {
|
||||
toolType = "Shovels";
|
||||
}
|
||||
else if (materialName.contains("SWORD")) {
|
||||
} else if (materialName.contains("SWORD")) {
|
||||
toolType = "Swords";
|
||||
}
|
||||
|
||||
@@ -279,14 +270,11 @@ public class McImportCommand implements CommandExecutor {
|
||||
String toolType = "UNIDENTIFIED";
|
||||
if (materialName.contains("BOOT") || materialName.contains("SHOE")) {
|
||||
toolType = "Boots";
|
||||
}
|
||||
else if (materialName.contains("CHESTPLATE") || materialName.contains("CHEST")) {
|
||||
} else if (materialName.contains("CHESTPLATE") || materialName.contains("CHEST")) {
|
||||
toolType = "Chestplates";
|
||||
}
|
||||
else if (materialName.contains("HELM") || materialName.contains("HAT")) {
|
||||
} else if (materialName.contains("HELM") || materialName.contains("HAT")) {
|
||||
toolType = "Helmets";
|
||||
}
|
||||
else if (materialName.contains("LEGGINGS") || materialName.contains("LEGS") || materialName.contains("PANTS")) {
|
||||
} else if (materialName.contains("LEGGINGS") || materialName.contains("LEGS") || materialName.contains("PANTS")) {
|
||||
toolType = "Leggings";
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class McmmoCommand implements CommandExecutor {
|
||||
|
||||
private void displayOtherCommands(CommandSender sender) {
|
||||
//Don't show them this category if they have none of the permissions
|
||||
if(!Permissions.skillreset(sender) && !Permissions.mmoedit(sender) && !Permissions.adminChat(sender) && !Permissions.mcgod(sender))
|
||||
if (!Permissions.skillreset(sender) && !Permissions.mmoedit(sender) && !Permissions.adminChat(sender) && !Permissions.mcgod(sender))
|
||||
return;
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Other"));
|
||||
|
||||
@@ -23,12 +23,12 @@ public class McscoreboardCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
|
||||
if (!mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Scoreboard.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!ScoreboardManager.isPlayerBoardSetup(sender.getName())) {
|
||||
if (!ScoreboardManager.isPlayerBoardSetup(sender.getName())) {
|
||||
sender.sendMessage(LocaleLoader.getString("Scoreboard.NotSetupYet"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,16 +37,14 @@ public class XprateCommand implements TabExecutor {
|
||||
|
||||
if (mcMMO.p.isXPEventEnabled()) {
|
||||
|
||||
if(mcMMO.p.getAdvancedConfig().useTitlesForXPEvent())
|
||||
{
|
||||
if (mcMMO.p.getAdvancedConfig().useTitlesForXPEvent()) {
|
||||
NotificationManager.broadcastTitle(mcMMO.p.getServer(),
|
||||
LocaleLoader.getString("Commands.Event.Stop"),
|
||||
LocaleLoader.getString("Commands.Event.Stop.Subtitle"),
|
||||
10, 10*20, 20);
|
||||
}
|
||||
|
||||
if(mcMMO.p.getGeneralConfig().broadcastEventMessages())
|
||||
{
|
||||
if (mcMMO.p.getGeneralConfig().broadcastEventMessages()) {
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop"));
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop.Subtitle"));
|
||||
}
|
||||
@@ -72,34 +70,29 @@ public class XprateCommand implements TabExecutor {
|
||||
|
||||
if (CommandUtils.shouldDisableToggle(args[1])) {
|
||||
mcMMO.p.setXPEventEnabled(false);
|
||||
}
|
||||
else if (CommandUtils.shouldEnableToggle(args[1])) {
|
||||
} else if (CommandUtils.shouldEnableToggle(args[1])) {
|
||||
mcMMO.p.setXPEventEnabled(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
int newXpRate = Integer.parseInt(args[0]);
|
||||
|
||||
if(newXpRate < 0)
|
||||
{
|
||||
if (newXpRate < 0) {
|
||||
sender.sendMessage(ChatColor.RED+LocaleLoader.getString("Commands.NegativeNumberWarn"));
|
||||
return true;
|
||||
}
|
||||
|
||||
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
|
||||
|
||||
if(mcMMO.p.getAdvancedConfig().useTitlesForXPEvent())
|
||||
{
|
||||
if (mcMMO.p.getAdvancedConfig().useTitlesForXPEvent()) {
|
||||
NotificationManager.broadcastTitle(mcMMO.p.getServer(),
|
||||
LocaleLoader.getString("Commands.Event.Start"),
|
||||
LocaleLoader.getString("Commands.Event.XP", newXpRate),
|
||||
10, 10*20, 20);
|
||||
}
|
||||
|
||||
if(mcMMO.p.getGeneralConfig().broadcastEventMessages())
|
||||
{
|
||||
if (mcMMO.p.getGeneralConfig().broadcastEventMessages()) {
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start"));
|
||||
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate));
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
//public class DropTreasureCommand implements CommandExecutor {
|
||||
// @Override
|
||||
// public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
// if(sender instanceof Player) {
|
||||
// if(!sender.isOp()) {
|
||||
// if (sender instanceof Player) {
|
||||
// if (!sender.isOp()) {
|
||||
// sender.sendMessage("This command is for Operators only");
|
||||
// return false;
|
||||
// }
|
||||
@@ -27,13 +27,13 @@
|
||||
// Location location = player.getLocation();
|
||||
// McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
//
|
||||
// if(mmoPlayer == null) {
|
||||
// if (mmoPlayer == null) {
|
||||
// //TODO: Localize
|
||||
// player.sendMessage("Your player data is not loaded yet");
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if(args.length == 0) {
|
||||
// if (args.length == 0) {
|
||||
// mcMMO.p.getLogger().info(player.toString() +" is dropping all mcMMO treasures via admin command at location "+location.toString());
|
||||
// for(Rarity rarity : FishingTreasureConfig.getInstance().fishingRewards.keySet()) {
|
||||
// for(FishingTreasure fishingTreasure : FishingTreasureConfig.getInstance().fishingRewards.get(rarity)) {
|
||||
|
||||
@@ -13,7 +13,7 @@ public class PlayerDebugCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
if (sender instanceof Player) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer((Player) sender);
|
||||
mcMMOPlayer.toggleDebugMode(); //Toggle debug mode
|
||||
NotificationManager.sendPlayerInformationChatOnlyPrefixed(mcMMOPlayer.getPlayer(), "Commands.Mmodebug.Toggle", String.valueOf(mcMMOPlayer.isDebugMode()));
|
||||
|
||||
@@ -25,9 +25,9 @@ public class AdminChatCommand extends BaseCommand {
|
||||
@Default @Conditions(CommandManager.ADMIN_CONDITION)
|
||||
public void processCommand(String[] args) {
|
||||
BukkitCommandIssuer bukkitCommandIssuer = (BukkitCommandIssuer) getCurrentCommandIssuer();
|
||||
if(args == null || args.length == 0) {
|
||||
if (args == null || args.length == 0) {
|
||||
//Process with no arguments
|
||||
if(bukkitCommandIssuer.isPlayer()) {
|
||||
if (bukkitCommandIssuer.isPlayer()) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(bukkitCommandIssuer.getPlayer());
|
||||
pluginRef.getChatManager().setOrToggleChatChannel(mmoPlayer, ChatChannel.ADMIN);
|
||||
} else {
|
||||
@@ -35,10 +35,10 @@ public class AdminChatCommand extends BaseCommand {
|
||||
mcMMO.p.getLogger().info("You cannot switch chat channels as console, please provide full arguments.");
|
||||
}
|
||||
} else {
|
||||
if(bukkitCommandIssuer.isPlayer()) {
|
||||
if (bukkitCommandIssuer.isPlayer()) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(bukkitCommandIssuer.getPlayer());
|
||||
|
||||
if(mmoPlayer == null)
|
||||
if (mmoPlayer == null)
|
||||
return;
|
||||
|
||||
//Message contains the original command so it needs to be passed to this method to trim it
|
||||
|
||||
@@ -11,7 +11,6 @@ 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.mcMMO;
|
||||
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;
|
||||
@@ -31,9 +30,9 @@ public class PartyChatCommand extends BaseCommand {
|
||||
public void processCommand(String[] args) {
|
||||
BukkitCommandIssuer bukkitCommandIssuer = (BukkitCommandIssuer) getCurrentCommandIssuer();
|
||||
|
||||
if(args == null || args.length == 0) {
|
||||
if (args == null || args.length == 0) {
|
||||
//Process with no arguments
|
||||
if(bukkitCommandIssuer.isPlayer()) {
|
||||
if (bukkitCommandIssuer.isPlayer()) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(bukkitCommandIssuer.getPlayer());
|
||||
pluginRef.getChatManager().setOrToggleChatChannel(mmoPlayer, ChatChannel.PARTY);
|
||||
} else {
|
||||
@@ -46,7 +45,7 @@ public class PartyChatCommand extends BaseCommand {
|
||||
/*
|
||||
* Player Logic
|
||||
*/
|
||||
if(bukkitCommandIssuer.getIssuer() instanceof Player) {
|
||||
if (bukkitCommandIssuer.getIssuer() instanceof Player) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(bukkitCommandIssuer.getPlayer());
|
||||
processCommandArgsPlayer(mmoPlayer, args);
|
||||
/*
|
||||
@@ -73,14 +72,14 @@ public class PartyChatCommand extends BaseCommand {
|
||||
* @param args command arguments
|
||||
*/
|
||||
private void processCommandArgsConsole(@NotNull String[] args) {
|
||||
if(args.length <= 1) {
|
||||
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]);
|
||||
Party targetParty = mcMMO.p.getPartyManager().getParty(args[0]);
|
||||
|
||||
if(targetParty != null) {
|
||||
if (targetParty != null) {
|
||||
pluginRef.getChatManager().processConsoleMessage(StringUtils.buildStringAfterNthElement(args, 1), targetParty);
|
||||
} else {
|
||||
mcMMO.p.getLogger().severe("A party with that name doesn't exist!");
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ConvertDatabaseCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
DatabaseManager oldDatabase = DatabaseManagerFactory.createDatabaseManager(previousType, mcMMO.getUsersFilePath(), mcMMO.p.getLogger(), mcMMO.p.getPurgeTime(), mcMMO.p.getAdvancedConfig().getStartingLevel());
|
||||
if(oldDatabase == null) {
|
||||
if (oldDatabase == null) {
|
||||
sender.sendMessage("Unable to load the old database! Check your log for errors.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if(mmoPlayer == null) {
|
||||
if (mmoPlayer == null) {
|
||||
EventUtils.tryLevelChangeEvent(player, skill, value, xpRemoved, true, XPGainReason.COMMAND);
|
||||
} else {
|
||||
EventUtils.tryLevelChangeEvent(mmoPlayer, skill, value, xpRemoved, true, XPGainReason.COMMAND);
|
||||
@@ -45,7 +45,7 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageAll(Player player, int value, boolean isSilent) {
|
||||
if(isSilent)
|
||||
if (isSilent)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", value));
|
||||
@@ -53,7 +53,7 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
|
||||
if(isSilent)
|
||||
if (isSilent)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, mcMMO.p.getSkillTools().getLocalizedSkillName(skill)));
|
||||
|
||||
@@ -26,12 +26,11 @@ public class AddxpCommand extends ExperienceCommand {
|
||||
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
|
||||
if (player != null) {
|
||||
//Check if player profile is loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
if (UserManager.getPlayer(player) == null)
|
||||
return;
|
||||
|
||||
UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
profile.addXp(skill, value);
|
||||
profile.scheduleAsyncSave();
|
||||
}
|
||||
@@ -39,7 +38,7 @@ public class AddxpCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageAll(Player player, int value, boolean isSilent) {
|
||||
if(isSilent)
|
||||
if (isSilent)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", value));
|
||||
@@ -47,7 +46,7 @@ public class AddxpCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
|
||||
if(isSilent)
|
||||
if (isSilent)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, mcMMO.p.getSkillTools().getLocalizedSkillName(skill)));
|
||||
|
||||
@@ -24,16 +24,16 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
PrimarySkillType skill;
|
||||
|
||||
if(args.length < 2) {
|
||||
if (args.length < 2) {
|
||||
return false;
|
||||
} else {
|
||||
if(args.length == 2 && !isSilent(args) || args.length == 3 && isSilent(args)) {
|
||||
if (args.length == 2 && !isSilent(args) || args.length == 3 && isSilent(args)) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!permissionsCheckSelf(sender)) {
|
||||
if(command.getPermissionMessage() != null)
|
||||
if (command.getPermissionMessage() != null)
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
sender.sendMessage("(mcMMO) No permission!");
|
||||
return true;
|
||||
@@ -49,15 +49,13 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
skill = null;
|
||||
}
|
||||
|
||||
if (skill != null && SkillTools.isChildSkill(skill))
|
||||
{
|
||||
if (skill != null && SkillTools.isChildSkill(skill)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
|
||||
return true;
|
||||
}
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(sender.getName()) == null)
|
||||
{
|
||||
if (UserManager.getPlayer(sender.getName()) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
@@ -65,7 +63,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
|
||||
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]), isSilent(args));
|
||||
return true;
|
||||
} else if((args.length == 3 && !isSilent(args))
|
||||
} else if ((args.length == 3 && !isSilent(args))
|
||||
|| (args.length == 4 && isSilent(args))) {
|
||||
if (!permissionsCheckOthers(sender)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
@@ -82,8 +80,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
skill = null;
|
||||
}
|
||||
|
||||
if (skill != null && SkillTools.isChildSkill(skill))
|
||||
{
|
||||
if (skill != null && SkillTools.isChildSkill(skill)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
|
||||
return true;
|
||||
}
|
||||
@@ -104,14 +101,13 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
//Check loading by name
|
||||
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName);
|
||||
|
||||
if(CommandUtils.unloadedProfile(sender, profile)) {
|
||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
editValues(null, profile, skill, value, isSilent(args));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value, isSilent(args));
|
||||
}
|
||||
|
||||
@@ -126,7 +122,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
private boolean isSilent(String[] args) {
|
||||
int length = args.length;
|
||||
|
||||
if(length == 0)
|
||||
if (length == 0)
|
||||
return false;
|
||||
|
||||
return args[length-1].equalsIgnoreCase("-s");
|
||||
@@ -159,8 +155,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
|
||||
if (skill == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", mcMMO.p.getSkillTools().getLocalizedSkillName(skill), playerName));
|
||||
}
|
||||
}
|
||||
@@ -174,8 +169,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
if (player != null) {
|
||||
handlePlayerMessageAll(player, value, isSilent);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
handleCommand(player, profile, skill, value);
|
||||
|
||||
if (player != null) {
|
||||
|
||||
@@ -41,7 +41,7 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if(mmoPlayer != null) {
|
||||
if (mmoPlayer != null) {
|
||||
EventUtils.tryLevelEditEvent(mmoPlayer, skill, value, xpRemoved, value > skillLevel, XPGainReason.COMMAND, skillLevel);
|
||||
} else {
|
||||
EventUtils.tryLevelEditEvent(player, skill, value, xpRemoved, value > skillLevel, XPGainReason.COMMAND, skillLevel);
|
||||
@@ -51,7 +51,7 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageAll(Player player, int value, boolean isSilent) {
|
||||
if(isSilent)
|
||||
if (isSilent)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", value));
|
||||
@@ -59,7 +59,7 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill, boolean isSilent) {
|
||||
if(isSilent)
|
||||
if (isSilent)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", mcMMO.p.getSkillTools().getLocalizedSkillName(skill), value));
|
||||
|
||||
@@ -48,8 +48,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
skill = null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
skill = mcMMO.p.getSkillTools().matchSkill(args[0]);
|
||||
}
|
||||
|
||||
@@ -68,8 +67,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
skill = null;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
skill = mcMMO.p.getSkillTools().matchSkill(args[1]);
|
||||
}
|
||||
|
||||
@@ -87,14 +85,13 @@ public class SkillresetCommand implements TabExecutor {
|
||||
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName);
|
||||
|
||||
//Check if it was present in DB
|
||||
if(CommandUtils.unloadedProfile(sender, profile)) {
|
||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
editValues(null, profile, skill);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill);
|
||||
}
|
||||
|
||||
@@ -156,8 +153,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
|
||||
if (skill == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", mcMMO.p.getSkillTools().getLocalizedSkillName(skill), playerName));
|
||||
}
|
||||
}
|
||||
@@ -171,8 +167,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
if (player != null) {
|
||||
handlePlayerMessageAll(player);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
handleCommand(player, profile, skill);
|
||||
|
||||
if (player != null) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -31,11 +31,11 @@ public class PartyAcceptCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
// Changing parties
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
|
||||
if (!mcMMO.p.getPartyManager().changeOrJoinParty(mcMMOPlayer, mcMMOPlayer.getPartyInvite().getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.joinInvitedParty(mcMMOPlayer);
|
||||
mcMMO.p.getPartyManager().joinInvitedParty(mcMMOPlayer);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "accept"));
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.party;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -31,7 +30,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.setPartyLeader(target.getUniqueId(), playerParty);
|
||||
mcMMO.p.getPartyManager().setPartyLeader(target.getUniqueId(), playerParty);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
|
||||
@@ -12,8 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class PartyChangePasswordCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,11 +23,45 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PartyCommand implements TabExecutor {
|
||||
private static final List<String> PARTY_SUBCOMMANDS;
|
||||
private static final List<String> XPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
|
||||
private static final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
|
||||
private final List<String> PARTY_SUBCOMMANDS;
|
||||
private final List<String> XPSHARE_COMPLETIONS = ImmutableList.of("none", "equal");
|
||||
private final List<String> ITEMSHARE_COMPLETIONS = ImmutableList.of("none", "equal", "random", "loot", "mining", "herbalism", "woodcutting", "misc");
|
||||
private final CommandExecutor partyJoinCommand;
|
||||
private final CommandExecutor partyAcceptCommand;
|
||||
private final CommandExecutor partyCreateCommand;
|
||||
private final CommandExecutor partyQuitCommand;
|
||||
private final CommandExecutor partyXpShareCommand;
|
||||
private final CommandExecutor partyItemShareCommand;
|
||||
private final CommandExecutor partyInviteCommand;
|
||||
private final CommandExecutor partyKickCommand;
|
||||
private final CommandExecutor partyDisbandCommand;
|
||||
private final CommandExecutor partyChangeOwnerCommand;
|
||||
private final CommandExecutor partyLockCommand;
|
||||
private final CommandExecutor partyChangePasswordCommand;
|
||||
private final CommandExecutor partyRenameCommand;
|
||||
private final CommandExecutor partyInfoCommand;
|
||||
private final CommandExecutor partyHelpCommand;
|
||||
private final CommandExecutor partyTeleportCommand;
|
||||
private final CommandExecutor partyAllianceCommand;
|
||||
public PartyCommand() {
|
||||
partyJoinCommand = new PartyJoinCommand();
|
||||
partyAcceptCommand = new PartyAcceptCommand();
|
||||
partyCreateCommand = new PartyCreateCommand();
|
||||
partyQuitCommand = new PartyQuitCommand();
|
||||
partyXpShareCommand = new PartyXpShareCommand();
|
||||
partyItemShareCommand = new PartyItemShareCommand();
|
||||
partyInviteCommand = new PartyInviteCommand();
|
||||
partyKickCommand = new PartyKickCommand();
|
||||
partyDisbandCommand = new PartyDisbandCommand();
|
||||
partyChangeOwnerCommand = new PartyChangeOwnerCommand();
|
||||
partyLockCommand = new PartyLockCommand();
|
||||
partyChangePasswordCommand = new PartyChangePasswordCommand();
|
||||
partyRenameCommand = new PartyRenameCommand();
|
||||
partyInfoCommand = new PartyInfoCommand();
|
||||
partyHelpCommand = new PartyHelpCommand();
|
||||
partyTeleportCommand = new PtpCommand();
|
||||
partyAllianceCommand = new PartyAllianceCommand();
|
||||
|
||||
static {
|
||||
ArrayList<String> subcommands = new ArrayList<>();
|
||||
|
||||
for (PartySubcommandType subcommand : PartySubcommandType.values()) {
|
||||
@@ -38,24 +72,6 @@ public class PartyCommand implements TabExecutor {
|
||||
PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands);
|
||||
}
|
||||
|
||||
private final CommandExecutor partyJoinCommand = new PartyJoinCommand();
|
||||
private final CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
|
||||
private final CommandExecutor partyCreateCommand = new PartyCreateCommand();
|
||||
private final CommandExecutor partyQuitCommand = new PartyQuitCommand();
|
||||
private final CommandExecutor partyXpShareCommand = new PartyXpShareCommand();
|
||||
private final CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
|
||||
private final CommandExecutor partyInviteCommand = new PartyInviteCommand();
|
||||
private final CommandExecutor partyKickCommand = new PartyKickCommand();
|
||||
private final CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
|
||||
private final CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
|
||||
private final CommandExecutor partyLockCommand = new PartyLockCommand();
|
||||
private final CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand();
|
||||
private final CommandExecutor partyRenameCommand = new PartyRenameCommand();
|
||||
private final CommandExecutor partyInfoCommand = new PartyInfoCommand();
|
||||
private final CommandExecutor partyHelpCommand = new PartyHelpCommand();
|
||||
private final CommandExecutor partyTeleportCommand = new PtpCommand();
|
||||
private final CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
@@ -73,13 +89,12 @@ public class PartyCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
{
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
if (mcMMOPlayer == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (args.length < 1) {
|
||||
if (!mcMMOPlayer.inParty()) {
|
||||
@@ -140,31 +155,18 @@ public class PartyCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (subcommand) {
|
||||
case XPSHARE:
|
||||
return partyXpShareCommand.onCommand(sender, command, label, args);
|
||||
case ITEMSHARE:
|
||||
return partyItemShareCommand.onCommand(sender, command, label, args);
|
||||
case KICK:
|
||||
return partyKickCommand.onCommand(sender, command, label, args);
|
||||
case DISBAND:
|
||||
return partyDisbandCommand.onCommand(sender, command, label, args);
|
||||
case OWNER:
|
||||
return partyChangeOwnerCommand.onCommand(sender, command, label, args);
|
||||
case LOCK:
|
||||
case UNLOCK:
|
||||
return partyLockCommand.onCommand(sender, command, label, args);
|
||||
case PASSWORD:
|
||||
return partyChangePasswordCommand.onCommand(sender, command, label, args);
|
||||
case RENAME:
|
||||
return partyRenameCommand.onCommand(sender, command, label, args);
|
||||
case ALLIANCE:
|
||||
return partyAllianceCommand.onCommand(sender, command, label, args);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
return switch (subcommand) {
|
||||
case XPSHARE -> partyXpShareCommand.onCommand(sender, command, label, args);
|
||||
case ITEMSHARE -> partyItemShareCommand.onCommand(sender, command, label, args);
|
||||
case KICK -> partyKickCommand.onCommand(sender, command, label, args);
|
||||
case DISBAND -> partyDisbandCommand.onCommand(sender, command, label, args);
|
||||
case OWNER -> partyChangeOwnerCommand.onCommand(sender, command, label, args);
|
||||
case LOCK, UNLOCK -> partyLockCommand.onCommand(sender, command, label, args);
|
||||
case PASSWORD -> partyChangePasswordCommand.onCommand(sender, command, label, args);
|
||||
case RENAME -> partyRenameCommand.onCommand(sender, command, label, args);
|
||||
case ALLIANCE -> partyAllianceCommand.onCommand(sender, command, label, args);
|
||||
default -> true;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,12 +181,13 @@ public class PartyCommand implements TabExecutor {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
|
||||
switch (subcommand) {
|
||||
case JOIN:
|
||||
case INVITE:
|
||||
case KICK:
|
||||
case OWNER:
|
||||
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
|
||||
return StringUtil.copyPartialMatches(args[1], playerNames, new ArrayList<>(playerNames.size()));
|
||||
case XPSHARE:
|
||||
return StringUtil.copyPartialMatches(args[1], XPSHARE_COMPLETIONS, new ArrayList<>(XPSHARE_COMPLETIONS.size()));
|
||||
@@ -198,13 +201,12 @@ public class PartyCommand implements TabExecutor {
|
||||
case TELEPORT:
|
||||
List<String> matches = StringUtil.copyPartialMatches(args[1], PtpCommand.TELEPORT_SUBCOMMANDS, new ArrayList<>(PtpCommand.TELEPORT_SUBCOMMANDS.size()));
|
||||
|
||||
if (matches.size() == 0) {
|
||||
if (matches.isEmpty()) {
|
||||
Player player = (Player) sender;
|
||||
final McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Not Loaded
|
||||
if(mcMMOPlayer == null)
|
||||
{
|
||||
if (mcMMOPlayer == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.party;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -19,23 +19,22 @@ public class PartyCreateCommand implements CommandExecutor {
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
{
|
||||
if (UserManager.getPlayer(player) == null) {
|
||||
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check to see if the party exists, and if it does cancel creating a new party
|
||||
if (PartyManager.checkPartyExistence(player, args[1])) {
|
||||
if (mcMMO.p.getPartyManager().checkPartyExistence(player, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Changing parties
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, args[1])) {
|
||||
if (!mcMMO.p.getPartyManager().changeOrJoinParty(mcMMOPlayer, args[1])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.createParty(mcMMOPlayer, args[1], getPassword(args));
|
||||
mcMMO.p.getPartyManager().createParty(mcMMOPlayer, args[1], getPassword(args));
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -26,14 +26,14 @@ public class PartyDisbandCommand implements CommandExecutor {
|
||||
final String partyName = playerParty.getName();
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
if (!PartyManager.handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
if (!mcMMO.p.getPartyManager().handlePartyChangeEvent(member, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
member.sendMessage(LocaleLoader.getString("Party.Disband"));
|
||||
}
|
||||
|
||||
PartyManager.disbandParty(mcMMOPlayer, playerParty);
|
||||
mcMMO.p.getPartyManager().disbandParty(mcMMOPlayer, playerParty);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband"));
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.party.ShareMode;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -24,8 +23,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
case 1:
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
@@ -71,8 +69,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
||||
|
||||
if (isUnlockedFeature(party, partyFeature)) {
|
||||
unlockedPartyFeatures.add(partyFeature.getLocaleString());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
lockedPartyFeatures.add(partyFeature.getFeatureLockedLocaleString());
|
||||
}
|
||||
}
|
||||
@@ -125,7 +122,7 @@ public class PartyInfoCommand implements CommandExecutor {
|
||||
* Only show members of the party that this member can see
|
||||
*/
|
||||
|
||||
List<Player> nearMembers = PartyManager.getNearVisibleMembers(mcMMOPlayer);
|
||||
List<Player> nearMembers = mcMMO.p.getPartyManager().getNearVisibleMembers(mcMMOPlayer);
|
||||
int membersOnline = party.getVisibleMembers(player).size();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
|
||||
|
||||
@@ -4,7 +4,6 @@ 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.party.PartyManager;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -40,19 +39,19 @@ public class PartyInviteCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartyManager.inSameParty(player, target)) {
|
||||
if (mcMMO.p.getPartyManager().inSameParty(player, target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!PartyManager.canInvite(mcMMOPlayer)) {
|
||||
if (!mcMMO.p.getPartyManager().canInvite(mcMMOPlayer)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Locked"));
|
||||
return true;
|
||||
}
|
||||
|
||||
Party playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
if (PartyManager.isPartyFull(target, playerParty)) {
|
||||
if (mcMMO.p.getPartyManager().isPartyFull(target, playerParty)) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), mcMMO.p.getGeneralConfig().getPartyMaxSize()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,7 @@ import java.util.Locale;
|
||||
public class PartyItemShareCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
@@ -50,11 +49,9 @@ public class PartyItemShareCommand implements CommandExecutor {
|
||||
|
||||
if (CommandUtils.shouldEnableToggle(args[2])) {
|
||||
toggle = true;
|
||||
}
|
||||
else if (CommandUtils.shouldDisableToggle(args[2])) {
|
||||
} else if (CommandUtils.shouldDisableToggle(args[2])) {
|
||||
toggle = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.gmail.nossr50.commands.party;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -34,8 +34,7 @@ public class PartyJoinCommand implements CommandExecutor {
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
@@ -51,25 +50,24 @@ public class PartyJoinCommand implements CommandExecutor {
|
||||
String password = getPassword(args);
|
||||
|
||||
// Make sure party passwords match
|
||||
if (!PartyManager.checkPartyPassword(player, targetParty, password)) {
|
||||
if (!mcMMO.p.getPartyManager().checkPartyPassword(player, targetParty, password)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String partyName = targetParty.getName();
|
||||
|
||||
// Changing parties
|
||||
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, partyName)) {
|
||||
if (!mcMMO.p.getPartyManager().changeOrJoinParty(mcMMOPlayer, partyName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(PartyManager.isPartyFull(player, targetParty))
|
||||
{
|
||||
if (mcMMO.p.getPartyManager().isPartyFull(player, targetParty)) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
|
||||
return true;
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
|
||||
PartyManager.addToParty(mcMMOPlayer, targetParty);
|
||||
mcMMO.p.getPartyManager().addToParty(mcMMOPlayer, targetParty);
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -37,15 +36,15 @@ public class PartyKickCommand implements CommandExecutor {
|
||||
Player onlineTarget = target.getPlayer();
|
||||
String partyName = playerParty.getName();
|
||||
|
||||
if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
if (!mcMMO.p.getPartyManager().handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget));
|
||||
mcMMO.p.getPartyManager().processPartyLeaving(UserManager.getPlayer(onlineTarget));
|
||||
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(target, playerParty);
|
||||
mcMMO.p.getPartyManager().removeFromParty(target, playerParty);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
|
||||
@@ -18,8 +18,7 @@ public class PartyLockCommand implements CommandExecutor {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("lock")) {
|
||||
togglePartyLock(sender, true);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("unlock")) {
|
||||
} else if (args[0].equalsIgnoreCase("unlock")) {
|
||||
togglePartyLock(sender, false);
|
||||
}
|
||||
|
||||
@@ -33,11 +32,9 @@ public class PartyLockCommand implements CommandExecutor {
|
||||
|
||||
if (CommandUtils.shouldEnableToggle(args[1])) {
|
||||
togglePartyLock(sender, true);
|
||||
}
|
||||
else if (CommandUtils.shouldDisableToggle(args[1])) {
|
||||
} else if (CommandUtils.shouldDisableToggle(args[1])) {
|
||||
togglePartyLock(sender, false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sendUsageStrings(sender);
|
||||
}
|
||||
|
||||
@@ -55,8 +52,7 @@ public class PartyLockCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private void togglePartyLock(CommandSender sender, boolean lock) {
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -26,11 +26,11 @@ public class PartyQuitCommand implements CommandExecutor {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
Party playerParty = mcMMOPlayer.getParty();
|
||||
|
||||
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
|
||||
if (!mcMMO.p.getPartyManager().handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.removeFromParty(mcMMOPlayer);
|
||||
mcMMO.p.getPartyManager().removeFromParty(mcMMOPlayer);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -36,14 +36,14 @@ public class PartyRenameCommand implements CommandExecutor {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
// Check to see if the party exists, and if it does cancel renaming the party
|
||||
if (PartyManager.checkPartyExistence(player, newPartyName)) {
|
||||
if (mcMMO.p.getPartyManager().checkPartyExistence(player, newPartyName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String leaderName = playerParty.getLeader().getPlayerName();
|
||||
|
||||
for (Player member : playerParty.getOnlineMembers()) {
|
||||
if (!PartyManager.handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
|
||||
if (!mcMMO.p.getPartyManager().handlePartyChangeEvent(member, oldPartyName, newPartyName, EventReason.CHANGED_PARTIES)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,20 +30,15 @@ public enum PartySubcommandType {
|
||||
|
||||
if (commandName.equalsIgnoreCase("?")) {
|
||||
return HELP;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
|
||||
} else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
|
||||
return QUIT;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("leader")) {
|
||||
} else if (commandName.equalsIgnoreCase("leader")) {
|
||||
return OWNER;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
|
||||
} else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
|
||||
return XPSHARE;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
|
||||
} else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
|
||||
return ITEMSHARE;
|
||||
}
|
||||
else if (commandName.equalsIgnoreCase("ally")) {
|
||||
} else if (commandName.equalsIgnoreCase("ally")) {
|
||||
return ALLIANCE;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class PartyXpShareCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gmail.nossr50.commands.party.alliance;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -31,7 +31,7 @@ public class PartyAllianceAcceptCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.acceptAllianceInvite(mcMMOPlayer);
|
||||
mcMMO.p.getPartyManager().acceptAllianceInvite(mcMMOPlayer);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "accept"));
|
||||
|
||||
@@ -5,7 +5,6 @@ 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.party.PartyManager;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -38,8 +37,7 @@ public class PartyAllianceCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
@@ -129,7 +127,7 @@ public class PartyAllianceCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
private void displayMemberInfo(McMMOPlayer mcMMOPlayer) {
|
||||
List<Player> nearMembers = PartyManager.getNearMembers(mcMMOPlayer);
|
||||
List<Player> nearMembers = mcMMO.p.getPartyManager().getNearMembers(mcMMOPlayer);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Party.Alliance.Members.Header"));
|
||||
player.sendMessage(playerParty.createMembersList(player));
|
||||
player.sendMessage(ChatColor.DARK_GRAY + "----------------------------");
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.gmail.nossr50.commands.party.alliance;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -28,7 +28,7 @@ public class PartyAllianceDisbandCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PartyManager.disbandAlliance(player, party, party.getAlly());
|
||||
mcMMO.p.getPartyManager().disbandAlliance(player, party, party.getAlly());
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "alliance", "disband"));
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.gmail.nossr50.commands.party.alliance;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -44,7 +44,7 @@ public class PartyAllianceInviteCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartyManager.inSameParty(player, target)) {
|
||||
if (mcMMO.p.getPartyManager().inSameParty(player, target)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,7 @@ public class PtpAcceptAnyCommand implements CommandExecutor {
|
||||
|
||||
if (ptpRecord.isConfirmRequired()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled"));
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ public class PtpAcceptCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
@@ -56,8 +55,7 @@ public class PtpAcceptCommand implements CommandExecutor {
|
||||
if (!Permissions.partyTeleportWorld(target, targetWorld)) {
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
|
||||
return true;
|
||||
}
|
||||
else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) {
|
||||
} else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) {
|
||||
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", playerWorld.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@@ -46,22 +45,20 @@ public class PtpCommand implements TabExecutor {
|
||||
Player player = (Player) sender;
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
{
|
||||
if(!WorldGuardManager.getInstance().hasMainFlag(player))
|
||||
if (WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if (!WorldGuardManager.getInstance().hasMainFlag(player))
|
||||
return true;
|
||||
}
|
||||
|
||||
/* WORLD BLACKLIST CHECK */
|
||||
if(WorldBlacklist.isWorldBlacklisted(player.getWorld()))
|
||||
if (WorldBlacklist.isWorldBlacklisted(player.getWorld()))
|
||||
return true;
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(UserManager.getPlayer((Player) sender) == null)
|
||||
{
|
||||
if (UserManager.getPlayer((Player) sender) == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
@@ -172,8 +169,7 @@ public class PtpCommand implements TabExecutor {
|
||||
if (!Permissions.partyTeleportWorld(target, targetWorld)) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
|
||||
return;
|
||||
}
|
||||
else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(player, targetWorld)) {
|
||||
} else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(player, targetWorld)) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
|
||||
return;
|
||||
}
|
||||
@@ -210,7 +206,7 @@ public class PtpCommand implements TabExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PartyManager.inSameParty(player, target)) {
|
||||
if (!mcMMO.p.getPartyManager().inSameParty(player, target)) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
||||
return false;
|
||||
}
|
||||
@@ -229,14 +225,12 @@ public class PtpCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
|
||||
if(UserManager.getPlayer(targetPlayer) == null)
|
||||
{
|
||||
if (UserManager.getPlayer(targetPlayer) == null) {
|
||||
targetPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(UserManager.getPlayer(teleportingPlayer) == null)
|
||||
{
|
||||
if (UserManager.getPlayer(teleportingPlayer) == null) {
|
||||
teleportingPlayer.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return;
|
||||
}
|
||||
@@ -251,8 +245,7 @@ public class PtpCommand implements TabExecutor {
|
||||
if (warmup > 0) {
|
||||
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
|
||||
mcMMO.p.getFoliaLib().getImpl().runAtEntityLater(teleportingPlayer, new TeleportationWarmup(mcMMOPlayer, mcMMOTarget), 20 * warmup);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,7 @@ public class PtpToggleCommand implements CommandExecutor {
|
||||
|
||||
if (ptpRecord.isEnabled()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled"));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.gmail.nossr50.commands.player;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
|
||||
import com.gmail.nossr50.runnables.commands.McRankCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class McrankCommand implements TabExecutor {
|
||||
public class McRankCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
switch (args.length) {
|
||||
@@ -85,8 +85,7 @@ public class McrankCommand implements TabExecutor {
|
||||
if (sender instanceof Player) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
|
||||
if(mcMMOPlayer == null)
|
||||
{
|
||||
if (mcMMOPlayer == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return;
|
||||
}
|
||||
@@ -111,7 +110,7 @@ public class McrankCommand implements TabExecutor {
|
||||
boolean useBoard = mcMMO.p.getGeneralConfig().getScoreboardsEnabled() && (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getRankUseBoard());
|
||||
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getRankUseChat();
|
||||
|
||||
mcMMO.p.getFoliaLib().getImpl().runAsync(new McrankCommandAsyncTask(playerName, sender, useBoard, useChat));
|
||||
mcMMO.p.getFoliaLib().getImpl().runAsync(new McRankCommandAsyncTask(playerName, sender, useBoard, useChat));
|
||||
}
|
||||
|
||||
private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) {
|
||||
@@ -4,7 +4,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
|
||||
import com.gmail.nossr50.runnables.commands.McTopCommandAsyncTask;
|
||||
import com.gmail.nossr50.util.MetadataConstants;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MctopCommand implements TabExecutor {
|
||||
public class McTopCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
PrimarySkillType skill = null;
|
||||
@@ -44,6 +44,12 @@ public class MctopCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the command is for Maces but the MC version is not correct
|
||||
if (skill == PrimarySkillType.MACES
|
||||
&& !mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 21, 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
display(1, skill, sender, command);
|
||||
return true;
|
||||
|
||||
@@ -58,6 +64,12 @@ public class MctopCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the command is for Maces but the MC version is not correct
|
||||
if (skill == PrimarySkillType.MACES
|
||||
&& !mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 21, 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
display(Math.abs(Integer.parseInt(args[1])), skill, sender, command);
|
||||
return true;
|
||||
|
||||
@@ -115,7 +127,7 @@ public class MctopCommand implements TabExecutor {
|
||||
boolean useBoard = (sender instanceof Player) && (mcMMO.p.getGeneralConfig().getTopUseBoard());
|
||||
boolean useChat = !useBoard || mcMMO.p.getGeneralConfig().getTopUseChat();
|
||||
|
||||
mcMMO.p.getFoliaLib().getImpl().runAsync(new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat));
|
||||
mcMMO.p.getFoliaLib().getImpl().runAsync(new McTopCommandAsyncTask(page, skill, sender, useBoard, useChat));
|
||||
}
|
||||
|
||||
private PrimarySkillType extractSkill(CommandSender sender, String skillName) {
|
||||
@@ -24,22 +24,22 @@ public class XPBarCommand implements TabExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
if (sender instanceof Player) {
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer((Player) sender);
|
||||
if(mmoPlayer == null) {
|
||||
if (mmoPlayer == null) {
|
||||
NotificationManager.sendPlayerInformationChatOnlyPrefixed(mmoPlayer.getPlayer(), "Profile.PendingLoad");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args.length == 0) {
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
} else if(args.length < 2) {
|
||||
} else if (args.length < 2) {
|
||||
String option = args[0];
|
||||
|
||||
if(option.equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.RESET.toString())) {
|
||||
if (option.equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.RESET.toString())) {
|
||||
mmoPlayer.getExperienceBarManager().xpBarSettingToggle(ExperienceBarManager.XPBarSettingTarget.RESET, null);
|
||||
return true;
|
||||
} else if(option.equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.DISABLE.toString())) {
|
||||
} else if (option.equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.DISABLE.toString())) {
|
||||
mmoPlayer.getExperienceBarManager().disableAllBars();
|
||||
return true;
|
||||
} else {
|
||||
@@ -50,7 +50,7 @@ public class XPBarCommand implements TabExecutor {
|
||||
} else if (args.length == 2) {
|
||||
String skillName = args[1];
|
||||
|
||||
if(SkillUtils.isSkill(skillName)) {
|
||||
if (SkillUtils.isSkill(skillName)) {
|
||||
|
||||
PrimarySkillType targetSkill = mcMMO.p.getSkillTools().matchSkill(skillName);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class XPBarCommand implements TabExecutor {
|
||||
String option = args[0].toLowerCase();
|
||||
|
||||
ExperienceBarManager.XPBarSettingTarget settingTarget = getSettingTarget(option);
|
||||
if(settingTarget != null && settingTarget != ExperienceBarManager.XPBarSettingTarget.RESET) {
|
||||
if (settingTarget != null && settingTarget != ExperienceBarManager.XPBarSettingTarget.RESET) {
|
||||
//Change setting
|
||||
mmoPlayer.getExperienceBarManager().xpBarSettingToggle(settingTarget, targetSkill);
|
||||
return true;
|
||||
@@ -103,7 +103,7 @@ public class XPBarCommand implements TabExecutor {
|
||||
|
||||
return StringUtil.copyPartialMatches(args[0], options, new ArrayList<>(ExperienceBarManager.XPBarSettingTarget.values().length));
|
||||
case 2:
|
||||
if(!args[0].equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.RESET.toString()))
|
||||
if (!args[0].equalsIgnoreCase(ExperienceBarManager.XPBarSettingTarget.RESET.toString()))
|
||||
return StringUtil.copyPartialMatches(args[1], mcMMO.p.getSkillTools().LOCALIZED_SKILL_NAMES, new ArrayList<>(mcMMO.p.getSkillTools().LOCALIZED_SKILL_NAMES.size()));
|
||||
default:
|
||||
return ImmutableList.of();
|
||||
|
||||
@@ -5,9 +5,8 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||
import com.gmail.nossr50.listeners.InteractionManager;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.random.RandomChanceSkill;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.random.ProbabilityUtil;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -30,7 +29,7 @@ public class AcrobaticsCommand extends SkillCommand {
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
// ACROBATICS_DODGE
|
||||
if (canDodge) {
|
||||
String[] dodgeStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_DODGE);
|
||||
final String[] dodgeStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.ACROBATICS_DODGE);
|
||||
dodgeChance = dodgeStrings[0];
|
||||
dodgeChanceLucky = dodgeStrings[1];
|
||||
}
|
||||
@@ -38,8 +37,8 @@ public class AcrobaticsCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canDodge = canUseSubskill(player, SubSkillType.ACROBATICS_DODGE);
|
||||
canRoll = canUseSubskill(player, SubSkillType.ACROBATICS_ROLL);
|
||||
canDodge = Permissions.canUseSubSkill(player, SubSkillType.ACROBATICS_DODGE);
|
||||
canRoll = Permissions.canUseSubSkill(player, SubSkillType.ACROBATICS_ROLL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,27 +54,8 @@ public class AcrobaticsCommand extends SkillCommand {
|
||||
|
||||
AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName("Roll");
|
||||
|
||||
if(abstractSubSkill != null)
|
||||
{
|
||||
double rollChance, graceChance;
|
||||
|
||||
//Chance to roll at half
|
||||
RandomChanceSkill roll_rcs = new RandomChanceSkill(player, SubSkillType.ACROBATICS_ROLL);
|
||||
|
||||
//Chance to graceful roll
|
||||
RandomChanceSkill grace_rcs = new RandomChanceSkill(player, SubSkillType.ACROBATICS_ROLL);
|
||||
grace_rcs.setSkillLevel(grace_rcs.getSkillLevel() * 2); //Double Odds
|
||||
|
||||
//Chance Stat Calculations
|
||||
rollChance = RandomChanceUtil.getRandomChanceExecutionChance(roll_rcs);
|
||||
graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs);
|
||||
//damageThreshold = mcMMO.p.getAdvancedConfig().getRollDamageThreshold();
|
||||
|
||||
String[] rollStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL);
|
||||
|
||||
//Format
|
||||
double rollChanceLucky = rollChance * 1.333D;
|
||||
double graceChanceLucky = graceChance * 1.333D;
|
||||
if (abstractSubSkill != null) {
|
||||
String[] rollStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.ACROBATICS_ROLL);
|
||||
|
||||
messages.add(getStatMessage(SubSkillType.ACROBATICS_ROLL, rollStrings[0])
|
||||
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollStrings[1]) : ""));
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -30,14 +29,7 @@ public class AlchemyCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
protected String[] calculateAbilityDisplayValues(Player player) {
|
||||
//TODO: Needed?
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
{
|
||||
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return new String[] {"DATA NOT LOADED", "DATA NOT LOADED"};
|
||||
}
|
||||
|
||||
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
|
||||
AlchemyManager alchemyManager = mmoPlayer.getAlchemyManager();
|
||||
String[] displayValues = new String[2];
|
||||
|
||||
boolean isLucky = Permissions.lucky(player, PrimarySkillType.ALCHEMY);
|
||||
@@ -59,7 +51,7 @@ public class AlchemyCommand extends SkillCommand {
|
||||
|
||||
// ALCHEMY_CONCOCTIONS
|
||||
if (canConcoctions) {
|
||||
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
|
||||
AlchemyManager alchemyManager = mmoPlayer.getAlchemyManager();
|
||||
tier = alchemyManager.getTier();
|
||||
ingredientCount = alchemyManager.getIngredients().size();
|
||||
ingredientList = alchemyManager.getIngredientList();
|
||||
@@ -68,8 +60,8 @@ public class AlchemyCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canCatalysis = canUseSubskill(player, SubSkillType.ALCHEMY_CATALYSIS);
|
||||
canConcoctions = canUseSubskill(player, SubSkillType.ALCHEMY_CONCOCTIONS);
|
||||
canCatalysis = Permissions.canUseSubSkill(player, SubSkillType.ALCHEMY_CATALYSIS);
|
||||
canConcoctions = Permissions.canUseSubSkill(player, SubSkillType.ALCHEMY_CONCOCTIONS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,8 +4,9 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.archery.Archery;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.random.ProbabilityUtil;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -32,14 +33,14 @@ public class ArcheryCommand extends SkillCommand {
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
// ARCHERY_ARROW_RETRIEVAL
|
||||
if (canRetrieve) {
|
||||
String[] retrieveStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
|
||||
String[] retrieveStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
|
||||
retrieveChance = retrieveStrings[0];
|
||||
retrieveChanceLucky = retrieveStrings[1];
|
||||
}
|
||||
|
||||
// ARCHERY_DAZE
|
||||
if (canDaze) {
|
||||
String[] dazeStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ARCHERY_DAZE);
|
||||
String[] dazeStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.ARCHERY_DAZE);
|
||||
dazeChance = dazeStrings[0];
|
||||
dazeChanceLucky = dazeStrings[1];
|
||||
}
|
||||
@@ -52,9 +53,9 @@ public class ArcheryCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canSkillShot = canUseSubskill(player, SubSkillType.ARCHERY_SKILL_SHOT);
|
||||
canDaze = canUseSubskill(player, SubSkillType.ARCHERY_DAZE);
|
||||
canRetrieve = canUseSubskill(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
|
||||
canSkillShot = Permissions.canUseSubSkill(player, SubSkillType.ARCHERY_SKILL_SHOT);
|
||||
canDaze = Permissions.canUseSubSkill(player, SubSkillType.ARCHERY_DAZE);
|
||||
canRetrieve = Permissions.canUseSubSkill(player, SubSkillType.ARCHERY_ARROW_RETRIEVAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,7 +76,7 @@ public class ArcheryCommand extends SkillCommand {
|
||||
messages.add(getStatMessage(SubSkillType.ARCHERY_SKILL_SHOT, skillShotBonus));
|
||||
}
|
||||
|
||||
if(canUseSubskill(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) {
|
||||
if (Permissions.canUseSubSkill(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) {
|
||||
messages.add(getStatMessage(SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK,
|
||||
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK, 1000))));
|
||||
}
|
||||
|
||||
@@ -5,10 +5,9 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.axes.Axes;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.ProbabilityUtil;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -38,7 +37,7 @@ public class AxesCommand extends SkillCommand {
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
// ARMOR IMPACT
|
||||
if (canImpact) {
|
||||
impactDamage = UserManager.getPlayer(player).getAxesManager().getImpactDurabilityDamage();
|
||||
impactDamage = mmoPlayer.getAxesManager().getImpactDurabilityDamage();
|
||||
}
|
||||
|
||||
// AXE MASTERY
|
||||
@@ -48,7 +47,7 @@ public class AxesCommand extends SkillCommand {
|
||||
|
||||
// CRITICAL HIT
|
||||
if (canCritical) {
|
||||
String[] criticalHitStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.AXES_CRITICAL_STRIKES);
|
||||
String[] criticalHitStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.AXES_CRITICAL_STRIKES);
|
||||
critChance = criticalHitStrings[0];
|
||||
critChanceLucky = criticalHitStrings[1];
|
||||
}
|
||||
@@ -64,10 +63,10 @@ public class AxesCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canSkullSplitter = Permissions.skullSplitter(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.AXES_SKULL_SPLITTER);
|
||||
canCritical = canUseSubskill(player, SubSkillType.AXES_CRITICAL_STRIKES);
|
||||
canAxeMastery = canUseSubskill(player, SubSkillType.AXES_AXE_MASTERY);
|
||||
canImpact = canUseSubskill(player, SubSkillType.AXES_ARMOR_IMPACT);
|
||||
canGreaterImpact = canUseSubskill(player, SubSkillType.AXES_GREATER_IMPACT);
|
||||
canCritical = Permissions.canUseSubSkill(player, SubSkillType.AXES_CRITICAL_STRIKES);
|
||||
canAxeMastery = Permissions.canUseSubSkill(player, SubSkillType.AXES_AXE_MASTERY);
|
||||
canImpact = Permissions.canUseSubSkill(player, SubSkillType.AXES_ARMOR_IMPACT);
|
||||
canGreaterImpact = Permissions.canUseSubSkill(player, SubSkillType.AXES_GREATER_IMPACT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,7 +95,7 @@ public class AxesCommand extends SkillCommand {
|
||||
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : ""));
|
||||
}
|
||||
|
||||
if(canUseSubskill(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) {
|
||||
if (Permissions.canUseSubSkill(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) {
|
||||
messages.add(getStatMessage(SubSkillType.AXES_AXES_LIMIT_BREAK,
|
||||
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.AXES_AXES_LIMIT_BREAK, 1000))));
|
||||
}
|
||||
@@ -106,7 +105,7 @@ public class AxesCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected List<Component> getTextComponents(Player player) {
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
final List<Component> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.AXES);
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.gmail.nossr50.datatypes.skills.SubSkillType.*;
|
||||
|
||||
public class CrossbowsCommand extends SkillCommand {
|
||||
private boolean canTrickShot;
|
||||
private boolean canPoweredShot;
|
||||
|
||||
public CrossbowsCommand() {
|
||||
super(PrimarySkillType.CROSSBOWS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
// TODO: Implement data calculations
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canTrickShot = RankUtils.hasUnlockedSubskill(player, CROSSBOWS_TRICK_SHOT)
|
||||
&& Permissions.trickShot(player);
|
||||
|
||||
canPoweredShot = RankUtils.hasUnlockedSubskill(player, CROSSBOWS_POWERED_SHOT)
|
||||
&& Permissions.poweredShot(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||
List<String> messages = new ArrayList<>();
|
||||
|
||||
if (mmoPlayer == null) {
|
||||
return messages;
|
||||
}
|
||||
|
||||
if (canPoweredShot) {
|
||||
messages.add(getStatMessage(CROSSBOWS_POWERED_SHOT,
|
||||
percent.format(mmoPlayer.getCrossbowsManager().getDamageBonusPercent(player))));
|
||||
}
|
||||
|
||||
if (canTrickShot) {
|
||||
messages.add(getStatMessage(CROSSBOWS_TRICK_SHOT,
|
||||
String.valueOf(mmoPlayer.getCrossbowsManager().getTrickShotMaxBounceCount())));
|
||||
}
|
||||
|
||||
if (Permissions.canUseSubSkill(player, CROSSBOWS_CROSSBOWS_LIMIT_BREAK)) {
|
||||
messages.add(getStatMessage(CROSSBOWS_CROSSBOWS_LIMIT_BREAK,
|
||||
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, CROSSBOWS_CROSSBOWS_LIMIT_BREAK, 1000))));
|
||||
}
|
||||
|
||||
messages.add(ChatColor.GRAY + "The Crossbows skill is a work in progress and is still being developed, feedback would be appreciated in the mcMMO discord server.");
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Component> getTextComponents(Player player) {
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.CROSSBOWS);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.excavation.ExcavationManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -38,14 +37,14 @@ public class ExcavationCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canGigaDrill = Permissions.gigaDrillBreaker(player) && RankUtils.hasUnlockedSubskill(player, SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER);
|
||||
canTreasureHunt = canUseSubskill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY);
|
||||
canTreasureHunt = Permissions.canUseSubSkill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||
List<String> messages = new ArrayList<>();
|
||||
|
||||
ExcavationManager excavationManager = UserManager.getPlayer(player).getExcavationManager();
|
||||
ExcavationManager excavationManager = mmoPlayer.getExcavationManager();
|
||||
|
||||
if (canGigaDrill) {
|
||||
messages.add(getStatMessage(SubSkillType.EXCAVATION_GIGA_DRILL_BREAKER, gigaDrillBreakerLength)
|
||||
@@ -54,7 +53,7 @@ public class ExcavationCommand extends SkillCommand {
|
||||
//messages.add(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
|
||||
}
|
||||
|
||||
if(canUseSubskill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
|
||||
if (Permissions.canUseSubSkill(player, SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
|
||||
messages.add(getStatMessage(false, false, SubSkillType.EXCAVATION_ARCHAEOLOGY,
|
||||
percent.format(excavationManager.getArchaelogyExperienceOrbChance() / 100.0D)));
|
||||
messages.add(getStatMessage(true, false, SubSkillType.EXCAVATION_ARCHAEOLOGY,
|
||||
|
||||
@@ -7,8 +7,9 @@ import com.gmail.nossr50.datatypes.treasure.Rarity;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.random.Probability;
|
||||
import com.gmail.nossr50.util.random.ProbabilityUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
@@ -48,7 +49,7 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
FishingManager fishingManager = UserManager.getPlayer(player).getFishingManager();
|
||||
FishingManager fishingManager = mmoPlayer.getFishingManager();
|
||||
|
||||
// TREASURE HUNTER
|
||||
if (canTreasureHunt) {
|
||||
@@ -71,7 +72,7 @@ public class FishingCommand extends SkillCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if(totalEnchantChance >= 1)
|
||||
if (totalEnchantChance >= 1)
|
||||
magicChance = percent.format(totalEnchantChance / 100.0);
|
||||
else
|
||||
magicChance = percent.format(0);
|
||||
@@ -79,7 +80,8 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
// FISHING_SHAKE
|
||||
if (canShake) {
|
||||
String[] shakeStrings = RandomChanceUtil.calculateAbilityDisplayValuesStatic(player, PrimarySkillType.FISHING, fishingManager.getShakeChance());
|
||||
Probability shakeProbability = Probability.ofPercent(fishingManager.getShakeChance());
|
||||
String[] shakeStrings = ProbabilityUtil.getRNGDisplayValues(shakeProbability);
|
||||
shakeChance = shakeStrings[0];
|
||||
shakeChanceLucky = shakeStrings[1];
|
||||
}
|
||||
@@ -98,12 +100,12 @@ public class FishingCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canTreasureHunt = canUseSubskill(player, SubSkillType.FISHING_TREASURE_HUNTER);
|
||||
canMagicHunt = canUseSubskill(player, SubSkillType.FISHING_MAGIC_HUNTER) && canUseSubskill(player, SubSkillType.FISHING_TREASURE_HUNTER);
|
||||
canShake = canUseSubskill(player, SubSkillType.FISHING_SHAKE);
|
||||
canFishermansDiet = canUseSubskill(player, SubSkillType.FISHING_FISHERMANS_DIET);
|
||||
canMasterAngler = mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() != null && canUseSubskill(player, SubSkillType.FISHING_MASTER_ANGLER);
|
||||
canIceFish = canUseSubskill(player, SubSkillType.FISHING_ICE_FISHING);
|
||||
canTreasureHunt = Permissions.canUseSubSkill(player, SubSkillType.FISHING_TREASURE_HUNTER);
|
||||
canMagicHunt = Permissions.canUseSubSkill(player, SubSkillType.FISHING_MAGIC_HUNTER) && Permissions.canUseSubSkill(player, SubSkillType.FISHING_TREASURE_HUNTER);
|
||||
canShake = Permissions.canUseSubSkill(player, SubSkillType.FISHING_SHAKE);
|
||||
canFishermansDiet = Permissions.canUseSubSkill(player, SubSkillType.FISHING_FISHERMANS_DIET);
|
||||
canMasterAngler = mcMMO.getCompatibilityManager().getMasterAnglerCompatibilityLayer() != null && Permissions.canUseSubSkill(player, SubSkillType.FISHING_MASTER_ANGLER);
|
||||
canIceFish = Permissions.canUseSubSkill(player, SubSkillType.FISHING_ICE_FISHING);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,8 +5,8 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.random.ProbabilityUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
@@ -24,6 +24,8 @@ public class HerbalismCommand extends SkillCommand {
|
||||
private int farmersDietRank;
|
||||
private String doubleDropChance;
|
||||
private String doubleDropChanceLucky;
|
||||
private String tripleDropChance;
|
||||
private String tripleDropChanceLucky;
|
||||
private String hylianLuckChance;
|
||||
private String hylianLuckChanceLucky;
|
||||
private String shroomThumbChance;
|
||||
@@ -35,6 +37,7 @@ public class HerbalismCommand extends SkillCommand {
|
||||
private boolean canGreenThumbBlocks;
|
||||
private boolean canFarmersDiet;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean canTripleDrop;
|
||||
private boolean canShroomThumb;
|
||||
|
||||
public HerbalismCommand() {
|
||||
@@ -46,10 +49,16 @@ public class HerbalismCommand extends SkillCommand {
|
||||
|
||||
// DOUBLE DROPS
|
||||
if (canDoubleDrop) {
|
||||
String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_DOUBLE_DROPS);
|
||||
String[] doubleDropStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.HERBALISM_DOUBLE_DROPS);
|
||||
doubleDropChance = doubleDropStrings[0];
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
}
|
||||
|
||||
if (canTripleDrop) {
|
||||
String[] tripleDropStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.HERBALISM_VERDANT_BOUNTY);
|
||||
tripleDropChance = tripleDropStrings[0];
|
||||
tripleDropChanceLucky = tripleDropStrings[1];
|
||||
}
|
||||
|
||||
// FARMERS DIET
|
||||
if (canFarmersDiet) {
|
||||
@@ -67,21 +76,21 @@ public class HerbalismCommand extends SkillCommand {
|
||||
if (canGreenThumbBlocks || canGreenThumbPlants) {
|
||||
greenThumbStage = RankUtils.getRank(player, SubSkillType.HERBALISM_GREEN_THUMB);
|
||||
|
||||
String[] greenThumbStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_GREEN_THUMB);
|
||||
String[] greenThumbStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.HERBALISM_GREEN_THUMB);
|
||||
greenThumbChance = greenThumbStrings[0];
|
||||
greenThumbChanceLucky = greenThumbStrings[1];
|
||||
}
|
||||
|
||||
// HYLIAN LUCK
|
||||
if (hasHylianLuck) {
|
||||
String[] hylianLuckStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_HYLIAN_LUCK);
|
||||
String[] hylianLuckStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.HERBALISM_HYLIAN_LUCK);
|
||||
hylianLuckChance = hylianLuckStrings[0];
|
||||
hylianLuckChanceLucky = hylianLuckStrings[1];
|
||||
}
|
||||
|
||||
// SHROOM THUMB
|
||||
if (canShroomThumb) {
|
||||
String[] shroomThumbStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_SHROOM_THUMB);
|
||||
String[] shroomThumbStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.HERBALISM_SHROOM_THUMB);
|
||||
shroomThumbChance = shroomThumbStrings[0];
|
||||
shroomThumbChanceLucky = shroomThumbStrings[1];
|
||||
}
|
||||
@@ -89,13 +98,14 @@ public class HerbalismCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
hasHylianLuck = canUseSubskill(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
|
||||
hasHylianLuck = Permissions.canUseSubSkill(player, SubSkillType.HERBALISM_HYLIAN_LUCK);
|
||||
canGreenTerra = Permissions.greenTerra(player);
|
||||
canGreenThumbPlants = RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbPlant(player, Material.WHEAT) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.BEETROOTS) || Permissions.greenThumbPlant(player, Material.NETHER_WART) || Permissions.greenThumbPlant(player, Material.COCOA));
|
||||
canGreenThumbBlocks = RankUtils.hasUnlockedSubskill(player, SubSkillType.HERBALISM_GREEN_THUMB) && (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLESTONE_WALL) || Permissions.greenThumbBlock(player, Material.STONE_BRICKS));
|
||||
canFarmersDiet = canUseSubskill(player, SubSkillType.HERBALISM_FARMERS_DIET);
|
||||
canDoubleDrop = canUseSubskill(player, SubSkillType.HERBALISM_DOUBLE_DROPS) && !mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(skill);
|
||||
canShroomThumb = canUseSubskill(player, SubSkillType.HERBALISM_SHROOM_THUMB);
|
||||
canFarmersDiet = Permissions.canUseSubSkill(player, SubSkillType.HERBALISM_FARMERS_DIET);
|
||||
canDoubleDrop = Permissions.canUseSubSkill(player, SubSkillType.HERBALISM_DOUBLE_DROPS) && !mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(skill);
|
||||
canTripleDrop = Permissions.canUseSubSkill(player, SubSkillType.HERBALISM_VERDANT_BOUNTY) && !mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(skill);
|
||||
canShroomThumb = Permissions.canUseSubSkill(player, SubSkillType.HERBALISM_SHROOM_THUMB);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,11 +116,16 @@ public class HerbalismCommand extends SkillCommand {
|
||||
messages.add(getStatMessage(SubSkillType.HERBALISM_DOUBLE_DROPS, doubleDropChance)
|
||||
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
|
||||
}
|
||||
|
||||
|
||||
if (canTripleDrop) {
|
||||
messages.add(getStatMessage(SubSkillType.HERBALISM_VERDANT_BOUNTY, tripleDropChance)
|
||||
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", tripleDropChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canFarmersDiet) {
|
||||
messages.add(getStatMessage(false, true, SubSkillType.HERBALISM_FARMERS_DIET, String.valueOf(farmersDietRank)));
|
||||
}
|
||||
|
||||
|
||||
if (canGreenTerra) {
|
||||
messages.add(getStatMessage(SubSkillType.HERBALISM_GREEN_TERRA, greenTerraLength)
|
||||
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.maces.MacesManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.gmail.nossr50.datatypes.skills.SubSkillType.MACES_CRIPPLE;
|
||||
import static com.gmail.nossr50.datatypes.skills.SubSkillType.MACES_MACES_LIMIT_BREAK;
|
||||
|
||||
public class MacesCommand extends SkillCommand {
|
||||
|
||||
public MacesCommand() {
|
||||
super(PrimarySkillType.MACES);
|
||||
}
|
||||
|
||||
String crippleChanceToApply, crippleChanceToApplyLucky, crippleLengthAgainstPlayers, crippleLengthAgainstMobs;
|
||||
|
||||
@Override
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
if (SkillUtils.canUseSubskill(player, MACES_CRIPPLE)) {
|
||||
int crippleRank = RankUtils.getRank(player, MACES_CRIPPLE);
|
||||
crippleLengthAgainstPlayers = String.valueOf(MacesManager.getCrippleTickDuration(true) / 20.0D);
|
||||
crippleLengthAgainstMobs = String.valueOf(MacesManager.getCrippleTickDuration(false) / 20.0D);
|
||||
|
||||
crippleChanceToApply = String.valueOf(mcMMO.p.getAdvancedConfig().getCrippleChanceToApplyOnHit(crippleRank) + "%");
|
||||
crippleChanceToApplyLucky = String.valueOf(mcMMO.p.getAdvancedConfig().getCrippleChanceToApplyOnHit(crippleRank) * 1.33);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {}
|
||||
|
||||
@Override
|
||||
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||
final List<String> messages = new ArrayList<>();
|
||||
|
||||
if (SkillUtils.canUseSubskill(player, MACES_MACES_LIMIT_BREAK)) {
|
||||
messages.add(getStatMessage(MACES_MACES_LIMIT_BREAK,
|
||||
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player,
|
||||
MACES_MACES_LIMIT_BREAK, 1000))));
|
||||
}
|
||||
|
||||
if (SkillUtils.canUseSubskill(player, MACES_CRIPPLE)) {
|
||||
messages.add(getStatMessage(MACES_CRIPPLE, crippleChanceToApply)
|
||||
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", crippleChanceToApplyLucky) : ""));
|
||||
messages.add(getStatMessage(true, true, MACES_CRIPPLE,
|
||||
crippleLengthAgainstPlayers,
|
||||
crippleLengthAgainstMobs));
|
||||
}
|
||||
|
||||
if (SkillUtils.canUseSubskill(player, SubSkillType.MACES_CRUSH)) {
|
||||
messages.add(getStatMessage(SubSkillType.MACES_CRUSH,
|
||||
String.valueOf(mmoPlayer.getMacesManager().getCrushDamage())));
|
||||
}
|
||||
|
||||
messages.add(ChatColor.GRAY + "The Maces skill is a work in progress and is still being developed," +
|
||||
" feedback would be appreciated in the mcMMO discord server.");
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Component> getTextComponents(Player player) {
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.MACES);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,8 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.ProbabilityUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -18,6 +17,8 @@ import java.util.List;
|
||||
public class MiningCommand extends SkillCommand {
|
||||
private String doubleDropChance;
|
||||
private String doubleDropChanceLucky;
|
||||
private String tripleDropChance;
|
||||
private String tripleDropChanceLucky;
|
||||
private String superBreakerLength;
|
||||
private String superBreakerLengthEndurance;
|
||||
|
||||
@@ -30,6 +31,7 @@ public class MiningCommand extends SkillCommand {
|
||||
|
||||
private boolean canSuperBreaker;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean canTripleDrop;
|
||||
private boolean canBlast;
|
||||
private boolean canBiggerBombs;
|
||||
private boolean canDemoExpert;
|
||||
@@ -42,7 +44,7 @@ public class MiningCommand extends SkillCommand {
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
// BLAST MINING
|
||||
if (canBlast || canDemoExpert || canBiggerBombs) {
|
||||
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
|
||||
MiningManager miningManager = mmoPlayer.getMiningManager();
|
||||
|
||||
blastMiningRank = miningManager.getBlastMiningTier();
|
||||
bonusTNTDrops = miningManager.getDropMultiplier();
|
||||
@@ -51,10 +53,17 @@ public class MiningCommand extends SkillCommand {
|
||||
blastDamageDecrease = percent.format(miningManager.getBlastDamageModifier() / 100.0D);
|
||||
blastRadiusIncrease = miningManager.getBlastRadiusModifier();
|
||||
}
|
||||
|
||||
// Mastery TRIPLE DROPS
|
||||
if (canTripleDrop) {
|
||||
String[] masteryTripleDropStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.MINING_MOTHER_LODE);
|
||||
tripleDropChance = masteryTripleDropStrings[0];
|
||||
tripleDropChanceLucky = masteryTripleDropStrings[1];
|
||||
}
|
||||
|
||||
// DOUBLE DROPS
|
||||
if (canDoubleDrop) {
|
||||
String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.MINING_DOUBLE_DROPS);
|
||||
String[] doubleDropStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.MINING_DOUBLE_DROPS);
|
||||
doubleDropChance = doubleDropStrings[0];
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
}
|
||||
@@ -72,7 +81,8 @@ public class MiningCommand extends SkillCommand {
|
||||
canBiggerBombs = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_BIGGER_BOMBS) && Permissions.biggerBombs(player);
|
||||
canBlast = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_BLAST_MINING) && Permissions.remoteDetonation(player);
|
||||
canDemoExpert = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_DEMOLITIONS_EXPERTISE) && Permissions.demolitionsExpertise(player);
|
||||
canDoubleDrop = canUseSubskill(player, SubSkillType.MINING_DOUBLE_DROPS);
|
||||
canDoubleDrop = Permissions.canUseSubSkill(player, SubSkillType.MINING_DOUBLE_DROPS);
|
||||
canTripleDrop = Permissions.canUseSubSkill(player, SubSkillType.MINING_MOTHER_LODE);
|
||||
canSuperBreaker = RankUtils.hasUnlockedSubskill(player, SubSkillType.MINING_SUPER_BREAKER) && Permissions.superBreaker(player);
|
||||
}
|
||||
|
||||
@@ -94,13 +104,18 @@ public class MiningCommand extends SkillCommand {
|
||||
messages.add(getStatMessage(SubSkillType.MINING_DEMOLITIONS_EXPERTISE, blastDamageDecrease));
|
||||
//messages.add(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease));
|
||||
}
|
||||
|
||||
|
||||
if (canDoubleDrop) {
|
||||
messages.add(getStatMessage(SubSkillType.MINING_DOUBLE_DROPS, doubleDropChance)
|
||||
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
|
||||
//messages.add(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canTripleDrop) {
|
||||
messages.add(getStatMessage(SubSkillType.MINING_MOTHER_LODE, tripleDropChance)
|
||||
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", tripleDropChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canSuperBreaker) {
|
||||
messages.add(getStatMessage(SubSkillType.MINING_SUPER_BREAKER, superBreakerLength)
|
||||
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.listeners.InteractionManager;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -27,31 +26,26 @@ public class MmoInfoCommand implements TabExecutor {
|
||||
/*
|
||||
* Only allow players to use this command
|
||||
*/
|
||||
if(commandSender instanceof Player player)
|
||||
{
|
||||
if(args.length < 1)
|
||||
if (commandSender instanceof Player player) {
|
||||
if (args == null || args.length < 1 || args[0] == null || args[0].isEmpty())
|
||||
return false;
|
||||
|
||||
if(Permissions.mmoinfo(player))
|
||||
{
|
||||
if(args == null || args[0] == null)
|
||||
return false;
|
||||
|
||||
if(args[0].equalsIgnoreCase( "???"))
|
||||
{
|
||||
if (Permissions.mmoinfo(player)) {
|
||||
if (args[0].equalsIgnoreCase( "???")) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", "???"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Mystery"));
|
||||
return true;
|
||||
} else if(InteractionManager.getAbstractByName(args[0]) != null || mcMMO.p.getSkillTools().EXACT_SUBSKILL_NAMES.contains(args[0]))
|
||||
{
|
||||
displayInfo(player, args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Not a real skill
|
||||
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.NoMatch"));
|
||||
final SubSkillType subSkillType = matchSubSkill(args[0]);
|
||||
if (subSkillType != null) {
|
||||
displayInfo(player, subSkillType);
|
||||
} else {
|
||||
//Not a real skill
|
||||
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.NoMatch"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -59,6 +53,15 @@ public class MmoInfoCommand implements TabExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
public SubSkillType matchSubSkill(String name) {
|
||||
for(SubSkillType subSkillType : SubSkillType.values()) {
|
||||
if (subSkillType.getNiceNameNoSpaces(subSkillType).equalsIgnoreCase(name)
|
||||
|| subSkillType.name().equalsIgnoreCase(name))
|
||||
return subSkillType;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
@@ -67,20 +70,12 @@ public class MmoInfoCommand implements TabExecutor {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
private void displayInfo(Player player, String subSkillName)
|
||||
{
|
||||
private void displayInfo(Player player, SubSkillType subSkillType) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", subSkillName));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", subSkillType.getLocaleName()));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.OldSkill"));
|
||||
|
||||
for(SubSkillType subSkillType : SubSkillType.values())
|
||||
{
|
||||
if(subSkillType.getNiceNameNoSpaces(subSkillType).equalsIgnoreCase(subSkillName))
|
||||
subSkillName = subSkillType.getWikiName(subSkillType.toString());
|
||||
}
|
||||
|
||||
//Send Player Wiki Link
|
||||
TextComponentFactory.sendPlayerSubSkillWikiLink(player, subSkillName);
|
||||
TextComponentFactory.sendPlayerSubSkillWikiLink(player, subSkillType.getLocaleName(), subSkillType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.BukkitCommandIssuer;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Conditions;
|
||||
import co.aikar.commands.annotation.Default;
|
||||
import com.gmail.nossr50.commands.CommandManager;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@CommandPermission("mcmmo.commands.mmopower")
|
||||
@CommandAlias("mmopower|mmopowerlevel|powerlevel")
|
||||
public class PowerLevelCommand extends BaseCommand {
|
||||
private final @NotNull mcMMO pluginRef;
|
||||
|
||||
public PowerLevelCommand(@NotNull mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
@Default
|
||||
@Conditions(CommandManager.POWER_LEVEL_CONDITION)
|
||||
public void processCommand(String[] args) {
|
||||
BukkitCommandIssuer bukkitCommandIssuer = (BukkitCommandIssuer) getCurrentCommandIssuer();
|
||||
Player player = bukkitCommandIssuer.getPlayer();
|
||||
McMMOPlayer mmoPlayer = UserManager.getPlayer(player); //Should never be null at this point because its caught in an ACF validation
|
||||
if (mmoPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int powerLevel = mmoPlayer.getPowerLevel();
|
||||
|
||||
mmoPlayer.getPlayer().sendMessage(ChatColor.DARK_AQUA + "Your " + ChatColor.GOLD + "[mcMMO]" + ChatColor.DARK_AQUA + " power level is: " + ChatColor.GREEN + powerLevel);
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,8 @@ import com.gmail.nossr50.skills.repair.Repair;
|
||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.ProbabilityUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
@@ -68,7 +67,7 @@ public class RepairCommand extends SkillCommand {
|
||||
|
||||
// SUPER REPAIR
|
||||
if (canSuperRepair) {
|
||||
String[] superRepairStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.REPAIR_SUPER_REPAIR);
|
||||
String[] superRepairStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.REPAIR_SUPER_REPAIR);
|
||||
superRepairChance = superRepairStrings[0];
|
||||
superRepairChanceLucky = superRepairStrings[1];
|
||||
}
|
||||
@@ -76,9 +75,9 @@ public class RepairCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canSuperRepair = canUseSubskill(player, SubSkillType.REPAIR_SUPER_REPAIR);
|
||||
canMasterRepair = canUseSubskill(player, SubSkillType.REPAIR_REPAIR_MASTERY);
|
||||
canArcaneForge = canUseSubskill(player, SubSkillType.REPAIR_ARCANE_FORGING);
|
||||
canSuperRepair = Permissions.canUseSubSkill(player, SubSkillType.REPAIR_SUPER_REPAIR);
|
||||
canMasterRepair = Permissions.canUseSubSkill(player, SubSkillType.REPAIR_REPAIR_MASTERY);
|
||||
canArcaneForge = Permissions.canUseSubSkill(player, SubSkillType.REPAIR_ARCANE_FORGING);
|
||||
canRepairDiamond = Permissions.repairMaterialType(player, MaterialType.DIAMOND);
|
||||
canRepairGold = Permissions.repairMaterialType(player, MaterialType.GOLD);
|
||||
canRepairIron = Permissions.repairMaterialType(player, MaterialType.IRON);
|
||||
@@ -94,7 +93,7 @@ public class RepairCommand extends SkillCommand {
|
||||
List<String> messages = new ArrayList<>();
|
||||
|
||||
if (canArcaneForge) {
|
||||
RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
|
||||
RepairManager repairManager = mmoPlayer.getRepairManager();
|
||||
|
||||
messages.add(getStatMessage(false, true,
|
||||
SubSkillType.REPAIR_ARCANE_FORGING,
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -30,14 +30,14 @@ public class SalvageCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canScrapCollector = canUseSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR);
|
||||
canArcaneSalvage = canUseSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE);
|
||||
canScrapCollector = Permissions.canUseSubSkill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR);
|
||||
canArcaneSalvage = Permissions.canUseSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||
List<String> messages = new ArrayList<>();
|
||||
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
|
||||
SalvageManager salvageManager = mmoPlayer.getSalvageManager();
|
||||
|
||||
if (canScrapCollector) {
|
||||
messages.add(getStatMessage(false, true,
|
||||
|
||||
@@ -5,16 +5,12 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.gmail.nossr50.util.skills.PerksUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.skills.SkillTools;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
@@ -32,20 +28,18 @@ import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class SkillCommand implements TabExecutor {
|
||||
protected PrimarySkillType skill;
|
||||
private final String skillName;
|
||||
|
||||
protected DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||
protected DecimalFormat decimal = new DecimalFormat("##0.00");
|
||||
protected McMMOPlayer mmoPlayer;
|
||||
|
||||
private final CommandExecutor skillGuideCommand;
|
||||
|
||||
public SkillCommand(PrimarySkillType skill) {
|
||||
this.skill = skill;
|
||||
skillName = mcMMO.p.getSkillTools().getLocalizedSkillName(skill);
|
||||
skillGuideCommand = new SkillGuideCommand(skill);
|
||||
}
|
||||
|
||||
@@ -60,9 +54,9 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
mmoPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
if (mmoPlayer == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
||||
return true;
|
||||
}
|
||||
@@ -70,7 +64,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
if (args.length == 0) {
|
||||
boolean isLucky = Permissions.lucky(player, skill);
|
||||
boolean hasEndurance = PerksUtils.handleActivationPerks(player, 0, 0) != 0;
|
||||
float skillValue = mcMMOPlayer.getSkillLevel(skill);
|
||||
float skillValue = mmoPlayer.getSkillLevel(skill);
|
||||
|
||||
//Send the players a few blank lines to make finding the top of the skill command easier
|
||||
if (mcMMO.p.getAdvancedConfig().doesSkillCommandSendBlankLines())
|
||||
@@ -81,7 +75,8 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
permissionsCheck(player);
|
||||
dataCalculations(player, skillValue);
|
||||
|
||||
sendSkillCommandHeader(player, mcMMOPlayer, (int) skillValue);
|
||||
sendSkillCommandHeader(mcMMO.p.getSkillTools().getLocalizedSkillName(skill),
|
||||
player, mmoPlayer, (int) skillValue);
|
||||
|
||||
//Make JSON text components
|
||||
List<Component> subskillTextComponents = getTextComponents(player);
|
||||
@@ -93,8 +88,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
|
||||
TextComponentFactory.sendPlayerSubSkillList(player, subskillTextComponents);
|
||||
|
||||
/*for(TextComponent tc : subskillTextComponents)
|
||||
{
|
||||
/*for(TextComponent tc : subskillTextComponents) {
|
||||
player.spigot().sendMessage(new TextComponent[]{tc, new TextComponent(": TESTING")});
|
||||
}*/
|
||||
|
||||
@@ -144,19 +138,17 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Guides.Available", skillName, skillName.toLowerCase(Locale.ENGLISH)));
|
||||
final String skillName = mcMMO.p.getSkillTools().getLocalizedSkillName(skill);
|
||||
player.sendMessage(LocaleLoader.getString("Guides.Available",
|
||||
skillName,
|
||||
skillName.toLowerCase(Locale.ENGLISH)));
|
||||
}
|
||||
|
||||
private void sendSkillCommandHeader(Player player, McMMOPlayer mcMMOPlayer, int skillValue) {
|
||||
ChatColor hd1 = ChatColor.DARK_AQUA;
|
||||
ChatColor c1 = ChatColor.GOLD;
|
||||
ChatColor c2 = ChatColor.RED;
|
||||
|
||||
|
||||
private void sendSkillCommandHeader(String skillName, Player player, McMMOPlayer mcMMOPlayer, int skillValue) {
|
||||
// send header
|
||||
player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", skillName));
|
||||
|
||||
if(!SkillTools.isChildSkill(skill))
|
||||
{
|
||||
if (!SkillTools.isChildSkill(skill)) {
|
||||
/*
|
||||
* NON-CHILD SKILLS
|
||||
*/
|
||||
@@ -173,7 +165,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
*/
|
||||
|
||||
|
||||
Set<PrimarySkillType> parents = FamilyTree.getParents(skill);
|
||||
var parents = mcMMO.p.getSkillTools().getChildSkillParents(skill);
|
||||
|
||||
//TODO: Add JSON here
|
||||
/*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/
|
||||
@@ -181,10 +173,8 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
|
||||
StringBuilder parentMessage = new StringBuilder();
|
||||
|
||||
for(int i = 0; i < parentList.size(); i++)
|
||||
{
|
||||
if(i+1 < parentList.size())
|
||||
{
|
||||
for(int i = 0; i < parentList.size(); i++) {
|
||||
if (i+1 < parentList.size()) {
|
||||
parentMessage.append(LocaleLoader.getString("Effects.Child.ParentList", mcMMO.p.getSkillTools().getLocalizedSkillName(parentList.get(i)), mcMMOPlayer.getSkillLevel(parentList.get(i))));
|
||||
parentMessage.append(ChatColor.GRAY).append(", ");
|
||||
} else {
|
||||
@@ -232,9 +222,9 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
return Math.min((int) skillValue, maxLevel) / rankChangeLevel;
|
||||
}
|
||||
|
||||
protected String[] getAbilityDisplayValues(SkillActivationType skillActivationType, Player player, SubSkillType subSkill) {
|
||||
return RandomChanceUtil.calculateAbilityDisplayValues(skillActivationType, player, subSkill);
|
||||
}
|
||||
// protected String[] getAbilityDisplayValues(SkillActivationType skillActivationType, Player player, SubSkillType subSkill) {
|
||||
// return RandomChanceUtil.calculateAbilityDisplayValues(skillActivationType, player, subSkill);
|
||||
// }
|
||||
|
||||
protected String[] calculateLengthDisplayValues(Player player, float skillValue) {
|
||||
int maxLength = mcMMO.p.getSkillTools().getSuperAbilityMaxLength(mcMMO.p.getSkillTools().getSuperAbility(skill));
|
||||
@@ -243,11 +233,9 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
|
||||
int length;
|
||||
|
||||
if(abilityLengthCap <= 0)
|
||||
{
|
||||
if (abilityLengthCap <= 0) {
|
||||
length = 2 + (int) (skillValue / abilityLengthVar);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar);
|
||||
}
|
||||
|
||||
@@ -260,27 +248,24 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
|
||||
}
|
||||
|
||||
protected String getStatMessage(SubSkillType subSkillType, String... vars)
|
||||
{
|
||||
protected String getStatMessage(SubSkillType subSkillType, String... vars) {
|
||||
return getStatMessage(false, false, subSkillType, vars);
|
||||
}
|
||||
|
||||
protected String getStatMessage(boolean isExtra, boolean isCustom, SubSkillType subSkillType, String... vars)
|
||||
{
|
||||
protected String getStatMessage(boolean isExtra, boolean isCustom, SubSkillType subSkillType, String... vars) {
|
||||
String templateKey = isCustom ? "Ability.Generic.Template.Custom" : "Ability.Generic.Template";
|
||||
String statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription() : subSkillType.getLocaleKeyStatExtraDescription();
|
||||
|
||||
if(isCustom)
|
||||
if (isCustom)
|
||||
return LocaleLoader.getString(templateKey, LocaleLoader.getString(statDescriptionKey, vars));
|
||||
else
|
||||
{
|
||||
else {
|
||||
String[] mergedList = NotificationManager.addItemToFirstPositionOfArray(LocaleLoader.getString(statDescriptionKey), vars);
|
||||
return LocaleLoader.getString(templateKey, mergedList);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getLimitBreakDescriptionParameter() {
|
||||
if(mcMMO.p.getAdvancedConfig().canApplyLimitBreakPVE()) {
|
||||
if (mcMMO.p.getAdvancedConfig().canApplyLimitBreakPVE()) {
|
||||
return "(PVP/PVE)";
|
||||
} else {
|
||||
return "(PVP)";
|
||||
@@ -297,14 +282,4 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
|
||||
protected abstract List<Component> getTextComponents(Player player);
|
||||
|
||||
/**
|
||||
* Checks if a player can use a skill
|
||||
* @param player target player
|
||||
* @param subSkillType target subskill
|
||||
* @return true if the player has permission and has the skill unlocked
|
||||
*/
|
||||
protected boolean canUseSubskill(Player player, SubSkillType subSkillType)
|
||||
{
|
||||
return Permissions.isSubSkillEnabled(player, subSkillType) && RankUtils.hasUnlockedSubskill(player, subSkillType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,8 +77,7 @@ public class SkillGuideCommand implements CommandExecutor {
|
||||
while (allStrings.size() < 9) {
|
||||
if (pageIndexStart + allStrings.size() > guide.size()) {
|
||||
allStrings.add("");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.ProbabilityUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -34,19 +33,19 @@ public class SmeltingCommand extends SkillCommand {
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
// FUEL EFFICIENCY
|
||||
if (canFuelEfficiency) {
|
||||
burnTimeModifier = String.valueOf(UserManager.getPlayer(player).getSmeltingManager().getFuelEfficiencyMultiplier());
|
||||
burnTimeModifier = String.valueOf(mmoPlayer.getSmeltingManager().getFuelEfficiencyMultiplier());
|
||||
}
|
||||
|
||||
// FLUX MINING
|
||||
/*if (canFluxMine) {
|
||||
String[] fluxMiningStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SMELTING_FLUX_MINING);
|
||||
String[] fluxMiningStrings = getRNGDisplayValues(player, SubSkillType.SMELTING_FLUX_MINING);
|
||||
str_fluxMiningChance = fluxMiningStrings[0];
|
||||
str_fluxMiningChanceLucky = fluxMiningStrings[1];
|
||||
}*/
|
||||
|
||||
// SECOND SMELT
|
||||
if (canSecondSmelt) {
|
||||
String[] secondSmeltStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SMELTING_SECOND_SMELT);
|
||||
String[] secondSmeltStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.SMELTING_SECOND_SMELT);
|
||||
str_secondSmeltChance = secondSmeltStrings[0];
|
||||
str_secondSmeltChanceLucky = secondSmeltStrings[1];
|
||||
}
|
||||
@@ -54,8 +53,8 @@ public class SmeltingCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canFuelEfficiency = canUseSubskill(player, SubSkillType.SMELTING_FUEL_EFFICIENCY);
|
||||
canSecondSmelt = canUseSubskill(player, SubSkillType.SMELTING_SECOND_SMELT);
|
||||
canFuelEfficiency = Permissions.canUseSubSkill(player, SubSkillType.SMELTING_FUEL_EFFICIENCY);
|
||||
canSecondSmelt = Permissions.canUseSubSkill(player, SubSkillType.SMELTING_SECOND_SMELT);
|
||||
//canFluxMine = canUseSubskill(player, SubSkillType.SMELTING_FLUX_MINING);
|
||||
canUnderstandTheArt = Permissions.vanillaXpBoost(player, skill) && RankUtils.hasUnlockedSubskill(player, SubSkillType.SMELTING_UNDERSTANDING_THE_ART);
|
||||
}
|
||||
@@ -81,7 +80,7 @@ public class SmeltingCommand extends SkillCommand {
|
||||
|
||||
if (canUnderstandTheArt) {
|
||||
messages.add(getStatMessage(false, true, SubSkillType.SMELTING_UNDERSTANDING_THE_ART,
|
||||
String.valueOf(UserManager.getPlayer(player).getSmeltingManager().getVanillaXpMultiplier())));
|
||||
String.valueOf(mmoPlayer.getSmeltingManager().getVanillaXpMultiplier())));
|
||||
}
|
||||
|
||||
return messages;
|
||||
|
||||
@@ -5,10 +5,10 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
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 com.gmail.nossr50.util.random.ProbabilityUtil;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -38,7 +38,7 @@ public class SwordsCommand extends SkillCommand {
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
// SWORDS_COUNTER_ATTACK
|
||||
if (canCounter) {
|
||||
String[] counterStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SWORDS_COUNTER_ATTACK);
|
||||
String[] counterStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.SWORDS_COUNTER_ATTACK);
|
||||
counterChance = counterStrings[0];
|
||||
counterChanceLucky = counterStrings[1];
|
||||
}
|
||||
@@ -69,8 +69,8 @@ public class SwordsCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canRupture = canUseSubskill(player, SubSkillType.SWORDS_RUPTURE);
|
||||
canCounter = canUseSubskill(player, SubSkillType.SWORDS_COUNTER_ATTACK);
|
||||
canRupture = SkillUtils.canUseSubskill(player, SubSkillType.SWORDS_RUPTURE);
|
||||
canCounter = SkillUtils.canUseSubskill(player, SubSkillType.SWORDS_COUNTER_ATTACK);
|
||||
canSerratedStrike = RankUtils.hasUnlockedSubskill(player, SubSkillType.SWORDS_SERRATED_STRIKES) && Permissions.serratedStrikes(player);
|
||||
}
|
||||
|
||||
@@ -101,13 +101,12 @@ public class SwordsCommand extends SkillCommand {
|
||||
+ (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
|
||||
}
|
||||
|
||||
if(canUseSubskill(player, SubSkillType.SWORDS_STAB))
|
||||
{
|
||||
if (SkillUtils.canUseSubskill(player, SubSkillType.SWORDS_STAB)) {
|
||||
messages.add(getStatMessage(SubSkillType.SWORDS_STAB,
|
||||
String.valueOf(UserManager.getPlayer(player).getSwordsManager().getStabDamage())));
|
||||
String.valueOf(mmoPlayer.getSwordsManager().getStabDamage())));
|
||||
}
|
||||
|
||||
if(canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {
|
||||
if (SkillUtils.canUseSubskill(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {
|
||||
messages.add(getStatMessage(SubSkillType.SWORDS_SWORDS_LIMIT_BREAK,
|
||||
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK, 1000))));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.random.ProbabilityUtil;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -35,7 +35,7 @@ public class TamingCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
if (canGore) {
|
||||
String[] goreStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.TAMING_GORE);
|
||||
String[] goreStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.TAMING_GORE);
|
||||
goreChance = goreStrings[0];
|
||||
goreChanceLucky = goreStrings[1];
|
||||
}
|
||||
@@ -43,15 +43,15 @@ public class TamingCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canBeastLore = canUseSubskill(player, SubSkillType.TAMING_BEAST_LORE);
|
||||
canBeastLore = Permissions.canUseSubSkill(player, SubSkillType.TAMING_BEAST_LORE);
|
||||
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
|
||||
canEnvironmentallyAware = canUseSubskill(player, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE);
|
||||
canFastFood = canUseSubskill(player, SubSkillType.TAMING_FAST_FOOD_SERVICE);
|
||||
canGore = canUseSubskill(player, SubSkillType.TAMING_GORE);
|
||||
canSharpenedClaws = canUseSubskill(player, SubSkillType.TAMING_SHARPENED_CLAWS);
|
||||
canShockProof = canUseSubskill(player, SubSkillType.TAMING_SHOCK_PROOF);
|
||||
canThickFur = canUseSubskill(player, SubSkillType.TAMING_THICK_FUR);
|
||||
canHolyHound = canUseSubskill(player, SubSkillType.TAMING_HOLY_HOUND);
|
||||
canEnvironmentallyAware = Permissions.canUseSubSkill(player, SubSkillType.TAMING_ENVIRONMENTALLY_AWARE);
|
||||
canFastFood = Permissions.canUseSubSkill(player, SubSkillType.TAMING_FAST_FOOD_SERVICE);
|
||||
canGore = Permissions.canUseSubSkill(player, SubSkillType.TAMING_GORE);
|
||||
canSharpenedClaws = Permissions.canUseSubSkill(player, SubSkillType.TAMING_SHARPENED_CLAWS);
|
||||
canShockProof = Permissions.canUseSubSkill(player, SubSkillType.TAMING_SHOCK_PROOF);
|
||||
canThickFur = Permissions.canUseSubSkill(player, SubSkillType.TAMING_THICK_FUR);
|
||||
canHolyHound = Permissions.canUseSubSkill(player, SubSkillType.TAMING_HOLY_HOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.gmail.nossr50.datatypes.skills.SubSkillType.TRIDENTS_IMPALE;
|
||||
import static com.gmail.nossr50.datatypes.skills.SubSkillType.TRIDENTS_TRIDENTS_LIMIT_BREAK;
|
||||
|
||||
public class TridentsCommand extends SkillCommand {
|
||||
|
||||
|
||||
public TridentsCommand() {
|
||||
super(PrimarySkillType.TRIDENTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dataCalculations(Player player, float skillValue) {}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {}
|
||||
|
||||
@Override
|
||||
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
||||
List<String> messages = new ArrayList<>();
|
||||
|
||||
if (SkillUtils.canUseSubskill(player, TRIDENTS_TRIDENTS_LIMIT_BREAK)) {
|
||||
messages.add(getStatMessage(TRIDENTS_TRIDENTS_LIMIT_BREAK,
|
||||
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, TRIDENTS_TRIDENTS_LIMIT_BREAK, 1000))));
|
||||
}
|
||||
|
||||
if (SkillUtils.canUseSubskill(player, TRIDENTS_IMPALE)) {
|
||||
messages.add(getStatMessage(TRIDENTS_IMPALE,
|
||||
String.valueOf(mmoPlayer.getTridentsManager().impaleDamageBonus())));
|
||||
}
|
||||
|
||||
messages.add(ChatColor.GRAY + "The Tridents skill is a work in progress and is still being developed, feedback would be appreciated in the mcMMO discord server.");
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Component> getTextComponents(Player player) {
|
||||
List<Component> textComponents = new ArrayList<>();
|
||||
|
||||
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.TRIDENTS);
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,9 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.ProbabilityUtil;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -40,7 +39,7 @@ public class UnarmedCommand extends SkillCommand {
|
||||
protected void dataCalculations(Player player, float skillValue) {
|
||||
// UNARMED_ARROW_DEFLECT
|
||||
if (canDeflect) {
|
||||
String[] deflectStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_ARROW_DEFLECT);
|
||||
String[] deflectStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.UNARMED_ARROW_DEFLECT);
|
||||
deflectChance = deflectStrings[0];
|
||||
deflectChanceLucky = deflectStrings[1];
|
||||
}
|
||||
@@ -54,19 +53,19 @@ public class UnarmedCommand extends SkillCommand {
|
||||
|
||||
// UNARMED_DISARM
|
||||
if (canDisarm) {
|
||||
String[] disarmStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_DISARM);
|
||||
String[] disarmStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.UNARMED_DISARM);
|
||||
disarmChance = disarmStrings[0];
|
||||
disarmChanceLucky = disarmStrings[1];
|
||||
}
|
||||
|
||||
// IRON ARM
|
||||
if (canIronArm) {
|
||||
ironArmBonus = UserManager.getPlayer(player).getUnarmedManager().getSteelArmStyleDamage();
|
||||
ironArmBonus = mmoPlayer.getUnarmedManager().getSteelArmStyleDamage();
|
||||
}
|
||||
|
||||
// IRON GRIP
|
||||
if (canIronGrip) {
|
||||
String[] ironGripStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_IRON_GRIP);
|
||||
String[] ironGripStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.UNARMED_IRON_GRIP);
|
||||
ironGripChance = ironGripStrings[0];
|
||||
ironGripChanceLucky = ironGripStrings[1];
|
||||
}
|
||||
@@ -75,10 +74,10 @@ public class UnarmedCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canBerserk = RankUtils.hasUnlockedSubskill(player, SubSkillType.UNARMED_BERSERK) && Permissions.berserk(player);
|
||||
canIronArm = canUseSubskill(player, SubSkillType.UNARMED_STEEL_ARM_STYLE);
|
||||
canDeflect = canUseSubskill(player, SubSkillType.UNARMED_ARROW_DEFLECT);
|
||||
canDisarm = canUseSubskill(player, SubSkillType.UNARMED_DISARM);
|
||||
canIronGrip = canUseSubskill(player, SubSkillType.UNARMED_IRON_GRIP);
|
||||
canIronArm = Permissions.canUseSubSkill(player, SubSkillType.UNARMED_STEEL_ARM_STYLE);
|
||||
canDeflect = Permissions.canUseSubSkill(player, SubSkillType.UNARMED_ARROW_DEFLECT);
|
||||
canDisarm = Permissions.canUseSubSkill(player, SubSkillType.UNARMED_DISARM);
|
||||
canIronGrip = Permissions.canUseSubSkill(player, SubSkillType.UNARMED_IRON_GRIP);
|
||||
// TODO: Apparently we forgot about block cracker?
|
||||
}
|
||||
|
||||
@@ -114,7 +113,7 @@ public class UnarmedCommand extends SkillCommand {
|
||||
//messages.add(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if(canUseSubskill(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) {
|
||||
if (Permissions.canUseSubSkill(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) {
|
||||
messages.add(getStatMessage(SubSkillType.UNARMED_UNARMED_LIMIT_BREAK,
|
||||
String.valueOf(CombatUtils.getLimitBreakDamageAgainstQuality(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK, 1000))));
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.random.ProbabilityUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import com.gmail.nossr50.util.text.TextComponentFactory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -18,15 +18,15 @@ public class WoodcuttingCommand extends SkillCommand {
|
||||
private String treeFellerLength;
|
||||
private String treeFellerLengthEndurance;
|
||||
private String doubleDropChance;
|
||||
private String tripleDropChance;
|
||||
private String doubleDropChanceLucky;
|
||||
private String tripleDropChanceLucky;
|
||||
|
||||
private boolean canTreeFell;
|
||||
private boolean canLeafBlow;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean canTripleDrop;
|
||||
private boolean canKnockOnWood;
|
||||
private boolean canSplinter;
|
||||
private boolean canBarkSurgeon;
|
||||
private boolean canNaturesBounty;
|
||||
|
||||
public WoodcuttingCommand() {
|
||||
super(PrimarySkillType.WOODCUTTING);
|
||||
@@ -38,7 +38,14 @@ public class WoodcuttingCommand extends SkillCommand {
|
||||
if (canDoubleDrop) {
|
||||
setDoubleDropClassicChanceStrings(player);
|
||||
}
|
||||
|
||||
|
||||
//Clean Cuts
|
||||
if (canTripleDrop) {
|
||||
String[] tripleDropStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.WOODCUTTING_CLEAN_CUTS);
|
||||
tripleDropChance = tripleDropStrings[0];
|
||||
tripleDropChanceLucky = tripleDropStrings[1];
|
||||
}
|
||||
|
||||
// TREE FELLER
|
||||
if (canTreeFell) {
|
||||
String[] treeFellerStrings = calculateLengthDisplayValues(player, skillValue);
|
||||
@@ -48,7 +55,7 @@ public class WoodcuttingCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
private void setDoubleDropClassicChanceStrings(Player player) {
|
||||
String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.WOODCUTTING_HARVEST_LUMBER);
|
||||
String[] doubleDropStrings = ProbabilityUtil.getRNGDisplayValues(mmoPlayer, SubSkillType.WOODCUTTING_HARVEST_LUMBER);
|
||||
doubleDropChance = doubleDropStrings[0];
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
}
|
||||
@@ -56,14 +63,12 @@ public class WoodcuttingCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void permissionsCheck(Player player) {
|
||||
canTreeFell = RankUtils.hasUnlockedSubskill(player, SubSkillType.WOODCUTTING_TREE_FELLER) && Permissions.treeFeller(player);
|
||||
canDoubleDrop = canUseSubskill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER)
|
||||
&& !mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(skill)
|
||||
canDoubleDrop = !mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(skill)
|
||||
&& Permissions.canUseSubSkill(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER)
|
||||
&& RankUtils.getRank(player, SubSkillType.WOODCUTTING_HARVEST_LUMBER) >= 1;
|
||||
canLeafBlow = canUseSubskill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER);
|
||||
canKnockOnWood = canTreeFell && canUseSubskill(player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD);
|
||||
/*canSplinter = canUseSubskill(player, SubSkillType.WOODCUTTING_SPLINTER);
|
||||
canBarkSurgeon = canUseSubskill(player, SubSkillType.WOODCUTTING_BARK_SURGEON);
|
||||
canNaturesBounty = canUseSubskill(player, SubSkillType.WOODCUTTING_NATURES_BOUNTY);*/
|
||||
canTripleDrop = !mcMMO.p.getGeneralConfig().getDoubleDropsDisabled(skill) && Permissions.canUseSubSkill(player, SubSkillType.WOODCUTTING_CLEAN_CUTS);
|
||||
canLeafBlow = Permissions.canUseSubSkill(player, SubSkillType.WOODCUTTING_LEAF_BLOWER);
|
||||
canKnockOnWood = canTreeFell && Permissions.canUseSubSkill(player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,10 +80,16 @@ public class WoodcuttingCommand extends SkillCommand {
|
||||
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canTripleDrop) {
|
||||
messages.add(getStatMessage(SubSkillType.WOODCUTTING_CLEAN_CUTS, tripleDropChance)
|
||||
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", tripleDropChanceLucky) : ""));
|
||||
}
|
||||
|
||||
|
||||
if (canKnockOnWood) {
|
||||
String lootNote;
|
||||
|
||||
if(RankUtils.hasReachedRank(2, player, SubSkillType.WOODCUTTING_KNOCK_ON_WOOD)) {
|
||||
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");
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdvancedConfig extends BukkitConfig {
|
||||
int[] defaultCrippleValues = new int[]{10, 15, 20, 25};
|
||||
|
||||
public AdvancedConfig(File dataFolder) {
|
||||
super("advanced.yml", dataFolder);
|
||||
@@ -504,8 +505,7 @@ public class AdvancedConfig extends BukkitConfig {
|
||||
*/
|
||||
|
||||
|
||||
/*public ChatColor getJSONStatHoverElementColor(StatType statType, boolean isPrefix)
|
||||
{
|
||||
/*public ChatColor getJSONStatHoverElementColor(StatType statType, boolean isPrefix) {
|
||||
String keyAddress = isPrefix ? "Prefix" : "Value";
|
||||
String keyLocation = "Style.JSON.Hover.Details." + StringUtils.getCapitalized(statType.toString()) +"."+keyAddress+".Color";
|
||||
|
||||
@@ -517,50 +517,41 @@ public class AdvancedConfig extends BukkitConfig {
|
||||
*
|
||||
* @return the ChatColor for this element
|
||||
*/
|
||||
/*public ChatColor getJSONStatHoverDetailsColor()
|
||||
{
|
||||
/*public ChatColor getJSONStatHoverDetailsColor() {
|
||||
String keyLocation = "Style.JSON.Hover.Details.Header.Color";
|
||||
return getChatColorFromKey(keyLocation);
|
||||
}
|
||||
|
||||
public boolean isJSONDetailsHeaderBold()
|
||||
{
|
||||
public boolean isJSONDetailsHeaderBold() {
|
||||
return config.getBoolean("Style.JSON.Hover.Details.Header.Bold");
|
||||
}
|
||||
|
||||
public boolean isJSONDetailsHeaderItalic()
|
||||
{
|
||||
public boolean isJSONDetailsHeaderItalic() {
|
||||
return config.getBoolean("Style.JSON.Hover.Details.Header.Italics");
|
||||
}
|
||||
|
||||
public boolean isJSONDetailsHeaderUnderlined()
|
||||
{
|
||||
public boolean isJSONDetailsHeaderUnderlined() {
|
||||
return config.getBoolean("Style.JSON.Hover.Details.Header.Underlined");
|
||||
}
|
||||
|
||||
public ChatColor getJSONStatHoverDescriptionColor()
|
||||
{
|
||||
public ChatColor getJSONStatHoverDescriptionColor() {
|
||||
String keyLocation = "Style.JSON.Hover.Details.Description.Color";
|
||||
return getChatColorFromKey(keyLocation);
|
||||
}
|
||||
|
||||
public boolean isJSONDetailsDescriptionBold()
|
||||
{
|
||||
public boolean isJSONDetailsDescriptionBold() {
|
||||
return config.getBoolean("Style.JSON.Hover.Details.Description.Bold");
|
||||
}
|
||||
|
||||
public boolean isJSONDetailsDescriptionItalic()
|
||||
{
|
||||
public boolean isJSONDetailsDescriptionItalic() {
|
||||
return config.getBoolean("Style.JSON.Hover.Details.Description.Italics");
|
||||
}
|
||||
|
||||
public boolean isJSONDetailsDescriptionUnderlined()
|
||||
{
|
||||
public boolean isJSONDetailsDescriptionUnderlined() {
|
||||
return config.getBoolean("Style.JSON.Hover.Details.Description.Underlined");
|
||||
}
|
||||
|
||||
public ChatColor getJSONActionBarColor(NotificationType notificationType)
|
||||
{
|
||||
public ChatColor getJSONActionBarColor(NotificationType notificationType) {
|
||||
return getChatColor(config.getString("Style.JSON.Notification."+notificationType.toString()+".Color"));
|
||||
}*/
|
||||
private ChatColor getChatColorFromKey(String keyLocation) {
|
||||
@@ -580,22 +571,19 @@ public class AdvancedConfig extends BukkitConfig {
|
||||
return ChatColor.WHITE;
|
||||
}
|
||||
|
||||
/*public boolean isJSONStatHoverElementBold(StatType statType, boolean isPrefix)
|
||||
{
|
||||
/*public boolean isJSONStatHoverElementBold(StatType statType, boolean isPrefix) {
|
||||
String keyAddress = isPrefix ? "Prefix" : "Value";
|
||||
String keyLocation = "Style.JSON.Hover.Details." + StringUtils.getCapitalized(statType.toString()) +"."+keyAddress+".Bold";
|
||||
return config.getBoolean(keyLocation);
|
||||
}
|
||||
|
||||
public boolean isJSONStatHoverElementItalic(StatType statType, boolean isPrefix)
|
||||
{
|
||||
public boolean isJSONStatHoverElementItalic(StatType statType, boolean isPrefix) {
|
||||
String keyAddress = isPrefix ? "Prefix" : "Value";
|
||||
String keyLocation = "Style.JSON.Hover.Details." + StringUtils.getCapitalized(statType.toString()) +"."+keyAddress+".Italics";
|
||||
return config.getBoolean(keyLocation);
|
||||
}
|
||||
|
||||
public boolean isJSONStatHoverElementUnderlined(StatType statType, boolean isPrefix)
|
||||
{
|
||||
public boolean isJSONStatHoverElementUnderlined(StatType statType, boolean isPrefix) {
|
||||
String keyAddress = isPrefix ? "Prefix" : "Value";
|
||||
String keyLocation = "Style.JSON.Hover.Details." + StringUtils.getCapitalized(statType.toString()) +"."+keyAddress+".Underline";
|
||||
return config.getBoolean(keyLocation);
|
||||
@@ -627,7 +615,11 @@ public class AdvancedConfig extends BukkitConfig {
|
||||
|
||||
/* ALCHEMY */
|
||||
public int getCatalysisMaxBonusLevel() {
|
||||
return config.getInt("Skills.Alchemy.Catalysis.MaxBonusLevel", 1000);
|
||||
if (mcMMO.isRetroModeEnabled()) {
|
||||
return config.getInt("Skills.Alchemy.Catalysis.MaxBonusLevel.RetroMode", 1000);
|
||||
} else {
|
||||
return config.getInt("Skills.Alchemy.Catalysis.MaxBonusLevel.Standard", 100);
|
||||
}
|
||||
}
|
||||
|
||||
public double getCatalysisMinSpeed() {
|
||||
@@ -693,6 +685,15 @@ public class AdvancedConfig extends BukkitConfig {
|
||||
return config.getDouble("Skills.Axes.SkullSplitter.DamageModifier", 2.0D);
|
||||
}
|
||||
|
||||
/* CROSSBOWS */
|
||||
public double getPoweredShotRankDamageMultiplier() {
|
||||
return config.getDouble("Skills.Crossbows.PoweredShot.RankDamageMultiplier", 10.0D);
|
||||
}
|
||||
|
||||
public double getPoweredShotDamageMax() {
|
||||
return config.getDouble("Skills.Archery.SkillShot.MaxDamage", 9.0D);
|
||||
}
|
||||
|
||||
/* EXCAVATION */
|
||||
//Nothing to configure, everything is already configurable in config.yml
|
||||
|
||||
@@ -937,4 +938,10 @@ public class AdvancedConfig extends BukkitConfig {
|
||||
public boolean isKnockOnWoodXPOrbEnabled() {
|
||||
return config.getBoolean("Skills.Woodcutting.TreeFeller.Knock_On_Wood.Add_XP_Orbs_To_Drops", true);
|
||||
}
|
||||
|
||||
/* MACES */
|
||||
public double getCrippleChanceToApplyOnHit(int rank) {
|
||||
String root = "Skills.Maces.Cripple.Chance_To_Apply_On_Hit.Rank_";
|
||||
return config.getDouble(root + rank, defaultCrippleValues[rank-1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public abstract class BukkitConfig {
|
||||
try {
|
||||
config.save(configFile);
|
||||
|
||||
if(copyDefaults && !savedDefaults) {
|
||||
if (copyDefaults && !savedDefaults) {
|
||||
copyMissingDefaultsFromResource();
|
||||
savedDefaults = true;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public abstract class BukkitConfig {
|
||||
YamlConfiguration saveDefaultConfigToDisk() {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Copying default config to disk: " + fileName + " to defaults/" + fileName);
|
||||
try(InputStream inputStream = mcMMO.p.getResource(fileName)) {
|
||||
if(inputStream == null) {
|
||||
if (inputStream == null) {
|
||||
mcMMO.p.getLogger().severe("Unable to copy default config: " + fileName);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,12 @@ public class ChatConfig extends BukkitConfig {
|
||||
return config.getBoolean(key, true);
|
||||
}
|
||||
|
||||
public boolean isConsoleIncludedInAudience(@NotNull ChatChannel chatChannel) {
|
||||
String key = "Chat.Channels." + StringUtils.getCapitalized(chatChannel.toString()) + ".Send_To_Console";
|
||||
return config.getBoolean(key, true);
|
||||
}
|
||||
|
||||
|
||||
public boolean isSpyingAutomatic() {
|
||||
return config.getBoolean("Chat.Channels.Party.Spies.Automatically_Enable_Spying", false);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CustomItemSupportConfig extends BukkitConfig {
|
||||
public CustomItemSupportConfig(File dataFolder) {
|
||||
super("custom_item_support.yml", dataFolder);
|
||||
validate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
|
||||
}
|
||||
|
||||
public boolean isCustomRepairAllowed() {
|
||||
return config.getBoolean("Custom_Item_Support.Repair.Allow_Repair_On_Items_With_Custom_Model_Data", true);
|
||||
}
|
||||
|
||||
public boolean isCustomSalvageAllowed() {
|
||||
return config.getBoolean("Custom_Item_Support.Salvage.Allow_Salvage_On_Items_With_Custom_Model_Data", true);
|
||||
}
|
||||
}
|
||||
@@ -547,6 +547,10 @@ public class GeneralConfig extends BukkitConfig {
|
||||
return config.getBoolean("Particles.Bleed", true);
|
||||
}
|
||||
|
||||
public boolean getCrippleEffectEnabled() {
|
||||
return config.getBoolean("Particles.Cripple", true);
|
||||
}
|
||||
|
||||
public boolean getDodgeEffectEnabled() {
|
||||
return config.getBoolean("Particles.Dodge", true);
|
||||
}
|
||||
@@ -1009,4 +1013,6 @@ public class GeneralConfig extends BukkitConfig {
|
||||
public boolean useVerboseLogging() {
|
||||
return config.getBoolean("General.Verbose_Logging", false);
|
||||
}
|
||||
|
||||
public boolean isMasterySystemEnabled() { return config.getBoolean( "General.PowerLevel.Skill_Mastery.Enabled"); }
|
||||
}
|
||||
|
||||
@@ -4,31 +4,40 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.VisibleForTesting;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
@Deprecated
|
||||
public abstract class LegacyConfigLoader {
|
||||
protected final File configFile;
|
||||
protected final @NotNull File configFile;
|
||||
protected final @NotNull File dataFolder;
|
||||
protected String fileName;
|
||||
protected @NotNull String fileName;
|
||||
protected YamlConfiguration config;
|
||||
|
||||
public LegacyConfigLoader(String relativePath, String fileName, @NotNull File dataFolder) {
|
||||
public LegacyConfigLoader(@NotNull String relativePath, @NotNull String fileName, @NotNull File dataFolder) {
|
||||
this.fileName = fileName;
|
||||
this.dataFolder = dataFolder;
|
||||
configFile = new File(dataFolder, relativePath + File.separator + fileName);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
public LegacyConfigLoader(String fileName, @NotNull File dataFolder) {
|
||||
public LegacyConfigLoader(@NotNull String fileName, @NotNull File dataFolder) {
|
||||
this.fileName = fileName;
|
||||
this.dataFolder = dataFolder;
|
||||
configFile = new File(dataFolder, fileName);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public LegacyConfigLoader(@NotNull File file) {
|
||||
this.fileName = file.getName();
|
||||
this.dataFolder = file.getParentFile();
|
||||
configFile = new File(dataFolder, fileName);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public LegacyConfigLoader(String relativePath, String fileName) {
|
||||
this.fileName = fileName;
|
||||
|
||||
@@ -50,12 +50,12 @@ public class SoundConfig extends BukkitConfig {
|
||||
|
||||
public float getVolume(SoundType soundType) {
|
||||
String key = "Sounds." + soundType.toString() + ".Volume";
|
||||
return (float) config.getDouble(key);
|
||||
return (float) config.getDouble(key, 1.0);
|
||||
}
|
||||
|
||||
public float getPitch(SoundType soundType) {
|
||||
String key = "Sounds." + soundType.toString() + ".Pitch";
|
||||
return (float) config.getDouble(key);
|
||||
return (float) config.getDouble(key, 1.0);
|
||||
}
|
||||
|
||||
public boolean getIsEnabled(SoundType soundType) {
|
||||
|
||||
@@ -73,7 +73,7 @@ public class WorldBlacklist {
|
||||
closeRead(fileReader);
|
||||
}
|
||||
|
||||
if(blacklist.size() > 0)
|
||||
if (blacklist.size() > 0)
|
||||
plugin.getLogger().info(blacklist.size() + " entries in mcMMO World Blacklist");
|
||||
}
|
||||
|
||||
|
||||
@@ -177,6 +177,10 @@ public class ExperienceConfig extends BukkitConfig {
|
||||
return config.getBoolean("ExploitFix.PreventPluginNPCInteraction", true);
|
||||
}
|
||||
|
||||
public boolean isArmorStandInteractionPrevented() {
|
||||
return config.getBoolean("ExploitFix.PreventArmorStandInteraction", true);
|
||||
}
|
||||
|
||||
public boolean isFishingExploitingPrevented() {
|
||||
return config.getBoolean("ExploitFix.Fishing", true);
|
||||
}
|
||||
@@ -256,7 +260,7 @@ public class ExperienceConfig extends BukkitConfig {
|
||||
|
||||
/* Skill modifiers */
|
||||
public double getFormulaSkillModifier(PrimarySkillType skill) {
|
||||
return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString()));
|
||||
return config.getDouble("Experience_Formula.Skill_Multiplier." + StringUtils.getCapitalized(skill.toString()), 1);
|
||||
}
|
||||
|
||||
/* Custom XP perk */
|
||||
@@ -296,6 +300,10 @@ public class ExperienceConfig extends BukkitConfig {
|
||||
}
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
public double getCombatXP(String entity) {
|
||||
return config.getDouble("Experience_Values.Combat.Multiplier." + entity);
|
||||
}
|
||||
|
||||
public double getCombatXP(EntityType entity) {
|
||||
return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"));
|
||||
}
|
||||
@@ -314,96 +322,73 @@ public class ExperienceConfig extends BukkitConfig {
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, Material material) {
|
||||
//TODO: Temporary measure to fix an exploit caused by a yet to be fixed Spigot bug (as of 7/3/2020)
|
||||
if (material.toString().equalsIgnoreCase("LILY_PAD"))
|
||||
return 0;
|
||||
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(material);
|
||||
if (config.contains(explicitString))
|
||||
return config.getInt(explicitString);
|
||||
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(material);
|
||||
if (config.contains(friendlyString))
|
||||
return config.getInt(friendlyString);
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(material);
|
||||
if (config.contains(wildcardString))
|
||||
return config.getInt(wildcardString);
|
||||
return 0;
|
||||
return getXpHelper(skill, StringUtils.getExplicitConfigMaterialString(material),
|
||||
StringUtils.getFriendlyConfigMaterialString(material),
|
||||
StringUtils.getWildcardConfigMaterialString(material));
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, BlockState blockState) {
|
||||
Material data = blockState.getType();
|
||||
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
|
||||
if (config.contains(explicitString))
|
||||
return config.getInt(explicitString);
|
||||
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
|
||||
if (config.contains(friendlyString))
|
||||
return config.getInt(friendlyString);
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
|
||||
if (config.contains(wildcardString))
|
||||
return config.getInt(wildcardString);
|
||||
return 0;
|
||||
Material material = blockState.getType();
|
||||
return getXp(skill, material);
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, Block block) {
|
||||
Material data = block.getType();
|
||||
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
|
||||
if (config.contains(explicitString))
|
||||
return config.getInt(explicitString);
|
||||
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
|
||||
if (config.contains(friendlyString))
|
||||
return config.getInt(friendlyString);
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
|
||||
if (config.contains(wildcardString))
|
||||
return config.getInt(wildcardString);
|
||||
return 0;
|
||||
Material material = block.getType();
|
||||
return getXp(skill, material);
|
||||
}
|
||||
|
||||
/* Materials */
|
||||
public int getXp(PrimarySkillType skill, BlockData data) {
|
||||
return getXpHelper(skill, StringUtils.getExplicitConfigBlockDataString(data),
|
||||
StringUtils.getFriendlyConfigBlockDataString(data),
|
||||
StringUtils.getWildcardConfigBlockDataString(data));
|
||||
}
|
||||
|
||||
private int getXpHelper(PrimarySkillType skill, String explicitString, String friendlyString, String wildcardString) {
|
||||
if (explicitString.equalsIgnoreCase("LILY_PAD")) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
|
||||
if (config.contains(explicitString))
|
||||
return config.getInt(explicitString);
|
||||
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
|
||||
if (config.contains(friendlyString))
|
||||
return config.getInt(friendlyString);
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
|
||||
if (config.contains(wildcardString))
|
||||
return config.getInt(wildcardString);
|
||||
String[] configStrings = {explicitString, friendlyString, wildcardString};
|
||||
|
||||
for (String configString : configStrings) {
|
||||
String fullPath = baseString + configString;
|
||||
if (config.contains(fullPath)) {
|
||||
return config.getInt(fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material data) {
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
|
||||
if (config.contains(explicitString))
|
||||
return true;
|
||||
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
|
||||
if (config.contains(friendlyString))
|
||||
return true;
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
|
||||
return config.contains(wildcardString);
|
||||
|
||||
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material material) {
|
||||
return doesBlockGiveSkillXPHelper(skill, StringUtils.getExplicitConfigMaterialString(material),
|
||||
StringUtils.getFriendlyConfigMaterialString(material),
|
||||
StringUtils.getWildcardConfigMaterialString(material));
|
||||
}
|
||||
|
||||
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, BlockData data) {
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
|
||||
if (config.contains(explicitString))
|
||||
return true;
|
||||
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
|
||||
if (config.contains(friendlyString))
|
||||
return true;
|
||||
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
|
||||
return config.contains(wildcardString);
|
||||
return doesBlockGiveSkillXPHelper(skill, StringUtils.getExplicitConfigBlockDataString(data),
|
||||
StringUtils.getFriendlyConfigBlockDataString(data),
|
||||
StringUtils.getWildcardConfigBlockDataString(data));
|
||||
}
|
||||
|
||||
private boolean doesBlockGiveSkillXPHelper(PrimarySkillType skill, String explicitString, String friendlyString, String wildcardString) {
|
||||
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
|
||||
String[] configStrings = {explicitString, friendlyString, wildcardString};
|
||||
|
||||
for (String configString : configStrings) {
|
||||
String fullPath = baseString + configString;
|
||||
if (config.contains(fullPath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Experience Bar Stuff
|
||||
*/
|
||||
@@ -482,7 +467,7 @@ public class ExperienceConfig extends BukkitConfig {
|
||||
|
||||
/* Alchemy */
|
||||
public double getPotionXP(PotionStage stage) {
|
||||
return config.getDouble("Experience_Values.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D);
|
||||
return config.getDouble("Experience_Values.Alchemy.Potion_Brewing.Stage_" + stage.toNumerical(), 10D);
|
||||
}
|
||||
|
||||
/* Archery */
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gmail.nossr50.config.mods;
|
||||
import com.gmail.nossr50.config.LegacyConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomEntity;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.apache.commons.lang.ClassUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -30,7 +29,7 @@ public class CustomEntityLegacyConfig extends LegacyConfigLoader {
|
||||
String className = config.getString(entityName + ".Class", "");
|
||||
|
||||
try {
|
||||
clazz = ClassUtils.getClass(className);
|
||||
clazz = Class.forName(className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
mcMMO.p.getLogger().warning("Invalid class (" + className + ") detected for " + entityName + ".");
|
||||
mcMMO.p.getLogger().warning("This custom entity may not function properly.");
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.gmail.nossr50.config.party;
|
||||
|
||||
import com.gmail.nossr50.config.BukkitConfig;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class PartyConfig extends BukkitConfig {
|
||||
public PartyConfig(File dataFolder) {
|
||||
super("party.yml", dataFolder);
|
||||
validate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
|
||||
}
|
||||
|
||||
public boolean isPartyEnabled() {
|
||||
return config.getBoolean("Party.Enabled", true);
|
||||
}
|
||||
}
|
||||
@@ -3,21 +3,29 @@ package com.gmail.nossr50.config.skills.alchemy;
|
||||
import com.gmail.nossr50.config.LegacyConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.skills.alchemy.AlchemyPotion;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.*;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.jetbrains.annotations.VisibleForTesting;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.gmail.nossr50.util.ItemUtils.setItemName;
|
||||
import static com.gmail.nossr50.util.PotionUtil.*;
|
||||
|
||||
public class PotionConfig extends LegacyConfigLoader {
|
||||
private static PotionConfig instance;
|
||||
|
||||
private final List<ItemStack> concoctionsIngredientsTierOne = new ArrayList<>();
|
||||
private final List<ItemStack> concoctionsIngredientsTierTwo = new ArrayList<>();
|
||||
@@ -28,30 +36,34 @@ public class PotionConfig extends LegacyConfigLoader {
|
||||
private final List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<>();
|
||||
private final List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<>();
|
||||
|
||||
private final Map<String, AlchemyPotion> potionMap = new HashMap<>();
|
||||
/**
|
||||
* Map of potion names to AlchemyPotion objects.
|
||||
*/
|
||||
private final Map<String, AlchemyPotion> alchemyPotions = new HashMap<>();
|
||||
|
||||
private PotionConfig() {
|
||||
public PotionConfig() {
|
||||
super("potions.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static PotionConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new PotionConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
@VisibleForTesting
|
||||
PotionConfig(File file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
}
|
||||
|
||||
public void loadPotions() {
|
||||
loadConcoctions();
|
||||
loadPotionMap();
|
||||
}
|
||||
|
||||
private void loadConcoctions() {
|
||||
ConfigurationSection concoctionSection = config.getConfigurationSection("Concoctions");
|
||||
@VisibleForTesting
|
||||
void loadConcoctions() {
|
||||
final ConfigurationSection concoctionSection = config.getConfigurationSection("Concoctions");
|
||||
|
||||
// Load the ingredients for each tier
|
||||
loadConcoctionsTier(concoctionsIngredientsTierOne, concoctionSection.getStringList("Tier_One_Ingredients"));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierTwo, concoctionSection.getStringList("Tier_Two_Ingredients"));
|
||||
loadConcoctionsTier(concoctionsIngredientsTierThree, concoctionSection.getStringList("Tier_Three_Ingredients"));
|
||||
@@ -71,7 +83,7 @@ public class PotionConfig extends LegacyConfigLoader {
|
||||
}
|
||||
|
||||
private void loadConcoctionsTier(List<ItemStack> ingredientList, List<String> ingredientStrings) {
|
||||
if (ingredientStrings != null && ingredientStrings.size() > 0) {
|
||||
if (ingredientStrings != null && !ingredientStrings.isEmpty()) {
|
||||
for (String ingredientString : ingredientStrings) {
|
||||
ItemStack ingredient = loadIngredient(ingredientString);
|
||||
|
||||
@@ -85,23 +97,24 @@ public class PotionConfig extends LegacyConfigLoader {
|
||||
/**
|
||||
* Find the Potions configuration section and load all defined potions.
|
||||
*/
|
||||
private void loadPotionMap() {
|
||||
int loadPotionMap() {
|
||||
ConfigurationSection potionSection = config.getConfigurationSection("Potions");
|
||||
int pass = 0;
|
||||
int fail = 0;
|
||||
int potionsLoaded = 0;
|
||||
int failures = 0;
|
||||
|
||||
for (String potionName : potionSection.getKeys(false)) {
|
||||
AlchemyPotion potion = loadPotion(potionSection.getConfigurationSection(potionName));
|
||||
|
||||
if (potion != null) {
|
||||
potionMap.put(potionName, potion);
|
||||
pass++;
|
||||
alchemyPotions.put(potionName, potion);
|
||||
potionsLoaded++;
|
||||
} else {
|
||||
fail++;
|
||||
failures++;
|
||||
}
|
||||
}
|
||||
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Loaded " + pass + " Alchemy potions, skipped " + fail + ".");
|
||||
mcMMO.p.getLogger().info("Loaded " + potionsLoaded + " Alchemy potions, skipped " + failures + ".");
|
||||
return potionsLoaded;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,37 +127,70 @@ public class PotionConfig extends LegacyConfigLoader {
|
||||
*/
|
||||
private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
|
||||
try {
|
||||
final String key = potion_section.getName();
|
||||
|
||||
final ConfigurationSection potionData = potion_section.getConfigurationSection("PotionData");
|
||||
boolean extended = false;
|
||||
boolean upgraded = false;
|
||||
|
||||
String name = potion_section.getString("Name");
|
||||
if (name != null) {
|
||||
name = ChatColor.translateAlternateColorCodes('&', name);
|
||||
if (potionData != null) {
|
||||
extended = potionData.getBoolean("Extended", false);
|
||||
upgraded = potionData.getBoolean("Upgraded", false);
|
||||
}
|
||||
|
||||
PotionData data;
|
||||
if (!potion_section.contains("PotionData")) { // Backwards config compatability
|
||||
short dataValue = Short.parseShort(potion_section.getName());
|
||||
Potion potion = Potion.fromDamage(dataValue);
|
||||
data = new PotionData(potion.getType(), potion.hasExtendedDuration(), potion.getLevel() == 2);
|
||||
Material material;
|
||||
final String materialString = potion_section.getString("Material", null);
|
||||
if (materialString != null) {
|
||||
material = ItemUtils.exhaustiveMaterialLookup(materialString);
|
||||
if (material == null) {
|
||||
mcMMO.p.getLogger().warning("PotionConfig: Failed to parse material for potion " + key + ": " + materialString);
|
||||
mcMMO.p.getLogger().warning("PotionConfig: Defaulting to POTION");
|
||||
material = Material.POTION;
|
||||
}
|
||||
} else {
|
||||
ConfigurationSection potionData = potion_section.getConfigurationSection("PotionData");
|
||||
data = new PotionData(PotionType.valueOf(potionData.getString("PotionType", "WATER")), potionData.getBoolean("Extended", false), potionData.getBoolean("Upgraded", false));
|
||||
mcMMO.p.getLogger().warning("PotionConfig: Missing Material config entry for potion " + key + "," +
|
||||
" from configuration section: " + potion_section + ", defaulting to POTION");
|
||||
material = Material.POTION;
|
||||
}
|
||||
|
||||
Material material = Material.POTION;
|
||||
String mat = potion_section.getString("Material", null);
|
||||
if (mat != null) {
|
||||
material = Material.valueOf(mat);
|
||||
final ItemStack itemStack = new ItemStack(material, 1);
|
||||
final PotionMeta potionMeta = (PotionMeta) itemStack.getItemMeta();
|
||||
|
||||
if (potionMeta == null) {
|
||||
mcMMO.p.getLogger().severe("PotionConfig: Failed to get PotionMeta for " + key + ", from configuration section:" +
|
||||
" " + potion_section);
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
// extended and upgraded seem to be mutually exclusive
|
||||
if (extended && upgraded) {
|
||||
mcMMO.p.getLogger().warning("Potion " + key + " has both Extended and Upgraded set to true," +
|
||||
" defaulting to Extended.");
|
||||
upgraded = false;
|
||||
}
|
||||
|
||||
String potionTypeStr = potionData.getString("PotionType", null);
|
||||
if (potionTypeStr == null) {
|
||||
mcMMO.p.getLogger().severe("PotionConfig: Missing PotionType for " + key + ", from configuration section:" +
|
||||
" " + potion_section);
|
||||
return null;
|
||||
}
|
||||
|
||||
// This works via side effects
|
||||
// TODO: Redesign later, side effects are stupid
|
||||
if(!setPotionType(potionMeta, potionTypeStr, upgraded, extended)) {
|
||||
mcMMO.p.getLogger().severe("PotionConfig: Failed to set parameters of potion for " + key + ": " + potionTypeStr);
|
||||
return null;
|
||||
}
|
||||
|
||||
final List<String> lore = new ArrayList<>();
|
||||
if (potion_section.contains("Lore")) {
|
||||
for (String line : potion_section.getStringList("Lore")) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
}
|
||||
potionMeta.setLore(lore);
|
||||
|
||||
List<PotionEffect> effects = new ArrayList<>();
|
||||
if (potion_section.contains("Effects")) {
|
||||
for (String effect : potion_section.getStringList("Effects")) {
|
||||
String[] parts = effect.split(" ");
|
||||
@@ -154,9 +200,9 @@ public class PotionConfig extends LegacyConfigLoader {
|
||||
int duration = parts.length > 2 ? Integer.parseInt(parts[2]) : 0;
|
||||
|
||||
if (type != null) {
|
||||
effects.add(new PotionEffect(type, duration, amplifier));
|
||||
potionMeta.addCustomEffect(new PotionEffect(type, duration, amplifier), true);
|
||||
} else {
|
||||
mcMMO.p.getLogger().warning("Failed to parse effect for potion " + name + ": " + effect);
|
||||
mcMMO.p.getLogger().severe("PotionConfig: Failed to parse effect for potion " + key + ": " + effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,28 +211,62 @@ public class PotionConfig extends LegacyConfigLoader {
|
||||
if (potion_section.contains("Color")) {
|
||||
color = Color.fromRGB(potion_section.getInt("Color"));
|
||||
} else {
|
||||
color = this.generateColor(effects);
|
||||
color = this.generateColor(potionMeta.getCustomEffects());
|
||||
}
|
||||
potionMeta.setColor(color);
|
||||
|
||||
Map<ItemStack, String> children = new HashMap<>();
|
||||
final Map<ItemStack, String> children = new HashMap<>();
|
||||
if (potion_section.contains("Children")) {
|
||||
for (String child : potion_section.getConfigurationSection("Children").getKeys(false)) {
|
||||
ItemStack ingredient = loadIngredient(child);
|
||||
if (ingredient != null) {
|
||||
children.put(ingredient, potion_section.getConfigurationSection("Children").getString(child));
|
||||
} else {
|
||||
mcMMO.p.getLogger().warning("Failed to parse child for potion " + name + ": " + child);
|
||||
mcMMO.p.getLogger().severe("PotionConfig: Failed to parse child for potion " + key + ": " + child);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Set the name of the potion
|
||||
setPotionDisplayName(potion_section, potionMeta);
|
||||
|
||||
return new AlchemyPotion(material, data, name, lore, effects, color, children);
|
||||
// TODO: Might not need to .setItemMeta
|
||||
itemStack.setItemMeta(potionMeta);
|
||||
return new AlchemyPotion(potion_section.getName(), itemStack, children);
|
||||
} catch (Exception e) {
|
||||
mcMMO.p.getLogger().warning("Failed to load Alchemy potion: " + potion_section.getName());
|
||||
mcMMO.p.getLogger().warning("PotionConfig: Failed to load Alchemy potion: " + potion_section.getName());
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean setPotionType(PotionMeta potionMeta, String potionTypeStr, boolean upgraded, boolean extended) {
|
||||
final PotionType potionType = matchPotionType(potionTypeStr, upgraded, extended);
|
||||
|
||||
if (potionType == null) {
|
||||
mcMMO.p.getLogger().severe("PotionConfig: Failed to parse potion type for: " + potionTypeStr);
|
||||
return false;
|
||||
}
|
||||
|
||||
// set base
|
||||
setBasePotionType(potionMeta, potionType, extended, upgraded);
|
||||
|
||||
// Legacy only
|
||||
setUpgradedAndExtendedProperties(potionType, potionMeta, upgraded, extended);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setPotionDisplayName(ConfigurationSection section, PotionMeta potionMeta) {
|
||||
// If a potion doesn't have any custom effects, there is no reason to override the vanilla name
|
||||
if (potionMeta.getCustomEffects().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String configuredName = section.getString("Name", null);
|
||||
if (configuredName != null) {
|
||||
setItemName(potionMeta, configuredName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a string representation of an ingredient.
|
||||
* Format: '<MATERIAL>[:data]'
|
||||
@@ -210,43 +290,63 @@ public class PotionConfig extends LegacyConfigLoader {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ingredients for the given tier.
|
||||
* @param tier Tier to get ingredients for.
|
||||
* @return List of ingredients for the given tier.
|
||||
*/
|
||||
public List<ItemStack> getIngredients(int tier) {
|
||||
switch (tier) {
|
||||
case 8:
|
||||
return concoctionsIngredientsTierEight;
|
||||
case 7:
|
||||
return concoctionsIngredientsTierSeven;
|
||||
case 6:
|
||||
return concoctionsIngredientsTierSix;
|
||||
case 5:
|
||||
return concoctionsIngredientsTierFive;
|
||||
case 4:
|
||||
return concoctionsIngredientsTierFour;
|
||||
case 3:
|
||||
return concoctionsIngredientsTierThree;
|
||||
case 2:
|
||||
return concoctionsIngredientsTierTwo;
|
||||
case 1:
|
||||
default:
|
||||
return concoctionsIngredientsTierOne;
|
||||
}
|
||||
return switch (tier) {
|
||||
case 8 -> concoctionsIngredientsTierEight;
|
||||
case 7 -> concoctionsIngredientsTierSeven;
|
||||
case 6 -> concoctionsIngredientsTierSix;
|
||||
case 5 -> concoctionsIngredientsTierFive;
|
||||
case 4 -> concoctionsIngredientsTierFour;
|
||||
case 3 -> concoctionsIngredientsTierThree;
|
||||
case 2 -> concoctionsIngredientsTierTwo;
|
||||
default -> concoctionsIngredientsTierOne;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given ItemStack is a valid potion.
|
||||
* @param item ItemStack to be checked.
|
||||
* @return True if the given ItemStack is a valid potion, false otherwise.
|
||||
*/
|
||||
public boolean isValidPotion(ItemStack item) {
|
||||
return getPotion(item) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AlchemyPotion that corresponds to the given name.
|
||||
* @param name Name of the potion to be checked.
|
||||
* @return AlchemyPotion that corresponds to the given name.
|
||||
*/
|
||||
public AlchemyPotion getPotion(String name) {
|
||||
return potionMap.get(name);
|
||||
return alchemyPotions.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the AlchemyPotion that corresponds to the given ItemStack.
|
||||
*
|
||||
* @param item ItemStack to be checked.
|
||||
*
|
||||
* @return AlchemyPotion that corresponds to the given ItemStack.
|
||||
*/
|
||||
public AlchemyPotion getPotion(ItemStack item) {
|
||||
for (AlchemyPotion potion : potionMap.values()) {
|
||||
if (potion.isSimilar(item)) {
|
||||
return potion;
|
||||
}
|
||||
final List<AlchemyPotion> potionList = alchemyPotions.values()
|
||||
.stream()
|
||||
.filter(potion -> potion.isSimilarPotion(item))
|
||||
.toList();
|
||||
if(potionList.size() > 1) {
|
||||
mcMMO.p.getLogger().severe("Multiple potions defined in config have matched this potion, for mcMMO to behave" +
|
||||
" properly there should only be one match found.");
|
||||
mcMMO.p.getLogger().severe("Potion ItemStack:" + item.toString());
|
||||
mcMMO.p.getLogger().severe("Alchemy Potions from config matching this item: "
|
||||
+ potionList.stream().map(AlchemyPotion::toString).collect(Collectors.joining(", ")));
|
||||
}
|
||||
return null;
|
||||
|
||||
return potionList.isEmpty() ? null : potionList.get(0);
|
||||
}
|
||||
|
||||
public Color generateColor(List<PotionEffect> effects) {
|
||||
@@ -278,5 +378,4 @@ public class PotionConfig extends LegacyConfigLoader {
|
||||
}
|
||||
return Color.fromRGB(red / colors.size(), green / colors.size(), blue / colors.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class RepairConfigManager {
|
||||
repairables.addAll(mainRepairConfig.getLoadedRepairables());
|
||||
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if(fileName.equals(REPAIR_VANILLA_YML))
|
||||
if (fileName.equals(REPAIR_VANILLA_YML))
|
||||
continue;
|
||||
|
||||
if (!pattern.matcher(fileName).matches()) {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class SalvageConfigManager {
|
||||
salvageables.addAll(mainSalvageConfig.getLoadedSalvageables());
|
||||
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if(fileName.equals(SALVAGE_VANILLA_YML))
|
||||
if (fileName.equals(SALVAGE_VANILLA_YML))
|
||||
continue;
|
||||
|
||||
if (!pattern.matcher(fileName).matches()) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.gmail.nossr50.datatypes.treasure.*;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.EnchantmentUtils;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.PotionUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -13,12 +14,13 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.gmail.nossr50.util.PotionUtil.matchPotionType;
|
||||
|
||||
public class FishingTreasureConfig extends BukkitConfig {
|
||||
|
||||
public static final String FILENAME = "fishing_treasures.yml";
|
||||
@@ -48,7 +50,7 @@ public class FishingTreasureConfig extends BukkitConfig {
|
||||
List<String> reason = new ArrayList<>();
|
||||
ConfigurationSection enchantment_drop_rates = config.getConfigurationSection("Enchantment_Drop_Rates");
|
||||
|
||||
if(enchantment_drop_rates != null) {
|
||||
if (enchantment_drop_rates != null) {
|
||||
for (String tier : enchantment_drop_rates.getKeys(false)) {
|
||||
double totalEnchantDropRate = 0;
|
||||
double totalItemDropRate = 0;
|
||||
@@ -204,30 +206,40 @@ public class FishingTreasureConfig extends BukkitConfig {
|
||||
}
|
||||
|
||||
if (materialName.contains("POTION")) {
|
||||
// Update for 1.20.5
|
||||
|
||||
Material mat = Material.matchMaterial(materialName);
|
||||
if (mat == null) {
|
||||
reason.add("Potion format for " + FILENAME + " has changed");
|
||||
continue;
|
||||
} else {
|
||||
item = new ItemStack(mat, amount, data);
|
||||
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
|
||||
PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
|
||||
|
||||
if (itemMeta == null) {
|
||||
mcMMO.p.getLogger().severe("Item meta when adding potion to fishing treasure was null, contact the mcMMO devs!");
|
||||
if (potionMeta == null) {
|
||||
mcMMO.p.getLogger().severe("FishingConfig: Item meta when adding potion to fishing treasure was null," +
|
||||
" contact the mcMMO devs!");
|
||||
reason.add("FishingConfig: Item meta when adding potion to fishing treasure was null");
|
||||
continue;
|
||||
}
|
||||
|
||||
PotionType potionType = null;
|
||||
try {
|
||||
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
||||
}
|
||||
String potionTypeStr;
|
||||
potionTypeStr = config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER");
|
||||
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
|
||||
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
|
||||
itemMeta.setBasePotionData(new PotionData(potionType, extended, upgraded));
|
||||
final PotionType potionType = matchPotionType(potionTypeStr, extended, upgraded);
|
||||
|
||||
if (potionType == null) {
|
||||
reason.add("FishingConfig: Could not derive potion type from: " + potionTypeStr +", " + extended + ", " + upgraded);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set the base potion type
|
||||
// NOTE: Upgraded/Extended are ignored in 1.20.5 and later
|
||||
PotionUtil.setBasePotionType(potionMeta, potionType, upgraded, extended);
|
||||
|
||||
if (customName != null) {
|
||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', customName));
|
||||
potionMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', customName));
|
||||
}
|
||||
|
||||
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||
@@ -235,9 +247,9 @@ public class FishingTreasureConfig extends BukkitConfig {
|
||||
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
||||
}
|
||||
itemMeta.setLore(lore);
|
||||
potionMeta.setLore(lore);
|
||||
}
|
||||
item.setItemMeta(itemMeta);
|
||||
item.setItemMeta(potionMeta);
|
||||
}
|
||||
} else if (material == Material.ENCHANTED_BOOK) {
|
||||
//If any whitelisted enchants exist we use whitelist-based matching
|
||||
@@ -355,7 +367,8 @@ public class FishingTreasureConfig extends BukkitConfig {
|
||||
Enchantment enchantment = EnchantmentUtils.getByName(enchantmentName);
|
||||
|
||||
if (enchantment == null) {
|
||||
mcMMO.p.getLogger().warning("Skipping invalid enchantment in " + FILENAME + ": " + enchantmentName);
|
||||
mcMMO.p.getLogger().info("Skipping invalid enchantment in '" + FILENAME + "', named:"
|
||||
+ enchantmentName);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.LogUtils;
|
||||
import com.gmail.nossr50.util.PotionUtil;
|
||||
import com.gmail.nossr50.util.text.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -14,7 +15,6 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -165,22 +165,33 @@ public class TreasureConfig extends BukkitConfig {
|
||||
Material mat = Material.matchMaterial(materialName);
|
||||
if (mat == null) {
|
||||
reason.add("Potion format for " + FILENAME + " has changed");
|
||||
continue;
|
||||
} else {
|
||||
item = new ItemStack(mat, amount, data);
|
||||
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
|
||||
|
||||
PotionType potionType = null;
|
||||
try {
|
||||
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
||||
PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
|
||||
if (potionMeta == null) {
|
||||
mcMMO.p.getLogger().severe("Item meta when adding potion to treasure was null, contact the mcMMO devs!");
|
||||
reason.add("Item meta when adding potion to treasure was null, contact the mcMMO devs!");
|
||||
continue;
|
||||
}
|
||||
|
||||
String potionTypeStr;
|
||||
potionTypeStr = config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER");
|
||||
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
|
||||
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
|
||||
itemMeta.setBasePotionData(new PotionData(potionType, extended, upgraded));
|
||||
PotionType potionType = PotionUtil.matchPotionType(potionTypeStr, extended, upgraded);
|
||||
|
||||
if (potionType == null) {
|
||||
reason.add("Could not derive potion type from: " + potionTypeStr +", " + extended + ", " + upgraded);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set the base potion type
|
||||
// NOTE: extended/upgraded are ignored in 1.20.5 and later
|
||||
PotionUtil.setBasePotionType(potionMeta, potionType, extended, upgraded);
|
||||
|
||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
||||
potionMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
||||
}
|
||||
|
||||
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||
@@ -188,9 +199,9 @@ public class TreasureConfig extends BukkitConfig {
|
||||
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
||||
}
|
||||
itemMeta.setLore(lore);
|
||||
potionMeta.setLore(lore);
|
||||
}
|
||||
item.setItemMeta(itemMeta);
|
||||
item.setItemMeta(potionMeta);
|
||||
}
|
||||
} else if (material != null) {
|
||||
item = new ItemStack(material, amount, data);
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.logging.Logger;
|
||||
|
||||
public class DatabaseManagerFactory {
|
||||
private static Class<? extends DatabaseManager> customManager = null;
|
||||
public static final String MYSQL_DRIVER = "com.mysql.cj.jdbc.Driver";
|
||||
|
||||
public static DatabaseManager getDatabaseManager(@NotNull String userFilePath, @NotNull Logger logger, long purgeTime, int startingLevel) {
|
||||
if (customManager != null) {
|
||||
@@ -27,7 +28,7 @@ public class DatabaseManagerFactory {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Falling back on " + (mcMMO.p.getGeneralConfig().getUseMySQL() ? "SQL" : "Flatfile") + " database");
|
||||
}
|
||||
|
||||
return mcMMO.p.getGeneralConfig().getUseMySQL() ? new SQLDatabaseManager() : new FlatFileDatabaseManager(userFilePath, logger, purgeTime, startingLevel);
|
||||
return mcMMO.p.getGeneralConfig().getUseMySQL() ? new SQLDatabaseManager(logger, MYSQL_DRIVER) : new FlatFileDatabaseManager(userFilePath, logger, purgeTime, startingLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,7 +69,7 @@ public class DatabaseManagerFactory {
|
||||
|
||||
case SQL:
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Using SQL Database");
|
||||
return new SQLDatabaseManager();
|
||||
return new SQLDatabaseManager(logger, "com.mysql.cj.jdbc.Driver");
|
||||
|
||||
case CUSTOM:
|
||||
try {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class FlatFileDataProcessor {
|
||||
assert !lineData.isEmpty();
|
||||
|
||||
//Make sure the data line is "correct"
|
||||
if(lineData.charAt(lineData.length() - 1) != ':') {
|
||||
if (lineData.charAt(lineData.length() - 1) != ':') {
|
||||
// Length checks depend on last rawSplitData being ':'
|
||||
// We add it here if it is missing
|
||||
lineData = lineData.concat(":");
|
||||
@@ -48,9 +48,9 @@ public class FlatFileDataProcessor {
|
||||
boolean anyBadData = false;
|
||||
|
||||
//This is the minimum size of the split array needed to be considered proper data
|
||||
if(splitDataLine.length < getMinimumSplitDataLength()) {
|
||||
if (splitDataLine.length < getMinimumSplitDataLength()) {
|
||||
//Data is considered junk
|
||||
if(!corruptDataFound) {
|
||||
if (!corruptDataFound) {
|
||||
logger.severe("Some corrupt data was found in mcmmo.users and has been repaired, it is possible that some player data has been lost in this process.");
|
||||
corruptDataFound = true;
|
||||
}
|
||||
@@ -59,9 +59,9 @@ public class FlatFileDataProcessor {
|
||||
builder.appendFlag(FlatFileDataFlag.CORRUPTED_OR_UNRECOGNIZABLE);
|
||||
|
||||
//TODO: This block here is probably pointless
|
||||
if(splitDataLine.length >= 10 //The value here is kind of arbitrary, it shouldn't be too low to avoid false positives, but also we aren't really going to correctly identify when player data has been corrupted or not with 100% accuracy ever
|
||||
if (splitDataLine.length >= 10 //The value here is kind of arbitrary, it shouldn't be too low to avoid false positives, but also we aren't really going to correctly identify when player data has been corrupted or not with 100% accuracy ever
|
||||
&& splitDataLine[0] != null && !splitDataLine[0].isEmpty()) {
|
||||
if(splitDataLine[0].length() <= 16 && splitDataLine[0].length() >= 3) {
|
||||
if (splitDataLine[0].length() <= 16 && splitDataLine[0].length() >= 3) {
|
||||
logger.severe("Not enough data found to recover corrupted player data for user: "+splitDataLine[0]);
|
||||
registerData(builder.appendFlag(FlatFileDataFlag.TOO_INCOMPLETE));
|
||||
return;
|
||||
@@ -81,14 +81,14 @@ public class FlatFileDataProcessor {
|
||||
String name = splitDataLine[USERNAME_INDEX];
|
||||
String strOfUUID = splitDataLine[UUID_INDEX];
|
||||
|
||||
if(name.isEmpty()) {
|
||||
if (name.isEmpty()) {
|
||||
reportBadDataLine("No name found for data", "[MISSING NAME]", lineData);
|
||||
builder.appendFlag(FlatFileDataFlag.MISSING_NAME);
|
||||
anyBadData = true;
|
||||
badDataValues[USERNAME_INDEX] = true;
|
||||
}
|
||||
|
||||
if(strOfUUID.isEmpty() || strOfUUID.equalsIgnoreCase("NULL")) {
|
||||
if (strOfUUID.isEmpty() || strOfUUID.equalsIgnoreCase("NULL")) {
|
||||
invalidUUID = true;
|
||||
badDataValues[UUID_INDEX] = true;
|
||||
reportBadDataLine("Empty/null UUID for user", "Empty/null", lineData);
|
||||
@@ -110,20 +110,20 @@ public class FlatFileDataProcessor {
|
||||
}
|
||||
|
||||
//Duplicate UUID is no good, reject them
|
||||
if(!invalidUUID && uuid != null && uuids.contains(uuid)) {
|
||||
if (!invalidUUID && uuid != null && uuids.contains(uuid)) {
|
||||
registerData(builder.appendFlag(FlatFileDataFlag.DUPLICATE_UUID));
|
||||
return;
|
||||
}
|
||||
|
||||
uuids.add(uuid);
|
||||
|
||||
if(names.contains(name)) {
|
||||
if (names.contains(name)) {
|
||||
builder.appendFlag(FlatFileDataFlag.DUPLICATE_NAME);
|
||||
anyBadData = true;
|
||||
badDataValues[USERNAME_INDEX] = true;
|
||||
}
|
||||
|
||||
if(!name.isEmpty())
|
||||
if (!name.isEmpty())
|
||||
names.add(name);
|
||||
|
||||
//Make sure the data is up to date schema wise, if it isn't we adjust it to the correct size and flag it for repair
|
||||
@@ -136,9 +136,9 @@ public class FlatFileDataProcessor {
|
||||
|
||||
//Check each data for bad values
|
||||
for(int i = 0; i < DATA_ENTRY_COUNT; i++) {
|
||||
if(shouldNotBeEmpty(splitDataLine[i], i)) {
|
||||
if (shouldNotBeEmpty(splitDataLine[i], i)) {
|
||||
|
||||
if(i == OVERHAUL_LAST_LOGIN) {
|
||||
if (i == OVERHAUL_LAST_LOGIN) {
|
||||
builder.appendFlag(FlatFileDataFlag.LAST_LOGIN_SCHEMA_UPGRADE);
|
||||
}
|
||||
|
||||
@@ -149,13 +149,13 @@ public class FlatFileDataProcessor {
|
||||
|
||||
boolean isCorrectType = isOfExpectedType(splitDataLine[i], getExpectedValueType(i));
|
||||
|
||||
if(!isCorrectType) {
|
||||
if (!isCorrectType) {
|
||||
anyBadData = true;
|
||||
badDataValues[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(anyBadData) {
|
||||
if (anyBadData) {
|
||||
builder.appendFlag(FlatFileDataFlag.BAD_VALUES);
|
||||
builder.appendBadDataValues(badDataValues);
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class FlatFileDataProcessor {
|
||||
public @NotNull String[] isDataSchemaUpToDate(@NotNull String[] splitDataLine, @NotNull FlatFileDataBuilder builder, boolean[] badDataValues) {
|
||||
assert splitDataLine.length <= DATA_ENTRY_COUNT; //should NEVER be higher
|
||||
|
||||
if(splitDataLine.length < DATA_ENTRY_COUNT) {
|
||||
if (splitDataLine.length < DATA_ENTRY_COUNT) {
|
||||
int oldLength = splitDataLine.length;
|
||||
splitDataLine = Arrays.copyOf(splitDataLine, DATA_ENTRY_COUNT);
|
||||
int newLength = splitDataLine.length;
|
||||
@@ -184,7 +184,7 @@ public class FlatFileDataProcessor {
|
||||
|
||||
|
||||
public boolean shouldNotBeEmpty(@Nullable String data, int index) {
|
||||
if(getExpectedValueType(index) == ExpectedType.IGNORED) {
|
||||
if (getExpectedValueType(index) == ExpectedType.IGNORED) {
|
||||
return false;
|
||||
} else {
|
||||
return data == null || data.isEmpty();
|
||||
@@ -248,66 +248,31 @@ public class FlatFileDataProcessor {
|
||||
FlatFileDataContainer flatFileDataContainer = builder.build();
|
||||
flatFileDataContainers.add(flatFileDataContainer);
|
||||
|
||||
if(flatFileDataContainer.getDataFlags() != null)
|
||||
if (flatFileDataContainer.getDataFlags() != null)
|
||||
flatFileDataFlags.addAll(flatFileDataContainer.getDataFlags());
|
||||
}
|
||||
|
||||
public static @NotNull ExpectedType getExpectedValueType(int dataIndex) throws IndexOutOfBoundsException {
|
||||
switch(dataIndex) {
|
||||
case USERNAME_INDEX:
|
||||
return ExpectedType.STRING;
|
||||
case 2: //Assumption: Used to be for something, no longer used
|
||||
case 3: //Assumption: Used to be for something, no longer used
|
||||
case 23: //Assumption: Used to be used for something, no longer used
|
||||
case 33: //Assumption: Used to be used for something, no longer used
|
||||
case HEALTHBAR:
|
||||
case LEGACY_LAST_LOGIN:
|
||||
return ExpectedType.IGNORED;
|
||||
case SKILLS_MINING:
|
||||
case SKILLS_REPAIR:
|
||||
case SKILLS_UNARMED:
|
||||
case SKILLS_HERBALISM:
|
||||
case SKILLS_EXCAVATION:
|
||||
case SKILLS_ARCHERY:
|
||||
case SKILLS_SWORDS:
|
||||
case SKILLS_AXES:
|
||||
case SKILLS_WOODCUTTING:
|
||||
case SKILLS_ACROBATICS:
|
||||
case SKILLS_TAMING:
|
||||
case SKILLS_FISHING:
|
||||
case SKILLS_ALCHEMY:
|
||||
case COOLDOWN_BERSERK:
|
||||
case COOLDOWN_GIGA_DRILL_BREAKER:
|
||||
case COOLDOWN_TREE_FELLER:
|
||||
case COOLDOWN_GREEN_TERRA:
|
||||
case COOLDOWN_SERRATED_STRIKES:
|
||||
case COOLDOWN_SKULL_SPLITTER:
|
||||
case COOLDOWN_SUPER_BREAKER:
|
||||
case COOLDOWN_BLAST_MINING:
|
||||
case SCOREBOARD_TIPS:
|
||||
case COOLDOWN_CHIMAERA_WING:
|
||||
return ExpectedType.INTEGER;
|
||||
case EXP_MINING:
|
||||
case EXP_WOODCUTTING:
|
||||
case EXP_REPAIR:
|
||||
case EXP_UNARMED:
|
||||
case EXP_HERBALISM:
|
||||
case EXP_EXCAVATION:
|
||||
case EXP_ARCHERY:
|
||||
case EXP_SWORDS:
|
||||
case EXP_AXES:
|
||||
case EXP_ACROBATICS:
|
||||
case EXP_TAMING:
|
||||
case EXP_FISHING:
|
||||
case EXP_ALCHEMY:
|
||||
return ExpectedType.FLOAT;
|
||||
case UUID_INDEX:
|
||||
return ExpectedType.UUID;
|
||||
case OVERHAUL_LAST_LOGIN:
|
||||
return ExpectedType.LONG;
|
||||
}
|
||||
|
||||
throw new IndexOutOfBoundsException();
|
||||
return switch (dataIndex) {
|
||||
case USERNAME_INDEX -> ExpectedType.STRING; //Assumption: Used to be for something, no longer used
|
||||
//Assumption: Used to be for something, no longer used
|
||||
//Assumption: Used to be used for something, no longer used
|
||||
//Assumption: Used to be used for something, no longer used
|
||||
case 2, 3, 23, 33, HEALTHBAR, LEGACY_LAST_LOGIN -> ExpectedType.IGNORED;
|
||||
case SKILLS_MINING, SKILLS_REPAIR, SKILLS_UNARMED, SKILLS_HERBALISM, SKILLS_EXCAVATION, SKILLS_ARCHERY,
|
||||
SKILLS_SWORDS, SKILLS_AXES, SKILLS_WOODCUTTING, SKILLS_ACROBATICS, SKILLS_TAMING, SKILLS_FISHING,
|
||||
SKILLS_ALCHEMY, SKILLS_CROSSBOWS, SKILLS_TRIDENTS, SKILLS_MACES, COOLDOWN_BERSERK,
|
||||
COOLDOWN_GIGA_DRILL_BREAKER, COOLDOWN_TREE_FELLER, COOLDOWN_GREEN_TERRA, COOLDOWN_SERRATED_STRIKES,
|
||||
COOLDOWN_SKULL_SPLITTER, COOLDOWN_SUPER_BREAKER, COOLDOWN_BLAST_MINING, SCOREBOARD_TIPS,
|
||||
COOLDOWN_CHIMAERA_WING, COOLDOWN_SUPER_SHOTGUN, COOLDOWN_TRIDENTS, COOLDOWN_ARCHERY, COOLDOWN_MACES ->
|
||||
ExpectedType.INTEGER;
|
||||
case EXP_MINING, EXP_WOODCUTTING, EXP_REPAIR, EXP_UNARMED, EXP_HERBALISM, EXP_EXCAVATION, EXP_ARCHERY,
|
||||
EXP_SWORDS, EXP_AXES, EXP_ACROBATICS, EXP_TAMING, EXP_FISHING, EXP_ALCHEMY, EXP_CROSSBOWS,
|
||||
EXP_TRIDENTS, EXP_MACES -> ExpectedType.FLOAT;
|
||||
case UUID_INDEX -> ExpectedType.UUID;
|
||||
case OVERHAUL_LAST_LOGIN -> ExpectedType.LONG;
|
||||
default -> throw new IndexOutOfBoundsException();
|
||||
};
|
||||
}
|
||||
|
||||
public @NotNull List<FlatFileDataContainer> getFlatFileDataContainers() {
|
||||
@@ -330,12 +295,12 @@ public class FlatFileDataProcessor {
|
||||
for(FlatFileDataContainer dataContainer : flatFileDataContainers) {
|
||||
String[] splitData = FlatFileDataUtil.getPreparedSaveDataLine(dataContainer);
|
||||
|
||||
if(splitData == null)
|
||||
if (splitData == null)
|
||||
continue;
|
||||
|
||||
//We add a trailing : as it is needed for some reason (is it?)
|
||||
//TODO: Is the trailing ":" actually necessary?
|
||||
String fromSplit = org.apache.commons.lang.StringUtils.join(splitData, ":") + ":";
|
||||
String fromSplit = org.apache.commons.lang3.StringUtils.join(splitData, ":") + ":";
|
||||
stringBuilder.append(fromSplit).append("\r\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -80,10 +80,20 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
public static final int SCOREBOARD_TIPS = 42;
|
||||
public static final int COOLDOWN_CHIMAERA_WING = 43;
|
||||
public static final int OVERHAUL_LAST_LOGIN = 44;
|
||||
public static final int EXP_CROSSBOWS = 45;
|
||||
public static final int SKILLS_CROSSBOWS = 46;
|
||||
public static final int EXP_TRIDENTS = 47;
|
||||
public static final int SKILLS_TRIDENTS = 48;
|
||||
public static final int COOLDOWN_SUPER_SHOTGUN = 49;
|
||||
public static final int COOLDOWN_TRIDENTS = 50;
|
||||
public static final int COOLDOWN_ARCHERY = 51;
|
||||
public static final int EXP_MACES = 52;
|
||||
public static final int SKILLS_MACES = 53;
|
||||
public static final int COOLDOWN_MACES = 54;
|
||||
//Update this everytime new data is added
|
||||
public static final int DATA_ENTRY_COUNT = COOLDOWN_MACES + 1;
|
||||
|
||||
public static final int DATA_ENTRY_COUNT = OVERHAUL_LAST_LOGIN + 1; //Update this everytime new data is added
|
||||
|
||||
protected FlatFileDatabaseManager(@NotNull File usersFile, @NotNull Logger logger, long purgeTime, int startingLevel, boolean testing) {
|
||||
FlatFileDatabaseManager(@NotNull File usersFile, @NotNull Logger logger, long purgeTime, int startingLevel, boolean testing) {
|
||||
this.usersFile = usersFile;
|
||||
this.usersFilePath = usersFile.getPath();
|
||||
this.logger = logger;
|
||||
@@ -91,15 +101,15 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
this.startingLevel = startingLevel;
|
||||
this.testing = testing;
|
||||
|
||||
if(!usersFile.exists()) {
|
||||
if (!usersFile.exists()) {
|
||||
initEmptyDB();
|
||||
}
|
||||
|
||||
if(!testing) {
|
||||
if (!testing) {
|
||||
List<FlatFileDataFlag> flatFileDataFlags = checkFileHealthAndStructure();
|
||||
|
||||
if(flatFileDataFlags != null) {
|
||||
if(flatFileDataFlags.size() > 0) {
|
||||
if (flatFileDataFlags != null) {
|
||||
if (!flatFileDataFlags.isEmpty()) {
|
||||
logger.info("Detected "+flatFileDataFlags.size() + " data entries which need correction.");
|
||||
}
|
||||
}
|
||||
@@ -108,7 +118,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
protected FlatFileDatabaseManager(@NotNull String usersFilePath, @NotNull Logger logger, long purgeTime, int startingLevel) {
|
||||
FlatFileDatabaseManager(@NotNull String usersFilePath, @NotNull Logger logger, long purgeTime, int startingLevel) {
|
||||
this(new File(usersFilePath), logger, purgeTime, startingLevel, false);
|
||||
}
|
||||
|
||||
@@ -142,8 +152,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
// If they're still around, rewrite them to the file.
|
||||
if (!powerless) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
purgedUsers++;
|
||||
}
|
||||
}
|
||||
@@ -212,7 +221,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
if (lastPlayed == -1) {
|
||||
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(uuid);
|
||||
|
||||
if(player.getLastPlayed() != 0) {
|
||||
if (player.getLastPlayed() != 0) {
|
||||
lastPlayed = player.getLastPlayed();
|
||||
rewrite = true;
|
||||
}
|
||||
@@ -224,7 +233,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
if (rewrite) {
|
||||
// Rewrite their data with a valid time
|
||||
character[OVERHAUL_LAST_LOGIN] = Long.toString(lastPlayed);
|
||||
String newLine = org.apache.commons.lang.StringUtils.join(character, ":");
|
||||
String newLine = org.apache.commons.lang3.StringUtils.join(character, ":");
|
||||
writer.append(newLine).append("\r\n");
|
||||
} else {
|
||||
writer.append(line).append("\r\n");
|
||||
@@ -236,8 +245,8 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
out = new FileWriter(usersFilePath);
|
||||
out.write(writer.toString());
|
||||
|
||||
if(testing) {
|
||||
System.out.println(writer.toString());
|
||||
if (testing) {
|
||||
System.out.println(writer);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
@@ -344,15 +353,15 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
boolean wroteUser = false;
|
||||
// While not at the end of the file
|
||||
while ((line = in.readLine()) != null) {
|
||||
if(line.startsWith("#")) {
|
||||
if (line.startsWith("#")) {
|
||||
writer.append(line).append("\r\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
//Check for incomplete or corrupted data
|
||||
if(!line.contains(":")) {
|
||||
if (!line.contains(":")) {
|
||||
|
||||
if(!corruptDataFound) {
|
||||
if (!corruptDataFound) {
|
||||
logger.severe("mcMMO found some unexpected or corrupted data in mcmmo.users and is removing it, it is possible some data has been lost.");
|
||||
corruptDataFound = true;
|
||||
}
|
||||
@@ -363,9 +372,9 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
String[] splitData = line.split(":");
|
||||
|
||||
//This would be rare, but check the splitData for having enough entries to contain a UUID
|
||||
if(splitData.length < UUID_INDEX) { //UUID have been in mcMMO DB for a very long time so any user without
|
||||
if (splitData.length < UUID_INDEX) { //UUID have been in mcMMO DB for a very long time so any user without
|
||||
|
||||
if(!corruptDataFound) {
|
||||
if (!corruptDataFound) {
|
||||
logger.severe("mcMMO found some unexpected or corrupted data in mcmmo.users and is removing it, it is possible some data has been lost.");
|
||||
corruptDataFound = true;
|
||||
}
|
||||
@@ -387,7 +396,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
/*
|
||||
* If we couldn't find the user in the DB we need to add him
|
||||
*/
|
||||
if(!wroteUser) {
|
||||
if (!wroteUser) {
|
||||
writeUserToLine(profile, writer);
|
||||
}
|
||||
|
||||
@@ -467,12 +476,28 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
appendable.append(String.valueOf(profile.getScoreboardTipsShown())).append(":");
|
||||
appendable.append(String.valueOf(profile.getUniqueData(UniqueDataType.CHIMAERA_WING_DATS))).append(":");
|
||||
appendable.append(String.valueOf(profile.getLastLogin())).append(":"); //overhaul last login
|
||||
appendable.append(String.valueOf(profile.getSkillXpLevel(PrimarySkillType.CROSSBOWS))).append(":");
|
||||
appendable.append(String.valueOf(profile.getSkillLevel(PrimarySkillType.CROSSBOWS))).append(":");
|
||||
appendable.append(String.valueOf(profile.getSkillXpLevel(PrimarySkillType.TRIDENTS))).append(":");
|
||||
appendable.append(String.valueOf(profile.getSkillLevel(PrimarySkillType.TRIDENTS))).append(":");
|
||||
// public static final int COOLDOWN_SUPER_SHOTGUN = 49;
|
||||
appendable.append(String.valueOf(profile.getAbilityDATS(SuperAbilityType.SUPER_SHOTGUN))).append(":");
|
||||
// public static final int COOLDOWN_TRIDENTS = 50;
|
||||
appendable.append(String.valueOf(profile.getAbilityDATS(SuperAbilityType.TRIDENTS_SUPER_ABILITY))).append(":");
|
||||
// public static final int COOLDOWN_ARCHERY = 51;
|
||||
appendable.append(String.valueOf(profile.getAbilityDATS(SuperAbilityType.EXPLOSIVE_SHOT))).append(":");
|
||||
// public static final int EXP_MACES = 52;
|
||||
appendable.append(String.valueOf(profile.getSkillXpLevel(PrimarySkillType.MACES))).append(":");
|
||||
// public static final int SKILLS_MACES = 53;
|
||||
appendable.append(String.valueOf(profile.getSkillLevel(PrimarySkillType.MACES))).append(":");
|
||||
// public static final int COOLDOWN_MACES = 54;
|
||||
appendable.append(String.valueOf(profile.getAbilityDATS(SuperAbilityType.MACES_SUPER_ABILITY))).append(":");
|
||||
appendable.append("\r\n");
|
||||
}
|
||||
|
||||
public @NotNull List<PlayerStat> readLeaderboard(@Nullable PrimarySkillType primarySkillType, int pageNumber, int statsPerPage) throws InvalidSkillException {
|
||||
//Fix for a plugin that people are using that is throwing SQL errors
|
||||
if(primarySkillType != null && SkillTools.isChildSkill(primarySkillType)) {
|
||||
if (primarySkillType != null && SkillTools.isChildSkill(primarySkillType)) {
|
||||
logger.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!");
|
||||
}
|
||||
@@ -546,11 +571,11 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
private @NotNull UserQuery getUserQuery(@Nullable UUID uuid, @Nullable String playerName) throws NullPointerException {
|
||||
boolean hasName = playerName != null && !playerName.equalsIgnoreCase("null");
|
||||
|
||||
if(hasName && uuid != null) {
|
||||
if (hasName && uuid != null) {
|
||||
return new UserQueryFull(playerName, uuid);
|
||||
} else if (uuid != null) {
|
||||
return new UserQueryUUIDImpl(uuid);
|
||||
} else if(hasName) {
|
||||
} else if (hasName) {
|
||||
return new UserQueryNameImpl(playerName);
|
||||
} else {
|
||||
throw new NullPointerException("Both name and UUID cannot be null, at least one must be non-null!");
|
||||
@@ -565,16 +590,11 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
* @return a profile with the targets data or an unloaded profile if no data was found
|
||||
*/
|
||||
private @NotNull PlayerProfile processUserQuery(@NotNull UserQuery userQuery) throws RuntimeException {
|
||||
switch(userQuery.getType()) {
|
||||
case UUID_AND_NAME:
|
||||
return queryByUUIDAndName((UserQueryFull) userQuery);
|
||||
case UUID:
|
||||
return queryByUUID((UserQueryUUID) userQuery);
|
||||
case NAME:
|
||||
return queryByName((UserQueryNameImpl) userQuery);
|
||||
default:
|
||||
throw new RuntimeException("No case for this UserQueryType!");
|
||||
}
|
||||
return switch (userQuery.getType()) {
|
||||
case UUID_AND_NAME -> queryByUUIDAndName((UserQueryFull) userQuery);
|
||||
case UUID -> queryByUUID((UserQueryUUID) userQuery);
|
||||
case NAME -> queryByName((UserQueryNameImpl) userQuery);
|
||||
};
|
||||
}
|
||||
|
||||
private @NotNull PlayerProfile queryByName(@NotNull UserQueryName userQuery) {
|
||||
@@ -589,7 +609,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
if(line.startsWith("#")) {
|
||||
if (line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -599,13 +619,12 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
|
||||
|
||||
/* Don't read corrupt data */
|
||||
if(rawSplitData.length < (USERNAME_INDEX + 1)) {
|
||||
if (rawSplitData.length < (USERNAME_INDEX + 1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//If we couldn't find anyone
|
||||
if(playerName.equalsIgnoreCase(rawSplitData[USERNAME_INDEX])) {
|
||||
// we found the player
|
||||
if (playerName.equalsIgnoreCase(rawSplitData[USERNAME_INDEX])) {
|
||||
return loadFromLine(rawSplitData);
|
||||
}
|
||||
}
|
||||
@@ -640,24 +659,24 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
String line;
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
if(line.startsWith("#")) {
|
||||
if (line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
// Find if the line contains the player we want.
|
||||
String[] rawSplitData = line.split(":");
|
||||
|
||||
/* Don't read corrupt data */
|
||||
if(rawSplitData.length < (UUID_INDEX + 1)) {
|
||||
if (rawSplitData.length < (UUID_INDEX + 1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
UUID fromDataUUID = UUID.fromString(rawSplitData[UUID_INDEX]);
|
||||
if(fromDataUUID.equals(uuid)) {
|
||||
if (fromDataUUID.equals(uuid)) {
|
||||
return loadFromLine(rawSplitData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if(testing) {
|
||||
if (testing) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -681,7 +700,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
* No match was found in the file
|
||||
*/
|
||||
|
||||
return grabUnloadedProfile(uuid, "Player-Not-Found="+uuid.toString());
|
||||
return grabUnloadedProfile(uuid, "Player-Not-Found="+ uuid);
|
||||
}
|
||||
|
||||
private @NotNull PlayerProfile queryByUUIDAndName(@NotNull UserQueryFull userQuery) {
|
||||
@@ -696,27 +715,27 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
String line;
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
if(line.startsWith("#")) {
|
||||
if (line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
// Find if the line contains the player we want.
|
||||
String[] rawSplitData = line.split(":");
|
||||
|
||||
/* Don't read corrupt data */
|
||||
if(rawSplitData.length < (UUID_INDEX + 1)) {
|
||||
if (rawSplitData.length < (UUID_INDEX + 1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
UUID fromDataUUID = UUID.fromString(rawSplitData[UUID_INDEX]);
|
||||
if(fromDataUUID.equals(uuid)) {
|
||||
if (fromDataUUID.equals(uuid)) {
|
||||
//Matched UUID, now check if name matches
|
||||
String dbPlayerName = rawSplitData[USERNAME_INDEX];
|
||||
|
||||
boolean matchingName = dbPlayerName.equalsIgnoreCase(playerName);
|
||||
|
||||
if (!matchingName) {
|
||||
logger.warning("When loading user: "+playerName +" with UUID of (" + uuid.toString()
|
||||
logger.warning("When loading user: "+playerName +" with UUID of (" + uuid
|
||||
+") we found a mismatched name, the name in the DB will be replaced (DB name: "+dbPlayerName+")");
|
||||
//logger.info("Name updated for player: " + rawSplitData[USERNAME_INDEX] + " => " + playerName);
|
||||
rawSplitData[USERNAME_INDEX] = playerName;
|
||||
@@ -726,7 +745,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
return loadFromLine(rawSplitData);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if(testing) {
|
||||
if (testing) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -754,7 +773,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
private @NotNull PlayerProfile grabUnloadedProfile(@NotNull UUID uuid, @Nullable String playerName) {
|
||||
if(playerName == null) {
|
||||
if (playerName == null) {
|
||||
playerName = ""; //No name for you boy!
|
||||
}
|
||||
|
||||
@@ -773,7 +792,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
String line;
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
if(line.startsWith("#")) {
|
||||
if (line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -885,7 +904,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
character[UUID_INDEX] = fetchedUUIDs.remove(character[USERNAME_INDEX]).toString();
|
||||
line = org.apache.commons.lang.StringUtils.join(character, ":") + ":";
|
||||
line = org.apache.commons.lang3.StringUtils.join(character, ":") + ":";
|
||||
}
|
||||
|
||||
i++;
|
||||
@@ -980,6 +999,9 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
List<PlayerStat> taming = new ArrayList<>();
|
||||
List<PlayerStat> fishing = new ArrayList<>();
|
||||
List<PlayerStat> alchemy = new ArrayList<>();
|
||||
List<PlayerStat> crossbows = new ArrayList<>();
|
||||
List<PlayerStat> tridents = new ArrayList<>();
|
||||
List<PlayerStat> maces = new ArrayList<>();
|
||||
|
||||
BufferedReader in = null;
|
||||
String playerName = null;
|
||||
@@ -991,7 +1013,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
|
||||
if(line.startsWith("#"))
|
||||
if (line.startsWith("#"))
|
||||
continue;
|
||||
|
||||
String[] data = line.split(":");
|
||||
@@ -1013,6 +1035,9 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
powerLevel += putStat(taming, playerName, skills.get(PrimarySkillType.TAMING));
|
||||
powerLevel += putStat(unarmed, playerName, skills.get(PrimarySkillType.UNARMED));
|
||||
powerLevel += putStat(woodcutting, playerName, skills.get(PrimarySkillType.WOODCUTTING));
|
||||
powerLevel += putStat(crossbows, playerName, skills.get(PrimarySkillType.CROSSBOWS));
|
||||
powerLevel += putStat(tridents, playerName, skills.get(PrimarySkillType.TRIDENTS));
|
||||
powerLevel += putStat(maces, playerName, skills.get(PrimarySkillType.MACES));
|
||||
|
||||
putStat(powerLevels, playerName, powerLevel);
|
||||
}
|
||||
@@ -1048,6 +1073,9 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
taming.sort(c);
|
||||
fishing.sort(c);
|
||||
alchemy.sort(c);
|
||||
crossbows.sort(c);
|
||||
tridents.sort(c);
|
||||
maces.sort(c);
|
||||
powerLevels.sort(c);
|
||||
|
||||
playerStatHash.put(PrimarySkillType.MINING, mining);
|
||||
@@ -1063,6 +1091,9 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
playerStatHash.put(PrimarySkillType.TAMING, taming);
|
||||
playerStatHash.put(PrimarySkillType.FISHING, fishing);
|
||||
playerStatHash.put(PrimarySkillType.ALCHEMY, alchemy);
|
||||
playerStatHash.put(PrimarySkillType.CROSSBOWS, crossbows);
|
||||
playerStatHash.put(PrimarySkillType.TRIDENTS, tridents);
|
||||
playerStatHash.put(PrimarySkillType.MACES, maces);
|
||||
|
||||
return LeaderboardStatus.UPDATED;
|
||||
}
|
||||
@@ -1094,7 +1125,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
public @Nullable List<FlatFileDataFlag> checkFileHealthAndStructure() {
|
||||
ArrayList<FlatFileDataFlag> flagsFound = null;
|
||||
LogUtils.debug(logger, "(" + usersFile.getPath() + ") Validating database file..");
|
||||
FlatFileDataProcessor dataProcessor = null;
|
||||
FlatFileDataProcessor dataProcessor;
|
||||
|
||||
if (usersFile.exists()) {
|
||||
BufferedReader bufferedReader = null;
|
||||
@@ -1113,12 +1144,12 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
//Analyze the data
|
||||
while ((currentLine = bufferedReader.readLine()) != null) {
|
||||
//Commented lines
|
||||
if(currentLine.startsWith("#") && dbCommentDate == null) { //The first commented line in the file is likely to be our note about when the file was created
|
||||
if (currentLine.startsWith("#") && dbCommentDate == null) { //The first commented line in the file is likely to be our note about when the file was created
|
||||
dbCommentDate = currentLine;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(currentLine.isEmpty())
|
||||
if (currentLine.isEmpty())
|
||||
continue;
|
||||
|
||||
//TODO: We are never passing empty lines, should we remove the flag for them?
|
||||
@@ -1126,12 +1157,12 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
//Only update the file if needed
|
||||
if(dataProcessor.getFlatFileDataFlags().size() > 0) {
|
||||
if (!dataProcessor.getFlatFileDataFlags().isEmpty()) {
|
||||
flagsFound = new ArrayList<>(dataProcessor.getFlatFileDataFlags());
|
||||
logger.info("Updating FlatFile Database...");
|
||||
fileWriter = new FileWriter(usersFilePath);
|
||||
//Write data to file
|
||||
if(dbCommentDate != null)
|
||||
if (dbCommentDate != null)
|
||||
fileWriter.write(dbCommentDate + "\r\n");
|
||||
|
||||
fileWriter.write(dataProcessor.processDataForSave().toString());
|
||||
@@ -1144,7 +1175,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
if(flagsFound == null || flagsFound.size() == 0) {
|
||||
if (flagsFound == null || flagsFound.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return flagsFound;
|
||||
@@ -1152,7 +1183,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
private void closeResources(BufferedReader bufferedReader, FileWriter fileWriter) {
|
||||
if(bufferedReader != null) {
|
||||
if (bufferedReader != null) {
|
||||
try {
|
||||
bufferedReader.close();
|
||||
}
|
||||
@@ -1224,6 +1255,9 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.ACROBATICS, EXP_ACROBATICS, username);
|
||||
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.FISHING, EXP_FISHING, username);
|
||||
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.ALCHEMY, EXP_ALCHEMY, username);
|
||||
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.CROSSBOWS, EXP_CROSSBOWS, username);
|
||||
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.TRIDENTS, EXP_TRIDENTS, username);
|
||||
tryLoadSkillFloatValuesFromRawData(skillsXp, character, PrimarySkillType.MACES, EXP_MACES, username);
|
||||
|
||||
// Taming - Unused
|
||||
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.SUPER_BREAKER, COOLDOWN_SUPER_BREAKER, username);
|
||||
@@ -1232,11 +1266,14 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.BERSERK, COOLDOWN_BERSERK, username);
|
||||
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.GREEN_TERRA, COOLDOWN_GREEN_TERRA, username);
|
||||
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.GIGA_DRILL_BREAKER, COOLDOWN_GIGA_DRILL_BREAKER, username);
|
||||
// Archery - Unused
|
||||
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.EXPLOSIVE_SHOT, COOLDOWN_ARCHERY, username);
|
||||
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.SERRATED_STRIKES, COOLDOWN_SERRATED_STRIKES, username);
|
||||
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.SKULL_SPLITTER, COOLDOWN_SKULL_SPLITTER, username);
|
||||
// Acrobatics - Unused
|
||||
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.BLAST_MINING, COOLDOWN_BLAST_MINING, username);
|
||||
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.SUPER_SHOTGUN, COOLDOWN_SUPER_SHOTGUN, username);
|
||||
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.TRIDENTS_SUPER_ABILITY, COOLDOWN_TRIDENTS, username);
|
||||
tryLoadSkillCooldownFromRawData(skillsDATS, character, SuperAbilityType.MACES_SUPER_ABILITY, COOLDOWN_MACES, username);
|
||||
|
||||
UUID uuid;
|
||||
try {
|
||||
@@ -1269,12 +1306,15 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
return new PlayerProfile(username, uuid, skills, skillsXp, skillsDATS, scoreboardTipsShown, uniquePlayerDataMap, lastLogin);
|
||||
}
|
||||
|
||||
private void tryLoadSkillCooldownFromRawData(@NotNull Map<SuperAbilityType, Integer> cooldownMap, @NotNull String[] character, @NotNull SuperAbilityType superAbilityType, int cooldownSuperBreaker, @NotNull String userName) {
|
||||
private void tryLoadSkillCooldownFromRawData(@NotNull Map<SuperAbilityType, Integer> cooldownMap, @NotNull String[] splitData, @NotNull SuperAbilityType superAbilityType, int index, @NotNull String userName) {
|
||||
try {
|
||||
cooldownMap.put(superAbilityType, Integer.valueOf(character[cooldownSuperBreaker]));
|
||||
cooldownMap.put(superAbilityType, Integer.valueOf(splitData[index]));
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
// TODO: Add debug message
|
||||
// set to 0 when data not found
|
||||
cooldownMap.put(superAbilityType, 0);
|
||||
} catch (NumberFormatException e) {
|
||||
logger.severe("Data corruption when trying to load the value for skill "+superAbilityType+" for player named " + userName+ " setting value to zero");
|
||||
e.printStackTrace();
|
||||
throw new NumberFormatException("Data corruption when trying to load the cooldown for skill "+superAbilityType+" for player named " + userName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1293,6 +1333,10 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
int valueFromString = Integer.parseInt(character[index]);
|
||||
skillMap.put(primarySkillType, valueFromString);
|
||||
} catch (ArrayIndexOutOfBoundsException e ) {
|
||||
// TODO: Add debug message
|
||||
// set to 0 when data not found
|
||||
skillMap.put(primarySkillType, 0);
|
||||
} catch (NumberFormatException e) {
|
||||
skillMap.put(primarySkillType, 0);
|
||||
logger.severe("Data corruption when trying to load the value for skill "+primarySkillType+" for player named " + userName+ " setting value to zero");
|
||||
@@ -1317,6 +1361,9 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.AXES, SKILLS_AXES, username);
|
||||
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.FISHING, SKILLS_FISHING, username);
|
||||
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.ALCHEMY, SKILLS_ALCHEMY, username);
|
||||
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.CROSSBOWS, SKILLS_CROSSBOWS, username);
|
||||
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.TRIDENTS, SKILLS_TRIDENTS, username);
|
||||
tryLoadSkillIntValuesFromRawData(skills, character, PrimarySkillType.MACES, SKILLS_MACES, username);
|
||||
|
||||
return skills;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public final class SQLDatabaseManager implements DatabaseManager {
|
||||
private static final String ALL_QUERY_VERSION = "total";
|
||||
@@ -32,6 +33,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
public static final String USER_VARCHAR = "VARCHAR(40)";
|
||||
public static final int CHILD_SKILLS_SIZE = 2;
|
||||
public static final String LEGACY_DRIVER_PATH = "com.mysql.jdbc.Driver";
|
||||
public static final int MAGIC_NUMBER = 44;
|
||||
private final String tablePrefix = mcMMO.p.getGeneralConfig().getMySQLTablePrefix();
|
||||
|
||||
private final Map<UUID, Integer> cachedUserIDs = new HashMap<>();
|
||||
@@ -45,23 +47,19 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
private final ReentrantLock massUpdateLock = new ReentrantLock();
|
||||
|
||||
private final String CHARSET_SQL = "utf8mb4"; //This is compliant with UTF-8 while "utf8" is not, confusing but this is how it is.
|
||||
private String driverPath = "com.mysql.cj.jdbc.Driver"; //modern driver
|
||||
private final Logger logger;
|
||||
private final boolean h2;
|
||||
|
||||
protected SQLDatabaseManager() {
|
||||
String connectionString = "jdbc:mysql://" + mcMMO.p.getGeneralConfig().getMySQLServerName()
|
||||
+ ":" + mcMMO.p.getGeneralConfig().getMySQLServerPort() + "/" + mcMMO.p.getGeneralConfig().getMySQLDatabaseName();
|
||||
SQLDatabaseManager(Logger logger, String driverPath) {
|
||||
this(logger, driverPath, false);
|
||||
}
|
||||
|
||||
if(!mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 17, 0) //Temporary hack for SQL and 1.17 support
|
||||
&& mcMMO.p.getGeneralConfig().getMySQLSSL())
|
||||
connectionString +=
|
||||
"?verifyServerCertificate=false"+
|
||||
"&useSSL=true"+
|
||||
"&requireSSL=true";
|
||||
else
|
||||
connectionString+=
|
||||
"?useSSL=false";
|
||||
SQLDatabaseManager(Logger logger, String driverPath, boolean h2) {
|
||||
this.logger = logger;
|
||||
this.h2 = h2;
|
||||
String connectionString = getConnectionString(h2);
|
||||
|
||||
if(mcMMO.p.getGeneralConfig().getMySQLPublicKeyRetrieval()) {
|
||||
if (!h2 && mcMMO.p.getGeneralConfig().getMySQLPublicKeyRetrieval()) {
|
||||
connectionString+=
|
||||
"&allowPublicKeyRetrieval=true";
|
||||
}
|
||||
@@ -76,7 +74,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
} catch (ClassNotFoundException ex) {
|
||||
e.printStackTrace();
|
||||
ex.printStackTrace();
|
||||
mcMMO.p.getLogger().severe("Neither driver found");
|
||||
logger.severe("Neither driver found");
|
||||
return;
|
||||
}
|
||||
//throw e; // aborts onEnable() Riking if you want to do this, fully implement it.
|
||||
@@ -133,9 +131,31 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
checkStructure();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getConnectionString(boolean h2) {
|
||||
if (h2) {
|
||||
return "jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=MySQL";
|
||||
}
|
||||
|
||||
String connectionString = "jdbc:mysql://" + mcMMO.p.getGeneralConfig().getMySQLServerName()
|
||||
+ ":" + mcMMO.p.getGeneralConfig().getMySQLServerPort() + "/" + mcMMO.p.getGeneralConfig().getMySQLDatabaseName();
|
||||
|
||||
if (!mcMMO.getCompatibilityManager().getMinecraftGameVersion().isAtLeast(1, 17, 0) //Temporary hack for SQL and 1.17 support
|
||||
&& mcMMO.p.getGeneralConfig().getMySQLSSL())
|
||||
connectionString +=
|
||||
"?verifyServerCertificate=false"+
|
||||
"&useSSL=true"+
|
||||
"&requireSSL=true";
|
||||
else
|
||||
connectionString+=
|
||||
"?useSSL=false";
|
||||
return connectionString;
|
||||
}
|
||||
|
||||
// TODO: unit tests
|
||||
public int purgePowerlessUsers() {
|
||||
massUpdateLock.lock();
|
||||
mcMMO.p.getLogger().info("Purging powerless users...");
|
||||
logger.info("Purging powerless users...");
|
||||
|
||||
Connection connection = null;
|
||||
Statement statement = null;
|
||||
@@ -149,7 +169,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "taming = 0 AND mining = 0 AND woodcutting = 0 AND repair = 0 "
|
||||
+ "AND unarmed = 0 AND herbalism = 0 AND excavation = 0 AND "
|
||||
+ "archery = 0 AND swords = 0 AND axes = 0 AND acrobatics = 0 "
|
||||
+ "AND fishing = 0 AND alchemy = 0;");
|
||||
+ "AND fishing = 0 AND alchemy = 0 AND crossbows = 0 AND tridents = 0 AND maces = 0;");
|
||||
|
||||
statement.executeUpdate("DELETE FROM `" + tablePrefix + "experience` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "skills` `s` WHERE `" + tablePrefix + "experience`.`user_id` = `s`.`user_id`)");
|
||||
statement.executeUpdate("DELETE FROM `" + tablePrefix + "huds` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "skills` `s` WHERE `" + tablePrefix + "huds`.`user_id` = `s`.`user_id`)");
|
||||
@@ -165,13 +185,13 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
massUpdateLock.unlock();
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Purged " + purged + " users from the database.");
|
||||
logger.info("Purged " + purged + " users from the database.");
|
||||
return purged;
|
||||
}
|
||||
|
||||
public void purgeOldUsers() {
|
||||
massUpdateLock.lock();
|
||||
mcMMO.p.getLogger().info("Purging inactive users older than " + (mcMMO.p.getPurgeTime() / 2630000000L) + " months...");
|
||||
logger.info("Purging inactive users older than " + (mcMMO.p.getPurgeTime() / 2630000000L) + " months...");
|
||||
|
||||
Connection connection = null;
|
||||
Statement statement = null;
|
||||
@@ -196,7 +216,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
massUpdateLock.unlock();
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Purged " + purged + " users from the database.");
|
||||
logger.info("Purged " + purged + " users from the database.");
|
||||
}
|
||||
|
||||
public boolean removeUser(String playerName, UUID uuid) {
|
||||
@@ -212,7 +232,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
"JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) " +
|
||||
"JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) " +
|
||||
"JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) " +
|
||||
"WHERE u.user = ?");
|
||||
"WHERE u.`user` = ?");
|
||||
|
||||
statement.setString(1, playerName);
|
||||
|
||||
@@ -227,7 +247,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
if (success) {
|
||||
if(uuid != null)
|
||||
if (uuid != null)
|
||||
cleanupUser(uuid);
|
||||
|
||||
Misc.profileCleanup(playerName);
|
||||
@@ -253,7 +273,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
if (id == -1) {
|
||||
id = newUser(connection, profile.getPlayerName(), profile.getUniqueId());
|
||||
if (id == -1) {
|
||||
mcMMO.p.getLogger().severe("Failed to create new account for " + profile.getPlayerName());
|
||||
logger.severe("Failed to create new account for " + profile.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -263,7 +283,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
success &= (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update last login for " + profile.getPlayerName());
|
||||
logger.severe("Failed to update last login for " + profile.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -271,7 +291,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
||||
+ ", archery = ?, swords = ?, axes = ?, acrobatics = ?"
|
||||
+ ", fishing = ?, alchemy = ?, total = ? WHERE user_id = ?");
|
||||
+ ", fishing = ?, alchemy = ?, crossbows = ?, tridents = ?, maces = ?, total = ? WHERE user_id = ?");
|
||||
statement.setInt(1, profile.getSkillLevel(PrimarySkillType.TAMING));
|
||||
statement.setInt(2, profile.getSkillLevel(PrimarySkillType.MINING));
|
||||
statement.setInt(3, profile.getSkillLevel(PrimarySkillType.REPAIR));
|
||||
@@ -285,15 +305,18 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
statement.setInt(11, profile.getSkillLevel(PrimarySkillType.ACROBATICS));
|
||||
statement.setInt(12, profile.getSkillLevel(PrimarySkillType.FISHING));
|
||||
statement.setInt(13, profile.getSkillLevel(PrimarySkillType.ALCHEMY));
|
||||
statement.setInt(14, profile.getSkillLevel(PrimarySkillType.CROSSBOWS));
|
||||
statement.setInt(15, profile.getSkillLevel(PrimarySkillType.TRIDENTS));
|
||||
statement.setInt(16, profile.getSkillLevel(PrimarySkillType.MACES));
|
||||
int total = 0;
|
||||
for (PrimarySkillType primarySkillType : SkillTools.NON_CHILD_SKILLS)
|
||||
total += profile.getSkillLevel(primarySkillType);
|
||||
statement.setInt(14, total);
|
||||
statement.setInt(15, id);
|
||||
statement.setInt(17, total);
|
||||
statement.setInt(18, id);
|
||||
success &= (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update skills for " + profile.getPlayerName());
|
||||
logger.severe("Failed to update skills for " + profile.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -301,7 +324,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||
+ ", unarmed = ?, herbalism = ?, excavation = ?"
|
||||
+ ", archery = ?, swords = ?, axes = ?, acrobatics = ?"
|
||||
+ ", fishing = ?, alchemy = ? WHERE user_id = ?");
|
||||
+ ", fishing = ?, alchemy = ?, crossbows = ?, tridents = ?, maces = ? WHERE user_id = ?");
|
||||
statement.setInt(1, profile.getSkillXpLevel(PrimarySkillType.TAMING));
|
||||
statement.setInt(2, profile.getSkillXpLevel(PrimarySkillType.MINING));
|
||||
statement.setInt(3, profile.getSkillXpLevel(PrimarySkillType.REPAIR));
|
||||
@@ -315,18 +338,22 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
statement.setInt(11, profile.getSkillXpLevel(PrimarySkillType.ACROBATICS));
|
||||
statement.setInt(12, profile.getSkillXpLevel(PrimarySkillType.FISHING));
|
||||
statement.setInt(13, profile.getSkillXpLevel(PrimarySkillType.ALCHEMY));
|
||||
statement.setInt(14, id);
|
||||
statement.setInt(14, profile.getSkillXpLevel(PrimarySkillType.CROSSBOWS));
|
||||
statement.setInt(15, profile.getSkillXpLevel(PrimarySkillType.TRIDENTS));
|
||||
statement.setInt(16, profile.getSkillXpLevel(PrimarySkillType.MACES));
|
||||
statement.setInt(17, id);
|
||||
success &= (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update experience for " + profile.getPlayerName());
|
||||
logger.severe("Failed to update experience for " + profile.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "cooldowns SET "
|
||||
+ " mining = ?, woodcutting = ?, unarmed = ?"
|
||||
+ ", herbalism = ?, excavation = ?, swords = ?"
|
||||
+ ", axes = ?, blast_mining = ?, chimaera_wing = ? WHERE user_id = ?");
|
||||
+ ", axes = ?, blast_mining = ?, chimaera_wing = ?, crossbows = ?"
|
||||
+ ", tridents = ?, maces = ? WHERE user_id = ?");
|
||||
statement.setLong(1, profile.getAbilityDATS(SuperAbilityType.SUPER_BREAKER));
|
||||
statement.setLong(2, profile.getAbilityDATS(SuperAbilityType.TREE_FELLER));
|
||||
statement.setLong(3, profile.getAbilityDATS(SuperAbilityType.BERSERK));
|
||||
@@ -336,11 +363,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
statement.setLong(7, profile.getAbilityDATS(SuperAbilityType.SKULL_SPLITTER));
|
||||
statement.setLong(8, profile.getAbilityDATS(SuperAbilityType.BLAST_MINING));
|
||||
statement.setLong(9, profile.getUniqueData(UniqueDataType.CHIMAERA_WING_DATS));
|
||||
statement.setInt(10, id);
|
||||
statement.setLong(10, profile.getAbilityDATS(SuperAbilityType.SUPER_SHOTGUN));
|
||||
statement.setLong(11, profile.getAbilityDATS(SuperAbilityType.TRIDENTS_SUPER_ABILITY));
|
||||
statement.setLong(12, profile.getAbilityDATS(SuperAbilityType.MACES_SUPER_ABILITY));
|
||||
statement.setInt(13, id);
|
||||
success = (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update cooldowns for " + profile.getPlayerName());
|
||||
logger.severe("Failed to update cooldowns for " + profile.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -351,7 +381,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
success = (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update hud settings for " + profile.getPlayerName());
|
||||
logger.severe("Failed to update hud settings for " + profile.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -370,12 +400,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
List<PlayerStat> stats = new ArrayList<>();
|
||||
|
||||
//Fix for a plugin that people are using that is throwing SQL errors
|
||||
if(skill != null && SkillTools.isChildSkill(skill)) {
|
||||
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!");
|
||||
if (skill != null && SkillTools.isChildSkill(skill)) {
|
||||
logger.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);
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement statement = null;
|
||||
@@ -383,7 +412,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
try {
|
||||
connection = getConnection(PoolIdentifier.MISC);
|
||||
statement = connection.prepareStatement("SELECT " + query + ", user FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 AND NOT user = '\\_INVALID\\_OLD\\_USERNAME\\_' ORDER BY " + query + " DESC, user LIMIT ?, ?");
|
||||
statement = connection.prepareStatement("SELECT " + query + ", `user` FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 AND NOT `user` = '\\_INVALID\\_OLD\\_USERNAME\\_' ORDER BY " + query + " DESC, `user` LIMIT ?, ?");
|
||||
statement.setInt(1, (pageNumber * statsPerPage) - statsPerPage);
|
||||
statement.setInt(2, statsPerPage);
|
||||
resultSet = statement.executeQuery();
|
||||
@@ -424,7 +453,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
// Get count of all users with higher skill level than player
|
||||
String sql = "SELECT COUNT(*) AS 'rank' FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
"WHERE user = ?)";
|
||||
"WHERE `user` = ?)";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
statement.setString(1, playerName);
|
||||
@@ -437,7 +466,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
// Ties are settled by alphabetical order
|
||||
sql = "SELECT user, " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||
"AND " + skillName + " = (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
"WHERE user = '" + playerName + "') ORDER BY user";
|
||||
"WHERE `user` = '" + playerName + "') ORDER BY user";
|
||||
|
||||
resultSet.close();
|
||||
statement.close();
|
||||
@@ -460,7 +489,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
"WHERE " + ALL_QUERY_VERSION + " > 0 " +
|
||||
"AND " + ALL_QUERY_VERSION + " > " +
|
||||
"(SELECT " + ALL_QUERY_VERSION + " " +
|
||||
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = ?)";
|
||||
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE `user` = ?)";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
statement.setString(1, playerName);
|
||||
@@ -478,7 +507,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
"WHERE " + ALL_QUERY_VERSION + " > 0 " +
|
||||
"AND " + ALL_QUERY_VERSION + " = " +
|
||||
"(SELECT " + ALL_QUERY_VERSION + " " +
|
||||
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = ?) ORDER BY user";
|
||||
"FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE `user` = ?) ORDER BY user";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
statement.setString(1, playerName);
|
||||
@@ -546,12 +575,13 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
statement = connection.prepareStatement(
|
||||
"UPDATE `" + tablePrefix + "users` "
|
||||
+ "SET user = ? "
|
||||
+ "WHERE user = ?");
|
||||
+ "SET `user` = ? "
|
||||
+ "WHERE `user` = ?");
|
||||
statement.setString(1, "_INVALID_OLD_USERNAME_");
|
||||
statement.setString(2, playerName);
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
|
||||
statement = connection.prepareStatement("INSERT INTO " + tablePrefix + "users (user, uuid, lastlogin) VALUES (?, ?, UNIX_TIMESTAMP())", Statement.RETURN_GENERATED_KEYS);
|
||||
statement.setString(1, playerName);
|
||||
statement.setString(2, uuid != null ? uuid.toString() : null);
|
||||
@@ -560,7 +590,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
resultSet = statement.getGeneratedKeys();
|
||||
|
||||
if (!resultSet.next()) {
|
||||
mcMMO.p.getLogger().severe("Unable to create new user account in DB");
|
||||
logger.severe("Unable to create new user account in DB");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -600,9 +630,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return loadPlayerFromDB(uuid, null);
|
||||
}
|
||||
|
||||
|
||||
private PlayerProfile loadPlayerFromDB(@Nullable UUID uuid, @Nullable String playerName) throws RuntimeException {
|
||||
if(uuid == null && playerName == null) {
|
||||
if (uuid == null && playerName == null) {
|
||||
throw new RuntimeException("Error looking up player, both UUID and playerName are null and one must not be.");
|
||||
}
|
||||
|
||||
@@ -622,17 +651,18 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
writeMissingRows(connection, id);
|
||||
|
||||
statement = connection.prepareStatement(
|
||||
"SELECT "
|
||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
|
||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
|
||||
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, c.chimaera_wing, "
|
||||
+ "h.mobhealthbar, h.scoreboardtips, u.uuid, u.user "
|
||||
"SELECT " +
|
||||
"s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, s.crossbows, s.tridents, s.maces, " +
|
||||
"e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, e.crossbows, e.tridents, e.maces, " +
|
||||
"c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, c.chimaera_wing, c.crossbows, c.tridents, c.maces, " +
|
||||
"h.mobhealthbar, h.scoreboardtips, u.uuid, u.`user` "
|
||||
+ "FROM " + tablePrefix + "users u "
|
||||
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
||||
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
||||
+ "JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) "
|
||||
+ "JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) "
|
||||
+ "WHERE u.id = ?");
|
||||
+ "WHERE u.id = ?"
|
||||
);
|
||||
statement.setInt(1, id);
|
||||
|
||||
resultSet = statement.executeQuery();
|
||||
@@ -640,7 +670,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
if (resultSet.next()) {
|
||||
try {
|
||||
PlayerProfile profile = loadFromResult(playerName, resultSet);
|
||||
String name = resultSet.getString(42); // TODO: Magic Number, make sure it stays updated
|
||||
String name = resultSet.getString(MAGIC_NUMBER); // TODO: Magic Number, make sure it stays updated
|
||||
resultSet.close();
|
||||
statement.close();
|
||||
|
||||
@@ -650,15 +680,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
&& uuid != null) {
|
||||
statement = connection.prepareStatement(
|
||||
"UPDATE `" + tablePrefix + "users` "
|
||||
+ "SET user = ? "
|
||||
+ "WHERE user = ?");
|
||||
+ "SET `user` = ? "
|
||||
+ "WHERE `user` = ?");
|
||||
statement.setString(1, "_INVALID_OLD_USERNAME_");
|
||||
statement.setString(2, name);
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
statement = connection.prepareStatement(
|
||||
"UPDATE `" + tablePrefix + "users` "
|
||||
+ "SET user = ?, uuid = ? "
|
||||
+ "SET `user` = ?, uuid = ? "
|
||||
+ "WHERE id = ?");
|
||||
statement.setString(1, playerName);
|
||||
statement.setString(2, uuid.toString());
|
||||
@@ -706,7 +736,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
||||
+ "JOIN " + tablePrefix + "cooldowns c ON (u.id = c.user_id) "
|
||||
+ "JOIN " + tablePrefix + "huds h ON (u.id = h.user_id) "
|
||||
+ "WHERE u.user = ?");
|
||||
+ "WHERE u.`user` = ?");
|
||||
List<String> usernames = getStoredUsers();
|
||||
int convertedUsers = 0;
|
||||
long startMillis = System.currentTimeMillis();
|
||||
@@ -745,7 +775,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
connection = getConnection(PoolIdentifier.MISC);
|
||||
statement = connection.prepareStatement(
|
||||
"UPDATE `" + tablePrefix + "users` SET "
|
||||
+ " uuid = ? WHERE user = ?");
|
||||
+ " uuid = ? WHERE `user` = ?");
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, userName);
|
||||
statement.execute();
|
||||
@@ -769,7 +799,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
try {
|
||||
connection = getConnection(PoolIdentifier.MISC);
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "users SET uuid = ? WHERE user = ?");
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "users SET uuid = ? WHERE `user` = ?");
|
||||
|
||||
for (Map.Entry<String, UUID> entry : fetchedUUIDs.entrySet()) {
|
||||
statement.setString(1, entry.getValue().toString());
|
||||
@@ -811,7 +841,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
connection = getConnection(PoolIdentifier.MISC);
|
||||
statement = connection.createStatement();
|
||||
resultSet = statement.executeQuery("SELECT user FROM " + tablePrefix + "users");
|
||||
resultSet = statement.executeQuery("SELECT `user` FROM " + tablePrefix + "users");
|
||||
while (resultSet.next()) {
|
||||
users.add(resultSet.getString("user"));
|
||||
}
|
||||
@@ -832,7 +862,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
* Checks that the database structure is present and correct
|
||||
*/
|
||||
private void checkStructure() {
|
||||
|
||||
PreparedStatement statement = null;
|
||||
Statement createStatement = null;
|
||||
ResultSet resultSet = null;
|
||||
@@ -840,27 +869,30 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
try {
|
||||
connection = getConnection(PoolIdentifier.MISC);
|
||||
statement = connection.prepareStatement("SELECT table_name FROM INFORMATION_SCHEMA.TABLES"
|
||||
+ " WHERE table_schema = ?"
|
||||
+ " AND table_name = ?");
|
||||
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
|
||||
statement.setString(2, tablePrefix + "users");
|
||||
String schemaQuery = this.h2 ? "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_name = ?"
|
||||
: "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = ? AND table_name = ?";
|
||||
|
||||
statement = connection.prepareStatement(schemaQuery);
|
||||
|
||||
setStatementQuery(statement, "users");
|
||||
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
if (!resultSet.next()) {
|
||||
createStatement = connection.createStatement();
|
||||
createStatement.executeUpdate("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` ("
|
||||
+ "`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
||||
+ "`user` varchar(40) NOT NULL,"
|
||||
+ "`uuid` varchar(36) NULL DEFAULT NULL,"
|
||||
+ "`lastlogin` int(32) unsigned NOT NULL,"
|
||||
+ "PRIMARY KEY (`id`),"
|
||||
+ "INDEX(`user`(20) ASC),"
|
||||
+ "UNIQUE KEY `uuid` (`uuid`)) DEFAULT CHARSET=" + CHARSET_SQL + " AUTO_INCREMENT=1;");
|
||||
String sql = "CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` (" +
|
||||
"`id` int AUTO_INCREMENT," +
|
||||
"`user` varchar(40) NOT NULL," +
|
||||
"`uuid` varchar(36)," +
|
||||
"`lastlogin` bigint NOT NULL," +
|
||||
"PRIMARY KEY (`id`)," +
|
||||
"INDEX `user_index`(`user`)," +
|
||||
"UNIQUE(`uuid`))";
|
||||
createStatement.executeUpdate(sql);
|
||||
tryClose(createStatement);
|
||||
}
|
||||
tryClose(resultSet);
|
||||
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
|
||||
statement.setString(2, tablePrefix + "huds");
|
||||
setStatementQuery(statement, "huds");
|
||||
resultSet = statement.executeQuery();
|
||||
if (!resultSet.next()) {
|
||||
createStatement = connection.createStatement();
|
||||
@@ -873,8 +905,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
tryClose(createStatement);
|
||||
}
|
||||
tryClose(resultSet);
|
||||
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
|
||||
statement.setString(2, tablePrefix + "cooldowns");
|
||||
setStatementQuery(statement, "cooldowns");
|
||||
resultSet = statement.executeQuery();
|
||||
if (!resultSet.next()) {
|
||||
createStatement = connection.createStatement();
|
||||
@@ -893,13 +924,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`chimaera_wing` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`crossbows` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`tridents` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`maces` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=" + CHARSET_SQL + ";");
|
||||
tryClose(createStatement);
|
||||
}
|
||||
tryClose(resultSet);
|
||||
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
|
||||
statement.setString(2, tablePrefix + "skills");
|
||||
setStatementQuery(statement, "skills");
|
||||
resultSet = statement.executeQuery();
|
||||
if (!resultSet.next()) {
|
||||
String startingLevel = "'" + mcMMO.p.getAdvancedConfig().getStartingLevel() + "'";
|
||||
@@ -920,14 +953,16 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`fishing` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`crossbows` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`tridents` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`maces` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
|
||||
+ "`total` int(10) unsigned NOT NULL DEFAULT "+totalLevel+","
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=" + CHARSET_SQL + ";");
|
||||
tryClose(createStatement);
|
||||
}
|
||||
tryClose(resultSet);
|
||||
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
|
||||
statement.setString(2, tablePrefix + "experience");
|
||||
setStatementQuery(statement, "experience");
|
||||
resultSet = statement.executeQuery();
|
||||
if (!resultSet.next()) {
|
||||
createStatement = connection.createStatement();
|
||||
@@ -946,6 +981,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`fishing` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`crossbows` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "`tridents` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=" + CHARSET_SQL + ";");
|
||||
tryClose(createStatement);
|
||||
@@ -968,7 +1005,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Killing orphans");
|
||||
// TODO: refactor
|
||||
LogUtils.debug(logger, "Killing orphans");
|
||||
createStatement = connection.createStatement();
|
||||
createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "experience` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "experience`.`user_id` = `u`.`id`)");
|
||||
createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "huds` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "huds`.`user_id` = `u`.`id`)");
|
||||
@@ -985,21 +1023,79 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
tryClose(connection);
|
||||
}
|
||||
|
||||
final String skills = "skills";
|
||||
final String crossbows = "crossbows";
|
||||
final String tridents = "tridents";
|
||||
final String maces = "maces";
|
||||
final String experience = "experience";
|
||||
final String cooldowns = "cooldowns";
|
||||
|
||||
updateStructure(skills, crossbows, String.valueOf(32));
|
||||
updateStructure(skills, tridents, String.valueOf(32));
|
||||
updateStructure(skills, maces, String.valueOf(32));
|
||||
|
||||
updateStructure(experience, crossbows, String.valueOf(10));
|
||||
updateStructure(experience, tridents, String.valueOf(10));
|
||||
updateStructure(experience, maces, String.valueOf(10));
|
||||
|
||||
updateStructure(cooldowns, crossbows, String.valueOf(10));
|
||||
updateStructure(cooldowns, tridents, String.valueOf(10));
|
||||
updateStructure(cooldowns, maces, String.valueOf(10));
|
||||
}
|
||||
|
||||
private Connection getConnection(PoolIdentifier identifier) throws SQLException {
|
||||
Connection connection = null;
|
||||
switch (identifier) {
|
||||
case LOAD:
|
||||
connection = loadPool.getConnection();
|
||||
break;
|
||||
case MISC:
|
||||
connection = miscPool.getConnection();
|
||||
break;
|
||||
case SAVE:
|
||||
connection = savePool.getConnection();
|
||||
break;
|
||||
private void updateStructure(String tableName, String columnName, String columnSize) {
|
||||
try (Connection connection = getConnection(PoolIdentifier.MISC)) {
|
||||
if (!columnExists(connection, mcMMO.p.getGeneralConfig().getMySQLDatabaseName(), tablePrefix+tableName, columnName)) {
|
||||
try (Statement createStatement = connection.createStatement()) {
|
||||
// logger.info("[SQLDB Check] Adding column '" + columnName + "' to table '" + tablePrefix + tableName + "'...");
|
||||
String startingLevel = "'" + mcMMO.p.getAdvancedConfig().getStartingLevel() + "'";
|
||||
createStatement.executeUpdate("ALTER TABLE `" + tablePrefix + tableName + "` "
|
||||
+ "ADD COLUMN `" + columnName + "` int(" + columnSize + ") unsigned NOT NULL DEFAULT " + startingLevel);
|
||||
}
|
||||
} else {
|
||||
// logger.info("[SQLDB Check] Column '" + columnName + "' already exists in table '" + tablePrefix + tableName + "', looks good!");
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace(); // Consider more robust logging
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean columnExists(Connection connection, String database, String tableName, String columnName) throws SQLException {
|
||||
// logger.info("[SQLDB Check] Checking if column '" + columnName + "' exists in table '" + tableName + "'");
|
||||
try (Statement createStatement = connection.createStatement()) {
|
||||
String sql = "SELECT `COLUMN_NAME`\n" +
|
||||
"FROM `INFORMATION_SCHEMA`.`COLUMNS`\n" +
|
||||
"WHERE `TABLE_SCHEMA`='" + database + "'\n" +
|
||||
" AND `TABLE_NAME`='" + tableName + "'\n" +
|
||||
" AND `COLUMN_NAME`='" + columnName + "'";
|
||||
var resultSet = createStatement.executeQuery(sql);
|
||||
return resultSet.next();
|
||||
} catch (SQLException e) {
|
||||
logger.info("Failed to check if column exists in table " + tableName + " for column " + columnName);
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setStatementQuery(PreparedStatement statement, String tableName) throws SQLException {
|
||||
if (!this.h2) {
|
||||
// Set schema name for MySQL
|
||||
statement.setString(1, mcMMO.p.getGeneralConfig().getMySQLDatabaseName());
|
||||
statement.setString(2, tablePrefix + tableName);
|
||||
} else {
|
||||
// For H2, the schema parameter is not needed
|
||||
statement.setString(1, tablePrefix + tableName);
|
||||
}
|
||||
}
|
||||
|
||||
Connection getConnection(PoolIdentifier identifier) throws SQLException {
|
||||
Connection connection = switch (identifier) {
|
||||
case LOAD -> loadPool.getConnection();
|
||||
case MISC -> miscPool.getConnection();
|
||||
case SAVE -> savePool.getConnection();
|
||||
};
|
||||
if (connection == null) {
|
||||
throw new RuntimeException("getConnection() for " + identifier.name().toLowerCase(Locale.ENGLISH) + " pool timed out. Increase max connections settings.");
|
||||
}
|
||||
@@ -1012,8 +1108,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
* @param upgrade Upgrade to attempt to apply
|
||||
*/
|
||||
private void checkDatabaseStructure(Connection connection, UpgradeType upgrade) {
|
||||
// TODO: Rewrite / Refactor
|
||||
if (!mcMMO.getUpgradeManager().shouldUpgrade(upgrade)) {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Skipping " + upgrade.name() + " upgrade (unneeded)");
|
||||
LogUtils.debug(logger, "Skipping " + upgrade.name() + " upgrade (unneeded)");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1126,15 +1223,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
Map<PrimarySkillType, Float> skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP
|
||||
Map<SuperAbilityType, Integer> skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown
|
||||
Map<UniqueDataType, Integer> uniqueData = new EnumMap<>(UniqueDataType.class); //Chimaera wing cooldown and other misc info
|
||||
MobHealthbarType mobHealthbarType;
|
||||
UUID uuid;
|
||||
int scoreboardTipsShown;
|
||||
|
||||
final int OFFSET_SKILLS = 0; // TODO update these numbers when the query
|
||||
// changes (a new skill is added)
|
||||
final int OFFSET_XP = 13;
|
||||
final int OFFSET_DATS = 26;
|
||||
final int OFFSET_OTHER = 39;
|
||||
final int OFFSET_XP = 16;
|
||||
final int OFFSET_DATS = 29;
|
||||
final int OFFSET_OTHER = 42;
|
||||
|
||||
skills.put(PrimarySkillType.TAMING, result.getInt(OFFSET_SKILLS + 1));
|
||||
skills.put(PrimarySkillType.MINING, result.getInt(OFFSET_SKILLS + 2));
|
||||
@@ -1149,6 +1245,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
skills.put(PrimarySkillType.ACROBATICS, result.getInt(OFFSET_SKILLS + 11));
|
||||
skills.put(PrimarySkillType.FISHING, result.getInt(OFFSET_SKILLS + 12));
|
||||
skills.put(PrimarySkillType.ALCHEMY, result.getInt(OFFSET_SKILLS + 13));
|
||||
skills.put(PrimarySkillType.CROSSBOWS, result.getInt(OFFSET_SKILLS + 14));
|
||||
skills.put(PrimarySkillType.TRIDENTS, result.getInt(OFFSET_SKILLS + 15));
|
||||
skills.put(PrimarySkillType.MACES, result.getInt(OFFSET_SKILLS + 16));
|
||||
|
||||
skillsXp.put(PrimarySkillType.TAMING, result.getFloat(OFFSET_XP + 1));
|
||||
skillsXp.put(PrimarySkillType.MINING, result.getFloat(OFFSET_XP + 2));
|
||||
@@ -1163,6 +1262,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
skillsXp.put(PrimarySkillType.ACROBATICS, result.getFloat(OFFSET_XP + 11));
|
||||
skillsXp.put(PrimarySkillType.FISHING, result.getFloat(OFFSET_XP + 12));
|
||||
skillsXp.put(PrimarySkillType.ALCHEMY, result.getFloat(OFFSET_XP + 13));
|
||||
skillsXp.put(PrimarySkillType.CROSSBOWS, result.getFloat(OFFSET_XP + 14));
|
||||
skillsXp.put(PrimarySkillType.TRIDENTS, result.getFloat(OFFSET_XP + 15));
|
||||
skillsXp.put(PrimarySkillType.MACES, result.getFloat(OFFSET_XP + 16));
|
||||
|
||||
// Taming - Unused - result.getInt(OFFSET_DATS + 1)
|
||||
skillsDATS.put(SuperAbilityType.SUPER_BREAKER, result.getInt(OFFSET_DATS + 2));
|
||||
@@ -1171,12 +1273,16 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
skillsDATS.put(SuperAbilityType.BERSERK, result.getInt(OFFSET_DATS + 5));
|
||||
skillsDATS.put(SuperAbilityType.GREEN_TERRA, result.getInt(OFFSET_DATS + 6));
|
||||
skillsDATS.put(SuperAbilityType.GIGA_DRILL_BREAKER, result.getInt(OFFSET_DATS + 7));
|
||||
skillsDATS.put(SuperAbilityType.EXPLOSIVE_SHOT, result.getInt(OFFSET_DATS + 8));
|
||||
// Archery - Unused - result.getInt(OFFSET_DATS + 8)
|
||||
skillsDATS.put(SuperAbilityType.SERRATED_STRIKES, result.getInt(OFFSET_DATS + 9));
|
||||
skillsDATS.put(SuperAbilityType.SKULL_SPLITTER, result.getInt(OFFSET_DATS + 10));
|
||||
// Acrobatics - Unused - result.getInt(OFFSET_DATS + 11)
|
||||
skillsDATS.put(SuperAbilityType.BLAST_MINING, result.getInt(OFFSET_DATS + 12));
|
||||
uniqueData.put(UniqueDataType.CHIMAERA_WING_DATS, result.getInt(OFFSET_DATS + 13));
|
||||
skillsDATS.put(SuperAbilityType.SUPER_SHOTGUN, result.getInt(OFFSET_DATS + 14));
|
||||
skillsDATS.put(SuperAbilityType.TRIDENTS_SUPER_ABILITY, result.getInt(OFFSET_DATS + 15));
|
||||
skillsDATS.put(SuperAbilityType.MACES_SUPER_ABILITY, result.getInt(OFFSET_DATS + 16));
|
||||
|
||||
try {
|
||||
scoreboardTipsShown = result.getInt(OFFSET_OTHER + 2);
|
||||
@@ -1196,17 +1302,21 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
private void printErrors(SQLException ex) {
|
||||
if (debug) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
ex.printStackTrace();
|
||||
|
||||
StackTraceElement element = ex.getStackTrace()[0];
|
||||
mcMMO.p.getLogger().severe("Location: " + element.getClassName() + " " + element.getMethodName() + " " + element.getLineNumber());
|
||||
mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage());
|
||||
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
|
||||
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
|
||||
// logger.severe("SQLException: " + ex.getMessage());
|
||||
logger.severe("SQLState: " + ex.getSQLState());
|
||||
logger.severe("VendorError: " + ex.getErrorCode());
|
||||
|
||||
// Handling SQLException chain
|
||||
SQLException nextException = ex.getNextException();
|
||||
while (nextException != null) {
|
||||
logger.severe("Caused by: " + nextException.getMessage());
|
||||
nextException = nextException.getNextException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DatabaseType getDatabaseType() {
|
||||
return DatabaseType.SQL;
|
||||
}
|
||||
@@ -1222,7 +1332,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return;
|
||||
}
|
||||
resultSet.close();
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables to drop name uniqueness...");
|
||||
logger.info("Updating mcMMO MySQL tables to drop name uniqueness...");
|
||||
statement.execute("ALTER TABLE `" + tablePrefix + "users` "
|
||||
+ "DROP INDEX `user`,"
|
||||
+ "ADD INDEX `user` (`user`(20) ASC)");
|
||||
@@ -1240,7 +1350,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_ALCHEMY);
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Alchemy...");
|
||||
logger.info("Updating mcMMO MySQL tables for Alchemy...");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD `alchemy` int(10) NOT NULL DEFAULT '0'");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "experience` ADD `alchemy` int(10) NOT NULL DEFAULT '0'");
|
||||
}
|
||||
@@ -1252,7 +1362,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_BLAST_MINING_COOLDOWN);
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Blast Mining...");
|
||||
logger.info("Updating mcMMO MySQL tables for Blast Mining...");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0'");
|
||||
}
|
||||
}
|
||||
@@ -1263,7 +1373,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_UNIQUE_PLAYER_DATA);
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Chimaera Wing...");
|
||||
logger.info("Updating mcMMO MySQL tables for Chimaera Wing...");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "cooldowns` ADD `chimaera_wing` int(32) NOT NULL DEFAULT '0'");
|
||||
}
|
||||
}
|
||||
@@ -1274,7 +1384,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_FISHING);
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Fishing...");
|
||||
logger.info("Updating mcMMO MySQL tables for Fishing...");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0'");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0'");
|
||||
}
|
||||
@@ -1286,7 +1396,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_MOB_HEALTHBARS);
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for mob healthbars...");
|
||||
logger.info("Updating mcMMO MySQL tables for mob healthbars...");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` ADD `mobhealthbar` varchar(50) NOT NULL DEFAULT '" + mcMMO.p.getGeneralConfig().getMobHealthbarDefault() + "'");
|
||||
}
|
||||
}
|
||||
@@ -1297,7 +1407,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.ADD_SCOREBOARD_TIPS);
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for scoreboard tips...");
|
||||
logger.info("Updating mcMMO MySQL tables for scoreboard tips...");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` ADD `scoreboardtips` int(10) NOT NULL DEFAULT '0' ;");
|
||||
}
|
||||
}
|
||||
@@ -1310,7 +1420,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
resultSet.last();
|
||||
|
||||
if (resultSet.getRow() != SkillTools.NON_CHILD_SKILLS.size()) {
|
||||
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
|
||||
logger.info("Indexing tables, this may take a while on larger databases");
|
||||
|
||||
for (PrimarySkillType skill : SkillTools.NON_CHILD_SKILLS) {
|
||||
String skill_name = skill.name().toLowerCase(Locale.ENGLISH);
|
||||
@@ -1351,7 +1461,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
if (!column_exists) {
|
||||
mcMMO.p.getLogger().info("Adding UUIDs to mcMMO MySQL user table...");
|
||||
logger.info("Adding UUIDs to mcMMO MySQL user table...");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` ADD `uuid` varchar(36) NULL DEFAULT NULL");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` ADD UNIQUE INDEX `uuid` (`uuid`) USING BTREE");
|
||||
|
||||
@@ -1420,7 +1530,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
if (column_exists) {
|
||||
mcMMO.p.getLogger().info("Removing party name from users table...");
|
||||
logger.info("Removing party name from users table...");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party`");
|
||||
}
|
||||
|
||||
@@ -1454,7 +1564,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
if (!column_exists) {
|
||||
mcMMO.p.getLogger().info("Adding skill total column to skills table...");
|
||||
logger.info("Adding skill total column to skills table...");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD COLUMN `total` int NOT NULL DEFAULT '0'");
|
||||
statement.executeUpdate("UPDATE `" + tablePrefix + "skills` SET `total` = (taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy)");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_total` (`total`) USING BTREE");
|
||||
@@ -1490,7 +1600,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
if (column_exists) {
|
||||
mcMMO.p.getLogger().info("Removing Spout HUD type from huds table...");
|
||||
logger.info("Removing Spout HUD type from huds table...");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` DROP COLUMN `hudtype`");
|
||||
}
|
||||
|
||||
@@ -1515,7 +1625,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
statement = connection.prepareStatement("SELECT id, user FROM " + tablePrefix + "users WHERE uuid = ? OR (uuid IS NULL AND user = ?)");
|
||||
statement = connection.prepareStatement("SELECT id, `user` FROM " + tablePrefix + "users WHERE uuid = ? OR (uuid IS NULL AND `user` = ?)");
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, playerName);
|
||||
resultSet = statement.executeQuery();
|
||||
@@ -1544,7 +1654,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
statement = connection.prepareStatement("SELECT id, user FROM " + tablePrefix + "users WHERE user = ?");
|
||||
statement = connection.prepareStatement("SELECT id, `user` FROM " + tablePrefix + "users WHERE `user` = ?");
|
||||
statement.setString(1, playerName);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
@@ -1577,7 +1687,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
LogUtils.debug(mcMMO.p.getLogger(), "Releasing connection pool resource...");
|
||||
LogUtils.debug(logger, "Releasing connection pool resource...");
|
||||
miscPool.close();
|
||||
loadPool.close();
|
||||
savePool.close();
|
||||
@@ -1619,19 +1729,19 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
*/
|
||||
|
||||
//Alter users table
|
||||
mcMMO.p.getLogger().info("SQL Converting tables from latin1 to utf8mb4");
|
||||
logger.info("SQL Converting tables from latin1 to utf8mb4");
|
||||
|
||||
//Update "user" column
|
||||
try {
|
||||
mcMMO.p.getLogger().info("Updating user column to new encoding");
|
||||
logger.info("Updating user column to new encoding");
|
||||
statement.executeUpdate(getUpdateUserInUsersTableSQLQuery());
|
||||
|
||||
//Update "uuid" column
|
||||
mcMMO.p.getLogger().info("Updating user column to new encoding");
|
||||
logger.info("Updating user column to new encoding");
|
||||
statement.executeUpdate(getUpdateUUIDInUsersTableSQLQuery());
|
||||
|
||||
//Update "mobhealthbar" column
|
||||
mcMMO.p.getLogger().info("Updating mobhealthbar column to new encoding");
|
||||
logger.info("Updating mobhealthbar column to new encoding");
|
||||
statement.executeUpdate(getUpdateMobHealthBarInHudsTableSQLQuery());
|
||||
|
||||
mcMMO.getUpgradeManager().setUpgradeCompleted(UpgradeType.SQL_CHARSET_UTF8MB4);
|
||||
@@ -1645,7 +1755,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
private String getUpdateUserInUsersTableSQLQuery() {
|
||||
return "ALTER TABLE\n" +
|
||||
" " + tablePrefix + "users\n" +
|
||||
" CHANGE user user\n" +
|
||||
" CHANGE `user` user\n" +
|
||||
" " + USER_VARCHAR + "\n" +
|
||||
" CHARACTER SET utf8mb4\n" +
|
||||
" COLLATE utf8mb4_unicode_ci;";
|
||||
@@ -1670,4 +1780,28 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
" CHARACTER SET utf8mb4\n" +
|
||||
" COLLATE utf8mb4_unicode_ci;";
|
||||
}
|
||||
|
||||
public void printAllTablesWithColumns(Connection connection) {
|
||||
try {
|
||||
DatabaseMetaData metaData = connection.getMetaData();
|
||||
String[] types = {"TABLE"};
|
||||
ResultSet tables = metaData.getTables(null, null, "%", types);
|
||||
|
||||
while (tables.next()) {
|
||||
String tableName = tables.getString("TABLE_NAME");
|
||||
System.out.println("Table: " + tableName);
|
||||
|
||||
ResultSet columns = metaData.getColumns(null, null, tableName, "%");
|
||||
while (columns.next()) {
|
||||
String columnName = columns.getString("COLUMN_NAME");
|
||||
String columnType = columns.getString("TYPE_NAME");
|
||||
System.out.println(" Column: " + columnName + " Type: " + columnType);
|
||||
}
|
||||
columns.close();
|
||||
}
|
||||
tables.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class FlatFileDataBuilder {
|
||||
}
|
||||
|
||||
public @NotNull FlatFileDataContainer build() {
|
||||
if(dataFlags.contains(FlatFileDataFlag.BAD_VALUES)) {
|
||||
if (dataFlags.contains(FlatFileDataFlag.BAD_VALUES)) {
|
||||
return new BadCategorizedFlatFileData(uniqueProcessingId, dataFlags, splitStringData, badDataValues);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ import static com.gmail.nossr50.database.FlatFileDatabaseManager.*;
|
||||
public class FlatFileDataUtil {
|
||||
|
||||
public static @Nullable String[] getPreparedSaveDataLine(@NotNull FlatFileDataContainer dataContainer) {
|
||||
if(dataContainer.getDataFlags() == null) {
|
||||
if (dataContainer.getDataFlags() == null) {
|
||||
return dataContainer.getSplitData();
|
||||
}
|
||||
|
||||
//Data of this type is not salvageable
|
||||
//TODO: Test that we ignore the things we are supposed to ignore
|
||||
//TODO: Should we even keep track of the bad data or just not even build data containers for it? Making containers for it is only really useful for debugging.. well I suppose operations are typically async so it shouldn't matter
|
||||
if(dataContainer.getDataFlags().contains(FlatFileDataFlag.CORRUPTED_OR_UNRECOGNIZABLE)
|
||||
if (dataContainer.getDataFlags().contains(FlatFileDataFlag.CORRUPTED_OR_UNRECOGNIZABLE)
|
||||
|| dataContainer.getDataFlags().contains(FlatFileDataFlag.DUPLICATE_UUID) //For now we will not try to fix any issues with UUIDs
|
||||
|| dataContainer.getDataFlags().contains(FlatFileDataFlag.BAD_UUID_DATA) //For now we will not try to fix any issues with UUIDs
|
||||
|| dataContainer.getDataFlags().contains(FlatFileDataFlag.TOO_INCOMPLETE)) {
|
||||
@@ -29,7 +29,7 @@ public class FlatFileDataUtil {
|
||||
/*
|
||||
* First fix the bad data values if they exist
|
||||
*/
|
||||
if(dataContainer instanceof BadCategorizedFlatFileData badData) {
|
||||
if (dataContainer instanceof BadCategorizedFlatFileData badData) {
|
||||
splitData = repairBadData(dataContainer.getSplitData(), badData.getBadDataIndexes());
|
||||
} else {
|
||||
splitData = dataContainer.getSplitData();
|
||||
@@ -42,7 +42,7 @@ public class FlatFileDataUtil {
|
||||
|
||||
public static @NotNull String[] repairBadData(@NotNull String[] splitData, boolean[] badDataValues) {
|
||||
for(int i = 0; i < FlatFileDatabaseManager.DATA_ENTRY_COUNT; i++) {
|
||||
if(badDataValues[i]) {
|
||||
if (badDataValues[i]) {
|
||||
//This data value was marked as bad so we zero initialize it
|
||||
splitData[i] = getZeroInitialisedData(i, 0);
|
||||
}
|
||||
@@ -56,60 +56,29 @@ public class FlatFileDataUtil {
|
||||
* @return the "zero" initialized data corresponding to the index
|
||||
*/
|
||||
public static @NotNull String getZeroInitialisedData(int index, int startingLevel) throws IndexOutOfBoundsException {
|
||||
switch(index) {
|
||||
case USERNAME_INDEX:
|
||||
return LEGACY_INVALID_OLD_USERNAME; //We'll keep using this value for legacy compatibility reasons (not sure if needed but don't care)
|
||||
case 2: //Assumption: Used to be for something, no longer used
|
||||
case 3: //Assumption: Used to be for something, no longer used
|
||||
case 23: //Assumption: Used to be used for something, no longer used
|
||||
case 33: //Assumption: Used to be used for something, no longer used
|
||||
case LEGACY_LAST_LOGIN:
|
||||
case HEALTHBAR:
|
||||
return "IGNORED";
|
||||
case SKILLS_MINING:
|
||||
case SKILLS_REPAIR:
|
||||
case SKILLS_UNARMED:
|
||||
case SKILLS_HERBALISM:
|
||||
case SKILLS_EXCAVATION:
|
||||
case SKILLS_ARCHERY:
|
||||
case SKILLS_SWORDS:
|
||||
case SKILLS_AXES:
|
||||
case SKILLS_WOODCUTTING:
|
||||
case SKILLS_ACROBATICS:
|
||||
case SKILLS_TAMING:
|
||||
case SKILLS_FISHING:
|
||||
case SKILLS_ALCHEMY:
|
||||
return String.valueOf(startingLevel);
|
||||
case OVERHAUL_LAST_LOGIN:
|
||||
return String.valueOf(-1L);
|
||||
case COOLDOWN_BERSERK:
|
||||
case COOLDOWN_GIGA_DRILL_BREAKER:
|
||||
case COOLDOWN_TREE_FELLER:
|
||||
case COOLDOWN_GREEN_TERRA:
|
||||
case COOLDOWN_SERRATED_STRIKES:
|
||||
case COOLDOWN_SKULL_SPLITTER:
|
||||
case COOLDOWN_SUPER_BREAKER:
|
||||
case COOLDOWN_BLAST_MINING:
|
||||
case SCOREBOARD_TIPS:
|
||||
case COOLDOWN_CHIMAERA_WING:
|
||||
case EXP_MINING:
|
||||
case EXP_WOODCUTTING:
|
||||
case EXP_REPAIR:
|
||||
case EXP_UNARMED:
|
||||
case EXP_HERBALISM:
|
||||
case EXP_EXCAVATION:
|
||||
case EXP_ARCHERY:
|
||||
case EXP_SWORDS:
|
||||
case EXP_AXES:
|
||||
case EXP_ACROBATICS:
|
||||
case EXP_TAMING:
|
||||
case EXP_FISHING:
|
||||
case EXP_ALCHEMY:
|
||||
return "0";
|
||||
case UUID_INDEX:
|
||||
throw new IndexOutOfBoundsException(); //TODO: Add UUID recovery? Might not even be worth it.
|
||||
}
|
||||
//TODO: Add UUID recovery? Might not even be worth it.
|
||||
return switch (index) {
|
||||
case USERNAME_INDEX ->
|
||||
LEGACY_INVALID_OLD_USERNAME; //We'll keep using this value for legacy compatibility reasons (not sure if needed but don't care)
|
||||
//Assumption: Used to be for something, no longer used
|
||||
//Assumption: Used to be for something, no longer used
|
||||
//Assumption: Used to be used for something, no longer used
|
||||
//Assumption: Used to be used for something, no longer used
|
||||
case 2, 3, 23, 33, LEGACY_LAST_LOGIN, HEALTHBAR -> "IGNORED";
|
||||
case SKILLS_MINING, SKILLS_REPAIR, SKILLS_UNARMED, SKILLS_HERBALISM, SKILLS_EXCAVATION, SKILLS_ARCHERY,
|
||||
SKILLS_SWORDS, SKILLS_AXES, SKILLS_WOODCUTTING, SKILLS_ACROBATICS, SKILLS_TAMING, SKILLS_FISHING,
|
||||
SKILLS_ALCHEMY, SKILLS_CROSSBOWS, SKILLS_TRIDENTS, SKILLS_MACES -> String.valueOf(startingLevel);
|
||||
case OVERHAUL_LAST_LOGIN -> String.valueOf(-1L);
|
||||
case COOLDOWN_BERSERK, COOLDOWN_GIGA_DRILL_BREAKER, COOLDOWN_TREE_FELLER, COOLDOWN_GREEN_TERRA,
|
||||
COOLDOWN_SERRATED_STRIKES, COOLDOWN_SKULL_SPLITTER, COOLDOWN_SUPER_BREAKER, COOLDOWN_BLAST_MINING,
|
||||
COOLDOWN_SUPER_SHOTGUN, COOLDOWN_TRIDENTS, COOLDOWN_ARCHERY, COOLDOWN_MACES, SCOREBOARD_TIPS, COOLDOWN_CHIMAERA_WING,
|
||||
EXP_MINING, EXP_WOODCUTTING, EXP_REPAIR, EXP_UNARMED, EXP_HERBALISM, EXP_EXCAVATION, EXP_ARCHERY,
|
||||
EXP_SWORDS, EXP_AXES, EXP_ACROBATICS, EXP_TAMING, EXP_FISHING, EXP_ALCHEMY, EXP_CROSSBOWS,
|
||||
EXP_TRIDENTS, EXP_MACES -> "0";
|
||||
case UUID_INDEX ->
|
||||
throw new IndexOutOfBoundsException(); //TODO: Add UUID recovery? Might not even be worth it.
|
||||
default -> throw new IndexOutOfBoundsException();
|
||||
};
|
||||
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,56 +25,56 @@ public class LevelUpBroadcastPredicate<T extends CommandSender> implements Predi
|
||||
Player broadcastingPlayer = (Player) broadcaster; //Always a player no need to check cast
|
||||
|
||||
//Broadcaster should be online
|
||||
if(!broadcastingPlayer.isOnline()) {
|
||||
if (!broadcastingPlayer.isOnline()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
McMMOPlayer mmoBroadcastingPlayer = UserManager.getPlayer(broadcastingPlayer);
|
||||
|
||||
if(mmoBroadcastingPlayer == null) {
|
||||
if (mmoBroadcastingPlayer == null) {
|
||||
//This should never be null, but just in case...
|
||||
mcMMO.p.getLogger().severe("McMMOPlayer was null for broadcaster in LevelUpBroadcastPredicate when it should never be null!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(t instanceof Player listeningPlayer) {
|
||||
if (t instanceof Player listeningPlayer) {
|
||||
|
||||
//Party Member Check
|
||||
if(mcMMO.p.getGeneralConfig().isLevelUpBroadcastsPartyMembersOnly()) {
|
||||
if (mcMMO.p.getGeneralConfig().isLevelUpBroadcastsPartyMembersOnly()) {
|
||||
McMMOPlayer mmoListeningPlayer = UserManager.getPlayer(listeningPlayer);
|
||||
|
||||
if(mmoListeningPlayer == null) {
|
||||
if (mmoListeningPlayer == null) {
|
||||
return false; //No profile so therefor no party
|
||||
}
|
||||
|
||||
Party playerWhoLeveledParty = mmoBroadcastingPlayer.getParty();
|
||||
Party broadcastRecipientParty = mmoListeningPlayer.getParty();
|
||||
|
||||
if(playerWhoLeveledParty == null || broadcastRecipientParty == null) {
|
||||
if (playerWhoLeveledParty == null || broadcastRecipientParty == null) {
|
||||
return false; //No party on either player when being in the same party is required
|
||||
}
|
||||
|
||||
if(!playerWhoLeveledParty.equals(broadcastRecipientParty)) {
|
||||
if (!playerWhoLeveledParty.equals(broadcastRecipientParty)) {
|
||||
return false; //Not in the same party when it is required
|
||||
}
|
||||
}
|
||||
|
||||
//Same world check
|
||||
if(isLevelUpBroadcastsSameWorldOnly()) {
|
||||
if(!mmoBroadcastingPlayer.getPlayer().getWorld().equals(listeningPlayer.getWorld())) {
|
||||
if (isLevelUpBroadcastsSameWorldOnly()) {
|
||||
if (!mmoBroadcastingPlayer.getPlayer().getWorld().equals(listeningPlayer.getWorld())) {
|
||||
return false; //Not in the same world when its required
|
||||
}
|
||||
|
||||
//Distance checks
|
||||
if(mcMMO.p.getGeneralConfig().shouldLevelUpBroadcastsRestrictDistance()) {
|
||||
if(!Misc.isNear(mmoBroadcastingPlayer.getPlayer().getLocation(), listeningPlayer.getLocation(), mcMMO.p.getGeneralConfig().getLevelUpBroadcastRadius())) {
|
||||
if (mcMMO.p.getGeneralConfig().shouldLevelUpBroadcastsRestrictDistance()) {
|
||||
if (!Misc.isNear(mmoBroadcastingPlayer.getPlayer().getLocation(), listeningPlayer.getLocation(), mcMMO.p.getGeneralConfig().getLevelUpBroadcastRadius())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Visibility checks
|
||||
if(!listeningPlayer.canSee(mmoBroadcastingPlayer.getPlayer()) && listeningPlayer != mmoBroadcastingPlayer.getPlayer()) {
|
||||
if (!listeningPlayer.canSee(mmoBroadcastingPlayer.getPlayer()) && listeningPlayer != mmoBroadcastingPlayer.getPlayer()) {
|
||||
return false; //Player who leveled should be invisible to this player so don't send the message
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user